Beispiel #1
0
        public ColorElement(PropertyFieldWrapper memberInfo, object item, IList <Color> array = null, int index = -1) : base(memberInfo, item, (IList)array)
        {
            if (array != null)
            {
                drawLabel = false;
                height    = 30;
                c         = new ColorObject(array, index);
            }
            else
            {
                height = 30;
                c      = new ColorObject(memberInfo, item);
            }

            int order = 0;

            foreach (PropertyFieldWrapper variable in ConfigManager.GetFieldsAndProperties(c))
            {
                var wrapped = UIModConfig.WrapIt(this, ref height, variable, c, order++);

                if (array != null)
                {
                    wrapped.Item1.Left.Pixels  -= 20;
                    wrapped.Item1.Width.Pixels += 20;
                }
            }
        }
Beispiel #2
0
        public override void OnBind()
        {
            base.OnBind();
            colorList = (IList <Color>)list;
            if (colorList != null)
            {
                drawLabel = false;
                height    = 30;
                c         = new ColorObject(colorList, index);
            }
            else
            {
                height = 30;
                c      = new ColorObject(memberInfo, item);
            }

            int order = 0;

            foreach (PropertyFieldWrapper variable in ConfigManager.GetFieldsAndProperties(c))
            {
                var wrapped = UIModConfig.WrapIt(this, ref height, variable, c, order++);

                if (colorList != null)
                {
                    wrapped.Item1.Left.Pixels  -= 20;
                    wrapped.Item1.Width.Pixels += 20;
                }
            }
        }
Beispiel #3
0
        public override void OnBind()
        {
            base.OnBind();
            colorList = (IList <Color>)list;
            if (colorList != null)
            {
                drawLabel = false;
                height    = 30;
                c         = new ColorObject(colorList, index);
            }
            else
            {
                height = 30;
                c      = new ColorObject(memberInfo, item);
            }

            // TODO: Draw the sliders in the same manner as vanilla.
            var  colorHSLSliderAttribute = ConfigManager.GetCustomAttribute <ColorHSLSliderAttribute>(memberInfo, item, list);
            bool useHue = colorHSLSliderAttribute != null;
            bool showSaturationAndLightness = colorHSLSliderAttribute?.showSaturationAndLightness ?? false;
            bool noAlpha = ConfigManager.GetCustomAttribute <ColorNoAlphaAttribute>(memberInfo, item, list) != null;

            List <string> skip = new List <string>();

            if (noAlpha)
            {
                skip.Add(nameof(ColorObject.A));
            }
            if (useHue)
            {
                skip.AddRange(new[] { nameof(ColorObject.R), nameof(ColorObject.G), nameof(ColorObject.B) });
            }
            else
            {
                skip.AddRange(new[] { nameof(ColorObject.Hue), nameof(ColorObject.Saturation), nameof(ColorObject.Lightness) });
            }
            if (useHue && !showSaturationAndLightness)
            {
                skip.AddRange(new[] { nameof(ColorObject.Saturation), nameof(ColorObject.Lightness) });
            }

            int order = 0;

            foreach (PropertyFieldWrapper variable in ConfigManager.GetFieldsAndProperties(c))
            {
                if (skip.Contains(variable.Name))
                {
                    continue;
                }

                var wrapped = UIModConfig.WrapIt(this, ref height, variable, c, order++);

                if (colorList != null)
                {
                    wrapped.Item1.Left.Pixels  -= 20;
                    wrapped.Item1.Width.Pixels += 20;
                }
            }
        }
Beispiel #4
0
        protected override void SetupList()
        {
            dataList.Clear();
            Array array = memberInfo.GetValue(item) as Array;
            int   count = array.Length;
            int   top   = 0;

            for (int i = 0; i < count; i++)
            {
                int index = i;
                UIModConfig.WrapIt(dataList, ref top, memberInfo, item, 0, data, itemType, index);
            }
        }
