public UIItemSlot(Vector2 pos, UIObject parent = null, Condition con = null, DrawInItemSlot db = null, DrawInItemSlot di = null, DrawInItemSlot pdi = null, bool drawAsNormalItemSlot = false, int contextForItemSlot = 1)
            : base(pos, new Vector2(52), parent)
        {
            this.item = new Item();

            this.conditions = con;

            this.size = new Vector2(52);
            //If you want to change the size of the item slot you can change it here or by changing it in your UIWindow file :)
            //The size is 52 by 52 as that is the size of InventoryBackTexture, you can change it to your own however.

            this.drawBack = db;
            //This is called when the background is to be drawn. Leave as null to use default draw.

            this.drawItem = di;
            //This is called when the item is drawn. It might be good to leave this null, or copy and paste the default code to change the origin.

            this.postDrawItem = pdi;
            //This is called after the item is drawn. Used to draw other things, such as the item tooltip.
            //To draw the item tooltip, use UIParameters.mousePos + Vector2(12) as your starting position for the text :)

            this.drawAsNormalItemSlot = drawAsNormalItemSlot;

            this.contextForItemSlot = contextForItemSlot;
        }
Exemple #2
0
 /// <summary>
 /// Create a new UIItemSlot.
 /// </summary>
 /// <param name="position">Position of the slot (px). If parent is not null, position is added to parent position.</param>
 /// <param name="size">Size of the slot</param>
 /// <param name="parent">Parent UIObject</param>
 /// <param name="condition">Condition checked before item is placed in slot. If null, all items are permitted.</param>
 /// <param name="drawBackground">Method run when slot background is drawn. If null, slot is drawn with default background texture.</param>
 /// <param name="drawItem">Method run when item in slot is drawn. If null, item is drawn in center of slot.</param>
 /// <param name="postDrawItem">Method run after item in slot is drawn. Use to draw elements over the item.</param>
 /// <param name="leftClick">Method run when slot is left clicked. Leave null for default behavior.</param>
 /// <param name="rightClick">Method run when slot is right clicked. Leave null for default behavior.</param>
 /// <param name="drawAsNormalItemSlot">Draw as an inventory ItemSlot.</param>
 /// <param name="contextForItemSlot">Context for slot if drawAsNormalItemSlot is true.</param>
 public UIItemSlot(Vector2 position, int size    = 52, UIObject parent = null, Condition condition = null,
                   DrawInItemSlot drawBackground = null, DrawInItemSlot drawItem = null, DrawInItemSlot postDrawItem = null,
                   LeftClick leftClick           = null, RightClick rightClick   = null, bool drawAsNormalItemSlot = false,
                   int contextForItemSlot        = 1) : base(position, new Vector2(size), parent)
 {
     this.item                 = new Item();
     this.conditions           = condition;
     this.drawBack             = drawBackground;
     this.drawItem             = drawItem;
     this.postDrawItem         = postDrawItem;
     this.leftClick            = leftClick;
     this.rightClick           = rightClick;
     this.drawAsNormalItemSlot = drawAsNormalItemSlot;
     this.contextForItemSlot   = contextForItemSlot;
 }