Files
mandy/docs/launcher.md

21 KiB

The Mandy Launcher

The Python launcher has the Mandy name and the layout of the launcher mockup, its indigo taken toward a neutral night: violet and pink only on the PLAY pill, the rail's mark and the switches that are on; Mandy in the rail with the update state (the same coloured dot as the Updates card), commit, card and driver under it; and cards on every page. The folders it reads and writes keep the Leonida names (%APPDATA%\Leonida, %LOCALAPPDATA%\Leonida), so no setting, cache or save moves.

A desktop window for the port, in the usual shape of a game launcher: a narrow navigation column on the left and pages of cards. It is Leonida's own design: no other company's name, logo, font or artwork, no picture files, and no game assets in the repository. It is not an official product.

Starting it

  • Windows: double-click Launcher.bat at the repository root. It looks for Python 3.12 or newer with Tcl/Tk (the window needs it): the py launcher's versions, python on PATH, then the per-user installs under %LOCALAPPDATA%\Programs\Python. Without one it asks, then installs Python 3.12 for your user account only (no admin): winget if present, else the python.org installer pinned and checked against its SHA-256, the same one Build.bat uses, with Tcl/Tk. LEONIDA_PY_INSTALL_DRYRUN=1 prints those commands and runs nothing.
  • Linux: python3 tools/leonida_launcher.py (needs Tkinter: the python3-tk package).

