Added an info box for name, repo link.

This commit is contained in:
2026-06-24 10:33:09 +02:00
parent 6d706a34cd
commit 65b692f293
+51
View File
@@ -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)
}
}
}