diff --git a/CMakeLists.txt b/CMakeLists.txt index e00662b..e3c55a3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,6 +47,8 @@ set(ASSETS assets/level2.tmx assets/level3.tmx assets/level4.tmx + assets/interior1_0_dialogs.json + assets/interior1_0.tmx # ... ) diff --git a/assets/converters.py b/assets/converters.py index 95d2799..3d97807 100644 --- a/assets/converters.py +++ b/assets/converters.py @@ -69,6 +69,9 @@ def convert_map(input: str, output: str, params: dict, target): npc_paths = {} npcs = {} signs = {} + portals = {} + + name = os.path.splitext(os.path.basename(input))[0] map_struct = fxconv.Structure() @@ -226,6 +229,17 @@ def convert_map(input: str, output: str, params: dict, target): "icon": SIGN_TYPES.index(object.type) } signs[object.id] = data + # Get the portals + for object in ed_objgroup.objects: + if (object.get_data_type() == "rectangle" + and object.type == "PORTAL"): + data = { + "rect": object.get_data(), + "name": object.name, + "dest": object.get_property("dest"), + "destPortal": object.get_property("destPortal") + } + portals[object.id] = data except Exception as e: # Show a simple error message on failure. sys.stderr.write(f"ERROR: Failed to get the extra data.\n" @@ -297,8 +311,23 @@ def convert_map(input: str, output: str, params: dict, target): sign_struct += fxconv.u32(i["needAction"]) map_struct += fxconv.ptr(sign_struct) # Load portals - map_struct += fxconv.u32(0) # TODO: Portal support in-game - map_struct += fxconv.ptr(bytes()) + map_struct += fxconv.u32(len(portals)) + portal_struct = fxconv.Structure() + for i in portals.values(): + dest_file_name = os.path.splitext(os.path.basename(i["dest"]))[0] + dest_portal = i["destPortal"] + portal_name = i["name"] + if VERBOSE: print(f"INFO: Storing portal {name}_{portal_name}") + portal_struct += fxconv.sym(f"{name}_{portal_name}") + # Add the collider + rect = i["rect"] + portal_struct += fxconv.u32(rect[0]) + portal_struct += fxconv.u32(rect[1]) + portal_struct += fxconv.u32(rect[2]) + portal_struct += fxconv.u32(rect[3]) + # Add a reference to the destination portal + portal_struct += fxconv.ref(f"{dest_file_name}_{dest_portal}") + map_struct += fxconv.ptr(portal_struct) map_struct += fxconv.u32(dialog_num) # Get the name of the dialog file and create a reference to it: it is built @@ -319,7 +348,6 @@ def convert_map(input: str, output: str, params: dict, target): map_struct += fxconv.ptr(foreground_data) # Create the fxconv object - name = os.path.splitext(os.path.basename(input))[0] fxconv.elf(map_struct, output, f"_{name}", **target) def convert_dialog(input: str, output: str, params: dict, target): diff --git a/assets/fxconv-metadata.txt b/assets/fxconv-metadata.txt index 423d18e..9a82591 100644 --- a/assets/fxconv-metadata.txt +++ b/assets/fxconv-metadata.txt @@ -37,3 +37,11 @@ level3_dialogs.json: level4_dialogs.json: custom-type: dialog name: level4_dialogs + +interior1_0.tmx: + custom-type: tmx + name: level0 + +interior1_0_dialogs.json: + custom-type: dialog + name: interior1_0_dialogs diff --git a/assets/interior1-0.tmx b/assets/interior1_0.tmx similarity index 74% rename from assets/interior1-0.tmx rename to assets/interior1_0.tmx index 3456a8b..e40d41a 100644 --- a/assets/interior1-0.tmx +++ b/assets/interior1_0.tmx @@ -1,5 +1,10 @@ - + + + + + + @@ -39,14 +44,11 @@ - + - - - - + + - diff --git a/assets/interior1_0_dialogs.json b/assets/interior1_0_dialogs.json new file mode 100644 index 0000000..f503523 --- /dev/null +++ b/assets/interior1_0_dialogs.json @@ -0,0 +1,13 @@ +{ "dialogs":[ + { "ID":0, + "dialog":"_", + "isQuestion":0, + "choice":"_", + "conclusion1":"_", + "next1":-1, + "conclusion2":"_", + "next2":-1, + "nextOther":1 + } + ] +} diff --git a/assets/level0.tmx b/assets/level0.tmx index 0b21923..6bc62a8 100644 --- a/assets/level0.tmx +++ b/assets/level0.tmx @@ -1,5 +1,5 @@ - + @@ -173,5 +173,11 @@ + + + + + + diff --git a/assets/tinytiled b/assets/tinytiled index f426664..b084ecd 160000 --- a/assets/tinytiled +++ b/assets/tinytiled @@ -1 +1 @@ -Subproject commit f426664f4444d4c8a6054bc7b69fb676ed43bcaa +Subproject commit b084ecda91a2352a72a5d1a61b37e0009228ee40 diff --git a/src/game.h b/src/game.h index 992d0bd..3a5f71c 100644 --- a/src/game.h +++ b/src/game.h @@ -12,8 +12,8 @@ typedef enum { D_UP, D_DOWN, D_LEFT, D_RIGHT } Direction; typedef enum { P_LEFTUP = -1, P_CENTER = 0, P_RIGHTDOWN = 1 } Checkpos; typedef struct { - uint32_t x, y; - uint32_t w, h; + uint32_t x1, y1; + uint32_t x2, y2; } Collider; @@ -109,10 +109,8 @@ typedef struct { typedef struct { Collider collider; - /*if the portal tps to an interior or exterior map*/ - uint16_t tp_interior; - /*Id of the interior/exterior map to transport the player to*/ - uint16_t tp_to; + /* The destination portal */ + void *portal; } Portal; typedef struct {