mirror of
https://github.com/Faraphel/Atlas-Install.git
synced 2025-07-05 04:08:21 +02:00
track disabled in multiplayer are replaced by their original wii track corresponding to their special slot
This commit is contained in:
parent
13c7e1d165
commit
413e906547
3 changed files with 86 additions and 16 deletions
|
@ -118,7 +118,12 @@ class Game:
|
|||
# TODO: normalize all tracks should get the threads amount changeable
|
||||
yield from extracted_game.extract_autoadd(cache_autoadd_directory)
|
||||
yield from extracted_game.extract_original_tracks(cache_ogtracks_directory)
|
||||
yield from mod_config.normalize_all_tracks(cache_autoadd_directory, cache_cttracks_directory, 8)
|
||||
yield from mod_config.normalize_all_tracks(
|
||||
cache_autoadd_directory,
|
||||
cache_cttracks_directory,
|
||||
cache_ogtracks_directory,
|
||||
8
|
||||
)
|
||||
|
||||
# patch the game
|
||||
yield from extracted_game.prepare_dol()
|
||||
|
|
|
@ -10,6 +10,7 @@ from source.mkw.Cup import Cup
|
|||
from source.mkw.Track import Track
|
||||
import json
|
||||
|
||||
from source.mkw.OriginalTrack import OriginalTrack
|
||||
from source.safe_eval import safe_eval
|
||||
from source.wt.szs import SZSPath
|
||||
|
||||
|
@ -254,15 +255,17 @@ class ModConfig:
|
|||
return full_cticon
|
||||
|
||||
def normalize_all_tracks(self, autoadd_path: "Path | str", destination_path: "Path | str",
|
||||
thread_amount: int = 8) -> Generator[dict, None, None]:
|
||||
original_tracks_path: "Path | str", thread_amount: int = 8) -> Generator[dict, None, None]:
|
||||
"""
|
||||
Convert all tracks of the mod to szs into the destination_path
|
||||
:param original_tracks_path: path to the originals tracks (if a track is disabled for multiplayer)
|
||||
:param thread_amount: number of thread to use
|
||||
:param autoadd_path: autoadd directory
|
||||
:param destination_path: destination where the files are converted
|
||||
"""
|
||||
yield {"description": "Normalizing track..."}
|
||||
destination_path = Path(destination_path)
|
||||
original_tracks_path = Path(original_tracks_path)
|
||||
destination_path.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
normalize_threads: list[dict] = []
|
||||
|
@ -279,19 +282,6 @@ class ModConfig:
|
|||
|
||||
track_directory = self.path.parent / "_TRACKS"
|
||||
|
||||
# prepare the default track
|
||||
default_track_file: Path = next(
|
||||
track_directory.rglob(f"{self.default_track.repr_format(self, self.track_file_template)}.*")
|
||||
)
|
||||
|
||||
yield {"description": "normalizing default track"}
|
||||
# normalize the default track before to make it available as a callback
|
||||
SZSPath(default_track_file).normalize(
|
||||
autoadd_path,
|
||||
destination_path / f"{default_track_file.stem}.szs",
|
||||
format="szs"
|
||||
)
|
||||
|
||||
for track in self.get_tracks():
|
||||
track_file: Path = next(
|
||||
track_directory.rglob(f"{track.repr_format(self, self.track_file_template)}.*")
|
||||
|
@ -308,7 +298,10 @@ class ModConfig:
|
|||
if safe_eval(self.multiplayer_disable_if, {"track": track}) == "True":
|
||||
# if the track should use the default track instead in multiplayer,
|
||||
# copy the default track to the same file but with a _d at the end
|
||||
shutil.copy(default_track_file, destination_path / f"{track_file.stem}_d.szs")
|
||||
shutil.copy(
|
||||
original_tracks_path / f"{OriginalTrack(track_data=track.special, track_key='slot').name}_d.szs",
|
||||
destination_path / f"{track_file.stem}_d.szs"
|
||||
)
|
||||
|
||||
else:
|
||||
# delete the _d file if it exists
|
||||
|
|
72
source/mkw/OriginalTrack.py
Normal file
72
source/mkw/OriginalTrack.py
Normal file
|
@ -0,0 +1,72 @@
|
|||
class OriginalTrackNotFound(Exception):
|
||||
def __init__(self, track_data: any):
|
||||
super().__init__(f'Can\'t find original track "{track_data}"')
|
||||
|
||||
|
||||
class OriginalTrack:
|
||||
all_original_tracks: list[dict] = [
|
||||
# wii tracks
|
||||
{"name": "beginner_course", "slot": "T11", "nickname": "LC"},
|
||||
{"name": "farm_course", "slot": "T12", "nickname": "MMM"},
|
||||
{"name": "kinoko_course", "slot": "T13", "nickname": "MG"},
|
||||
{"name": "factory_course", "slot": "T14", "nickname": "TF"},
|
||||
|
||||
{"name": "castle_course", "slot": "T21", "nickname": "MC"},
|
||||
{"name": "shopping_course", "slot": "T22", "nickname": "CM"},
|
||||
{"name": "boardcross_course", "slot": "T23", "nickname": "DKS"},
|
||||
{"name": "truck_course", "slot": "T24", "nickname": "WGM"},
|
||||
|
||||
{"name": "senior_course", "slot": "T31", "nickname": "DC"},
|
||||
{"name": "water_course", "slot": "T32", "nickname": "KC"},
|
||||
{"name": "treehouse_course", "slot": "T33", "nickname": "MT"},
|
||||
{"name": "volcano_course", "slot": "T34", "nickname": "GV"},
|
||||
|
||||
{"name": "desert_course", "slot": "T41", "nickname": "DDR"},
|
||||
{"name": "ridgehighway_course", "slot": "T42", "nickname": "MH"},
|
||||
{"name": "koppa_course", "slot": "T43", "nickname": "BC"},
|
||||
{"name": "rainbow_course", "slot": "T44", "nickname": "RR"},
|
||||
|
||||
# retro tracks
|
||||
{"name": "old_peach_gc", "slot": "T51", "nickname": "gPB"},
|
||||
{"name": "old_falls_ds", "slot": "T52", "nickname": "dYF"},
|
||||
{"name": "old_obake_sfc", "slot": "T53", "nickname": "sGV2"},
|
||||
{"name": "old_mario_64", "slot": "T54", "nickname": "nMR"},
|
||||
|
||||
{"name": "old_sherbet_64", "slot": "T61", "nickname": "nSL"},
|
||||
{"name": "old_heyho_gba", "slot": "T62", "nickname": "gSGB"},
|
||||
{"name": "old_town_ds", "slot": "T63", "nickname": "dDS"},
|
||||
{"name": "old_waluigi_gc", "slot": "T64", "nickname": "gWS"},
|
||||
|
||||
{"name": "old_desert_ds", "slot": "T71", "nickname": "dDH"},
|
||||
{"name": "old_koopa_gba", "slot": "T72", "nickname": "gBC3"},
|
||||
{"name": "old_donkey_64", "slot": "T73", "nickname": "nDKJP"},
|
||||
{"name": "old_mario_gc", "slot": "T74", "nickname": "gMC"},
|
||||
|
||||
{"name": "old_mario_sfc", "slot": "T81", "nickname": "sMC3"},
|
||||
{"name": "old_garden_ds", "slot": "T82", "nickname": "dPG"},
|
||||
{"name": "old_donkey_gc", "slot": "T83", "nickname": "gDKM"},
|
||||
{"name": "old_koopa_64", "slot": "T84", "nickname": "nBC"},
|
||||
|
||||
# wii arena
|
||||
{"name": "block_battle", "slot": "A11", "nickname": "aBP"},
|
||||
{"name": "venice_battle", "slot": "A12", "nickname": "aDP"},
|
||||
{"name": "skate_battle", "slot": "A13", "nickname": "aFS"},
|
||||
{"name": "casino_battle", "slot": "A14", "nickname": "aCCW"},
|
||||
{"name": "sand_battle", "slot": "A15", "nickname": "aTD"},
|
||||
|
||||
# retro arena
|
||||
{"name": "old_battle4_sfc", "slot": "A21", "nickname": "asBC4"},
|
||||
{"name": "old_battle3_gba", "slot": "A22", "nickname": "agBC3"},
|
||||
{"name": "old_matenro_64", "slot": "A23", "nickname": "anSS"},
|
||||
{"name": "old_CookieLand_gc", "slot": "A24", "nickname": "agCL"},
|
||||
{"name": "old_House_ds", "slot": "A25", "nickname": "adTH"},
|
||||
]
|
||||
|
||||
__slots__ = ("name", "slot", "nickname")
|
||||
|
||||
def __init__(self, track_data: any, track_key: str = "slot"):
|
||||
colors = list(filter(lambda color: color[track_key] == track_data, self.all_original_tracks))
|
||||
if len(colors) == 0: raise OriginalTrackNotFound(track_data)
|
||||
|
||||
for key, value in colors[0].items():
|
||||
setattr(self, key, value)
|
Loading…
Reference in a new issue