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: every slider has the same length

v0lumehi3403e0b4fa3c
diff --git a/frontend/Sources/NSPortBuilder/LaunchOptionsView.swift b/frontend/Sources/NSPortBuilder/LaunchOptionsView.swift
index 76552903..8ffe5ec8 100644
--- a/frontend/Sources/NSPortBuilder/LaunchOptionsView.swift
+++ b/frontend/Sources/NSPortBuilder/LaunchOptionsView.swift
@@ -223,7 +223,7 @@ struct LaunchOptionsView: View {
}
Text(pixels ?? "\(Int(((Double(value) ?? 0) * 100).rounded()))%")
.font(.manrope(13, .semibold)).monospacedDigit().foregroundStyle(.secondary)
- .frame(width: pixels == nil ? 44 : 72, alignment: .trailing)
+ .frame(width: LaunchControl.valueWidth, alignment: .trailing)
ZStack {
if Double(value) != Double(s.def) {
Button { set(s, s.def) } label: {
diff --git a/frontend/Sources/NSPortBuilder/LauncherStyles.swift b/frontend/Sources/NSPortBuilder/LauncherStyles.swift
index b27596d5..0c19c328 100644
--- a/frontend/Sources/NSPortBuilder/LauncherStyles.swift
+++ b/frontend/Sources/NSPortBuilder/LauncherStyles.swift
@@ -235,6 +235,9 @@ struct LauncherHeroActionLabel: View {
/// in one column whatever their labels.
enum LaunchControl {
static let width: CGFloat = 220
+ /// A slider's value, in percent or in pixels: wide enough for "1920×1080" in 13 pt Manrope semibold with monospaced digits
+ /// (71 pt), so every slider of the sheet is equally long and the reset arrows line up.
+ static let valueWidth: CGFloat = 72
/// 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.
diff --git a/frontend/Tests/NSPortBuilderTests/LauncherControlWidthTests.swift b/frontend/Tests/NSPortBuilderTests/LauncherControlWidthTests.swift
index dbfa9411..938b8fa5 100644
--- a/frontend/Tests/NSPortBuilderTests/LauncherControlWidthTests.swift
+++ b/frontend/Tests/NSPortBuilderTests/LauncherControlWidthTests.swift
@@ -238,6 +238,15 @@ final class LauncherControlWidthTests: XCTestCase {
// MARK: Launch options
+ /// Every slider's value has one width, so the sliders are equally long: the widest value, four digits by four in pixels or
+ /// three in percent, fits it on one line.
+ @MainActor func testTheWidestSliderValueFitsItsColumn() {
+ for value in ["8888×8888", "888%"] {
+ let width = NSHostingView(rootView: Text(value).font(.manrope(13, .semibold)).monospacedDigit().fixedSize()).fittingSize.width
+ XCTAssertLessThanOrEqual(width, LaunchControl.valueWidth, value)
+ }
+ }
+
/// 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 {