Exemple #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);
        }
Exemple #2
0
        private void SetupGamepadPoints(SpriteBatch spriteBatch)
        {
            UILinkPointNavigator.Shortcuts.BackButtonCommand            = 6;
            UILinkPointNavigator.Shortcuts.FANCYUI_SPECIAL_INSTRUCTIONS = 1;
            int num  = 3002;
            int num2 = num;

            UILinkPointNavigator.SetPosition(3000, _cancelButton.GetDimensions().Center());
            UILinkPoint uILinkPoint = UILinkPointNavigator.Points[3000];

            uILinkPoint.Unlink();
            uILinkPoint.Right = 3001;
            uILinkPoint.Up    = num + 40;
            UILinkPointNavigator.SetPosition(3001, _submitButton.GetDimensions().Center());
            uILinkPoint = UILinkPointNavigator.Points[3001];
            uILinkPoint.Unlink();
            uILinkPoint.Left = 3000;
            uILinkPoint.Up   = num + 49;
            for (int i = 0; i < 5; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    int num3 = i * 10 + j;
                    num2 = num + num3;
                    if (_keyList[num3] != null)
                    {
                        UILinkPointNavigator.SetPosition(num2, _keyList[num3].GetDimensions().Center());
                        uILinkPoint = UILinkPointNavigator.Points[num2];
                        uILinkPoint.Unlink();
                        int num4 = j - 1;
                        while (num4 >= 0 && _keyList[i * 10 + num4] == _keyList[num3])
                        {
                            num4--;
                        }
                        if (num4 != -1)
                        {
                            uILinkPoint.Left = i * 10 + num4 + num;
                        }
                        else
                        {
                            uILinkPoint.Left = i * 10 + 9 + num;
                        }
                        int k;
                        for (k = j + 1; k <= 9 && _keyList[i * 10 + k] == _keyList[num3]; k++)
                        {
                        }
                        if (k != 10 && _keyList[num3] != _keyList[k])
                        {
                            uILinkPoint.Right = i * 10 + k + num;
                        }
                        else
                        {
                            uILinkPoint.Right = i * 10 + num;
                        }
                        if (i != 0)
                        {
                            uILinkPoint.Up = num2 - 10;
                        }
                        if (i != 4)
                        {
                            uILinkPoint.Down = num2 + 10;
                        }
                        else
                        {
                            uILinkPoint.Down = ((j < 5) ? 3000 : 3001);
                        }
                    }
                }
            }
        }
