variant have been renamed gameid_template and now allow to change the entire game id instead of only the end part.

This commit is contained in:
Faraphel 2022-09-02 13:41:50 +02:00
parent 423a02ce4c
commit f093e3462a
4 changed files with 21 additions and 4 deletions

View file

@ -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": {

View file

@ -278,7 +278,7 @@ class ExtractedGame:
'',
' <patch id="save_SD">',
' <savegame clone="false"',
f' external="/{RIIVOLUTION_FOLDER_NAME}/save/{"{$__gameid}{$__region}"}{mod_config.variant}"/>',
f' external="/{RIIVOLUTION_FOLDER_NAME}/save/{self.original_game.get_patched_gameid(mod_config)}"/>',
' </patch>',
'</wiidisc>',
))

View file

@ -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

View file

@ -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