public AmmoBagPanel(BaseAmmoBag bag) : base(bag)
    {
        Width.Pixels  = 12 + (SlotSize + SlotMargin) * 9;
        Height.Pixels = 40 + (SlotSize + SlotMargin) * Container.GetItemStorage().Count / 9;

        UIGrid <UIContainerSlot> gridItems = new UIGrid <UIContainerSlot>(9)
        {
            Width    = { Percent = 100 },
            Height   = { Pixels = -28, Percent = 100 },
            Y        = { Pixels = 28 },
            Settings = { ItemMargin = SlotMargin }
        };

        Add(gridItems);

        for (int i = 0; i < Container.GetItemStorage().Count; i++)
        {
            UIContainerSlot slot = new UIContainerSlot(Container.GetItemStorage(), i)
            {
                Width  = { Pixels = SlotSize },
                Height = { Pixels = SlotSize }
            };
            gridItems.Add(slot);
        }
    }
Exemple #2
0
        public override void OnInitialize()
        {
            panelMain.Width.Pixels  = 232;
            panelMain.Height.Pixels = 132;
            panelMain.Center();
            panelMain.Top.Pixels -= panelMain.Height.Pixels / 3f * 2f;
            panelMain.SetPadding(0);
            panelMain.OnMouseDown    += DragStart;
            panelMain.OnMouseUp      += DragEnd;
            panelMain.BackgroundColor = panelColor;
            Append(panelMain);

            textLabel.HAlign     = 0.5f;
            textLabel.Top.Pixels = 8;
            panelMain.Append(textLabel);

            display              = new UIContainerSlot(barrel);
            display.HAlign       = 0.5f;
            display.Top.Pixels   = 36;
            display.CanInteract += (item, mouseItem) => false;
            panelMain.Append(display);

            items.Width.Set(-16, 1);
            items.Height.Pixels  = 40;
            items.Left.Pixels    = 8;
            items.Top.Pixels     = 84;
            items.ListPadding    = 4;
            items.OverflowHidden = true;
            panelMain.Append(items);
        }
        public NinjaArsenalBeltPanel(NinjaArsenalBelt bag) : base(bag)
        {
            Width.Pixels  = 12 + (SlotSize + SlotMargin) * 9;
            Height.Pixels = 40 + (SlotSize + SlotMargin) * Container.Handler.Slots / 9;


            UIGrid <UIContainerSlot> gridItems = new UIGrid <UIContainerSlot>(9)
            {
                Width      = { Percent = 100 },
                Height     = { Pixels = -28, Percent = 100 },
                Y          = { Pixels = 28 },
                ItemMargin = SlotMargin
            };

            Add(gridItems);

            for (int i = 0; i < Container.Handler.Slots; i++)
            {
                UIContainerSlot slot = new UIContainerSlot(() => Container.Handler, i)
                {
                    Width = { Pixels = SlotSize }, Height = { Pixels = SlotSize }
                };
                gridItems.Add(slot);
            }
        }
Exemple #4
0
        public GlacialConcentratorPanel(GlacialConcentrator container) : base(container)
        {
            Width.Pixels    = 272;
            Height.Pixels   = 316 + 54;
            BackgroundColor = new Color(38, 49, 90);

            UIText textLabel = new UIText(Language.GetText("Mods.Gelum.MapObject.GlacialConcentrator"))
            {
                X = { Percent = 50 },
                HorizontalAlignment = HorizontalAlignment.Center
            };

            Add(textLabel);

            UIEnergyStore energy = new UIEnergyStore(container)
            {
                Width  = { Pixels = 256 },
                Height = { Pixels = 256 },
                X      = { Percent = 50 },
                Y      = { Pixels = 28 }
            };

            Add(energy);

            UIContainerSlot slot = new UIContainerSlot(() => Handler)
            {
                X      = { Percent = 50 },
                Y      = { Percent = 100 },
                Width  = { Pixels = 54 },
                Height = { Pixels = 54 }
            };

            Add(slot);
        }
        public override void OnInitialize()
        {
            Width  = (0, 0.22f);
            Height = (0, 0.17f);
            this.Center();
            SetPadding(8);

            UIGrid <UIContainerSlot> gridItems = new UIGrid <UIContainerSlot>(9)
            {
                Width  = (0, 1),
                Height = (0, 1)
            };

            //Append(gridItems);

            for (int i = 0; i < Container.Handler.Slots; i++)
            {
                UIContainerSlot slot = new UIContainerSlot(() => Container.Handler, i);
                gridItems.Add(slot);
            }

            UIEnergyBar bar = new UIEnergyBar(Container)
            {
                HAlign = 1,
                Height = (0, 1),
                Width  = (40, 0)
            };

            Append(bar);
        }
    public AlchemistBagPanel(AlchemistBag bag) : base(bag)
    {
        Width.Pixels  = 12 + (SlotSize + SlotMargin) * 9;
        Height.Pixels = 100 + (SlotSize + SlotMargin) * Container.GetItemStorage().Count / 9;

        UIText textPotions = new UIText("Potions")
        {
            Y = { Pixels = 28 }
        };

        Add(textPotions);

        UIGrid <UIContainerSlot> gridItems = new UIGrid <UIContainerSlot>(9)
        {
            Width    = { Percent = 100 },
            Height   = { Pixels = SlotSize * 2 + SlotMargin },
            Y        = { Pixels = 56 },
            Settings = { ItemMargin = SlotMargin }
        };

        Add(gridItems);

        for (int i = 0; i < AlchemistBag.PotionSlots; i++)
        {
            UIContainerSlot slot = new UIContainerSlot(Container.GetItemStorage(), i)
            {
                Width  = { Pixels = SlotSize },
                Height = { Pixels = SlotSize }
            };
            gridItems.Add(slot);
        }

        UIText textIngredients = new UIText("Ingredients")
        {
            Y = { Pixels = 56 + 8 + SlotSize * 2 + SlotMargin }
        };

        Add(textIngredients);

        UIGrid <UIContainerSlot> gridIngredients = new UIGrid <UIContainerSlot>(9)
        {
            Width    = { Percent = 100 },
            Height   = { Pixels = (SlotSize + SlotMargin) * 7 - SlotMargin },
            Y        = { Pixels = 56 + 8 + 20 + 8 + SlotSize * 2 + SlotMargin },
            Settings = { ItemMargin = SlotMargin }
        };

        Add(gridIngredients);

        for (int i = AlchemistBag.PotionSlots; i < AlchemistBag.PotionSlots + AlchemistBag.IngredientSlots; i++)
        {
            UIContainerSlot slot = new UIContainerSlot(Container.GetItemStorage(), i)
            {
                Width  = { Pixels = SlotSize },
                Height = { Pixels = SlotSize }
            };
            gridIngredients.Add(slot);
        }
    }
