Example #1
0
 /// <summary>
 /// Adds an ItemSlotGrid with Exclusions.
 /// </summary>
 /// <param name="inventory">The attached inventory.</param>
 /// <param name="SendPacket">A handler that should send supplied network packet to the server, if the inventory modifications should be synced</param>
 /// <param name="columns">The number of columns.</param>
 /// <param name="excludingSlots">The slots that have been excluded from the slot grid.</param>
 /// <param name="bounds">The bounds of the slot grid.</param>
 /// <param name="key">The name of the slot grid.</param>
 public static GuiComposer AddItemSlotGridExcl(this GuiComposer composer, IInventory inventory, API.Common.Action <object> SendPacket, int columns, int[] excludingSlots, ElementBounds bounds, string key = null)
 {
     if (!composer.composed)
     {
         composer.AddInteractiveElement(new GuiElementItemSlotGridExcl(composer.Api, inventory, SendPacket, columns, excludingSlots, bounds), key);
         GuiElementItemSlotGridBase.UpdateLastSlotGridFlag(composer);
     }
     return(composer);
 }
        internal static void UpdateLastSlotGridFlag(GuiComposer composer)
        {
            Dictionary <IInventory, GuiElementItemSlotGridBase> lastelembyInventory = new Dictionary <IInventory, GuiElementItemSlotGridBase>();

            foreach (GuiElement elem in composer.interactiveElements.Values)
            {
                if (elem is GuiElementItemSlotGridBase)
                {
                    GuiElementItemSlotGridBase slotgridelem = elem as GuiElementItemSlotGridBase;
                    slotgridelem.isLastSlotGridInComposite = false;

                    lastelembyInventory[slotgridelem.inventory] = slotgridelem;
                }
            }

            foreach (GuiElementItemSlotGridBase lastelem in lastelembyInventory.Values)
            {
                lastelem.isLastSlotGridInComposite = true;
            }
        }