From da63b8ce06be67657fe76e5e0d39adb4dc6902cb Mon Sep 17 00:00:00 2001
From: mibi88 <76903855+mibi88@users.noreply.github.com>
Date: Wed, 31 Jul 2024 12:54:40 +0200
Subject: [PATCH] Added sign support back
---
assets/converters.py | 43 ++++++++++++++++++++++++++++++++++---------
assets/level0.tmx | 5 +++++
assets/level1.tmx | 2 ++
assets/level2.tmx | 2 ++
assets/level3.tmx | 2 ++
assets/level4.tmx | 4 +++-
src/map.c | 5 -----
src/map.h | 9 ---------
8 files changed, 48 insertions(+), 24 deletions(-)
diff --git a/assets/converters.py b/assets/converters.py
index 5ee1245..da2c3f1 100644
--- a/assets/converters.py
+++ b/assets/converters.py
@@ -7,7 +7,8 @@ import fxconv
from tiled import *
VERBOSE = 1
-SIGN_TYPES = ["INFO", "SGN"]
+SIGN_TYPES = ["SGN", "INFO"]
+FACES = ["MALE", "FEMALE", "MILKMAN", "POLICE"]
def convert(input, output, params, target):
if params["custom-type"] == "tmx":
@@ -49,6 +50,17 @@ def convert_map(input, output, params, target):
+ f" Error message: {e}\n")
sys.exit(1)
+ # Get the map position
+ try:
+ if VERBOSE: print("INFO: Getting the map position")
+ map_x = int(input_map.get_property("mapX"))
+ map_y = int(input_map.get_property("mapY"))
+ if VERBOSE: print(f"INFO: Map position: ({map_x}, {map_y}).")
+ except Exception as e:
+ sys.stderr.write(f"ERROR: Failed to get the map position.\n"
+ + f" Error message: {e}\n")
+ sys.exit(1)
+
# Get informations about dialogs
try:
if VERBOSE: print("INFO: Getting informations about dialogs")
@@ -148,9 +160,10 @@ def convert_map(input, output, params, target):
raise Exception("Path required but not found!")
data = {
"position": object.get_data(),
- "needAction": object.get_property("needAction"),
- "dialogID": object.get_property("dialogID"),
- #"face": object.get_property("face"),
+ "name": object.name,
+ "needAction": int(object.get_property("needAction")),
+ "dialogID": int(object.get_property("dialogID")),
+ "face": FACES.index(object.get_property("face")),
"path": path
}
npcs[object.id] = data
@@ -158,8 +171,11 @@ def convert_map(input, output, params, target):
for object in ed_objgroup.objects:
if object.get_data_type() == "point" and object.type in SIGN_TYPES:
data = {
- "needAction": object.get_property("needAction"),
- "dialogID": object.get_property("dialogID")
+ "position": object.get_data(),
+ "name": object.name,
+ "needAction": int(object.get_property("needAction")),
+ "dialogID": int(object.get_property("dialogID")),
+ "icon": SIGN_TYPES.index(object.type)
}
signs[object.id] = data
except Exception as e:
@@ -187,8 +203,17 @@ def convert_map(input, output, params, target):
map_struct += fxconv.u32(0) # TODO: NPC support in-game
map_struct += fxconv.ptr(bytes())
# Load signs
- map_struct += fxconv.u32(0) # TODO: Sign support in-game
- map_struct += fxconv.ptr(bytes())
+ map_struct += fxconv.u32(len(signs)) # TODO: Sign support in-game
+ sign_struct = fxconv.Structure()
+ for i in signs.values():
+ sign_struct += fxconv.u32(i["position"][0])
+ sign_struct += fxconv.u32(i["position"][1])
+ sign_struct += fxconv.u32(i["icon"])
+ sign_struct += fxconv.string(i["name"])
+ sign_struct += fxconv.u32(i["dialogID"])
+ 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(dialog_num)
@@ -227,7 +252,7 @@ def convert_dialog(input, output, params, target):
dialog_struct += fxconv.u32(dialog_id)
dialog_struct += fxconv.string(i["dialog"])
dialog_struct += fxconv.u32(i["isQuestion"])
- dialog_struct += fxconv.string(i["choice"])
+ dialog_struct += fxconv.string(i["choice"].replace('$', '\0'))
dialog_struct += fxconv.string(i["conclusion1"])
dialog_struct += fxconv.u32(i["next1"])
dialog_struct += fxconv.string(i["conclusion2"])
diff --git a/assets/level0.tmx b/assets/level0.tmx
index 108691e..f61d568 100644
--- a/assets/level0.tmx
+++ b/assets/level0.tmx
@@ -5,6 +5,8 @@
+
+
@@ -117,6 +119,7 @@