mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-19 10:49:58 -04:00
Bring back the switch for Discord Rich Presence, in the game's Game tab and in the launcher's Settings.
The presence is off by default and its only switch was a row of the settings menu's Menu tab, which the Ocarina menu left out, so it could be turned on only by editing nx2navi.ini. The row is in the Game tab now, and the launcher's Settings has a Discord Status row that writes discord_rpc to the game's nx2navi.ini (launcher/gameini.py, which reads the file as runtime/cfg.c does and changes only the line it sets). The connection itself works: the installed game's --probe-discord connects and sets the status. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -40,7 +40,7 @@ ROOT = Path(__file__).resolve().parent.parent
|
||||
sys.path.insert(0, str(ROOT))
|
||||
sys.path.insert(0, str(ROOT / 'tools'))
|
||||
|
||||
from launcher import build, feed, gamefiles, jobs, net, saves, settings, toolchain, updater, versions, winsys # noqa: E402
|
||||
from launcher import build, feed, gameini, gamefiles, jobs, net, saves, settings, toolchain, updater, versions, winsys # noqa: E402
|
||||
from launcher.context import Context # noqa: E402
|
||||
from launcher.paths import Layout # noqa: E402
|
||||
|
||||
@@ -253,6 +253,32 @@ class VersionTest(unittest.TestCase):
|
||||
versions.parse('banana')
|
||||
|
||||
|
||||
class GameIniTest(Tmp):
|
||||
"""The game settings the launcher switches (launcher/gameini.py), read as runtime/cfg.c reads nx2navi.ini."""
|
||||
|
||||
def test_new_file_gets_the_section(self):
|
||||
gameini.put(self.tmp, 'discord', 'discord_rpc', '1')
|
||||
self.assertEqual((self.tmp / 'nx2navi.ini').read_text(encoding='utf-8'), '[discord]\ndiscord_rpc = 1\n')
|
||||
self.assertEqual(gameini.get(self.tmp, 'discord_rpc'), '1')
|
||||
|
||||
def test_only_the_key_line_changes(self):
|
||||
ini = self.tmp / 'nx2navi.ini'
|
||||
ini.write_bytes('[display]\r\nfullscreen = 1\r\n# discord_rpc = 1\r\n[discord]\r\n'
|
||||
'NX2NAVI_DISCORD_RPC = "1"\r\ndiscord_app_id = 42'.encode('utf-8'))
|
||||
self.assertEqual(gameini.get(self.tmp, 'DISCORD_RPC'), '1') # quotes, prefix and case as the game reads them
|
||||
gameini.put(self.tmp, 'discord', 'discord_rpc', '0')
|
||||
self.assertEqual(ini.read_bytes().decode('utf-8'), '[display]\r\nfullscreen = 1\r\n# discord_rpc = 1\r\n'
|
||||
'[discord]\r\ndiscord_rpc = 0\r\ndiscord_app_id = 42')
|
||||
self.assertEqual(gameini.get(self.tmp, 'discord_rpc'), '0')
|
||||
|
||||
def test_missing_key_goes_under_its_section(self):
|
||||
ini = self.tmp / 'nx2navi.ini'
|
||||
ini.write_bytes(b'[discord]\ndiscord_app_id = 42\n[display]\nfullscreen = 1')
|
||||
self.assertEqual(gameini.get(self.tmp, 'discord_rpc'), '')
|
||||
gameini.put(self.tmp, 'discord', 'discord_rpc', '1')
|
||||
self.assertEqual(ini.read_bytes(), b'[discord]\ndiscord_rpc = 1\ndiscord_app_id = 42\n[display]\nfullscreen = 1')
|
||||
|
||||
|
||||
class SettingsTest(Tmp):
|
||||
def test_roundtrip_and_reset(self):
|
||||
s = settings.Settings(self.layout.settings)
|
||||
|
||||
Reference in New Issue
Block a user