Exemple #7
0
 public void Load(PortableDSU dsu)
 {
     slot            = new UIContainerSlot(dsu);
     slot.maxStack   = int.MaxValue;
     slot.HAlign     = 0.5f;
     slot.Top.Pixels = 36;
     panelMain.Append(slot);
 }
 public override void Load()
 {
     for (int i = 0; i < qeChest.GetItems().Count; i++)
     {
         UIContainerSlot slot = new UIContainerSlot(qeChest, i);
         gridItems.Add(slot);
     }
 }
        public override void OnInitialize()
        {
            Width  = (408, 0);
            Height = (40 + Container.Handler.Slots / 9 * 44, 0);
            this.Center();

            textLabel = new UIText(Container.DisplayName.GetTranslation())
            {
                HAlign = 0.5f
            };
            Append(textLabel);

            UIButton buttonLootAll = new UIButton(PortableStorage.textureLootAll)
            {
                Size = new Vector2(20)
            };

            buttonLootAll.OnClick      += (evt, element) => ItemUtility.LootAll(Container.Handler, Main.LocalPlayer);
            buttonLootAll.GetHoverText += () => Language.GetText("LegacyInterface.29").ToString();
            Append(buttonLootAll);

            UIButton buttonDepositAll = new UIButton(PortableStorage.textureDepositAll)
            {
                Size = new Vector2(20),
                Left = (28, 0)
            };

            buttonDepositAll.OnClick      += (evt, element) => ItemUtility.DepositAll(Container.Handler, Main.LocalPlayer);
            buttonDepositAll.GetHoverText += () => Language.GetText("LegacyInterface.30").ToString();
            Append(buttonDepositAll);

            buttonClose = new UITextButton("X")
            {
                Size        = new Vector2(20),
                Left        = (-20, 1),
                RenderPanel = false
            };
            buttonClose.OnClick += (evt, element) => BaseLibrary.BaseLibrary.PanelGUI.UI.CloseUI(Container);
            Append(buttonClose);

            gridItems = new UIGrid <UIContainerSlot>(9)
            {
                Width          = (0, 1),
                Height         = (-28, 1),
                Top            = (28, 0),
                OverflowHidden = true,
                ListPadding    = 4f
            };
            Append(gridItems);

            for (int i = 0; i < Container.Handler.Slots; i++)
            {
                UIContainerSlot slot = new UIContainerSlot(() => Container.Handler, i);
                gridItems.Add(slot);
            }
        }
    }
}
        public AlchemistBagPanel(AlchemistBag bag) : base(bag)
        {
            Width.Pixels  = 12 + (SlotSize + SlotMargin) * 9;
            Height.Pixels = 100 + (SlotSize + SlotMargin) * Container.Handler.Slots / 9;

            UIText textPotions = new UIText("Potions")
            {
                Y = { Pixels = 28 }
            };

            Add(textPotions);

            UIGrid <UIContainerSlot> gridItems = new UIGrid <UIContainerSlot>(9)
            {
                Width      = { Percent = 100 },
                Height     = { Pixels = SlotSize * 2 + SlotMargin },
                Y          = { Pixels = 56 },
                ItemMargin = SlotMargin
            };

            Add(gridItems);

            for (int i = 0; i < 18; i++)
            {
                UIContainerSlot slot = new UIContainerSlot(() => Container.Handler, i)
                {
                    Width = { Pixels = SlotSize }, Height = { Pixels = SlotSize }
                };
                gridItems.Add(slot);
            }

            UIText textIngredients = new UIText("Ingredients")
            {
                Y = { Pixels = 56 + 8 + SlotSize * 2 + SlotMargin }
            };

            Add(textIngredients);

            UIGrid <UIContainerSlot> gridIngredients = new UIGrid <UIContainerSlot>(9)
            {
                Width      = { Percent = 100 },
                Height     = { Pixels = (SlotSize + SlotMargin) * 7 - SlotMargin },
                Y          = { Pixels = 56 + 8 + 20 + 8 + SlotSize * 2 + SlotMargin },
                ItemMargin = SlotMargin
            };

            Add(gridIngredients);

            for (int i = 18; i < 81; i++)
            {
                UIContainerSlot slot = new UIContainerSlot(() => Container.Handler, i)
                {
                    Width = { Pixels = SlotSize }, Height = { Pixels = SlotSize }
                };
                gridIngredients.Add(slot);
            }
        }
