Let players export their save into one zip for a bug report and import a save someone shared, in the launcher and in the game's menu.

The launcher's home has a Saves screen: Export Save writes NX2navi-save-<date>_<time>.zip into Downloads (or a chosen folder) with a manifest, the save the game would load next and, for a bug report, the game's latest log and nx2navi.ini, never a key file; Import a Save checks a zip's manifest, game, paths and CRCs, backs the current save up into the saves folder and replaces it while the game is not running. The game's Game tab has the same exports and an import that waits in profile/save-import and becomes the save at the next start, since the running game would write its progress back over a save replaced under it.

The zip code (runtime/save_zip.c) and the import at start are checked without game files by tests/save_zip_check.py and tests/save_share_check.py; the launcher side by its test suite.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-09 13:13:43 -05:00
parent cb234fade1
commit b2074499de
26 changed files with 2974 additions and 78 deletions

View File

@@ -149,6 +149,48 @@ def open_path(path):
subprocess.Popen(['xdg-open', path], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
def reveal(path):
"""Show a file in its folder, selected in Explorer (a file to drag into a bug report); elsewhere open the folder."""
path = Path(path)
if os.name == 'nt':
subprocess.Popen(['explorer', f'/select,{path}']) # noqa: S603, S607
else:
open_path(path.parent)
KNOWN_FOLDERS = {'downloads': '{374DE290-123F-4565-9164-39C4925E467B}',
'desktop': '{B4BFCC3A-DB2C-424C-B029-7FE99A87C641}'}
def known_folder(name):
"""Windows: the folder the shell keeps for name ('downloads', 'desktop'), also when the player moved it to another
drive; None elsewhere or when the shell names none."""
if os.name != 'nt' or name not in KNOWN_FOLDERS:
return None
try:
from ctypes import wintypes
class GUID(ctypes.Structure):
_fields_ = [('d1', wintypes.DWORD), ('d2', wintypes.WORD), ('d3', wintypes.WORD),
('d4', ctypes.c_ubyte * 8)]
ole32, shell32 = ctypes.WinDLL('ole32'), ctypes.WinDLL('shell32') # private handles: argtypes stay here
ole32.CLSIDFromString.argtypes = (wintypes.LPCWSTR, ctypes.POINTER(GUID))
ole32.CoTaskMemFree.argtypes = (ctypes.c_void_p,)
shell32.SHGetKnownFolderPath.argtypes = (ctypes.POINTER(GUID), wintypes.DWORD, wintypes.HANDLE,
ctypes.POINTER(ctypes.c_void_p))
g, out = GUID(), ctypes.c_void_p()
if ole32.CLSIDFromString(KNOWN_FOLDERS[name], ctypes.byref(g)) != 0:
return None
if shell32.SHGetKnownFolderPath(ctypes.byref(g), 0, None, ctypes.byref(out)) != 0:
return None
try:
return Path(ctypes.wstring_at(out.value))
finally:
ole32.CoTaskMemFree(out)
except (AttributeError, OSError):
return None
def start_game(exe):
"""Start the game from its own folder; returns the process to watch. ocarina.exe is a console program and the
launcher has no console, so without CREATE_NO_WINDOW Windows opened an empty console window beside the game,