mirror of
https://github.com/csd4ni3l/connect-the-current.git
synced 2026-01-01 04:13:41 +01:00
update utils.py and run.py to latest template
This commit is contained in:
12
run.py
12
run.py
@@ -10,7 +10,6 @@ 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
|
||||
@@ -18,6 +17,8 @@ from arcade.experimental.controller_window import ControllerWindow
|
||||
|
||||
sys.excepthook = on_exception
|
||||
|
||||
__builtins__.print = lambda *args, **kwargs: logging.debug(" ".join(map(str, args)))
|
||||
|
||||
if not log_dir in os.listdir():
|
||||
os.makedirs(log_dir)
|
||||
|
||||
@@ -73,8 +74,6 @@ else:
|
||||
fps_limit = 0
|
||||
|
||||
settings = {
|
||||
"music": True,
|
||||
"music_volume": 50,
|
||||
"resolution": f"{resolution[0]}x{resolution[1]}",
|
||||
"antialiasing": "4x MSAA",
|
||||
"window_mode": "Windowed",
|
||||
@@ -86,14 +85,11 @@ else:
|
||||
with open("settings.json", "w") as file:
|
||||
file.write(json.dumps(settings))
|
||||
|
||||
# if settings.get("music", True):
|
||||
# theme_sound.play(volume=settings.get("music_volume", 50) / 100, loop=True)
|
||||
|
||||
try:
|
||||
window = ControllerWindow(width=resolution[0], height=resolution[1], title='Connect the Current', samples=antialiasing, antialiasing=antialiasing > 0, fullscreen=fullscreen, vsync=vsync, resizable=False, style=style, visible=False)
|
||||
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='Connect the Current', samples=antialiasing, antialiasing=antialiasing > 0, fullscreen=fullscreen, vsync=vsync, resizable=False, style=style, visible=False)
|
||||
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)
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
import logging, arcade, arcade.gui, sys, traceback
|
||||
|
||||
from utils.constants import menu_background_color
|
||||
|
||||
import pyglet.info, pyglet.event
|
||||
import logging, arcade, traceback, pyglet.display
|
||||
|
||||
def dump_platform():
|
||||
import platform
|
||||
@@ -38,29 +34,6 @@ def print_debug_info():
|
||||
logging.debug('########################## DEBUG INFO ##########################')
|
||||
logging.debug('')
|
||||
|
||||
class ErrorView(arcade.gui.UIView):
|
||||
def __init__(self, message, title):
|
||||
super().__init__()
|
||||
|
||||
self.message = message
|
||||
self.title = title
|
||||
|
||||
def exit(self):
|
||||
logging.fatal('Exited with error code 1.')
|
||||
sys.exit(1)
|
||||
|
||||
def on_show_view(self):
|
||||
super().on_show_view()
|
||||
|
||||
self.window.set_caption('Connect the Current - Error')
|
||||
self.window.set_mouse_visible(True)
|
||||
self.window.set_exclusive_mouse(False)
|
||||
arcade.set_background_color(menu_background_color)
|
||||
|
||||
msgbox = arcade.gui.UIMessageBox(width=self.window.width / 2, height=self.window.height / 2, message_text=self.message, title=self.title)
|
||||
msgbox.on_action = lambda _: self.exit()
|
||||
self.add_widget(msgbox)
|
||||
|
||||
def on_exception(*exc_info):
|
||||
logging.error(f"Unhandled exception:\n{''.join(traceback.format_exception(exc_info[1], limit=None))}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user