# 81 — WBP_DebugMenu

## Blueprint Spec — UE 5.5–5.7

---

### Parent Class
`UserWidget`

### Dependencies
- [`BPC_DevCheatManager`](../11-polish/80_BPC_DevCheatManager.md) — Cheat execution
- [`BPC_PlayerCamera`](../02-player/11_BPC_PlayerCamera.md) — Camera controls
- [`BPC_FPSCounter`](../11-polish/79_BPC_FPSCounter.md) — Performance display
- [`BPC_AIDirector`](../09-ai/57_BPC_AIDirector.md) — AI debug panel
- [`BPC_DynamicEventSystem`](../10-adaptive/67_BPC_DynamicEventSystem.md) — Event debug
- [`BPC_NarrativeState`](../07-narrative/36_BPC_NarrativeState.md) — Story state viewer

### Purpose
Visual debug overlay menu for developers and QA testers. Provides categorized panels for toggling debug features, viewing runtime state (narrative, AI, events, inventory), adjusting world settings (time scale, lighting), and executing cheat commands from a user-friendly UI. Accessible via the ~ console toggle or from the BPC_DevCheatManager. Only available in non-shipping builds.

### Enums

**EDebugPanel**

| Value | Description |
|-------|-------------|
| Main | Top-level menu |
| Cheats | Cheat toggles |
| Performance | FPS, memory, draw calls |
| AI | AI state and debug vis |
| Narrative | Quest/chapter state |
| World | Time, lighting, weather |
| Camera | Camera modes |
| Inventory | Item list and manipulation |
| Events | Dynamic event state |

### Variables

| Name | Type | Description |
|------|------|-------------|
| `Panels` | TMap\<EDebugPanel, UUserWidget\> | Sub-panel references |
| `ActivePanel` | EDebugPanel | Currently visible |
| `bIsOpen` | Bool | Menu visible |
| `bMinimized` | Bool | Compact view |
| `DebugConsoleText` | FText | Command input |

### Functions

| Name | Inputs | Outputs | Description |
|------|--------|---------|-------------|
| `OpenMenu` | — | — | Show debug menu |
| `CloseMenu` | — | — | Hide debug menu |
| `ToggleMenu` | — | — | Open/close |
| `SwitchPanel` | Panel: EDebugPanel | — | Change active panel |
| `GetMinimumView` | — | — | Compact mode |
| `ExecuteCommandFromUI` | Command: FString | — | Run cheat |
| `UpdateAIDebugDisplay` | — | — | Refresh AI info |
| `UpdatePerformanceDisplay` | Metrics: FPerformanceMetrics | — | Refresh FPS/stats |
| `UpdateNarrativeStateDisplay` | — | — | Show story state |
| `UpdateEventStateDisplay` | — | — | Show event state |
| `ToggleGodModeUI` | — | — | Toggle from UI |
| `ToggleNoClipUI` | — | — | Toggle from UI |
| `ToggleCollisionDebug` | — | — | Toggle from UI |
| `ToggleAIVisibility` | — | — | Toggle from UI |
| `SetTimeScaleFromUI` | Scale: Float | — | Slider control |
| `SpawnItemFromUI` | ItemID: FString | — | Drop-down spawn |
| `SkipToChapterFromUI` | ChapterID: FString | — | Drop-down skip |

### Blueprint Flow

```
[OpenMenu]
  └─► If bIsOpen: return
  └─► bIsOpen = true
  └─► Set input mode: GameAndUI (mouse cursor visible)
  └─► SetVisibility(Visible)
  └─► Default panel: Main
  └─► Pause game time (optional)
  └─► Bind keyboard shortcuts:
         Tab -> SwitchPanel(next)
         Esc -> CloseMenu
         F1 -> Cheats, F2 -> Performance, F3 -> AI
         F4 -> Narrative, F5 -> World, F6 -> Camera

[CloseMenu]
  └─► bIsOpen = false
  └─► Set input mode: GameOnly
  └─► SetVisibility(Collapsed)
  └─► Resume game time (if paused)

[SwitchPanel]
  └─► Hide all sub-panels
  └─► ActivePanel = Panel
  └─► Show corresponding sub-panel
  └─► Update displayed data:
         Performance -> Call BPC_FPSCounter.GetPerformanceSnapshot()
         AI -> Call BPC_AIDirector.GetDebugState()
         Narrative -> Call BPC_NarrativeState.GetCurrentChapter()
         Events -> Call BPC_DynamicEventSystem.GetActiveEvents()

[UI Layout]
  └─► Left sidebar: Panel selection buttons
  └─► Main content: Active panel content
  └─► Bottom bar: Command input field + Execute button + Minimize
  └─► Top bar: Indices for quick-nav, FPS counter overlay

[ExecuteCommandFromUI]
  └─► Get text from command input field
  └─► Pass to BPC_DevCheatManager.ExecuteCheat()
  └─► Clear input field
  └─► Add to command history
  └─► Show result feedback text (success/failure)
```

### Event Dispatchers

| Name | Payload | Description |
|------|---------|-------------|
| `OnDebugCommandExecuted` | Command: FString | Command run |
| `OnPanelChanged` | Panel: EDebugPanel | Switch panels |

### Communications With

| Target | Method | Why |
|--------|--------|-----|
| [`BPC_DevCheatManager`](../11-polish/80_BPC_DevCheatManager.md) | Direct call | Execute commands |
| [`BPC_FPSCounter`](../11-polish/79_BPC_FPSCounter.md) | Direct call | Performance data |
| [`BPC_AIDirector`](../09-ai/57_BPC_AIDirector.md) | Direct call | AI debug state |
| [`BPC_NarrativeState`](../07-narrative/36_BPC_NarrativeState.md) | Direct call | Story state |
| [`BPC_DynamicEventSystem`](../10-adaptive/67_BPC_DynamicEventSystem.md) | Direct call | Event debug |
| [`BPC_PlayerCamera`](../02-player/11_BPC_PlayerCamera.md) | Direct call | Camera modes |
| [`BPC_DevCheatManager`](../11-polish/80_BPC_DevCheatManager.md) | Direct call | All cheat toggles |

### Reuse Notes
- Panel-based architecture allows easy addition of new debug panels
- All interactive elements bound to DevCheatManager functions
- Comms-visible only; all logic lives in DevCheatManager
- Command input field mirrors console functionality
- Quick-nav keyboard shortcuts for common panels
- Compact/minimized mode for minimal screen intrusion during gameplay
- Designed for developer productivity, not end users