diff --git a/Pack/MKWFaraphel/mod_config.json b/Pack/MKWFaraphel/mod_config.json index d8c0b05..59c9482 100644 --- a/Pack/MKWFaraphel/mod_config.json +++ b/Pack/MKWFaraphel/mod_config.json @@ -2,7 +2,7 @@ "version": "v0.12", "name": "Mario Kart Wii Faraphel", "nickname": "MKWF", - "variant": "60", + "gameid_template": "RMC{{region}}60", "global_settings": { "include_track_if": { diff --git a/source/mkw/ExtractedGame.py b/source/mkw/ExtractedGame.py index 113c046..bdd657e 100644 --- a/source/mkw/ExtractedGame.py +++ b/source/mkw/ExtractedGame.py @@ -278,7 +278,7 @@ class ExtractedGame: '', ' ', ' ', + f' external="/{RIIVOLUTION_FOLDER_NAME}/save/{self.original_game.get_patched_gameid(mod_config)}"/>', ' ', '', )) diff --git a/source/mkw/Game.py b/source/mkw/Game.py index 9d596cb..7ffc187 100644 --- a/source/mkw/Game.py +++ b/source/mkw/Game.py @@ -67,11 +67,24 @@ class Game: except StopIteration as e: return e.value + def get_patched_gameid(self, mod_config: ModConfig) -> str: + """ + :return: the patched game id + """ + region: str = self.wit_path.id[3] + return mod_config.multiple_safe_eval(template=mod_config.gameid_template, args=["region"])(region=region) + def edit(self, mod_config: ModConfig) -> Generator[Progress, None, None]: + """ + Edit some metadata about the game + :param mod_config: the mod configuration + """ + yield Progress(description=_("TEXT_CHANGING_GAME_METADATA"), determinate=False) + self.wit_path.edit( name=mod_config.name, - game_id=self.wit_path.id[:4] + mod_config.variant + game_id=self.get_patched_gameid(mod_config) ) @staticmethod diff --git a/source/mkw/ModConfig.py b/source/mkw/ModConfig.py index 78d5da2..2fa9ce7 100644 --- a/source/mkw/ModConfig.py +++ b/source/mkw/ModConfig.py @@ -5,6 +5,7 @@ from typing import Generator, Callable, Iterator, TYPE_CHECKING import json from PIL import Image +from source.mkw.collection.Region import Region from source.utils import threaded from source.mkw import Tag from source.mkw.ModSettings.ModSettingsGroup import ModSettingsGroup @@ -75,7 +76,7 @@ class ModConfig: name: str nickname: str = None version: str = "v1.0.0" - variant: str = "01" + gameid_template: "TemplateMultipleSafeEval" = "RMC{{region}}01" _tracks: list["Track | TrackGroup | dict"] = field(default_factory=list) default_track_attributes: dict[str, any] = field(default_factory=dict) @@ -470,3 +471,6 @@ class ModConfig: # if there is more than the max amount of thread running, wait for one to finish while len(normalize_threads) > 0: yield from remove_finished_threads() # if there is no longer any track to add, wait for all process to finish + + def get_gameid(self, region: Region): + pass