mirror of
https://github.com/Faraphel/Atlas-Install.git
synced 2025-07-05 20:28:27 +02:00
get_ctfile now have a template option for the track name
This commit is contained in:
parent
db87f6cdd7
commit
5207e18928
4 changed files with 15 additions and 19 deletions
|
@ -62,11 +62,7 @@
|
|||
},
|
||||
"tags_cups": ["Switch", "3DS", "DS", "GCN", "GBA", "N64", "SNES", "MKT", "RMX", "DX", "GP"],
|
||||
|
||||
"track_formatting": {
|
||||
"menu_name": "{{ ('\\c{YOR2}\\x'+hex(65296+getattr(track, 'score'))[2:]+'\\{off} ') if hasattr(track, 'score') else '' }}{{ (prefix+' ') if prefix else '' }}{{ getattr(track, 'name', '') }}{{ (' ('+suffix +')') if suffix else '' }}",
|
||||
"race_name": "{{ getattr(track, 'name', '') }}",
|
||||
"file_name": "{{ getattr(track, 'sha1', '_') }}"
|
||||
},
|
||||
"track_file_template": "{{ getattr(track, 'sha1', '_') }}",
|
||||
|
||||
"default_track": {
|
||||
"music": "T32",
|
||||
|
|
|
@ -56,13 +56,14 @@ class Cup:
|
|||
# if the icon doesn't exist, use the default automatically generated one
|
||||
return self.get_default_cticon(mod_config=mod_config)
|
||||
|
||||
def get_ctfile(self, mod_config: "ModConfig") -> str:
|
||||
def get_ctfile(self, mod_config: "ModConfig", template: str) -> str:
|
||||
"""
|
||||
Get the ctfile for this cup
|
||||
:return: the ctfile
|
||||
"""
|
||||
ctfile = f'C "{self.cup_name}"\n'
|
||||
for track in self._tracks: ctfile += track.get_ctfile(mod_config=mod_config)
|
||||
for track in self._tracks: ctfile += track.get_ctfile(mod_config, template)
|
||||
ctfile += "\n"
|
||||
|
||||
return ctfile
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ Thread: any
|
|||
class ModConfig:
|
||||
__slots__ = ("name", "path", "nickname", "variant", "tags_prefix", "tags_suffix",
|
||||
"default_track", "_tracks", "version", "original_track_prefix", "swap_original_order",
|
||||
"keep_original_track", "enable_random_cup", "tags_cups", "track_formatting")
|
||||
"keep_original_track", "enable_random_cup", "tags_cups", "track_file_template")
|
||||
|
||||
def __init__(self, path: Path | str, name: str, nickname: str = None, version: str = None, variant: str = None,
|
||||
tags_prefix: dict[Tag, Color] = None, tags_suffix: dict[Tag, Color] = None,
|
||||
|
@ -31,7 +31,7 @@ class ModConfig:
|
|||
default_track: "Track | TrackGroup" = None, tracks: list["Track | TrackGroup"] = None,
|
||||
original_track_prefix: bool = None, swap_original_order: bool = None,
|
||||
keep_original_track: bool = None, enable_random_cup: bool = None,
|
||||
track_formatting: dict[str, str] = None):
|
||||
track_file_template: str = None):
|
||||
|
||||
self.path = Path(path)
|
||||
|
||||
|
@ -46,11 +46,8 @@ class ModConfig:
|
|||
|
||||
self.default_track: "Track | TrackGroup" = default_track if default_track is not None else None
|
||||
self._tracks: list["Track | TrackGroup"] = tracks if tracks is not None else []
|
||||
self.track_formatting: dict[str, str] = {
|
||||
"menu_name": "{{ getattr(track, 'name', '') }}",
|
||||
"race_name": "{{ getattr(track, 'name', '') }}",
|
||||
"file_name": "{{ getattr(track, 'sha1', '_') }}",
|
||||
} | (track_formatting if track_formatting is not None else {})
|
||||
self.track_file_template: str = track_file_template \
|
||||
if track_file_template is not None else "{{ getattr(track, 'sha1', '_') }}"
|
||||
|
||||
self.original_track_prefix: bool = original_track_prefix if original_track_prefix is not None else True
|
||||
self.swap_original_order: bool = swap_original_order if swap_original_order is not None else True
|
||||
|
@ -189,7 +186,8 @@ class ModConfig:
|
|||
)
|
||||
|
||||
for cup in self.get_cups():
|
||||
ctfile += cup.get_ctfile(mod_config=self)
|
||||
# get all the cup ctfile, use "-" for the template since the track's name are not used here
|
||||
ctfile += cup.get_ctfile(mod_config=self, template="-")
|
||||
|
||||
return ctfile
|
||||
|
||||
|
|
|
@ -84,19 +84,20 @@ class Track:
|
|||
def is_new(self, mod_config: "ModConfig", default: any = None) -> bool:
|
||||
...
|
||||
|
||||
def get_ctfile(self, mod_config: "ModConfig", hidden: bool = False) -> str:
|
||||
def get_ctfile(self, mod_config: "ModConfig", template: str, hidden: bool = False) -> str:
|
||||
"""
|
||||
return the ctfile of the track
|
||||
:hidden: if the track is in a group
|
||||
:template: format of the track's name
|
||||
:return: ctfile
|
||||
"""
|
||||
menu_name = f'{self.repr_format(mod_config=mod_config, template=mod_config.track_formatting["menu_name"])!r}'
|
||||
file_name = f'{self.repr_format(mod_config=mod_config, template=mod_config.track_formatting["file_name"])!r}'
|
||||
name = repr(self.repr_format(mod_config=mod_config, template=template))
|
||||
file_name = repr(self.repr_format(mod_config=mod_config, template=mod_config.track_file_template))
|
||||
|
||||
return (
|
||||
f'{"H" if hidden else "T"} {self.music}; ' # track type
|
||||
f'{self.special}; {(0x04 if hidden else 0) | (0x01 if self.is_new(mod_config, False) else 0):#04x}; ' # lecode flags
|
||||
f'{file_name}; ' # filename
|
||||
f'{menu_name}; ' # name of the track in the menu
|
||||
f'{name}; ' # name of the track in the menu
|
||||
f'{file_name}\n' # unique identifier for each track
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue