custom region shoule now be supported by the installer

This commit is contained in:
Faraphel 2022-01-13 13:40:57 +01:00
parent edb1c78658
commit 61b54936b3
4 changed files with 23 additions and 9 deletions

View file

@ -3,6 +3,8 @@
"name":"Mario Kart Wii Faraphel", "name":"Mario Kart Wii Faraphel",
"nickname":"MKWF", "nickname":"MKWF",
"game_variant":"60", "game_variant":"60",
"region": 5500,
"cheat_region": 20000,
"cup":{ "cup":{
"0":{ "0":{
"name":"Coupe Champignon", "name":"Coupe Champignon",

View file

@ -30,11 +30,14 @@ def get_cup_icon(cup_id: [str, int], font_path: str = "./file/SuperMario256.ttf"
class CT_Config: 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.version = version
self.name = name self.name = name
self.nickname = nickname if nickname else name self.nickname = nickname if nickname else name
self.game_variant = game_variant # this is the "60" part in RMCP60 for example 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.ordered_cups = []
self.unordered_tracks = [] self.unordered_tracks = []
@ -164,6 +167,8 @@ class CT_Config:
self.name = ctconfig_json["name"] self.name = ctconfig_json["name"]
self.nickname = ctconfig_json["nickname"] if "nickname" in ctconfig_json else self.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.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: def search_tracks(self, values_list=False, not_value=False, only_unordered_track=False, **kwargs) -> list:
""" """

View file

@ -275,7 +275,9 @@ class Game:
patch the main.dol file to allow the addition of LECODE.bin file 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) 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: def install_patch_lecode(self) -> None:
""" """
@ -413,10 +415,6 @@ class Game:
file_process = json.load(fp_file) file_process = json.load(fp_file)
for bmg_process in file_process["bmg"]: 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 bmg_language and "language" in bmg_process:
if gamelang_to_lang[bmg_language] in bmg_process["language"]: if gamelang_to_lang[bmg_language] in bmg_process["language"]:
continue continue

View file

@ -5,10 +5,19 @@ WSTRT_PATH = "./tools/szs/wstrt"
@error.better_wszst_error(wszst_tools=WSTRT_PATH) @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 Patch the main.dol file
:param region_id: optional option to the mod region
:param path: path to the game :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) 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)