Merge branch 'refactored' of https://github.com/faroukbmiled/BOIIIWD into refactored
This commit is contained in:
commit
ce299aefcf
@ -222,9 +222,8 @@ class LibraryTab(ctk.CTkScrollableFrame):
|
|||||||
for zone_path in folder_path.glob("**/zone"):
|
for zone_path in folder_path.glob("**/zone"):
|
||||||
json_path = zone_path / "workshop.json"
|
json_path = zone_path / "workshop.json"
|
||||||
if json_path.exists():
|
if json_path.exists():
|
||||||
# current folder name
|
|
||||||
curr_folder_name = zone_path.parent.name
|
|
||||||
|
|
||||||
|
curr_folder_name = zone_path.parent.name
|
||||||
workshop_id = extract_json_data(json_path, "PublisherID") or "None"
|
workshop_id = extract_json_data(json_path, "PublisherID") or "None"
|
||||||
name = re.sub(r'\^\w+', '', extract_json_data(json_path, "Title")) or "None"
|
name = re.sub(r'\^\w+', '', extract_json_data(json_path, "Title")) or "None"
|
||||||
name = name[:45] + "..." if len(name) > 45 else name
|
name = name[:45] + "..." if len(name) > 45 else name
|
||||||
@ -424,17 +423,21 @@ class LibraryTab(ctk.CTkScrollableFrame):
|
|||||||
def show_map_thread():
|
def show_map_thread():
|
||||||
workshop_id = workshop
|
workshop_id = workshop
|
||||||
online = if_internet_available("return")
|
online = if_internet_available("return")
|
||||||
|
valid_id = None
|
||||||
|
|
||||||
if not workshop_id.isdigit():
|
if not workshop_id.isdigit():
|
||||||
try:
|
try:
|
||||||
if extract_workshop_id(workshop_id).strip().isdigit():
|
if extract_workshop_id(workshop_id).strip().isdigit():
|
||||||
workshop_id = extract_workshop_id(workshop_id).strip()
|
workshop_id = extract_workshop_id(workshop_id).strip()
|
||||||
else:
|
else:
|
||||||
show_message("Warning", "Not a valid Workshop ID.")
|
raise
|
||||||
except:
|
except:
|
||||||
show_message("Warning", "Not a valid Workshop ID.")
|
valid_id = False
|
||||||
return
|
# show_message("Warning", "Not a valid Workshop ID.")
|
||||||
if online:
|
for button_view in self.button_view_list:
|
||||||
|
button_view.configure(state="normal")
|
||||||
|
# return
|
||||||
|
if online and valid_id!=False:
|
||||||
try:
|
try:
|
||||||
url = f"https://steamcommunity.com/sharedfiles/filedetails/?id={workshop_id}"
|
url = f"https://steamcommunity.com/sharedfiles/filedetails/?id={workshop_id}"
|
||||||
response = requests.get(url)
|
response = requests.get(url)
|
||||||
@ -463,7 +466,7 @@ class LibraryTab(ctk.CTkScrollableFrame):
|
|||||||
stars_div = soup.find("div", class_="fileRatingDetails")
|
stars_div = soup.find("div", class_="fileRatingDetails")
|
||||||
starts = stars_div.find("img")["src"]
|
starts = stars_div.find("img")["src"]
|
||||||
except:
|
except:
|
||||||
show_message("Warning", "Not a valid Workshop ID\nCouldn't get information.")
|
show_message("Warning", "Couldn't get information.")
|
||||||
for button_view in self.button_view_list:
|
for button_view in self.button_view_list:
|
||||||
button_view.configure(state="normal")
|
button_view.configure(state="normal")
|
||||||
return
|
return
|
||||||
@ -495,7 +498,7 @@ class LibraryTab(ctk.CTkScrollableFrame):
|
|||||||
url, workshop_id, invalid_warn, folder)
|
url, workshop_id, invalid_warn, folder)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
show_message("Error", f"Failed to fetch map information.\nError: {e}", icon="cancel")
|
show_message("Error", f"Failed to fetch information.\nError: {e}", icon="cancel")
|
||||||
for button_view in self.button_view_list:
|
for button_view in self.button_view_list:
|
||||||
button_view.configure(state="normal")
|
button_view.configure(state="normal")
|
||||||
return
|
return
|
||||||
@ -539,7 +542,6 @@ class LibraryTab(ctk.CTkScrollableFrame):
|
|||||||
button_view.configure(state="normal")
|
button_view.configure(state="normal")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
info_thread = threading.Thread(target=show_map_thread)
|
info_thread = threading.Thread(target=show_map_thread)
|
||||||
info_thread.start()
|
info_thread.start()
|
||||||
|
|
||||||
@ -606,14 +608,20 @@ class LibraryTab(ctk.CTkScrollableFrame):
|
|||||||
name_label = ctk.CTkLabel(info_frame, text=f"Name: {map_name}")
|
name_label = ctk.CTkLabel(info_frame, text=f"Name: {map_name}")
|
||||||
name_label.grid(row=0, column=0, columnspan=2, sticky="w", padx=20, pady=5)
|
name_label.grid(row=0, column=0, columnspan=2, sticky="w", padx=20, pady=5)
|
||||||
|
|
||||||
|
id_label = ctk.CTkLabel(info_frame, text=f"ID: {workshop_id}")
|
||||||
|
id_label.grid(row=1, column=0, columnspan=2, sticky="w", padx=20, pady=5)
|
||||||
|
|
||||||
|
folder_name = ctk.CTkLabel(info_frame, text=f"Folder: {os.path.basename(folder)}")
|
||||||
|
folder_name.grid(row=1, column=1, columnspan=2, sticky="w", padx=20, pady=5)
|
||||||
|
|
||||||
type_label = ctk.CTkLabel(info_frame, text=f"Type: {map_mod_type}")
|
type_label = ctk.CTkLabel(info_frame, text=f"Type: {map_mod_type}")
|
||||||
type_label.grid(row=1, column=0, columnspan=2, sticky="w", padx=20, pady=5)
|
type_label.grid(row=2, column=0, columnspan=2, sticky="w", padx=20, pady=5)
|
||||||
|
|
||||||
size_label = ctk.CTkLabel(info_frame, text=f"{size_text} {map_size}")
|
size_label = ctk.CTkLabel(info_frame, text=f"{size_text} {map_size}")
|
||||||
size_label.grid(row=2, column=0, columnspan=2, sticky="w", padx=20, pady=5)
|
size_label.grid(row=3, column=0, columnspan=2, sticky="w", padx=20, pady=5)
|
||||||
|
|
||||||
date_created_label = ctk.CTkLabel(info_frame, text=f"Posted: {date_created}")
|
date_created_label = ctk.CTkLabel(info_frame, text=f"Posted: {date_created}")
|
||||||
date_created_label.grid(row=3, column=0, columnspan=2, sticky="w", padx=20, pady=5)
|
date_created_label.grid(row=4, column=0, columnspan=2, sticky="w", padx=20, pady=5)
|
||||||
|
|
||||||
if date_updated != "Not updated" and date_updated != "Offline":
|
if date_updated != "Not updated" and date_updated != "Offline":
|
||||||
date_updated_label = ctk.CTkLabel(info_frame, text=f"Updated: {date_updated} 🔗")
|
date_updated_label = ctk.CTkLabel(info_frame, text=f"Updated: {date_updated} 🔗")
|
||||||
@ -623,13 +631,10 @@ class LibraryTab(ctk.CTkScrollableFrame):
|
|||||||
webbrowser.open(f"https://steamcommunity.com/sharedfiles/filedetails/changelog/{workshop_id}"))
|
webbrowser.open(f"https://steamcommunity.com/sharedfiles/filedetails/changelog/{workshop_id}"))
|
||||||
else:
|
else:
|
||||||
date_updated_label = ctk.CTkLabel(info_frame, text=f"Updated: {date_updated}")
|
date_updated_label = ctk.CTkLabel(info_frame, text=f"Updated: {date_updated}")
|
||||||
date_updated_label.grid(row=4, column=0, columnspan=2, sticky="w", padx=20, pady=5)
|
|
||||||
|
|
||||||
date_updated_label = ctk.CTkLabel(info_frame, text=f"Downloaded at: {down_date}")
|
|
||||||
date_updated_label.grid(row=5, column=0, columnspan=2, sticky="w", padx=20, pady=5)
|
date_updated_label.grid(row=5, column=0, columnspan=2, sticky="w", padx=20, pady=5)
|
||||||
|
|
||||||
folder_name = ctk.CTkLabel(info_frame, text=f"Folder name: {os.path.basename(folder)}")
|
date_updated_label = ctk.CTkLabel(info_frame, text=f"Downloaded at: {down_date}")
|
||||||
folder_name.grid(row=6, column=0, columnspan=2, sticky="w", padx=20, pady=5)
|
date_updated_label.grid(row=6, column=0, columnspan=2, sticky="w", padx=20, pady=5)
|
||||||
|
|
||||||
stars_image_label = ctk.CTkLabel(stars_frame)
|
stars_image_label = ctk.CTkLabel(stars_frame)
|
||||||
stars_width, stars_height = stars_image_size
|
stars_width, stars_height = stars_image_size
|
||||||
@ -643,7 +648,7 @@ class LibraryTab(ctk.CTkScrollableFrame):
|
|||||||
|
|
||||||
image_label = ctk.CTkLabel(image_frame)
|
image_label = ctk.CTkLabel(image_frame)
|
||||||
width, height = image_size
|
width, height = image_size
|
||||||
# preview image is too big if offlinr, // to round floats
|
# preview image is too big if offline, // to round floats
|
||||||
if width > 1000 or height > 1000:
|
if width > 1000 or height > 1000:
|
||||||
width = width // 2
|
width = width // 2
|
||||||
height = height // 2
|
height = height // 2
|
||||||
@ -653,20 +658,25 @@ class LibraryTab(ctk.CTkScrollableFrame):
|
|||||||
image_label.pack(expand=True, fill="both", padx=(10, 20), pady=(10, 10))
|
image_label.pack(expand=True, fill="both", padx=(10, 20), pady=(10, 10))
|
||||||
|
|
||||||
# Buttons
|
# Buttons
|
||||||
close_button = ctk.CTkButton(buttons_frame, text="View", command=view_map_mod, width=130)
|
view_button = ctk.CTkButton(buttons_frame, text="View", command=view_map_mod, width=130)
|
||||||
close_button.grid(row=0, column=0, padx=(20, 20), pady=(10, 10), sticky="n")
|
view_button.grid(row=0, column=0, padx=(20, 20), pady=(10, 10), sticky="n")
|
||||||
|
view_button_tooltip = CTkToolTip(view_button, message="View Workshop", topmost=True)
|
||||||
|
|
||||||
update_btn = ctk.CTkButton(buttons_frame, text="Update", command=check_for_updates, width=130)
|
update_btn = ctk.CTkButton(buttons_frame, text="Update", command=check_for_updates, width=130)
|
||||||
update_btn.grid(row=0, column=1, padx=(10, 20), pady=(10, 10), sticky="n")
|
update_btn.grid(row=0, column=1, padx=(10, 20), pady=(10, 10), sticky="n")
|
||||||
update_btn_tooltip = CTkToolTip(update_btn, message="Checks and installs updates of the current selected item (redownload!)", topmost=True)
|
update_btn_tooltip = CTkToolTip(update_btn, message="Checks and installs updates of the current selected item (redownload!)", topmost=True)
|
||||||
|
|
||||||
view_button = ctk.CTkButton(buttons_frame, text="Close", command=close_window, width=130)
|
close_button = ctk.CTkButton(buttons_frame, text="Close", command=close_window, width=130)
|
||||||
view_button.grid(row=0, column=2, padx=(10, 20), pady=(10, 10), sticky="n")
|
close_button.grid(row=0, column=2, padx=(10, 20), pady=(10, 10), sticky="n")
|
||||||
|
|
||||||
if invalid_warn:
|
if invalid_warn:
|
||||||
update_btn.configure(text="Update", state="disabled")
|
update_btn.configure(text="Update", state="disabled")
|
||||||
update_btn_tooltip.configure(message="Disabled due to item being blocked or duplicated")
|
update_btn_tooltip.configure(message="Disabled due to item being blocked or duplicated")
|
||||||
|
|
||||||
|
if not workshop_id.isdigit():
|
||||||
|
view_button.configure(text="View", state="disabled")
|
||||||
|
view_button_tooltip.configure(message="Not a valid Workshop ID")
|
||||||
|
|
||||||
top.grid_rowconfigure(0, weight=0)
|
top.grid_rowconfigure(0, weight=0)
|
||||||
top.grid_rowconfigure(1, weight=0)
|
top.grid_rowconfigure(1, weight=0)
|
||||||
top.grid_rowconfigure(2, weight=1)
|
top.grid_rowconfigure(2, weight=1)
|
||||||
|
Loading…
Reference in New Issue
Block a user