mirror of
https://github.com/Faraphel/Atlas-Install.git
synced 2025-07-04 19:58:26 +02:00
Common_?.bmg should now be created from game's file
This commit is contained in:
parent
588c128dfd
commit
e7c32ee304
3 changed files with 47 additions and 11 deletions
|
@ -38,5 +38,6 @@ def create_lecode_config(self):
|
||||||
rctfile.write(f' T {_course_config["music"]}; ' +
|
rctfile.write(f' T {_course_config["music"]}; ' +
|
||||||
f'{_course_config["special"]}; ' +
|
f'{_course_config["special"]}; ' +
|
||||||
f'{"0x01" if _course_config["new"] else "0x00"}; ' +
|
f'{"0x01" if _course_config["new"] else "0x00"}; ' +
|
||||||
|
f'"-"; ' +
|
||||||
f'"{star}{_course_config["name"]}\\n{_course_config["author"]}"; ' +
|
f'"{star}{_course_config["name"]}\\n{_course_config["author"]}"; ' +
|
||||||
f'"-"\n')
|
f'"-"\n')
|
|
@ -9,13 +9,48 @@ def patch_bmg(self, gamefile): # gamefile est le fichier .szs trouvé dans le /f
|
||||||
subprocess.call(["./tools/szs/wszst", "EXTRACT", gamefile, "-d", gamefile + ".d", "--overwrite"]
|
subprocess.call(["./tools/szs/wszst", "EXTRACT", gamefile, "-d", gamefile + ".d", "--overwrite"]
|
||||||
, creationflags=CREATE_NO_WINDOW)
|
, creationflags=CREATE_NO_WINDOW)
|
||||||
|
|
||||||
|
bmgtracks = subprocess.check_output(["wbmgt", "CAT", gamefile + ".d/message/Common.bmg"])
|
||||||
|
bmgtracks = bmgtracks.decode()
|
||||||
|
trackheader = "#--- standard track names"
|
||||||
|
trackend = "2328"
|
||||||
|
bmgtracks = bmgtracks[bmgtracks.find(trackheader) + len(trackheader):bmgtracks.find(trackend)]
|
||||||
|
|
||||||
|
with open("./file/ExtraCommon.txt", "w") as f:
|
||||||
|
f.write("#BMG\n\n")
|
||||||
|
|
||||||
|
for bmgtrack in bmgtracks.split("\n"):
|
||||||
|
if "=" in bmgtrack:
|
||||||
|
|
||||||
|
if "T" in bmgtrack[:bmgtrack.find("=")]:
|
||||||
|
sTid, offset = bmgtrack.find("T") + 1, 0x7000
|
||||||
|
else:
|
||||||
|
sTid, offset = bmgtrack.find("U") + 1, 0x7020
|
||||||
|
|
||||||
|
eTid = sTid + 2
|
||||||
|
Tid = bmgtrack[sTid:eTid]
|
||||||
|
Tid = hex((int(Tid[0]) - 1) * 4 + (int(Tid[1]) - 1) + offset)[2:]
|
||||||
|
Tname = bmgtrack[bmgtrack.find("= ") + 2:]
|
||||||
|
|
||||||
|
f.write(f" {Tid}\t= {Tname}\n")
|
||||||
|
|
||||||
bmglang = gamefile[-len("E.txt"):-len(".txt")] # Langue du fichier
|
bmglang = gamefile[-len("E.txt"):-len(".txt")] # Langue du fichier
|
||||||
bmgtext = subprocess.check_output(["tools/szs/wctct", "bmg", "--le-code", "--long", "./file/CTFILE.txt",
|
bmgtext = subprocess.check_output(["tools/szs/wctct", "bmg", "--le-code", "--long", "./file/CTFILE.txt",
|
||||||
"--patch-bmg", "OVERWRITE="+gamefile+".d/message/Common.bmg"]
|
"--patch-bmg", "OVERWRITE=" + gamefile + ".d/message/Common.bmg",
|
||||||
, creationflags=CREATE_NO_WINDOW)
|
"--patch-bmg", "OVERWRITE=./file/ExtraCommon.txt"],
|
||||||
|
creationflags=CREATE_NO_WINDOW)
|
||||||
|
rbmgtext = subprocess.check_output(["tools/szs/wctct", "bmg", "--le-code", "--long", "./file/RCTFILE.txt",
|
||||||
|
"--patch-bmg", "OVERWRITE=" + gamefile + ".d/message/Common.bmg",
|
||||||
|
"--patch-bmg", "OVERWRITE=./file/ExtraCommon.txt"],
|
||||||
|
creationflags=CREATE_NO_WINDOW)
|
||||||
shutil.rmtree(gamefile + ".d")
|
shutil.rmtree(gamefile + ".d")
|
||||||
|
|
||||||
common_file = f"./file/Common_{bmglang}.txt"
|
common_file = f"./file/Common_{bmglang}.txt"
|
||||||
with open(common_file, "w", encoding="utf-8") as f: f.write(bmgtext.decode())
|
rcommon_file = f"./file/Common_R{bmglang}.txt"
|
||||||
|
with open(common_file, "w", encoding="utf-8") as f:
|
||||||
|
f.write(bmgtext.decode())
|
||||||
|
with open(rcommon_file, "w", encoding="utf-8") as f:
|
||||||
|
f.write(rbmgtext.decode())
|
||||||
subprocess.call(["./tools/szs/wbmgt", "ENCODE", common_file, "--overwrite"])
|
subprocess.call(["./tools/szs/wbmgt", "ENCODE", common_file, "--overwrite"])
|
||||||
|
subprocess.call(["./tools/szs/wbmgt", "ENCODE", rcommon_file, "--overwrite"])
|
||||||
os.remove(common_file)
|
os.remove(common_file)
|
||||||
|
os.remove(rcommon_file)
|
||||||
|
|
|
@ -18,6 +18,9 @@ def patch_file(self):
|
||||||
max_step = len(fc["img"]) + total_track + 1 # + len(fc["bmg"])
|
max_step = len(fc["img"]) + total_track + 1 # + len(fc["bmg"])
|
||||||
self.Progress(show=True, indeter=False, statut=self.translate("Conversion des fichiers"), max=max_step, step=0)
|
self.Progress(show=True, indeter=False, statut=self.translate("Conversion des fichiers"), max=max_step, step=0)
|
||||||
|
|
||||||
|
self.Progress(statut=self.translate("Configuration de LE-CODE"), add=1)
|
||||||
|
self.create_lecode_config()
|
||||||
|
|
||||||
for i, file in enumerate(fc["img"]):
|
for i, file in enumerate(fc["img"]):
|
||||||
self.Progress(statut=self.translate("Conversion des images")+f"\n({i + 1}/{len(fc['img'])}) {file}", add=1)
|
self.Progress(statut=self.translate("Conversion des images")+f"\n({i + 1}/{len(fc['img'])}) {file}", add=1)
|
||||||
if not (os.path.exists("./file/" + get_filename(file))):
|
if not (os.path.exists("./file/" + get_filename(file))):
|
||||||
|
@ -64,9 +67,6 @@ def patch_file(self):
|
||||||
process_list.pop(process)
|
process_list.pop(process)
|
||||||
break
|
break
|
||||||
|
|
||||||
self.Progress(statut=self.translate("Configuration de LE-CODE"), add=1)
|
|
||||||
self.create_lecode_config()
|
|
||||||
|
|
||||||
self.Progress(show=False)
|
self.Progress(show=False)
|
||||||
self.button_install_mod.grid(row=2, column=1, sticky="NEWS")
|
self.button_install_mod.grid(row=2, column=1, sticky="NEWS")
|
||||||
self.listbox_outputformat.grid(row=2, column=2, sticky="NEWS")
|
self.listbox_outputformat.grid(row=2, column=2, sticky="NEWS")
|
||||||
|
|
Loading…
Reference in a new issue