mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-21 01:29:57 -04:00
Keep the launcher hidden through the game's own Restart.
The game's Restart ends the process the launcher started and starts another. The launcher took that for the game ending: it came back over the game and forgot a game was running, so its Play could start a second copy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -43,7 +43,7 @@ Rebuild the Game, Settings); settings (update check, Hide Launcher While Playing
|
|||||||
Open Logs Folder, Uninstall, Back); uninstall (keep or remove the built game).
|
Open Logs Folder, Uninstall, Back); uninstall (keep or remove the built game).
|
||||||
|
|
||||||
Controls: the mouse (hover moves the cursor, a click selects); the keyboard (arrows, Enter or Space, Esc, F5 checks
|
Controls: the mouse (hover moves the cursor, a click selects); the keyboard (arrows, Enter or Space, Esc, F5 checks
|
||||||
for updates); an XInput gamepad (d-pad or left stick, A, B, Y).
|
for updates); an XInput gamepad (d-pad or left stick, A, B, Y) while the window is in front.
|
||||||
|
|
||||||
`python -m launcher --selftest --shots DIR` draws every screen with made-up states and saves a PNG of each.
|
`python -m launcher --selftest --shots DIR` draws every screen with made-up states and saves a PNG of each.
|
||||||
|
|
||||||
|
|||||||
@@ -809,7 +809,9 @@ class App:
|
|||||||
self.root.after(1000, self.watch_game)
|
self.root.after(1000, self.watch_game)
|
||||||
|
|
||||||
def watch_game(self):
|
def watch_game(self):
|
||||||
if self.game_proc and self.game_proc.poll() is None:
|
# The game's own Restart ends the process started here and starts another (gfx_present.c gfx_window_closed)
|
||||||
|
gd = self.settings.get('game_dir')
|
||||||
|
if (self.game_proc and self.game_proc.poll() is None) or (gd and saves.game_running(gd)):
|
||||||
self.root.after(1000, self.watch_game)
|
self.root.after(1000, self.watch_game)
|
||||||
return
|
return
|
||||||
code = self.game_proc.returncode if self.game_proc else 0
|
code = self.game_proc.returncode if self.game_proc else 0
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import time
|
|||||||
import unittest
|
import unittest
|
||||||
import zipfile
|
import zipfile
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from unittest import mock
|
||||||
|
|
||||||
ROOT = Path(__file__).resolve().parent.parent
|
ROOT = Path(__file__).resolve().parent.parent
|
||||||
sys.path.insert(0, str(ROOT))
|
sys.path.insert(0, str(ROOT))
|
||||||
@@ -1708,6 +1709,25 @@ def have_display():
|
|||||||
|
|
||||||
|
|
||||||
@unittest.skipUnless(have_display(), 'needs tkinter, numpy and a display')
|
@unittest.skipUnless(have_display(), 'needs tkinter, numpy and a display')
|
||||||
|
class WhilePlayingTest(Tmp):
|
||||||
|
def test_the_games_restart_does_not_bring_the_launcher_back(self):
|
||||||
|
try:
|
||||||
|
from launcher.ui.app import App
|
||||||
|
except ImportError as e:
|
||||||
|
self.skipTest(f'no window toolkit: {e}')
|
||||||
|
a = mock.MagicMock()
|
||||||
|
a.settings = {'game_dir': str(self.tmp)}
|
||||||
|
a.game_proc = mock.MagicMock(returncode=0)
|
||||||
|
a.game_proc.poll.return_value = 0 # the process started here has ended
|
||||||
|
with mock.patch('launcher.ui.app.saves.game_running', return_value=True):
|
||||||
|
App.watch_game(a) # but the restarted game runs from the same exe
|
||||||
|
a.root.deiconify.assert_not_called()
|
||||||
|
a.root.after.assert_called_once()
|
||||||
|
with mock.patch('launcher.ui.app.saves.game_running', return_value=False):
|
||||||
|
App.watch_game(a)
|
||||||
|
a.root.deiconify.assert_called_once()
|
||||||
|
|
||||||
|
|
||||||
class WindowTest(Tmp):
|
class WindowTest(Tmp):
|
||||||
def test_selftest(self):
|
def test_selftest(self):
|
||||||
r = subprocess.run([sys.executable, '-m', 'launcher', '--root', str(self.tmp / 'w'), '--selftest'],
|
r = subprocess.run([sys.executable, '-m', 'launcher', '--root', str(self.tmp / 'w'), '--selftest'],
|
||||||
|
|||||||
Reference in New Issue
Block a user