Пример #1
0
        private void RegisterClickEvent(SlotGroup group, RenderedSlot slot)
        {
            if (slot.picture == null)
            {
                return;
            }
            slot.picture.Click += (sender, args) => {
                // Deselect old slot.
                if (selectedSlot != null)
                {
                    selectedSlot.background.Image = IMAGE_BACKGROUND;
                    selectedSlot.background.SendToBack();
                    selectedSlot.picture.Redraw();
                }

                // Select new slot.
                selectedSlot          = slot;
                slot.background.Image = IMAGE_BACKGROUNDSELECTED;
                slot.background.SendToBack();

                var data = group.window.GetAt(slot.index);
                HotbarGroup.Visible = false;
                if (data != null)
                {
                    SlotID.Text     = data.id.ToString();
                    SlotAmount.Text = data.count.ToString();
                    if (selectedWinow is IInventory && slot.hotbar)
                    {
                        HotbarGroup.Visible = true;
                    }
                }
            };
        }
Пример #2
0
 public void Add(RenderedSlot slot)
 {
     this.slots[index++] = slot;
     if (type == SlotGroupType.inventory)
     {
         slot.inventory = true;
     }
     else if (type == SlotGroupType.hotbar)
     {
         slot.hotbar = true;
     }
 }
Пример #3
0
        private RenderedSlot CreateSlot(int x, int y, byte index)
        {
            var slot = new RenderedSlot()
            {
                index      = index,
                background = new PictureBox()
                {
                    Size     = new Size(SIZE, SIZE),
                    Image    = IMAGE_BACKGROUND,
                    Location = new Point(x, y),
                    SizeMode = PictureBoxSizeMode.StretchImage
                },
                picture = new TransparentControl()
                {
                    Size     = new Size(SIZE, SIZE),
                    Location = new Point(x, y),
                }
            };

            this.Controls.Add(slot.picture);
            this.Controls.Add(slot.background);

            return(slot);
        }