diff --git a/source/create_lecode_config.py b/source/create_lecode_config.py index 8c5e280..d36dcf6 100644 --- a/source/create_lecode_config.py +++ b/source/create_lecode_config.py @@ -38,5 +38,6 @@ def create_lecode_config(self): rctfile.write(f' T {_course_config["music"]}; ' + f'{_course_config["special"]}; ' + f'{"0x01" if _course_config["new"] else "0x00"}; ' + + f'"-"; ' + f'"{star}{_course_config["name"]}\\n{_course_config["author"]}"; ' + f'"-"\n') \ No newline at end of file diff --git a/source/patch_bmg.py b/source/patch_bmg.py index 93de920..5905a95 100644 --- a/source/patch_bmg.py +++ b/source/patch_bmg.py @@ -5,17 +5,52 @@ import os from .definition import * -def patch_bmg(self, gamefile): # gamefile est le fichier .szs trouvé dans le /files/Scene/UI/ du jeu - subprocess.call(["./tools/szs/wszst", "EXTRACT", gamefile, "-d", gamefile+".d", "--overwrite"] +def patch_bmg(self, gamefile): # gamefile est le fichier .szs trouvé dans le /files/Scene/UI/ du jeu + subprocess.call(["./tools/szs/wszst", "EXTRACT", gamefile, "-d", gamefile + ".d", "--overwrite"] , creationflags=CREATE_NO_WINDOW) - bmglang = gamefile[-len("E.txt"):-len(".txt")] # Langue du fichier + 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 bmgtext = subprocess.check_output(["tools/szs/wctct", "bmg", "--le-code", "--long", "./file/CTFILE.txt", - "--patch-bmg", "OVERWRITE="+gamefile+".d/message/Common.bmg"] - , creationflags=CREATE_NO_WINDOW) - shutil.rmtree(gamefile+".d") + "--patch-bmg", "OVERWRITE=" + gamefile + ".d/message/Common.bmg", + "--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") 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"]) - os.remove(common_file) \ No newline at end of file + subprocess.call(["./tools/szs/wbmgt", "ENCODE", rcommon_file, "--overwrite"]) + os.remove(common_file) + os.remove(rcommon_file) diff --git a/source/patch_file.py b/source/patch_file.py index 9603a70..e03a32c 100644 --- a/source/patch_file.py +++ b/source/patch_file.py @@ -18,6 +18,9 @@ def patch_file(self): 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(statut=self.translate("Configuration de LE-CODE"), add=1) + self.create_lecode_config() + 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) if not (os.path.exists("./file/" + get_filename(file))): @@ -64,9 +67,6 @@ def patch_file(self): process_list.pop(process) break - self.Progress(statut=self.translate("Configuration de LE-CODE"), add=1) - self.create_lecode_config() - self.Progress(show=False) self.button_install_mod.grid(row=2, column=1, sticky="NEWS") self.listbox_outputformat.grid(row=2, column=2, sticky="NEWS")