2024-01-21 20:38:02 -08:00
|
|
|
package sectr
|
|
|
|
|
2024-02-08 07:50:36 -08:00
|
|
|
import "base:runtime"
|
|
|
|
import "core:fmt"
|
|
|
|
import "core:mem"
|
2024-01-29 23:27:45 -08:00
|
|
|
import "core:mem/virtual"
|
2024-02-08 07:50:36 -08:00
|
|
|
import "core:os"
|
|
|
|
|
|
|
|
import rl "vendor:raylib"
|
2024-01-29 23:27:45 -08:00
|
|
|
|
|
|
|
memory : Memory
|
|
|
|
|
|
|
|
memory_chunk_size :: 2 * Gigabyte
|
|
|
|
memory_persistent_size :: 128 * Megabyte
|
|
|
|
memory_trans_temp_size :: (memory_chunk_size - memory_persistent_size ) / 2
|
|
|
|
|
|
|
|
Memory :: struct {
|
2024-02-08 07:50:36 -08:00
|
|
|
live : virtual.Arena,
|
|
|
|
snapshot : []u8,
|
2024-01-29 23:27:45 -08:00
|
|
|
persistent : ^ TrackedAllocator,
|
|
|
|
transient : ^ TrackedAllocator,
|
2024-02-08 13:05:15 -08:00
|
|
|
temp : ^ TrackedAllocator,
|
|
|
|
|
2024-02-08 19:33:53 -08:00
|
|
|
replay : ReplayState,
|
|
|
|
logger : Logger,
|
2024-01-29 23:27:45 -08:00
|
|
|
}
|
|
|
|
|
2024-02-09 10:09:58 -08:00
|
|
|
save_snapshot :: proc( snapshot : [^]u8 ) {
|
|
|
|
state := get_state()
|
|
|
|
|
|
|
|
// state.font_rec_mono_semicasual_reg
|
|
|
|
// state.default_font
|
|
|
|
|
|
|
|
live_ptr := cast( ^ rawptr ) memory.live.curr_block.base
|
|
|
|
mem.copy_non_overlapping( & snapshot[0], live_ptr, memory_chunk_size )
|
|
|
|
}
|
|
|
|
|
|
|
|
load_snapshot :: proc( snapshot : [^]u8 ) {
|
|
|
|
live_ptr := cast( ^ rawptr ) memory.live.curr_block.base
|
|
|
|
mem.copy_non_overlapping( live_ptr, snapshot, memory_chunk_size )
|
|
|
|
}
|
|
|
|
|
2024-01-21 20:38:02 -08:00
|
|
|
State :: struct {
|
2024-02-08 07:50:36 -08:00
|
|
|
input_data : [2] InputState,
|
2024-02-09 10:09:58 -08:00
|
|
|
input_prev : ^ InputState,
|
|
|
|
input : ^ InputState,
|
2024-02-08 07:50:36 -08:00
|
|
|
|
|
|
|
debug : DebugData,
|
|
|
|
|
2024-01-21 20:38:02 -08:00
|
|
|
project : Project,
|
|
|
|
|
|
|
|
screen_width : i32,
|
|
|
|
screen_height : i32,
|
|
|
|
|
|
|
|
monitor_id : i32,
|
|
|
|
monitor_refresh_hz : i32,
|
|
|
|
|
|
|
|
engine_refresh_hz : i32,
|
|
|
|
engine_refresh_target : i32,
|
|
|
|
|
2024-01-22 00:47:53 -08:00
|
|
|
font_rec_mono_semicasual_reg : Font,
|
|
|
|
default_font : Font,
|
2024-01-21 20:38:02 -08:00
|
|
|
}
|
|
|
|
|
2024-02-09 10:09:58 -08:00
|
|
|
get_state :: proc() -> (^ State) {
|
|
|
|
return cast( ^ State ) raw_data( memory.persistent.backing.data )
|
|
|
|
}
|
|
|
|
|
2024-01-21 20:38:02 -08:00
|
|
|
Project :: struct {
|
2024-02-09 10:09:58 -08:00
|
|
|
path : string,
|
|
|
|
name : string,
|
|
|
|
|
2024-01-21 20:38:02 -08:00
|
|
|
// TODO(Ed) : Support multiple workspaces
|
|
|
|
workspace : Workspace
|
|
|
|
}
|
|
|
|
|
|
|
|
Workspace :: struct {
|
2024-02-09 10:09:58 -08:00
|
|
|
name : string
|
2024-02-08 07:50:36 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
DebugData :: struct {
|
|
|
|
square_size : i32,
|
|
|
|
square_pos : rl.Vector2,
|
|
|
|
|
|
|
|
draw_debug_text_y : f32,
|
|
|
|
|
|
|
|
mouse_vis : b32,
|
2024-02-08 13:05:15 -08:00
|
|
|
mouse_pos : vec2,
|
2024-02-08 07:50:36 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
DebugActions :: struct {
|
|
|
|
pause_renderer : b32,
|
|
|
|
|
|
|
|
load_auto_snapshot : b32,
|
|
|
|
record_replay : b32,
|
|
|
|
play_replay : b32,
|
|
|
|
|
|
|
|
show_mouse_pos : b32,
|
|
|
|
}
|
|
|
|
|
|
|
|
poll_debug_actions :: proc( actions : ^ DebugActions, input : ^ InputState )
|
|
|
|
{
|
|
|
|
using actions
|
|
|
|
using input
|
|
|
|
|
2024-02-08 13:05:15 -08:00
|
|
|
base_replay_bind := keyboard.right_alt.ended_down && pressed( keyboard.L)
|
|
|
|
record_replay = base_replay_bind && keyboard.right_shift.ended_down
|
|
|
|
play_replay = base_replay_bind && ! keyboard.right_shift.ended_down
|
2024-02-08 07:50:36 -08:00
|
|
|
|
2024-02-08 13:05:15 -08:00
|
|
|
show_mouse_pos = keyboard.right_alt.ended_down && pressed(keyboard.M)
|
2024-02-08 07:50:36 -08:00
|
|
|
}
|