Beispiel #1
0
        public override void OnBind()
        {
            base.OnBind();
            Height.Set(30f, 0f);

            //itemChoice = new UIModConfigItemDefinitionChoice(_GetValue()?.GetID() ?? 0, 0.5f);
            itemChoice = new ItemDefinitionOptionElement(Value, 0.5f);
            itemChoice.Top.Set(2f, 0f);
            itemChoice.Left.Set(-30, 1f);
            itemChoice.OnClick += (a, b) =>
            {
                itemSelectionExpanded = !itemSelectionExpanded;
                updateNeeded          = true;
            };
            Append(itemChoice);

            chooserPanel = new UIPanel();
            chooserPanel.Top.Set(30, 0);
            chooserPanel.Height.Set(200, 0);
            chooserPanel.Width.Set(0, 1);
            chooserPanel.BackgroundColor = Color.CornflowerBlue;

            UIPanel textBoxBackgroundA = new UIPanel();

            textBoxBackgroundA.Width.Set(160, 0f);
            textBoxBackgroundA.Height.Set(30, 0f);
            textBoxBackgroundA.Top.Set(-6, 0);
            textBoxBackgroundA.PaddingTop    = 0;
            textBoxBackgroundA.PaddingBottom = 0;
            chooserFilter = new UIFocusInputTextField("Filter by Name");
            chooserFilter.OnTextChange += (a, b) =>
            {
                updateNeeded = true;
            };
            chooserFilter.OnRightClick += (a, b) => chooserFilter.SetText("");
            chooserFilter.Width         = StyleDimension.Fill;
            chooserFilter.Height.Set(-6, 1f);
            chooserFilter.Top.Set(6, 0f);
            textBoxBackgroundA.Append(chooserFilter);
            chooserPanel.Append(textBoxBackgroundA);

            UIPanel textBoxBackgroundB = new UIPanel();

            textBoxBackgroundB.CopyStyle(textBoxBackgroundA);
            textBoxBackgroundB.Left.Set(180, 0);
            chooserFilterMod = new UIFocusInputTextField("Filter by Mod");
            chooserFilterMod.OnTextChange += (a, b) =>
            {
                updateNeeded = true;
            };
            chooserFilterMod.OnRightClick += (a, b) => chooserFilterMod.SetText("");
            chooserFilterMod.Width         = StyleDimension.Fill;
            chooserFilterMod.Height.Set(-6, 1f);
            chooserFilterMod.Top.Set(6, 0f);
            textBoxBackgroundB.Append(chooserFilterMod);
            chooserPanel.Append(textBoxBackgroundB);

            chooserGrid = new NestedUIGrid();
            chooserGrid.Top.Set(30, 0);
            chooserGrid.Height.Set(-30, 1);
            chooserGrid.Width.Set(-12, 1);
            chooserPanel.Append(chooserGrid);

            UIScrollbar scrollbar = new UIScrollbar();

            scrollbar.SetView(100f, 1000f);
            scrollbar.Height.Set(-30f, 1f);
            scrollbar.Top.Set(30f, 0f);
            scrollbar.Left.Pixels += 8;
            scrollbar.HAlign       = 1f;
            chooserGrid.SetScrollbar(scrollbar);
            chooserPanel.Append(scrollbar);
            //Append(chooserPanel);

            UIModConfigHoverImageSplit upDownButton = new UIModConfigHoverImageSplit(upDownTexture, "Zoom in", "Zoom out");

            upDownButton.Recalculate();
            upDownButton.Top.Set(-4f, 0f);
            upDownButton.Left.Set(-18, 1f);
            upDownButton.OnClick += (a, b) =>
            {
                Rectangle r = b.GetDimensions().ToRectangle();
                if (a.MousePosition.Y < r.Y + r.Height / 2)
                {
                    itemScale = Math.Min(1f, itemScale + 0.1f);
                }
                else
                {
                    itemScale = Math.Max(0.5f, itemScale - 0.1f);
                }
                foreach (var itemchoice in items)
                {
                    itemchoice.SetScale(itemScale);
                }
            };
            chooserPanel.Append(upDownButton);
        }
