Exemplo n.º 1
0
        /** スクロール作成。
         */
        public void CreateScroll(int a_layer, Fee.JsonItem.JsonItem a_parent_jsonitem)
        {
            this.DeleteScroll(a_layer);

            Fee.Ui.Scroll <JsonViewer_Item> t_scroll = Fee.Ui.Scroll <JsonViewer_Item> .Create(null, DrawPriority, Fee.Ui.Scroll_Type.Vertical, JsonViewer_Item.GetH());

            {
                t_scroll.SetRect(100 + this.scroll.Count * (JsonViewer_Item.GetW() + 2), 100, JsonViewer_Item.GetW(), Fee.Render2D.Config.VIRTUAL_H - 200);

                switch (a_parent_jsonitem.GetValueType())
                {
                case Fee.JsonItem.ValueType.AssociativeArray:
                {
                    if (a_parent_jsonitem.GetListMax() == 0)
                    {
                        JsonViewer_Item t_scrollitem = new JsonViewer_Item("リストが空", this, this.scroll.Count, null);
                        t_scroll.PushItem(t_scrollitem);
                    }
                    else
                    {
                        foreach (string t_key_string in a_parent_jsonitem.GetAssociativeKeyList())
                        {
                            JsonViewer_Item t_scrollitem = new JsonViewer_Item(t_key_string, this, this.scroll.Count, a_parent_jsonitem.GetItem(t_key_string));
                            t_scroll.PushItem(t_scrollitem);
                        }
                    }
                } break;

                case Fee.JsonItem.ValueType.IndexArray:
                {
                    if (a_parent_jsonitem.GetListMax() == 0)
                    {
                        JsonViewer_Item t_scrollitem = new JsonViewer_Item("リストが空", this, this.scroll.Count, null);
                        t_scroll.PushItem(t_scrollitem);
                    }
                    else
                    {
                        for (int ii = 0; ii < a_parent_jsonitem.GetListMax(); ii++)
                        {
                            JsonViewer_Item t_scrollitem = new JsonViewer_Item("[" + ii.ToString() + "]", this, this.scroll.Count, a_parent_jsonitem.GetItem(ii));
                            t_scroll.PushItem(t_scrollitem);
                        }
                    }
                } break;

                default:
                {
                    JsonViewer_Item t_scrollitem = new JsonViewer_Item("", this, this.scroll.Count, a_parent_jsonitem);
                    t_scroll.PushItem(t_scrollitem);
                } break;
                }
            }
            this.scroll.Add(t_scroll);
        }
        /** Get
         */
        public static System.Type Get(Fee.JsonItem.JsonItem a_jsonitem)
        {
            System.Type t_type = null;

            switch (a_jsonitem.GetValueType())
            {
            case ValueType.Null:
            {
                //値型が不明なので値型はSystem.Objectにする。
                t_type = typeof(System.Object);
            } break;

            case ValueType.AssociativeArray:
            {
                //値型が不明なので値型はSystem.Objectにする。
                t_type = typeof(System.Collections.Generic.Dictionary <string, System.Object>);
            } break;

            case ValueType.IndexArray:
            {
                //値型が不明なので値型はSystem.Objectにする。
                t_type = typeof(System.Collections.Generic.List <System.Object>);
            } break;

            case ValueType.StringData:
            {
                t_type = typeof(System.String);
            } break;

            case ValueType.SignedNumber:
            {
                t_type = JsonItem.GetSignedNumberType();
            } break;

            case ValueType.UnsignedNumber:
            {
                t_type = JsonItem.GetUnsignedNumberType();
            } break;

            case ValueType.FloatingNumber:
            {
                t_type = JsonItem.GetFloatingNumberType();
            } break;

            case ValueType.BoolData:
            {
                t_type = typeof(System.Boolean);
            } break;

            case ValueType.DecimalNumber:
            {
                t_type = typeof(System.Decimal);
            } break;

            case ValueType.BinaryData:
            {
                t_type = typeof(System.Collections.Generic.List <byte>);
            } break;

            default:
            {
                Tool.Assert(false);
            } break;
            }

            return(t_type);
        }
