From c353e0b095fb724ee50d6e09fb00cc82b51da250 Mon Sep 17 00:00:00 2001 From: iamcheeseman <[hidden email]> Date: Thu, 15 Jan 2026 20:23:41 -0500 Subject: unlockable abilities --- tools/compile_assets/main.odin | 18 +++++++----------- tools/compile_assets/tiled.odin | 26 ++++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 13 deletions(-) (limited to 'tools') diff --git a/tools/compile_assets/main.odin b/tools/compile_assets/main.odin index 01fdb3f..b82b5f3 100644 --- a/tools/compile_assets/main.odin +++ b/tools/compile_assets/main.odin @@ -35,13 +35,6 @@ Tileset_Id :: enum { Object_Type :: enum { } -Resource_Id :: union { - Image_Id, - Animation_Id, - Room_Id, - Tileset_Id, -} - images: [Image_Id]Image_Resource = { } @@ -60,12 +53,15 @@ tiles: []Tile_Resource = { world: []Room_Position_Resource = { } -path_to_id: map[string]Resource_Id = { -} - -load_resources :: proc() { +Resource_Id :: union { + Image_Id, + Animation_Id, + Room_Id, + Tileset_Id, } +path_to_resource_id: map[string]Resource_Id = { +} ` images: map[string]string diff --git a/tools/compile_assets/tiled.odin b/tools/compile_assets/tiled.odin index 29a6a69..621e988 100644 --- a/tools/compile_assets/tiled.odin +++ b/tools/compile_assets/tiled.odin @@ -452,6 +452,10 @@ load_json_room :: proc(path: string, file: ^os.File) { type_name := strings.to_screaming_snake_case(obj.type) // `object_type_names` now owns `type_name`; freed in main + if type_name in object_type_names { + key, _ := delete_key(&object_type_names, type_name) + delete(key) + } object_type_names[type_name] = {} pos := [2]f32{f32(obj.x), f32(obj.y)} @@ -465,9 +469,26 @@ load_json_room :: proc(path: string, file: ^os.File) { } defer delete(properties) + cwd, cwd_err := os.get_working_directory(context.temp_allocator) + assert(cwd_err == nil) + room_dir, room_dir_err := filepath.rel( + cwd, + filepath.dir(path, context.temp_allocator), + context.temp_allocator, + ) + assert(room_dir_err == nil) + for property in obj.properties { - fmt.println(property.name, property.value) - properties[property.name] = property.value + value := property.value + if strings.compare(property.type, "file") == 0 { + rel, err := filepath.join( + {room_dir, value.(string)}, + context.temp_allocator, + ) + assert(err == nil) + value = rel + } + properties[property.name] = value } line := fmt.tprintf( @@ -507,3 +528,4 @@ load_json_room :: proc(path: string, file: ^os.File) { ) rooms[filepath.stem(path)] = line } + -- cgit v1.3-2-g0d8e