mirror of
https://github.com/FAUSheppy/homelab_gamevault
synced 2025-12-07 15:31:36 +01:00
wip: extra files & picture scroller
This commit is contained in:
20
client.py
20
client.py
@@ -9,7 +9,7 @@ customtkinter.set_default_color_theme("blue")
|
|||||||
|
|
||||||
app = customtkinter.CTk()
|
app = customtkinter.CTk()
|
||||||
|
|
||||||
app.geometry("1000x750")
|
app.geometry("1030x750")
|
||||||
last_geometry = app.winfo_geometry()
|
last_geometry = app.winfo_geometry()
|
||||||
app.title("Test")
|
app.title("Test")
|
||||||
app.update()
|
app.update()
|
||||||
@@ -26,10 +26,16 @@ def create_navbar():
|
|||||||
def switch_to_main():
|
def switch_to_main():
|
||||||
'''Switch back to main view from details'''
|
'''Switch back to main view from details'''
|
||||||
|
|
||||||
|
global details_elements
|
||||||
|
global last_geometry
|
||||||
|
|
||||||
|
last_geometry = (0,0)
|
||||||
|
|
||||||
# destroy details elements #
|
# destroy details elements #
|
||||||
for el in details_elements:
|
for el in details_elements:
|
||||||
el.destory()
|
el.destroy()
|
||||||
|
|
||||||
|
details_elements = []
|
||||||
load_main()
|
load_main()
|
||||||
|
|
||||||
def switch_to_game_details(software):
|
def switch_to_game_details(software):
|
||||||
@@ -48,21 +54,27 @@ def load_main():
|
|||||||
create_main_window_tile(software)
|
create_main_window_tile(software)
|
||||||
|
|
||||||
# set update listener & update positions #
|
# set update listener & update positions #
|
||||||
app.bind("<Configure>", update_button_positions)
|
|
||||||
update_button_positions()
|
update_button_positions()
|
||||||
|
app.bind("<Configure>", update_button_positions)
|
||||||
|
|
||||||
def destroy_main():
|
def destroy_main():
|
||||||
'''Destroy all elements in the main view'''
|
'''Destroy all elements in the main view'''
|
||||||
|
|
||||||
|
global buttons
|
||||||
|
|
||||||
app.unbind("<Configure>")
|
app.unbind("<Configure>")
|
||||||
for b in buttons:
|
for b in buttons:
|
||||||
b.destroy()
|
b.destroy()
|
||||||
|
|
||||||
|
buttons = []
|
||||||
|
|
||||||
def load_details(app, software):
|
def load_details(app, software):
|
||||||
'''Load the details page for a software'''
|
'''Load the details page for a software'''
|
||||||
|
|
||||||
|
global details_elements
|
||||||
|
|
||||||
app.title("Lan Vault: {}".format(software.title))
|
app.title("Lan Vault: {}".format(software.title))
|
||||||
details_elements = client_details.create_details_page(app, software)
|
details_elements = client_details.create_details_page(app, software, switch_to_main)
|
||||||
|
|
||||||
def create_main_window_tile(software):
|
def create_main_window_tile(software):
|
||||||
'''Create the main window tile'''
|
'''Create the main window tile'''
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ def show_large_picture(app, path):
|
|||||||
'''Show a full-window version of the clicked picture'''
|
'''Show a full-window version of the clicked picture'''
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def create_details_page(app, software):
|
def create_details_page(app, software, backswitch_function):
|
||||||
'''Create the details page for a software and return its elements for later destruction'''
|
'''Create the details page for a software and return its elements for later destruction'''
|
||||||
|
|
||||||
elements = []
|
elements = []
|
||||||
@@ -19,10 +19,19 @@ def create_details_page(app, software):
|
|||||||
|
|
||||||
img = PIL.ImageTk.PhotoImage(img)
|
img = PIL.ImageTk.PhotoImage(img)
|
||||||
|
|
||||||
|
# navbar #
|
||||||
|
navbar = customtkinter.CTkFrame(app)
|
||||||
|
navbar.grid(column=0, row=0)
|
||||||
|
back_button = customtkinter.CTkButton(navbar, text="Back",
|
||||||
|
command=backswitch_function)
|
||||||
|
back_button.pack(anchor="nw", side="left")
|
||||||
|
elements.append(navbar)
|
||||||
|
elements.append(back_button)
|
||||||
|
|
||||||
# thumbnail image #
|
# thumbnail image #
|
||||||
thumbnail_image = customtkinter.CTkButton(app, text="", image=img, width=500, height=700,
|
thumbnail_image = customtkinter.CTkButton(app, text="", image=img, width=500, height=700,
|
||||||
command=lambda: show_large_picture(app, path))
|
command=lambda: show_large_picture(app, path))
|
||||||
thumbnail_image.grid(column=0, row=0, padx=10, pady=10)
|
thumbnail_image.grid(column=0, row=1, padx=10, pady=10)
|
||||||
elements.append(thumbnail_image)
|
elements.append(thumbnail_image)
|
||||||
|
|
||||||
# fonts #
|
# fonts #
|
||||||
@@ -31,7 +40,8 @@ def create_details_page(app, software):
|
|||||||
|
|
||||||
# info box #
|
# info box #
|
||||||
info_frame = customtkinter.CTkFrame(app)
|
info_frame = customtkinter.CTkFrame(app)
|
||||||
info_frame.grid(column=1, row=0, sticky="ns", padx=10, pady=10)
|
info_frame.grid(column=1, row=1, sticky="ns", padx=10, pady=10)
|
||||||
|
elements.append(info_frame)
|
||||||
|
|
||||||
# title #
|
# title #
|
||||||
title = customtkinter.CTkLabel(info_frame, text=software.title, font=title_font)
|
title = customtkinter.CTkLabel(info_frame, text=software.title, font=title_font)
|
||||||
@@ -46,18 +56,32 @@ def create_details_page(app, software):
|
|||||||
elements.append(genre)
|
elements.append(genre)
|
||||||
|
|
||||||
# description #
|
# description #
|
||||||
description = customtkinter.CTkTextbox(info_frame, width=400, height=200)
|
description = customtkinter.CTkTextbox(info_frame)
|
||||||
description.insert("0.0", software.description)
|
description.insert("0.0", software.description)
|
||||||
description.pack(anchor="w", side="top", fill="both", padx=20, pady=15)
|
description.pack(anchor="w", side="top", fill="both", padx=20, pady=15)
|
||||||
elements.append(description)
|
elements.append(description)
|
||||||
|
|
||||||
|
# registry modification #
|
||||||
|
reg_mod_yes_no = "yes" if software.reg_files else "no"
|
||||||
|
reg_mod_text = "Requires Registry Modification: {}".format(reg_mod_yes_no)
|
||||||
|
reg_mod_info = customtkinter.CTkLabel(info_frame, text=reg_mod_text, padx=20)
|
||||||
|
reg_mod_info.pack(anchor="w", side="top")
|
||||||
|
elements.append(reg_mod_info)
|
||||||
|
|
||||||
# dependencies #
|
# dependencies #
|
||||||
if software.dependencies:
|
if software.dependencies:
|
||||||
dependencies_text = ",".join(software.dependencies)
|
dependencies_text = "Dependencies: " + ",".join(software.dependencies)
|
||||||
dependencies = customtkinter.CTkLabel(info_frame, text=dependencies_text)
|
dependencies = customtkinter.CTkLabel(info_frame, text=dependencies_text)
|
||||||
dependencies.pack(anchor="w", side="top", padx=20)
|
dependencies.pack(anchor="w", side="top", padx=20)
|
||||||
elements.append(dependencies)
|
elements.append(dependencies)
|
||||||
|
|
||||||
|
# extra_files #
|
||||||
|
if software.extra_files:
|
||||||
|
extra_text = "Targets extra directories: " + ",".join(set(software.extra_files.values()))
|
||||||
|
extra_text_label = customtkinter.CTkLabel(info_frame, text=extra_text)
|
||||||
|
extra_text_label.pack(anchor="w", side="top", padx=20)
|
||||||
|
elements.append(extra_text_label)
|
||||||
|
|
||||||
# buttons #
|
# buttons #
|
||||||
install_button = customtkinter.CTkButton(info_frame, text="Install",
|
install_button = customtkinter.CTkButton(info_frame, text="Install",
|
||||||
command=lambda: software.install())
|
command=lambda: software.install())
|
||||||
@@ -75,15 +99,21 @@ def create_details_page(app, software):
|
|||||||
elements.append(remove_button)
|
elements.append(remove_button)
|
||||||
|
|
||||||
# add other pictures #
|
# add other pictures #
|
||||||
i = 0
|
if software.pictures:
|
||||||
for path in software.pictures[1:]:
|
|
||||||
img = PIL.Image.open(path)
|
picture_frame = customtkinter.CTkScrollableFrame(info_frame, height=200, width=300, orientation="horizontal")
|
||||||
img = img.resize((200, 300))
|
picture_frame.pack(anchor="w", side="top", padx=10)
|
||||||
img = PIL.ImageTk.PhotoImage(img)
|
|
||||||
extra_pic_button = customtkinter.CTkButton(app, text="", image=img, width=200, height=300,
|
i = 0
|
||||||
command=lambda: show_large_picture(app, path))
|
for path in software.pictures[1:]:
|
||||||
extra_pic_button.grid(padx=10, pady=10, row=0, column=i)
|
img = PIL.Image.open(path)
|
||||||
elements.append(extra_pic_button)
|
img = img.resize((180, 180))
|
||||||
i += 1
|
img = PIL.ImageTk.PhotoImage(img)
|
||||||
|
extra_pic_button = customtkinter.CTkButton(picture_frame, text="", image=img, command=lambda: show_large_picture(app, path))
|
||||||
|
extra_pic_button.grid(padx=10, pady=10, row=0, column=i)
|
||||||
|
elements.append(extra_pic_button)
|
||||||
|
i += 1
|
||||||
|
|
||||||
|
elements.append(picture_frame)
|
||||||
|
|
||||||
return elements
|
return elements
|
||||||
|
|||||||
@@ -11,6 +11,5 @@ dependencies:
|
|||||||
- DirectX 9.0c
|
- DirectX 9.0c
|
||||||
link_only: false
|
link_only: false
|
||||||
extra_files:
|
extra_files:
|
||||||
dummy_file_1.txt: "%APP_DATA%/game_vault/"
|
dummy_file_1.txt: "%APPDATA%/game_vault/"
|
||||||
dummy_dir_1: "%APP_DATA%/game_vault/"
|
|
||||||
run_exe: "GNUFreeDink/dink.exe"
|
run_exe: "GNUFreeDink/dink.exe"
|
||||||
BIN
example_software_root/FreeDink/pictures/freedink_ingamel.jpg
Normal file
BIN
example_software_root/FreeDink/pictures/freedink_ingamel.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 33 KiB |
10
software.py
10
software.py
@@ -2,6 +2,8 @@ import yaml
|
|||||||
import os
|
import os
|
||||||
import localaction
|
import localaction
|
||||||
import zipfile
|
import zipfile
|
||||||
|
import shutil
|
||||||
|
import pathlib
|
||||||
|
|
||||||
class Software:
|
class Software:
|
||||||
|
|
||||||
@@ -84,7 +86,13 @@ class Software:
|
|||||||
print("Running installer:", installer_path)
|
print("Running installer:", installer_path)
|
||||||
localaction.run_exe(installer_path)
|
localaction.run_exe(installer_path)
|
||||||
|
|
||||||
# TODO download & install gamefiles #
|
# install gamefiles #
|
||||||
|
if self.extra_files:
|
||||||
|
for src, dest in self.extra_files.items():
|
||||||
|
tmp = self.backend.get(os.path.join(self.directory, "extra_files", src), self.cache_dir)
|
||||||
|
dest_dir = os.path.expandvars(dest)
|
||||||
|
os.makedirs(dest_dir, exist_ok=True)
|
||||||
|
shutil.copy(tmp, dest_dir)
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
'''Run the configured exe for this software'''
|
'''Run the configured exe for this software'''
|
||||||
|
|||||||
Reference in New Issue
Block a user