Standard library only (tools/leonida_launcher.py). The window tells Windows it draws at the screen's own scale, so its text is sharp at 125-200 %; sizes in pixels follow that scale. Nothing slow runs on the window's thread before it first draws (no picture is read at all; git and the card's name are read by workers), so it cannot open white. An error in a button's code is written into the output box instead of being lost.

Languages

English, French, Spanish, Portuguese and German. The launcher follows Windows' display language (GetUserDefaultUILanguage; on Linux the LANG-style variables) and falls back to English; Language in Settings overrides it. The translations are tools/launcher_i18n/<code>.json, each mapping the English text in tools/leonida_launcher.py to its translation: a text without one shows in English. A new text in the launcher needs its line in every file, which tests/test_leonida_launcher.py checks (same keys, same {fields}).

Pages

  • Play: three cards.

    • Play: the PLAY pill runs powershell -NoProfile -ExecutionPolicy Bypass -File scripts\play-d3d12.ps1 -Game <folder> -Data <folder> plus the switches chosen in Settings (on Linux scripts/play-linux.sh <folder>/game_scarlett_master.exe, with --series-x if chosen). Under it: the state, the game folder (or where to choose it), a one-line warning while the profile the next PLAY runs is Series X and the commit limit is under 64 GiB (as in Settings, below; that profile is the launcher's when it was changed since the last PLAY, otherwise the F1 menu's LEONIDA_MENU_CONSOLE when the menu saved one, as the scripts decide it, below), the options PLAY passes and what the in-game F1 menu saved (below). The state reads a few of the script's own messages: Starting, Building the runtime, Preparing shaders, Running (a guess from the text; the log is the truth); at the end it says the game closed, closed right after starting (with what to send), or stopped with an error code. Only one thing runs at a time: while it runs PLAY becomes Stop, which, after a confirmation, ends the process and everything it started (taskkill /T /F; on Linux the process group).
    • Updates: up to date, how many updates there are, or why it cannot tell (a zip copy, no git, no branch to follow, a failed fetch); the time of the last check with Check now; what is new, one line per new commit on the followed branch's first-parent line (a merged pull request is named #N and its title), six at most and "+ n more"; and Update Mandy when there is something to take.
    • Output: the script's output, with Run in diagnostic mode and Copy my info. The window takes at most 2 000 lines a turn, each run of them in one insert, and comes back after 10 ms while more is waiting, so a run that floods the pipe (the runtime's stderr without -Log) leaves the window answering (take_output, the design of #3192).

    The rail shows the same update state at its bottom, with the time of the last check.

  • Settings: the page of the launcher mockup OreoFR chose: cards in two columns with switches, segmented choices and lists, a short line under some options and the longer text when the pointer rests on one; saved with Save (PLAY saves too):

    • Picture: the profile (Series S is -SeriesS; Series X is the script's default), DLSS (off is -NoDlss), the DLSS mode (-Dlss quality|balanced|performance|ultra, Auto = none; on Series X DLSS makes the picture only with one), the resolution (-Resolution, Default = none, left out with a DLSS mode), the window shape (-Aspect: Default = none, which is 16:9; your screen's = auto, 21:9, 32:9 or 16:10; a shape saved otherwise, W:H or a decimal, is kept as a choice of its own; the game still draws 16:9 inside it), how the picture fills that window (-PresentScale: Fit, the script's default with -Aspect, passes nothing, or Stretch; greyed while the shape is Default, since the script only takes it with -Aspect) and -Quality. With Series X chosen and Windows' commit limit (RAM + page file, GlobalMemoryStatusEx) under 64 GiB, a warning-coloured line under the profile gives the PC's RAM and limit: the profile commits about 59 GB, so expect stutters and frame generation cutting in and out (every frame over 100 ms resets it); it suggests Series S or a fixed page file that brings the limit to about 80 GB, and the pointer on it shows the steps (sysdm.cpl > Advanced > Performance Settings > Advanced > Virtual memory > Custom size) with a size for this PC. It follows the profile control before Save, blocks nothing and changes no switch; when the F1 menu saved another console, the profile's "F1 menu: Series X" line (below) says so. The page-file steps and the measurements are in d3d12/docs/windows-memory.md.
    • Frame generation: the mode, DLSS, FSR (-FsrFrameGen) or Off (-NoFrameGen); the multiplier of DLSS's, Auto (nothing passed: the script's own choice, 2x on RTX 40 and 50 with NVIDIA's files) or 2x to 6x (-FrameGen n, the range play-nvidia.ps1 takes), passed with the DLSS mode only (Off wins over FSR, FSR over the multiplier). 3x and up are marked RTX 50: the scripts pass any of them whatever the card, and the runtime makes no more than the card does (fg.rs asks Streamline for its most), so an RTX 40 makes 2x and logs that it was asked for more; a card without DLSS frame generation starts none. On Series X a multiplier also brings DLSS in (-Dlss quality unless a mode is chosen), where Auto leaves the title's own path. A multiplier saved by the older launcher shows as chosen and can be set back to Auto. Then the frame limit, Auto (nothing passed: the runtime's followed limit), 30, 40, 60 or No limit (LEONIDA_FG_LIMIT_FPS through -More); -SmoothMotion.
    • Ray tracing: Off or Hardware (-HardwareRT, a trial). Software ray tracing (-RayTracing) is no longer offered; a software choice saved by an older launcher is dropped at the next Save or PLAY.
    • Shaders: shader preparation (off is -NoPrecompile) and full pipeline precompilation; fresh settings enable both, and turning the full one off with the preparation on passes -PrecompileUsed. Turning the full one on turns the preparation on. With the note on NVIDIA's shader cache size.
    • General, diagnostics & advanced: the language, the graphics card (-Adapter: Default = none, Windows' own choice; otherwise a card of this PC by its name, which the runtime looks for in each card's name, any case), -Log, crash tracing (LEONIDA_D3D12_DRED=1), the update check, and Advanced options: LEONIDA_* variables as NAME=value separated by ;, for when someone asks you to try one (they win over the frame limit above). A part that is not such a pair is shown in red and not passed. With variables to pass, PLAY starts the script with powershell -Command "& '...\play-d3d12.ps1' ... -More @{NAME='value'}", since -File cannot hand over a hashtable (play-nvidia.ps1 clears inherited LEONIDA_* variables, so -More is the way in); every argument is single-quoted, a quote doubled. The graphics card list is read from the registry, DriverDesc under HKLM\SYSTEM\CurrentControlSet\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318}\00NN (winreg, about 10 ms the first time and under 1 ms after), each name once, without Windows' software adapters (Microsoft Basic Render Driver and the like) and drivers that are not on the PCI bus (virtual displays). A driver left by a card taken out of the PC can still be listed; chosen, the runtime logs that it names no card and uses Windows' default. Off Windows, or when nothing reads, the list has Default only; a saved value no card gives (#1) is kept as a choice. Advanced mode…, beside that field, opens a second window (one at a time; a second click brings it to the front) with every LEONIDA_* variable of d3d12/docs/switches.md, read from the repository when it opens (682 names today; without the file the window says so). That file is not a list of recommended settings, and the window opens with that warning and a link to d3d12/docs/findings.md. Each row has the name, its section, how the code reads it, whether LEONIDA_AB can turn it, the NVIDIA launcher script sets it or findings.md names it, the code's comment (two lines; the pointer on it shows all of it) and the value: a switch for the kinds "off unless set and not 0" (on writes 1) and "on, 0 turns it off" (off writes 0), a text otherwise. Names and comments come from the code and stay in English. A search over names and comments, a section filter, Only what I set and Only those the play script sets narrow the list; only the rows on screen exist, so filtering the 682 names takes a few milliseconds. It edits the same field, nothing else: Apply or Close writes the changed names into it (a value set adds or updates its pair, a value cleared removes it), so the field's checks and the frame generation + ray tracing unlock run as if it had been typed; pairs the list does not know and parts that are not pairs are kept as they were written, and a value with " or ; is refused. Reset all (after a confirmation) clears every listed name. Nothing is set by default, so PLAY's command does not change until a value is applied. Like the field, these go through -More, which wins over the F1 menu's file at a normal start.
    • Game folders (not in the mockup, under its cards): the game folder (a picker, and a check that game_scarlett_master.exe is in it), the data folder (empty = the script's default) and the mods folder.

    -Capture is in the diagnostics card. A control another choice makes pointless is greyed (its value is kept, and comes back when that choice is undone): frame generation's mode and limit with hardware ray tracing (the scripts leave frame generation off with it; a note says so; with LEONIDA_FG_WITH_RT=1 in the advanced options they start it anyway, so nothing is greyed and the note says it is unlocked), the frame generation multiplier with FSR or Off and, as the mode, with hardware ray tracing unless unlocked, the DLSS mode with DLSS off, the resolution with a DLSS mode, the frame limit with frame generation off, how the picture fills the window while the shape is Default, and shader preparation, kept on, while every pipeline is precompiled. On Linux only the game folder and Series X are used. Under frame generation, DLSS, ray tracing, the profile and Smooth Motion a muted line "F1 menu: " says that the F1 menu's file holds a value for the same setting.

  • Run in diagnostic mode (Play, Settings and Tools): PLAY with -Log and LEONIDA_D3D12_DRED=1; when the game ends the logs folder opens, for the newest file to go with a report.

  • Copy my info (the same three places): puts on the clipboard what a report needs and shows it first: the Leonida commit and its date, each graphics card with its driver (NVIDIA's own number, 621.47, from the Windows one, 32.0.16.2147), Python, Tk and Windows versions, the RAM and Windows' commit limit, the switches and variables PLAY passes, and whether the game folder holds the game. No folder names: they can carry the user's name.

  • Mods: the mods\*\mod.json of the mods folder (this repository's mods unless changed), with the enabled flag written back as the mod manager does it (tools/leonida_mods.py); a button opens that manager.

  • Saves: the D3D12 runtime's saves under the data folder, <data>\data\7952987A\saves\<user id>\<configuration>\<Name>~<FNV-1a 64 hex>\v<N>\{0, 1, manifest} (d3d12/crates/leonida-hle/src/modules/xgamesave.rs; tools/leonida_saves.py). Containers and their blobs are listed with size, modified time and the newest readable version. Actions: back up one container or all (a ZIP in <data>\save-backups), restore from a backup (confirmation, and the current saves are backed up first), duplicate a container under a new name, delete (the folder is moved to save-backups\deleted, not erased), export and import a single blob, and a read-only hex and strings viewer. All of them are refused while the game is running.

  • Updates: at every start the launcher runs git fetch in its own folder and, when the clone is behind the branch it follows, lists the new commits in the Play page's Updates card (git log --first-parent HEAD..@{u}) with an Update Mandy button. Update runs git pull --ff-only (it stops, changing nothing, if local changes or another branch are in the way), then, on Windows, rebuilds the runtime when d3d12/ changed; on Linux it only says that d3d12/ changed, and the rebuild is yours to run (linux.md). A copy downloaded as a zip has no .git, and updating means a git clone of the repository instead. A zip copy, a missing git, a failed check (with git's reason) or a branch that follows no upstream is shown in the Updates card and the rail instead of an update.

  • Tools: update Leonida (as above), fetch NVIDIA's DLSS files (d3d12\Get-NVIDIA-DLSS.cmd, after a confirmation: about 70 MB from NVIDIA's GitHub), rebuild the runtime (d3d12\scripts\build-nvidia.ps1), open the logs folder (%LOCALAPPDATA%\Leonida\logs) and the screenshots folder. The two scripts are Windows only.

  • About: what the port is, that it runs your own copy, the credits (see d3d12/README.md) and the licence.

The launcher and the F1 menu: which one wins

The in-game F1 menu saves its choices in d3d12\leonida-settings.txt (LEONIDA_*=value lines; d3d12/scripts/play-nvidia.ps1 reads it at every start), and the launcher keeps its own options in launcher.json and passes them as switches at every PLAY. For one setting, the newest choice wins:

  • an option you changed in the launcher since the last PLAY is passed as chosen (-Chosen): it wins over the F1 menu's value for the same setting, and the script drops that value from the menu file;
  • an option you did not change is passed again but does not count as chosen: the F1 menu's saved value, if there is one, wins;
  • the advanced options, the frame limit and crash tracing (-More) always win at a normal start.

So the launcher can show one value while the game starts with the F1 menu's. The Play card lists what the F1 menu saved ("Saved in the F1 menu", read again when the window comes back to the front and when a run ends), and Clear F1 settings deletes that file, after a confirmation and only while the game is not running: the next start then uses the launcher's options and the game's defaults. With no file or nothing in it the card says "Nothing saved in the F1 menu" rather than hiding the section, so a clear shows its result where it was asked for.

The Play card's commit-limit warning uses the same order for the console (effective_console): the launcher's profile if it changed since the last PLAY, otherwise the menu's LEONIDA_MENU_CONSOLE (series-x or series-s) when the file holds one, otherwise the launcher's. At the first PLAY nothing counts as changed (-Chosen none), so the menu's console wins there too. It is read again with the menu file (focus, end of a run).

Settings file

%APPDATA%\Leonida\launcher.json (Linux: ~/.config/leonida/launcher.json), written when you press Save or close the window. Unknown or mistyped keys are ignored.

Tests

python -I tests/test_leonida_saves.py does the same for the Saves page on fake save trees. python -I tests/test_leonida_launcher.py covers the parts without a window: reading and writing the settings, the command line each option produces (checked against the switch names in scripts/play-d3d12.ps1), the advanced options and their quoting, the Advanced mode window's reading of switches.md and its edits of the advanced options (unknown pairs kept, " and ; refused), the F1 menu's file (reading it and deleting only that file), which console the warning follows, the output pump's batches (take_output: 10 001 lines are one insert a turn), the translations (every text of the window in every language), the language choice, the driver number, Copy my info, the mod list, what is new upstream (the pull requests' titles) and the Python offer of Launcher.bat.

Saves: what the bytes are, and what is not edited

  • Layout. A container's folder is its name with every byte but letters, digits, - and _ written %XX (cut at 100 characters), ~, and the 64-bit FNV-1a of the exact name in 16 hex digits. Inside, the highest v<N> whose manifest parses is the container; the manifest is u32-LE-length-prefixed strings: container name, display name, then the blob names, and blob i is the file i. The runtime writes a new version as v<N>.new and one rename commits it, and drops older versions the next time it opens the container. Duplicate therefore writes a folder with the new name's hash and a manifest naming it; any change to a blob is written the same way, as a new v<N+1> beside the old one, after a backup.
  • Blobs. Every container measured has two: Save Game Data and Save Game Header (296 bytes). Save Game Data is an ASAV file (saves.md). The profile and settings containers are plain ASAV (mode 1: the body is the record or hash-keyed JSON text, entropy 0.4 to 4.6 bits per byte). The story-save containers are mode 3 and their body has an entropy of 8.00: compressed or encrypted, and no format note in docs/ names an algorithm for it.
  • Editing. The launcher shows a packed save as "this save is packed (compressed or encrypted); editing is not supported" and does not try to decode, decompress or work around it. For the plain ones the ASAV header carries a checksum at 0x160 whose algorithm is open (docs/saves.md), and the header blob repeats the size, so the launcher does not edit values: that would write saves the title may reject, on the strength of a guess. What is offered is replacing a whole blob with a file you changed yourself (export, change, import), with the backup and the new version described above; a changed size no longer matches the header blob, which the page warns about.
  • Nothing from a real save is in the repository: tests/test_leonida_saves.py builds its own fake trees.

The HTML launcher (launcher/, in progress)

launcher/index.html is a second front end in the layout of a publisher's game launcher (a slim rail with the game's tile, a picture over the whole window, the sections top right, the logo with a large PLAY button), and launcher/serve.py the small server behind it. python -I launcher/serve.py serves it on 127.0.0.1 only and opens it in a window of its own (Edge or Chrome in app mode, else the default browser). --no-run only looks: PLAY and the tools print the command they would run. Launcher.bat still opens the Tkinter window above.

  • Who may ask: a request must name this machine in Host and carry the token written into the page for that run (a header for /api, a cookie for pictures and the event stream). Mods, saves and captures are named by folder, name or index, never by path.
  • The picture behind PLAY: the one chosen in Settings, else the newest background.webp, .png or .jpg in the launcher's settings folder (%APPDATA%\Leonida), else the newest capture, else art the page draws. When there is none, the server fetches the game's key art from rockstargames.com once and keeps it there as background.jpg (or .webp, by what comes back); --no-art leaves it. The request names a plain browser and nothing about you or the project. The picture is never part of the repository. That download is the launcher's only internet access.
  • python -I tests/test_launcher_serve.py covers the above without a browser or the internet.