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
Launch options: Reset to tested defaults is one row control wide
v0lumehi843e9a924eb2
diff --git a/frontend-qt/nspb_qt/localization.py b/frontend-qt/nspb_qt/localization.pyindex 23673c02..a2b9a3f8 100644--- a/frontend-qt/nspb_qt/localization.py+++ b/frontend-qt/nspb_qt/localization.py@@ -383,7 +383,7 @@ TABLE: dict[str, tuple[str, str, str, str]] = {'library.scrollBack': ('向前滚动', 'Scroll back', 'Rulla bakåt', 'Zurückblättern'),'library.scrollForward': ('向后滚动', 'Scroll forward', 'Rulla framåt', 'Weiterblättern'),'launch.title': ('启动选项', 'Launch options', 'Startalternativ', 'Startoptionen'),- 'launch.reset': ('恢复测试默认值', 'Reset to tested defaults', 'Återställ testade standardvärden', 'Auf getestete Standardwerte zurücksetzen'),+ 'launch.reset': ('恢复测试默认值', 'Reset to tested defaults', 'Återställ testade värden', 'Getestete Werte laden'),'launch.rowReset': ('恢复此设置的默认值', 'Reset this setting to its default', 'Återställ den här inställningen till standardvärdet', 'Diese Einstellung auf den Standard zurücksetzen'),'launch.done': ('完成', 'Done', 'Klar', 'Fertig'),'launch.applied': ('已保存到这个游戏应用中,每次启动都会生效。', 'Saved in the game’s app: applies every time it starts.', 'Sparat i spelets app och används vid varje start.', 'In der App des Spiels gesichert: gilt bei jedem Start.'),diff --git a/frontend/Sources/NSPortBuilder/LaunchOptionsView.swift b/frontend/Sources/NSPortBuilder/LaunchOptionsView.swiftindex de627908..76552903 100644--- a/frontend/Sources/NSPortBuilder/LaunchOptionsView.swift+++ b/frontend/Sources/NSPortBuilder/LaunchOptionsView.swift@@ -83,9 +83,11 @@ struct LaunchOptionsView: View {HStack(spacing: 14) {Text(m.t("launch.applied")).font(.manrope(12)).foregroundStyle(.secondary).lineLimit(2)Spacer(minLength: 8)+ // One LauncherControl wide, as the buttons of a setting row: its label fits on one line in every languageif let game, let settings, !game.launchOptions.isEmpty || (store?.hasChoices(settings) ?? false) {Button(m.t("launch.reset")) { reset(settings) }.buttonStyle(LauncherSecondaryButtonStyle())+ .launcherRowControls().padTarget("opt.reset", scope: "launch") { reset(settings) }}Button { dismiss() } label: {diff --git a/frontend/Sources/NSPortBuilder/Localization.swift b/frontend/Sources/NSPortBuilder/Localization.swiftindex 9b862606..b5a77fd1 100644--- a/frontend/Sources/NSPortBuilder/Localization.swift+++ b/frontend/Sources/NSPortBuilder/Localization.swift@@ -1329,7 +1329,7 @@ enum L10n {"library.scrollBack": "Rulla bakåt","library.scrollForward": "Rulla framåt","launch.title": "Startalternativ",- "launch.reset": "Återställ testade standardvärden",+ "launch.reset": "Återställ testade värden","launch.rowReset": "Återställ den här inställningen till standardvärdet","launch.done": "Klar","launch.applied": "Sparat i spelets app och används vid varje start.",@@ -2175,7 +2175,7 @@ enum L10n {"library.scrollBack": "Zurückblättern","library.scrollForward": "Weiterblättern","launch.title": "Startoptionen",- "launch.reset": "Auf getestete Standardwerte zurücksetzen",+ "launch.reset": "Getestete Werte laden","launch.rowReset": "Diese Einstellung auf den Standard zurücksetzen","launch.done": "Fertig","launch.applied": "In der App des Spiels gesichert: gilt bei jedem Start.",diff --git a/frontend/Tests/NSPortBuilderTests/LauncherControlWidthTests.swift b/frontend/Tests/NSPortBuilderTests/LauncherControlWidthTests.swiftindex 91720ffc..dbfa9411 100644--- a/frontend/Tests/NSPortBuilderTests/LauncherControlWidthTests.swift+++ b/frontend/Tests/NSPortBuilderTests/LauncherControlWidthTests.swift@@ -235,4 +235,50 @@ final class LauncherControlWidthTests: XCTestCase {XCTAssertEqual(size.height, LauncherControl.height, name)}}++ // MARK: Launch options++ /// The Launch options sheet at its own size, with a choice made so that Reset to tested defaults shows: in every language+ /// the button is one LauncherControl and its label fits on one line.+ @MainActor func testLaunchOptionsResetFitsInEveryLanguage() throws {+ NSApplication.shared.setActivationPolicy(.accessory)+ let directory = FileManager.default.temporaryDirectory.appendingPathComponent("launch-width-\(UUID().uuidString)")+ defer { try? FileManager.default.removeItem(at: directory) }+ let titleID = "0100FFFF28200000"+ let app = directory.appendingPathComponent("Game.app")+ let dm = app.appendingPathComponent("Contents/Resources/dm")+ try FileManager.default.createDirectory(at: dm, withIntermediateDirectories: true)+ let info: [String: Any] = ["DMTitleID": titleID, "CFBundleIdentifier": "org.example.launchwidth." + titleID.lowercased()]+ try PropertyListSerialization.data(fromPropertyList: info, format: .xml, options: 0).write(to: app.appendingPathComponent("Contents/Info.plist"))+ let scale = #"{"env": "DM_RENDER_SCALE", "kind": "range", "label": "Render scale", "note": "", "default": "1.0", "section": "Game", "min": 0.5, "max": 1.0, "step": 0.05}"#+ try #"{"game": "\#(titleID)", "settings": [\#(scale)]}"#.write(to: dm.appendingPathComponent("launcher.json"), atomically: true, encoding: .utf8)+ var game = LibraryGame(titleID: titleID, name: "Game")+ game.appPath = app.path+ game.launchOptions["DM_FULLSCREEN"] = "1" // Display mode is the launcher's own row: the choice stays in the library+ struct Snapshot: Codable { let games: [LibraryGame]; let folder: String }+ let file = directory.appendingPathComponent("library.json")+ try JSONEncoder().encode(Snapshot(games: [game], folder: directory.path)).write(to: file)+ let library = GameLibrary(file: file)+ let model = BuildModel()+ for lang in Lang.allCases {+ model.lang = lang+ let samples = Samples()+ let view = LaunchOptionsView(m: model, library: library, gameID: game.id).environmentObject(PadFocus())+ .environment(\.measuresLauncherControls, true)+ .onPreferenceChange(LauncherControlSamples.self) { samples.all = $0 }+ let host = NSHostingView(rootView: view)+ let window = NSWindow(contentRect: NSRect(x: 0, y: 0, width: 600, height: 700), styleMask: [.titled], backing: .buffered, defer: false)+ window.contentView = host+ window.orderFront(nil)+ RunLoop.main.run(until: Date().addingTimeInterval(0.3))+ host.layoutSubtreeIfNeeded()+ window.orderOut(nil)+ XCTAssertFalse(samples.all.isEmpty, "\(lang): the sheet showed no Reset to tested defaults")+ for sample in samples.all {+ XCTAssertEqual(sample.size.width, LauncherControl.width, "\(lang)")+ XCTAssertEqual(sample.size.height, LauncherControl.height, "\(lang)")+ XCTAssertLessThanOrEqual(sample.labelWidth, sample.room, "\(lang): \(L10n.string("launch.reset", lang))")+ }+ }+ }}