mirror of
https://github.com/csd4ni3l/connect-the-current.git
synced 2026-01-01 04:13:41 +01:00
Switched to Linux and it changed the line encoding, probably, cause every file is showing as changed.
This commit is contained in:
@@ -1,71 +1,71 @@
|
||||
import arcade.color
|
||||
from arcade.types import Color
|
||||
from arcade.gui.widgets.buttons import UITextureButtonStyle, UIFlatButtonStyle
|
||||
from arcade.gui.widgets.slider import UISliderStyle
|
||||
|
||||
CUSTOM_DIFFICULTY_SETTINGS = [
|
||||
["source_count", "Source Count", 1, 20],
|
||||
["house_count", "House Count", 1, 20],
|
||||
["size", "Size", 3, 30]
|
||||
]
|
||||
|
||||
ROTATIONS = {
|
||||
"line": ["vertical", "horizontal"],
|
||||
"corner": ["right_bottom", "left_bottom", "left_top", "right_top"],
|
||||
"t_junction": ["top_bottom_right", "left_right_bottom", "top_bottom_left", "left_right_top"],
|
||||
"cross": ["cross"]
|
||||
}
|
||||
|
||||
NEIGHBOURS = {
|
||||
"vertical": {"b", "t"},
|
||||
"horizontal": {"l", "r"},
|
||||
"left_bottom": {"l", "b"},
|
||||
"right_bottom": {"r", "b"},
|
||||
"left_top": {"l", "t"},
|
||||
"right_top": {"r", "t"},
|
||||
"top_bottom_right": {"t", "b", "r"},
|
||||
"top_bottom_left": {"t", "b", "l"},
|
||||
"left_right_bottom": {"l", "r", "b"},
|
||||
"left_right_top": {"l", "r", "t"},
|
||||
"cross": {"l", "r", "t", "b"}
|
||||
}
|
||||
|
||||
DIRECTIONS = {"t": (0, -1, "b"), "b": (0, 1, "t"), "l": (-1, 0, "r"), "r": (1, 0, "l")}
|
||||
|
||||
menu_background_color = (30, 30, 47)
|
||||
log_dir = 'logs'
|
||||
discord_presence_id = 1435687634960777266
|
||||
|
||||
button_style = {'normal': UITextureButtonStyle(font_name="Roboto", font_color=arcade.color.BLACK), 'hover': UITextureButtonStyle(font_name="Roboto", font_color=arcade.color.BLACK),
|
||||
'press': UITextureButtonStyle(font_name="Roboto", font_color=arcade.color.BLACK), 'disabled': UITextureButtonStyle(font_name="Roboto", font_color=arcade.color.BLACK)}
|
||||
big_button_style = {'normal': UITextureButtonStyle(font_name="Roboto", font_color=arcade.color.BLACK, font_size=26), 'hover': UITextureButtonStyle(font_name="Roboto", font_color=arcade.color.BLACK, font_size=26),
|
||||
'press': UITextureButtonStyle(font_name="Roboto", font_color=arcade.color.BLACK, font_size=26), 'disabled': UITextureButtonStyle(font_name="Roboto", font_color=arcade.color.BLACK, font_size=26)}
|
||||
|
||||
dropdown_style = {'normal': UIFlatButtonStyle(font_name="Roboto", font_color=arcade.color.BLACK, bg=Color(128, 128, 128)), 'hover': UIFlatButtonStyle(font_name="Roboto", font_color=arcade.color.BLACK, bg=Color(49, 154, 54)),
|
||||
'press': UIFlatButtonStyle(font_name="Roboto", font_color=arcade.color.BLACK, bg=Color(128, 128, 128)), 'disabled': UIFlatButtonStyle(font_name="Roboto", font_color=arcade.color.BLACK, bg=Color(128, 128, 128))}
|
||||
|
||||
slider_default_style = UISliderStyle(bg=Color(128, 128, 128), unfilled_track=Color(128, 128, 128), filled_track=Color(49, 154, 54))
|
||||
slider_hover_style = UISliderStyle(bg=Color(49, 154, 54), unfilled_track=Color(128, 128, 128), filled_track=Color(49, 154, 54))
|
||||
|
||||
slider_style = {'normal': slider_default_style, 'hover': slider_hover_style, 'press': slider_hover_style, 'disabled': slider_default_style}
|
||||
|
||||
settings = {
|
||||
"Graphics": {
|
||||
"Window Mode": {"type": "option", "options": ["Windowed", "Fullscreen", "Borderless"], "config_key": "window_mode", "default": "Windowed"},
|
||||
"Resolution": {"type": "option", "options": ["1366x768", "1440x900", "1600x900", "1920x1080", "2560x1440", "3840x2160"], "config_key": "resolution"},
|
||||
"Anti-Aliasing": {"type": "option", "options": ["None", "2x MSAA", "4x MSAA", "8x MSAA", "16x MSAA"], "config_key": "anti_aliasing", "default": "4x MSAA"},
|
||||
"VSync": {"type": "bool", "config_key": "vsync", "default": True},
|
||||
"FPS Limit": {"type": "slider", "min": 0, "max": 480, "config_key": "fps_limit", "default": 60},
|
||||
},
|
||||
"Sound": {
|
||||
"Music": {"type": "bool", "config_key": "music", "default": True},
|
||||
"SFX": {"type": "bool", "config_key": "sfx", "default": True},
|
||||
"Music Volume": {"type": "slider", "min": 0, "max": 100, "config_key": "music_volume", "default": 50},
|
||||
"SFX Volume": {"type": "slider", "min": 0, "max": 100, "config_key": "sfx_volume", "default": 50},
|
||||
},
|
||||
"Miscellaneous": {
|
||||
"Discord RPC": {"type": "bool", "config_key": "discord_rpc", "default": True},
|
||||
},
|
||||
"Credits": {}
|
||||
}
|
||||
settings_start_category = "Graphics"
|
||||
import arcade.color
|
||||
from arcade.types import Color
|
||||
from arcade.gui.widgets.buttons import UITextureButtonStyle, UIFlatButtonStyle
|
||||
from arcade.gui.widgets.slider import UISliderStyle
|
||||
|
||||
CUSTOM_DIFFICULTY_SETTINGS = [
|
||||
["source_count", "Source Count", 1, 20],
|
||||
["house_count", "House Count", 1, 20],
|
||||
["size", "Size", 3, 30]
|
||||
]
|
||||
|
||||
ROTATIONS = {
|
||||
"line": ["vertical", "horizontal"],
|
||||
"corner": ["right_bottom", "left_bottom", "left_top", "right_top"],
|
||||
"t_junction": ["top_bottom_right", "left_right_bottom", "top_bottom_left", "left_right_top"],
|
||||
"cross": ["cross"]
|
||||
}
|
||||
|
||||
NEIGHBOURS = {
|
||||
"vertical": {"b", "t"},
|
||||
"horizontal": {"l", "r"},
|
||||
"left_bottom": {"l", "b"},
|
||||
"right_bottom": {"r", "b"},
|
||||
"left_top": {"l", "t"},
|
||||
"right_top": {"r", "t"},
|
||||
"top_bottom_right": {"t", "b", "r"},
|
||||
"top_bottom_left": {"t", "b", "l"},
|
||||
"left_right_bottom": {"l", "r", "b"},
|
||||
"left_right_top": {"l", "r", "t"},
|
||||
"cross": {"l", "r", "t", "b"}
|
||||
}
|
||||
|
||||
DIRECTIONS = {"t": (0, -1, "b"), "b": (0, 1, "t"), "l": (-1, 0, "r"), "r": (1, 0, "l")}
|
||||
|
||||
menu_background_color = (30, 30, 47)
|
||||
log_dir = 'logs'
|
||||
discord_presence_id = 1435687634960777266
|
||||
|
||||
button_style = {'normal': UITextureButtonStyle(font_name="Roboto", font_color=arcade.color.BLACK), 'hover': UITextureButtonStyle(font_name="Roboto", font_color=arcade.color.BLACK),
|
||||
'press': UITextureButtonStyle(font_name="Roboto", font_color=arcade.color.BLACK), 'disabled': UITextureButtonStyle(font_name="Roboto", font_color=arcade.color.BLACK)}
|
||||
big_button_style = {'normal': UITextureButtonStyle(font_name="Roboto", font_color=arcade.color.BLACK, font_size=26), 'hover': UITextureButtonStyle(font_name="Roboto", font_color=arcade.color.BLACK, font_size=26),
|
||||
'press': UITextureButtonStyle(font_name="Roboto", font_color=arcade.color.BLACK, font_size=26), 'disabled': UITextureButtonStyle(font_name="Roboto", font_color=arcade.color.BLACK, font_size=26)}
|
||||
|
||||
dropdown_style = {'normal': UIFlatButtonStyle(font_name="Roboto", font_color=arcade.color.BLACK, bg=Color(128, 128, 128)), 'hover': UIFlatButtonStyle(font_name="Roboto", font_color=arcade.color.BLACK, bg=Color(49, 154, 54)),
|
||||
'press': UIFlatButtonStyle(font_name="Roboto", font_color=arcade.color.BLACK, bg=Color(128, 128, 128)), 'disabled': UIFlatButtonStyle(font_name="Roboto", font_color=arcade.color.BLACK, bg=Color(128, 128, 128))}
|
||||
|
||||
slider_default_style = UISliderStyle(bg=Color(128, 128, 128), unfilled_track=Color(128, 128, 128), filled_track=Color(49, 154, 54))
|
||||
slider_hover_style = UISliderStyle(bg=Color(49, 154, 54), unfilled_track=Color(128, 128, 128), filled_track=Color(49, 154, 54))
|
||||
|
||||
slider_style = {'normal': slider_default_style, 'hover': slider_hover_style, 'press': slider_hover_style, 'disabled': slider_default_style}
|
||||
|
||||
settings = {
|
||||
"Graphics": {
|
||||
"Window Mode": {"type": "option", "options": ["Windowed", "Fullscreen", "Borderless"], "config_key": "window_mode", "default": "Windowed"},
|
||||
"Resolution": {"type": "option", "options": ["1366x768", "1440x900", "1600x900", "1920x1080", "2560x1440", "3840x2160"], "config_key": "resolution"},
|
||||
"Anti-Aliasing": {"type": "option", "options": ["None", "2x MSAA", "4x MSAA", "8x MSAA", "16x MSAA"], "config_key": "anti_aliasing", "default": "4x MSAA"},
|
||||
"VSync": {"type": "bool", "config_key": "vsync", "default": True},
|
||||
"FPS Limit": {"type": "slider", "min": 0, "max": 480, "config_key": "fps_limit", "default": 60},
|
||||
},
|
||||
"Sound": {
|
||||
"Music": {"type": "bool", "config_key": "music", "default": True},
|
||||
"SFX": {"type": "bool", "config_key": "sfx", "default": True},
|
||||
"Music Volume": {"type": "slider", "min": 0, "max": 100, "config_key": "music_volume", "default": 50},
|
||||
"SFX Volume": {"type": "slider", "min": 0, "max": 100, "config_key": "sfx_volume", "default": 50},
|
||||
},
|
||||
"Miscellaneous": {
|
||||
"Discord RPC": {"type": "bool", "config_key": "discord_rpc", "default": True},
|
||||
},
|
||||
"Credits": {}
|
||||
}
|
||||
settings_start_category = "Graphics"
|
||||
|
||||
@@ -1,46 +1,46 @@
|
||||
import arcade.gui, arcade
|
||||
|
||||
button_texture = arcade.gui.NinePatchTexture(64 // 4, 64 // 4, 64 // 4, 64 // 4, arcade.load_texture("assets/graphics/button.png"))
|
||||
button_hovered_texture = arcade.gui.NinePatchTexture(64 // 4, 64 // 4, 64 // 4, 64 // 4, arcade.load_texture("assets/graphics/button_hovered.png"))
|
||||
|
||||
wire_sound_effect = arcade.Sound("assets/sound/wire.mp3")
|
||||
|
||||
TEXTURE_MAP = {
|
||||
("line", "vertical", True): arcade.load_texture("assets/graphics/powered_lines/line/vertical.png"),
|
||||
("line", "vertical", False): arcade.load_texture("assets/graphics/unpowered_lines/line/vertical.png"),
|
||||
|
||||
("line", "horizontal", True): arcade.load_texture("assets/graphics/powered_lines/line/horizontal.png"),
|
||||
("line", "horizontal", False): arcade.load_texture("assets/graphics/unpowered_lines/line/horizontal.png"),
|
||||
|
||||
("corner", "left_bottom", True): arcade.load_texture("assets/graphics/powered_lines/corner/left_bottom.png"),
|
||||
("corner", "left_bottom", False): arcade.load_texture("assets/graphics/unpowered_lines/corner/left_bottom.png"),
|
||||
|
||||
("corner", "left_top", True): arcade.load_texture("assets/graphics/powered_lines/corner/left_top.png"),
|
||||
("corner", "left_top", False): arcade.load_texture("assets/graphics/unpowered_lines/corner/left_top.png"),
|
||||
|
||||
("corner", "right_bottom", True): arcade.load_texture("assets/graphics/powered_lines/corner/right_bottom.png"),
|
||||
("corner", "right_bottom", False): arcade.load_texture("assets/graphics/unpowered_lines/corner/right_bottom.png"),
|
||||
|
||||
("corner", "right_top", True): arcade.load_texture("assets/graphics/powered_lines/corner/right_top.png"),
|
||||
("corner", "right_top", False): arcade.load_texture("assets/graphics/unpowered_lines/corner/right_top.png"),
|
||||
|
||||
("t_junction", "left_right_bottom", True): arcade.load_texture("assets/graphics/powered_lines/t_junction/left_right_bottom.png"),
|
||||
("t_junction", "left_right_bottom", False): arcade.load_texture("assets/graphics/unpowered_lines/t_junction/left_right_bottom.png"),
|
||||
|
||||
("t_junction", "left_right_top", True): arcade.load_texture("assets/graphics/powered_lines/t_junction/left_right_top.png"),
|
||||
("t_junction", "left_right_top", False): arcade.load_texture("assets/graphics/unpowered_lines/t_junction/left_right_top.png"),
|
||||
|
||||
("t_junction", "top_bottom_left", True): arcade.load_texture("assets/graphics/powered_lines/t_junction/top_bottom_left.png"),
|
||||
("t_junction", "top_bottom_left", False): arcade.load_texture("assets/graphics/unpowered_lines/t_junction/top_bottom_left.png"),
|
||||
|
||||
("t_junction", "top_bottom_right", True): arcade.load_texture("assets/graphics/powered_lines/t_junction/top_bottom_right.png"),
|
||||
("t_junction", "top_bottom_right", False): arcade.load_texture("assets/graphics/unpowered_lines/t_junction/top_bottom_right.png"),
|
||||
|
||||
("cross", "cross", True): arcade.load_texture("assets/graphics/powered_lines/cross/cross.png"),
|
||||
("cross", "cross", False): arcade.load_texture("assets/graphics/unpowered_lines/cross/cross.png"),
|
||||
|
||||
("power_source", "cross", True): arcade.load_texture("assets/graphics/power_source.png"),
|
||||
|
||||
("house", "cross", True): arcade.load_texture("assets/graphics/powered_lines/cross/cross.png"),
|
||||
("house", "cross", False): arcade.load_texture("assets/graphics/unpowered_lines/cross/cross.png"),
|
||||
}
|
||||
import arcade.gui, arcade
|
||||
|
||||
button_texture = arcade.gui.NinePatchTexture(64 // 4, 64 // 4, 64 // 4, 64 // 4, arcade.load_texture("assets/graphics/button.png"))
|
||||
button_hovered_texture = arcade.gui.NinePatchTexture(64 // 4, 64 // 4, 64 // 4, 64 // 4, arcade.load_texture("assets/graphics/button_hovered.png"))
|
||||
|
||||
wire_sound_effect = arcade.Sound("assets/sound/wire.mp3")
|
||||
|
||||
TEXTURE_MAP = {
|
||||
("line", "vertical", True): arcade.load_texture("assets/graphics/powered_lines/line/vertical.png"),
|
||||
("line", "vertical", False): arcade.load_texture("assets/graphics/unpowered_lines/line/vertical.png"),
|
||||
|
||||
("line", "horizontal", True): arcade.load_texture("assets/graphics/powered_lines/line/horizontal.png"),
|
||||
("line", "horizontal", False): arcade.load_texture("assets/graphics/unpowered_lines/line/horizontal.png"),
|
||||
|
||||
("corner", "left_bottom", True): arcade.load_texture("assets/graphics/powered_lines/corner/left_bottom.png"),
|
||||
("corner", "left_bottom", False): arcade.load_texture("assets/graphics/unpowered_lines/corner/left_bottom.png"),
|
||||
|
||||
("corner", "left_top", True): arcade.load_texture("assets/graphics/powered_lines/corner/left_top.png"),
|
||||
("corner", "left_top", False): arcade.load_texture("assets/graphics/unpowered_lines/corner/left_top.png"),
|
||||
|
||||
("corner", "right_bottom", True): arcade.load_texture("assets/graphics/powered_lines/corner/right_bottom.png"),
|
||||
("corner", "right_bottom", False): arcade.load_texture("assets/graphics/unpowered_lines/corner/right_bottom.png"),
|
||||
|
||||
("corner", "right_top", True): arcade.load_texture("assets/graphics/powered_lines/corner/right_top.png"),
|
||||
("corner", "right_top", False): arcade.load_texture("assets/graphics/unpowered_lines/corner/right_top.png"),
|
||||
|
||||
("t_junction", "left_right_bottom", True): arcade.load_texture("assets/graphics/powered_lines/t_junction/left_right_bottom.png"),
|
||||
("t_junction", "left_right_bottom", False): arcade.load_texture("assets/graphics/unpowered_lines/t_junction/left_right_bottom.png"),
|
||||
|
||||
("t_junction", "left_right_top", True): arcade.load_texture("assets/graphics/powered_lines/t_junction/left_right_top.png"),
|
||||
("t_junction", "left_right_top", False): arcade.load_texture("assets/graphics/unpowered_lines/t_junction/left_right_top.png"),
|
||||
|
||||
("t_junction", "top_bottom_left", True): arcade.load_texture("assets/graphics/powered_lines/t_junction/top_bottom_left.png"),
|
||||
("t_junction", "top_bottom_left", False): arcade.load_texture("assets/graphics/unpowered_lines/t_junction/top_bottom_left.png"),
|
||||
|
||||
("t_junction", "top_bottom_right", True): arcade.load_texture("assets/graphics/powered_lines/t_junction/top_bottom_right.png"),
|
||||
("t_junction", "top_bottom_right", False): arcade.load_texture("assets/graphics/unpowered_lines/t_junction/top_bottom_right.png"),
|
||||
|
||||
("cross", "cross", True): arcade.load_texture("assets/graphics/powered_lines/cross/cross.png"),
|
||||
("cross", "cross", False): arcade.load_texture("assets/graphics/unpowered_lines/cross/cross.png"),
|
||||
|
||||
("power_source", "cross", True): arcade.load_texture("assets/graphics/power_source.png"),
|
||||
|
||||
("house", "cross", True): arcade.load_texture("assets/graphics/powered_lines/cross/cross.png"),
|
||||
("house", "cross", False): arcade.load_texture("assets/graphics/unpowered_lines/cross/cross.png"),
|
||||
}
|
||||
|
||||
180
utils/utils.py
180
utils/utils.py
@@ -1,90 +1,90 @@
|
||||
import logging, arcade, arcade.gui, sys, traceback
|
||||
|
||||
from utils.constants import menu_background_color
|
||||
|
||||
import pyglet.info, pyglet.event
|
||||
|
||||
def dump_platform():
|
||||
import platform
|
||||
logging.debug(f'Platform: {platform.platform()}')
|
||||
logging.debug(f'Release: {platform.release()}')
|
||||
logging.debug(f'Machine: {platform.machine()}')
|
||||
logging.debug(f'Architecture: {platform.architecture()}')
|
||||
|
||||
def dump_gl(context=None):
|
||||
if context is not None:
|
||||
info = context.get_info()
|
||||
else:
|
||||
from pyglet.gl import gl_info as info
|
||||
logging.debug(f'gl_info.get_version(): {info.get_version()}')
|
||||
logging.debug(f'gl_info.get_vendor(): {info.get_vendor()}')
|
||||
logging.debug(f'gl_info.get_renderer(): {info.get_renderer()}')
|
||||
|
||||
def print_debug_info():
|
||||
logging.debug('########################## DEBUG INFO ##########################')
|
||||
logging.debug('')
|
||||
dump_platform()
|
||||
dump_gl()
|
||||
logging.debug('')
|
||||
logging.debug(f'Number of screens: {len(pyglet.display.get_display().get_screens())}')
|
||||
logging.debug('')
|
||||
for n, screen in enumerate(pyglet.display.get_display().get_screens()):
|
||||
logging.debug(f"Screen #{n+1}:")
|
||||
logging.debug(f'DPI: {screen.get_dpi()}')
|
||||
logging.debug(f'Scale: {screen.get_scale()}')
|
||||
logging.debug(f'Size: {screen.width}, {screen.height}')
|
||||
logging.debug(f'Position: {screen.x}, {screen.y}')
|
||||
logging.debug('')
|
||||
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))}")
|
||||
|
||||
def get_closest_resolution():
|
||||
allowed_resolutions = [(1366, 768), (1440, 900), (1600,900), (1920,1080), (2560,1440), (3840,2160)]
|
||||
screen_width, screen_height = arcade.get_screens()[0].width, arcade.get_screens()[0].height
|
||||
if (screen_width, screen_height) in allowed_resolutions:
|
||||
if not allowed_resolutions.index((screen_width, screen_height)) == 0:
|
||||
closest_resolution = allowed_resolutions[allowed_resolutions.index((screen_width, screen_height))-1]
|
||||
else:
|
||||
closest_resolution = (screen_width, screen_height)
|
||||
else:
|
||||
target_width, target_height = screen_width // 2, screen_height // 2
|
||||
|
||||
closest_resolution = min(
|
||||
allowed_resolutions,
|
||||
key=lambda res: abs(res[0] - target_width) + abs(res[1] - target_height)
|
||||
)
|
||||
return closest_resolution
|
||||
|
||||
class FakePyPresence():
|
||||
def __init__(self):
|
||||
...
|
||||
def update(self, *args, **kwargs):
|
||||
...
|
||||
def close(self, *args, **kwargs):
|
||||
...
|
||||
import logging, arcade, arcade.gui, sys, traceback
|
||||
|
||||
from utils.constants import menu_background_color
|
||||
|
||||
import pyglet.info, pyglet.event
|
||||
|
||||
def dump_platform():
|
||||
import platform
|
||||
logging.debug(f'Platform: {platform.platform()}')
|
||||
logging.debug(f'Release: {platform.release()}')
|
||||
logging.debug(f'Machine: {platform.machine()}')
|
||||
logging.debug(f'Architecture: {platform.architecture()}')
|
||||
|
||||
def dump_gl(context=None):
|
||||
if context is not None:
|
||||
info = context.get_info()
|
||||
else:
|
||||
from pyglet.gl import gl_info as info
|
||||
logging.debug(f'gl_info.get_version(): {info.get_version()}')
|
||||
logging.debug(f'gl_info.get_vendor(): {info.get_vendor()}')
|
||||
logging.debug(f'gl_info.get_renderer(): {info.get_renderer()}')
|
||||
|
||||
def print_debug_info():
|
||||
logging.debug('########################## DEBUG INFO ##########################')
|
||||
logging.debug('')
|
||||
dump_platform()
|
||||
dump_gl()
|
||||
logging.debug('')
|
||||
logging.debug(f'Number of screens: {len(pyglet.display.get_display().get_screens())}')
|
||||
logging.debug('')
|
||||
for n, screen in enumerate(pyglet.display.get_display().get_screens()):
|
||||
logging.debug(f"Screen #{n+1}:")
|
||||
logging.debug(f'DPI: {screen.get_dpi()}')
|
||||
logging.debug(f'Scale: {screen.get_scale()}')
|
||||
logging.debug(f'Size: {screen.width}, {screen.height}')
|
||||
logging.debug(f'Position: {screen.x}, {screen.y}')
|
||||
logging.debug('')
|
||||
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))}")
|
||||
|
||||
def get_closest_resolution():
|
||||
allowed_resolutions = [(1366, 768), (1440, 900), (1600,900), (1920,1080), (2560,1440), (3840,2160)]
|
||||
screen_width, screen_height = arcade.get_screens()[0].width, arcade.get_screens()[0].height
|
||||
if (screen_width, screen_height) in allowed_resolutions:
|
||||
if not allowed_resolutions.index((screen_width, screen_height)) == 0:
|
||||
closest_resolution = allowed_resolutions[allowed_resolutions.index((screen_width, screen_height))-1]
|
||||
else:
|
||||
closest_resolution = (screen_width, screen_height)
|
||||
else:
|
||||
target_width, target_height = screen_width // 2, screen_height // 2
|
||||
|
||||
closest_resolution = min(
|
||||
allowed_resolutions,
|
||||
key=lambda res: abs(res[0] - target_width) + abs(res[1] - target_height)
|
||||
)
|
||||
return closest_resolution
|
||||
|
||||
class FakePyPresence():
|
||||
def __init__(self):
|
||||
...
|
||||
def update(self, *args, **kwargs):
|
||||
...
|
||||
def close(self, *args, **kwargs):
|
||||
...
|
||||
|
||||
Reference in New Issue
Block a user