aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authoriamcheeseman <[hidden email]>2026-01-15 20:23:41 -0500
committeriamcheeseman <[hidden email]>2026-01-15 20:23:41 -0500
commitc353e0b095fb724ee50d6e09fb00cc82b51da250 (patch)
tree060f11a1e09352e3191b0fc1ad7970abc8b7e3a0 /tools
parent012a78995d9e360de1d931943b34f21d4f4a85af (diff)
unlockable abilities
Diffstat (limited to 'tools')
-rw-r--r--tools/compile_assets/main.odin18
-rw-r--r--tools/compile_assets/tiled.odin26
2 files changed, 31 insertions, 13 deletions
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 {
<object-types>}
-Resource_Id :: union {
- Image_Id,
- Animation_Id,
- Room_Id,
- Tileset_Id,
-}
-
images: [Image_Id]Image_Resource = {
<image-load>}
@@ -60,12 +53,15 @@ tiles: []Tile_Resource = {
world: []Room_Position_Resource = {
<room-positions>}
-path_to_id: map[string]Resource_Id = {
-<resource-paths>}
-
-load_resources :: proc() {
+Resource_Id :: union {
+ Image_Id,
+ Animation_Id,
+ Room_Id,
+ Tileset_Id,
}
+path_to_resource_id: map[string]Resource_Id = {
+<resource-paths>}
`
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
}
+