|
|
|
@ -156,6 +156,8 @@ class GuiApplication: |
|
|
|
self._mouse = MouseState(self._scale) |
|
|
|
self._mouse = MouseState(self._scale) |
|
|
|
self._mouse_events: list[MouseEvent] = [] |
|
|
|
self._mouse_events: list[MouseEvent] = [] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self._should_render = True |
|
|
|
|
|
|
|
|
|
|
|
# Debug variables |
|
|
|
# Debug variables |
|
|
|
self._mouse_history: deque[MousePos] = deque(maxlen=MOUSE_THREAD_RATE) |
|
|
|
self._mouse_history: deque[MousePos] = deque(maxlen=MOUSE_THREAD_RATE) |
|
|
|
|
|
|
|
|
|
|
|
@ -237,6 +239,9 @@ class GuiApplication: |
|
|
|
|
|
|
|
|
|
|
|
self._modal_overlay = ModalOverlay(overlay=overlay, callback=callback) |
|
|
|
self._modal_overlay = ModalOverlay(overlay=overlay, callback=callback) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def set_should_render(self, should_render: bool): |
|
|
|
|
|
|
|
self._should_render = should_render |
|
|
|
|
|
|
|
|
|
|
|
def texture(self, asset_path: str, width: int | None = None, height: int | None = None, |
|
|
|
def texture(self, asset_path: str, width: int | None = None, height: int | None = None, |
|
|
|
alpha_premultiply=False, keep_aspect_ratio=True): |
|
|
|
alpha_premultiply=False, keep_aspect_ratio=True): |
|
|
|
cache_key = f"{asset_path}_{width}_{height}_{alpha_premultiply}{keep_aspect_ratio}" |
|
|
|
cache_key = f"{asset_path}_{width}_{height}_{alpha_premultiply}{keep_aspect_ratio}" |
|
|
|
@ -322,6 +327,12 @@ class GuiApplication: |
|
|
|
# Store all mouse events for the current frame |
|
|
|
# Store all mouse events for the current frame |
|
|
|
self._mouse_events = self._mouse.get_events() |
|
|
|
self._mouse_events = self._mouse.get_events() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Skip rendering when screen is off |
|
|
|
|
|
|
|
if not self._should_render: |
|
|
|
|
|
|
|
time.sleep(1 / self._target_fps) |
|
|
|
|
|
|
|
yield False |
|
|
|
|
|
|
|
continue |
|
|
|
|
|
|
|
|
|
|
|
if self._render_texture: |
|
|
|
if self._render_texture: |
|
|
|
rl.begin_texture_mode(self._render_texture) |
|
|
|
rl.begin_texture_mode(self._render_texture) |
|
|
|
rl.clear_background(rl.BLACK) |
|
|
|
rl.clear_background(rl.BLACK) |
|
|
|
@ -344,9 +355,9 @@ class GuiApplication: |
|
|
|
self._modal_overlay = ModalOverlay() |
|
|
|
self._modal_overlay = ModalOverlay() |
|
|
|
if original_modal.callback is not None: |
|
|
|
if original_modal.callback is not None: |
|
|
|
original_modal.callback(result) |
|
|
|
original_modal.callback(result) |
|
|
|
yield True |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
yield False |
|
|
|
yield False |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
yield True |
|
|
|
|
|
|
|
|
|
|
|
if self._render_texture: |
|
|
|
if self._render_texture: |
|
|
|
rl.end_texture_mode() |
|
|
|
rl.end_texture_mode() |
|
|
|
|