Author:ptrace Comitter:ptrace Date:2026-05-05 05:35:19 UTC

smol statistics in corner

diff --git a/src/cells.jai b/src/cells.jai index 8eb0395..ea3bd6e 100644 --- a/src/cells.jai +++ b/src/cells.jai @@ -28,23 +28,30 @@ cells_fit_zoom :: ($update_camera: bool = true) -> Camera2D {     return cam; } cells_draw_2d :: () { cells_draw_2d :: (stats: *Statistics) {     code :: #code {         label: string;         color: Color;         if it == {         case 0;         if it_index == 0 {             label = "R";             color = COLOR_NODE_ROOT;         case NODE_INTERNAL;             label = "N";             color = COLOR_NODE_INTERNAL;         case NODE_EMPTY;             color = COLOR_NODE_EMPTY;         case;             label = tprint("%", it);             color = COLOR_NODE_VALUE;             stats.nodes += 1;         }         else {             if it == {             case NODE_INTERNAL;                 label = "N";                 color = COLOR_NODE_INTERNAL;                 stats.nodes += 1;             case NODE_EMPTY;                 color = COLOR_NODE_EMPTY;                 stats.empty += 1;             case;                 label = tprint("%", it);                 color = COLOR_NODE_VALUE;                 stats.children += 1;             }         } @@ -65,18 +72,11 @@ cells_draw_2d :: () {         );     }     traverse_tree_array(code);     traverse_tree_array(code, stats); } cells_draw_screen :: () {     info := to_c_string(tprint("Array Items %", tree.count));     DrawText(         info,         SCREEN_WIDTH - MeasureText(info, 18) - 16,         SCREEN_HEIGHT - 24,         18,         { 160, 160, 200, 220 }     ); cells_draw_screen :: (stats: *Statistics) {     gui_statistics(stats);     code :: #code {         if CheckCollisionPointRec( @@ -124,7 +124,7 @@ dimensions :: (length: int) -> (row: int, col: int) {     return cast(int, row), cast(int, col); } traverse_tree_array :: ($code1: Code) { traverse_tree_array :: ($code1: Code, stats: *Statistics = null) {     rect: Rectangle;     rect.x = 0.0;     rect.y = 0.0; diff --git a/src/gui.jai b/src/gui.jai index ddf4902..2bbb578 100644 --- a/src/gui.jai +++ b/src/gui.jai @@ -28,6 +28,30 @@ gui_draw_screen :: () {     draw_text(right, "Cells", SIZE, .CELLS); } gui_statistics :: (st: *Statistics) {     FONT_SIZE :: 20;     using st;     total = nodes + children + empty;     stats := tprint("Nodes: %1 | Children: %2 | Empty: %3 | Total: %4",         nodes,         children,         empty,         total     );     info := to_c_string(stats);     DrawText(         info,         SCREEN_WIDTH - MeasureText(info, FONT_SIZE) - 16,         SCREEN_HEIGHT - 24,         FONT_SIZE,         { 160, 160, 200, 220 }     ); } #scope_file diff --git a/src/main.jai b/src/main.jai index 8a26c95..21348c7 100644 --- a/src/main.jai +++ b/src/main.jai @@ -93,6 +93,13 @@ Node :: struct {     right: int  = NODE_EMPTY; } Statistics :: struct {     nodes: int;     children: int;     empty: int;     total: int; } #if true main :: () {     #if MEMORY_DEBUGGER_ENABLED defer report_memory_leaks(); @@ -154,8 +161,10 @@ Node :: struct {     push_allocator(temp);     while !WindowShouldClose() {         frame_time = GetFrameTime();         stat_vtree: Statistics;         stat_cells: Statistics;         frame_time   = GetFrameTime();         mouse_screen = GetMousePosition();         mouse_world  = GetScreenToWorld2D(mouse_screen, camera); @@ -182,18 +191,20 @@ Node :: struct {             defer EndMode2D();             if mode == {             case .TRAD_TREE;  vtree_draw_2d();             case .TRAD_TREE;  vtree_draw_2d(*stat_vtree);             case .HYPER_TREE; // Todo;             case .CELLS;      cells_draw_2d();             case .CELLS;      cells_draw_2d(*stat_cells);             }             input_draw_selection();         }         gui_draw_screen();         if mode == {         case .TRAD_TREE;  vtree_draw_screen();         case .TRAD_TREE;  vtree_draw_screen(*stat_vtree);         case .HYPER_TREE; // Todo;         case .CELLS;      cells_draw_screen();         case .CELLS;      cells_draw_screen(*stat_cells);         }         DrawFPS(10, 10); @@ -201,7 +212,6 @@ Node :: struct {         DrawText(TextFormat("Mouse (World):  %", mouse_world), 10, 80, 20, WHITE);         DrawText(TextFormat("Mouse (Screen): %", mouse_screen), 10, 120, 20, WHITE);         gui_draw_screen();         reset_temporary_storage();     } diff --git a/src/vtree.jai b/src/vtree.jai index 309b448..4ca972f 100644 --- a/src/vtree.jai +++ b/src/vtree.jai @@ -37,10 +37,17 @@ vtree_fit_zoom :: ($update_camera: bool = true) -> Camera2D {     return cam; } vtree_draw_2d :: () { vtree_draw_2d :: (stat: *Statistics) {     for i: 0..node_count-1 {         n := nodes[i];         if n.value == {         case NODE_EMPTY;    stat.empty += 1;         case NODE_INTERNAL; stat.nodes += 1;         case;             stat.children += 1;         }         idx_left  := 2 * n.index + 1;         idx_right := 2 * n.index + 2; @@ -58,7 +65,6 @@ vtree_draw_2d :: () {             );         }         // CLANK         node_scale := pow(DEPTH_SCALE_NODE, cast(float)n.depth);         font_scale := pow(DEPTH_SCALE_FONT, cast(float)n.depth); @@ -116,19 +122,11 @@ vtree_draw_2d :: () {     } } vtree_draw_screen :: () {     info := to_c_string(tprint("Nodes %", node_count));     DrawText(         info,         SCREEN_WIDTH - MeasureText(info, 18) - 16,         SCREEN_HEIGHT - 24,         18,         { 160, 160, 200, 220 }     ); vtree_draw_screen :: (stat: *Statistics) {     gui_statistics(stat);     for i: 0..node_count-1 {         n := nodes[i];         // CLANK         node_scale  := pow(DEPTH_SCALE_NODE, cast(float)n.depth);         node_r := NODE_RADIUS * node_scale;         n_screen := GetWorldToScreen2D({ n.x, n.y }, camera);