Skip to content

Play your own Switch games on iPhone/iPad — one-click macOS app, no terminal. | 把 Switch 游戏装进 iPhone:图形界面一键构建,不用命令行。Bring your own game.

Launcher: an update pill over the library and in console mode

LNPANDY15fbef7af2e2
diff --git a/frontend-qt/nspb_qt/localization.py b/frontend-qt/nspb_qt/localization.py
index fada0ea7..4595a6ff 100644
--- a/frontend-qt/nspb_qt/localization.py
+++ b/frontend-qt/nspb_qt/localization.py
@@ -500,6 +500,9 @@ TABLE: dict[str, tuple[str, str, str, str]] = {
'app.staging': ('正在后台下载 %@…', 'Downloading %@ in the background…', 'Hämtar %@ i bakgrunden …', '%@ wird im Hintergrund geladen …'),
'app.ready': ('%@ 已下载并校验:退出 App 时安装,或点「立即重启」', '%@ is downloaded and verified: it installs when you quit, or Restart now', '%@ är hämtad och verifierad. Den installeras när du avslutar eller när du väljer Starta om nu.', '%@ ist geladen und geprüft: Es wird beim Beenden installiert, oder klicke auf „Jetzt neu starten“'),
'app.restartNow': ('立即重启', 'Restart now', 'Starta om nu', 'Jetzt neu starten'),
+ 'update.pill': ('更新 v%@', 'Update v%@', 'Uppdatera v%@', 'Update v%@'),
+ 'update.pillHelp': ('查看这个版本更新了什么,并下载。', 'See what changed in this release and download it.', 'Se vad den här versionen ändrar och hämta den.', 'Was diese Version ändert und sie laden.'),
+ 'update.readOnlyHint': ('这个副本所在的位置无法自我更新。把 NX2Apple.app 移到「应用程序」文件夹后再更新。', 'This copy cannot update where it is. Move NX2Apple.app into Applications first.', 'Den här kopian kan inte uppdatera där den är. Flytta NX2Apple.app till Program-programmen först.', 'Diese Kopie kann sich nicht dort aktualisieren. Lege NX2Apple.app zuerst in Programme.'),
'app.waitForBuild': ('构建进行中:更新会等构建结束', 'A build is running: the update waits until it is done', 'Ett bygge körs. Uppdateringen väntar tills det är klart.', 'Ein Build läuft: Das Update wartet, bis er fertig ist'),
'app.stageNetFail': ('%@ 下载失败(GitHub 不通?下次打开时再试)', 'Could not download %@ (GitHub unreachable? it tries again next launch)', 'Kunde inte hämta %@ (kan inte nå GitHub?). Ett nytt försök görs nästa gång appen startas.', '%@ konnte nicht geladen werden (GitHub nicht erreichbar? Beim nächsten Start wird es erneut versucht)'),
'app.noDigest': ('%@ 已发布,但 GitHub 没有提供校验值,所以不会自动安装——可以手动更新', '%@ is out, but GitHub gave no checksum for it, so it is not installed automatically — update by hand', '%@ finns, men GitHub gav ingen kontrollsumma. Den installeras därför inte automatiskt. Uppdatera manuellt.', '%@ ist da, aber GitHub hat keine Prüfsumme dafür geliefert, daher wird es nicht automatisch installiert. Aktualisiere von Hand'),
diff --git a/frontend/Sources/NSPortBuilder/ConsoleView.swift b/frontend/Sources/NSPortBuilder/ConsoleView.swift
index f5548596..a65c2092 100644
--- a/frontend/Sources/NSPortBuilder/ConsoleView.swift
+++ b/frontend/Sources/NSPortBuilder/ConsoleView.swift
@@ -28,15 +28,20 @@ enum ConsoleInput {
var inputs: AnyPublisher<ConsoleInput, Never> = Empty().eraseToAnyPublisher()
/// Set by the real launcher: leaving the mode calls it instead of showing the preview's "Back on desktop" screen.
var onExit: (() -> Void)?
+ /// A newer release is out (the launcher's update check): the top bar shows a pill for it. Tapping says what to do —
+ /// the update itself runs from Settings, after leaving console mode.
+ var updateTag: String? = nil
@StateObject private var pad = PadFocus()
@StateObject private var gamepad: LauncherGamepad
@State private var tileFrames: [String: CGRect] = [:]
+ @State private var updateAlert: String?
/// The glyph set follows the input used last: a controller's own buttons, or key caps after the keyboard.
@State private var glyphs: ConsoleGlyphs
/// `gamepad` is the one the root view owns (the controller has a single handler, so two would fight); without one the view makes its own.
- init(driver: Driver, lang: Lang = .initial(), inputs: AnyPublisher<ConsoleInput, Never> = Empty().eraseToAnyPublisher(), gamepad: LauncherGamepad? = nil, glyphs: ConsoleGlyphs? = nil, onExit: (() -> Void)? = nil) {
+ init(driver: Driver, lang: Lang = .initial(), inputs: AnyPublisher<ConsoleInput, Never> = Empty().eraseToAnyPublisher(), gamepad: LauncherGamepad? = nil, glyphs: ConsoleGlyphs? = nil, onExit: (() -> Void)? = nil, updateTag: String? = nil) {
self.onExit = onExit
+ self.updateTag = updateTag
_glyphs = State(initialValue: glyphs ?? .current())
self.driver = driver
self.lang = lang
@@ -124,6 +129,14 @@ enum ConsoleInput {
let inset: CGFloat = compact ? 24 : 64
return VStack(alignment: .leading, spacing: 0) {
topBar(compact: compact).padding(.horizontal, inset).padding(.top, compact ? 24 : 40)
+ .alert(String(format: lang == .zh ? "更新 %@" : "Update %@", updateAlert ?? ""),
+ isPresented: Binding(get: { updateAlert != nil }, set: { if !$0 { updateAlert = nil } })) {
+ Button("OK") { updateAlert = nil }
+ } message: {
+ Text(String(format: lang == .zh
+ ? "新版本 %@ 已发布。退出主机模式后,在设置 → 应用 中更新。"
+ : "Version %@ is out. Leave console mode and update in Settings → App.", updateAlert ?? ""))
+ }
if state.games.isEmpty {
empty(compact: compact).frame(maxWidth: .infinity, maxHeight: .infinity)
} else {
@@ -172,6 +185,21 @@ enum ConsoleInput {
private func topBar(compact: Bool) -> some View {
HStack(spacing: compact ? 12 : 20) {
ConsoleControllerChips(controllers: state.controllers, merged: state.padMerge, lang: lang, compact: compact) { driver.openControllers() }
+ if let updateTag {
+ Button { updateAlert = updateTag } label: {
+ HStack(spacing: 6) {
+ Image(systemName: "arrow.down.circle").font(.system(size: compact ? 12 : 14, weight: .medium))
+ Text(String(format: lang == .zh ? "更新 %@" : lang == .de ? "Update %@" : "Update %@", updateTag))
+ .font(.manrope(compact ? 13 : 15, .semibold))
+ }
+ .padding(.horizontal, 11).padding(.vertical, compact ? 5 : 7)
+ .background(LauncherPalette.ready.opacity(0.16), in: Capsule())
+ .overlay(Capsule().strokeBorder(LauncherPalette.ready.opacity(0.4)))
+ .contentShape(Capsule())
+ }
+ .buttonStyle(.plain)
+ .accessibilityLabel(String(format: lang == .zh ? "更新 %@" : "Update %@", updateTag))
+ }
Text(state.time, style: .time).font(.manrope(compact ? 17 : 22, .medium)).monospacedDigit()
.foregroundStyle(.white.opacity(0.65)).fixedSize()
}
diff --git a/frontend/Sources/NSPortBuilder/LauncherView.swift b/frontend/Sources/NSPortBuilder/LauncherView.swift
index 6e094f87..1f6c8c17 100644
--- a/frontend/Sources/NSPortBuilder/LauncherView.swift
+++ b/frontend/Sources/NSPortBuilder/LauncherView.swift
@@ -281,6 +281,27 @@ struct ContentView: View {
.padTarget("tab." + destination.rawValue, scope: "main") { page = destination }
}
Spacer(minLength: 8)
+ // The update pill: one tap opens the update sheet (what changed, download). Gone once
+ // the release is installed or the app learns there is nothing newer.
+ if let update = m.appUpdate {
+ let readOnly = m.appInstallability == .readOnly
+ Button { m.showUpdateSheet = true } label: {
+ HStack(spacing: 7) {
+ Image(systemName: readOnly ? "exclamationmark.arrow.circlepath" : "arrow.down.circle")
+ .font(.system(size: 13, weight: .medium))
+ Text(String(format: m.t("update.pill"), update.tag)).font(.manrope(13, .semibold))
+ }
+ .padding(.horizontal, 13).padding(.vertical, 8)
+ .background((readOnly ? LauncherPalette.building : LauncherPalette.ready).opacity(0.16),
+ in: Capsule())
+ .overlay(Capsule().strokeBorder((readOnly ? LauncherPalette.building : LauncherPalette.ready).opacity(0.4)))
+ .contentShape(Capsule())
+ }
+ .buttonStyle(.plain)
+ .help(m.t(readOnly ? "update.readOnlyHint" : "update.pillHelp"))
+ .accessibilityLabel(String(format: m.t("update.pill"), update.tag))
+ .padding(.trailing, 4)
+ }
searchField
Button { newBuild() } label: {
Group {
diff --git a/frontend/Sources/NSPortBuilder/Localization.swift b/frontend/Sources/NSPortBuilder/Localization.swift
index d0747dc9..67df58c3 100644
--- a/frontend/Sources/NSPortBuilder/Localization.swift
+++ b/frontend/Sources/NSPortBuilder/Localization.swift
@@ -561,6 +561,9 @@ enum L10n {
"app.staging": ("正在后台下载 %@…", "Downloading %@ in the background…"),
"app.ready": ("%@ 已下载并校验:退出 App 时安装,或点「立即重启」", "%@ is downloaded and verified: it installs when you quit, or Restart now"),
"app.restartNow": ("立即重启", "Restart now"),
+ "update.pill": ("更新 v%@", "Update v%@"),
+ "update.pillHelp": ("查看这个版本更新了什么,并下载。", "See what changed in this release and download it."),
+ "update.readOnlyHint": ("这个副本所在的位置无法自我更新。把 NX2Apple.app 移到「应用程序」文件夹后再更新。", "This copy cannot update where it is. Move NX2Apple.app into Applications first."),
"app.waitForBuild": ("构建进行中:更新会等构建结束", "A build is running: the update waits until it is done"),
"app.stageNetFail": ("%@ 下载失败(GitHub 不通?下次打开时再试)", "Could not download %@ (GitHub unreachable? it tries again next launch)"),
"app.noDigest": ("%@ 已发布,但 GitHub 没有提供校验值,所以不会自动安装——可以手动更新", "%@ is out, but GitHub gave no checksum for it, so it is not installed automatically — update by hand"),
@@ -1412,6 +1415,9 @@ enum L10n {
"app.staging": "Hämtar %@ i bakgrunden …",
"app.ready": "%@ är hämtad och verifierad. Den installeras när du avslutar eller när du väljer Starta om nu.",
"app.restartNow": "Starta om nu",
+ "update.pill": "Uppdatera v%@",
+ "update.pillHelp": "Se vad den här versionen ändrar och hämta den.",
+ "update.readOnlyHint": "Den här kopian kan inte uppdatera där den är. Flytta NX2Apple.app till Program-programmen först.",
"app.waitForBuild": "Ett bygge körs. Uppdateringen väntar tills det är klart.",
"app.stageNetFail": "Kunde inte hämta %@ (kan inte nå GitHub?). Ett nytt försök görs nästa gång appen startas.",
"app.noDigest": "%@ finns, men GitHub gav ingen kontrollsumma. Den installeras därför inte automatiskt. Uppdatera manuellt.",
@@ -2268,6 +2274,9 @@ enum L10n {
"app.staging": "%@ wird im Hintergrund geladen …",
"app.ready": "%@ ist geladen und geprüft: Es wird beim Beenden installiert, oder klicke auf „Jetzt neu starten“",
"app.restartNow": "Jetzt neu starten",
+ "update.pill": "Update v%@",
+ "update.pillHelp": "Was diese Version ändert und sie laden.",
+ "update.readOnlyHint": "Diese Kopie kann sich nicht dort aktualisieren. Lege NX2Apple.app zuerst in Programme.",
"app.waitForBuild": "Ein Build läuft: Das Update wartet, bis er fertig ist",
"app.stageNetFail": "%@ konnte nicht geladen werden (GitHub nicht erreichbar? Beim nächsten Start wird es erneut versucht)",
"app.noDigest": "%@ ist da, aber GitHub hat keine Prüfsumme dafür geliefert, daher wird es nicht automatisch installiert. Aktualisiere von Hand",
diff --git a/frontend/Sources/NSPortBuilder/OnboardingRoot.swift b/frontend/Sources/NSPortBuilder/OnboardingRoot.swift
index 533cc1c3..b1359718 100644
--- a/frontend/Sources/NSPortBuilder/OnboardingRoot.swift
+++ b/frontend/Sources/NSPortBuilder/OnboardingRoot.swift
@@ -29,7 +29,8 @@ struct RootView: View {
case .launcher:
ZStack {
if console.active {
- ConsoleView(driver: shared.console, lang: model.lang, onExit: { console.exit(); shared.console.returnFromGame() })
+ ConsoleView(driver: shared.console, lang: model.lang, onExit: { console.exit(); shared.console.returnFromGame() },
+ updateTag: model.appUpdate?.tag)
.onAppear { shared.console.reloadCovers() }
.transition(CalmTransition.console)
} else {
diff --git a/frontend/Tests/NSPortBuilderTests/GermanLocalizationTests.swift b/frontend/Tests/NSPortBuilderTests/GermanLocalizationTests.swift
index 794dae4f..7bd5cd8d 100644
--- a/frontend/Tests/NSPortBuilderTests/GermanLocalizationTests.swift
+++ b/frontend/Tests/NSPortBuilderTests/GermanLocalizationTests.swift
@@ -17,6 +17,7 @@ final class GermanLocalizationTests: XCTestCase {
"dep.zstd.win", "dep.spirv", "dep.dotnet", "dep.phase.download", "dep.python.hint",
"controls.fn.A", "controls.fn.B", "controls.fn.X", "controls.fn.Y", "controls.fn.L", "controls.fn.R",
"controls.fn.ZL", "controls.fn.ZR", "controls.fn.Plus", "controls.fn.Minus", "launch.mods",
+ "update.pill",
]
/// printf-style placeholders in order: %@, %d, %ld, %lld, %.0f and %.1f, positional %1$@, and %%.