Play your own Switch games on iPhone/iPad — one-click macOS app, no terminal. | 把 Switch 游戏装进 iPhone:图形界面一键构建,不用命令行。Bring your own game.
Swift apple-siliconcustom-formathomebrewiosipaipadipadosiphonemetalnative-portnintendo-switchnxnativeromfsswitch-games
Launcher: plain confirmation for Remove, Free space and Uninstall
v0lumehic1adffdd8c47
diff --git a/frontend-qt/nspb_qt/localization.py b/frontend-qt/nspb_qt/localization.pyindex 6eec211f..73efc657 100644--- a/frontend-qt/nspb_qt/localization.py+++ b/frontend-qt/nspb_qt/localization.py@@ -254,8 +254,6 @@ TABLE: dict[str, tuple[str, str, str, str]] = {'saves.askToMac': ('用 %@ 的存档替换这台 Mac 上的存档?', 'Replace the save on this Mac with the one from %@?', 'Ersätt sparfilen på den här Mac-datorn med den från %@?', 'Spielstand auf diesem Mac durch den von %@ ersetzen?'),'saves.askNote': ('请先在 %1$@ 上关闭游戏:正在运行的游戏之后会用自己的存档覆盖复制过去的存档。被替换的存档会先保存到 %2$@。', 'Close the game on %1$@ first: a running game writes its own save over the copy later. The save being replaced is kept in %2$@ first.', 'Stäng först spelet på %1$@: ett spel som körs skriver senare över kopian med sin egen sparfil. Sparfilen som ersätts sparas först i %2$@.', 'Beende das Spiel zuerst auf %1$@. Ein laufendes Spiel schreibt später seinen eigenen Spielstand über die Kopie. Der zu ersetzende Spielstand wird vorher in %2$@ gesichert.'),'saves.cancel': ('取消', 'Cancel', 'Avbryt', 'Abbrechen'),- 'confirm.typePrompt': ('输入「%@」以确认', 'Type “%@” to confirm', 'Skriv “%@” för att bekräfta', 'Gib „%@“ ein, um zu bestätigen'),- 'confirm.cancel': ('取消', 'Cancel', 'Avbryt', 'Abbrechen'),'saves.replace': ('替换', 'Replace', 'Ersätt', 'Ersetzen'),'saves.copying': ('正在复制存档…', 'Copying the save…', 'Kopierar sparfilen …', 'Spielstand wird kopiert …'),'saves.copied': ('已复制。', 'Copied.', 'Kopierad.', 'Kopiert.'),@@ -501,7 +499,8 @@ TABLE: dict[str, tuple[str, str, str, str]] = {'uninstall.title': ('卸载 NX2Apple', 'Uninstall NX2Apple', 'Avinstallera NX2Apple', 'NX2Apple deinstallieren'),'uninstall.note': ('删除设置、内置引擎副本与启动器自己克隆的仓库。游戏文件夹、存档和 prod.keys 保留,应用本体移到废纸篓。', 'Removes settings, the installed engine trees and the launcher’s own repository clone. Your games folder, saves and prod.keys stay; the app itself goes to the Trash.', 'Tar bort inställningar, installerade engine-träd och startarens egen klon av arkivet. Dina spelmappar, sparfiler och prod.keys stannar; själva appen läggs i papperskorgen.', 'Entfernt Einstellungen, installierte Engine-Bäume und den eigenen Klon des Archivs. Dein Spieleordner, Spielstände und prod.keys bleiben. Die App selbst kommt in den Papierkorb.'),'uninstall.button': ('卸载…', 'Uninstall…', 'Avinstallera…', 'Deinstallieren…'),- 'uninstall.confirm': ('输入 NX2Apple 确认卸载。这会删除设置与引擎副本,应用本体移到废纸篓。', 'Type NX2Apple to confirm. Settings and the engine trees are removed, and the app itself goes to the Trash.', 'Skriv NX2Apple för att bekräfta. Inställningar och engine-träd tas bort och själva appen läggs i papperskorgen.', 'Tippe NX2Apple zur Bestätigung. Einstellungen und Engine-Bäume werden entfernt, die App selbst kommt in den Papierkorb.'),+ 'uninstall.confirm': ('这会删除设置与引擎副本,应用本体移到废纸篓。', 'Settings and the engine trees are removed, and the app itself goes to the Trash.', 'Inställningar och engine-träd tas bort och själva appen läggs i papperskorgen.', 'Einstellungen und Engine-Bäume werden entfernt, die App selbst kommt in den Papierkorb.'),+ 'uninstall.confirmButton': ('卸载', 'Uninstall', 'Avinstallera', 'Deinstallieren'),'uninstall.done': ('已卸载 %ld 项。现在可以退出应用。', 'Removed %ld items. You can quit the app now.', 'Tog bort %ld poster. Du kan avsluta appen nu.', '%ld Einträge entfernt. Du kannst die App jetzt beenden.'),'uninstall.failed': ('有未能删除的项目:', 'Some items could not be removed:', 'Några poster kunde inte tas bort:', 'Einige Einträge konnten nicht entfernt werden:'),'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'),diff --git a/frontend/Sources/NSPortBuilder/ContentView.swift b/frontend/Sources/NSPortBuilder/ContentView.swiftindex b9b2049a..d59a2cf7 100644--- a/frontend/Sources/NSPortBuilder/ContentView.swift+++ b/frontend/Sources/NSPortBuilder/ContentView.swift@@ -627,7 +627,7 @@ final class BuildModel: ObservableObject {/// Whether the "a new version is out" sheet is up: opened by the launch check and by Check for/// updates, so a user learns what changed before deciding, not after downloading.@Published var showUpdateSheet = false- /// The uninstall row's dialog: computed when the row is pressed, run when the phrase matches.+ /// The uninstall row's dialog: computed when the row is pressed, run when the player confirms.@Published var uninstallPlan: Uninstall.Plan?@Published var appStatus = ""/// Set when the last update attempt was refused (a release this macOS cannot open, a bad download); the update sheet shows it.@@ -3518,7 +3518,7 @@ struct BuilderView: View {dividerif m.appInstallability == .ok {// The uninstaller (Uninstall.swift): state folders and the launcher's own checkout go; the- // games folder and prod.keys stay; the app itself goes to the Trash. Typed confirmation.+ // games folder and prod.keys stay; the app itself goes to the Trash.row(m.t("uninstall.title"), detail: m.t("uninstall.note")) {Button(m.t("uninstall.button")) {m.uninstallPlan = Uninstall.plan(home: NSHomeDirectory(), gamesFolder: library.folder,diff --git a/frontend/Sources/NSPortBuilder/TypeToConfirm.swift b/frontend/Sources/NSPortBuilder/DockProgress.swiftsimilarity index 51%rename from frontend/Sources/NSPortBuilder/TypeToConfirm.swiftrename to frontend/Sources/NSPortBuilder/DockProgress.swiftindex d9e45be7..50e632f8 100644--- a/frontend/Sources/NSPortBuilder/TypeToConfirm.swift+++ b/frontend/Sources/NSPortBuilder/DockProgress.swift@@ -1,41 +1,5 @@import SwiftUI-/// A destructive action that asks for a phrase to be typed before it runs (NX Play's Remove Game and-/// Free Up Space): a click-through confirmation dialog is not enough for "deletes builds and data for good".-///-/// The phrase is the game's name — something in front of the player, not a magic word to look up.-struct TypeToConfirm: ViewModifier {- @Binding var isPresented: Bool- let phrase: String- let title: String- let message: String- let buttonTitle: String- let action: () -> Void- @State private var typed = ""-- func body(content: Content) -> some View {- content.alert(title, isPresented: $isPresented) {- TextField(String(format: L10n.string("confirm.typePrompt", .initial()), phrase), text: $typed)- Button(buttonTitle, role: .destructive) {- defer { typed = "" }- guard typed.trimmingCharacters(in: .whitespaces) == phrase else { return }- action()- }- Button(L10n.string("confirm.cancel", .initial()), role: .cancel) { typed = "" }- } message: {- Text(message + "\n" + String(format: L10n.string("confirm.typePrompt", .initial()), phrase))- }- }-}--extension View {- func typeToConfirm(isPresented: Binding<Bool>, phrase: String, title: String, message: String,- buttonTitle: String, action: @escaping () -> Void) -> some View {- modifier(TypeToConfirm(isPresented: isPresented, phrase: phrase, title: title, message: message,- buttonTitle: buttonTitle, action: action))- }-}-/// The Dock icon mirrors a running build: a dark tile with the share of the work done, so a build's/// progress is visible from wherever the launcher was left.enum DockProgress {diff --git a/frontend/Sources/NSPortBuilder/FreeSpace.swift b/frontend/Sources/NSPortBuilder/FreeSpace.swiftindex d2cccbc3..41bb6dcd 100644--- a/frontend/Sources/NSPortBuilder/FreeSpace.swift+++ b/frontend/Sources/NSPortBuilder/FreeSpace.swift@@ -303,12 +303,10 @@ struct FreeSpaceView: View {.preferredColorScheme(.dark).tint(LauncherPalette.cream).onAppear { if survey == nil { measure() } }- .typeToConfirm(- isPresented: $confirming, phrase: game.name,- title: String(format: m.t("free.confirm"), Self.bytes(chosenBytes)),- message: ([m.t("free.confirmNote")] + BuildFolderPart.allCases.filter { chosen.contains($0) && !($0 == .oldShaders && chosen.contains(.shaders)) }.map { m.t("free.cost." + $0.rawValue) }).joined(separator: "\n"),- buttonTitle: m.t("free.confirmButton")) {- removeChosen()+ .confirmationDialog(String(format: m.t("free.confirm"), Self.bytes(chosenBytes)), isPresented: $confirming, titleVisibility: .visible) {+ Button(m.t("free.confirmButton"), role: .destructive) { removeChosen() }+ } message: {+ Text(([m.t("free.confirmNote")] + BuildFolderPart.allCases.filter { chosen.contains($0) && !($0 == .oldShaders && chosen.contains(.shaders)) }.map { m.t("free.cost." + $0.rawValue) }).joined(separator: "\n"))}}diff --git a/frontend/Sources/NSPortBuilder/LauncherView.swift b/frontend/Sources/NSPortBuilder/LauncherView.swiftindex 6211b390..ab1add69 100644--- a/frontend/Sources/NSPortBuilder/LauncherView.swift+++ b/frontend/Sources/NSPortBuilder/LauncherView.swift@@ -263,14 +263,14 @@ struct ContentView: View {)) {Button(m.t("library.ok")) { launchError = nil; library.error = nil }} message: { Text(launchError ?? library.error ?? "") }- .typeToConfirm(- isPresented: Binding(get: { removing != nil }, set: { if !$0 { removing = nil } }),- phrase: removing?.name ?? "",- title: m.t("library.removeQuestion"), message: m.t("library.removeNote"),- buttonTitle: m.t("library.remove")) {- if let game = removing { library.remove(game.id) }- removing = nil- }+ .confirmationDialog(m.t("library.removeQuestion"), isPresented: Binding(+ get: { removing != nil }, set: { if !$0 { removing = nil } }+ ), titleVisibility: .visible) {+ Button(m.t("library.remove"), role: .destructive) {+ if let game = removing { library.remove(game.id) }+ removing = nil+ }+ } message: { Text(m.t("library.removeNote")) }.sheet(isPresented: Binding(get: { optionsFor != nil }, set: { if !$0 { optionsFor = nil } })) {if let id = optionsFor { LaunchOptionsView(m: m, library: library, gameID: id).environmentObject(padFocus).launcherDropdownHost() }}@@ -280,22 +280,21 @@ struct ContentView: View {}.onChange(of: freeSpaceFor) { id in padFocus.scope = id != nil ? "free" : currentPadScope }.sheet(isPresented: $m.showUpdateSheet) { UpdateSheet(m: m) }- .typeToConfirm(- isPresented: Binding(get: { m.uninstallPlan != nil }, set: { if !$0 { m.uninstallPlan = nil } }),- phrase: "NX2Apple",- title: m.t("uninstall.title"),- message: m.t("uninstall.confirm"),- buttonTitle: m.t("uninstall.button")) {- if let plan = m.uninstallPlan {- let result = Uninstall.run(plan)- m.uninstallPlan = nil- if result.failures.isEmpty {- m.appStatus = String(format: m.t("uninstall.done"), result.removed.count)- } else {- m.appStatus = m.t("uninstall.failed") + "\n" + result.failures.joined(separator: "\n")+ .confirmationDialog(m.t("uninstall.title"), isPresented: Binding(+ get: { m.uninstallPlan != nil }, set: { if !$0 { m.uninstallPlan = nil } }+ ), titleVisibility: .visible) {+ Button(m.t("uninstall.confirmButton"), role: .destructive) {+ if let plan = m.uninstallPlan {+ let result = Uninstall.run(plan)+ m.uninstallPlan = nil+ if result.failures.isEmpty {+ m.appStatus = String(format: m.t("uninstall.done"), result.removed.count)+ } else {+ m.appStatus = m.t("uninstall.failed") + "\n" + result.failures.joined(separator: "\n")+ }}}- }+ } message: { Text(m.t("uninstall.confirm")) }.sheet(isPresented: Binding(get: { savesFor != nil }, set: { if !$0 { savesFor = nil } })) {if let id = savesFor { SavesView(m: m, library: library, gameID: id).environmentObject(padFocus).launcherDropdownHost() }}diff --git a/frontend/Sources/NSPortBuilder/Localization.swift b/frontend/Sources/NSPortBuilder/Localization.swiftindex 7d3fa5db..af49899a 100644--- a/frontend/Sources/NSPortBuilder/Localization.swift+++ b/frontend/Sources/NSPortBuilder/Localization.swift@@ -297,8 +297,6 @@ enum L10n {"saves.askToMac": ("用 %@ 的存档替换这台 Mac 上的存档?", "Replace the save on this Mac with the one from %@?"),"saves.askNote": ("请先在 %1$@ 上关闭游戏:正在运行的游戏之后会用自己的存档覆盖复制过去的存档。被替换的存档会先保存到 %2$@。", "Close the game on %1$@ first: a running game writes its own save over the copy later. The save being replaced is kept in %2$@ first."),"saves.cancel": ("取消", "Cancel"),- "confirm.typePrompt": ("输入「%@」以确认", "Type \u{201c}%@\u{201d} to confirm"),- "confirm.cancel": ("取消", "Cancel"),"saves.replace": ("替换", "Replace"),"saves.copying": ("正在复制存档…", "Copying the save…"),"saves.copied": ("已复制。", "Copied."),@@ -562,7 +560,8 @@ enum L10n {"uninstall.title": ("卸载 NX2Apple", "Uninstall NX2Apple"),"uninstall.note": ("删除设置、内置引擎副本与启动器自己克隆的仓库。游戏文件夹、存档和 prod.keys 保留,应用本体移到废纸篓。", "Removes settings, the installed engine trees and the launcher\u{2019}s own repository clone. Your games folder, saves and prod.keys stay; the app itself goes to the Trash."),"uninstall.button": ("卸载…", "Uninstall…"),- "uninstall.confirm": ("输入 NX2Apple 确认卸载。这会删除设置与引擎副本,应用本体移到废纸篓。", "Type NX2Apple to confirm. Settings and the engine trees are removed, and the app itself goes to the Trash."),+ "uninstall.confirm": ("这会删除设置与引擎副本,应用本体移到废纸篓。", "Settings and the engine trees are removed, and the app itself goes to the Trash."),+ "uninstall.confirmButton": ("卸载", "Uninstall"),"uninstall.done": ("已卸载 %ld 项。现在可以退出应用。", "Removed %ld items. You can quit the app now."),"uninstall.failed": ("有未能删除的项目:", "Some items could not be removed:"),"app.waitForBuild": ("构建进行中:更新会等构建结束", "A build is running: the update waits until it is done"),@@ -1230,8 +1229,6 @@ enum L10n {"saves.askToMac": "Ersätt sparfilen på den här Mac-datorn med den från %@?","saves.askNote": "Stäng först spelet på %1$@: ett spel som körs skriver senare över kopian med sin egen sparfil. Sparfilen som ersätts sparas först i %2$@.","saves.cancel": "Avbryt",- "confirm.typePrompt": "Skriv \u{201c}%@\u{201d} för att bekräfta",- "confirm.cancel": "Avbryt","saves.replace": "Ersätt","saves.copying": "Kopierar sparfilen …","saves.copied": "Kopierad.",@@ -1427,7 +1424,8 @@ enum L10n {"uninstall.title": "Avinstallera NX2Apple","uninstall.note": "Tar bort inställningar, installerade engine-träd och startarens egen klon av arkivet. Dina spelmappar, sparfiler och prod.keys stannar; själva appen läggs i papperskorgen.","uninstall.button": "Avinstallera…",- "uninstall.confirm": "Skriv NX2Apple för att bekräfta. Inställningar och engine-träd tas bort och själva appen läggs i papperskorgen.",+ "uninstall.confirm": "Inställningar och engine-träd tas bort och själva appen läggs i papperskorgen.",+ "uninstall.confirmButton": "Avinstallera","uninstall.done": "Tog bort %ld poster. Du kan avsluta appen nu.","uninstall.failed": "Några poster kunde inte tas bort:", "update.pill": "Uppdatera %@","update.pillHelp": "Se vad den här versionen ändrar och hämta den.",@@ -2047,8 +2045,6 @@ enum L10n {"saves.askToMac": "Spielstand auf diesem Mac durch den von %@ ersetzen?","saves.askNote": "Beende das Spiel zuerst auf %1$@. Ein laufendes Spiel schreibt später seinen eigenen Spielstand über die Kopie. Der zu ersetzende Spielstand wird vorher in %2$@ gesichert.","saves.cancel": "Abbrechen",- "confirm.typePrompt": "Gib \u{201e}%@\u{201c} ein, um zu bestätigen",- "confirm.cancel": "Abbrechen","saves.replace": "Ersetzen","saves.copying": "Spielstand wird kopiert …","saves.copied": "Kopiert.",@@ -2290,7 +2286,8 @@ enum L10n {"uninstall.title": "NX2Apple deinstallieren","uninstall.note": "Entfernt Einstellungen, installierte Engine-Bäume und den eigenen Klon des Archivs. Dein Spieleordner, Spielstände und prod.keys bleiben. Die App selbst kommt in den Papierkorb.","uninstall.button": "Deinstallieren…",- "uninstall.confirm": "Tippe NX2Apple zur Bestätigung. Einstellungen und Engine-Bäume werden entfernt, die App selbst kommt in den Papierkorb.",+ "uninstall.confirm": "Einstellungen und Engine-Bäume werden entfernt, die App selbst kommt in den Papierkorb.",+ "uninstall.confirmButton": "Deinstallieren","uninstall.done": "%ld Einträge entfernt. Du kannst die App jetzt beenden.","uninstall.failed": "Einige Einträge konnten nicht entfernt werden:", "update.pill": "Update %@","update.pillHelp": "Was diese Version ändert und sie laden.",diff --git a/frontend/Tests/NSPortBuilderTests/DockProgressTests.swift b/frontend/Tests/NSPortBuilderTests/DockProgressTests.swiftindex 77d3ca71..251b0746 100644--- a/frontend/Tests/NSPortBuilderTests/DockProgressTests.swift+++ b/frontend/Tests/NSPortBuilderTests/DockProgressTests.swift@@ -1,7 +1,7 @@import XCTest@testable import NSPortBuilder-/// The Dock tile's text for a running build (DockProgress in TypeToConfirm.swift): the visible part is+/// The Dock tile's text for a running build (DockProgress): the visible part is/// pure, so it is tested; the AppKit half (drawing the tile) is not.final class DockProgressTests: XCTestCase {func testThePercentTextForAProgressFraction() {