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: Game language is a menu, like the iOS shell
v0lumehi7f24d8724f77
diff --git a/frontend/Sources/NSPortBuilder/LaunchOptionsView.swift b/frontend/Sources/NSPortBuilder/LaunchOptionsView.swiftindex 6b6c9346..9346ee48 100644--- a/frontend/Sources/NSPortBuilder/LaunchOptionsView.swift+++ b/frontend/Sources/NSPortBuilder/LaunchOptionsView.swift@@ -207,7 +207,7 @@ struct LaunchOptionsView: View {switch s.kind {case "choice":let options = (s.options ?? []).map { (value: $0[0], label: $0.count > 1 ? $0[1] : $0[0]) }- if options.count <= 3 {+ if LaunchControl.isSegmented(env: s.env, labels: options.map(\.label)) {LauncherSegmented(options: options, selection: value) { set(s, $0) }} else {LauncherDropdown(options: options, selection: value, label: s.label, fill: true) { set(s, $0) }diff --git a/frontend/Sources/NSPortBuilder/LauncherStyles.swift b/frontend/Sources/NSPortBuilder/LauncherStyles.swiftindex 4179e864..5d47c32e 100644--- a/frontend/Sources/NSPortBuilder/LauncherStyles.swift+++ b/frontend/Sources/NSPortBuilder/LauncherStyles.swift@@ -106,6 +106,16 @@ struct LauncherSwitchStyle: ToggleStyle {/// in one column whatever their labels.enum LaunchControl {static let width: CGFloat = 220++ /// Characters the segments of one control share: a segment of 12.5 pt text, 24 pt of padding in 220 pt, takes about 10 with two+ /// choices and 6 with three.+ static let segmentedCharacters = 20++ /// Segmented for two or three short labels, a menu otherwise. The game's language (DM_LANG) is always a menu, as on the iPhone.+ static func isSegmented(env: String, labels: [String]) -> Bool {+ guard env != "DM_LANG", labels.count <= 3 else { return false }+ return labels.allSatisfy { $0.count <= segmentedCharacters / max(labels.count, 1) }+ }}/// Two or three choices side by side; the chosen one is a cream pill. Each choice takes an equal share of the widthdiff --git a/frontend/Tests/NSPortBuilderTests/LaunchOptionsTests.swift b/frontend/Tests/NSPortBuilderTests/LaunchOptionsTests.swiftindex 7823be3f..84340b42 100644--- a/frontend/Tests/NSPortBuilderTests/LaunchOptionsTests.swift+++ b/frontend/Tests/NSPortBuilderTests/LaunchOptionsTests.swift@@ -77,4 +77,19 @@ final class LaunchOptionsTests: XCTestCase {folder.appendingPathComponent("C Atmosphere/atmosphere/contents/01007EF00011E000/romfs").path].joined(separator: ":"),"the list's order (higher wins), and a code-only mod left out")}++ func testShortChoicesAreSegmentedAndTheGameLanguageIsAlwaysAMenu() {+ func segmented(_ env: String, _ labels: [String]) -> Bool { LaunchControl.isSegmented(env: env, labels: labels) }+ XCTAssertTrue(segmented("DM_FPS_TARGET", ["30 fps", "60 fps"]))+ XCTAssertTrue(segmented("DM_OPMODE", ["Docked", "Handheld"]))+ XCTAssertTrue(segmented("DM_FULLSCREEN", ["Window", "Fullscreen"]))+ XCTAssertTrue(segmented("DM_PRESENT_UPSCALE", ["Standard", "MetalFX"]))+ XCTAssertTrue(segmented("DM_FULLSCREEN", ["Fenster", "Vollbild"]))+ XCTAssertTrue(segmented("DM_FULLSCREEN", ["窗口", "全屏"]))+ XCTAssertFalse(segmented("DM_LANG", ["English", "Japanese"]), "the game language is a menu, as on the iPhone")+ XCTAssertFalse(segmented("DM_LANG", ["en", "ja", "de"]))+ XCTAssertFalse(segmented("DM_X", ["American English", "Japanese"]), "a label that does not fit its segment")+ 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")+ }}