Exemple #11
0
 public override void Load()
 {
     for (int i = 1; i < barrel.Items.Count; i++)
     {
         UIContainerSlot slot = new UIContainerSlot(barrel, i);
         slot.CanInteract += (item, mouseItem) => (mouseItem.IsAir || mouseItem.modItem is BaseUpgrade) && (!(item.modItem is StackUpgrade) || barrel.Items[0].stack <= barrel.maxStoredItems - ((StackUpgrade)item.modItem).stackInc * TEBarrel.BaseMax);
         items.Add(slot);
     }
 }
        public void Load(VacuumBag bag)
        {
            guid = bag.guid;

            for (int i = 0; i < bag.GetItems().Count; i++)
            {
                UIContainerSlot slot = new UIContainerSlot(bag, i);
                gridItems.Add(slot);
            }
        }
Exemple #13
0
        public override void Load()
        {
            UIContainerSlot slotFuel = new UIContainerSlot(coalPlant);

            slotFuel.Left.Pixels = 8;
            slotFuel.Top.Pixels  = 64;
            panelInfo.Append(slotFuel);

            barEnergy.energy = coalPlant.energy;
        }
Exemple #14
0
        public void Load(Bag bag)
        {
            this.bag = bag;

            for (int i = 0; i < bag.GetItems().Count; i++)
            {
                UIContainerSlot slot = new UIContainerSlot(bag, i);
                gridItems.Add(slot);
            }
        }
Exemple #15
0
        public void Load(QEBag bag)
        {
            guid = bag.guid;

            for (int i = 0; i < PortableStorage.Instance.GetModWorld <PSWorld>().enderItems[bag.frequency].Count; i++)
            {
                UIContainerSlot slot = new UIContainerSlot(bag, i);
                gridItems.Add(slot);
            }
        }
Exemple #16
0
        public void Load(QEBag bag)
        {
            this.bag = bag;

            for (int i = 0; i < PortableStorage.Instance.GetModWorld <PSWorld>().GetItemStorage(bag.frequency).Count; i++)
            {
                UIContainerSlot slot = new UIContainerSlot(bag, i);
                slot.OnInteract += Net.SyncQE;
                gridItems.Add(slot);
            }
        }
Exemple #17
0
        public void Load(AmmoBelt belt)
        {
            guid = belt.guid;

            for (int i = 0; i < belt.GetItems().Count; i++)
            {
                UIContainerSlot slot = new UIContainerSlot(belt, i);
                slot.CanInteract += (item, mouse) => mouse.IsAir || mouse.ammo > 0;
                gridItems.Add(slot);
            }
        }
        public override void OnInitialize()
        {
            Size = new Vector2(408, 172);
            this.Center();

            UIAnimatedTexture textureActivation = new UIAnimatedTexture(ModContent.GetTexture("PortableStorage/Textures/Items/TheBlackHole"), new DrawAnimationVertical(8, 8), ScaleMode.Stretch)
            {
                Size    = new Vector2(20),
                Animate = Bag.active
            };

            textureActivation.GetHoverText += () => Bag.active ? "Deactivate" : "Activate";
            textureActivation.OnClick      += (evt, element) =>
            {
                Bag.active = !Bag.active;
                textureActivation.Animate = Bag.active;

                Bag.Handler.OnContentsChanged?.Invoke(-1);
            };
            Append(textureActivation);

            textLabel = new UIText(Bag.DisplayName.GetTranslation())
            {
                HAlign = 0.5f
            };
            Append(textLabel);

            buttonClose = new UITextButton("X")
            {
                Size        = new Vector2(20),
                Left        = (-20, 1),
                RenderPanel = false
            };
            buttonClose.OnClick += (evt, element) => PortableStorage.Instance.PanelUI.UI.CloseUI(Bag);
            Append(buttonClose);

            gridItems = new UIGrid <UIContainerSlot>(9)
            {
                Width          = (0, 1),
                Height         = (-28, 1),
                Top            = (28, 0),
                OverflowHidden = true,
                ListPadding    = 4f
            };
            Append(gridItems);

            for (int i = 0; i < Bag.Handler.Slots; i++)
            {
                UIContainerSlot slot = new UIContainerSlot(() => Bag.Handler, i);
                gridItems.Add(slot);
            }
        }
    }
}
Exemple #19
0
        public override void OnInitialize()
        {
            panelMain.Width.Pixels  = 84;
            panelMain.Height.Pixels = 64;
            panelMain.Center();
            panelMain.BackgroundColor = panelColor;
            panelMain.SetPadding(0);
            panelMain.OnMouseDown += DragStart;
            panelMain.OnMouseUp   += DragEnd;
            base.Append(panelMain);

            slot             = new UIContainerSlot(spawner);
            slot.Left.Pixels = 8;
            slot.Top.Pixels  = 8;
            panelMain.Append(slot);
        }
