added a "custom" note on the main menu text if the configuration for the mod is not the default / official one

This commit is contained in:
Faraphel 2021-10-25 22:37:53 +02:00
parent c3da90e544
commit cff27f6198
2 changed files with 36 additions and 9 deletions

View file

@ -44,8 +44,10 @@ class NoGui:
""" """
'fake' gui if no gui are used for compatibility. 'fake' gui if no gui are used for compatibility.
""" """
class NoButton: class NoButton:
def grid(self, *args, **kwargs): pass def grid(self, *args, **kwargs): pass
def config(self, *args, **kwargs): pass def config(self, *args, **kwargs): pass
class NoVariable: class NoVariable:
@ -59,7 +61,9 @@ class NoGui:
return self.value return self.value
def progress(*args, **kwargs): print(args, kwargs) def progress(*args, **kwargs): print(args, kwargs)
def translate(*args, **kwargs): return "" def translate(*args, **kwargs): return ""
def log_error(*args, **kwargs): print(args, kwargs) def log_error(*args, **kwargs): print(args, kwargs)
is_dev_version = False is_dev_version = False
@ -148,7 +152,8 @@ class Game:
self.region = region_id_to_name[self.region_ID] if self.region_ID in region_id_to_name else self.region self.region = region_id_to_name[self.region_ID] if self.region_ID in region_id_to_name else self.region
@in_thread @in_thread
def install_mod(self): self.nothread_install_mod() def install_mod(self):
self.nothread_install_mod()
def nothread_install_mod(self): def nothread_install_mod(self):
""" """
@ -184,7 +189,7 @@ class Game:
extracted_file = [] extracted_file = []
max_step += 4 # PATCH main.dol and PATCH lecode.bin, converting, changing ID max_step += 4 # PATCH main.dol and PATCH lecode.bin, converting, changing ID
self.gui.progress(show=True, indeter=False, statut=self.gui.translate("Installing mod"), max=max_step, self.gui.progress(show=True, indeter=False, statut=self.gui.translate("Installing mod"), max=max_step,
step=0) step=0)
def replace_file(path, file, subpath="/") -> None: def replace_file(path, file, subpath="/") -> None:
""" """
@ -273,8 +278,14 @@ class Game:
Patch bmg file (text file) Patch bmg file (text file)
:param gamefile: an .szs file where file will be patched :param gamefile: an .szs file where file will be patched
""" """
NINTENDO_CWF_REPLACE = "Wiimmfi" NINTENDO_CWF_REPLACE = "Wiimmfi"
MAINMENU_REPLACE = f"MKWFaraphel {self.ctconfig.version}" _customized = " (custom)"
MAINMENU_REPLACE = (
f"MKWFaraphel {self.ctconfig.version}" +
("" if self.gui.is_using_official_config() else _customized)
)
menu_replacement = { menu_replacement = {
"CWF de Nintendo": NINTENDO_CWF_REPLACE, "CWF de Nintendo": NINTENDO_CWF_REPLACE,
"Wi-Fi Nintendo": NINTENDO_CWF_REPLACE, "Wi-Fi Nintendo": NINTENDO_CWF_REPLACE,
@ -353,7 +364,8 @@ class Game:
finalise(f"./file/Common_R{bmglang}.txt", rbmgcommon) finalise(f"./file/Common_R{bmglang}.txt", rbmgcommon)
@in_thread @in_thread
def patch_file(self): self.nothread_patch_file() def patch_file(self):
self.nothread_patch_file()
def nothread_patch_file(self): def nothread_patch_file(self):
""" """
@ -452,7 +464,8 @@ class Game:
if not self.gui.boolvar_disable_download.get(): if not self.gui.boolvar_disable_download.get():
if not os.path.exists(track.file_wu8): if not os.path.exists(track.file_wu8):
try: track.download_wu8(GITHUB_DEV_BRANCH if self.gui.is_dev_version else GITHUB_MASTER_BRANCH) try:
track.download_wu8(GITHUB_DEV_BRANCH if self.gui.is_dev_version else GITHUB_MASTER_BRANCH)
except CantDownloadTrack: except CantDownloadTrack:
error_count += 1 error_count += 1
if error_count > error_max: # Too much track wasn't correctly converted if error_count > error_max: # Too much track wasn't correctly converted
@ -466,10 +479,11 @@ class Game:
f" ({error_count} / {error_max})")) f" ({error_count} / {error_max})"))
if not track.check_szs_sha1(): # if sha1 of track's szs is incorrect or track's szs does not exist if not track.check_szs_sha1(): # if sha1 of track's szs is incorrect or track's szs does not exist
if os.path.exists(track.file_wu8): track.convert_wu8_to_szs() if os.path.exists(track.file_wu8):
track.convert_wu8_to_szs()
else: else:
messagebox.showerror(self.gui.translate("Error"), messagebox.showerror(self.gui.translate("Error"),
self.gui.translate("Can't convert track.\nEnable track download and retry.")) self.gui.translate("Can't convert track.\nEnable track download and retry."))
raise CantConvertTrack() raise CantConvertTrack()
elif self.gui.boolvar_del_track_after_conv.get(): elif self.gui.boolvar_del_track_after_conv.get():
os.remove(track.file_wu8) os.remove(track.file_wu8)
@ -487,8 +501,10 @@ class Game:
if self.gui.boolvar_del_track_after_conv.get(): os.remove(track.file_wu8) if self.gui.boolvar_del_track_after_conv.get(): os.remove(track.file_wu8)
if not (any(thread_list.values())): return 1 # if there is no more process if not (any(thread_list.values())): return 1 # if there is no more process
if len(thread_list): return 1 if len(thread_list):
else: return 0 return 1
else:
return 0
total_track = len(self.ctconfig.all_tracks) total_track = len(self.ctconfig.all_tracks)
self.gui.progress(max=total_track, indeter=False, show=True) self.gui.progress(max=total_track, indeter=False, show=True)

View file

@ -293,3 +293,14 @@ class Gui:
return translated_text return translated_text
return "".join(texts) # if no translation language is found return "".join(texts) # if no translation language is found
def is_using_official_config(self) -> bool:
"""
:return: True if the parameter is the official one, False if it is customized
"""
return (
self.boolvar_use_1star_track.get() is True and
self.boolvar_use_2star_track.get() is True and
self.boolvar_use_3star_track.get() is True and
self.stringvar_sort_track_by.get() == "name"
)