Exemple #1
0
 public void Unload()
 {
     items        = null;
     slotZone     = null;
     bottomBar    = null;
     capacityText = null;
     sideBar      = null;
 }
Exemple #2
0
        public void RebuildUI()
        {
            RemoveAllChildren();

            slotZone = new UISlotZone(HoverItemSlot, GetItem, UI.InventoryScale);
            Append(slotZone);

            slotZone.ScrollBar = new UIScrollbar();
            Append(slotZone.ScrollBar);

            sideBar = new List <UITextButton>();
            BuildSortAndFilter();

            sideBar.Add(new UITextButton(Lang.inter[30].Value, 0.75f, 1.0f)); // Deposit all
            var depositAll = sideBar[4];

            depositAll.Action += (bool rightClicked, bool mouseInBounds) =>
            {
                if (!rightClicked && mouseInBounds && TryDepositAll())
                {
                    RefreshItems();
                    Main.PlaySound(7, -1, -1, 1);
                    Recipe.FindRecipes();
                }
            };
            Append(depositAll);

            sideBar.Add(new UITextButton(Lang.inter[31].Value, 0.75f, 1.0f)); // Quick stack
            var quickStack = sideBar[5];

            quickStack.Action += (bool rightClicked, bool mouseInBounds) =>
            {
                if (!rightClicked && mouseInBounds && TryQuickStack(true))
                {
                    RefreshItems();
                    Main.PlaySound(7, -1, -1, 1);
                    Recipe.FindRecipes();
                }
            };
            Append(quickStack);

            sideBar.Add(new UITextButton(Lang.inter[82].Value, 0.75f, 1.0f)); // Restock
            var restock = sideBar[6];

            restock.Action += (bool rightClicked, bool mouseInBounds) =>
            {
                if (!rightClicked && mouseInBounds && TryRestock())
                {
                    RefreshItems();
                    Main.PlaySound(7, -1, -1, 1);
                    Recipe.FindRecipes();
                }
            };
            Append(restock);

            bottomBar.Append(capacityText);
            Append(bottomBar);

            foreach (var s in sideBar)
            {
                Append(s);
            }
        }