示例#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);
        }
示例#2
0
        /** Create
         */
        public static void Create(ref System.Object a_to_ref_object, System.Type a_to_type, Fee.JsonItem.JsonItem a_from_jsonitem)
        {
            switch (a_to_type.FullName)
            {
            case "System." + nameof(System.Char):
            case "System." + nameof(System.SByte):
            case "System." + nameof(System.Byte):
            case "System." + nameof(System.Int16):
            case "System." + nameof(System.UInt16):
            case "System." + nameof(System.Int32):
            case "System." + nameof(System.UInt32):
            case "System." + nameof(System.Int64):
            case "System." + nameof(System.UInt64):
            case "System." + nameof(System.Single):
            case "System." + nameof(System.Double):
            case "System." + nameof(System.Boolean):
            case "System." + nameof(System.Decimal):
            case "System." + nameof(System.String):
            case "System." + nameof(System.Object):
            {
                return;
            } break;

            default:
            {
                if (a_from_jsonitem.IsNull() == true)
                {
                    //NULL処理。
                    return;
                }
                else
                {
                    if (a_to_type.IsArray == true)
                    {
                        //[]

                        int t_list_count = 0;
                        if (a_from_jsonitem.IsIndexArray() == true)
                        {
                            t_list_count = a_from_jsonitem.GetListMax();
                        }

                        try{
                            System.Type t_element_type = a_to_type.GetElementType();
                            a_to_ref_object = System.Array.CreateInstance(t_element_type, t_list_count);
                            return;
                        }catch (System.Exception t_exception) {
                            Tool.DebugReThrow(t_exception);
                        }
                    }
                    else
                    {
                        //インスタンス。
                        try{
                            a_to_ref_object = System.Activator.CreateInstance(a_to_type);
                            return;
                        }catch (System.Exception t_exception) {
                            //引数なしconstructorの呼び出しに失敗。
                            //UnityEngine.Object系は[Fee.JsonItem.Ignore]を指定して除外するべき。
                            Tool.DebugReThrow(t_exception);
                        }
                    }
                }

                //失敗。
                Tool.Assert(false);
                return;
            } break;
            }
        }
示例#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);
        }