Skip to content

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

Launch options: say why a game has no resolution setting (#574)

Haseenesssb97eb402da39
diff --git a/frontend/Sources/NX2Apple/LaunchOptionsView.swift b/frontend/Sources/NX2Apple/LaunchOptionsView.swift
index d903a926..c6a4a539 100644
--- a/frontend/Sources/NX2Apple/LaunchOptionsView.swift
+++ b/frontend/Sources/NX2Apple/LaunchOptionsView.swift
@@ -52,6 +52,7 @@ struct LaunchOptionsView: View {
ScrollViewReader { proxy in
ScrollView {
VStack(alignment: .leading, spacing: 24) {
+ if let note = ResolutionNote.text(settings, shown: { $0.isShown(in: settings) { value($0, game) } }, t: loc.t) { resolutionNote(note) }
groups(settings.filter(\.isBasic), game, all: settings)
modsSection(game)
frameTimesSection(game)
@@ -145,6 +146,25 @@ struct LaunchOptionsView: View {
private var divider: some View { Divider().opacity(0.25).padding(.leading, 18) }
+ /// Why there is no resolution row (#574), above the settings, where the player looks for one.
+ private func resolutionNote(_ note: ResolutionNote.Text) -> some View {
+ HStack(alignment: .firstTextBaseline, spacing: 10) {
+ Image(systemName: "info.circle").font(.system(size: 13)).foregroundStyle(.secondary)
+ VStack(alignment: .leading, spacing: 3) {
+ Text(note.title).font(.manrope(14, .medium))
+ if let detail = note.detail {
+ Text(detail).font(.manrope(12)).foregroundStyle(.secondary).fixedSize(horizontal: false, vertical: true)
+ }
+ }
+ Spacer(minLength: 0)
+ }
+ .padding(.horizontal, 18).padding(.vertical, 13)
+ .frame(maxWidth: .infinity, alignment: .leading)
+ .background(LauncherPalette.surface.opacity(0.75), in: RoundedRectangle(cornerRadius: 14))
+ .overlay(RoundedRectangle(cornerRadius: 14).strokeBorder(Color.white.opacity(0.06)))
+ .accessibilityElement(children: .combine)
+ }
+
/// The translated heading of a section this launcher knows; a section it does not know is drawn under its own name.
private func sectionName(_ section: String) -> String {
let key = "launch.section." + section
@@ -382,3 +402,32 @@ struct LaunchOptionsView: View {
else { NSWorkspace.shared.open(support.deletingLastPathComponent()) }
}
}
+
+/// The note of a game whose build has no render scale row (#574). The row comes only with a render scale hook in the engine
+/// for that game (today Breath of the Wild and Tears of the Kingdom, #534), so a player of another game looks for a resolution
+/// setting and finds none. The note says so and names the rows of the sheet that come closest, Console mode and Upscaling,
+/// with their labels as the sheet shows them and where they are when they sit under Advanced settings.
+enum ResolutionNote {
+ struct Text: Equatable {
+ let title: String
+ let detail: String?
+ }
+
+ /// The rows that come closest to a resolution setting, in the order the note names them.
+ static let closest = ["DM_OPMODE", "DM_PRESENT_UPSCALE"]
+
+ /// nil when the list has a render scale row (shown or not: the build has one), or no row at all. `shown` is the sheet's own test
+ /// for a sub-setting (needs), so the note names only rows the player can find.
+ static func text(_ settings: [LaunchSetting], shown: (LaunchSetting) -> Bool = { _ in true }, t: (String) -> String) -> Text? {
+ guard !settings.isEmpty, !settings.contains(where: { $0.env == "DM_RENDER_SCALE" }) else { return nil }
+ let names = closest.compactMap { env in settings.first { $0.env == env && shown($0) } }
+ .map { $0.isBasic ? $0.label : String(format: t("launch.noResolution.advanced"), $0.label) }
+ let detail: String?
+ switch names.count {
+ case 0: detail = nil
+ case 1: detail = String(format: t("launch.noResolution.one"), names[0])
+ default: detail = String(format: t("launch.noResolution.two"), names[0], names[1])
+ }
+ return Text(title: t("launch.noResolution"), detail: detail)
+ }
+}
diff --git a/frontend/Tests/NX2AppleTests/LaunchOptionsTests.swift b/frontend/Tests/NX2AppleTests/LaunchOptionsTests.swift
index fa49e107..57e6604c 100644
--- a/frontend/Tests/NX2AppleTests/LaunchOptionsTests.swift
+++ b/frontend/Tests/NX2AppleTests/LaunchOptionsTests.swift
@@ -134,4 +134,29 @@ final class LaunchOptionsTests: IsolatedDefaultsTestCase {
XCTAssertFalse(segmented("DM_X", ["One", "Two", "Seven tens"]), "three segments are narrower than two")
XCTAssertFalse(segmented("DM_X", ["A", "B", "C", "D"]), "four or more are a menu")
}
+
+ /// #574: a list without a render scale row says so above the settings, and names the rows that come closest, by the sheet's labels.
+ func testAListWithoutARenderScaleSaysWhyAndNamesTheClosestRows() throws {
+ let upscale = #"{"env": "DM_PRESENT_UPSCALE", "kind": "choice", "label": "Upscaling", "note": "", "default": "off", "section": "Game", "options": [["off", "Standard"], ["metalfx", "MetalFX"]]}"#
+ func note(_ rows: [String], _ lang: Lang = .en) throws -> ResolutionNote.Text? {
+ let (app, repo) = try self.app(rows.joined(separator: ","))
+ let list = try XCTUnwrap(LaunchSetting.forMac(app: app, titleID: "01007EF00011E000", repo: repo, labels: { L10n.string($0, lang) }))
+ return ResolutionNote.text(list, t: { L10n.string($0, lang) })
+ }
+ XCTAssertEqual(try note([opmode, upscale, hud]),
+ ResolutionNote.Text(title: "This game has no resolution setting yet.",
+ detail: "The closest settings are Console mode and Upscaling (under Advanced settings)."),
+ "Xenoblade Chronicles 2's list: Console mode is basic, Upscaling sits under Advanced settings")
+ XCTAssertEqual(try note([opmode, upscale], .zh)?.detail, "最接近的设置是主机模式和超分(在高级设置中)。")
+ XCTAssertEqual(try note([upscale])?.detail, "The closest setting is Upscaling (under Advanced settings).")
+ XCTAssertEqual(try note([hud]), ResolutionNote.Text(title: "This game has no resolution setting yet.", detail: nil))
+ XCTAssertNil(try note([scale, opmode, upscale]), "a game with a render scale row has its resolution setting")
+ XCTAssertEqual(try note([]), ResolutionNote.Text(title: "This game has no resolution setting yet.", detail: nil),
+ "a build with no rows of its own still has Display mode, and no render scale")
+ XCTAssertNil(ResolutionNote.text([], t: { L10n.string($0, .en) }), "no rows at all: the sheet says launch.none instead")
+ let (app, repo) = try self.app([opmode, upscale].joined(separator: ","))
+ let list = try XCTUnwrap(LaunchSetting.forMac(app: app, titleID: "01007EF00011E000", repo: repo, labels: { L10n.string($0, .en) }))
+ XCTAssertEqual(ResolutionNote.text(list, shown: { $0.env != "DM_PRESENT_UPSCALE" }, t: { L10n.string($0, .en) })?.detail,
+ "The closest setting is Console mode.", "a row the sheet hides (a sub-setting whose parent is off) is not named")
+ }
}
diff --git a/frontend/l10n/de.json b/frontend/l10n/de.json
index eab599e3..c04adb43 100644
--- a/frontend/l10n/de.json
+++ b/frontend/l10n/de.json
@@ -924,6 +924,10 @@
"launch.modsNoteOrder": "Eine Mod ändert die Dateien, die das Spiel liest. Sichere die Spielstände, bevor du eine Mod ein- oder ausschaltest: Ein Spielstand, der mit einer Mod entstanden ist, lässt sich ohne sie womöglich nicht laden. Ersetzen zwei Mods dieselbe Datei, gewinnt die weiter oben in der Liste.",
"launch.modsOpen": "Mods-Ordner öffnen",
"launch.modsRefresh": "Aktualisieren",
+ "launch.noResolution": "Für dieses Spiel gibt es noch keine Einstellung für die Auflösung.",
+ "launch.noResolution.advanced": "%@ (unter Erweiterte Einstellungen)",
+ "launch.noResolution.one": "Am nächsten kommt %@.",
+ "launch.noResolution.two": "Am nächsten kommen %1$@ und %2$@.",
"launch.none": "Dieser Build bringt keine Liste mit Startoptionen mit.",
"launch.opt.DM_FPS_TARGET.30": "30 fps",
"launch.opt.DM_FPS_TARGET.60": "60 fps",
diff --git a/frontend/l10n/en.json b/frontend/l10n/en.json
index c1f54631..acab3620 100644
--- a/frontend/l10n/en.json
+++ b/frontend/l10n/en.json
@@ -922,6 +922,10 @@
"launch.modsNoteOrder": "A mod changes the files the game reads. Back up the saves before switching a mod on or off: a save made with a mod may not load without it. Where two mods replace the same file, the one higher in the list wins.",
"launch.modsOpen": "Open mods folder",
"launch.modsRefresh": "Refresh",
+ "launch.noResolution": "This game has no resolution setting yet.",
+ "launch.noResolution.advanced": "%@ (under Advanced settings)",
+ "launch.noResolution.one": "The closest setting is %@.",
+ "launch.noResolution.two": "The closest settings are %1$@ and %2$@.",
"launch.none": "This build carries no list of launch options.",
"launch.opt.DM_FPS_TARGET.30": "30 fps",
"launch.opt.DM_FPS_TARGET.60": "60 fps",
diff --git a/frontend/l10n/fr.json b/frontend/l10n/fr.json
index 4776aaed..c5bf0044 100644
--- a/frontend/l10n/fr.json
+++ b/frontend/l10n/fr.json
@@ -923,6 +923,10 @@
"launch.modsNoteOrder": "Un mod modifie les fichiers lus par le jeu. Sauvegardez vos parties avant d’activer ou de désactiver un mod : une sauvegarde faite avec un mod peut ne pas se charger sans lui. Quand deux mods remplacent le même fichier, celui placé le plus haut dans la liste l’emporte.",
"launch.modsOpen": "Dossier des mods",
"launch.modsRefresh": "Actualiser",
+ "launch.noResolution": "Ce jeu n’a pas encore de réglage de résolution.",
+ "launch.noResolution.advanced": "%@ (dans Réglages avancés)",
+ "launch.noResolution.one": "Le réglage le plus proche est %@.",
+ "launch.noResolution.two": "Les réglages les plus proches sont %1$@ et %2$@.",
"launch.none": "Ce build ne contient aucune liste d’options de lancement.",
"launch.opt.DM_FPS_TARGET.30": "30 i/s",
"launch.opt.DM_FPS_TARGET.60": "60 i/s",
diff --git a/frontend/l10n/it.json b/frontend/l10n/it.json
index 1c5fecde..31e127bc 100644
--- a/frontend/l10n/it.json
+++ b/frontend/l10n/it.json
@@ -923,6 +923,10 @@
"launch.modsNoteOrder": "Una mod modifica i file letti dal gioco. Fai un backup dei salvataggi prima di attivare o disattivare una mod: un salvataggio creato con una mod potrebbe non caricarsi senza. Se due mod sostituiscono lo stesso file, vince quella più in alto nell’elenco.",
"launch.modsOpen": "Apri cartella mod",
"launch.modsRefresh": "Aggiorna",
+ "launch.noResolution": "Questo gioco non ha ancora un’impostazione della risoluzione.",
+ "launch.noResolution.advanced": "%@ (in Impostazioni avanzate)",
+ "launch.noResolution.one": "L’impostazione più vicina è %@.",
+ "launch.noResolution.two": "Le impostazioni più vicine sono %1$@ e %2$@.",
"launch.none": "Questa build non contiene un elenco di opzioni di avvio.",
"launch.opt.DM_FPS_TARGET.30": "30 fps",
"launch.opt.DM_FPS_TARGET.60": "60 fps",
diff --git a/frontend/l10n/sv.json b/frontend/l10n/sv.json
index ab2b496d..b5bfa143 100644
--- a/frontend/l10n/sv.json
+++ b/frontend/l10n/sv.json
@@ -765,6 +765,10 @@
"launch.modsNoteOrder": "En modd ändrar filerna som spelet läser. Säkerhetskopiera sparfilerna innan du slår på eller av en modd: en sparfil från en modd kanske inte kan läsas utan den. När två moddar ersätter samma fil gäller den som ligger högre i listan.",
"launch.modsOpen": "Öppna moddmapp",
"launch.modsRefresh": "Uppdatera",
+ "launch.noResolution": "Det här spelet har ingen inställning för upplösning än.",
+ "launch.noResolution.advanced": "%@ (under Avancerade inställningar)",
+ "launch.noResolution.one": "Närmast kommer %@.",
+ "launch.noResolution.two": "Närmast kommer %1$@ och %2$@.",
"launch.none": "Den här versionen saknar lista över startalternativ.",
"launch.opt.DM_FPS_TARGET.30": "30 fps",
"launch.opt.DM_FPS_TARGET.60": "60 fps",
diff --git a/frontend/l10n/zh.json b/frontend/l10n/zh.json
index 77b3ebea..c85a136d 100644
--- a/frontend/l10n/zh.json
+++ b/frontend/l10n/zh.json
@@ -923,6 +923,10 @@
"launch.modsNoteOrder": "模组会改变游戏读取的文件。开关模组前请先备份存档:用模组存的档,去掉模组后可能无法读取。两个模组替换同一个文件时,列表中靠上的生效。",
"launch.modsOpen": "打开模组文件夹",
"launch.modsRefresh": "刷新",
+ "launch.noResolution": "这个游戏暂时还没有分辨率设置。",
+ "launch.noResolution.advanced": "%@(在高级设置中)",
+ "launch.noResolution.one": "最接近的设置是%@。",
+ "launch.noResolution.two": "最接近的设置是%1$@和%2$@。",
"launch.none": "这个版本没有附带启动选项列表。",
"launch.opt.DM_FPS_TARGET.30": "30 fps",
"launch.opt.DM_FPS_TARGET.60": "60 fps",