Inventory Panel¶
ModularInventoryPanel is the primary UI component for viewing and managing a full inventory. It dynamically generates a grid of SlotUI nodes based on the capacity of the attached Inventory.
Setup in Editor¶
- Add a
ModularInventoryPanelnode to your UI (usually inside aCanvasLayer). - In the Inspector, assign the following properties:
- Grid Container: A
GridContainernode that will hold the dynamically generated slots. - Slot Scene:
SlotUI.tscnscene (pre-assigned by default). - Tooltip: An
ItemTooltipnode (optional, it will auto-find one if left empty). - Source Component:
InventoryComponentyou want this panel to display.
- Grid Container: A
How It Works¶
Dynamic Slot Generation¶
When the panel attaches to an Inventory, it clears any existing slots and instantiates a new SlotUI for every index up to inventory.capacity.
Each generated SlotUI is automatically:
- Added to the GridContainer.
- Tagged with the inventory_drop_targets group so it can receive dragged items.
- Assigned metadata ("inventory" and "slot_index") required by the DragDropSystem.
Drag & Drop Integration¶
The panel intercepts mouse clicks on its slots and forwards them to the global DragDropSystem:
- Left Click (Press & Drag): Starts a full-stack drag.
- Shift + Left Click: Quick-moves entire stack to another open inventory.
- Right Click: Starts a drag of exactly 1 item.
Tooltip Management¶
The panel listens to tooltip_requested and tooltip_hidden signals from its child SlotUI nodes. When a slot is hovered, the panel calls tooltip.show_tooltip(slot_data, mouse_position).