Exemple #20
0
        public override void OnInitialize()
        {
            panelMain.Width.Pixels  = Main.screenWidth / 7f;
            panelMain.Height.Pixels = 84;
            panelMain.Center();
            panelMain.SetPadding(0);
            panelMain.OnMouseDown += DragStart;
            panelMain.OnMouseUp   += DragEnd;
            Append(panelMain);

            textLabel.HAlign     = 0.5f;
            textLabel.Top.Pixels = 8;
            panelMain.Append(textLabel);

            slot            = new UIContainerSlot(dsu);
            slot.maxStack   = int.MaxValue;
            slot.HAlign     = 0.5f;
            slot.Top.Pixels = 36;
            panelMain.Append(slot);
        }
        public override void OnInitialize()
        {
            Width  = (408, 0);
            Height = (40 + Bag.Handler.Slots / 9 * 44, 0);
            this.Center();

            textLabel = new UIText(Bag.DisplayName.GetTranslation())
            {
                HAlign = 0.5f
            };
            Append(textLabel);

            buttonClose = new UITextButton("X")
            {
                Size        = new Vector2(20),
                Left        = (-20, 1),
                RenderPanel = false
            };
            buttonClose.OnClick += (evt, element) => PortableStorage.Instance.PanelUI.UI.CloseUI(Bag);
            Append(buttonClose);

            gridItems = new UIGrid <UIContainerSlot>(9)
            {
                Width          = (0, 1),
                Height         = (-28, 1),
                Top            = (28, 0),
                OverflowHidden = true,
                ListPadding    = 4f
            };
            Append(gridItems);

            for (int i = 0; i < Bag.Handler.Slots; i++)
            {
                UIContainerSlot slot = new UIContainerSlot(() => Bag.Handler, i);
                gridItems.Add(slot);
            }
        }
    }
}
        public AutoExtractinatorPanel(AutoExtractinator container) : base(container)
        {
            Width.Pixels    = 272;
            Height.Pixels   = 348;
            BackgroundColor = new Color(38, 49, 90);

            UIText textLabel = new UIText(Language.GetText("Mods.Gelum.MapObject.AutoExtractinator"))
            {
                X = { Percent = 50 },
                HorizontalAlignment = HorizontalAlignment.Center
            };

            Add(textLabel);

            UIEnergyStore energy = new UIEnergyStore(container)
            {
                Width  = { Pixels = 64 },
                Height = { Pixels = 64 },
                X      = { Percent = 50 },
                Y      = { Pixels = 28 }
            };

            Add(energy);

            UIContainerSlot slot = new UIContainerSlot(() => Handler)
            {
                X      = { Percent = 50 },
                Y      = { Percent = 100 },
                Width  = { Pixels = 54 },
                Height = { Pixels = 54 }
            };

            Add(slot);

            slot = new UIContainerSlot(() => Handler, 1)
            {
                X      = { Pixels = 0 },
                Y      = { Percent = 50 },
                Width  = { Pixels = 54 },
                Height = { Pixels = 54 }
            };
            Add(slot);

            UIGrid <UIContainerSlot> grid = new UIGrid <UIContainerSlot>(3)
            {
                Width  = { Pixels = 54 * 3 + 8 },
                Height = { Pixels = 54 * 3 + 8 },
                X      = { Percent = 100 },
                Y      = { Pixels = 100 }
            };

            Add(grid);

            for (int i = 2; i < 11; i++)
            {
                slot = new UIContainerSlot(() => Handler, i)
                {
                    Width  = { Pixels = 54 },
                    Height = { Pixels = 54 }
                };
                grid.Add(slot);
            }
        }
        public WalletPanel(Wallet wallet) : base(wallet)
        {
            Width.Pixels  = 12 + (SlotSize + SlotMargin) * 4;
            Height.Pixels = 44 + SlotSize;

            Clear();

            UIText textLabel = new UIText(Container.DisplayName.GetDefault())
            {
                X = { Percent = 50 },
                HorizontalAlignment = HorizontalAlignment.Center
            };

            Add(textLabel);

            UIButton buttonLootAll = new UIButton(PortableStorage.textureLootAll)
            {
                Size      = new Vector2(20),
                HoverText = Language.GetText("LegacyInterface.29")
            };

            buttonLootAll.OnClick += args => ItemUtility.LootAll(Container.Handler, Main.LocalPlayer);
            Add(buttonLootAll);

            UIButton buttonDepositAll = new UIButton(PortableStorage.textureDepositAll)
            {
                Size      = new Vector2(20),
                X         = { Pixels = 28 },
                HoverText = Language.GetText("LegacyInterface.30")
            };

            buttonDepositAll.OnClick += args => ItemUtility.DepositAll(Container.Handler, Main.LocalPlayer);
            Add(buttonDepositAll);

            UITextButton buttonClose = new UITextButton("X")
            {
                Size        = new Vector2(20),
                X           = { Percent = 100 },
                Padding     = Padding.Zero,
                RenderPanel = false
            };

            buttonClose.OnClick += args => PanelUI.Instance.CloseUI(Container);
            Add(buttonClose);

            UIGrid <UIContainerSlot> gridItems = new UIGrid <UIContainerSlot>(4)
            {
                Width      = { Percent = 100 },
                Height     = { Pixels = -28, Percent = 100 },
                Y          = { Pixels = 28 },
                ItemMargin = SlotMargin
            };

            Add(gridItems);

            for (int i = 0; i < Container.Handler.Slots; i++)
            {
                UIContainerSlot slot = new UIContainerSlot(() => Container.Handler, i)
                {
                    ShortStackSize = true,
                    Width          = { Pixels = SlotSize },
                    Height         = { Pixels = SlotSize }
                };
                gridItems.Add(slot);
            }
        }
        public MiningLaserPanel(MiningLaser container) : base(container)
        {
            Width.Pixels    = 400;
            Height.Pixels   = 232;
            BackgroundColor = new Color(38, 49, 90);

            UIText textLabel = new UIText(Language.GetText("Mods.Gelum.MapObject.MiningLaser"))
            {
                X = { Percent = 50 },
                HorizontalAlignment = HorizontalAlignment.Center
            };

            Add(textLabel);

            UIEnergyStore energy = new UIEnergyStore(container)
            {
                Width  = { Pixels = 64 },
                Height = { Pixels = 64 },
                X      = { Percent = 50 },
                Y      = { Pixels = 28 }
            };

            Add(energy);

            UIContainerSlot slot = new UIContainerSlot(() => Handler)
            {
                X      = { Percent = 50 },
                Y      = { Percent = 100 },
                Width  = { Pixels = 54 },
                Height = { Pixels = 54 }
            };

            Add(slot);

            #region Radius
            UIText textRadius = new UIText("Radius: " + container.radius)
            {
                X = { Percent = 50 },
                Y = { Pixels = 105 },
                HorizontalAlignment = HorizontalAlignment.Center
            };
            Add(textRadius);

            UITextButton buttonDecRadius = new UITextButton("--")
            {
                Y       = { Pixels = 100 },
                Width   = { Pixels = 40 },
                Height  = { Pixels = 20 },
                Padding = Padding.Zero
            };
            buttonDecRadius.OnClick += _ =>
            {
                if (container.radius > 10)
                {
                    container.radius     -= 10;
                    container.CurrentTile = Point16.NegativeOne;
                }

                textRadius.Text = "Radius: " + container.radius;
            };
            Add(buttonDecRadius);

            buttonDecRadius = new UITextButton("-")
            {
                X       = { Pixels = 48 },
                Y       = { Pixels = 100 },
                Width   = { Pixels = 40 },
                Height  = { Pixels = 20 },
                Padding = Padding.Zero
            };
            buttonDecRadius.OnClick += _ =>
            {
                if (container.radius > 1)
                {
                    container.radius--;
                    container.CurrentTile = Point16.NegativeOne;
                }

                textRadius.Text = "Radius: " + container.radius;
            };
            Add(buttonDecRadius);

            UITextButton buttonIncRadius = new UITextButton("+")
            {
                X       = { Percent = 100, Pixels = -48 },
                Y       = { Pixels = 100 },
                Width   = { Pixels = 40 },
                Height  = { Pixels = 20 },
                Padding = Padding.Zero
            };
            buttonIncRadius.OnClick += _ =>
            {
                container.radius++;
                container.CurrentTile = Point16.NegativeOne;
                textRadius.Text       = "Radius: " + container.radius;
            };
            Add(buttonIncRadius);

            buttonIncRadius = new UITextButton("++")
            {
                X       = { Percent = 100 },
                Y       = { Pixels = 100 },
                Width   = { Pixels = 40 },
                Height  = { Pixels = 20 },
                Padding = Padding.Zero
            };
            buttonIncRadius.OnClick += _ =>
            {
                container.radius     += 10;
                container.CurrentTile = Point16.NegativeOne;
                textRadius.Text       = "Radius: " + container.radius;
            };
            Add(buttonIncRadius);
            #endregion

            #region Depth
            UIText textDepth = new UIText("Depth: " + container.height)
            {
                X = { Percent = 50 },
                Y = { Pixels = 128 },
                HorizontalAlignment = HorizontalAlignment.Center
            };
            Add(textDepth);

            UITextButton buttonDecDepth = new UITextButton("---")
            {
                Y       = { Pixels = 128 },
                Width   = { Pixels = 40 },
                Height  = { Pixels = 20 },
                Padding = Padding.Zero
            };
            buttonDecDepth.OnClick += _ =>
            {
                if (container.height > 100)
                {
                    container.height     -= 100;
                    container.CurrentTile = Point16.NegativeOne;
                }

                textDepth.Text = "Depth: " + container.height;
            };
            Add(buttonDecDepth);

            buttonDecDepth = new UITextButton("--")
            {
                X       = { Pixels = 48 },
                Y       = { Pixels = 128 },
                Width   = { Pixels = 40 },
                Height  = { Pixels = 20 },
                Padding = Padding.Zero
            };
            buttonDecDepth.OnClick += _ =>
            {
                if (container.height > 10)
                {
                    container.height     -= 10;
                    container.CurrentTile = Point16.NegativeOne;
                }

                textDepth.Text = "Depth: " + container.height;
            };
            Add(buttonDecDepth);

            buttonDecDepth = new UITextButton("-")
            {
                X       = { Pixels = 96 },
                Y       = { Pixels = 128 },
                Width   = { Pixels = 40 },
                Height  = { Pixels = 20 },
                Padding = Padding.Zero
            };
            buttonDecDepth.OnClick += _ =>
            {
                if (container.height > 1)
                {
                    container.height--;
                    container.CurrentTile = Point16.NegativeOne;
                }

                textDepth.Text = "Depth: " + container.height;
            };
            Add(buttonDecDepth);

            UITextButton buttonIncDepth = new UITextButton("+")
            {
                X       = { Percent = 100, Pixels = -96 },
                Y       = { Pixels = 128 },
                Width   = { Pixels = 40 },
                Height  = { Pixels = 20 },
                Padding = Padding.Zero
            };
            buttonIncDepth.OnClick += _ =>
            {
                container.height++;
                container.CurrentTile = Point16.NegativeOne;
                textDepth.Text        = "Depth: " + container.height;
            };
            Add(buttonIncDepth);

            buttonIncDepth = new UITextButton("++")
            {
                X       = { Percent = 100, Pixels = -48 },
                Y       = { Pixels = 128 },
                Width   = { Pixels = 40 },
                Height  = { Pixels = 20 },
                Padding = Padding.Zero
            };
            buttonIncDepth.OnClick += _ =>
            {
                container.height     += 10;
                container.CurrentTile = Point16.NegativeOne;
                textDepth.Text        = "Depth: " + container.height;
            };
            Add(buttonIncDepth);

            buttonIncDepth = new UITextButton("+++")
            {
                X       = { Percent = 100 },
                Y       = { Pixels = 128 },
                Width   = { Pixels = 40 },
                Height  = { Pixels = 20 },
                Padding = Padding.Zero
            };
            buttonIncDepth.OnClick += _ =>
            {
                container.height     += 100;
                container.CurrentTile = Point16.NegativeOne;
                textDepth.Text        = "Depth: " + container.height;
            };
            Add(buttonIncDepth);
            #endregion
        }
        private void SetupMainPanel()
        {
            panelMain = new BaseElement
            {
                Width  = { Percent = 100 },
                Height = { Pixels = -28, Percent = 100 },
                Y      = { Pixels = 28 }
            };

            UIPanel panelLocations = new UIPanel
            {
                Width  = { Percent = 100 },
                Height = { Pixels = -48, Percent = 100 }
            };

            panelMain.Add(panelLocations);

            gridLocations = new UIGrid <UITeleporterItem>
            {
                Width  = { Pixels = -28, Percent = 100 },
                Height = { Percent = 100 }
            };
            panelLocations.Add(gridLocations);
            UpdateGrid();

            gridLocations.scrollbar.Height = new StyleDimension {
                Percent = 100
            };
            gridLocations.scrollbar.X.Percent = 100;
            panelLocations.Add(gridLocations.scrollbar);

            UITextButton buttonDialOnce = new UITextButton(Language.GetText("Mods.Teleportation.UI.DialOnce"))
            {
                Width  = { Pixels = -4, Percent = 25 },
                Height = { Pixels = 40 },
                Y      = { Percent = 100 }
            };

            buttonDialOnce.OnClick += args =>
            {
                if (SelectedTeleporter == null)
                {
                    return;
                }

                if (SelectedTeleporter.Destination == Container)
                {
                    SelectedTeleporter = null;
                }
                else
                {
                    Container.Destination = SelectedTeleporter;
                    Container.DialOnce    = true;
                    Net.SendTeleporterDestination(Container);
                }
            };
            panelMain.Add(buttonDialOnce);

            UITextButton buttonDial = new UITextButton(Language.GetText("Mods.Teleportation.UI.Dial"))
            {
                Width  = { Pixels = -4, Percent = 25 },
                Height = { Pixels = 40 },
                Y      = { Percent = 100 },
                X      = { Percent = 33 }
            };

            buttonDial.OnClick += args =>
            {
                if (SelectedTeleporter == null)
                {
                    return;
                }

                if (SelectedTeleporter.Destination == Container)
                {
                    SelectedTeleporter = null;
                }
                else
                {
                    Container.Destination = SelectedTeleporter;
                    Container.DialOnce    = false;
                    Net.SendTeleporterDestination(Container);
                }
            };
            panelMain.Add(buttonDial);

            UITextButton buttonInterrupt = new UITextButton(Language.GetText("Mods.Teleportation.UI.Interrupt"))
            {
                Width  = { Pixels = -4, Percent = 25 },
                Height = { Pixels = 40 },
                X      = { Percent = 50 },
                Y      = { Percent = 100 }
            };

            buttonInterrupt.OnClick += args =>
            {
                if (SelectedTeleporter != null)
                {
                    SelectedTeleporter.Destination = null;
                }
                SelectedTeleporter    = null;
                Container.Destination = null;
                Container.DialOnce    = false;
                Net.SendTeleporterDestination(Container);
            };
            panelMain.Add(buttonInterrupt);

            UIContainerSlot slotFuel = new UIContainerSlot(() => Container.Handler)
            {
                Width       = { Pixels = -4, Percent = 25 },
                X           = { Percent = 100 },
                Y           = { Percent = 100 },
                Padding     = new Padding(0, 24, 24, 0),
                PreviewItem = new Item()
            };

            slotFuel.PreviewItem.SetDefaults(ModContent.ItemType <FuelCell>());
            panelMain.Add(slotFuel);
        }
