Renamed gui to simulator as a better structure.

This commit is contained in:
2026-06-09 08:16:53 +02:00
parent 2df6a14610
commit f8ef6f030f
12 changed files with 153 additions and 34 deletions
+46
View File
@@ -0,0 +1,46 @@
package simulator
import "core:fmt"
import rl "vendor:raylib"
gui_status_bar :: proc(rect: rl.Rectangle, sim: ^Simulator) {
rl.DrawRectangleLinesEx(rect, 1, rl.DARKGRAY)
cursor: f32 = rect.x + PADDING
cy := rect.y + rect.height * 0.5
if sim.running && !sim.paused {
status_icon(&cursor, cy, rl.GREEN, .CIRCLE, "Running", sim.font)
} else {
status_icon(&cursor, cy, rl.RED, .SQUARE, "Paused", sim.font)
}
status_divider(&cursor, cy)
status_text(&cursor, cy, fmt.ctprintf("FPS: %d", rl.GetFPS()), sim.font)
}
StatusIconShape :: enum { CIRCLE, SQUARE }
status_icon :: proc(cursor: ^f32, cy: f32, color: rl.Color, shape: StatusIconShape, label: cstring, font: rl.Font) {
size: f32 = 10
ix := cursor^ + size * 0.5
switch shape {
case .CIRCLE: rl.DrawCircleV({ix, cy}, size * 0.5, color)
case .SQUARE: rl.DrawRectangleV({ix - size*0.5, cy - size*0.5}, {size, size}, color)
}
cursor^ += size + 6
rl.DrawTextEx(font, label, {cursor^, cy - f32(font.baseSize) * 0.5}, f32(font.baseSize), 1, rl.RAYWHITE)
cursor^ += rl.MeasureTextEx(font, label, f32(font.baseSize), 1).x + PADDING
}
status_divider :: proc(cursor: ^f32, cy: f32) {
rl.DrawLineV({cursor^, cy - 8}, {cursor^, cy + 8}, rl.DARKGRAY)
cursor^ += PADDING
}
status_text :: proc(cursor: ^f32, cy: f32, text: cstring, font: rl.Font) {
rl.DrawTextEx(font, text, {cursor^, cy - f32(font.baseSize) * 0.5}, f32(font.baseSize), 1, rl.RAYWHITE)
cursor^ += rl.MeasureTextEx(font, text, f32(font.baseSize), 1).x + PADDING
}