Stop the launcher's animations while another window is in front, so a launcher left open behind the game no longer draws every 15 ms.

With Hide Launcher While Playing off, the launcher stayed in its normal state behind the game and kept stepping its
animations: about 0.6 of a CPU core went to a window nobody saw, beside the game's render thread. The animations now
also stand still while the window is not in front, the same check the gamepad polling uses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
epicmeme546
2026-11-12 07:09:55 -05:00
parent fbd4067460
commit bd94adc9ec
2 changed files with 7 additions and 4 deletions

View File

@@ -55,7 +55,8 @@ Customize Launcher (on the home screen) makes the look the player's own:
scheme's backdrop back.
- Animations (on by default): the cursor glides from row to row, a new screen slides into place, sparks drift up
over the backdrop and Navi bobs in the title band with a pulsing halo (`App.animate`). They move by the time that
passed, stand still while the window is hidden or minimised, and Off stops them all.
passed, stand still while the window is hidden or minimised or another window is in front (the game, when Hide
Launcher While Playing is off), and Off stops them all.
- Sounds (Low by default; Off, Medium or High): two of the game's own interface sounds, the decide and cancel sounds
of its menus, when a row is chosen or a choice changes and when the player goes back. The launcher decodes them
from the player's built game or dump into `data/cache/sounds` (`gamefiles.extract_sounds`:

View File

@@ -1994,14 +1994,16 @@ class App:
def animate(self):
"""One step of everything that moves: the cursor on its way to the focused row and its breath, the screen
sliding into place, the sparks and Navi. Each moves by the time since the last step (the timer comes when
Tk gets to it, 16 to 50 ms apart), at most a tenth of a second's worth. With Animations off, and while the
window is hidden or minimised (the game is running), nothing moves and the timer runs slowly."""
Tk gets to it, 16 to 50 ms apart), at most a tenth of a second's worth. With Animations off, while the
window is hidden or minimised, and while another window is in front, nothing moves and the timer runs slowly.
The last covers a launcher left open behind the game (Hide Launcher While Playing off): drawing every 15 ms
took about 0.6 of a CPU core from the game for a window nobody saw."""
moving = False
try:
now = time.perf_counter()
dt = min(0.1, max(0.0, now - self.anim_last))
self.anim_last = now
moving = self.animated() and self.root.state() == 'normal'
moving = self.animated() and self.root.state() == 'normal' and winsys.in_front(self.root)
if moving:
self.anim_t += dt
self.step_slide(dt)