예제 #1
0
        public static void Initialize()
        {
            InitLangStuff();
            float itemSlotWidth  = Main.inventoryBackTexture.Width * inventoryScale;
            float itemSlotHeight = Main.inventoryBackTexture.Height * inventoryScale;

            panelTop  = Main.instance.invBottom + 60;
            panelLeft = 20f;
            basePanel = new UIPanel();
            float innerPanelLeft  = panelLeft + basePanel.PaddingLeft;
            float innerPanelWidth = numColumns * (itemSlotWidth + padding) + 20f + padding;

            panelWidth  = basePanel.PaddingLeft + innerPanelWidth + basePanel.PaddingRight;
            panelHeight = Main.screenHeight - panelTop - 40f;
            basePanel.Left.Set(panelLeft, 0f);
            basePanel.Top.Set(panelTop, 0f);
            basePanel.Width.Set(panelWidth, 0f);
            basePanel.Height.Set(panelHeight, 0f);
            basePanel.Recalculate();

            topBar = new UIElement();
            topBar.Width.Set(0f, 1f);
            topBar.Height.Set(32f, 0f);
            basePanel.Append(topBar);

            InitSortButtons();
            topBar.Append(sortButtons);

            depositButton.Left.Set(sortButtons.GetDimensions().Width + 2 * padding, 0f);
            depositButton.Width.Set(128f, 0f);
            depositButton.Height.Set(-2 * padding, 1f);
            depositButton.PaddingTop    = 8f;
            depositButton.PaddingBottom = 8f;
            topBar.Append(depositButton);

            float depositButtonRight = sortButtons.GetDimensions().Width + 2 * padding + depositButton.GetDimensions().Width;

            searchBar.Left.Set(depositButtonRight + padding, 0f);
            searchBar.Width.Set(-depositButtonRight - 2 * padding, 1f);
            searchBar.Height.Set(0f, 1f);
            topBar.Append(searchBar);

            topBar2 = new UIElement();
            topBar2.Width.Set(0f, 1f);
            topBar2.Height.Set(32f, 0f);
            topBar2.Top.Set(36f, 0f);
            basePanel.Append(topBar2);

            InitFilterButtons();
            topBar2.Append(filterButtons);
            searchBar2.Left.Set(depositButtonRight + padding, 0f);
            searchBar2.Width.Set(-depositButtonRight - 2 * padding, 1f);
            searchBar2.Height.Set(0f, 1f);
            topBar2.Append(searchBar2);

            slotZone.Width.Set(0f, 1f);
            slotZone.Top.Set(76f, 0f);
            slotZone.Height.Set(-116f, 1f);
            basePanel.Append(slotZone);

            numRows     = (items.Count + numColumns - 1) / numColumns;
            displayRows = (int)slotZone.GetDimensions().Height / ((int)itemSlotHeight + padding);
            slotZone.SetDimensions(numColumns, displayRows);
            int noDisplayRows = numRows - displayRows;

            if (noDisplayRows < 0)
            {
                noDisplayRows = 0;
            }
            scrollBarMaxViewSize = 1 + noDisplayRows;
            scrollBar.Height.Set(displayRows * (itemSlotHeight + padding), 0f);
            scrollBar.Left.Set(-20f, 1f);
            scrollBar.SetView(scrollBarViewSize, scrollBarMaxViewSize);
            slotZone.Append(scrollBar);

            bottomBar.Width.Set(0f, 1f);
            bottomBar.Height.Set(32f, 0f);
            bottomBar.Top.Set(-32f, 1f);
            basePanel.Append(bottomBar);

            capacityText.Left.Set(6f, 0f);
            capacityText.Top.Set(6f, 0f);
            TEStorageHeart heart    = GetHeart();
            int            numItems = 0;
            int            capacity = 0;

            if (heart != null)
            {
                foreach (TEAbstractStorageUnit abstractStorageUnit in heart.GetStorageUnits())
                {
                    if (abstractStorageUnit is TEStorageUnit)
                    {
                        TEStorageUnit storageUnit = (TEStorageUnit)abstractStorageUnit;
                        numItems += storageUnit.NumItems;
                        capacity += storageUnit.Capacity;
                    }
                }
            }
            capacityText.SetText(numItems + "/" + capacity + " Items");
            bottomBar.Append(capacityText);
        }
