Skip to content

Free fork of NotProton: Windows Steam games in Mac Steam, on CodeWeavers' Wine and Apple's Game Porting Toolkit

feat(update): Refresh and every launch bring Steam and the engines up to date

raymondchins7906bacf9502
diff --git a/app/Sources/BridgeplayApp/Resources/Localization/Localizable.xcstrings b/app/Sources/BridgeplayApp/Resources/Localization/Localizable.xcstrings
index 130f826..74f8a7b 100644
--- a/app/Sources/BridgeplayApp/Resources/Localization/Localizable.xcstrings
+++ b/app/Sources/BridgeplayApp/Resources/Localization/Localizable.xcstrings
@@ -2287,50 +2287,50 @@
}
}
},
- "Check installed files" : {
+ "Check for a Bridgeplay update and bring Steam and the engines up to date" : {
"localizations" : {
"it" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Controllo dei file installati"
+ "value" : "Cerca un aggiornamento di Bridgeplay e aggiorna Steam e i motori"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
- "value" : "检查已安装的文件"
+ "value" : "检查 Bridgeplay 更新,并将 Steam 和引擎更新到最新"
}
}
}
},
- "Check permissions, make sure your user owns the folder." : {
+ "Check installed files" : {
"localizations" : {
"it" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Controlla i permessi: la cartella deve appartenere al tuo utente."
+ "value" : "Controllo dei file installati"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
- "value" : "请检查权限,确认当前用户拥有该文件夹。"
+ "value" : "检查已安装的文件"
}
}
}
},
- "Check this Mac's setup again and look for a Bridgeplay update" : {
+ "Check permissions, make sure your user owns the folder." : {
"localizations" : {
"it" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Ricontrolla la configurazione di questo Mac e cerca un aggiornamento di Bridgeplay"
+ "value" : "Controlla i permessi: la cartella deve appartenere al tuo utente."
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
- "value" : "重新检查这台 Mac 的设置,并检查 Bridgeplay 更新"
+ "value" : "请检查权限,确认当前用户拥有该文件夹。"
}
}
}
diff --git a/app/Sources/BridgeplayApp/Support/PostUpdateRefresh.swift b/app/Sources/BridgeplayApp/Support/PostUpdateRefresh.swift
index a3f0e2a..e2ff48f 100644
--- a/app/Sources/BridgeplayApp/Support/PostUpdateRefresh.swift
+++ b/app/Sources/BridgeplayApp/Support/PostUpdateRefresh.swift
@@ -81,5 +81,7 @@ enum PostUpdateRefresh {
if let build { defaults.set(build, forKey: lastBuildKey) }
await status.requestInstall(unattended: true)
}
+ // Engines whose files this build rebuilt or re-pinned follow, under the same rule.
+ if decision != .wait { await status.updateEverything(includingSteamPatch: false) }
}
}
diff --git a/app/Sources/BridgeplayApp/Support/UpdateEverything.swift b/app/Sources/BridgeplayApp/Support/UpdateEverything.swift
new file mode 100644
index 0000000..96cf13b
--- /dev/null
+++ b/app/Sources/BridgeplayApp/Support/UpdateEverything.swift
@@ -0,0 +1,65 @@
+import Foundation
+
+// Brings everything this Bridgeplay ships up to date in one go: the patch inside Steam, then
+// every engine that is unpacked but no longer matches this build's pins (a release that
+// rebuilt a Wine file or moved to a newer runtime). It uses the Status page's own buttons, so
+// it refuses what they refuse, and it does nothing while Steam, a game or a Wine tool runs;
+// the Status rows keep offering the update until then. An engine the user never set up is
+// left alone.
+extension SystemStatus {
+
+ enum UpdatePlan: Equatable, Sendable {
+ case steamPatch
+ case winecx
+ case winehq
+ }
+
+ nonisolated static func updatePlan(
+ steam: SteamDeployment,
+ hasRunner: Bool,
+ winecx: FreeEngineState,
+ winehq: FreeEngineState
+ ) -> [UpdatePlan] {
+ var plan: [UpdatePlan] = []
+ if hasRunner, case .outdated(let deployed, let bundled) = steam, !deployed.isEmpty, deployed != bundled {
+ plan.append(.steamPatch)
+ }
+ if winecx == .outdated { plan.append(.winecx) }
+ if winehq == .outdated { plan.append(.winehq) }
+ return plan
+ }
+
+ // The launch passes includingSteamPatch false: PostUpdateRefresh owns that, with its
+ // stricter rule about which version may re-patch Steam unasked.
+ func updateEverything(includingSteamPatch: Bool = true) async {
+ guard canInstall, let snapshot else { return }
+ let plan = Self.updatePlan(
+ steam: snapshot.steam,
+ hasRunner: snapshot.runner != .none,
+ winecx: freeEngineState(FreeEngineWinecx.current.build),
+ winehq: freeEngineState(FreeEngine.current.build)
+ ).filter { includingSteamPatch || $0 != .steamPatch }
+ guard !plan.isEmpty else { return }
+
+ // pgrep and ps can take seconds, so neither runs on the main actor.
+ let busy = await Task.detached(priority: .utility) {
+ SteamBundle.isRunning || RunnerStore.clonedBuilds().contains {
+ RunnerInstaller.isRunning(from: SupportPaths.runnerRoot(forBuild: $0))
+ }
+ }.value
+ if snapshot.steamRunning || busy {
+ AppLog.note("update: \(plan) waiting for Steam and games to close")
+ return
+ }
+
+ AppLog.note("update: \(plan)")
+ for step in plan {
+ guard canInstall else { return }
+ switch step {
+ case .steamPatch: await requestInstall(unattended: true)
+ case .winecx: await installWinecxEngine()
+ case .winehq: await installFreeEngine()
+ }
+ }
+ }
+}
diff --git a/app/Sources/BridgeplayApp/Views/StatusView.swift b/app/Sources/BridgeplayApp/Views/StatusView.swift
index f13b599..c7e4fe0 100644
--- a/app/Sources/BridgeplayApp/Views/StatusView.swift
+++ b/app/Sources/BridgeplayApp/Views/StatusView.swift
@@ -462,9 +462,12 @@ struct StatusView: View {
private var refreshButton: some View {
Button("Refresh", systemImage: "arrow.clockwise") {
AppUpdater.shared.check()
- Task { await status.refresh() }
+ Task {
+ await status.refresh()
+ await status.updateEverything()
+ }
}
- .help(String(localized: "Check this Mac's setup again and look for a Bridgeplay update"))
+ .help(String(localized: "Check for a Bridgeplay update and bring Steam and the engines up to date"))
.disabled(!status.isIdle)
}
diff --git a/app/Tests/BridgeplayAppTests/UpdateEverythingTests.swift b/app/Tests/BridgeplayAppTests/UpdateEverythingTests.swift
new file mode 100644
index 0000000..22a81e1
--- /dev/null
+++ b/app/Tests/BridgeplayAppTests/UpdateEverythingTests.swift
@@ -0,0 +1,36 @@
+import Testing
+
+@testable import BridgeplayApp
+
+@Suite("Update everything")
+struct UpdateEverythingTests {
+
+ @Test("An older patch in Steam and outdated engines are all planned, in that order")
+ func everythingOutdated() {
+ let plan = SystemStatus.updatePlan(
+ steam: .outdated(deployed: "3.0.0", bundled: "3.0.1"), hasRunner: true,
+ winecx: .outdated, winehq: .outdated)
+ #expect(plan == [.steamPatch, .winecx, .winehq])
+ }
+
+ @Test("Engines the user never set up, or that are current, are left alone")
+ func onlyOutdatedEngines() {
+ let plan = SystemStatus.updatePlan(
+ steam: .installed(version: "3.0.1"), hasRunner: true, winecx: .outdated, winehq: .missing)
+ #expect(plan == [.winecx])
+ #expect(SystemStatus.updatePlan(
+ steam: .installed(version: "3.0.1"), hasRunner: true, winecx: .current, winehq: .missing).isEmpty)
+ }
+
+ @Test("Steam is not patched without a compatibility tool, or when the recorded version is unknown")
+ func steamPatchNeedsRunnerAndVersion() {
+ #expect(SystemStatus.updatePlan(
+ steam: .outdated(deployed: "3.0.0", bundled: "3.0.1"), hasRunner: false,
+ winecx: .current, winehq: .missing).isEmpty)
+ #expect(SystemStatus.updatePlan(
+ steam: .outdated(deployed: "", bundled: "3.0.1"), hasRunner: true,
+ winecx: .current, winehq: .missing).isEmpty)
+ #expect(SystemStatus.updatePlan(
+ steam: .notInstalled, hasRunner: true, winecx: .current, winehq: .missing).isEmpty)
+ }
+}