diff options
| author | Alec Goncharow <alec@goncharow.dev> | 2026-05-27 14:34:32 -0400 |
|---|---|---|
| committer | Alec Goncharow <alec@goncharow.dev> | 2026-05-27 14:34:32 -0400 |
| commit | 93ad8a5cdeb8421bcf02195bc470257935062138 (patch) | |
| tree | bd76666718c27f3c79e015f6c9f7404a38663207 /src/debug_overlay.jai | |
| parent | 13335d5ee6778ad65d49a774274bae84a64a7edf (diff) | |
Working widget idea, makings of a maze app
Forgot to commit as I went over the weekend, which is fine, not a ton of
interesting stuff just yet.
Diffstat (limited to 'src/debug_overlay.jai')
| -rw-r--r-- | src/debug_overlay.jai | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/debug_overlay.jai b/src/debug_overlay.jai new file mode 100644 index 0000000..90adc87 --- /dev/null +++ b/src/debug_overlay.jai @@ -0,0 +1,48 @@ +// Loaded into main.jai so it inherits global imports. + +#scope_file +debug_lines: [..] string; +debug_panel: UI_Panel; +panel_initialized := false; + +#scope_export + +debug_add_value :: (fmt: string, args: .. Any) { + builder: String_Builder; + print_to_builder(*builder, fmt, ..args); + array_add(*debug_lines, builder_to_string(*builder)); +} + +render_debug_overlay :: (font: *Simp.Dynamic_Font) { + if !font return; + + if !panel_initialized { + debug_panel.x = cast(float)window_width - 800.0; + debug_panel.y = cast(float)window_height - 40.0; + debug_panel.w = 300.0; + debug_panel.h = 40.0; + debug_panel.font = font; + ui_register_panel(*debug_panel); + panel_initialized = true; + } + + target_h := 50.0 + debug_lines.count * 32.0; + top := debug_panel.y + debug_panel.h; + debug_panel.h = target_h; + debug_panel.y = top - debug_panel.h; + + array_reset_keeping_memory(*debug_panel.elements); + + array_add(*debug_panel.elements, .{type=.HEADER, id=0, x0=0.0, y0=debug_panel.h - 40.0, x1=debug_panel.w, y1=debug_panel.h, label="Debug"}); + + y := debug_panel.h - 40.0; + for debug_lines { + y -= 32.0; + array_add(*debug_panel.elements, .{type=.DYNAMIC_TEXT, id=0, x0=10.0, y0=y, x1=debug_panel.w, y1=y+32.0, label=it}); + } +} + +clear_debug_overlay :: () { + for debug_lines free(it); + array_reset_keeping_memory(*debug_lines); +} |
