From 53ee294915fd4d50f339b8d40b3a72fd73eaa626 Mon Sep 17 00:00:00 2001 From: raphael60650 Date: Wed, 21 Jul 2021 22:52:49 +0200 Subject: [PATCH] track highlight functionnality weren't implemented since code rework --- source/CT_Config.py | 8 +++++--- source/Cup.py | 4 ++-- source/Game.py | 2 +- source/Track.py | 12 ++++++------ 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/source/CT_Config.py b/source/CT_Config.py index 69357e4..32353cb 100644 --- a/source/CT_Config.py +++ b/source/CT_Config.py @@ -9,6 +9,7 @@ from .Track import Track def get_cup_icon(id, font_path: str = "./file/SuperMario256.ttf", cup_icon_dir: str = "./file/cup_icon"): """ + :param id: :param cup_icon_dir: directory to cup icon :param font_path: path to the font used to generate icon :return: cup icon @@ -54,8 +55,9 @@ class CT_Config: self.all_version.add(track.since_version) self.all_tracks.append(track) - def create_ctfile(self, directory="./file/"): + def create_ctfile(self, directory="./file/", highlight_version=None): """ + :param highlight_version: :param directory: create CTFILE.txt and RCTFILE.txt in this directory :return: None """ @@ -79,8 +81,8 @@ class CT_Config: # all cups for cup in self.ordered_cups + unordered_cups: - ctfile.write(cup.get_ctfile_cup(race=False)) - rctfile.write(cup.get_ctfile_cup(race=True)) + ctfile.write(cup.get_ctfile_cup(race=False, highlight_version=highlight_version)) + rctfile.write(cup.get_ctfile_cup(race=True, highlight_version=highlight_version)) def get_cticon(self): """ diff --git a/source/Cup.py b/source/Cup.py index f89bfaa..1bedb88 100644 --- a/source/Cup.py +++ b/source/Cup.py @@ -18,14 +18,14 @@ class Cup: ] self.locked = locked - def get_ctfile_cup(self, race=False): + def get_ctfile_cup(self, *args, **kwargs): """ :param race: is it a text used for Race_*.szs ? :return: ctfile definition for the cup """ ctfile_cup = f'\nC "{self.name}"\n' for track in self.tracks: - ctfile_cup += track.get_ctfile(race) + ctfile_cup += track.get_ctfile(*args, **kwargs) return ctfile_cup def load_from_json(self, cup: dict): diff --git a/source/Game.py b/source/Game.py index 3b48d16..1c6acaa 100644 --- a/source/Game.py +++ b/source/Game.py @@ -306,7 +306,7 @@ class Game: self.gui.progress(show=True, indeter=False, statut=self.gui.translate("Converting files"), max=max_step, step=0) self.gui.progress(statut=self.gui.translate("Configurating LE-CODE"), add=1) - self.ctconfig.create_ctfile() + self.ctconfig.create_ctfile(highlight_version=self.gui.stringvar_mark_track_from_version.get()) self.gui.progress(statut=self.gui.translate("Creating ct_icon.png"), add=1) ct_icon = self.ctconfig.get_cticon() diff --git a/source/Track.py b/source/Track.py index 5046120..97442a7 100644 --- a/source/Track.py +++ b/source/Track.py @@ -59,7 +59,7 @@ class Track: print(f"error {dl.status_code} {self.file_wu8}") return -1 - def get_ctfile(self, race=False): + def get_ctfile(self, race=False, *args, **kwargs): """ :param race: is it a text used for Race_*.szs ? :return: ctfile definition for the track @@ -72,20 +72,20 @@ class Track: if not race: ctfile_text += ( f'"{self.get_track_name()}"; ' # track path - f'"{self.get_track_formatted_name()}"; ' # track text shown ig + f'"{self.get_track_formatted_name(*args, **kwargs)}"; ' # track text shown ig f'"-"\n') # sha1, useless for now. else: ctfile_text += ( f'"-"; ' # track path, not used in Race_*.szs, save a bit of space - f'"{self.get_track_formatted_name()}\\n{self.author}"; ' # only in race show author's name + f'"{self.get_track_formatted_name(*args, **kwargs)}\\n{self.author}"; ' # only in race show author's name f'"-"\n' # sha1, useless for now. ) return ctfile_text - def get_track_formatted_name(self, highlight_track_from_version: str = None): + def get_track_formatted_name(self, highlight_version: str = None): """ - :param highlight_track_from_version: if a specific version need to be highlighted. + :param highlight_version: if a specific version need to be highlighted. :return: the name of the track with colored prefix, suffix """ hl_prefix = "" @@ -99,7 +99,7 @@ class Track: star_text = "★" * self.score + "☆" * (3 - self.score) star_text = trackname_color[star_text] + " " - if self.since_version == highlight_track_from_version: + if self.since_version == highlight_version: hl_prefix, hl_suffix = "\\\\c{blue1}", "\\\\c{off}" if self.prefix in trackname_color: