package simulator import "core:fmt" import rl "vendor:raylib" // @TODO: render status bar text gui_status_bar :: proc(rect: rl.Rectangle, sim: ^Simulator) { // Left to right text draws 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("Rom Loaded: %v", sim.rom_loaded), sim.font) // FPS set far right fps_text := fmt.ctprintf("FPS: %d", rl.GetFPS()) fps_width := rl.MeasureTextEx(sim.font, fps_text, f32(sim.font.baseSize), 1).x fps_x := rect.x + rect.width - PADDING - fps_width rl.DrawTextEx( sim.font, fps_text, {fps_x, cy - f32(sim.font.baseSize) * 0.5}, f32(sim.font.baseSize), 1, rl.RAYWHITE, ) } 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 }