Exemplo n.º 3
0
        /** constructor
         */
        public JsonViewer_Item(string a_label, JsonViewer a_viewer, int a_layer, Fee.JsonItem.JsonItem a_jsonitem)
        {
            //deleter
            this.deleter = new Fee.Deleter.Deleter();

            //viewer
            this.viewer = a_viewer;

            //layer
            this.layer = a_layer;

            //jsonitem
            this.jsonitem = a_jsonitem;

            string t_text;

            UnityEngine.Color t_color = UnityEngine.Color.black;
            {
                if (a_jsonitem == null)
                {
                    t_text = a_label;
                }
                else
                {
                    //親がインデックス配列ならインデックス、連想配列ならキー名。
                    t_text = "label = " + a_label + "\n";

                    //データタイプ名。
                    t_text += a_jsonitem.GetValueType().ToString() + "\n";

                    //データ。
                    switch (a_jsonitem.GetValueType())
                    {
                    case Fee.JsonItem.ValueType.AssociativeArray:
                    {
                        t_text += "count = " + a_jsonitem.GetListMax().ToString() + "\n";
                        t_color = new UnityEngine.Color(0.2f, 0.3f, 0.2f, 1.0f);
                    } break;

                    case Fee.JsonItem.ValueType.IndexArray:
                    {
                        t_text += "count = " + a_jsonitem.GetListMax().ToString() + "\n";
                        t_color = new UnityEngine.Color(0.4f, 0.2f, 0.5f, 1.0f);
                    } break;

                    case Fee.JsonItem.ValueType.BoolData:
                    {
                        t_text += "value = " + a_jsonitem.GetBoolData().ToString() + "\n";
                        t_color = new UnityEngine.Color(0.1f, 0.2f, 0.4f, 1.0f);
                    } break;

                    case Fee.JsonItem.ValueType.SignedNumber:
                    {
                        t_text += "value = " + a_jsonitem.GetSignedNumber().ToString() + "\n";
                        t_color = new UnityEngine.Color(0.5f, 0.2f, 0.8f, 1.0f);
                    } break;

                    case Fee.JsonItem.ValueType.UnsignedNumber:
                    {
                        t_text += "value = " + a_jsonitem.GetUnsignedNumber().ToString() + "\n";
                        t_color = new UnityEngine.Color(0.4f, 0.6f, 0.3f, 1.0f);
                    } break;

                    case Fee.JsonItem.ValueType.FloatingNumber:
                    {
                        t_text += "value = " + a_jsonitem.GetFloatingNumber().ToString() + "\n";
                        t_color = new UnityEngine.Color(0.2f, 0.2f, 0.5f, 1.0f);
                    } break;

                    case Fee.JsonItem.ValueType.DecimalNumber:
                    {
                        t_text += "value = " + a_jsonitem.GetDecimalNumber().ToString() + "\n";
                        t_color = new UnityEngine.Color(0.1f, 0.1f, 0.1f, 1.0f);
                    } break;

                    case Fee.JsonItem.ValueType.StringData:
                    {
                        t_text += "value = " + a_jsonitem.GetStringData() + "\n";
                        t_color = new UnityEngine.Color(0.5f, 0.2f, 0.2f, 1.0f);
                    } break;
                    }
                }
            }

            //text
            this.text = Fee.Render2D.Text2D.Create(this.deleter, 0);
            this.text.SetText(t_text);
            this.text.SetAlignmentType(Fee.Render2D.Text2D_HorizontalAlignmentType.Left, Fee.Render2D.Text2D_VerticalAlignmentType.Top);
            this.text.SetColor(in t_color);
            this.text.SetClip(true);
            this.text.SetVisible(false);

            //button
            this.button = Fee.Ui.Button.Create(this.deleter, 0);
            this.button.SetNormalTexture(UnityEngine.Texture2D.whiteTexture);
            this.button.SetOnTexture(UnityEngine.Texture2D.whiteTexture);
            this.button.SetDownTexture(UnityEngine.Texture2D.whiteTexture);
            this.button.SetLockTexture(UnityEngine.Texture2D.whiteTexture);
            this.button.SetNormalColor(0.8f, 0.8f, 0.8f, 1.0f);
            this.button.SetOnColor(0.7f, 0.7f, 0.7f, 1.0f);
            this.button.SetDownColor(0.6f, 0.6f, 0.6f, 1.0f);
            this.button.SetLockColor(0.5f, 0.5f, 0.5f, 1.0f);
            this.button.SetOnButtonClick(this, -1);
            this.button.SetClip(true);
            this.button.SetVisible(false);
            this.button.SetDragCancelFlag(true);
        }