# WBP_InventoryMenu — Widget (Inventory Screen)

**Parent Class:** `UUserWidget` (created via Widget Blueprint)
**Dependencies:** `BPC_InventorySystem`, `SS_UIManager`, `BPC_ActiveItemSystem`, `BPC_EquipmentSlotSystem`, `DA_ItemData`
**File:** `WBP_InventoryMenu`

---

## Purpose

Full-screen inventory grid view. Supports standard grid-list display, diegetic overlay mode, and radial quick-slot menu. Reads from `BPC_InventorySystem` but never writes — all mutations go through the component.

---

## Responsibilities

- Display inventory slots in a scrollable grid (3 columns, N rows)
- Show item details in a side panel when an item is selected
- Support drag-and-drop between slots, between slots and equipment slots, and between slots and quick slots
- Support right-click / gamepad context menu (Use, Equip, Drop, Examine, Combine)
- Display item tooltip on hover
- Filter/sort by category via tabs (All, Documents, Tools, Keys, Consumables, Quest Items)
- Display weight bar at bottom (filled fractional, color-coded per weight tier)
- Support `E_InventoryViewMode` switching (Grid, Diegetic Overlay, Radial Quick)
- Close on B/Cancel or when `OnMenuClosed` fires from `SS_UIManager`

---

## Enums

```cpp
// Defined within the widget or a shared parent
E_InventoryViewMode
{
    Grid,
    DiegeticOverlay,
    RadialQuick
}
```

---

## Variables

| Name | Type | Description |
|------|------|-------------|
| `OwningInventory` | `BPC_InventorySystem` | Cached reference (set on Construct) |
| `ViewMode` | `E_InventoryViewMode` | Current display mode |
| `SelectedSlotIndex` | Int | Currently highlighted slot (-1 = none) |
| `SelectedItemData` | `DA_ItemData` | Item currently shown in detail panel |
| `GridPanel` | `UniformGridPanel` | Main slot grid |
| `DetailPanel` | `WBP_ItemDetailPanel` | Right-side detail panel |
| `WeightBar` | `ProgressBar` | Bottom weight bar |
| `WeightText` | `TextBlock` | "12.5 / 50.0 kg" |
| `TabButtons` | Array of `Button` | All, Documents, Tools, Keys, etc. |
| `ActiveFilter` | `E_ItemCategory` | Current filter |
| `ContextMenu` | `WBP_ContextMenu` | Right-click popup |
| `RadialMenu` | `WBP_RadialMenu` | Radial quick-slot selector (if RadialQuick mode) |

---

## Functions / Events

| Name | Inputs | Outputs | Description |
|------|--------|---------|-------------|
| `Construct` | — | — | Cache inventory, bind dispatchers, rebuild grid |
| `RebuildGrid` | Filter: `E_ItemCategory` | — | Clear grid, add slot widgets for matching items |
| `OnSlotClicked` | SlotIndex: Int | — | Set SelectedSlotIndex, update detail panel |
| `ShowContextMenu` | SlotIndex: Int | — | Open context menu at mouse position |
| `ContextMenuAction` | Action: `E_ItemAction` | — | Route to UseItem, EquipItem, DropItem, etc. |
| `UseItem` | SlotIndex: Int | — | Call inventory.UseItem(SlotIndex) |
| `EquipItem` | SlotIndex: Int | — | Call inventory.EquipFromSlot(SlotIndex) |
| `DropItem` | SlotIndex: Int | — | Call inventory.DropItem(SlotIndex) |
| `CombineItems` | SourceIndex: Int, TargetIndex: Int | — | Call inventory.CombineItems(Source, Target) |
| `ExamineItem` | SlotIndex: Int | — | Request narrative system examine description |
| `SwitchViewMode` | NewMode: `E_InventoryViewMode` | — | Transition between Grid/Diegetic/Radial |
| `UpdateWeightBar` | CurrentWeight: Float, MaxWeight: Float | — | Set bar percent, color per tier, update text |
| `OnInventoryChanged` | SlotIndex: Int | — | Called via dispatcher; rebuild affected row |
| `HandleNavigation` | Direction: `E_NavDirection` | — | Keyboard/gamepad slot navigation |

---

## Event Dispatchers

| Name | Parameters | Fired When |
|------|-----------|------------|
| `OnItemSelected` | ItemData: `DA_ItemData` | A slot is clicked |
| `OnItemUsed` | SlotIndex: Int | An item is used |
| `OnItemEquipped` | SlotIndex: Int | An item is equipped |
| `OnItemDropped` | SlotIndex: Int | An item is dropped from inventory |
| `OnCombineRequested` | SourceIndex: Int, TargetIndex: Int | Combine action initiated |
| `OnViewModeChanged` | NewMode: `E_InventoryViewMode` | View mode transitions |

---

## Blueprint Flow — Grid Population

```mermaid
flowchart TD
    A[Construct widget] --> B[Cache BPC_InventorySystem]
    B --> C[Bind OnInventoryChanged dispatcher]
    C --> D[RebuildGrid current filter]
    D --> E[Loop items in inventory]
    E --> F{Matches filter?}
    F -->|Yes| G[Create WBP_InventorySlot]
    G --> H[Add to UniformGridPanel column row]
    F -->|No| I[Skip]
    H --> J[Bind slot.OnClicked]
    J --> K[Update WeightBar]
```

---

## Communications With

| Target System | Method | Why |
|--------------|--------|-----|
| [`BPC_InventorySystem`](../04-inventory/BPC_InventorySystem.md) | Direct reference, dispatchers | Read items, execute mutations |
| [`SS_UIManager`](44_SS_UIManager.md) | `OpenMenu` / `CloseMenu` | Menu lifecycle |
| [`BPC_ActiveItemSystem`](../04-inventory/BPC_ActiveItemSystem.md) | Direct calls | Assign/clear quick slots from radial menu |
| [`BPC_EquipmentSlotSystem`](../04-inventory/BPC_EquipmentSlotSystem.md) | Dispatcher (`OnEquipmentChanged`) | Update equipped indicator |
| [`BPC_InteractionDetector`](../03-interaction/16_BPC_InteractionDetector.md) | Dispatcher | Drop item creates pickup actor |
| [`BPC_NarrativeStateSystem`] | Function | Examine item triggers narrative |

---

## Reuse Notes

The grid population loop is the same pattern used by container inventories and shop UIs — the only difference is the source `BPC_InventorySystem` reference. Consider creating a shared `WBP_SlotGrid` base if containers need the same logic. The Diegetic Overlay and Radial Quick modes are purely visual transformations of the same slot data.

- Renamed from `WBP_InventoryUI` to `WBP_InventoryMenu` per Master naming convention.
- Cross-references updated: `BPC_InventoryComponent` → `BPC_InventorySystem`, `BPC_InventoryQuickSlot` → `BPC_ActiveItemSystem`, `BPC_EquipmentSystem` → `BPC_EquipmentSlotSystem`.