diff --git a/ct_config.json b/ct_config.json index 902fb57..1d7797c 100644 --- a/ct_config.json +++ b/ct_config.json @@ -3,6 +3,8 @@ "name":"Mario Kart Wii Faraphel", "nickname":"MKWF", "game_variant":"60", + "region": 5500, + "cheat_region": 20000, "cup":{ "0":{ "name":"Coupe Champignon", diff --git a/source/CT_Config.py b/source/CT_Config.py index 4b9d1d3..c389dc6 100644 --- a/source/CT_Config.py +++ b/source/CT_Config.py @@ -30,11 +30,14 @@ def get_cup_icon(cup_id: [str, int], font_path: str = "./file/SuperMario256.ttf" class CT_Config: - def __init__(self, version: str = None, name: str = None, nickname: str = None, game_variant: str = None, gui=None): + def __init__(self, version: str = None, name: str = None, nickname: str = None, + game_variant: str = None, gui=None, region: int = None, cheat_region: int = None): self.version = version self.name = name self.nickname = nickname if nickname else name self.game_variant = game_variant # this is the "60" part in RMCP60 for example + self.region = region + self.cheat_region = cheat_region self.ordered_cups = [] self.unordered_tracks = [] @@ -164,6 +167,8 @@ class CT_Config: self.name = ctconfig_json["name"] self.nickname = ctconfig_json["nickname"] if "nickname" in ctconfig_json else self.name self.game_variant = ctconfig_json["game_variant"] if "game_variant" in ctconfig_json else "01" + self.region = ctconfig_json.get("region") + self.cheat_region = ctconfig_json.get("cheat_region") def search_tracks(self, values_list=False, not_value=False, only_unordered_track=False, **kwargs) -> list: """ diff --git a/source/Game.py b/source/Game.py index 37b8b21..43c4ea4 100644 --- a/source/Game.py +++ b/source/Game.py @@ -275,7 +275,9 @@ class Game: patch the main.dol file to allow the addition of LECODE.bin file """ self.gui.progress(statut=self.gui.translate("Patch main.dol"), add=1) - wstrt.patch(path=self.path) + + region_id = self.ctconfig.region if self.gui.is_using_official_config() else self.ctconfig.cheat_region + wstrt.patch(path=self.path, region_id=region_id) def install_patch_lecode(self) -> None: """ @@ -413,10 +415,6 @@ class Game: file_process = json.load(fp_file) for bmg_process in file_process["bmg"]: - if "only_file" in bmg_process: - if not os.path.basename(file) in bmg_process["only_file"]: - continue - if bmg_language and "language" in bmg_process: if gamelang_to_lang[bmg_language] in bmg_process["language"]: continue diff --git a/source/wszst/wstrt.py b/source/wszst/wstrt.py index e27dee6..8974a04 100644 --- a/source/wszst/wstrt.py +++ b/source/wszst/wstrt.py @@ -5,10 +5,19 @@ WSTRT_PATH = "./tools/szs/wstrt" @error.better_wszst_error(wszst_tools=WSTRT_PATH) -def patch(path: str) -> None: +def patch(path: str, region_id: int = None) -> None: """ Patch the main.dol file + :param region_id: optional option to the mod region :param path: path to the game """ - subprocess.run([WSTRT_PATH, "patch", path + "/sys/main.dol", "--clean-dol", "--add-lecode"], - creationflags=subprocess.CREATE_NO_WINDOW, check=True, stdout=subprocess.PIPE) \ No newline at end of file + + cmd = [ + WSTRT_PATH, "patch", + path + "/sys/main.dol", path + "/files/rel/StaticR.rel", + "--clean-dol", + "--add-lecode" + ] + if region_id: cmd.extend(["--region", str(region_id)]) + + subprocess.run(cmd, creationflags=subprocess.CREATE_NO_WINDOW, check=True, stdout=subprocess.PIPE) \ No newline at end of file