Added sign support back

This commit is contained in:
mibi88 2024-07-31 12:54:40 +02:00
parent 563ed47753
commit da63b8ce06
8 changed files with 48 additions and 24 deletions

View file

@ -7,7 +7,8 @@ import fxconv
from tiled import * from tiled import *
VERBOSE = 1 VERBOSE = 1
SIGN_TYPES = ["INFO", "SGN"] SIGN_TYPES = ["SGN", "INFO"]
FACES = ["MALE", "FEMALE", "MILKMAN", "POLICE"]
def convert(input, output, params, target): def convert(input, output, params, target):
if params["custom-type"] == "tmx": if params["custom-type"] == "tmx":
@ -49,6 +50,17 @@ def convert_map(input, output, params, target):
+ f" Error message: {e}\n") + f" Error message: {e}\n")
sys.exit(1) 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 # Get informations about dialogs
try: try:
if VERBOSE: print("INFO: Getting informations about dialogs") 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!") raise Exception("Path required but not found!")
data = { data = {
"position": object.get_data(), "position": object.get_data(),
"needAction": object.get_property("needAction"), "name": object.name,
"dialogID": object.get_property("dialogID"), "needAction": int(object.get_property("needAction")),
#"face": object.get_property("face"), "dialogID": int(object.get_property("dialogID")),
"face": FACES.index(object.get_property("face")),
"path": path "path": path
} }
npcs[object.id] = data npcs[object.id] = data
@ -158,8 +171,11 @@ def convert_map(input, output, params, target):
for object in ed_objgroup.objects: for object in ed_objgroup.objects:
if object.get_data_type() == "point" and object.type in SIGN_TYPES: if object.get_data_type() == "point" and object.type in SIGN_TYPES:
data = { data = {
"needAction": object.get_property("needAction"), "position": object.get_data(),
"dialogID": object.get_property("dialogID") "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 signs[object.id] = data
except Exception as e: 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.u32(0) # TODO: NPC support in-game
map_struct += fxconv.ptr(bytes()) map_struct += fxconv.ptr(bytes())
# Load signs # Load signs
map_struct += fxconv.u32(0) # TODO: Sign support in-game map_struct += fxconv.u32(len(signs)) # TODO: Sign support in-game
map_struct += fxconv.ptr(bytes()) 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.u32(0) # TODO: Portal support in-game
map_struct += fxconv.ptr(bytes()) map_struct += fxconv.ptr(bytes())
map_struct += fxconv.u32(dialog_num) 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.u32(dialog_id)
dialog_struct += fxconv.string(i["dialog"]) dialog_struct += fxconv.string(i["dialog"])
dialog_struct += fxconv.u32(i["isQuestion"]) 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.string(i["conclusion1"])
dialog_struct += fxconv.u32(i["next1"]) dialog_struct += fxconv.u32(i["next1"])
dialog_struct += fxconv.string(i["conclusion2"]) dialog_struct += fxconv.string(i["conclusion2"])

View file

@ -5,6 +5,8 @@
</editorsettings> </editorsettings>
<properties> <properties>
<property name="dialogFile" type="file" value="level0_dialogs.json"/> <property name="dialogFile" type="file" value="level0_dialogs.json"/>
<property name="mapX" type="int" value="0"/>
<property name="mapY" type="int" value="0"/>
</properties> </properties>
<tileset firstgid="1" source="tilesetnpp.tsx"/> <tileset firstgid="1" source="tilesetnpp.tsx"/>
<tileset firstgid="409" source="Walkable.tsx"/> <tileset firstgid="409" source="Walkable.tsx"/>
@ -117,6 +119,7 @@
<object id="12" name="PNJ3" type="NPC" x="267.25" y="125.75"> <object id="12" name="PNJ3" type="NPC" x="267.25" y="125.75">
<properties> <properties>
<property name="dialogID" type="int" value="12"/> <property name="dialogID" type="int" value="12"/>
<property name="face" value="FEMALE"/>
<property name="hasPath" type="int" value="1"/> <property name="hasPath" type="int" value="1"/>
<property name="needAction" type="int" value="1"/> <property name="needAction" type="int" value="1"/>
<property name="path" type="object" value="13"/> <property name="path" type="object" value="13"/>
@ -126,6 +129,7 @@
<object id="2" name="PNJ2" type="NPC" x="164" y="132"> <object id="2" name="PNJ2" type="NPC" x="164" y="132">
<properties> <properties>
<property name="dialogID" type="int" value="5"/> <property name="dialogID" type="int" value="5"/>
<property name="face" value="MALE"/>
<property name="hasPath" type="int" value="0"/> <property name="hasPath" type="int" value="0"/>
<property name="needAction" type="int" value="1"/> <property name="needAction" type="int" value="1"/>
<property name="path" type="object" value="0"/> <property name="path" type="object" value="0"/>
@ -135,6 +139,7 @@
<object id="10" name="PNJ1" type="NPC" x="252" y="164"> <object id="10" name="PNJ1" type="NPC" x="252" y="164">
<properties> <properties>
<property name="dialogID" type="int" value="7"/> <property name="dialogID" type="int" value="7"/>
<property name="face" value="MILKMAN"/>
<property name="hasPath" type="int" value="1"/> <property name="hasPath" type="int" value="1"/>
<property name="needAction" type="int" value="1"/> <property name="needAction" type="int" value="1"/>
<property name="path" type="object" value="9"/> <property name="path" type="object" value="9"/>

View file

@ -2,6 +2,8 @@
<map version="1.8" tiledversion="1.8.2" orientation="orthogonal" renderorder="right-down" width="48" height="24" tilewidth="8" tileheight="8" infinite="0" nextlayerid="5" nextobjectid="4"> <map version="1.8" tiledversion="1.8.2" orientation="orthogonal" renderorder="right-down" width="48" height="24" tilewidth="8" tileheight="8" infinite="0" nextlayerid="5" nextobjectid="4">
<properties> <properties>
<property name="dialogFile" type="file" value="level1_dialogs.json"/> <property name="dialogFile" type="file" value="level1_dialogs.json"/>
<property name="mapX" type="int" value="48"/>
<property name="mapY" type="int" value="0"/>
</properties> </properties>
<tileset firstgid="1" source="tilesetnpp.tsx"/> <tileset firstgid="1" source="tilesetnpp.tsx"/>
<tileset firstgid="409" source="Walkable.tsx"/> <tileset firstgid="409" source="Walkable.tsx"/>

View file

@ -2,6 +2,8 @@
<map version="1.8" tiledversion="1.8.2" orientation="orthogonal" renderorder="right-down" width="48" height="24" tilewidth="8" tileheight="8" infinite="0" nextlayerid="5" nextobjectid="5"> <map version="1.8" tiledversion="1.8.2" orientation="orthogonal" renderorder="right-down" width="48" height="24" tilewidth="8" tileheight="8" infinite="0" nextlayerid="5" nextobjectid="5">
<properties> <properties>
<property name="dialogFile" type="file" value="level2_dialogs.json"/> <property name="dialogFile" type="file" value="level2_dialogs.json"/>
<property name="mapX" type="int" value="0"/>
<property name="mapY" type="int" value="24"/>
</properties> </properties>
<tileset firstgid="1" source="tilesetnpp.tsx"/> <tileset firstgid="1" source="tilesetnpp.tsx"/>
<tileset firstgid="409" source="Walkable.tsx"/> <tileset firstgid="409" source="Walkable.tsx"/>

View file

@ -2,6 +2,8 @@
<map version="1.8" tiledversion="1.8.2" orientation="orthogonal" renderorder="right-down" width="48" height="24" tilewidth="8" tileheight="8" infinite="0" nextlayerid="5" nextobjectid="6"> <map version="1.8" tiledversion="1.8.2" orientation="orthogonal" renderorder="right-down" width="48" height="24" tilewidth="8" tileheight="8" infinite="0" nextlayerid="5" nextobjectid="6">
<properties> <properties>
<property name="dialogFile" type="file" value="level3_dialogs.json"/> <property name="dialogFile" type="file" value="level3_dialogs.json"/>
<property name="mapX" type="int" value="48"/>
<property name="mapY" type="int" value="24"/>
</properties> </properties>
<tileset firstgid="1" source="tilesetnpp.tsx"/> <tileset firstgid="1" source="tilesetnpp.tsx"/>
<tileset firstgid="409" source="Walkable.tsx"/> <tileset firstgid="409" source="Walkable.tsx"/>

View file

@ -2,6 +2,8 @@
<map version="1.8" tiledversion="1.8.2" orientation="orthogonal" renderorder="right-down" width="48" height="24" tilewidth="8" tileheight="8" infinite="0" nextlayerid="6" nextobjectid="9"> <map version="1.8" tiledversion="1.8.2" orientation="orthogonal" renderorder="right-down" width="48" height="24" tilewidth="8" tileheight="8" infinite="0" nextlayerid="6" nextobjectid="9">
<properties> <properties>
<property name="dialogFile" type="file" value="level4_dialogs.json"/> <property name="dialogFile" type="file" value="level4_dialogs.json"/>
<property name="mapX" type="int" value="48"/>
<property name="mapY" type="int" value="48"/>
</properties> </properties>
<tileset firstgid="1" source="tilesetnpp.tsx"/> <tileset firstgid="1" source="tilesetnpp.tsx"/>
<tileset firstgid="409" source="Walkable.tsx"/> <tileset firstgid="409" source="Walkable.tsx"/>
@ -100,7 +102,7 @@
<object id="6" name="NPC1" type="NPC" x="147.952" y="62.6849"> <object id="6" name="NPC1" type="NPC" x="147.952" y="62.6849">
<properties> <properties>
<property name="dialogID" type="int" value="0"/> <property name="dialogID" type="int" value="0"/>
<property name="face" value="MAN"/> <property name="face" value="MALE"/>
<property name="hasPath" type="int" value="1"/> <property name="hasPath" type="int" value="1"/>
<property name="needAction" type="int" value="1"/> <property name="needAction" type="int" value="1"/>
<property name="path" type="object" value="8"/> <property name="path" type="object" value="8"/>

View file

@ -224,8 +224,3 @@ short int map_get_walkable(Game *game, int x, int y) {
? map_level->walkable[y * map_level->w + x] ? map_level->walkable[y * map_level->w + x]
: MAP_OUTSIDE; : MAP_OUTSIDE;
} }
/* return the pointer to the map containing the given position */
Map *map_get_for_coordinates(Game *game, int x, int y) {
return game->map_level;
}

View file

@ -50,13 +50,4 @@ short int map_get_tile(Game *game, int x, int y, int l);
*/ */
short int map_get_walkable(Game *game, int x, int y); short int map_get_walkable(Game *game, int x, int y);
/* map_get_for_coordinates()
*
* return the pointer to the map containing the given position.
* game: The game struct.
* x: The coordinates to look at.
* y: The coordinates to look at.
*/
Map *map_get_for_coordinates(Game *game, int x, int y);
#endif #endif