Skip to content

nxnative for Mac: a game library around the build - #27

Merged
LNPANDY merged 7 commits into
LNPANDY:mainfrom
v0lumehi:launcher-redesign
Oct 27, 2026
Merged

LNPANDY merged 7 commits into
LNPANDY:mainfrom
v0lumehi:launcher-redesign

Conversation

@v0lumehi

@v0lumehi v0lumehi commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

nxnative for Mac: a game library around the build

The Mac front end (frontend/) was a build form. This turns it into a small launcher: a library of your games with their key art, a calmer build page, and Play with per-game launch options. Everything the old app could do is still there; the build runs the same scripts/build_ipa_from_nsp.py.

The library, with a build in progress

Build game Launch options

The redesign

  • Library. Finished Mac builds are found in a games folder you choose (and registered automatically when a build ends). A large hero shows the selected game with Play; the collection below scrolls with pager chevrons. Status reads green (ready on Mac), amber (building), gray (not built yet).
  • Key art. Each game shows its official eShop banner (1920×1080), looked up by title ID in blawar/titledb and cached under ~/Library/Application Support/NS Port Builder/artwork/. A custom image (Manage → Change artwork) still comes first; the repository's screenshots and the app icon are the fallbacks.
  • Build page and settings. One column of cards in the library's style: game files (one folder, or base / update / DLC / prod.keys), This Mac or iPhone / iPad, and the build button at the end of the page. Settings holds the games folder, the project repository (download and updates as before, from LNPANDY/NX2Apple) and the device dependencies.
  • Type and identity. Manrope for the interface (SIL OFL, embedded in the binary, so nothing needs installing); a new black app icon ("nx" in the same face, drawn by frontend/make_icon.swift). The app is now called nxnative: nxnative.app, release asset nxnative-macOS-arm64.zip. The CI also uploads the old asset name, so copies from before the rename still find their update.
  • Language. The interface follows the system (Chinese for any Chinese variant, English otherwise); the toggle is gone.
  • Kept from main. The shader-chain notice (an alert on [NOTE] chain-changed, now also read from the JSON say events, once per build) and the hint that the output folder is where the build cache lives (under Save to) are carried over into the new pages.

Launch options for Mac builds

The button beside Play shows the iPhone launcher's settings per game (frame rate, render scale, console mode, upscaling, language, rumble, the NVN performance switches, the HUD) and Play passes them to the app's environment. Only a choice that differs from the tested default is kept, as on the iPhone. The list comes from Contents/Resources/dm/launcher.json in the Mac app. Packing it is an engine change, so it is proposed upstream instead of here: seedds/nxnative#352; this fork gets it with the sync once merged. Until then a Mac app has no list and the button says so.

Progress and Stop

  • The launcher reads the script's --progress json events instead of lines (which carried a percentage only every 30 s): counts, totals and time left reach the UI twice a second, shown as thick amber bars; a step without a count shows slow diagonal stripes.
  • A running step shows how long it has been running, ticking every second; the script's time-left estimate counts down from when it came and disappears when it runs out.
  • The shader split's own count (files scanned) is also proposed upstream in Mac app carries the launcher settings; shader_split.py reports its progress seedds/nxnative#352; until then that step shows its stripes and its clock.
  • Stop ends the whole build. The script cleans up its children only on Ctrl-C, so a SIGTERM to it alone left the shader split's workers, dotnet or xcodebuild running. Builds now start in a process group of their own, and Stop (or quitting the app) ends the group. A stopped build also clears its progress.

Tests

  • Swift: swift test --package-path frontend (18 tests): bundle validation, library persistence and folder discovery, launch options, key art lookup (with a local title list), JSON progress, the process group on Stop, and a full fake build. Opt-in render tests produce the screenshots above.
  • No engine file differs from main: dm/, docs/ and scripts/ are untouched, so the sync's patcher-drift check is unaffected.
  • Qt: frontend-qt/tests/test_win.py passes with the regenerated string table.

The Mac front end becomes a small launcher: a library of the finished Mac
builds with their eShop key art (blawar/titledb, by title ID) and Play, a
calmer build page and settings in one style (Manrope, embedded), a new icon,
and the name nxnative (nxnative.app; the release also keeps the old asset
name so earlier copies still update).

