diff --git a/Pack/MKWFaraphel/essentials/_PATCH/files/Scene/UI/CommonLanguageMenu.d/message/Common.bmg.json b/Pack/MKWFaraphel/essentials/_PATCH/files/Scene/UI/CommonLanguageMenu.d/message/Common.bmg.json index 99b851c..f241942 100644 --- a/Pack/MKWFaraphel/essentials/_PATCH/files/Scene/UI/CommonLanguageMenu.d/message/Common.bmg.json +++ b/Pack/MKWFaraphel/essentials/_PATCH/files/Scene/UI/CommonLanguageMenu.d/message/Common.bmg.json @@ -14,7 +14,7 @@ }, { "mode": "patch", - "patchs": ["LE-FORCE-COPY"] + "patchs": ["LE-COPY"] } ] }, diff --git a/Pack/MKWFaraphel/essentials/_PATCH/files/Scene/UI/MultiplayerLanguage.d/message/Common.bmg.json b/Pack/MKWFaraphel/essentials/_PATCH/files/Scene/UI/MultiplayerLanguage.d/message/Common.bmg.json index 05ee049..786f72c 100644 --- a/Pack/MKWFaraphel/essentials/_PATCH/files/Scene/UI/MultiplayerLanguage.d/message/Common.bmg.json +++ b/Pack/MKWFaraphel/essentials/_PATCH/files/Scene/UI/MultiplayerLanguage.d/message/Common.bmg.json @@ -14,7 +14,7 @@ }, { "mode": "patch", - "patchs": ["LE-FORCE-COPY"] + "patchs": ["LE-COPY"] } ] }, diff --git a/Pack/MKWFaraphel/essentials/_PATCH/files/Scene/UI/RaceLanguage.d/message/Common.bmg.json b/Pack/MKWFaraphel/essentials/_PATCH/files/Scene/UI/RaceLanguage.d/message/Common.bmg.json index ba64c3d..d67a114 100644 --- a/Pack/MKWFaraphel/essentials/_PATCH/files/Scene/UI/RaceLanguage.d/message/Common.bmg.json +++ b/Pack/MKWFaraphel/essentials/_PATCH/files/Scene/UI/RaceLanguage.d/message/Common.bmg.json @@ -14,7 +14,7 @@ }, { "mode": "patch", - "patchs": ["LE-FORCE-COPY"] + "patchs": ["LE-COPY"] } ] }, diff --git a/source/wt/ctc.py b/source/wt/ctc.py index 508d8f1..1aab9a1 100644 --- a/source/wt/ctc.py +++ b/source/wt/ctc.py @@ -1,4 +1,6 @@ +from source.mkw.OriginalTrack import OriginalTrack from source.wt import * +import re tools_path = tools_szs_dir / "wctct" @@ -8,10 +10,29 @@ _tools_run_popen = get_tools_run_popen_function(tools_path) def bmg_ctfile(ctfile: "Path | str") -> str: + """ + get a bmg definition from a ctfile + :param ctfile: the ctfile + :return: a bmg definition + """ process = _tools_run_popen("BMG", "-", "--lecode") stdout, _ = process.communicate(input=ctfile.encode("utf-8")) if process.returncode != 0: raise WTError(tools_path, process.returncode) - return stdout.decode("utf-8") + # this command will generate unwanted definition for the originals tracks / arena. Delete them if + # they are not custom + + original_tracks_texts: list[str] = list(map(lambda data: data["name"], OriginalTrack.all_original_tracks)) + + def remove_unwanted_definition(match: re.Match) -> str: + def_id = int(match.group("id"), 16) + def_text = match.group("value").removesuffix("\r") + + # if the definition is a track / arena definition and the text is not modified, remove the definition + if 0x7000 <= def_id <= 0x7029 and def_text in original_tracks_texts: return "" + # otherwise, keep the line + return match.group() + + return re.sub(r" {2}(?P.*?)\t= (?P.*)", remove_unwanted_definition, stdout.decode("utf-8"))