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: slot_ui.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.
  • 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:

  1. When opened, it adds itself to the "modular_inventory_panel" group.
  2. Other SlotUI nodes can detect this panel when performing quick-move operations.
  3. panel's _inventory property 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.