예제 #2
0
        public void Initialize()
        {
            InitLangStuff();
            float smallSlotWidth = Main.inventoryBackTexture.Width * CraftingGUINew.INGREDIENTS_SCALE;

            panelTop = Main.instance.invBottom + 60;

            float innerCraftingPanelWidth = MagicStorageTwo.Instance.guiM.CraftingGUI.ActualWidth;
            float ingredientWidth         = CraftingGUINew.AVAILABLE_INGREDIENT_NUM_COLS * (smallSlotWidth + UICommon.PADDING) + 20f + UICommon.PADDING;

            ingredientWidth += 12 * 2;

            panelLeft    = 20f + (OffseLeft ? MagicStorageTwo.Instance.guiM.CraftingGUI.HasRecipe ? innerCraftingPanelWidth + ingredientWidth : innerCraftingPanelWidth : 0);
            storagePanel = new UIPanel();
            panelWidth   = itemsZone.ActualWidth + storagePanel.PaddingRight + storagePanel.PaddingLeft + 20 + UICommon.PADDING;
            storagePanel.Left.Set(panelLeft, 0f);
            storagePanel.Top.Set(panelTop, 0f);
            storagePanel.Width.Set(panelWidth, 0f);
            storagePanel.Recalculate();

            upperTopBar = new UIElement();
            upperTopBar.Width.Set(0f, 1f);
            upperTopBar.Height.Set(32f, 0f);
            storagePanel.Append(upperTopBar);

            InitSortButtons();
            upperTopBar.Append(sortButtons);

            depositButton.Left.Set(sortButtons.GetDimensions().Width + 2 * UICommon.PADDING, 0f);
            depositButton.Width.Set(32 * 3 + 8 * 2 + 4, 0f);
            depositButton.Height.Set(-2 * UICommon.PADDING, 1f);
            depositButton.PaddingTop    = 8f;
            depositButton.PaddingBottom = 8f;
            upperTopBar.Append(depositButton);

            float depositButtonRight = sortButtons.GetDimensions().Width + 2 * UICommon.PADDING + depositButton.GetDimensions().Width;

            nameSearchBar.Left.Set(depositButtonRight + UICommon.PADDING, 0f);
            nameSearchBar.Width.Set(-depositButtonRight - 1 * UICommon.PADDING, 1f);
            nameSearchBar.Height.Set(0f, 1f);
            upperTopBar.Append(nameSearchBar);

            lowerTopBar = new UIElement();
            lowerTopBar.Width.Set(0f, 1f);
            lowerTopBar.Height.Set(32f, 0f);
            lowerTopBar.Top.Set(36f, 0f);
            storagePanel.Append(lowerTopBar);

            InitFilterButtons();
            lowerTopBar.Append(filterButtons);
            modSearchBar.Left.Set(depositButtonRight + UICommon.PADDING, 0f);
            modSearchBar.Width.Set(-depositButtonRight - 1 * UICommon.PADDING, 1f);
            modSearchBar.Height.Set(0f, 1f);
            lowerTopBar.Append(modSearchBar);

            itemsZone.Width.Set(0f, 1f);
            itemsZone.Top.Set(76f, 0f);
            itemsZone.Height.Set(-116f, 1f);
            storagePanel.Append(itemsZone);

            numRows     = (items.Count + NUM_COLS - 1) / NUM_COLS;
            displayRows = Math.Min(itemsZone.MaxRows, 8);
            itemsZone.SetDimensions(NUM_COLS, displayRows);
            int noDisplayRows = numRows - displayRows;

            if (noDisplayRows < 0)
            {
                noDisplayRows = 0;
            }
            scrollBarMaxViewSize = 1 + noDisplayRows;
            itemsScrollBar.Top.Set(4, 0);
            itemsScrollBar.Height.Set(itemsZone.ActualHeight, 0f);
            itemsScrollBar.Left.Set(-20f, 1f);
            itemsScrollBar.SetView(SCROLLBAR_SIZE, scrollBarMaxViewSize);

            bottomBar.Width.Set(0f, 1f);
            bottomBar.Height.Set(32f, 0f);
            bottomBar.Top.Set(itemsZone.Top.Pixels + itemsZone.ActualHeight, 0f);
            storagePanel.Append(bottomBar);

            capacityText.Left.Set(6f, 0f);
            capacityText.Top.Set(6f, 0f);
            TEStorageHeart heart    = GetHeart();
            int            numItems = 0;
            int            capacity = 0;

            if (heart != null)
            {
                foreach (TEAbstractStorageUnit abstractStorageUnit in heart.GetStorageUnits())
                {
                    if (abstractStorageUnit is TEStorageUnit)
                    {
                        TEStorageUnit storageUnit = (TEStorageUnit)abstractStorageUnit;
                        numItems += storageUnit.NumItems;
                        capacity += storageUnit.Capacity;
                    }
                }
            }
            capacityText.SetText($"{numItems}/{capacity} {Locale.GetStr(Locale.C.ITEMS)}");
            bottomBar.Append(capacityText);
            panelHeight = upperTopBar.Height.Pixels + lowerTopBar.Height.Pixels + itemsZone.ActualHeight + bottomBar.Height.Pixels + 32;
            storagePanel.Height.Set(panelHeight, 0);
            storagePanel.Recalculate();
        }