authors are now stored as a list in ct_config.json

This commit is contained in:
Faraphel 2022-01-12 09:10:34 +01:00
parent b7f87d6a31
commit edb1c78658
3 changed files with 14400 additions and 13812 deletions

File diff suppressed because it is too large Load diff

View file

@ -55,7 +55,7 @@ class Gui:
self.root.resizable(False, False) self.root.resizable(False, False)
self.root.iconbitmap(bitmap="./icon.ico") self.root.iconbitmap(bitmap="./icon.ico")
if not(self.boolvar_dont_check_for_update.get()): self.check_update() if not self.boolvar_dont_check_for_update.get(): self.check_update()
self.menu_bar = Menu(self.root) self.menu_bar = Menu(self.root)
self.root.config(menu=self.menu_bar) self.root.config(menu=self.menu_bar)
@ -275,7 +275,8 @@ class Gui:
f"For game version : {self.game.ctconfig.version}\n" f"For game version : {self.game.ctconfig.version}\n"
f"./file/ directory : {os.listdir('./file/')}\n" f"./file/ directory : {os.listdir('./file/')}\n"
f"GAME/files/ information : {self.game.path, self.game.region}\n" f"GAME/files/ information : {self.game.path, self.game.region}\n"
f"{error}\n") f"{error}\n"
)
messagebox.showerror(self.translate("Error"), self.translate("An error occured", " :", "\n", error, "\n\n")) messagebox.showerror(self.translate("Error"), self.translate("An error occured", " :", "\n", error, "\n\n"))
def progress(self, show: bool = None, indeter: bool = None, step: int = None, def progress(self, show: bool = None, indeter: bool = None, step: int = None,
@ -321,10 +322,8 @@ class Gui:
self.button_select_path self.button_select_path
] ]
for widget in button: for widget in button:
if enable: if enable: widget.config(state=NORMAL)
widget.config(state=NORMAL) else: widget.config(state=DISABLED)
else:
widget.config(state=DISABLED)
def translate(self, *texts, gamelang: str = None) -> str: def translate(self, *texts, gamelang: str = None) -> str:
""" """
@ -334,18 +333,14 @@ class Gui:
:return: translated text :return: translated text
""" """
lang = gamelang_to_lang.get(gamelang, self.stringvar_language.get()) lang = gamelang_to_lang.get(gamelang, self.stringvar_language.get())
if lang not in translation_dict: return "".join(texts) # if no translation language is found
if lang in translation_dict: _lang_trad = translation_dict[lang]
_lang_trad = translation_dict[lang] translated_text = ""
translated_text = "" for text in texts:
for text in texts: if text in _lang_trad: translated_text += _lang_trad[text]
if text in _lang_trad: else: translated_text += text
translated_text += _lang_trad[text] return translated_text
else:
translated_text += text
return translated_text
return "".join(texts) # if no translation language is found
def is_using_official_config(self) -> bool: def is_using_official_config(self) -> bool:
""" """

View file

@ -24,7 +24,8 @@ def check_file_sha1(file: str, excepted_sha1: str) -> int:
class Track: class Track:
def __init__(self, name: str = "_", prefix: str = None, suffix: str = None, def __init__(self, name: str = "_", prefix: str = None, suffix: str = None,
author="Nintendo", special="T11", music="T11", new=True, sha1: str = None, since_version: str = None, author: str = "Nintendo", special: str = "T11", music: str = "T11",
new=True, sha1: str = None, since_version: str = None,
score: int = 0, warning: int = 0, note: str = "", track_wu8_dir: str = "./file/Track-WU8/", score: int = 0, warning: int = 0, note: str = "", track_wu8_dir: str = "./file/Track-WU8/",
track_szs_dir: str = "./file/Track/", track_version: str = None, tags: list = [], *args, **kwargs): track_szs_dir: str = "./file/Track/", track_version: str = None, tags: list = [], *args, **kwargs):
""" """
@ -34,7 +35,7 @@ class Track:
:param file_szs: path to its szs file :param file_szs: path to its szs file
:param prefix: track prefix (often original console or game) :param prefix: track prefix (often original console or game)
:param suffix: track suffix (often for variation like Boost or Night) :param suffix: track suffix (often for variation like Boost or Night)
:param author: track creator :param author: track creator(s)
:param special: track special slot :param special: track special slot
:param music: track music slot :param music: track music slot
:param new: is the track original or from an older game :param new: is the track original or from an older game
@ -117,6 +118,12 @@ class Track:
raise CantDownloadTrack(track=self, http_error=dl.status_code) raise CantDownloadTrack(track=self, http_error=dl.status_code)
raise CantDownloadTrack(track=self, http_error="Failed to download track") # if failed more than 3 times raise CantDownloadTrack(track=self, http_error="Failed to download track") # if failed more than 3 times
def get_author_str(self) -> str:
"""
:return: the list of authors with ", " separating them
"""
return ", ".join(self.author) if type(self.author) == str else self.author
def get_ctfile(self, race=False, *args, **kwargs) -> str: def get_ctfile(self, race=False, *args, **kwargs) -> str:
""" """
get ctfile text to create CTFILE.txt and RCTFILE.txt get ctfile text to create CTFILE.txt and RCTFILE.txt
@ -136,7 +143,7 @@ class Track:
else: else:
ctfile_text += ( ctfile_text += (
f'"-"; ' # track path, not used in Race_*.szs, save a bit of space f'"-"; ' # track path, not used in Race_*.szs, save a bit of space
f'"{self.get_track_formatted_name(*args, **kwargs)}\\n{self.author}"; ' # only in race show author's name f'"{self.get_track_formatted_name(*args, **kwargs)}\\n{self.get_author_str()}"; ' # only in race show author's name
f'"-"\n' # sha1, useless for now. f'"-"\n' # sha1, useless for now.
) )