Exemple #3
0
        public override void OnInitialize()
        {
            float slotWidth  = Main.inventoryBackTexture.Width * inventoryScale;
            float slotHeight = Main.inventoryBackTexture.Height * inventoryScale;

            float panelTop  = Main.instance.invBottom + 60;
            float panelLeft = 20f;

            UIPanel panel           = new UIPanel();
            float   innerPanelLeft  = panelLeft + panel.PaddingLeft;
            float   innerPanelWidth = columns * (slotWidth + padding) + 20f + padding;
            float   panelWidth      = panel.PaddingLeft + innerPanelWidth + panel.PaddingRight;
            float   panelHeight     = Main.screenHeight - panelTop - 40f;

            panel.Left.Set(panelLeft, 0f);
            panel.Top.Set(panelTop, 0f);
            panel.Width.Set(panelWidth, 0f);
            panel.Height.Set(panelHeight, 0f);
            panel.Recalculate();

            UIElement topBar = new UIElement();

            topBar.Width.Set(0f, 1f);
            topBar.Height.Set(32f, 0f);
            panel.Append(topBar);

            sortButtons = new UIButtonChoice(new Texture2D[]
            {
                Main.inventorySortTexture[0],
                MagicStorage.Instance.GetTexture("Assets/SortID"),
                MagicStorage.Instance.GetTexture("Assets/SortName"),
                MagicStorage.Instance.GetTexture("Assets/SortNumber")
            },
                                             new LocalizedText[]
            {
                Language.GetText("Mods.MagicStorage.Common.SortDefault"),
                Language.GetText("Mods.MagicStorage.Common.SortID"),
                Language.GetText("Mods.MagicStorage.Common.SortName"),
                Language.GetText("Mods.MagicStorage.Common.SortStack")
            });

            sortButtons.OnClick += (a, b) => {
                if ((SortMode)sortButtons.choice != sortMode)
                {
                    sortMode = (SortMode)sortButtons.choice;
                    RefreshItems();
                }
            };

            topBar.Append(sortButtons);

            UITextPanel <LocalizedText> depositButton = new UITextPanel <LocalizedText>(Language.GetText("Mods.MagicStorage.Common.DepositAll"), 1f);

            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;
            depositButton.OnClick      += ClickDeposit;
            depositButton.OnMouseOver  += (a, b) => depositButton.BackgroundColor = lightBlue;
            depositButton.OnMouseOut   += (a, b) => depositButton.BackgroundColor = blue;

            topBar.Append(depositButton);

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

            searchBar = new UISearchBar(Language.GetText("Mods.MagicStorage.Common.SearchName"));
            searchBar.Left.Set(depositButtonRight + padding, 0f);
            searchBar.Width.Set(-depositButtonRight - 2 * padding, 1f);
            searchBar.Height.Set(0f, 1f);

            topBar.Append(searchBar);

            UIElement topBar2 = new UIElement();

            topBar2.Width.Set(0f, 1f);
            topBar2.Height.Set(32f, 0f);
            topBar2.Top.Set(36f, 0f);

            panel.Append(topBar2);

            filterButtons = new UIButtonChoice(new Texture2D[]
            {
                MagicStorage.Instance.GetTexture("Assets/FilterAll"),
                MagicStorage.Instance.GetTexture("Assets/FilterMelee"),
                MagicStorage.Instance.GetTexture("Assets/FilterPickaxe"),
                MagicStorage.Instance.GetTexture("Assets/FilterArmor"),
                MagicStorage.Instance.GetTexture("Assets/FilterPotion"),
                MagicStorage.Instance.GetTexture("Assets/FilterTile"),
                MagicStorage.Instance.GetTexture("Assets/FilterMisc"),
            },
                                               new LocalizedText[]
            {
                Language.GetText("Mods.MagicStorage.Common.FilterAll"),
                Language.GetText("Mods.MagicStorage.Common.FilterWeapons"),
                Language.GetText("Mods.MagicStorage.Common.FilterTools"),
                Language.GetText("Mods.MagicStorage.Common.FilterEquips"),
                Language.GetText("Mods.MagicStorage.Common.FilterPotions"),
                Language.GetText("Mods.MagicStorage.Common.FilterTiles"),
                Language.GetText("Mods.MagicStorage.Common.FilterMisc")
            });

            filterButtons.OnClick += (a, b) => {
                if ((FilterMode)filterButtons.choice != filterMode)
                {
                    filterMode = (FilterMode)filterButtons.choice;
                    RefreshItems();
                }
            };

            topBar2.Append(filterButtons);

            searchBar2 = new UISearchBar(Language.GetText("Mods.MagicStorage.Common.SearchMod"));
            searchBar2.Left.Set(depositButtonRight + padding, 0f);
            searchBar2.Width.Set(-depositButtonRight - 2 * padding, 1f);
            searchBar2.Height.Set(0f, 1f);

            topBar2.Append(searchBar2);

            slotZone = new UISlotZone(GetItem, inventoryScale);
            slotZone.Width.Set(0f, 1f);
            slotZone.Top.Set(76f, 0f);
            slotZone.Height.Set(-116f, 1f);
            slotZone.OnMouseDown += PressSlotZone;

            panel.Append(slotZone);

            UIScrollbar scrollbar = new UIScrollbar();

            scrollbar.Left.Set(10, 0);
            slotZone.SetScrollbar(scrollbar);

            panel.Append(scrollbar);

            capacityText = new UIText(string.Empty);
            capacityText.Top.Set(-32f, 1f);
            capacityText.Left.Set(6f, 0f);
            capacityText.Height.Set(32f, 0);
            panel.Append(capacityText);

            float slotZoneHeight = capacityText.GetDimensions().Y - (filterButtons.GetDimensions().Y + filterButtons.GetDimensions().Height);

            slotZone.SetDimensions(columns, (int)(slotZoneHeight / (slotHeight + slotZone.padding)));

            Append(panel);
        }
Exemple #4
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();
        }