mirror of
https://github.com/FAUSheppy/homelab_gamevault
synced 2025-12-06 06:51:36 +01:00
wip: various details
This commit is contained in:
@@ -9,12 +9,13 @@ customtkinter.set_default_color_theme("blue")
|
|||||||
|
|
||||||
app = customtkinter.CTk()
|
app = customtkinter.CTk()
|
||||||
|
|
||||||
app.geometry("720x780")
|
app.geometry("1000x750")
|
||||||
last_geometry = app.winfo_geometry()
|
last_geometry = app.winfo_geometry()
|
||||||
app.title("Test")
|
app.title("Test")
|
||||||
app.update()
|
app.update()
|
||||||
|
|
||||||
buttons = []
|
buttons = []
|
||||||
|
details_elements = []
|
||||||
|
|
||||||
def create_navbar():
|
def create_navbar():
|
||||||
'''Create basic navigation bar'''
|
'''Create basic navigation bar'''
|
||||||
@@ -40,6 +41,8 @@ def switch_to_game_details(software):
|
|||||||
def load_main():
|
def load_main():
|
||||||
'''Load the main page overview'''
|
'''Load the main page overview'''
|
||||||
|
|
||||||
|
app.title("Lan Vault: Overview")
|
||||||
|
|
||||||
# create tiles from meta files #
|
# create tiles from meta files #
|
||||||
for software in db.find_all_metadata():
|
for software in db.find_all_metadata():
|
||||||
print(software.title)
|
print(software.title)
|
||||||
@@ -59,6 +62,7 @@ def destroy_main():
|
|||||||
def load_details(app, software):
|
def load_details(app, software):
|
||||||
'''Load the details page for a software'''
|
'''Load the details page for a software'''
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
def create_main_window_tile(software):
|
def create_main_window_tile(software):
|
||||||
|
|||||||
@@ -16,52 +16,64 @@ def create_details_page(app, software):
|
|||||||
img = PIL.ImageTk.PhotoImage(img)
|
img = PIL.ImageTk.PhotoImage(img)
|
||||||
|
|
||||||
# thumbnail image #
|
# thumbnail image #
|
||||||
thumbnail_image = customtkinter.CTkButton(app, text="", image=img, width=200, height=300,
|
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.pack()
|
thumbnail_image.grid(column=0, row=0, padx=10, pady=10)
|
||||||
elements.append(thumbnail_image)
|
elements.append(thumbnail_image)
|
||||||
|
|
||||||
|
# fonts #
|
||||||
|
title_font = customtkinter.CTkFont(family="Helvetica", size=29, weight="bold")
|
||||||
|
genre_font = customtkinter.CTkFont(family="Helvetica", size=14, slant="italic")
|
||||||
|
|
||||||
|
# info box #
|
||||||
|
info_frame = customtkinter.CTkFrame(app)
|
||||||
|
info_frame.grid(column=1, row=0, sticky="ns", padx=10, pady=10)
|
||||||
|
|
||||||
# title #
|
# title #
|
||||||
title = customtkinter.CTkLabel(app, textvariable=software.title)
|
title = customtkinter.CTkLabel(info_frame, text=software.title, font=title_font)
|
||||||
title.pack()
|
title.pack(anchor="w", side="top", padx=20, pady=10)
|
||||||
|
print("Title:", software.title)
|
||||||
elements.append(title)
|
elements.append(title)
|
||||||
|
|
||||||
# genre #
|
# genre #
|
||||||
genre = customtkinter.CTkLabel(app, textvariable=software.genre)
|
genre_text = "Genre: {}".format(software.genre)
|
||||||
genre.pack()
|
genre = customtkinter.CTkLabel(info_frame, text=genre_text, padx=20, font=genre_font)
|
||||||
|
genre.pack(anchor="w", side="top")
|
||||||
elements.append(genre)
|
elements.append(genre)
|
||||||
|
|
||||||
# description #
|
# description #
|
||||||
description = customtkinter.CTkTextbox(app)
|
description = customtkinter.CTkTextbox(info_frame, width=400, height=200)
|
||||||
description.insert("0.0", software.description)
|
description.insert("0.0", software.description)
|
||||||
description.pack()
|
description.pack(anchor="w", side="top", fill="both", padx=20, pady=15)
|
||||||
elements.append(description)
|
elements.append(description)
|
||||||
|
|
||||||
# dependencies #
|
# dependencies #
|
||||||
dependencies = customtkinter.CTkTextbox(app)
|
dependencies_text = ",".join(software.dependencies)
|
||||||
dependencies.insert("0.0", str(software.dependencies))
|
dependencies = customtkinter.CTkLabel(info_frame, text=dependencies_text)
|
||||||
description.pack()
|
dependencies.pack(anchor="w", side="top", padx=20)
|
||||||
elements.append(description)
|
elements.append(dependencies)
|
||||||
|
|
||||||
# buttons #
|
# buttons #
|
||||||
install_button = customtkinter.CTkButton(app, text="Install",
|
install_button = customtkinter.CTkButton(info_frame, text="Install",
|
||||||
command=lambda: software.install(software))
|
command=lambda: software.install(software))
|
||||||
remove_button = customtkinter.CTkButton(app, text="Remove",
|
remove_button = customtkinter.CTkButton(info_frame, text="Remove",
|
||||||
command=lambda: software.remove(software))
|
command=lambda: software.remove(software))
|
||||||
|
|
||||||
install_button.pack()
|
install_button.pack(padx=20, pady=30, anchor="sw", side="left")
|
||||||
remove_button.pack()
|
remove_button.pack(padx=20, pady=30, anchor="sw", side="left")
|
||||||
elements.append(install_button)
|
elements.append(install_button)
|
||||||
elements.append(remove_button)
|
elements.append(remove_button)
|
||||||
|
|
||||||
# add other pictures #
|
# add other pictures #
|
||||||
|
i = 0
|
||||||
for path in software.pictures[1:]:
|
for path in software.pictures[1:]:
|
||||||
img = PIL.Image.open(software.get_thumbnail())
|
img = PIL.Image.open(software.get_thumbnail())
|
||||||
img = img.resize((200, 300))
|
img = img.resize((200, 300))
|
||||||
img = PIL.ImageTk.PhotoImage(img)
|
img = PIL.ImageTk.PhotoImage(img)
|
||||||
extra_pic_button = customtkinter.CTkButton(app, text="", image=img, width=200, height=300,
|
extra_pic_button = customtkinter.CTkButton(app, text="", image=img, width=200, height=300,
|
||||||
command=lambda: show_large_picture(app, path))
|
command=lambda: show_large_picture(app, path))
|
||||||
extra_pic_button.pack()
|
extra_pic_button.grid(padx=10, pady=10, row=0, column=i)
|
||||||
elements.append(extra_pic_button)
|
elements.append(extra_pic_button)
|
||||||
|
i += 1
|
||||||
|
|
||||||
return elements
|
return elements
|
||||||
|
|||||||
@@ -30,11 +30,14 @@ class DataBackend:
|
|||||||
class LocalFS(DataBackend):
|
class LocalFS(DataBackend):
|
||||||
|
|
||||||
def get(self, path):
|
def get(self, path):
|
||||||
|
|
||||||
fullpath = os.path.join(self.remote_root_dir, path)
|
fullpath = os.path.join(self.remote_root_dir, path)
|
||||||
with open(fullpath, "rb") as f:
|
with open(fullpath, "rb") as f:
|
||||||
target = os.path.join(self.cache_dir, os.path.basename(path))
|
target = os.path.join(self.cache_dir, os.path.basename(path))
|
||||||
with open(target, "wb") as ft:
|
with open(target, "wb") as ft:
|
||||||
ft.write(f.read())
|
ft.write(f.read())
|
||||||
|
|
||||||
|
return target
|
||||||
|
|
||||||
def list(self, path):
|
def list(self, path):
|
||||||
fullpath = os.path.join(self.remote_root_dir, path)
|
fullpath = os.path.join(self.remote_root_dir, path)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
genre: RPG
|
genre: RPG
|
||||||
title: GNU FreeDink
|
title: GNU FreeDink
|
||||||
description: |
|
description: >
|
||||||
Free GNU RPG from 1993.
|
Free GNU RPG from 1993.
|
||||||
The game centers on Dink, a pig farmer-turned-hero who embarks on various quests throughout his world.
|
The game centers on Dink, a pig farmer-turned-hero who embarks on various quests throughout his world.
|
||||||
The game features isometric, Diablo-like gameplay,[3] including weapons, items, and magic.
|
The game features isometric, Diablo-like gameplay,[3] including weapons, items, and magic.
|
||||||
The game has a satirical off-color slant, including everything from a fiercely abusive uncle
|
The game has a satirical off-color slant, including everything from a fiercely abusive uncle
|
||||||
|
|||||||
24
software.py
24
software.py
@@ -1,22 +1,24 @@
|
|||||||
import yaml
|
import yaml
|
||||||
import os
|
import os
|
||||||
|
import localaction
|
||||||
|
|
||||||
class Software:
|
class Software:
|
||||||
|
|
||||||
def __init__(self, directory):
|
def __init__(self, directory, backend):
|
||||||
|
|
||||||
if os.path.isfile(directory) and directory.endswith("meta.yaml"):
|
if os.path.isfile(directory) and directory.endswith("meta.yaml"):
|
||||||
directory = os.path.dirname(directory)
|
directory = os.path.dirname(directory)
|
||||||
|
|
||||||
self.directory = directory
|
self.directory = directory
|
||||||
self._load_from_yaml()
|
self._load_from_yaml()
|
||||||
|
self.backend = backend
|
||||||
|
|
||||||
def _load_from_yaml(self):
|
def _load_from_yaml(self):
|
||||||
|
|
||||||
fullpath = os.path.join(self.directory, "meta.yaml")
|
fullpath = os.path.join(self.directory, "meta.yaml")
|
||||||
self.info_file = fullpath
|
self.info_file = fullpath
|
||||||
with open(fullpath) as f:
|
with open(fullpath) as f:
|
||||||
meta = yaml.load(f)
|
meta = yaml.safe_load(f)
|
||||||
|
|
||||||
self.title = meta.get("title")
|
self.title = meta.get("title")
|
||||||
self.genre = meta.get("genre")
|
self.genre = meta.get("genre")
|
||||||
@@ -32,5 +34,23 @@ class Software:
|
|||||||
def get_thumbnail(self):
|
def get_thumbnail(self):
|
||||||
|
|
||||||
return self.pictures[0]
|
return self.pictures[0]
|
||||||
|
|
||||||
|
def _extract_to_target(self, cache_src, target):
|
||||||
|
'''Extract a cached, downloaded zip to the target location'''
|
||||||
|
|
||||||
|
def install(self):
|
||||||
|
'''Install this software from the backend'''
|
||||||
|
|
||||||
|
local_file = self.backend.get_exe_or_data():
|
||||||
|
|
||||||
|
if local_file.endswith(".exe"):
|
||||||
|
localaction.run_exe(local_file)
|
||||||
|
elif local_file.endswith(".zip"):
|
||||||
|
_extract_to_target(INSTALL_DIR)
|
||||||
|
|
||||||
|
# download registry
|
||||||
|
# install registry
|
||||||
|
# TODO dependencies #
|
||||||
|
# download gamefiles
|
||||||
|
# install gamefiles
|
||||||
|
|
||||||
Reference in New Issue
Block a user