|
| 1 | +Toolbox Aid |
| 2 | +David Quesenberry |
| 3 | +04/05/2026 |
| 4 | +BUILD_PR_CANVAS_DEBUG_OVERLAY_RENDERER.md |
| 5 | + |
| 6 | +# BUILD PR |
| 7 | +Canvas Debug Overlay Renderer |
| 8 | + |
| 9 | +## Objective |
| 10 | +Build a real visual HUD for the existing dev console/debug overlay system and wire it into one sample so the overlay renders on-canvas inside the running game. |
| 11 | + |
| 12 | +## Scope |
| 13 | +- Create a dedicated canvas HUD renderer file |
| 14 | +- Wire the HUD renderer into the existing sample-level dev console integration |
| 15 | +- Render overlay content after gameplay/world rendering |
| 16 | +- Reuse existing overlay diagnostics and panel state from the current debug runtime |
| 17 | +- Keep implementation isolated to tool/dev + one sample integration target |
| 18 | + |
| 19 | +## Required Outputs |
| 20 | +Codex must produce implementation code and the implementation delta ZIP at: |
| 21 | +<project folder>/tmp/BUILD_PR_CANVAS_DEBUG_OVERLAY_RENDERER_delta.zip |
| 22 | + |
| 23 | +## File Targets |
| 24 | +Expected implementation focus: |
| 25 | +- tools/dev/canvasDebugHudRenderer.js |
| 26 | +- tools/dev/devConsoleIntegration.js |
| 27 | +- one sample entry file only |
| 28 | +- optional test file if needed for renderer validation |
| 29 | + |
| 30 | +## Implementation Requirements |
| 31 | + |
| 32 | +### 1. New HUD renderer |
| 33 | +Create: |
| 34 | +tools/dev/canvasDebugHudRenderer.js |
| 35 | + |
| 36 | +Responsibilities: |
| 37 | +- accept a 2D canvas context and overlay data |
| 38 | +- render a lightweight translucent HUD panel |
| 39 | +- draw title + section headers + line items |
| 40 | +- support current/active panel highlighting |
| 41 | +- support compact layout with predictable padding |
| 42 | +- render safely even when some diagnostics are missing |
| 43 | +- remain dependency-free |
| 44 | + |
| 45 | +### 2. Wire into existing integration |
| 46 | +Update: |
| 47 | +tools/dev/devConsoleIntegration.js |
| 48 | + |
| 49 | +Requirements: |
| 50 | +- import canvasDebugHudRenderer.js |
| 51 | +- keep combo-key bindings already implemented: |
| 52 | + - Shift + ` => toggle console |
| 53 | + - Ctrl + Shift + ` => toggle overlay |
| 54 | + - Ctrl + Shift + R => reload |
| 55 | + - Ctrl + Shift + ] => next panel |
| 56 | + - Ctrl + Shift + [ => previous panel |
| 57 | +- expose a method that draws the HUD onto a provided canvas context |
| 58 | +- preserve sample-safe boundaries |
| 59 | +- do not move logic into engine core |
| 60 | + |
| 61 | +### 3. Sample wiring |
| 62 | +Modify ONE sample/dev entry file only. |
| 63 | + |
| 64 | +Requirements: |
| 65 | +- initialize integration once |
| 66 | +- collect diagnostics in the loop |
| 67 | +- draw world/game first |
| 68 | +- draw debug HUD last |
| 69 | +- ensure repeated toggles do not duplicate listeners or runtime instances |
| 70 | + |
| 71 | +## HUD Rendering Rules |
| 72 | +- Render last in frame order |
| 73 | +- Default position: top-left |
| 74 | +- Use readable mono or browser-safe default font |
| 75 | +- Use translucent dark background |
| 76 | +- Use contrasting text |
| 77 | +- Keep dimensions adaptive to content |
| 78 | +- Avoid touching gameplay transforms/camera transforms |
| 79 | +- Use save()/restore() around canvas state mutations |
| 80 | +- Do not assume fullscreen |
| 81 | +- Do not require HTML DOM overlay |
| 82 | + |
| 83 | +## Minimum Visible Content |
| 84 | +HUD should visibly support: |
| 85 | +- Runtime |
| 86 | +- Frame |
| 87 | +- Scene |
| 88 | +- Camera |
| 89 | +- Entities |
| 90 | +- Render |
| 91 | +- Tilemap |
| 92 | +- Input |
| 93 | +- Hot Reload |
| 94 | +- Validation |
| 95 | + |
| 96 | +## Non-Goals |
| 97 | +- No engine renderer rewrite |
| 98 | +- No DOM-based console window |
| 99 | +- No CSS/HTML overlay framework |
| 100 | +- No broad sample migrations |
| 101 | +- No debug system spread across engine modules |
| 102 | + |
| 103 | +## Acceptance Criteria |
| 104 | +- Sample still runs normally |
| 105 | +- Shift + ` toggles console state |
| 106 | +- Ctrl + Shift + ` toggles HUD visibility |
| 107 | +- HUD draws on canvas |
| 108 | +- HUD renders after gameplay content |
| 109 | +- Panel navigation works |
| 110 | +- Missing diagnostics do not crash rendering |
| 111 | +- No F-key bindings remain |
| 112 | +- No engine core files modified |
| 113 | + |
| 114 | +## Validation |
| 115 | +- node --check on all touched JS files |
| 116 | +- run sample manually |
| 117 | +- verify HUD visible on canvas |
| 118 | +- verify combo keys work |
| 119 | +- verify reload combo does not browser-refresh the page |
| 120 | +- verify panel cycling updates visible section focus |
| 121 | +- verify no duplicate event listeners after reload/reinit |
| 122 | + |
| 123 | +## Risks |
| 124 | +- Canvas state leakage |
| 125 | +- overlay drawn before game content |
| 126 | +- integration duplicates runtime |
| 127 | +- browser key conflict regressions |
| 128 | + |
| 129 | +## Rollback |
| 130 | +If instability appears: |
| 131 | +- disable HUD draw call in sample |
| 132 | +- keep runtime logic intact |
| 133 | +- preserve combo key system |
0 commit comments