diff --git a/src/sandbox_main.zig b/src/sandbox_main.zig index 46de7a9..c3c8e20 100644 --- a/src/sandbox_main.zig +++ b/src/sandbox_main.zig @@ -444,4 +444,9 @@ fn handleInput(entities: *sandbox.Entities, rng: *std.Random, paused: *bool) voi if (rl.isKeyPressed(.space)) { paused.* = !paused.*; } + + // toggle ui: tab + if (rl.isKeyPressed(.tab)) { + ui.show_ui = !ui.show_ui; + } } diff --git a/src/ui.zig b/src/ui.zig index 1c520e2..a0e58c0 100644 --- a/src/ui.zig +++ b/src/ui.zig @@ -21,11 +21,19 @@ pub const dim_text_color = rl.Color.gray; pub const highlight_color = rl.Color.yellow; pub const box_bg = rl.Color{ .r = 0, .g = 0, .b = 0, .a = 200 }; +// ============================================================================= +// state +// ============================================================================= + +pub var show_ui: bool = true; + // ============================================================================= // drawing functions // ============================================================================= pub fn drawMetrics(entities: *const sandbox.Entities, update_us: i64, render_us: i64, paused: bool, font: rl.Font) void { + if (!show_ui) return; + var buf: [256]u8 = undefined; // fps box (above metrics) @@ -75,7 +83,7 @@ pub fn drawMetrics(entities: *const sandbox.Entities, update_us: i64, render_us: } fn drawControls(font: rl.Font, metrics_bottom: i32) void { - const ctrl_box_height: i32 = @intFromFloat(small_line_height * 4 + box_padding * 2); + const ctrl_box_height: i32 = @intFromFloat(small_line_height * 5 + box_padding * 2); const ctrl_box_y: i32 = metrics_bottom + 5; rl.drawRectangle(5, ctrl_box_y, 175, ctrl_box_height, box_bg); @@ -86,6 +94,7 @@ fn drawControls(font: rl.Font, metrics_bottom: i32) void { "shift +/-: 50k", "space: pause", "r: reset", + "tab: toggle ui", }; for (controls) |text| {