Skip to content

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

  1. Add a ModularInventoryPanel node to your UI (usually inside a CanvasLayer).
  2. In the Inspector, assign the following properties:
    • Grid Container: A GridContainer node that will hold the dynamically generated slots.
    • Slot Scene: SlotUI.tscn scene (pre-assigned by default).
    • Tooltip: An ItemTooltip node (optional, it will auto-find one if left empty).
    • Source Component: InventoryComponent you want this panel to display.

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).