update everything to newest template version (new build script, etc)

This commit is contained in:
csd4ni3l
2025-12-13 16:03:51 +01:00
parent c4718d86ae
commit 59ef40168f
7 changed files with 297 additions and 183 deletions

39
run.py
View File

@@ -6,22 +6,28 @@ os.environ['SSL_CERT_FILE'] = certifi.where() # Fix SSL not working and download
import pyglet
pyglet.options['shadow_window'] = False # Fix double window issue on Wayland
pyglet.options.debug_gl = False
max_texture_size = pyglet.image.get_max_texture_size()
import logging, datetime, json, sys, arcade
import logging, datetime, os, json, sys, arcade, platform
arcade.ArcadeContext.atlas_size = (max_texture_size, max_texture_size)
# Set up paths BEFORE importing modules that load assets
script_dir = os.path.dirname(os.path.abspath(__file__))
pyglet.resource.path.append(script_dir)
pyglet.font.add_directory(os.path.join(script_dir, 'assets', 'fonts'))
from utils.utils import get_closest_resolution, print_debug_info, on_exception
from utils.acoustid_metadata import get_fpcalc_path
from utils.constants import log_dir, menu_background_color
from menus.main import Main
from utils.preload import theme_sound # needed for preload
from arcade.experimental.controller_window import ControllerWindow
sys.excepthook = on_exception
pyglet.resource.path.append(os.getcwd())
pyglet.font.add_directory(os.path.join(os.getcwd(), 'assets', 'fonts'))
__builtins__.print = lambda *args, **kwargs: logging.debug(" ".join(map(str, args)))
if not log_dir in os.listdir():
os.makedirs(log_dir)
@@ -35,7 +41,7 @@ timestamp = datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
log_filename = f"debug_{timestamp}.log"
logging.basicConfig(filename=f'{os.path.join(log_dir, log_filename)}', format='%(asctime)s %(name)s %(levelname)s: %(message)s', level=logging.DEBUG)
for logger_name_to_disable in ['arcade', "watchdog", "PIL"]:
for logger_name_to_disable in ['arcade']:
logging.getLogger(logger_name_to_disable).propagate = False
logging.getLogger(logger_name_to_disable).disabled = True
@@ -50,6 +56,13 @@ if os.path.exists('settings.json'):
else:
antialiasing = 0
# Wayland workaround (can be overridden with environment variable)
if (platform.system() == "Linux" and
os.environ.get("WAYLAND_DISPLAY") and
not os.environ.get("ARCADE_FORCE_MSAA")):
logging.info("Wayland detected - disabling MSAA (set ARCADE_FORCE_MSAA=1 to override)")
antialiasing = 0
fullscreen = settings['window_mode'] == 'Fullscreen'
style = arcade.Window.WINDOW_STYLE_BORDERLESS if settings['window_mode'] == 'borderless' else arcade.Window.WINDOW_STYLE_DEFAULT
vsync = settings['vsync']
@@ -57,6 +70,14 @@ if os.path.exists('settings.json'):
else:
resolution = get_closest_resolution()
antialiasing = 4
# Wayland workaround (can be overridden with environment variable)
if (platform.system() == "Linux" and
os.environ.get("WAYLAND_DISPLAY") and
not os.environ.get("ARCADE_FORCE_MSAA")):
logging.info("Wayland detected - disabling MSAA (set ARCADE_FORCE_MSAA=1 to override)")
antialiasing = 0
fullscreen = False
style = arcade.Window.WINDOW_STYLE_DEFAULT
vsync = True
@@ -74,7 +95,11 @@ else:
with open("settings.json", "w", encoding="utf-8") as file:
file.write(json.dumps(settings))
window = ControllerWindow(width=resolution[0], height=resolution[1], title='Music Player', samples=antialiasing, antialiasing=antialiasing > 0, fullscreen=fullscreen, vsync=vsync, resizable=False, style=style)
try:
window = ControllerWindow(width=resolution[0], height=resolution[1], title='MusicPlayer', samples=antialiasing, antialiasing=antialiasing > 0, fullscreen=fullscreen, vsync=vsync, resizable=False, style=style, visible=False)
except (FileNotFoundError, PermissionError) as e:
logging.warning(f"Controller support unavailable: {e}. Falling back to regular window.")
window = arcade.Window(width=resolution[0], height=resolution[1], title='MusicPlayer', samples=antialiasing, antialiasing=antialiasing > 0, fullscreen=fullscreen, vsync=vsync, resizable=False, style=style, visible=False)
if vsync:
window.set_vsync(True)
@@ -95,7 +120,6 @@ else:
arcade.set_background_color(menu_background_color)
print_debug_info()
if not pyglet.media.codecs.have_ffmpeg():
logging.debug("FFmpeg is missing, opening FFmpeg popup...")
from menus.ffmpeg_missing import FFmpegMissing
@@ -111,6 +135,9 @@ else:
window.show_view(menu)
# Make window visible after all setup is complete (helps prevent double window on Wayland)
window.set_visible(True)
logging.debug('App started.')
arcade.run()