/// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="itemBinder">The part</param>
        /// <param name="parent">GUI parent of the part</param>
        /// <param name="partIndex">Index of the part</param>
        /// <param name="textBoxWidth">Width of the textBox</param>
        /// <param name="labeledControlWidth">Width of the labeledBox</param>
        public InventorySlotPart(ItemBinder itemBinder, InventorySlotItem parent, int partIndex, int textBoxWidth, int labeledControlWidth)
            : base(itemBinder, textBoxWidth, labeledControlWidth)
        {
            this.parent = parent;

            Size = new Size(326, 104);

            imageLabel        = new Label();
            imageLabel.Anchor = AnchorStyles.Left;
            imageLabel.Size   = new Size(IconData.ICON_WIDTH, IconData.ICON_HEIGHT);

            SetImage();

            Controls.Add(imageLabel, 0, 0);

            itemCore        = new TableLayoutPanel();
            itemCore.Anchor = AnchorStyles.Right;
            itemCore.Size   = new Size(200, 100);

            CreateSelector(new string[] { parent.itemBinder.itemData.partNames[partIndex], "air" });
            selector.DropDownStyle = ComboBoxStyle.DropDownList;
            itemCore.Controls.Add(selector, 0, 0);

            basicInfo = GenerateBasicInfo();
            itemCore.Controls.Add(basicInfo, 0, 1);

            Controls.Add(itemCore, 1, 0);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="playerDataFile">PlayerDataFile which inventory is to be used</param>
        public InventoryTab(PlayerDataFile playerDataFile)
        {
            Text = "Inventory";

            this.playerDataFile = playerDataFile;

            SetUpInventory(playerDataFile.bag);
            SetUpInventory(playerDataFile.inventory);

            itemBinders = new ItemBinder[40];
            itemSlots   = new InventorySlotItem[40];
            viewPanels  = new ViewPanel[40];

            for (int i = 0; i < 32; i++)
            {
                itemBinders[i] = new ItemBinder(playerDataFile.bag[i]);
                viewPanels[i]  = new ViewPanel(i, this);
                itemSlots[i]   = new InventorySlotItem(itemBinders[i], viewPanels[i], 140, 250);
            }

            for (int i = 32; i < 40; i++)
            {
                itemBinders[i] = new ItemBinder(playerDataFile.inventory[i - 32]);
                viewPanels[i]  = new ViewPanel(i, this);
                itemSlots[i]   = new InventorySlotItem(itemBinders[i], viewPanels[i], 140, 250);
            }

            TableLayoutPanel basicPanel = new TableLayoutPanel()
            {
                Dock     = DockStyle.Fill,
                AutoSize = true
            };

            itemView             = new TableLayoutPanel();
            itemView.Dock        = DockStyle.Top;
            itemView.AutoSize    = true;
            itemView.MinimumSize = new Size(0, 260);

            activeIndex = 0;
            viewPanels[activeIndex].BackColor = COLOR_SELECT;
            itemView.Controls.Add(itemSlots[activeIndex]);

            basicPanel.Controls.Add(itemView);

            TableLayoutPanel inventoryDisplay = new TableLayoutPanel()
            {
                CellBorderStyle = TableLayoutPanelCellBorderStyle.Outset,
                Anchor          = AnchorStyles.Bottom,
                Size            = new Size(946, 412)
            };

            inventoryDisplay.MouseLeave += (sender, e) => {
                itemView.Controls.RemoveAt(0);
                itemView.Controls.Add(itemSlots[activeIndex]);
                itemSlots[activeIndex].OverrideBug();
            };

            for (int i = 0; i < 40; i++)
            {
                inventoryDisplay.Controls.Add(viewPanels[i], i % 8, i / 8);
            }

            basicPanel.Controls.Add(inventoryDisplay);

            Controls.Add(basicPanel);
        }