Beispiel #2
0
        public ItemDefinitionElement(PropertyFieldWrapper memberInfo, object item, IList <ItemDefinition> array = null, int index = -1) : base(memberInfo, item, (IList)array)
        {
            Height.Set(30f, 0f);

            _GetValue = () => DefaultGetValue();
            _SetValue = (ItemDefinition value) => DefaultSetValue(value);

            if (array != null)
            {
                _GetValue            = () => array[index];
                _SetValue            = (ItemDefinition value) => { array[index] = value; Interface.modConfig.SetPendingChanges(); };
                _TextDisplayFunction = () => index + 1 + ": ";
            }

            //itemChoice = new UIModConfigItemDefinitionChoice(_GetValue()?.GetID() ?? 0, 0.5f);
            itemChoice = new ItemDefinitionOptionElement(_GetValue(), 0.5f);
            itemChoice.Top.Set(2f, 0f);
            itemChoice.Left.Set(-30, 1f);
            itemChoice.OnClick += (a, b) =>
            {
                itemSelectionExpanded = !itemSelectionExpanded;
                updateNeeded          = true;
            };
            Append(itemChoice);

            chooserPanel = new UIPanel();
            chooserPanel.Top.Set(30, 0);
            chooserPanel.Height.Set(200, 0);
            chooserPanel.Width.Set(0, 1);
            chooserPanel.BackgroundColor = Color.CornflowerBlue;

            UIPanel textBoxBackgroundA = new UIPanel();

            textBoxBackgroundA.Width.Set(160, 0f);
            textBoxBackgroundA.Height.Set(30, 0f);
            textBoxBackgroundA.Top.Set(-6, 0);
            textBoxBackgroundA.PaddingTop    = 0;
            textBoxBackgroundA.PaddingBottom = 0;
            chooserFilter = new UIFocusInputTextField("Filter by Name");
            chooserFilter.OnTextChange += (a, b) =>
            {
                updateNeeded = true;
            };
            chooserFilter.OnRightClick += (a, b) => chooserFilter.SetText("");
            chooserFilter.Width         = StyleDimension.Fill;
            chooserFilter.Height.Set(-6, 1f);
            chooserFilter.Top.Set(6, 0f);
            textBoxBackgroundA.Append(chooserFilter);
            chooserPanel.Append(textBoxBackgroundA);

            UIPanel textBoxBackgroundB = new UIPanel();

            textBoxBackgroundB.CopyStyle(textBoxBackgroundA);
            textBoxBackgroundB.Left.Set(180, 0);
            chooserFilterMod = new UIFocusInputTextField("Filter by Mod");
            chooserFilterMod.OnTextChange += (a, b) =>
            {
                updateNeeded = true;
            };
            chooserFilterMod.OnRightClick += (a, b) => chooserFilterMod.SetText("");
            chooserFilterMod.Width         = StyleDimension.Fill;
            chooserFilterMod.Height.Set(-6, 1f);
            chooserFilterMod.Top.Set(6, 0f);
            textBoxBackgroundB.Append(chooserFilterMod);
            chooserPanel.Append(textBoxBackgroundB);

            chooserGrid = new NestedUIGrid();
            chooserGrid.Top.Set(30, 0);
            chooserGrid.Height.Set(-30, 1);
            chooserGrid.Width.Set(-12, 1);
            chooserPanel.Append(chooserGrid);

            UIScrollbar scrollbar = new UIScrollbar();

            scrollbar.SetView(100f, 1000f);
            scrollbar.Height.Set(-30f, 1f);
            scrollbar.Top.Set(30f, 0f);
            scrollbar.Left.Pixels += 8;
            scrollbar.HAlign       = 1f;
            chooserGrid.SetScrollbar(scrollbar);
            chooserPanel.Append(scrollbar);
            //Append(chooserPanel);

            UIModConfigHoverImageSplit upDownButton = new UIModConfigHoverImageSplit(upDownTexture, "Zoom in", "Zoom out");

            upDownButton.Recalculate();
            upDownButton.Top.Set(-4f, 0f);
            upDownButton.Left.Set(-18, 1f);
            upDownButton.OnClick += (a, b) =>
            {
                Rectangle r = b.GetDimensions().ToRectangle();
                if (a.MousePosition.Y < r.Y + r.Height / 2)
                {
                    itemScale = Math.Min(1f, itemScale + 0.1f);
                }
                else
                {
                    itemScale = Math.Max(0.5f, itemScale - 0.1f);
                }
                foreach (var itemchoice in items)
                {
                    itemchoice.SetScale(itemScale);
                }
            };
            chooserPanel.Append(upDownButton);
        }
        public IntInputElement(PropertyFieldWrapper memberInfo, object item, IList <int> array, int index) : base(memberInfo, item, (IList)array)
        {
            _GetValue = () => DefaultGetValue();
            _SetValue = (int value) => DefaultSetValue(value);

            if (array != null)
            {
                _GetValue            = () => array[index];
                _SetValue            = (int value) => { array[index] = value; Interface.modConfig.SetPendingChanges(); };
                _TextDisplayFunction = () => index + 1 + ": " + array[index];
            }

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

            UIPanel textBoxBackground = new UIPanel();

            textBoxBackground.SetPadding(0);
            UIFocusInputTextField uIInputTextField = new UIFocusInputTextField("Type here");

            textBoxBackground.Top.Set(0f, 0f);
            textBoxBackground.Left.Set(-190, 1f);
            textBoxBackground.Width.Set(180, 0f);
            textBoxBackground.Height.Set(30, 0f);
            Append(textBoxBackground);

            uIInputTextField.SetText(_GetValue().ToString());
            uIInputTextField.Top.Set(5, 0f);
            uIInputTextField.Left.Set(10, 0f);
            uIInputTextField.Width.Set(-42, 1f);             // allow space for arrows
            uIInputTextField.Height.Set(20, 0);
            uIInputTextField.OnTextChange += (a, b) =>
            {
                if (Int32.TryParse(uIInputTextField.currentString, out int val))
                {
                    _SetValue(val);
                }
                //else
                //{
                //	Interface.modConfig.SetMessage($"{uIInputTextField.currentString} isn't a valid value.", Color.Green);
                //}
            };
            uIInputTextField.OnUnfocus += (a, b) => uIInputTextField.SetText(_GetValue().ToString());
            textBoxBackground.Append(uIInputTextField);

            UIModConfigHoverImageSplit upDownButton = new UIModConfigHoverImageSplit(upDownTexture, "+" + increment, "-" + increment);

            upDownButton.Recalculate();
            upDownButton.Top.Set(4f, 0f);
            upDownButton.Left.Set(-30, 1f);
            upDownButton.OnClick += (a, b) =>
            {
                Rectangle r = b.GetDimensions().ToRectangle();
                if (a.MousePosition.Y < r.Y + r.Height / 2)
                {
                    _SetValue(Utils.Clamp(_GetValue() + increment, min, max));
                }
                else
                {
                    _SetValue(Utils.Clamp(_GetValue() - increment, min, max));
                }
                uIInputTextField.SetText(_GetValue().ToString());
            };
            textBoxBackground.Append(upDownButton);
            Recalculate();
        }
