Skip to content

Run Windows games on Apple Silicon — free, open source, with an open compatibility database that tells you what actually works.

Whether an Epic Mac install removes the Windows copy is decided in HighballKit, and tested

Gabe31159570babc
diff --git a/Sources/HighballApp/AppState.swift b/Sources/HighballApp/AppState.swift
index 0b26dda..d97bc54 100644
--- a/Sources/HighballApp/AppState.swift
+++ b/Sources/HighballApp/AppState.swift
@@ -3483,17 +3483,23 @@ final class AppState {
let store = epicStore
let checkThenRemoveWindows: @MainActor () async throws -> Void = { [self] in
stage = L("Asking Epic about the Mac version")
- let hasMac: Bool
+ let hasMac: Bool?
do {
hasMac = try await Task.detached { try store.hasMacBuild(app) }.value
} catch {
appendLog("\(item.title): legendary info --platform Mac failed: \(error)")
- throw HighballError.failed(L("Highball could not ask Epic whether a Mac build of this game is there to download, so nothing was changed. Check your connection, then try again."))
+ hasMac = nil
}
- guard hasMac else {
+ switch EpicStore.MacInstallStep.after(hasMacBuild: hasMac, replacingWindows: replacingWindows) {
+ case .couldNotAsk:
+ throw HighballError.failed(L("Highball could not ask Epic whether a Mac build of this game is there to download, so nothing was changed. Check your connection, then try again."))
+ case .noMacBuild:
throw HighballError.failed(L("Epic lists a Mac version of this game, but has no Mac build to download for your account, so nothing was changed."))
+ case .install:
+ return
+ case .removeWindowsThenInstall:
+ break
}
- guard replacingWindows else { return }
stage = String(format: L("Removing the Windows version of %@"), item.title)
let log: @Sendable (String) -> Void = { line in Task { @MainActor in self.appendLog(line) } }
let status: Int32 = try await Task.detached { try store.uninstall(app, onLine: log) }.value
diff --git a/Sources/HighballKit/EpicStore.swift b/Sources/HighballKit/EpicStore.swift
index a439254..5e1f05a 100644
--- a/Sources/HighballKit/EpicStore.swift
+++ b/Sources/HighballKit/EpicStore.swift
@@ -260,6 +260,19 @@ public struct EpicStore: Sendable {
return versions[platform] != nil
}
+ /// What a Mac install does once `hasMacBuild` has answered: nil when it could not ask. Stop
+ /// with nothing changed unless Epic named a Mac build, and only then remove the Windows build
+ /// first when switching from it, so a missing build never costs the Windows copy.
+ public enum MacInstallStep: Equatable, Sendable {
+ case couldNotAsk, noMacBuild, install, removeWindowsThenInstall
+
+ public static func after(hasMacBuild: Bool?, replacingWindows: Bool) -> MacInstallStep {
+ guard let hasMacBuild else { return .couldNotAsk }
+ guard hasMacBuild else { return .noMacBuild }
+ return replacingWindows ? .removeWindowsThenInstall : .install
+ }
+ }
+
/// Installs a game's Windows build into the bottle at drive_c/Games/<folder>.
@discardableResult
public func install(_ appName: String, into bottle: Bottle, control: LegendaryControl? = nil,
diff --git a/Tests/HighballKitTests/StoreMacVersionTests.swift b/Tests/HighballKitTests/StoreMacVersionTests.swift
index 49d9715..f99dc07 100644
--- a/Tests/HighballKitTests/StoreMacVersionTests.swift
+++ b/Tests/HighballKitTests/StoreMacVersionTests.swift
@@ -250,6 +250,16 @@ final class EpicMacBuildTests: XCTestCase {
XCTAssertFalse(EpicStore.listsBuild(Data("No game information available.".utf8), platform: "Mac"))
}
+ /// The Windows copy goes only once Epic named a Mac build, and only when switching from it.
+ func testTheWindowsCopyGoesOnlyOnceEpicNamedAMacBuild() {
+ typealias Step = EpicStore.MacInstallStep
+ XCTAssertEqual(Step.after(hasMacBuild: nil, replacingWindows: true), .couldNotAsk)
+ XCTAssertEqual(Step.after(hasMacBuild: false, replacingWindows: true), .noMacBuild)
+ XCTAssertEqual(Step.after(hasMacBuild: false, replacingWindows: false), .noMacBuild)
+ XCTAssertEqual(Step.after(hasMacBuild: true, replacingWindows: false), .install)
+ XCTAssertEqual(Step.after(hasMacBuild: true, replacingWindows: true), .removeWindowsThenInstall)
+ }
+
func testTheFallBackToWindowsIsSeen() {
XCTAssertTrue(EpicStore.fellBackToWindows(#"[cli] WARNING: App has no asset for platform "Mac", falling back to "Windows"."#))
XCTAssertFalse(EpicStore.fellBackToWindows(#"[cli] INFO: Preparing download for "Garlic"..."#))