From facab26ff2b6ab5105c5bba82beaa49b71dd8b44 Mon Sep 17 00:00:00 2001 From: faroukbmiled Date: Fri, 6 Oct 2023 13:56:46 +0100 Subject: [PATCH] added a way to update invalid items --- boiiiwd_package/src/library_tab.py | 9 +++++++-- boiiiwd_package/src/main.py | 27 +++++++++++++++------------ 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/boiiiwd_package/src/library_tab.py b/boiiiwd_package/src/library_tab.py index 9281fc0..95027a3 100644 --- a/boiiiwd_package/src/library_tab.py +++ b/boiiiwd_package/src/library_tab.py @@ -683,7 +683,10 @@ class LibraryTab(ctk.CTkScrollableFrame): main_app.app.edit_workshop_id.delete(0, "end") main_app.app.edit_workshop_id.insert(0, workshop_id) main_app.app.main_button_event() - main_app.app.download_map(update=True) + if invalid_warn and check_config("update_invalid", "no") == "yes": + main_app.app.download_map(update=True, invalid_item_folder=os.path.basename(folder)) + else: + main_app.app.download_map(update=True) top.destroy() return else: @@ -797,7 +800,9 @@ class LibraryTab(ctk.CTkScrollableFrame): update_btn.configure(state="disabled") update_btn_tooltip.configure(message="Currently offline") view_button_tooltip.configure(message="Currently offline") - if invalid_warn: + if check_config("update_invalid", "no") == "yes": + update_btn_tooltip.configure(message="update_invalid is set to 'yes' in config.ini") + elif invalid_warn: update_btn.configure(text="Update", state="disabled") update_btn_tooltip.configure(message="Disabled due to item being blocked or duplicated") diff --git a/boiiiwd_package/src/main.py b/boiiiwd_package/src/main.py index e0a416c..931e140 100644 --- a/boiiiwd_package/src/main.py +++ b/boiiiwd_package/src/main.py @@ -1017,7 +1017,7 @@ class BOIIIWD(ctk.CTk): self.after(0, callback) @if_internet_available - def download_map(self, update=False): + def download_map(self, update=False, invalid_item_folder=None): self.is_downloading = False self.fail_threshold = 0 if not self.is_pressed: @@ -1029,7 +1029,7 @@ class BOIIIWD(ctk.CTk): start_down_thread = threading.Thread(target=self.queue_download_thread, args=(update,)) start_down_thread.start() else: - start_down_thread = threading.Thread(target=self.download_thread, args=(update,)) + start_down_thread = threading.Thread(target=self.download_thread, args=(update, invalid_item_folder,)) start_down_thread.start() else: show_message("Warning", "Already pressed, Please wait.") @@ -1389,7 +1389,7 @@ class BOIIIWD(ctk.CTk): self.stop_download() self.is_pressed = False - def download_thread(self, update=None): + def download_thread(self, update=None, invalid_item_folder=None): try: self.settings_tab.stopped = False @@ -1580,20 +1580,23 @@ class BOIIIWD(ctk.CTk): items_file = os.path.join(APPLICATION_PATH, LIBRARY_FILE) item_exists,_ = self.library_tab.item_exists_in_file(items_file, workshop_id) - if item_exists: - get_folder_name = self.library_tab.get_item_by_id(items_file, workshop_id, return_option="folder_name") - if get_folder_name: - folder_name = get_folder_name + if invalid_item_folder: + folder_name = invalid_item_folder + else: + if item_exists: + get_folder_name = self.library_tab.get_item_by_id(items_file, workshop_id, return_option="folder_name") + if get_folder_name: + folder_name = get_folder_name + else: + try: + folder_name = extract_json_data(json_file_path, self.settings_tab.folder_options.get()) + except: + folder_name = extract_json_data(json_file_path, "publisherID") else: try: folder_name = extract_json_data(json_file_path, self.settings_tab.folder_options.get()) except: folder_name = extract_json_data(json_file_path, "publisherID") - else: - try: - folder_name = extract_json_data(json_file_path, self.settings_tab.folder_options.get()) - except: - folder_name = extract_json_data(json_file_path, "publisherID") if mod_type == "mod": path_folder = os.path.join(destination_folder, "mods")