Beispiel #5
0
        public override void OnBind()
        {
            base.OnBind();
            vector2List = (IList <Vector2>)list;
            if (vector2List != null)
            {
                drawLabel = false;
                height    = 30;
                c         = new Vector2Object(vector2List, index);
            }
            else
            {
                height = 30;
                c      = new Vector2Object(memberInfo, item);
            }

            if (rangeAttribute != null && rangeAttribute.min is float && rangeAttribute.max is float)
            {
                max = (float)rangeAttribute.max;
                min = (float)rangeAttribute.min;
            }
            if (incrementAttribute != null && incrementAttribute.increment is float)
            {
                increment = (float)incrementAttribute.increment;
            }

            int order = 0;

            foreach (PropertyFieldWrapper variable in ConfigManager.GetFieldsAndProperties(c))
            {
                var wrapped = UIModConfig.WrapIt(this, ref height, variable, c, order++);

                // Can X and Y inherit range and increment automatically? Pass in "fake PropertyFieldWrapper" to achieve? Real one desired for label.
                if (wrapped.Item2 is FloatElement floatElement)
                {
                    floatElement.min       = min;
                    floatElement.max       = max;
                    floatElement.increment = increment;
                    floatElement.drawTicks = Attribute.IsDefined(memberInfo.MemberInfo, typeof(DrawTicksAttribute));
                }

                if (vector2List != null)
                {
                    wrapped.Item1.Left.Pixels  -= 20;
                    wrapped.Item1.Width.Pixels += 20;
                }
            }
        }
Beispiel #6
0
        protected override void SetupList()
        {
            dataList.Clear();
            int top = 0;

            dataWrapperList = new List <ISetElementWrapper>();

            Type genericType = typeof(SetElementWrapper <>).MakeGenericType(setType);

            if (data != null)
            {
                var valuesEnumerator = ((IEnumerable)data).GetEnumerator();

                int i = 0;
                while (valuesEnumerator.MoveNext())
                {
                    ISetElementWrapper proxy = (ISetElementWrapper)Activator.CreateInstance(genericType,
                                                                                            new object[] { valuesEnumerator.Current, (object)data });
                    dataWrapperList.Add(proxy);

                    var wrappermemberInfo = ConfigManager.GetFieldsAndProperties(this).ToList()[0];
                    int index             = i;
                    var wrapped           = UIModConfig.WrapIt(dataList, ref top, wrappermemberInfo, this, 0, dataWrapperList, genericType, i);
                    wrapped.Item2.Left.Pixels  += 24;
                    wrapped.Item2.Width.Pixels -= 24;

                    // Add delete button.
                    UIModConfigHoverImage deleteButton = new UIModConfigHoverImage(deleteTexture, "Remove");
                    deleteButton.VAlign = 0.5f;

                    // fix delete.
                    object o = valuesEnumerator.Current;                     // needed for closure?
                    deleteButton.OnClick += (a, b) => {
                        var removeMethod = data.GetType().GetMethods().FirstOrDefault(m => m.Name == "Remove");
                        removeMethod.Invoke(data, new object[] { o });
                        SetupList();
                        Interface.modConfig.SetPendingChanges();
                    };
                    wrapped.Item1.Append(deleteButton);

                    i++;
                }
            }
        }
