This commit is contained in:
faroukbmiled 2023-09-20 17:59:00 +01:00
parent 52678c1912
commit 478d2a6652
3 changed files with 34 additions and 33 deletions

View File

@ -1,4 +1,4 @@
import src.shared_vars as shared_vars import src.shared_vars as main_app
if __name__ == "__main__": if __name__ == "__main__":
shared_vars.app.mainloop() main_app.app.mainloop()

View File

@ -1,7 +1,8 @@
from src.imports import * from src.imports import *
from src.helpers import * from src.helpers import *
import src.shared_vars as shared import src.shared_vars as main_app
class LibraryTab(ctk.CTkScrollableFrame): class LibraryTab(ctk.CTkScrollableFrame):
def __init__(self, master, **kwargs): def __init__(self, master, **kwargs):
@ -217,7 +218,7 @@ class LibraryTab(ctk.CTkScrollableFrame):
curr_folder_name = zone_path.parent.name curr_folder_name = zone_path.parent.name
workshop_id = extract_json_data(json_path, "PublisherID") workshop_id = extract_json_data(json_path, "PublisherID")
name = extract_json_data(json_path, "Title").replace(">", "").replace("^", "") name = re.sub(r'\^\w+', '', extract_json_data(json_path, "Title"))
name = name[:45] + "..." if len(name) > 45 else name name = name[:45] + "..." if len(name) > 45 else name
item_type = extract_json_data(json_path, "Type") item_type = extract_json_data(json_path, "Type")
folder_name = extract_json_data(json_path, "FolderName") folder_name = extract_json_data(json_path, "FolderName")
@ -377,8 +378,8 @@ class LibraryTab(ctk.CTkScrollableFrame):
self.added_items.clear() self.added_items.clear()
self.added_folders.clear() self.added_folders.clear()
self.ids_added.clear() self.ids_added.clear()
status = self.load_items(shared.app.edit_destination_folder.get().strip()) status = self.load_items(main_app.app.edit_destination_folder.get().strip())
shared.app.title(f"BOIII Workshop Downloader - Library ➜ {status}") main_app.app.title(f"BOIII Workshop Downloader - Library ➜ {status}")
def view_item(self, workshop_id): def view_item(self, workshop_id):
url = f"https://steamcommunity.com/sharedfiles/filedetails/?id={workshop_id}" url = f"https://steamcommunity.com/sharedfiles/filedetails/?id={workshop_id}"
@ -499,13 +500,13 @@ class LibraryTab(ctk.CTkScrollableFrame):
if check_item_date(down_date, date_updated): if check_item_date(down_date, date_updated):
if show_message("There is an update.", "Press download to redownload!", icon="info", _return=True, option_1="No", option_2="Download"): if show_message("There is an update.", "Press download to redownload!", icon="info", _return=True, option_1="No", option_2="Download"):
if shared.app.is_downloading: if main_app.app.is_downloading:
show_message("Error", "Please wait for the current download to finish or stop it then restart.", icon="cancel") show_message("Error", "Please wait for the current download to finish or stop it then restart.", icon="cancel")
return return
shared.app.edit_workshop_id.delete(0, "end") main_app.app.edit_workshop_id.delete(0, "end")
shared.app.edit_workshop_id.insert(0, workshop_id) main_app.app.edit_workshop_id.insert(0, workshop_id)
shared.app.main_button_event() main_app.app.main_button_event()
shared.app.download_map(update=True) main_app.app.download_map(update=True)
top.destroy() top.destroy()
return return
else: else:
@ -612,10 +613,10 @@ class LibraryTab(ctk.CTkScrollableFrame):
def items_update_message(self, to_update_len): def items_update_message(self, to_update_len):
def main_thread(): def main_thread():
if show_message(f"{to_update_len} Item updates available", f"{to_update_len} Workshop Items have an update, Would you like to open the item updater window?", icon="info", _return=True): if show_message(f"{to_update_len} Item updates available", f"{to_update_len} Workshop Items have an update, Would you like to open the item updater window?", icon="info", _return=True):
shared.app.after(1, self.update_items_window) main_app.app.after(1, self.update_items_window)
else: else:
return return
shared.app.after(0, main_thread) main_app.app.after(0, main_thread)
self.update_button.configure(state="normal", width=65, height=20) self.update_button.configure(state="normal", width=65, height=20)
self.update_tooltip.configure(message='Check items for updates') self.update_tooltip.configure(message='Check items for updates')
return return
@ -744,25 +745,25 @@ class LibraryTab(ctk.CTkScrollableFrame):
def update_btn_fun(): def update_btn_fun():
if len(selected_id_list) == 1: if len(selected_id_list) == 1:
if shared.app.is_downloading: if main_app.app.is_downloading:
show_message("Error", "Please wait for the current download to finish or stop it then start.", icon="cancel") show_message("Error", "Please wait for the current download to finish or stop it then start.", icon="cancel")
return return
shared.app.edit_workshop_id.delete(0, "end") main_app.app.edit_workshop_id.delete(0, "end")
shared.app.edit_workshop_id.insert(0, selected_id_list[0]) main_app.app.edit_workshop_id.insert(0, selected_id_list[0])
shared.app.main_button_event() main_app.app.main_button_event()
shared.app.download_map(update=True) main_app.app.download_map(update=True)
top.destroy() top.destroy()
return return
elif len(selected_id_list) > 1: elif len(selected_id_list) > 1:
if shared.app.is_downloading: if main_app.app.is_downloading:
show_message("Error", "Please wait for the current download to finish or stop it then start.", icon="cancel") show_message("Error", "Please wait for the current download to finish or stop it then start.", icon="cancel")
return return
comma_separated_ids = ",".join(selected_id_list) comma_separated_ids = ",".join(selected_id_list)
shared.app.queuetextarea.delete("1.0", "end") main_app.app.queuetextarea.delete("1.0", "end")
shared.app.queuetextarea.insert("1.0", comma_separated_ids) main_app.app.queuetextarea.insert("1.0", comma_separated_ids)
shared.app.queue_button_event() main_app.app.queue_button_event()
shared.app.download_map(update=True) main_app.app.download_map(update=True)
top.destroy() top.destroy()
return return

