From 65b692f293115ada9132f9826173aa2414e474f6 Mon Sep 17 00:00:00 2001 From: Jason Hilder Date: Wed, 24 Jun 2026 10:33:09 +0200 Subject: [PATCH] Added an info box for name, repo link. --- src/simulator/gui_info_box.odin | 51 +++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 src/simulator/gui_info_box.odin diff --git a/src/simulator/gui_info_box.odin b/src/simulator/gui_info_box.odin new file mode 100644 index 0000000..3e56b45 --- /dev/null +++ b/src/simulator/gui_info_box.odin @@ -0,0 +1,51 @@ +package simulator +import rl "vendor:raylib" + +gui_info_box :: proc(rect: rl.Rectangle, sim: ^Simulator, screen_width: f32, screen_height: f32) { + if sim.info_box { + screen_rect := rl.Rectangle{0, 0, screen_width, screen_height} + rl.DrawRectangleRec(screen_rect, {0, 0, 0, 140}) + if rl.GuiWindowBox(rect, "App Info") > 0 { + sim.info_box = false + } + + content_y := rect.y + 24 + center_x := rect.x + rect.width / 2 + + name_text : cstring = "Octal Cookie" + desc_text : cstring = "A CHIP-8 emulator and simulator written in Odin." + source_text : cstring = "https://codeberg.org/jasonhilder/octal_cookie" + + name_size := rl.MeasureTextEx(sim.font, name_text, 18, 1) + desc_size := rl.MeasureTextEx(sim.font, desc_text, 18, 1) + source_size := rl.MeasureTextEx(sim.font, source_text, 18, 1) + + rl.DrawTextEx(sim.font, name_text, {center_x - name_size.x / 2, content_y + 20}, 18, 1, rl.WHITE) + + rl.DrawTextEx(sim.font, desc_text, {center_x - desc_size.x / 2, content_y + 46}, 18, 1, rl.WHITE) + + source_pos := rl.Vector2{center_x - source_size.x / 2, content_y + 72} + rl.DrawTextEx(sim.font, source_text, source_pos, 18, 1, rl.SKYBLUE) + + source_rect := rl.Rectangle{ + x = source_pos.x, + y = source_pos.y, + width = source_size.x, + height = source_size.y, + } + + mouse := rl.GetMousePosition() + if rl.CheckCollisionPointRec(mouse, source_rect) { + rl.SetMouseCursor(.POINTING_HAND) + + rl.DrawRectangleRec( {source_pos.x, source_pos.y + source_size.y - 1, source_size.x, 1}, rl.SKYBLUE,) + + if rl.IsMouseButtonPressed(.LEFT) { + rl.OpenURL("https://codeberg.org/jasonhilder/octal_cookie") + } + + } else { + rl.SetMouseCursor(.DEFAULT) + } + } +}