Beispiel #7
0
        private void SetupList()
        {
            dataList.Clear();

            object data = _GetValue();

            if (data != null)
            {
                if (separatePage && !ignoreSeparatePage)
                {
                    separatePagePanel = UIModConfig.MakeSeparateListPanel(item, data, memberInfo, array, index, AbridgedTextDisplayFunction);
                }
                else
                {
                    int order = 0;
                    foreach (PropertyFieldWrapper variable in ConfigManager.GetFieldsAndProperties(data))
                    {
                        if (Attribute.IsDefined(variable.MemberInfo, typeof(JsonIgnoreAttribute)))
                        {
                            continue;
                        }

                        int             top    = 0;
                        HeaderAttribute header = ConfigManager.GetCustomAttribute <HeaderAttribute>(variable, null, null);
                        if (header != null)
                        {
                            var wrapper = new PropertyFieldWrapper(typeof(HeaderAttribute).GetProperty(nameof(HeaderAttribute.Header)));
                            UIModConfig.WrapIt(dataList, ref top, wrapper, header, order++);
                        }
                        var wrapped = UIModConfig.WrapIt(dataList, ref top, variable, data, order++);
                        if (array != null)
                        {
                            //wrapped.Item1.Left.Pixels -= 20;
                            wrapped.Item1.Width.Pixels += 20;
                        }
                        else
                        {
                            //wrapped.Item1.Left.Pixels += 20;
                            //wrapped.Item1.Width.Pixels -= 20;
                        }
                    }
                }
            }
        }
Beispiel #8
0
        protected override void SetupList()
        {
            dataList.Clear();
            int top = 0;

            if (data != null)
            {
                for (int i = 0; i < ((IList)data).Count; i++)
                {
                    int index   = i;
                    var wrapped = UIModConfig.WrapIt(dataList, ref top, memberInfo, item, 0, data, listType, index);

                    wrapped.Item2.Left.Pixels  += 24;
                    wrapped.Item2.Width.Pixels -= 30;

                    // Add delete button.
                    UIModConfigHoverImage deleteButton = new UIModConfigHoverImage(deleteTexture, "Remove");
                    deleteButton.VAlign   = 0.5f;
                    deleteButton.OnClick += (a, b) => { ((IList)data).RemoveAt(index); SetupList(); Interface.modConfig.SetPendingChanges(); };
                    wrapped.Item1.Append(deleteButton);
                }
            }
        }
        protected override void SetupList()
        {
            dataList.Clear();
            int top = 0;

            dataWrapperList = new List <IDictionaryElementWrapper>();

            //var genericListType = typeof(List<>);
            //var specificListType = genericListType.MakeGenericType(typeof(double));
            //var list = Activator.CreateInstance(specificListType);

            //var listType = typeof(List<>);
            //var constructedListType = listType.MakeGenericType(keyType);
            //var keyList = (IList)Activator.CreateInstance(constructedListType);

            //foreach (var item in ((IDictionary)data))
            //{
            //	//var wrapped = UIModConfig.WrapIt(dataList, ref top, memberInfo, item, ref sliderID, keys, keyType, i2);
            //	keyList.Add(item);
            //	//i2++;
            //}
            //((IDictionary)data).

            //string elementTypeName = Console.ReadLine();
            //Type elementType = Type.GetType(elementTypeName);
            //Type[] types = new Type[] { elementType };

            //Type listType = memberInfo.Type.GetGenericArguments()[0];
            //Type listType = typeof(Dictionary<>);
            //Type genericType = listType.MakeGenericType(types);
            //IProxy proxy = (IProxy)Activator.CreateInstance(genericType);

            //Type genericType = typeof(Dictionary<,>).MakeGenericType(keyType, valueType);
            Type genericType = typeof(DictionaryElementWrapper <,>).MakeGenericType(keyType, valueType);

            if (data != null)
            {
                var keys             = ((IDictionary)data).Keys;
                var values           = ((IDictionary)data).Values;
                var keysEnumerator   = keys.GetEnumerator();
                var valuesEnumerator = values.GetEnumerator();
                int i = 0;
                while (keysEnumerator.MoveNext())
                {
                    valuesEnumerator.MoveNext();
                    //var wrapper = new UIModConfigDictionaryElementWrapper<typeof(keysEnumerator.Current), typeof(keysEnumerator.Current)>(keysEnumerator.Current, valuesEnumerator.Current, this);
                    //dynamic sampleObject = new ExpandoObject();
                    //sampleObject.key = keysEnumerator.Current;
                    //sampleObject.value = valuesEnumerator.Current;
                    //var wrapperwrapper = new UIModConfigDictionaryElementWrapperWrapper(sampleObject);

                    IDictionaryElementWrapper proxy = (IDictionaryElementWrapper)Activator.CreateInstance(genericType,
                                                                                                          new object[] { keysEnumerator.Current, valuesEnumerator.Current, (IDictionary)data });
                    dataWrapperList.Add(proxy);
                    //var v = new { Key = keysEnumerator.Current, Value = valuesEnumerator.Current };

                    //dataWrapperList.Add(wrapper);
                    //}

                    //var wrapperwrapper = new UIModConfigDictionaryElementWrapperWrapper(v);

                    //	var keys = ((IDictionary)data).Keys.ToList();
                    //var values = ((IDictionary)data).Values.ToList();
                    //for (int i = 0; i < ((IDictionary)data).Count; i++)
                    //{
                    //((IDictionary)data).
                    //	int index = i;
                    //((IDictionary)data).
                    //Type tupleType = typeof(Tuple<,>);
                    //	var wrapper = new UIModConfigDictionaryElementWrapper(((IDictionary)data)[], , this);
                    Type itemType          = memberInfo.Type.GetGenericArguments()[0];
                    var  wrappermemberInfo = ConfigManager.GetFieldsAndProperties(this).ToList()[0];
                    int  index             = i;
                    var  wrapped           = UIModConfig.WrapIt(dataList, ref top, wrappermemberInfo, this, 0, dataWrapperList, genericType, i);          // TODO: Sometime key is below value for some reason. IntFloatDictionary.
                    //var wrapped = UIModConfig.WrapIt(dataList, ref top, wrappermemberInfo, wrapperwrapper, ref sliderID);
                    // save wrap, pre save check?
                    wrapped.Item2.Left.Pixels  += 24;
                    wrapped.Item2.Width.Pixels -= 24;

                    // Add delete button.
                    UIModConfigHoverImage deleteButton = new UIModConfigHoverImage(deleteTexture, "Remove");
                    deleteButton.VAlign = 0.5f;

                    // fix delete.
                    object o = keysEnumerator.Current;
                    deleteButton.OnClick += (a, b) => {
                        ((IDictionary)data).Remove(o);
                        SetupList();
                        Interface.modConfig.SetPendingChanges();
                    };
                    wrapped.Item1.Append(deleteButton);

                    i++;
                }
            }
        }
Beispiel #10
0
        bool AllowNull => array == null;         // nulls don't make sense for a collection, but a standalone might be useful. NonNull attribute might be nice.

        // Label:
        //  Members
        //  Members
        public ObjectElement(PropertyFieldWrapper memberInfo, object item, IList array = null, int index = -1, bool ignoreSeparatePage = false) : base(memberInfo, item, array)
        {
            this.index = index;
            this.ignoreSeparatePage = ignoreSeparatePage;
            _GetValue = () => memberInfo.GetValue(this.item);
            _SetValue = (object value) => {
                if (!memberInfo.CanWrite)
                {
                    return;
                }
                memberInfo.SetValue(this.item, value);
            };

            if (array != null)
            {
                _GetValue = () => array[index];
                _SetValue = (object value) => { array[index] = value; Interface.modConfig.SetPendingChanges(); };
                // TODO: only do this if ToString is overriden.

                var  listType    = memberInfo.Type.GetGenericArguments()[0];
                bool hasToString = listType.GetMethod("ToString", new Type[0]).DeclaringType != typeof(object);

                if (hasToString)
                {
                    _TextDisplayFunction        = () => index + 1 + ": " + (array[index]?.ToString() ?? "null");
                    AbridgedTextDisplayFunction = () => (array[index]?.ToString() ?? "null");
                }
                else
                {
                    _TextDisplayFunction = () => index + 1 + ": ";
                }
            }
            else
            {
                bool hasToString = memberInfo.Type.GetMethod("ToString", new Type[0]).DeclaringType != typeof(object);
                if (hasToString)
                {
                    _TextDisplayFunction        = () => (labelAttribute == null ? memberInfo.Name : labelAttribute.Label) + (_GetValue() == null ? "" : ": " + _GetValue().ToString());
                    AbridgedTextDisplayFunction = () => _GetValue()?.ToString() ?? "";
                }
            }

            if (_GetValue() == null && !AllowNull)
            {
                object data = Activator.CreateInstance(memberInfo.Type);
                JsonConvert.PopulateObject("{}", data, ConfigManager.serializerSettings);
                //JsonDefaultValueAttribute jsonDefaultValueAttribute = (JsonDefaultValueAttribute)Attribute.GetCustomAttribute(memberInfo.MemberInfo, typeof(JsonDefaultValueAttribute));
                //if (jsonDefaultValueAttribute != null)
                //{
                //	JsonConvert.PopulateObject(jsonDefaultValueAttribute.json, subitem, ConfigManager.serializerSettings);
                //}
                _SetValue(data);
            }

            separatePage = ConfigManager.GetCustomAttribute <SeparatePageAttribute>(memberInfo, item, array) != null;
            //separatePage = separatePage && !ignoreSeparatePage;
            //separatePage = (SeparatePageAttribute)Attribute.GetCustomAttribute(memberInfo.MemberInfo, typeof(SeparatePageAttribute)) != null;
            if (separatePage && !ignoreSeparatePage)
            {
                // TODO: UITextPanel doesn't update...
                separatePageButton = new UITextPanel <FuncStringWrapper>(new FuncStringWrapper()
                {
                    func = _TextDisplayFunction
                });
                separatePageButton.HAlign = 0.5f;
                //e.Recalculate();
                //elementHeight = (int)e.GetOuterDimensions().Height;
                separatePageButton.OnClick += (a, c) => {
                    UIModConfig.SwitchToSubConfig(this.separatePagePanel);

                    /*	Interface.modConfig.uIElement.RemoveChild(Interface.modConfig.configPanelStack.Peek());
                     *      Interface.modConfig.uIElement.Append(separateListPanel);
                     *      Interface.modConfig.configPanelStack.Push(separateListPanel);*/
                    //separateListPanel.SetScrollbar(Interface.modConfig.uIScrollbar);

                    //UIPanel panel = new UIPanel();
                    //panel.Width.Set(200, 0);
                    //panel.Height.Set(200, 0);
                    //panel.Left.Set(200, 0);
                    //panel.Top.Set(200, 0);
                    //Interface.modConfig.Append(panel);

                    //Interface.modConfig.subMenu.Enqueue(subitem);
                    //Interface.modConfig.DoMenuModeState();
                };
                //e = new UIText($"{memberInfo.Name} click for more ({type.Name}).");
                //e.OnClick += (a, b) => { };
            }

            //data = _GetValue();// memberInfo.GetValue(this.item);
            //drawLabel = false;

            dataList = new NestedUIList();
            dataList.Width.Set(-14, 1f);
            dataList.Left.Set(14, 0f);
            dataList.Height.Set(-30, 1f);
            dataList.Top.Set(30, 0);
            dataList.ListPadding = 5f;
            Append(dataList);

            //string name = memberInfo.Name;
            //if (labelAttribute != null)
            //{
            //	name = labelAttribute.Label;
            //}
            if (array == null)
            {
                // drawLabel = false; TODO uncomment
            }

            initializeButton              = new UIModConfigHoverImage(playTexture, "Initialize");
            initializeButton.Top.Pixels  += 4;
            initializeButton.Left.Pixels -= 3;
            initializeButton.HAlign       = 1f;
            initializeButton.OnClick     += (a, b) => {
                Main.PlaySound(21);
                object data = Activator.CreateInstance(memberInfo.Type);
                // Crashes JSONItem
                JsonConvert.PopulateObject("{}", data, ConfigManager.serializerSettings);                 // Seems to fail on all data structures?

                //JsonDefaultValueAttribute jsonDefaultValueAttribute = (JsonDefaultValueAttribute)Attribute.GetCustomAttribute(memberInfo.MemberInfo, typeof(JsonDefaultValueAttribute));
                //if (jsonDefaultValueAttribute != null)
                //{
                //	JsonConvert.PopulateObject(jsonDefaultValueAttribute.json, subitem, ConfigManager.serializerSettings);
                //}

                _SetValue(data);

                //SeparatePageAttribute here?

                pendingChanges = true;
                //RemoveChild(initializeButton);
                //Append(deleteButton);
                //Append(expandButton);

                SetupList();
                Interface.modConfig.RecalculateChildren();
                Interface.modConfig.SetPendingChanges();
            };

            expandButton = new UIModConfigHoverImage(expandedTexture, "Expand");
            expandButton.Top.Set(4, 0f);             // 10, -25: 4, -52
            expandButton.Left.Set(-52, 1f);
            expandButton.OnClick += (a, b) => {
                expanded       = !expanded;
                pendingChanges = true;
            };

            deleteButton = new UIModConfigHoverImage(deleteTexture, "Clear");
            deleteButton.Top.Set(4, 0f);
            deleteButton.Left.Set(-25, 1f);
            deleteButton.OnClick += (a, b) => {
                _SetValue(null);
                pendingChanges = true;

                SetupList();
                //Interface.modConfig.RecalculateChildren();
                Interface.modConfig.SetPendingChanges();
            };

            if (_GetValue() != null)
            {
                //Append(expandButton);
                //Append(deleteButton);
                SetupList();
            }
            else
            {
                Append(initializeButton);
                //sortedContainer.Append(initializeButton);
            }

            pendingChanges = true;
            Recalculate();
        }
