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:
slot_ui.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_targetsgroup so it can receive dragged items. - Assigned metadata (
"inventory"and"slot_index") required by theDragDropSystem. - Added to the
"modular_inventory_panel"group for quick-move detection.
Drag & Drop Integration¶
panel intercepts mouse clicks on its slots and forwards them to the global DragDropSystem:
- Left Click (Press & Drag): Starts a full-stack drag (after moving beyond drag threshold).
- Shift + Left Click: Quick-moves entire stack to another open inventory.
- Right Click: Quick-moves single item to another open inventory.
Tooltip Management¶
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).
Auto-Finding the Tooltip
If you don't manually assign the tooltip property in the Inspector, ModularInventoryPanel will automatically search the scene tree for an ItemTooltip node in the "item_tooltip" group or inside a CanvasLayer.
Quick Move Integration¶
panel automatically participates in the quick-move system:
- When opened, it adds itself to the
"modular_inventory_panel"group. - Other
SlotUInodes can detect this panel when performing quick-move operations. - panel's
_inventoryproperty is accessed to determine where to transfer items.
Current Bug: Right-Click Handler Incomplete
In modular_panel.gd, the right-click handler currently does nothing (pass). Right-click quick-move is handled by SlotUI directly, but the panel's input handler should be updated to avoid confusion.