Launch options: the Mac app now carries the IPA's dm/launcher.json
(pack_app.py --settings; the iOS-only switches are marked platform:ios), so
the launcher shows the iPhone launcher's settings per game and passes them
to the app's environment on Play.

Progress and Stop: the launcher reads --progress json (counts, totals, time
left twice a second); shader_split.py reports its files as it scans them;
builds run in a process group of their own, so Stop ends the script and
every tool it started, and clears the progress.
A running stage shows how long it has been running, ticking every second in
the progress list and the build bar, so a step that works on one large piece
still visibly runs. The script's time-left estimate only comes with a new
count; it now counts down from when it came and disappears when it runs out,
instead of standing still with the count.
The progress count followed pool.map, which yields in job order: one slow
job (a large archive range) held the count while the other workers went on,
so the launcher showed the split standing still. The jobs are now submitted
as futures and counted as they finish, in any order; the results are still
collected in job order, so the tables do not change.
… ended

The Stop test asked the shell to die of the SIGTERM. When its two children
die first, the shell returns from its wait and exits 0 instead, which made
the test fail now and then although Stop worked. It now checks what Stop
promises: every process of the group is gone within 3 s, before the SIGKILL.
…gress go to seedds

The launch-settings list for the Mac app (settings.py, settings.tsv,
pack_app.py --settings, its step in the NSP script) and the shader split's
progress lines are engine changes. The fork takes those files from upstream
on every sync (build_ipa_from_nsp.py and shader_split.py are patch carriers,
checked for drift), so carried here they would block the sync or be
reverted by it. They are proposed upstream instead (seedds/nxnative#352),
and come back with the sync once merged.

The launcher works without them: an app without dm/launcher.json shows no
launch options, and a step without a count shows its stripes and its clock.
@KohlerVG

Copy link
Copy Markdown

Does this PR have a settings panel to change keyboard/controller controls to map?

@v0lumehi

Copy link
Copy Markdown
Collaborator Author

@KohlerVG no but I can add that feature. Only after @LNPANDY approved and merged this one of course

@LNPANDY

LNPANDY commented Oct 27, 2026

Copy link
Copy Markdown
Owner

This is the largest and most thoughtful contribution this fork has received, and it is exactly the direction the project wanted: a library you open like a console, not a build form. I have read it, built it, and run its tests. I want to take it — but not as-is, and I want to be explicit about why, because two of the issues below would bite a real user rather than a test.

What I verified

  • Builds clean: swift build -c release in frontend/, 27 s, only the pre-existing allowedFileTypes deprecation warnings.
  • It does not touch a single file this fork patches. Your 40 files include no member of the sync patcher set (nvn_mtl.m, hle_fs.c, main.m, build_ipa.sh, build_ipa_from_nsp.py, …), so the daily upstream sync cannot fight it. That was the first thing I checked, because a PR that edits a carrier has to carry its patcher change too — PR sync_upstream: the build_ipa.sh slim patch follows upstream #279's pack block #20 and frontend: an "Also build the Mac app" switch passes --platform ios,mac-app #16 were both in that territory.
  • Your test suite found a real problem in my own assumption: it exercises the whole build→register path with a process fixture, which is more than I had.

The two things that must change before this merges

1. One test fails on a non-English machine — and that is a product problem, not just a test problem.

testCompletedBuildAppearsAutomaticallyInCollection asserts logTail.contains("✓ Mac app (4s): …"). BuildModel.duration() uses DateComponentsFormatter, which follows the system locale — on this Mac (zh_CN) it produces 4秒, so the assertion fails. The same call renders the duration in the real log line a user sees, so the UI mixes languages on any non-English system: your localization is thorough, but this one string escapes it because it comes from Foundation rather than the string table. Fix: pin the formatter's locale to the interface language (or format the number yourself, as the rest of the app does). I reproduced it in six lines — say the word and I will send the patch.

2. The rename needs a migration path for existing installs.

nxnative.app + nxnative-macOS-arm64.zip is a better name, and uploading the old asset name too is the right instinct. But an existing user's app looks for NS-Port-Builder-macOS-arm64.zip and unpacks it expecting NS Port Builder.app; the new zip contains nxnative.app, so the in-app update will download, unzip, find no NS Port Builder.app beside it, and fail — with the old copy still running, which is the good outcome, but they never get the update. A one-line note in the release body ("re-download once; updates work from then on") is enough — I would rather do that than add bundle-swapping logic for one transition.

What I like, specifically

  • Launch options through dm/launcher.json is the right seam: the Mac app gets the iPhone launcher's settings without a second settings system, and platform:ios in settings.tsv keeps the two-switch difference honest instead of hiding it.
  • Stop ends the process group. This was a real hole — build_ipa_from_nsp.py only cleans up its children on Ctrl-C, so a SIGTERM to it alone left dotnet and xcodebuild running. I have hit that myself.
  • --progress json over lines: the 30-second percentage gap in lines was the reason the Qt front end never got a real progress bar. If you are willing, the same event stream would let me delete the Qt side's line-parsing — that is a follow-up, not a condition.
  • The shader-chain notice carried over and the output-folder hint under "Save to" — you read the two commits I landed this week and kept both behaviours. That is the detail that tells me you used the app rather than only its README.
  • The guard-byte discipline in your test fixture (the fake build writes a real .app with a CFBundleExecutable) is better than a mock, and it is why the test caught something real.

What I will do

I am going to take this, in this order: fix the locale-dependent duration (I can do it in the branch, or you can push it — your call), add the release-note line for the rename, run the full Python and Qt suites against the merged tree, and then merge with your commits intact. If you would rather keep iterating on your branch first, say so and I will wait — this is your work and it is good.

One question, because it decides whether I can verify the rest: does the library scan a real builds folder on your machine? If you have a few finished .apps, NX_LAUNCHER_SCAN_FOLDER=<dir> swift test --filter testReadOnlyScanOfConfiguredFolder would exercise MacGameBundle.read against real bundles rather than fixtures, and that is the one path I cannot test here (I have no built Mac apps in a folder right now).

The formatter follows the system locale, so a Chinese macOS wrote 4秒 into a log whose every
other line was English, and the test pinning "4s" failed on any non-English machine (18 tests,
1 failure, reproduced on zh_CN). The abbreviations are now built directly; the numbers are the
same, the letters are locale-free. 18 tests, 0 failures.
@LNPANDY

LNPANDY commented Oct 27, 2026

Copy link
Copy Markdown
Owner

I fixed the locale-dependent test and merged current main into the branch — both pushed here (commits 38c35e3, 4b494e8), so the PR now carries them and the full verification below ran on the merged tree.

The duration fix: duration() now formats by hand (3h 5m / 4m 12s / 4s) instead of DateComponentsFormatter — the numbers are identical, the letters no longer follow the system locale. The pinned "4s" assertion passes everywhere.

Full verification on the merged tree (your branch + main, which since your base gained 79 game profiles, the runtime-profile work, and this week's Windows fixes — all without a single conflict):

  • swift build -c release — clean; swift test — 18 tests, 0 failures
  • Python: test_pack_ipa.py 22 ✓, test_nsp_incremental.py 34 ✓, test_shader_regressions.py 8 ✓, test_launcher_settings.py 5 ✓, test_nsp_progress.py 6 ✓
  • sync patcher consistency: 10 patchers agree with the tree
  • Qt front end: 117 tests ✓
  • the app launches (smoke-tested the release binary)

Merging now, with your commits intact and you as the author of the feature. Two notes for after:

  1. The next release will carry this, so the rename migration note I asked for in the review goes into the release body at that point ("re-download once; in-app updates work from then on") — I will write it.
  2. Follow-ups, not conditions: the --progress json stream could replace the Qt front end's line parsing (its own progress bar is the payoff), and NX_LAUNCHER_SCAN_FOLDER against real finished builds is the one test I could not run here.

@LNPANDY
LNPANDY merged commit 3d6ee53 into LNPANDY:main Oct 27, 2026
LNPANDY added a commit that referenced this pull request Oct 27, 2026
v0lumehi's PR #27 turned the Mac front end into a launcher library (40 files), and m1guelpf's
#24/#26 fixed two HLE entries that games read through as nulls. Neither appeared anywhere in the
README, and the first thing a new visitor sees should include who built what beyond the
maintainer. Both names link their PRs so the work is one click away; the section ends by pointing
at Contributing, since a visible contributor list is also an invitation.
LNPANDY added a commit that referenced this pull request Oct 27, 2026
…ssue #29)

v0lumehi read the sync script while working on #27/#28 and found a real structural gap: a fix
merged here into a vendored file that is neither OURS nor PATCHED is silently reverted the next
time upstream touches that file. The concrete instance was PR #26 itself — hle_time.c and its test
carry the adjustable-clock entry, neither was protected, and seedds has no such function.

Both parts of the suggestion are taken:

- hle_time.c and t_time.c join OURS (with a comment saying why, and that they leave if upstream
  takes the PR). Found by the issue, verified by the code: neither file was in either list.
- A new pr-scope workflow fails a PR that edits a vendored file outside OURS/PATCHED and outside
  the fork-only paths (frontend/, frontend-qt/, .github/workflows/), with the at-risk list and the
  two ways out. It reads OURS and PATCHED from sync_upstream.py itself, so the check cannot drift
  from the lists it enforces.
@v0lumehi

v0lumehi commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator Author

@LNPANDY: I ran the scan test against my real games folder:

NX_LAUNCHER_SCAN_FOLDER=/Volumes/NX/games swift test --filter testReadOnlyScanOfConfiguredFolder
Discovered Mac build: The Legend of Zelda: Breath of the Wild (01007EF00011E000)
Discovered Mac build: Hades (0100535012974000)
Discovered Mac build: The Legend of Zelda: Breath of the Wild (01007EF00011E000)
Discovered Mac build: The Legend of Zelda: Breath of the Wild (01007EF00011E000)
Executed 1 test, with 0 failures

MacGameBundle.read accepts every finished build in the folder:

  • Breath of the Wild: BotW.app, a BotW.prev.app I kept, and 01007EF00011E000.app.
  • Hades: 0100535012974000.app.

An older <game>/mac/Hades.app is correctly left out. It predates the DMTitleID key in its Info.plist (an early game.json build), so read rejects it rather than listing a game it cannot identify.

@KohlerVG: the controls remapping is in #39 (Settings → Controls), with the engine side in seedds/nxnative#386.

v0lumehi added a commit to v0lumehi/NX2Apple that referenced this pull request Oct 27, 2026
…dth for the settings' buttons and controls

Controls (asked for in LNPANDY#27): Settings has a Controls card whose
Customize... opens a sheet with every keyboard function (sticks and
D-pad, then buttons and Shake) and every controller button. A key is set
by clicking its field and pressing the key (Esc keeps the old one, x
leaves the function on no key); one key holds one function, so the
function that had it is left on none, as the host does. A controller
button picks the button it sends. The layout is kept in the user
defaults, and Play passes only its changes as DM_KEYMAP / DM_PAD_MAP,
which the host reads from seedds/nxnative#386 on (input_map.h); a build
without it ignores them. The game's own launch options win over the
layout if both ever set one variable.

Widths: the Settings cards' buttons all have one minimum width, so they
stand in one column (Refresh, Change folder..., Check for updates, Check
again). In Launch options every control has one column of one width:
the two- and three-way choices share it equally, the language list
fills it, and the slider with its value fits it, so the controls of a
card line up whatever their labels.

ControlsTests checks the defaults (nothing passed), a move onto another
function's key, a swap, a move back to the default, the controller map,
persistence and the labels; the visual QA capture renders the sheet.
@KohlerVG

Copy link
Copy Markdown

@KohlerVG no but I can add that feature. Only after @LNPANDY approved and merged this one of course

Ok, sounds good. I'll try to contribute sometime this week with patches and any issues I find along the way.

@v0lumehi
v0lumehi deleted the launcher-redesign branch November 1, 2026 05:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants