Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0b35d9016c | |||
| 02ee850e82 |
+1
-1
@@ -23,7 +23,7 @@ main :: proc() {
|
||||
// Init the emu 8 "cpu"
|
||||
system := emu.init()
|
||||
|
||||
// TODO: move this into a gui component
|
||||
// @TODO: move this into a gui component
|
||||
// load rom, hardcoded for now, will eventually be cli or gui
|
||||
err := emu.load_rom(&system, "./test_roms/7-beep.ch8")
|
||||
if err != nil {
|
||||
|
||||
+16
-17
@@ -14,11 +14,11 @@ CONTROL_BAR_H :: f32(50)
|
||||
STATUS_BAR_H :: f32(30)
|
||||
|
||||
Layout :: struct {
|
||||
control_bar : rl.Rectangle,
|
||||
left_panel : rl.Rectangle,
|
||||
display : rl.Rectangle,
|
||||
right_panel : rl.Rectangle,
|
||||
status_bar : rl.Rectangle,
|
||||
control_bar : rl.Rectangle,
|
||||
left_panel : rl.Rectangle,
|
||||
display : rl.Rectangle,
|
||||
right_panel : rl.Rectangle,
|
||||
status_bar : rl.Rectangle,
|
||||
}
|
||||
|
||||
// Initialize main the gui 'window'
|
||||
@@ -32,7 +32,7 @@ run_gui :: proc(sim: ^Simulator) {
|
||||
// Load fonts
|
||||
font := rl.LoadFontEx("./assets/fonts/Inter_18pt-Regular.ttf", 18, nil, 0)
|
||||
rl.SetTextureFilter(font.texture, .BILINEAR)
|
||||
sim.font = font
|
||||
sim.font = font
|
||||
|
||||
rl.GuiLoadStyleDefault()
|
||||
rl.GuiLoadStyle("./assets/raygui_styles/style_dark.rgs")
|
||||
@@ -91,7 +91,6 @@ run_gui :: proc(sim: ^Simulator) {
|
||||
}
|
||||
|
||||
// @TODO: If this grows lets move it into its own file
|
||||
|
||||
calc_layout :: proc(screen_width: f32, screen_height: f32) -> Layout {
|
||||
sidebar_width := screen_width * SIDEBAR_PERCENT
|
||||
content_height := screen_height - CONTROL_BAR_H - STATUS_BAR_H
|
||||
@@ -99,33 +98,33 @@ calc_layout :: proc(screen_width: f32, screen_height: f32) -> Layout {
|
||||
|
||||
return Layout {
|
||||
control_bar = rl.Rectangle {
|
||||
x = 0,
|
||||
x = 0,
|
||||
y = 0,
|
||||
width = screen_width,
|
||||
width = screen_width,
|
||||
height = CONTROL_BAR_H,
|
||||
},
|
||||
left_panel = rl.Rectangle {
|
||||
x = 0,
|
||||
x = 0,
|
||||
y = CONTROL_BAR_H,
|
||||
width = sidebar_width,
|
||||
width = sidebar_width,
|
||||
height = content_height,
|
||||
},
|
||||
display = rl.Rectangle {
|
||||
x = sidebar_width,
|
||||
x = sidebar_width,
|
||||
y = CONTROL_BAR_H,
|
||||
width = screen_width - (sidebar_width * 2),
|
||||
width = screen_width - (sidebar_width * 2),
|
||||
height = display_height,
|
||||
},
|
||||
right_panel = rl.Rectangle {
|
||||
x = screen_width - sidebar_width,
|
||||
x = screen_width - sidebar_width,
|
||||
y = CONTROL_BAR_H,
|
||||
width = sidebar_width,
|
||||
width = sidebar_width,
|
||||
height = content_height,
|
||||
},
|
||||
status_bar = rl.Rectangle {
|
||||
x = 0,
|
||||
x = 0,
|
||||
y = screen_height - STATUS_BAR_H,
|
||||
width = screen_width, height = STATUS_BAR_H,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package simulator
|
||||
|
||||
import "core:strings"
|
||||
import "core:log"
|
||||
import "core:strings"
|
||||
import rl "vendor:raylib"
|
||||
|
||||
gui_left_panel :: proc(rect: rl.Rectangle, sim: ^Simulator) {
|
||||
@@ -12,6 +12,7 @@ gui_left_panel :: proc(rect: rl.Rectangle, sim: ^Simulator) {
|
||||
rect.height / 2,
|
||||
}
|
||||
rl.DrawRectangleLinesEx(top_panel, 1, rl.DARKGRAY)
|
||||
gui_file_loader(top_panel)
|
||||
|
||||
bottom_panel := rl.Rectangle {
|
||||
rect.x,
|
||||
@@ -23,6 +24,20 @@ gui_left_panel :: proc(rect: rl.Rectangle, sim: ^Simulator) {
|
||||
gui_key_pad(bottom_panel, sim.machine.keypad, sim.font)
|
||||
}
|
||||
|
||||
gui_file_loader :: proc(rect: rl.Rectangle,) {
|
||||
if rl.IsFileDropped() {
|
||||
log.info("file drop found!")
|
||||
dropped_file := rl.LoadDroppedFiles()
|
||||
|
||||
if dropped_file.count > 1 {
|
||||
path_str := string(dropped_file.paths[0])
|
||||
log.info("file dropped: ", path_str)
|
||||
}
|
||||
|
||||
rl.UnloadDroppedFiles(dropped_file)
|
||||
}
|
||||
}
|
||||
|
||||
gui_key_pad :: proc(rect: rl.Rectangle, display: [16]bool, font: rl.Font) {
|
||||
Key :: struct { label: string, index: int}
|
||||
keys := [16]Key {
|
||||
@@ -30,14 +45,14 @@ gui_key_pad :: proc(rect: rl.Rectangle, display: [16]bool, font: rl.Font) {
|
||||
{"4", 4}, {"5", 5}, {"6", 6}, {"D", 13},
|
||||
{"7", 7}, {"8", 8}, {"9", 9}, {"D", 14},
|
||||
{"A", 10}, {"0", 0}, {"B", 11}, {"F", 15}
|
||||
}
|
||||
}
|
||||
|
||||
btn_width := f32(rect.width / 4)
|
||||
btn_height := f32(rect.height / 4)
|
||||
|
||||
for val, idx in keys {
|
||||
str := strings.clone_to_cstring(val.label)
|
||||
ri := int(idx / 4)
|
||||
ri := int(idx / 4)
|
||||
ci := idx % 4
|
||||
|
||||
irect := rl.Rectangle{
|
||||
@@ -53,5 +68,5 @@ gui_key_pad :: proc(rect: rl.Rectangle, display: [16]bool, font: rl.Font) {
|
||||
|
||||
// Free the allocations!
|
||||
delete(str)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user