mirror of
https://git.planet-casio.com/Slyvtt/Collab_RPG.git
synced 2024-12-28 04:23:42 +01:00
Adding back dialog support. Not tested yet, because NPCs are not added back yet.
This commit is contained in:
parent
efde68f9c7
commit
91e0e4b74d
14 changed files with 81 additions and 9 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -14,5 +14,4 @@ __pycache__/
|
|||
*.sublime-workspace
|
||||
.vscode
|
||||
|
||||
level*.json
|
||||
tilesetnpp.json
|
||||
|
|
|
@ -37,6 +37,11 @@ set(SOURCES
|
|||
)
|
||||
# Shared assets, fx-9860G-only assets and fx-CG-50-only assets
|
||||
set(ASSETS
|
||||
assets/level0_dialogs.json
|
||||
assets/level1_dialogs.json
|
||||
assets/level2_dialogs.json
|
||||
assets/level3_dialogs.json
|
||||
assets/level4_dialogs.json
|
||||
assets/level0.tmx
|
||||
assets/level1.tmx
|
||||
assets/level2.tmx
|
||||
|
|
|
@ -240,7 +240,7 @@ def convert(input, output, params, target):
|
|||
if params["custom-type"] == "tmx":
|
||||
convert_map(input, output, params, target)
|
||||
return 0
|
||||
elif params["custom-type"] == "json":
|
||||
elif params["custom-type"] == "dialog":
|
||||
convert_dialog(input, output, params, target)
|
||||
return 0
|
||||
|
||||
|
@ -255,6 +255,8 @@ def convert_map(input, output, params, target):
|
|||
height = 0
|
||||
outdoor_tileset = None
|
||||
walkable_tileset = None
|
||||
dialog_num = 0
|
||||
dialog_ids = []
|
||||
|
||||
npc_paths = {}
|
||||
npcs = {}
|
||||
|
@ -271,6 +273,19 @@ def convert_map(input, output, params, target):
|
|||
sys.stderr.write(f"ERROR: Failed to get the dialog file.\n"
|
||||
+ f" Error message: {e}\n")
|
||||
sys.exit(1)
|
||||
|
||||
# Get informations about dialogs
|
||||
try:
|
||||
if VERBOSE: print("INFO: Getting informations about dialogs")
|
||||
with open(f"{input_map.parent_dir}/{dialog_file}", "r") as file:
|
||||
dialog_data = json.load(file)
|
||||
dialog_num = len(dialog_data["dialogs"])
|
||||
for i in dialog_data["dialogs"]:
|
||||
dialog_ids.append(i["ID"])
|
||||
except Exception as e:
|
||||
sys.stderr.write(f"ERROR: Failed to get informations about dialogs.\n"
|
||||
+ f" Error message: {e}\n")
|
||||
sys.exit(1)
|
||||
|
||||
# Get the outdoor tileset
|
||||
try:
|
||||
|
@ -377,6 +392,7 @@ def convert_map(input, output, params, target):
|
|||
+ f" Error message: {e}\n")
|
||||
sys.exit(1)
|
||||
# Generate the structs
|
||||
# Map struct
|
||||
map_struct += fxconv.u32(width)
|
||||
map_struct += fxconv.u32(height)
|
||||
map_struct += fxconv.u32(3)
|
||||
|
@ -394,14 +410,18 @@ def convert_map(input, output, params, target):
|
|||
walkable_data += fxconv.u8(i)
|
||||
map_struct += fxconv.ptr(walkable_data)
|
||||
|
||||
# Load NPCs
|
||||
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(0) # TODO: Portal support in-game
|
||||
map_struct += fxconv.ptr(bytes())
|
||||
map_struct += fxconv.u32(0) # TODO: Dialog support
|
||||
map_struct += fxconv.ptr(bytes())
|
||||
map_struct += fxconv.u32(dialog_num)
|
||||
|
||||
dialog_name = os.path.splitext(os.path.basename(dialog_file))[0]
|
||||
map_struct += fxconv.ref(f"_{dialog_name}")
|
||||
|
||||
background_data = bytes()
|
||||
for i in background_layer:
|
||||
|
@ -419,3 +439,31 @@ def convert_map(input, output, params, target):
|
|||
|
||||
def convert_dialog(input, output, params, target):
|
||||
if VERBOSE: print(f"INFO: Converting dialog file {input} -> {output}")
|
||||
dialog_data = None
|
||||
try:
|
||||
with open(input, "r") as file:
|
||||
dialog_data = json.load(file)
|
||||
except Exception as e:
|
||||
sys.stderr.write(f"ERROR: Failed parse json.\n"
|
||||
+ f" Error message: {e}\n")
|
||||
sys.exit(1)
|
||||
dialog_struct = fxconv.Structure()
|
||||
try:
|
||||
for i in dialog_data["dialogs"]:
|
||||
dialog_id = i["ID"]
|
||||
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["conclusion1"])
|
||||
dialog_struct += fxconv.u32(i["next1"])
|
||||
dialog_struct += fxconv.string(i["conclusion2"])
|
||||
dialog_struct += fxconv.u32(i["next2"])
|
||||
dialog_struct += fxconv.u32(i["nextOther"])
|
||||
# Save this struct
|
||||
name = os.path.splitext(os.path.basename(input))[0]
|
||||
fxconv.elf(dialog_struct, output, f"__{name}", **target)
|
||||
except Exception as e:
|
||||
sys.stderr.write(f"ERROR: Failed convert dialogs.\n"
|
||||
+ f" Error message: {e}\n")
|
||||
sys.exit(1)
|
||||
|
|
|
@ -17,3 +17,23 @@ level3.tmx:
|
|||
level4.tmx:
|
||||
custom-type: tmx
|
||||
name: level4
|
||||
|
||||
level0_dialogs.json:
|
||||
custom-type: dialog
|
||||
name: level0_dialogs
|
||||
|
||||
level1_dialogs.json:
|
||||
custom-type: dialog
|
||||
name: level1_dialogs
|
||||
|
||||
level2_dialogs.json:
|
||||
custom-type: dialog
|
||||
name: level2_dialogs
|
||||
|
||||
level3_dialogs.json:
|
||||
custom-type: dialog
|
||||
name: level3_dialogs
|
||||
|
||||
level4_dialogs.json:
|
||||
custom-type: dialog
|
||||
name: level4_dialogs
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<export target="level0.json" format="json"/>
|
||||
</editorsettings>
|
||||
<properties>
|
||||
<property name="dialogFile" type="file" value="DialogsLvl0.json"/>
|
||||
<property name="dialogFile" type="file" value="level0_dialogs.json"/>
|
||||
</properties>
|
||||
<tileset firstgid="1" source="tilesetnpp.tsx"/>
|
||||
<tileset firstgid="409" source="Walkable.tsx"/>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-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">
|
||||
<properties>
|
||||
<property name="dialogFile" type="file" value="DialogsLvl1.json"/>
|
||||
<property name="dialogFile" type="file" value="level1_dialogs.json"/>
|
||||
</properties>
|
||||
<tileset firstgid="1" source="tilesetnpp.tsx"/>
|
||||
<tileset firstgid="409" source="Walkable.tsx"/>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-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">
|
||||
<properties>
|
||||
<property name="dialogFile" type="file" value="DialogsLvl2.json"/>
|
||||
<property name="dialogFile" type="file" value="level2_dialogs.json"/>
|
||||
</properties>
|
||||
<tileset firstgid="1" source="tilesetnpp.tsx"/>
|
||||
<tileset firstgid="409" source="Walkable.tsx"/>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-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">
|
||||
<properties>
|
||||
<property name="dialogFile" type="file" value="DialogsLvl3.json"/>
|
||||
<property name="dialogFile" type="file" value="level3_dialogs.json"/>
|
||||
</properties>
|
||||
<tileset firstgid="1" source="tilesetnpp.tsx"/>
|
||||
<tileset firstgid="409" source="Walkable.tsx"/>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-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">
|
||||
<properties>
|
||||
<property name="dialogFile" type="file" value="DialogsLvl4.json"/>
|
||||
<property name="dialogFile" type="file" value="level4_dialogs.json"/>
|
||||
</properties>
|
||||
<tileset firstgid="1" source="tilesetnpp.tsx"/>
|
||||
<tileset firstgid="409" source="Walkable.tsx"/>
|
||||
|
|
Loading…
Reference in a new issue