mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-15 19:19:58 -04:00
Read co-op's switch by its new name, coop_steam, in the launcher too.
Main renamed the switch so that an old "coop = 1" turns nothing on; the launcher's check for Steam's library still read the old name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -198,15 +198,15 @@ def find(steam_folder, signed=signed_by_valve):
|
||||
|
||||
|
||||
def wanted(game_dir):
|
||||
"""True when co-op is on in the game's settings, read as runtime/cfg.c reads them: NX2NAVI_COOP from the
|
||||
environment the game inherits first, else nx2navi.ini's coop; empty is the default, off, and any other value but 0
|
||||
is on (cfg_bool). The launcher puts the library beside the game (ensure) only then: with co-op off the game loads
|
||||
"""True when co-op is on in the game's settings, read as runtime/cfg.c reads them: NX2NAVI_COOP_STEAM from the
|
||||
environment the game inherits first, else nx2navi.ini's coop_steam; empty is the default, off, and any other value
|
||||
but 0 is on (cfg_bool). The old co-op's switch, coop, turns nothing on (cfg.c keeps it known only). The launcher puts the library beside the game (ensure) only then: with co-op off the game loads
|
||||
none, and a Play should not wait for a search of the Steam library. A file that cannot be read counts as off."""
|
||||
value = os.environ.get('NX2NAVI_COOP')
|
||||
value = os.environ.get('NX2NAVI_COOP_STEAM')
|
||||
if value is None:
|
||||
from . import gameini
|
||||
try:
|
||||
value = gameini.get(game_dir, 'coop')
|
||||
value = gameini.get(game_dir, 'coop_steam')
|
||||
except OSError:
|
||||
return False
|
||||
return value not in ('', '0')
|
||||
|
||||
@@ -5088,19 +5088,22 @@ class SteamLibTest(Tmp):
|
||||
self.assertFalse((empty / steamlib.NAME).exists())
|
||||
|
||||
def test_the_library_is_wanted_only_with_co_op_on(self):
|
||||
"""As runtime/cfg.c reads co-op: NX2NAVI_COOP first, else the game's nx2navi.ini, off by default."""
|
||||
"""As runtime/cfg.c reads co-op: NX2NAVI_COOP_STEAM first, else the game's nx2navi.ini, off by default; the
|
||||
old switch, coop, turns nothing on."""
|
||||
game = self.tmp / 'game'
|
||||
game.mkdir()
|
||||
with mock.patch.dict(os.environ):
|
||||
os.environ.pop('NX2NAVI_COOP', None)
|
||||
os.environ.pop('NX2NAVI_COOP_STEAM', None)
|
||||
self.assertFalse(steamlib.wanted(game)) # no settings file: the default, off
|
||||
(game / 'nx2navi.ini').write_text('[coop]\ncoop = 0\n', encoding='utf-8')
|
||||
(game / 'nx2navi.ini').write_text('[coop]\ncoop_steam = 0\n', encoding='utf-8')
|
||||
self.assertFalse(steamlib.wanted(game))
|
||||
(game / 'nx2navi.ini').write_text('[coop]\ncoop = 1\ncoop =\n', encoding='utf-8')
|
||||
(game / 'nx2navi.ini').write_text('[coop]\ncoop = 1\n', encoding='utf-8')
|
||||
self.assertFalse(steamlib.wanted(game)) # the old switch turns nothing on
|
||||
(game / 'nx2navi.ini').write_text('[coop]\ncoop_steam = 1\ncoop_steam =\n', encoding='utf-8')
|
||||
self.assertTrue(steamlib.wanted(game)) # an empty line leaves the earlier value
|
||||
os.environ['NX2NAVI_COOP'] = '0'
|
||||
os.environ['NX2NAVI_COOP_STEAM'] = '0'
|
||||
self.assertFalse(steamlib.wanted(game)) # the environment wins, as in the game
|
||||
os.environ['NX2NAVI_COOP'] = '1'
|
||||
os.environ['NX2NAVI_COOP_STEAM'] = '1'
|
||||
self.assertTrue(steamlib.wanted(self.tmp / 'no game'))
|
||||
|
||||
def test_play_waits_for_the_library_only_with_co_op_on_and_not_on_the_windows_thread(self):
|
||||
@@ -5122,14 +5125,14 @@ class SteamLibTest(Tmp):
|
||||
with mock.patch.dict(os.environ), mock.patch('launcher.ui.app.steamlib.ensure', side_effect=ensure), \
|
||||
mock.patch('launcher.ui.app.winsys.start_game') as start, \
|
||||
mock.patch('launcher.ui.app.saves.game_running', return_value=False):
|
||||
os.environ.pop('NX2NAVI_COOP', None)
|
||||
os.environ.pop('NX2NAVI_COOP_STEAM', None)
|
||||
App.play(a) # co-op off: no search, the game starts
|
||||
self.assertEqual(searched, [])
|
||||
start.assert_called_once_with(game / 'ocarina.exe')
|
||||
a.game_proc = None
|
||||
start.reset_mock()
|
||||
a.root.after.reset_mock()
|
||||
gameini.put(game, 'coop', 'coop', '1')
|
||||
gameini.put(game, 'coop', 'coop_steam', '1')
|
||||
App.play(a) # co-op on: the search runs on its own thread
|
||||
self.assertTrue(done.wait(10))
|
||||
self.assertNotEqual(searched, [threading.current_thread()])
|
||||
|
||||
Reference in New Issue
Block a user