View File

@ -2,7 +2,7 @@ from src.update_window import check_for_updates_func
from src.imports import * from src.imports import *
from src.helpers import * from src.helpers import *
import src.shared_vars as shared import src.shared_vars as main_app
class SettingsTab(ctk.CTkFrame): class SettingsTab(ctk.CTkFrame):
@ -549,18 +549,18 @@ class SettingsTab(ctk.CTkFrame):
mod_type = extract_json_data(json_file_path, "Type") mod_type = extract_json_data(json_file_path, "Type")
items_file = os.path.join(application_path, LIBRARY_FILE) items_file = os.path.join(application_path, LIBRARY_FILE)
if shared.app.library_tab.item_exists_in_file(items_file, workshop_id): if main_app.app.library_tab.item_exists_in_file(items_file, workshop_id):
get_folder_name = shared.app.library_tab.get_item_by_id(items_file, workshop_id, return_option="folder_name") get_folder_name = main_app.app.library_tab.get_item_by_id(items_file, workshop_id, return_option="folder_name")
if get_folder_name: if get_folder_name:
folder_name = get_folder_name folder_name = get_folder_name
else: else:
try: try:
folder_name = extract_json_data(json_file_path, shared.app.settings_tab.folder_options.get()) folder_name = extract_json_data(json_file_path, main_app.app.settings_tab.folder_options.get())
except: except:
folder_name = extract_json_data(json_file_path, "publisherID") folder_name = extract_json_data(json_file_path, "publisherID")
else: else:
try: try:
folder_name = extract_json_data(json_file_path, shared.app.settings_tab.folder_options.get()) folder_name = extract_json_data(json_file_path, main_app.app.settings_tab.folder_options.get())
except: except:
folder_name = extract_json_data(json_file_path, "publisherID") folder_name = extract_json_data(json_file_path, "publisherID")
@ -586,7 +586,7 @@ class SettingsTab(ctk.CTkFrame):
remove_tree(os.path.join(map_folder, workshop_id)) remove_tree(os.path.join(map_folder, workshop_id))
if subfolders: if subfolders:
shared.app.show_complete_message(message=f"All items were moved\nYou can run the game now!\nPS: You have to restart the game\n(pressing launch will launch/restarts)") main_app.app.show_complete_message(message=f"All items were moved\nYou can run the game now!\nPS: You have to restart the game\n(pressing launch will launch/restarts)")
finally: finally:
if cut_var.get(): if cut_var.get():
@ -604,18 +604,18 @@ class SettingsTab(ctk.CTkFrame):
progress_color = get_button_state_colors(check_custom_theme(check_config("theme", fallback="boiiiwd_theme.json")), "progress_bar_fill_color") progress_color = get_button_state_colors(check_custom_theme(check_config("theme", fallback="boiiiwd_theme.json")), "progress_bar_fill_color")
progress_bar.configure(progress_color=progress_color) progress_bar.configure(progress_color=progress_color)
steam_folder_entry.insert(1, check_config("steam_folder", "")) steam_folder_entry.insert(1, check_config("steam_folder", ""))
boiii_folder_entry.insert(1, shared.app.edit_destination_folder.get()) boiii_folder_entry.insert(1, main_app.app.edit_destination_folder.get())
button_BOIII_browse.configure(command=open_BOIII_browser) button_BOIII_browse.configure(command=open_BOIII_browser)
button_steam_browse.configure(command=open_steam_browser) button_steam_browse.configure(command=open_steam_browser)
copy_button.configure(command=start_copy_operation) copy_button.configure(command=start_copy_operation)
cut_check.configure(command = lambda: check_status(cut_var, copy_var)) cut_check.configure(command = lambda: check_status(cut_var, copy_var))
copy_check.configure(command = lambda: check_status(copy_var, cut_var)) copy_check.configure(command = lambda: check_status(copy_var, cut_var))
shared.app.create_context_menu(steam_folder_entry) main_app.app.create_context_menu(steam_folder_entry)
shared.app.create_context_menu(boiii_folder_entry) main_app.app.create_context_menu(boiii_folder_entry)
copy_var.set(True) copy_var.set(True)
progress_bar.set(0) progress_bar.set(0)
except Exception as e: except Exception as e:
show_message("Error", f"{e}", icon="cancel") show_message("Error", f"{e}", icon="cancel")
shared.app.after(0, main_thread) main_app.app.after(0, main_thread)