Exemple #26
0
        public TestChestUI(TestChestTE chest) : base(chest)
        {
            Width.Pixels  = 408;
            Height.Pixels = 172;

            UITextButton buttonClose = new UITextButton("X")
            {
                Size        = new Vector2(20),
                X           = { Percent = 100 },
                Padding     = Padding.Zero,
                RenderPanel = false
            };

            buttonClose.OnClick += args => PanelUI.Instance.CloseUI(Container);
            Add(buttonClose);

            UIText textLabel = new UIText("Test Chest")
            {
                Width  = { Percent = 100 },
                Height = { Pixels = 20 },
                HorizontalAlignment = HorizontalAlignment.Center
            };

            Add(textLabel);

            UIButton buttonLootAll = new UIButton(Routed.textureLootAll)
            {
                Size      = new Vector2(20),
                HoverText = Language.GetText("LegacyInterface.29")
            };

            buttonLootAll.OnClick += args => ItemUtility.LootAll(Container.Handler, Main.LocalPlayer);
            Add(buttonLootAll);

            UIButton buttonDepositAll = new UIButton(Routed.textureDepositAll)
            {
                Size      = new Vector2(20),
                X         = { Pixels = 28 },
                HoverText = Language.GetText("LegacyInterface.30")
            };

            buttonDepositAll.OnClick += args => ItemUtility.DepositAll(Container.Handler, Main.LocalPlayer);
            Add(buttonDepositAll);

            UIButton buttonQuickStack = new UIButton(Routed.textureQuickStack)
            {
                Size      = new Vector2(20),
                X         = { Pixels = 56 },
                HoverText = Language.GetText("LegacyInterface.31")
            };

            buttonQuickStack.OnClick += args => ItemUtility.QuickStack(Container.Handler, Main.LocalPlayer);
            Add(buttonQuickStack);

            UIGrid <UIContainerSlot> gridItems = new UIGrid <UIContainerSlot>(9)
            {
                Width      = { Percent = 100 },
                Height     = { Pixels = -28, Percent = 100 },
                Y          = { Pixels = 28 },
                ItemMargin = 4
            };

            Add(gridItems);

            for (int i = 0; i < Container.Handler.Slots; i++)
            {
                UIContainerSlot slot = new UIContainerSlot(() => Container.Handler, i);
                gridItems.Add(slot);
            }
        }
        public override void OnInitialize()
        {
            Width  = (408, 0);
            Height = (40 + Bag.Handler.Slots / 9 * 44, 0);
            this.Center();

            textLabel = new UIText(Bag.DisplayName.GetTranslation())
            {
                HAlign = 0.5f
            };
            Append(textLabel);

            buttonClose = new UITextButton("X")
            {
                Size        = new Vector2(20),
                Left        = (-20, 1),
                RenderPanel = false
            };
            buttonClose.OnClick += (evt, element) => PortableStorage.Instance.PanelUI.UI.CloseUI(Bag);
            Append(buttonClose);

            gridItems = new UIGrid <UIContainerSlot>(9)
            {
                Width          = (0, 1),
                Height         = (-28, 1),
                Top            = (28, 0),
                OverflowHidden = true,
                ListPadding    = 4f
            };
            Append(gridItems);

            BuilderReserve devNull = Bag;

            for (int i = 0; i < Bag.Handler.Slots; i++)
            {
                UIContainerSlot slot = new UIContainerSlot(() => Bag.Handler, i);
                slot.ClickOverride += () =>
                {
                    if (!slot.Item.IsAir && Main.keyState.IsKeyDown(Keys.RightShift))
                    {
                        if (devNull.selectedIndex == slot.slot)
                        {
                            devNull.SetIndex(-1);
                        }
                        else
                        {
                            devNull.SetIndex(slot.slot);
                        }

                        return(true);
                    }

                    return(false);
                };
                slot.OnInteract += () =>
                {
                    if (slot.Item.IsAir && slot.slot == devNull.selectedIndex)
                    {
                        devNull.SetIndex(-1);
                    }
                };
                gridItems.Add(slot);
            }

            RefreshTextures();
        }
        public RequesterModulePanel(RequesterModule module) : base(module)
        {
            Width.Pixels  = 60 + (SlotSize + SlotMargin) * Columns - SlotMargin;
            Height.Pixels = 144 + (SlotSize + SlotMargin) * (Rows + 2) - SlotMargin * 2;
            X.Percent     = Y.Percent = 50;

            UITextButton buttonClose = new UITextButton("X")
            {
                Width       = { Pixels = 20 },
                Height      = { Pixels = 20 },
                X           = { Percent = 100 },
                RenderPanel = false,
                Padding     = new Padding(0)
            };

            buttonClose.OnClick += args =>
            {
                if (args.Button != MouseButton.Left)
                {
                    return;
                }

                PanelUI.Instance.CloseUI(Container);
            };
            Add(buttonClose);

            textQueue = new UIText("Queue")
            {
                Width = { Percent = 50 },
                HorizontalAlignment = HorizontalAlignment.Left
            };
            Add(textQueue);

            UIText textLabel = new UIText("Requester Module")
            {
                Width = { Percent = 100 },
                HorizontalAlignment = HorizontalAlignment.Center
            };

            Add(textLabel);

            UIPanel panel = new UIPanel
            {
                Y               = { Pixels = 28 },
                Width           = { Percent = 100 },
                Height          = { Pixels = (SlotSize + SlotMargin) * Rows - SlotMargin },
                BorderColor     = Color.Transparent,
                BackgroundColor = Utility.ColorPanel_Selected * 0.75f
            };

            Add(panel);

            gridSlots = new UIGrid <UIRequesterSlot>(Columns)
            {
                Width      = { Percent = 100, Pixels = -26 },
                Height     = { Percent = 100 },
                ItemMargin = SlotMargin
            };
            gridSlots.SearchSelector += item =>
            {
                if (string.IsNullOrWhiteSpace(search.Value))
                {
                    return(true);
                }

                string itemName   = item.Item.HoverName.ToLower();
                string searchName = search.Value.ToLower();

                return(itemName.Contains(searchName));
            };
            panel.Add(gridSlots);

            gridSlots.scrollbar.X.Percent      = 100;
            gridSlots.scrollbar.Y.Pixels       = 0;
            gridSlots.scrollbar.Height.Percent = 100;
            panel.Add(gridSlots.scrollbar);

            UITextInput inputSearch = new UITextInput(ref search)
            {
                Y                 = { Pixels = 36 + (SlotSize + SlotMargin) * Rows - SlotMargin },
                Width             = { Percent = 100 },
                Height            = { Pixels = 40 },
                RenderPanel       = true,
                VerticalAlignment = VerticalAlignment.Center,
                HintText          = "Search",
                Padding           = new Padding(8)
            };

            inputSearch.OnKeyPressed += args =>
            {
                if (inputSearch.Focused && (args.Key == Keys.Enter || args.Key == Keys.Escape))
                {
                    args.Handled        = true;
                    inputSearch.Focused = false;
                }
            };
            inputSearch.OnTextChange += () => gridSlots.Search();
            Add(inputSearch);

            // requested items
            {
                UIText textRequestedItem = new UIText("Requested Items")
                {
                    Width  = { Pixels = (SlotSize + SlotMargin) * 10 - SlotMargin },
                    Margin = new Margin(8, 0, 0, 0),
                    Y      = { Pixels = 84 + (SlotSize + SlotMargin) * Rows - SlotMargin },
                    HorizontalAlignment = HorizontalAlignment.Center
                };
                Add(textRequestedItem);

                panel = new UIPanel
                {
                    Y               = { Pixels = 112 + (SlotSize + SlotMargin) * Rows - SlotMargin },
                    Width           = { Percent = 100 },
                    Height          = { Pixels = 16 + (SlotSize + SlotMargin) * 2 - SlotMargin },
                    BorderColor     = Color.Transparent,
                    BackgroundColor = Utility.ColorPanel_Selected * 0.75f
                };
                Add(panel);

                UIGrid <UIContainerSlot> gridOutout = new UIGrid <UIContainerSlot>(10)
                {
                    Width      = { Pixels = (SlotSize + SlotMargin) * 10 },
                    Height     = { Percent = 100 },
                    ItemMargin = SlotMargin
                };
                panel.Add(gridOutout);

                for (int i = 0; i < Container.Handler.Slots; i++)
                {
                    UIContainerSlot slot = new UIContainerSlot(() => Container.Handler, i)
                    {
                        Width   = { Pixels = SlotSize },
                        Height  = { Pixels = SlotSize },
                        Padding = new Padding(2)
                    };
                    gridOutout.Add(slot);
                }
            }

            // return items
            {
                UIText textReturnItems = new UIText("Return")
                {
                    Width  = { Pixels = (SlotSize + SlotMargin) * 3 - SlotMargin },
                    Margin = new Margin(0, 0, 8, 0),
                    X      = { Percent = 100 },
                    Y      = { Pixels = 84 + (SlotSize + SlotMargin) * Rows - SlotMargin },
                    HorizontalAlignment = HorizontalAlignment.Center
                };
                Add(textReturnItems);

                UIGrid <UIContainerSlot> gridInput = new UIGrid <UIContainerSlot>(3)
                {
                    Width      = { Pixels = (SlotSize + SlotMargin) * 3 - SlotMargin },
                    Height     = { Percent = 100 },
                    X          = { Percent = 100 },
                    ItemMargin = SlotMargin
                };
                panel.Add(gridInput);

                for (int i = 0; i < Container.ReturnHandler.Slots; i++)
                {
                    UIContainerSlot slot = new UIContainerSlot(() => Container.ReturnHandler, i)
                    {
                        Width   = { Pixels = SlotSize },
                        Height  = { Pixels = SlotSize },
                        Padding = new Padding(2)
                    };
                    gridInput.Add(slot);
                }
            }

            UIButton buttonTransfer = new UIButton(ModContent.GetTexture("BaseLibrary/Textures/UI/QuickStack"))
            {
                Y         = { Percent = 50 },
                X         = { Pixels = 6 + (SlotSize + SlotMargin) * 10 - SlotMargin },
                Width     = { Pixels = 20 },
                Height    = { Pixels = 20 },
                HoverText = "Transfer items"
            };

            buttonTransfer.OnClick += args =>
            {
                for (int i = 0; i < Container.Handler.Slots; i++)
                {
                    ref Item item = ref Container.Handler.GetItemInSlotByRef(i);
                    Container.ReturnHandler.InsertItem(ref item);
                    if (!item.IsAir)
                    {
                        break;
                    }
                }

                Recipe.FindRecipes();
            };
Exemple #29
0
        public CrusherPanel(Crusher container) : base(container)
        {
            Width.Pixels    = 272;
            Height.Pixels   = 232;
            BackgroundColor = new Color(38, 49, 90);

            UIText textLabel = new UIText(Language.GetText("Mods.Gelum.MapObject.Crusher"))
            {
                X = { Percent = 50 },
                HorizontalAlignment = HorizontalAlignment.Center
            };

            Add(textLabel);

            UIEnergyStore energy = new UIEnergyStore(container)
            {
                Width  = { Pixels = 64 },
                Height = { Pixels = 64 },
                X      = { Percent = 50 },
                Y      = { Pixels = 28 }
            };

            Add(energy);

            UIContainerSlot slot = new UIContainerSlot(() => Handler)
            {
                X      = { Percent = 50 },
                Y      = { Percent = 100 },
                Width  = { Pixels = 54 },
                Height = { Pixels = 54 }
            };

            Add(slot);

            slot = new UIContainerSlot(() => Handler, 1)
            {
                X      = { Pixels = 0 },
                Y      = { Pixels = 108 },
                Width  = { Pixels = 54 },
                Height = { Pixels = 54 }
            };
            Add(slot);

            slot = new UIContainerSlot(() => Handler, 2)
            {
                X      = { Pixels = 62 },
                Y      = { Pixels = 108 },
                Width  = { Pixels = 54 },
                Height = { Pixels = 54 }
            };
            Add(slot);

            slot = new UIContainerSlot(() => Handler, 1)
            {
                X      = { Pixels = 0 },
                Y      = { Pixels = 108 },
                Width  = { Pixels = 54 },
                Height = { Pixels = 54 }
            };
            Add(slot);

            slot = new UIContainerSlot(() => Handler, 2)
            {
                X      = { Pixels = 62 },
                Y      = { Pixels = 108 },
                Width  = { Pixels = 54 },
                Height = { Pixels = 54 }
            };
            Add(slot);

            slot = new UIContainerSlot(() => Handler, 3)
            {
                X      = { Percent = 100, Pixels = -62 },
                Y      = { Pixels = 108 },
                Width  = { Pixels = 54 },
                Height = { Pixels = 54 }
            };
            Add(slot);

            slot = new UIContainerSlot(() => Handler, 4)
            {
                X      = { Percent = 100 },
                Y      = { Pixels = 108 },
                Width  = { Pixels = 54 },
                Height = { Pixels = 54 }
            };
            Add(slot);
        }