From eafb7a47e955935b24b3e02e655955401c86f48c Mon Sep 17 00:00:00 2001 From: Faraphel Date: Wed, 26 Jan 2022 09:37:28 +0100 Subject: [PATCH] reformatted some minor thing, added a log_error --- source/Error.py | 2 +- source/Game.py | 23 ++++++++++++++++------- source/Gui/Main.py | 14 ++++++++------ source/Gui/TrackConfiguration.py | 3 ++- source/Track.py | 2 +- 5 files changed, 28 insertions(+), 16 deletions(-) diff --git a/source/Error.py b/source/Error.py index 4693cd2..2627fc0 100644 --- a/source/Error.py +++ b/source/Error.py @@ -60,4 +60,4 @@ class ErrorLogger: messagebox.showerror( self.common.translate("Error"), self.common.translate("An error occured", " :", "\n", error, "\n\n") - ) \ No newline at end of file + ) diff --git a/source/Game.py b/source/Game.py index df66116..3e4417a 100644 --- a/source/Game.py +++ b/source/Game.py @@ -423,13 +423,19 @@ class Game: try: os.makedirs(f"{self.common.ct_config.pack_path}/file/Track-WU8/", exist_ok=True) - max_step = len(self.common.ct_config.file_process["img_encode"]) + \ - len(self.common.ct_config.all_tracks) + \ - 3 + \ - len("EGFIS") + max_step = ( + len(self.common.ct_config.file_process["img_encode"]) + + len(self.common.ct_config.all_tracks) + + 3 + + len("EGFIS") + ) - self.common.gui_main.progress(show=True, indeter=False, statut=self.common.translate("Converting files"), - max=max_step, step=0) + self.common.gui_main.progress( + show=True, + indeter=False, + statut=self.common.translate("Converting files"), + max=max_step, step=0 + ) self.common.gui_main.progress(statut=self.common.translate("Configurating LE-CODE"), add=1) self.common.ct_config.create_ctfile() @@ -549,7 +555,10 @@ class Game: :param track: the track that will be patched :return: 0 if no error occured """ - track.convert_wu8_to_szs() + try: track.convert_wu8_to_szs() + except Exception as e: + self.common.log_error() + raise e def clean_process() -> int: """ diff --git a/source/Gui/Main.py b/source/Gui/Main.py index 80720dd..66775d1 100644 --- a/source/Gui/Main.py +++ b/source/Gui/Main.py @@ -127,7 +127,6 @@ class Main: self.progressbar = ttk.Progressbar(self.root) self.progresslabel = Label(self.root) - if self.menu_bar: self.menu_bar.destroy() self.menu_bar = Menu(self.root) self.root.config(menu=self.menu_bar) @@ -232,9 +231,10 @@ class Main: mystuff_dir = filedialog.askdirectory() if mystuff_dir: stringvar.set(mystuff_dir) - self.menu_mystuff.entryconfig(index, label=self.common.translate( - "Apply", " ", label, f" ({stringvar.get()!r} ", "selected", ")") - ) + self.menu_mystuff.entryconfig( + index, + label=self.common.translate("Apply", " ", label, f" ({stringvar.get()!r} ", "selected", ")") + ) _func(init=True) self.menu_mystuff.entryconfig(index, command=_func) @@ -254,7 +254,8 @@ class Main: ctconfig_file=self.get_ctconfig_path_pack(self.stringvar_ctconfig.get()) ) - def get_available_packs(self) -> list: + @staticmethod + def get_available_packs() -> list: available_packs = [] for pack_ctconfig in glob.glob("./Pack/*/ct_config.json"): @@ -263,7 +264,8 @@ class Main: return available_packs - def get_ctconfig_path_pack(self, pack_name: str) -> str: + @staticmethod + def get_ctconfig_path_pack(pack_name: str) -> str: return "./Pack/" + pack_name + "/ct_config.json" def check_update(self) -> None: diff --git a/source/Gui/TrackConfiguration.py b/source/Gui/TrackConfiguration.py index 298710d..78222ea 100644 --- a/source/Gui/TrackConfiguration.py +++ b/source/Gui/TrackConfiguration.py @@ -177,7 +177,8 @@ class TrackConfiguration: command=self.promp_load_from_file ).grid(row=1, column=3, sticky="E") - def del_frame_track_filter(self, frames_filter: list, index: int = 0): + @staticmethod + def del_frame_track_filter(frames_filter: list, index: int = 0): for elem in frames_filter[index:]: # remove all track filter after this one elem["frame"].destroy() del frames_filter[index:] diff --git a/source/Track.py b/source/Track.py index 00592f7..b193c2a 100644 --- a/source/Track.py +++ b/source/Track.py @@ -237,4 +237,4 @@ class TrackGroup(Track): for track in self.tracks: ctfile_group += track.get_ctfile(*args, **kwargs) - return ctfile_group \ No newline at end of file + return ctfile_group