Beispiel #11
0
        public override void OnBind()
        {
            base.OnBind();

            if (list != null)
            {
                // TODO: only do this if ToString is overriden.

                var  listType    = memberInfo.Type.GetGenericArguments()[0];
                bool hasToString = listType.GetMethod("ToString", new Type[0]).DeclaringType != typeof(object);

                if (hasToString)
                {
                    TextDisplayFunction         = () => index + 1 + ": " + (list[index]?.ToString() ?? "null");
                    AbridgedTextDisplayFunction = () => (list[index]?.ToString() ?? "null");
                }
                else
                {
                    TextDisplayFunction = () => index + 1 + ": ";
                }
            }
            else
            {
                bool hasToString = memberInfo.Type.GetMethod("ToString", new Type[0]).DeclaringType != typeof(object);
                if (hasToString)
                {
                    TextDisplayFunction         = () => (labelAttribute == null ? memberInfo.Name : labelAttribute.Label) + (Value == null ? "" : ": " + Value.ToString());
                    AbridgedTextDisplayFunction = () => Value?.ToString() ?? "";
                }
            }

            // Null values without AllowNullAttribute aren't allowed, but could happen with modder mistakes, so not automatically populating will hint to modder the issue.
            if (Value == null && list != null)
            {
                // This should never actually happen, but I guess a bad Json file could.
                object data = Activator.CreateInstance(memberInfo.Type);
                string json = jsonDefaultValueAttribute?.json ?? "{}";
                JsonConvert.PopulateObject(json, data, ConfigManager.serializerSettings);
                Value = data;
            }

            separatePage = ConfigManager.GetCustomAttribute <SeparatePageAttribute>(memberInfo, item, list) != null;
            //separatePage = separatePage && !ignoreSeparatePage;
            //separatePage = (SeparatePageAttribute)Attribute.GetCustomAttribute(memberInfo.MemberInfo, typeof(SeparatePageAttribute)) != null;
            if (separatePage && !ignoreSeparatePage)
            {
                // TODO: UITextPanel doesn't update...
                separatePageButton = new UITextPanel <FuncStringWrapper>(new FuncStringWrapper()
                {
                    func = TextDisplayFunction
                });
                separatePageButton.HAlign = 0.5f;
                //e.Recalculate();
                //elementHeight = (int)e.GetOuterDimensions().Height;
                separatePageButton.OnClick += (a, c) => {
                    UIModConfig.SwitchToSubConfig(this.separatePagePanel);

                    /*	Interface.modConfig.uIElement.RemoveChild(Interface.modConfig.configPanelStack.Peek());
                     *      Interface.modConfig.uIElement.Append(separateListPanel);
                     *      Interface.modConfig.configPanelStack.Push(separateListPanel);*/
                    //separateListPanel.SetScrollbar(Interface.modConfig.uIScrollbar);

                    //UIPanel panel = new UIPanel();
                    //panel.Width.Set(200, 0);
                    //panel.Height.Set(200, 0);
                    //panel.Left.Set(200, 0);
                    //panel.Top.Set(200, 0);
                    //Interface.modConfig.Append(panel);

                    //Interface.modConfig.subMenu.Enqueue(subitem);
                    //Interface.modConfig.DoMenuModeState();
                };
                //e = new UIText($"{memberInfo.Name} click for more ({type.Name}).");
                //e.OnClick += (a, b) => { };
            }

            //data = _GetValue();// memberInfo.GetValue(this.item);
            //drawLabel = false;

            dataList = new NestedUIList();
            dataList.Width.Set(-14, 1f);
            dataList.Left.Set(14, 0f);
            dataList.Height.Set(-30, 1f);
            dataList.Top.Set(30, 0);
            dataList.ListPadding = 5f;
            Append(dataList);

            //string name = memberInfo.Name;
            //if (labelAttribute != null)
            //{
            //	name = labelAttribute.Label;
            //}
            if (list == null)
            {
                // drawLabel = false; TODO uncomment
            }

            initializeButton              = new UIModConfigHoverImage(playTexture, "Initialize");
            initializeButton.Top.Pixels  += 4;
            initializeButton.Left.Pixels -= 3;
            initializeButton.HAlign       = 1f;
            initializeButton.OnClick     += (a, b) => {
                SoundEngine.PlaySound(21);
                object data = Activator.CreateInstance(memberInfo.Type);
                string json = jsonDefaultValueAttribute?.json ?? "{}";
                JsonConvert.PopulateObject(json, data, ConfigManager.serializerSettings);
                Value = data;

                //SeparatePageAttribute here?

                pendingChanges = true;
                //RemoveChild(initializeButton);
                //Append(deleteButton);
                //Append(expandButton);

                SetupList();
                Interface.modConfig.RecalculateChildren();
                Interface.modConfig.SetPendingChanges();
            };

            expandButton = new UIModConfigHoverImage(expandedTexture, "Expand");
            expandButton.Top.Set(4, 0f);             // 10, -25: 4, -52
            expandButton.Left.Set(-52, 1f);
            expandButton.OnClick += (a, b) => {
                expanded       = !expanded;
                pendingChanges = true;
            };

            deleteButton = new UIModConfigHoverImage(deleteTexture, "Clear");
            deleteButton.Top.Set(4, 0f);
            deleteButton.Left.Set(-25, 1f);
            deleteButton.OnClick += (a, b) => {
                Value          = null;
                pendingChanges = true;

                SetupList();
                //Interface.modConfig.RecalculateChildren();
                Interface.modConfig.SetPendingChanges();
            };

            if (Value != null)
            {
                //Append(expandButton);
                //Append(deleteButton);
                SetupList();
            }
            else
            {
                Append(initializeButton);
                //sortedContainer.Append(initializeButton);
            }

            pendingChanges = true;
            Recalculate();
        }