Beispiel #4
0
        public override void OnBind()
        {
            base.OnBind();
            this.intList = (IList <int>)list;

            if (intList != null)
            {
                TextDisplayFunction = () => index + 1 + ": " + intList[index];
            }

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

            UIPanel textBoxBackground = new UIPanel();

            textBoxBackground.SetPadding(0);
            UIFocusInputTextField uIInputTextField = new UIFocusInputTextField("Type here");

            textBoxBackground.Top.Set(0f, 0f);
            textBoxBackground.Left.Set(-190, 1f);
            textBoxBackground.Width.Set(180, 0f);
            textBoxBackground.Height.Set(30, 0f);
            Append(textBoxBackground);

            uIInputTextField.SetText(GetValue().ToString());
            uIInputTextField.Top.Set(5, 0f);
            uIInputTextField.Left.Set(10, 0f);
            uIInputTextField.Width.Set(-42, 1f);             // allow space for arrows
            uIInputTextField.Height.Set(20, 0);
            uIInputTextField.OnTextChange += (a, b) => {
                if (Int32.TryParse(uIInputTextField.CurrentString, out int val))
                {
                    SetValue(val);
                }
                //else
                //{
                //	Interface.modConfig.SetMessage($"{uIInputTextField.currentString} isn't a valid value.", Color.Green);
                //}
            };
            uIInputTextField.OnUnfocus += (a, b) => uIInputTextField.SetText(GetValue().ToString());
            textBoxBackground.Append(uIInputTextField);

            UIModConfigHoverImageSplit upDownButton = new UIModConfigHoverImageSplit(upDownTexture, "+" + increment, "-" + increment);

            upDownButton.Recalculate();
            upDownButton.Top.Set(4f, 0f);
            upDownButton.Left.Set(-30, 1f);
            upDownButton.OnClick += (a, b) => {
                Rectangle r = b.GetDimensions().ToRectangle();
                if (a.MousePosition.Y < r.Y + r.Height / 2)
                {
                    SetValue(Utils.Clamp(GetValue() + increment, min, max));
                }
                else
                {
                    SetValue(Utils.Clamp(GetValue() - increment, min, max));
                }
                uIInputTextField.SetText(GetValue().ToString());
            };
            textBoxBackground.Append(upDownButton);
            Recalculate();
        }