Esempio n. 1
0
 public ItemSlot(GUI.IActionIcon Item)
 {
     this.Item    = Item;
     this.Width   = 40;
     this.Height  = 40;
     this.CanGrab = true;
     this.Tint    = Color.Gray;
 }
Esempio n. 2
0
        public override void Click(float X, float Y)
        {
            if (!CanGrab && !CanPut) //nothing to do here
            {
                return;
            }
            IActionIcon mouseItem   = WM.MouseGrab;
            IActionIcon currentItem = this.Item;

            if (mouseItem == null)
            {
                if (currentItem == null) //nothing to do here
                {
                    return;
                }
                else // take the item
                {
                    WM.MouseGrab = currentItem;
                    this.Item    = null;
                    ItemOut?.Invoke(this, new ItemEventArgs(currentItem));
                }
            }
            else //if mouse has something
            {
                if (!CanPut) //can't grab item: mouse full
                {
                    return;
                }
                ItemEventArgs iargs = new ItemEventArgs(mouseItem);
                BeforeItemChanged?.Invoke(this, iargs);
                if (iargs.Cancel) //custom function declined the item or no custom function
                {
                    return;
                }
                if (currentItem == null) //put in item
                {
                    iargs = new ItemEventArgs(mouseItem);
                    ItemIn?.Invoke(this, iargs);
                    this.Item    = mouseItem;
                    WM.MouseGrab = null;
                }
                else //swap items
                {
                    iargs = new ItemEventArgs(mouseItem);
                    ItemIn?.Invoke(this, iargs);
                    if (iargs.Cancel)
                    {
                        return;
                    }
                    this.Item    = mouseItem;
                    WM.MouseGrab = currentItem;
                    iargs        = new ItemEventArgs(mouseItem);
                    ItemOut?.Invoke(this, iargs);
                }
            }
            base.Click(X, Y);
        }
Esempio n. 3
0
 public ItemEventArgs(GUI.IActionIcon Item)
 {
     this.Item = Item;
 }