示例#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);
        }
示例#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);
        }