From 70dc1fb43c3d71d02431d2f7e2d81600d446e203 Mon Sep 17 00:00:00 2001 From: raphael60650 Date: Wed, 26 May 2021 13:49:24 +0200 Subject: [PATCH] simplified code and use OVERWRITE mode to patch bmg --- source/patch_bmg.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/source/patch_bmg.py b/source/patch_bmg.py index 5741b93..93de920 100644 --- a/source/patch_bmg.py +++ b/source/patch_bmg.py @@ -1,19 +1,21 @@ import subprocess import shutil +import os + from .definition import * -def patch_bmg(self, bmgfileszs): - subprocess.call(["./tools/szs/wszst", "EXTRACT", bmgfileszs, "-d", bmgfileszs + ".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) - bmgfile = "./file/" + get_nodir(bmgfileszs) + ".bmg" - print(bmgfile) - filecopy(bmgfileszs + ".d/message/Common.bmg", bmgfile) - shutil.rmtree(bmgfileszs + ".d") + 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") - bmgtext = subprocess.check_output(["tools/szs/wctct", "--le-code", "--long", "BMG", "./file/CTFILE.txt", - "--patch-bmg", "REPLACE="+bmgfile], creationflags=CREATE_NO_WINDOW) - with open(bmgfile+".txt", "w", encoding="utf-8") as f: f.write(bmgtext.decode()) - subprocess.call(["./tools/szs/wbmgt", "ENCODE", bmgfile+".txt", "--overwrite"]) - #os.remove(bmgfile+".txt") \ No newline at end of file + common_file = f"./file/Common_{bmglang}.txt" + with open(common_file, "w", encoding="utf-8") as f: f.write(bmgtext.decode()) + subprocess.call(["./tools/szs/wbmgt", "ENCODE", common_file, "--overwrite"]) + os.remove(common_file) \ No newline at end of file