mirror of
https://github.com/csd4ni3l/browser.git
synced 2026-01-01 12:13:43 +01:00
Update dependencies, run.py file, preloading, update build script to newest version
This commit is contained in:
44
run.py
44
run.py
@@ -3,21 +3,27 @@ os.environ['SSL_CERT_FILE'] = certifi.where() # Fix SSL not working
|
||||
|
||||
import pyglet
|
||||
|
||||
pyglet.options['shadow_window'] = False # Fix double window issue on Wayland
|
||||
pyglet.options.debug_gl = False
|
||||
|
||||
import logging, datetime, os, json, sys, arcade
|
||||
import logging, datetime, os, json, sys, arcade, platform
|
||||
|
||||
# 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.constants import log_dir, menu_background_color
|
||||
|
||||
from menus.main import Main
|
||||
from arcade.experimental.controller_window import ControllerWindow
|
||||
|
||||
sys.excepthook = on_exception
|
||||
|
||||
pyglet.resource.path.append(os.getcwd())
|
||||
pyglet.font.add_directory('./assets/fonts')
|
||||
|
||||
if not os.path.exists(log_dir):
|
||||
if not log_dir in os.listdir():
|
||||
os.makedirs(log_dir)
|
||||
|
||||
if not os.path.exists("html_cache"):
|
||||
@@ -25,7 +31,6 @@ if not os.path.exists("html_cache"):
|
||||
|
||||
if not os.path.exists("css_cache"):
|
||||
os.makedirs("css_cache")
|
||||
|
||||
while len(os.listdir(log_dir)) >= 5:
|
||||
files = [(file, os.path.getctime(os.path.join(log_dir, file))) for file in os.listdir(log_dir)]
|
||||
oldest_file = sorted(files, key=lambda x: x[1])[0][0]
|
||||
@@ -50,6 +55,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 +69,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,12 +94,19 @@ else:
|
||||
with open("settings.json", "w") as file:
|
||||
file.write(json.dumps(settings))
|
||||
|
||||
window = arcade.Window(width=resolution[0], height=resolution[1], title='csd4ni3l-browser', samples=antialiasing, antialiasing=antialiasing > 0, fullscreen=fullscreen, vsync=vsync, resizable=True, style=style)
|
||||
try:
|
||||
window = ControllerWindow(width=resolution[0], height=resolution[1], title='GameName', 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='GameName', samples=antialiasing, antialiasing=antialiasing > 0, fullscreen=fullscreen, vsync=vsync, resizable=False, style=style, visible=False)
|
||||
|
||||
if vsync:
|
||||
window.set_vsync(True)
|
||||
display_mode = window.display.get_default_screen().get_mode()
|
||||
refresh_rate = display_mode.rate
|
||||
if display_mode:
|
||||
refresh_rate = display_mode.rate
|
||||
else:
|
||||
refresh_rate = 60
|
||||
window.set_update_rate(1 / refresh_rate)
|
||||
window.set_draw_rate(1 / refresh_rate)
|
||||
elif not fps_limit == 0:
|
||||
@@ -96,6 +123,9 @@ main = Main()
|
||||
|
||||
window.show_view(main)
|
||||
|
||||
# Make window visible after all setup is complete (helps prevent double window on Wayland)
|
||||
window.set_visible(True)
|
||||
|
||||
logging.debug('Game started.')
|
||||
|
||||
arcade.run()
|
||||
|
||||
Reference in New Issue
Block a user