Free fork of NotProton: Windows Steam games in Mac Steam, on CodeWeavers' Wine and Apple's Game Porting Toolkit
Swift apple-silicond3dmetaldxmtdxvkgame-porting-toolkitgptkmac-gamingmacosmetalfxrosetta-2steamsteam-playwinewinecx
fix(setup): say Rosetta is still needed when the password window is closed (#1660)
Raymond Chin39602af69928
diff --git a/app/Sources/BridgeplayApp/Model/SetupChecks.swift b/app/Sources/BridgeplayApp/Model/SetupChecks.swiftindex 6904694..1d58f44 100644--- a/app/Sources/BridgeplayApp/Model/SetupChecks.swift+++ b/app/Sources/BridgeplayApp/Model/SetupChecks.swift@@ -50,8 +50,8 @@ enum SetupChecks {// most people, so the two common cases get plain sentences.static func rosettaFailure(_ error: Error) -> String {let text = error.localizedDescription- if text.contains("(-128)") || text.localizedCaseInsensitiveContains("user canceled") {- return String(localized: "Rosetta wasn't installed because the password window was closed. Press Install to try again.")+ if rosettaCancelled(error) {+ return String(localized: "Rosetta is still needed to run Windows games. The password window was closed, so it wasn't installed. Press Install to try again.")}if text.contains("(-60005)") || text.contains("(-60007)") {return String(localized: "Rosetta wasn't installed because macOS didn't accept the password. Use the name and password of an administrator of this Mac.")@@ -59,6 +59,12 @@ enum SetupChecks {return String(localized: "Rosetta wasn't installed. Check your internet connection and try again.")}+ // Closing the password window is a choice, not a failure to report.+ static func rosettaCancelled(_ error: Error) -> Bool {+ let text = error.localizedDescription+ return text.contains("(-128)") || text.localizedCaseInsensitiveContains("user canceled")+ }+static var loginUsers: URL {SupportPaths.Steam.userData.appending(path: "config/loginusers.vdf")}diff --git a/app/Sources/BridgeplayApp/Resources/Localization/Localizable.xcstrings b/app/Sources/BridgeplayApp/Resources/Localization/Localizable.xcstringsindex d8030a3..3a4028e 100644--- a/app/Sources/BridgeplayApp/Resources/Localization/Localizable.xcstrings+++ b/app/Sources/BridgeplayApp/Resources/Localization/Localizable.xcstrings@@ -8530,34 +8530,34 @@}}},- "Rosetta wasn't installed because macOS didn't accept the password. Use the name and password of an administrator of this Mac." : {+ "Rosetta is still needed to run Windows games. The password window was closed, so it wasn't installed. Press Install to try again." : {"localizations" : {"it" : {"stringUnit" : {"state" : "translated",- "value" : "Rosetta non è stato installato perché macOS non ha accettato la password. Usa nome e password di un amministratore di questo Mac."+ "value" : "Rosetta serve ancora per avviare i giochi Windows. La finestra della password è stata chiusa, quindi non è stato installato. Premi Installa per riprovare."}},"zh-Hans" : {"stringUnit" : {"state" : "translated",- "value" : "由于 macOS 未接受该密码,Rosetta 未能安装。请使用这台 Mac 管理员的名称和密码。"+ "value" : "运行 Windows 游戏仍需要 Rosetta。密码窗口已关闭,因此未能安装。请点击“安装”重试。"}}}},- "Rosetta wasn't installed because the password window was closed. Press Install to try again." : {+ "Rosetta wasn't installed because macOS didn't accept the password. Use the name and password of an administrator of this Mac." : {"localizations" : {"it" : {"stringUnit" : {"state" : "translated",- "value" : "Rosetta non è stato installato perché la finestra della password è stata chiusa. Premi Installa per riprovare."+ "value" : "Rosetta non è stato installato perché macOS non ha accettato la password. Usa nome e password di un amministratore di questo Mac."}},"zh-Hans" : {"stringUnit" : {"state" : "translated",- "value" : "由于密码窗口已关闭,Rosetta 未能安装。请点击“安装”重试。"+ "value" : "由于 macOS 未接受该密码,Rosetta 未能安装。请使用这台 Mac 管理员的名称和密码。"}}}diff --git a/app/Sources/BridgeplayApp/SetupAssistant.swift b/app/Sources/BridgeplayApp/SetupAssistant.swiftindex f89ac9b..d621cbd 100644--- a/app/Sources/BridgeplayApp/SetupAssistant.swift+++ b/app/Sources/BridgeplayApp/SetupAssistant.swift@@ -42,6 +42,8 @@ final class SetupAssistant {// Macvar rosettaInstalled = SetupChecks.rosettaInstalled()+ // Set when the password window was closed; the Rosetta row says so in place of an error.+ var rosettaNote: String?let appleSilicon = SetupChecks.isAppleSiliconlet macOSSupported = SetupChecks.macOSVersion.majorVersion >= SetupChecks.minimumMacOSlet freeBytes = SetupChecks.freeBytes()@@ -184,12 +186,18 @@ final class SetupAssistant {func installRosetta() async {isWorking = truedefer { isWorking = false }+ rosettaNote = nil+ message = nilif isPreview { await pretend(); rosettaInstalled = true; return }do {try await Task.detached(priority: .userInitiated) { try SetupChecks.installRosetta() }.value} catch {AppLog.note("setup: Rosetta install failed: \(error.localizedDescription)")- message = SetupChecks.rosettaFailure(error)+ if SetupChecks.rosettaCancelled(error) {+ rosettaNote = SetupChecks.rosettaFailure(error)+ } else {+ message = SetupChecks.rosettaFailure(error)+ }}rosettaInstalled = SetupChecks.rosettaInstalled()}diff --git a/app/Sources/BridgeplayApp/Views/SetupAssistantView.swift b/app/Sources/BridgeplayApp/Views/SetupAssistantView.swiftindex e908f7b..14b0b2b 100644--- a/app/Sources/BridgeplayApp/Views/SetupAssistantView.swift+++ b/app/Sources/BridgeplayApp/Views/SetupAssistantView.swift@@ -178,7 +178,7 @@ struct SetupAssistantView: View {tone: model.hasSpace ? .ok : .bad))SetupHairline()checked(3, StatusRow(title: String(localized: "Rosetta 2"),- value: model.rosettaInstalled ? String(localized: "Installed.") : String(localized: "Apple's translator for Windows games. Asks for your Mac password."),+ value: model.rosettaInstalled ? String(localized: "Installed.") : model.rosettaNote ?? String(localized: "Apple's translator for Windows games. Asks for your Mac password."),tone: model.rosettaInstalled ? .ok : .warning,action: model.rosettaInstalled ? nil : StatusAction(label: String(localized: "Install"), isProminent: true, isEnabled: !model.isWorkingdiff --git a/app/Tests/BridgeplayAppTests/SetupAssistantTests.swift b/app/Tests/BridgeplayAppTests/SetupAssistantTests.swiftindex 9aff72c..fc5929b 100644--- a/app/Tests/BridgeplayAppTests/SetupAssistantTests.swift+++ b/app/Tests/BridgeplayAppTests/SetupAssistantTests.swift@@ -67,6 +67,17 @@ struct SetupAssistantTests {#expect(SetupChecks.rosettaInstalled(runtime: runtime))}+ @Test("Retrying Rosetta install clears the old error card, not just the cancellation note")+ @MainActor+ func installRosettaClearsStaleMessage() async {+ let model = SetupAssistant(preview: .thisMac)+ // Mimics the card left over from an earlier wrong-password attempt.+ model.message = "Rosetta wasn't installed because macOS didn't accept the password. Use the name and password of an administrator of this Mac."+ await model.installRosetta()+ #expect(model.message == nil)+ #expect(model.rosettaNote == nil)+ }+@Test("The assistant stays away once the user finished or dismissed it")@MainActorfunc finishedFlag() throws {@@ -318,9 +329,12 @@ struct SetupChecksTests {@Test("Rosetta failures read as plain sentences")func rosettaMessages() {let cancelled = CommandFailure(command: "osascript", status: 1, stderr: "0:120: execution error: User canceled. (-128)")- #expect(SetupChecks.rosettaFailure(cancelled).contains("password window was closed"))+ #expect(SetupChecks.rosettaCancelled(cancelled))+ #expect(SetupChecks.rosettaFailure(cancelled).contains("still needed"))+ #expect(SetupChecks.rosettaFailure(cancelled).contains("Press Install"))let denied = CommandFailure(command: "osascript", status: 1, stderr: "execution error: The administrator user name or password was incorrect. (-60005)")#expect(SetupChecks.rosettaFailure(denied).contains("administrator"))+ #expect(!SetupChecks.rosettaCancelled(denied))let other = CommandFailure(command: "osascript", status: 1, stderr: "softwareupdate: network down")let message = SetupChecks.rosettaFailure(other)#expect(!message.contains("osascript"))