Skip to content

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

Epic Mac versions install and play from Highball

Gabe6fd9b6592d04
diff --git a/Sources/HighballApp/AppState.swift b/Sources/HighballApp/AppState.swift
index f387761..d2104c1 100644
--- a/Sources/HighballApp/AppState.swift
+++ b/Sources/HighballApp/AppState.swift
@@ -296,6 +296,7 @@ final class AppState {
epicOwned: epicOwned, epicInstalls: epicInstalls,
gogGames: gogGames, gogInstalledByBottle: gogInstalledByBottle, gogLaunchChoice: gogSettings.launchChoice,
gogMacInstalled: Set(gogMacInstalled.keys),
+ epicMacInstalled: Set(epicMacInstalls.keys),
battleNetByBottle: battleNetByBottle,
plays: libraryPlays, defaultBottle: defaultBottle?.name,
pinExists: { bottle, pin in
@@ -388,6 +389,7 @@ final class AppState {
/// Starts the native build through Steam for Mac.
func playOnMac(_ item: LibraryItem) {
if item.source == .gog { gogPlayMac(item); return }
+ if item.source == .epic { epicPlayMac(item); return }
guard let appid = item.steamAppID else { return }
recordPlay(item)
_ = openInSteamForMac(URL(string: "steam://run/\(appid)")!)
@@ -397,6 +399,7 @@ final class AppState {
/// download page for Steam for Mac.
func installOnMac(_ item: LibraryItem) {
if item.source == .gog { gogInstallMac(item); return }
+ if item.source == .epic { epicInstallMac(item); return }
guard let appid = item.steamAppID else { return }
if !openInSteamForMac(URL(string: "steam://install/\(appid)")!) {
NSWorkspace.shared.open(URL(string: "https://store.steampowered.com/about/")!)
@@ -433,6 +436,9 @@ final class AppState {
if item.source == .gog {
return item.installedOnMac && item.gogID.flatMap { gogMacInstalled[$0] }?.arch != .only32Bit
}
+ if item.source == .epic {
+ return item.installedOnMac && item.epicAppName.flatMap { epicMacArch[$0] } != .only32Bit
+ }
return MacSteamBuild.leads(entry: gameDB.entry(for: item), installedOnMac: item.installedOnMac,
appInfo: item.steamAppID.flatMap { macAppInfoByAppID[$0] })
}
@@ -1113,10 +1119,11 @@ final class AppState {
await MainActor.run { self.epicFetchInFlight = false }
return
}
+ let archs = Self.macArchs(installed)
await MainActor.run { [weak self] in
guard let self else { return }
self.epicFetchInFlight = false
- guard self.applyEpicInstalls(installed) else { return }
+ guard self.applyEpicInstalls(installed, archs: archs) else { return }
self.forgetProgramExecutables()
self.rebuildLibrary()
}
@@ -2119,12 +2126,13 @@ final class AppState {
}
}
- /// The native build's place on disk: a GOG Mac build's app, or Steam for Mac's install
- /// folder. Nil when no Mac build is installed.
+ /// The native build's place on disk: a GOG Mac build's app, the folder legendary put an Epic
+ /// Mac build in, or Steam for Mac's install folder. Nil when no Mac build is installed.
func macFolder(for item: LibraryItem) -> URL? {
guard item.installedOnMac else { return nil }
switch item.source {
case .gog: return item.gogID.flatMap { gogMacInstalled[$0] }.map { $0.app ?? $0.folder }
+ case .epic: return item.epicAppName.flatMap { epicMacInstalls[$0] }.map { URL(fileURLWithPath: $0) }
case .steam: return macSteamGames.first { $0.appid == item.steamAppID }?.installFolder
default: return nil
}
@@ -3306,7 +3314,7 @@ final class AppState {
func epicRefresh() {
epicSignedIn = epicStore.isAuthenticated
- guard epicSignedIn else { epicOwned = []; epicInstalls = [:]; epicInstallRecords = [:]; return }
+ guard epicSignedIn else { epicOwned = []; epicInstalls = [:]; epicMacInstalls = [:]; epicInstallRecords = [:]; epicMacArch = [:]; return }
guard !epicFetchInFlight else { return }
epicFetchInFlight = true
epicLoading = epicOwned.isEmpty
@@ -3315,10 +3323,11 @@ final class AppState {
// saved last time, stays, rather than the library emptying.
let owned = try? store.ownedGames()
let installed = try? store.installedGames()
+ let archs = installed.map(Self.macArchs)
await MainActor.run { [weak self] in
guard let self else { return }
if let owned { self.epicOwned = owned.sorted { $0.app_title < $1.app_title } }
- if let installed { _ = self.applyEpicInstalls(installed) }
+ if let installed, let archs { _ = self.applyEpicInstalls(installed, archs: archs) }
self.epicLoading = false
self.epicFetchInFlight = false
self.rebuildLibrary() // Epic results arrive after refresh(); fold them in
@@ -3368,9 +3377,20 @@ final class AppState {
@ObservationIgnored private var epicInstallControl: LegendaryControl?
func epicInstall(_ game: EpicStore.Game, in bottle: Bottle) {
+ epicDownload(title: "Installing \(game.app_title)") { store, control, onLine in
+ try store.install(game.app_name, into: bottle, control: control, onLine: onLine)
+ }
+ }
+
+ /// One legendary download under the strip (an install of either build): progress, Stop as a
+ /// Ctrl-C that keeps the progress, and legendary's refusals turned into sentences. `before`
+ /// runs first inside the same task (the Windows build's removal when switching to the Mac one).
+ private func epicDownload(title: String, before: (@MainActor () async throws -> Void)? = nil,
+ install: @escaping @Sendable (EpicStore, LegendaryControl, @escaping @Sendable (String) -> Void) throws -> Int32) {
let control = LegendaryControl()
- runBusy("Installing \(game.app_title)", expected: L("a large download; you can leave it running"),
+ runBusy(title, expected: L("a large download; you can leave it running"),
stop: .cancelTask(label: L("Stop")), cleanup: { [weak self] in self?.epicInstallControl = nil }) { [self] in
+ try await before?()
epicInstallControl = control
let store = epicStore
epicDownloadTotal = nil
@@ -3380,7 +3400,7 @@ final class AppState {
// keeps the download's progress for the next Install.
let status = try await withTaskCancellationHandler {
try await Task.detached {
- try store.install(game.app_name, into: bottle, control: control) { line in
+ try install(store, control) { line in
if EpicStore.refusedForLock(line) { refused.withLock { $0 = true } }
if let why = EpicStore.installFailure(line) { failure.withLock { if $0 == nil { $0 = why } } }
Task { @MainActor in self.appendLog(line); self.reportEpicDownload(line) }
@@ -3399,18 +3419,135 @@ final class AppState {
}
}
+ /// Epic games whose Mac build legendary installed, by app name, with where (one build per
+ /// game in legendary: such a game has no Windows install).
+ var epicMacInstalls: [String: String] = [:]
/// legendary's install records by app name (installed size, save folder), for the game page.
@ObservationIgnored var epicInstallRecords: [String: EpicStore.InstalledGame] = [:]
+ /// What each installed Epic Mac build is built for, read once per refresh, not per render.
+ var epicMacArch: [String: MacBinaryArch] = [:]
- /// Keeps legendary's records and the install map read from them. Whether the library changed.
- private func applyEpicInstalls(_ installed: [EpicStore.InstalledGame]) -> Bool {
- let installs = EpicStore.installMap(installed)
+ /// Splits legendary's records into the Windows and Mac builds (one per game). Whether the
+ /// library changed.
+ private func applyEpicInstalls(_ installed: [EpicStore.InstalledGame], archs: [String: MacBinaryArch]) -> Bool {
+ let windows = EpicStore.installMap(installed.filter { !$0.isMac }), mac = EpicStore.installMap(installed.filter(\.isMac))
epicInstallRecords = Dictionary(installed.map { ($0.app_name, $0) }, uniquingKeysWith: { a, _ in a })
- guard installs != epicInstalls else { return false }
- epicInstalls = installs
+ guard windows != epicInstalls || mac != epicMacInstalls || archs != epicMacArch else { return false }
+ epicInstalls = windows; epicMacInstalls = mac; epicMacArch = archs
return true
}
+ nonisolated private static func macArchs(_ installed: [EpicStore.InstalledGame]) -> [String: MacBinaryArch] {
+ Dictionary(installed.filter(\.isMac).compactMap { record in
+ record.install_path.map { (record.app_name, MacBinaryArch.ofApp(at: URL(fileURLWithPath: $0))) }
+ }, uniquingKeysWith: { a, _ in a })
+ }
+
+ /// The Windows build is installed and legendary keeps one build per game: switching asks
+ /// first (the Windows copy is removed, its settings stay).
+ var pendingEpicMacSwitch: LibraryItem?
+ /// An Epic Mac build the player asked to remove: asked first, it is a long download back.
+ var pendingEpicMacUninstall: LibraryItem?
+ /// An Epic game whose installed Mac build does not run (32-bit), switching to the Windows one:
+ /// asked first, as the Mac build is removed.
+ var pendingEpicWindowsSwitch: LibraryItem?
+
+ /// Removes an Epic game's Mac build through legendary, then installs the Windows one in the
+ /// default environment: legendary keeps one build per game.
+ func epicSwitchToWindows(_ item: LibraryItem) {
+ guard let app = item.epicAppName, let game = epicOwned.first(where: { $0.app_name == app }) else { return }
+ guard let bottle = defaultBottle else {
+ fail(HighballError.failed(L("Make an environment first: the Windows version installs into one.")))
+ return
+ }
+ let store = epicStore
+ let removeMac: @MainActor () async throws -> Void = { [self] in
+ stage = String(format: L("Removing the Mac 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
+ guard status == 0 else { throw HighballError.processFailed(command: "legendary uninstall", status: status, output: "see the log above") }
+ }
+ epicDownload(title: "Installing \(game.app_title)", before: removeMac) { store, control, onLine in
+ try store.install(app, into: bottle, control: control, onLine: onLine)
+ }
+ }
+
+ /// Installs an Epic game's Mac build. With the Windows build installed, that one is removed
+ /// first through legendary, once the player has said yes (pendingEpicMacSwitch). Before
+ /// anything is removed, legendary is asked whether Epic has a Mac build for this account:
+ /// with none, its install would fall back to the Windows build and put it in the Mac games
+ /// folder, outside every environment, after the Windows copy was already gone.
+ func epicInstallMac(_ item: LibraryItem, replacingWindows: Bool = false) {
+ guard let app = item.epicAppName else { return }
+ if item.installed && !replacingWindows { pendingEpicMacSwitch = item; return }
+ let store = epicStore
+ let checkThenRemoveWindows: @MainActor () async throws -> Void = { [self] in
+ stage = L("Asking Epic about the Mac version")
+ 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."))
+ }
+ guard hasMac else {
+ 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."))
+ }
+ 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
+ guard status == 0 else { throw HighballError.processFailed(command: "legendary uninstall", status: status, output: "see the log above") }
+ }
+ epicDownload(title: String(format: L("Installing the Mac version of %@"), item.title), before: checkThenRemoveWindows) { store, control, onLine in
+ try store.installMac(app, control: control, onLine: onLine)
+ }
+ }
+
+ /// Starts an Epic game's Mac build the way legendary launches it, with the sign-in arguments
+ /// Epic's own launcher passes (single use, fetched right before). On the strip, as the GOG
+ /// Mac build and the Windows build start: legendary takes seconds to answer, and a second
+ /// Play meanwhile finds Highball busy and starts nothing, where it used to start a second
+ /// copy. A failure reaches the alert, not only the log.
+ func epicPlayMac(_ item: LibraryItem) {
+ guard let app = item.epicAppName else { return }
+ if macGameProcesses[item.id] != nil {
+ fail(HighballError.failed("\(item.title) is already running."))
+ return
+ }
+ let store = epicStore
+ runBusy(String(format: L("Starting %@"), item.title), done: .handedOff) { [self] in
+ appendLog("\(item.title): opening the Mac version")
+ let info = try await Task.detached { try store.launchInfo(app) }.value
+ try Task.checkCancellation()
+ let p = Process()
+ p.executableURL = info.executable
+ p.arguments = info.arguments
+ p.currentDirectoryURL = info.workingDirectory
+ p.environment = ProcessInfo.processInfo.environment.merging(info.environment) { $1 }
+ p.terminationHandler = { [weak self] _ in Task { @MainActor in self?.macGameProcesses[item.id] = nil } }
+ do { try p.run() } catch {
+ throw HighballError.failed(String(format: L("The Mac version of %@ did not start: %@"), item.title, error.localizedDescription))
+ }
+ // Set before the termination handler's hop to the main actor can run, so an early
+ // exit never leaves a stale entry.
+ macGameProcesses[item.id] = p
+ recordPlay(item)
+ }
+ }
+
+ /// Removes an Epic game's Mac build through legendary, so its library stays right.
+ func epicUninstallMac(_ item: LibraryItem) {
+ guard let app = item.epicAppName else { return }
+ let store = epicStore
+ runBusy(String(format: L("Removing the Mac version of %@"), item.title), expected: nil) { [self] in
+ 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
+ guard status == 0 else { throw HighballError.processFailed(command: "legendary uninstall", status: status, output: "see the log above") }
+ await MainActor.run { self.epicRefresh() }
+ }
+ }
+
/// Quitting the app stops an Epic download the way Stop does, so it never runs on alone,
/// holding legendary's install lock with nothing on screen to stop it (highball#323).
func stopEpicInstall() { epicInstallControl?.stop() }
@@ -3630,16 +3767,18 @@ final class AppState {
}
var epicOwned: [EpicGame] = []
var epicInstalls: [String: String] = [:]
+ var epicMacInstalls: [String: String] = [:]
var gogGames: [GOGStore.Game] = []
- init(epicOwned: [EpicGame], epicInstalls: [String: String], gogGames: [GOGStore.Game]) {
- self.epicOwned = epicOwned; self.epicInstalls = epicInstalls; self.gogGames = gogGames
+ init(epicOwned: [EpicGame], epicInstalls: [String: String], epicMacInstalls: [String: String], gogGames: [GOGStore.Game]) {
+ self.epicOwned = epicOwned; self.epicInstalls = epicInstalls; self.epicMacInstalls = epicMacInstalls; self.gogGames = gogGames
}
init(from decoder: Decoder) throws {
let c = try decoder.container(keyedBy: CodingKeys.self)
epicOwned = try c.decodeIfPresent([EpicGame].self, forKey: .epicOwned) ?? []
epicInstalls = try c.decodeIfPresent([String: String].self, forKey: .epicInstalls) ?? [:]
+ epicMacInstalls = try c.decodeIfPresent([String: String].self, forKey: .epicMacInstalls) ?? [:]
gogGames = try c.decodeIfPresent([GOGStore.Game].self, forKey: .gogGames) ?? []
}
}
@@ -3654,6 +3793,7 @@ final class AppState {
return game
}
epicInstalls = cache.epicInstalls
+ epicMacInstalls = cache.epicMacInstalls
}
if gogStore.isAuthenticated { gogGames = cache.gogGames }
}
@@ -3662,7 +3802,7 @@ final class AppState {
let cache = LibraryCache(
epicOwned: epicOwned.map { .init(appName: $0.app_name, title: $0.app_title, artworkWide: $0.artworkWide, artworkTall: $0.artworkTall,
listsMac: $0.listsMac, cloudSaves: $0.cloudSaves) },
- epicInstalls: epicInstalls, gogGames: gogGames)
+ epicInstalls: epicInstalls, epicMacInstalls: epicMacInstalls, gogGames: gogGames)
try? JSONEncoder().encode(cache).write(to: libraryCacheFile, options: .atomic)
}
@@ -4312,7 +4452,8 @@ final class AppState {
struct InstalledSizes: Equatable {
/// The Windows build's folder (or a program's); nil for Steam, whose own record the page shows.
var game: Int64?
- /// The Mac build's size: a GOG Mac build's app, Steam for Mac's record.
+ /// The Mac build's size: a GOG Mac build's app, legendary's record of an Epic one, Steam
+ /// for Mac's record.
var macGame: Int64?
/// The saves Highball knows the place of: GOG's and Epic's cloud-save folders, Steam
/// Cloud's own copy for Steam. nil when there is no such place or nothing in it yet.
@@ -4348,7 +4489,8 @@ final class AppState {
return await Task.detached {
guard let record = known ?? (try? store.installedGames())?.first(where: { $0.app_name == app }) else { return InstalledSizes() }
let size = record.install_size ?? record.install_path.flatMap { DiskUsage.bytes(at: URL(fileURLWithPath: $0)) }
- return InstalledSizes(game: size, saves: record.save_path.flatMap { DiskUsage.bytes(at: URL(fileURLWithPath: $0)) })
+ return InstalledSizes(game: record.isMac ? nil : size, macGame: record.isMac ? size : nil,
+ saves: record.save_path.flatMap { DiskUsage.bytes(at: URL(fileURLWithPath: $0)) })
}.value
default:
// A program added by hand, a Battle.net game: the folder it lives in.
diff --git a/Sources/HighballApp/GameDetailView.swift b/Sources/HighballApp/GameDetailView.swift
index 111489d..4242e7f 100644
--- a/Sources/HighballApp/GameDetailView.swift
+++ b/Sources/HighballApp/GameDetailView.swift
@@ -428,6 +428,23 @@ struct GameDetailView: View {
}
.padding(.top, 2)
}
+ } else if let folder = state.macFolder(for: item) {
+ // Epic's Mac build, installed through legendary.
+ if let note = Self.archNote(MacBinaryArch.ofApp(at: folder)) {
+ Text(note).font(.callout).foregroundStyle(.secondary)
+ }
+ HStack(spacing: 10) {
+ Button(L("Show in Finder")) { NSWorkspace.shared.activateFileViewerSelecting([folder]) }
+ Button(L("Remove the Mac version…")) { state.pendingEpicMacUninstall = item }.disabled(state.busy)
+ }
+ .controlSize(.small).padding(.top, 2)
+ } else if item.installed {
+ // Epic keeps one build per game: from the Windows one, a switch.
+ HStack(spacing: 8) {
+ Button(L("Switch to the Mac version…")) { state.installOnMac(item) }.controlSize(.small).disabled(state.busy)
+ estimateText(macEstimate)
+ }
+ .padding(.top, 2)
}
}
Spacer(minLength: 0)
@@ -625,7 +642,7 @@ struct GameDetailView: View {
: L("Its anti-cheat does not run on macOS."))
.font(.callout).foregroundStyle(.secondary)
}
- } else if item.source == .gog, item.macListed, !item.installedOnMac {
+ } else if item.source == .gog || item.source == .epic, item.macListed, !item.installedOnMac {
// A Mac version is listed: that's the install on offer, the Windows one a click away.
VStack(alignment: .leading, spacing: 6) {
VStack(alignment: .leading, spacing: 10) {
@@ -641,6 +658,12 @@ struct GameDetailView: View {
estimateText(windowsEstimate)
}
}
+ } else if item.source == .epic, item.installedOnMac {
+ // Epic keeps one build per game, and this Mac one does not run (32-bit): the way
+ // out is the Windows build, which takes its place.
+ Text(L("This Mac version is 32-bit, which current macOS can't run.")).font(.callout).foregroundStyle(HB.warn)
+ Button(L("Switch to the Windows version…")) { state.pendingEpicWindowsSwitch = item }
+ .controlSize(.large).disabled(state.busy)
} else if item.source == .epic || item.source == .gog {
Button { state.install(item) } label: { primaryActionLabel(L("Install"), symbol: "arrow.down") }.buttonStyle(.borderedProminent).controlSize(.large).tint(HB.amber)
.disabled(state.busy)
diff --git a/Sources/HighballApp/HighballApp.swift b/Sources/HighballApp/HighballApp.swift
index 2515698..079247b 100644
--- a/Sources/HighballApp/HighballApp.swift
+++ b/Sources/HighballApp/HighballApp.swift
@@ -527,11 +527,37 @@ private extension View {
Text(GamePageCopy.updateAsk(recipe: pending.recipe, engineID: pending.engineID, canPlay: pending.play != nil))
}
}
- /// A GOG Mac build goes to the Trash only once the player has seen what goes.
+ /// Epic keeps one build per game: switching to the Mac one removes the Windows one first,
+ /// and removing the Mac one means downloading it again to play it. A GOG Mac build goes to
+ /// the Trash only once the player has seen what goes.
@MainActor func macVersionAsks(_ state: AppState) -> some View {
- self.alert(state.pendingGOGMacTrash.map { String(format: L("Move the Mac version of %@ to the Trash?"), $0.title) } ?? "",
- isPresented: .init(get: { state.pendingGOGMacTrash != nil }, set: { if !$0 { state.pendingGOGMacTrash = nil } }),
- presenting: state.pendingGOGMacTrash) { item in
+ self.alert(state.pendingEpicMacSwitch.map { String(format: L("Switch %@ to the Mac version?"), $0.title) } ?? "",
+ isPresented: .init(get: { state.pendingEpicMacSwitch != nil }, set: { if !$0 { state.pendingEpicMacSwitch = nil } }),
+ presenting: state.pendingEpicMacSwitch) { item in
+ Button(L("Switch to the Mac version")) { state.pendingEpicMacSwitch = nil; state.epicInstallMac(item, replacingWindows: true) }
+ Button(L("Cancel"), role: .cancel) { state.pendingEpicMacSwitch = nil }
+ } message: { _ in
+ Text(L("Epic keeps one version of a game installed at a time, so the Windows version is removed first, then the Mac version downloads. Your Highball settings for the game stay."))
+ }
+ .alert(state.pendingEpicWindowsSwitch.map { String(format: L("Switch %@ to the Windows version?"), $0.title) } ?? "",
+ isPresented: .init(get: { state.pendingEpicWindowsSwitch != nil }, set: { if !$0 { state.pendingEpicWindowsSwitch = nil } }),
+ presenting: state.pendingEpicWindowsSwitch) { item in
+ Button(L("Switch to the Windows version")) { state.pendingEpicWindowsSwitch = nil; state.epicSwitchToWindows(item) }
+ Button(L("Cancel"), role: .cancel) { state.pendingEpicWindowsSwitch = nil }
+ } message: { _ in
+ Text(L("Epic keeps one version of a game installed at a time, so the Mac version is removed first, then the Windows version downloads into your environment."))
+ }
+ .alert(state.pendingEpicMacUninstall.map { String(format: L("Remove the Mac version of %@?"), $0.title) } ?? "",
+ isPresented: .init(get: { state.pendingEpicMacUninstall != nil }, set: { if !$0 { state.pendingEpicMacUninstall = nil } }),
+ presenting: state.pendingEpicMacUninstall) { item in
+ Button(L("Remove"), role: .destructive) { state.pendingEpicMacUninstall = nil; state.epicUninstallMac(item) }
+ Button(L("Cancel"), role: .cancel) { state.pendingEpicMacUninstall = nil }
+ } message: { _ in
+ Text(L("Epic removes its files. Playing it again means downloading it again."))
+ }
+ .alert(state.pendingGOGMacTrash.map { String(format: L("Move the Mac version of %@ to the Trash?"), $0.title) } ?? "",
+ isPresented: .init(get: { state.pendingGOGMacTrash != nil }, set: { if !$0 { state.pendingGOGMacTrash = nil } }),
+ presenting: state.pendingGOGMacTrash) { item in
if state.gogMacTrashTarget(for: item) != nil {
Button(L("Move to the Trash"), role: .destructive) { state.pendingGOGMacTrash = nil; state.gogTrashMac(item) }
}
diff --git a/Sources/HighballApp/L10n.swift b/Sources/HighballApp/L10n.swift
index bcefc94..e6e81d9 100644
--- a/Sources/HighballApp/L10n.swift
+++ b/Sources/HighballApp/L10n.swift
@@ -413,6 +413,7 @@ enum L10n {
"The Mac version's saves sync with GOG's cloud before and after you play.": "Les sauvegardes de la version Mac se synchronisent avec le cloud GOG avant et après chaque partie.",
"The game handles the Mac version's saves; some games sync them with GOG's cloud themselves while comet runs.":
"Le jeu gère les sauvegardes de la version Mac ; certains jeux les synchronisent eux-mêmes avec le cloud GOG quand comet tourne.",
+ "Make an environment first: the Windows version installs into one.": "Créez d’abord un environnement : la version Windows s’y installe.",
"How saves sync with GOG": "Comment les sauvegardes se synchronisent avec GOG",
"GOG syncs saves in one of two ways, chosen per game and per version.": "GOG synchronise les sauvegardes de deux façons, selon le jeu et la version.",
"Folder sync: GOG names the folders a game saves in, and Highball copies them to and from GOG's cloud before and after you play, as GOG Galaxy does. When both copies changed, Highball asks which one to keep.":
@@ -430,8 +431,29 @@ enum L10n {
"How Epic's cloud saves work": "Comment fonctionnent les sauvegardes en ligne d’Epic",
"Epic's launcher syncs a game's saves with Epic's cloud when the game sets a cloud save folder. Highball plays Epic games through legendary, and their saves stay on this Mac.":
"Le lanceur d’Epic synchronise les sauvegardes d’un jeu avec le cloud d’Epic quand le jeu définit un dossier de sauvegarde en ligne. Highball lance les jeux Epic par legendary, et leurs sauvegardes restent sur ce Mac.",
+ "This Mac version is 32-bit, which current macOS can't run.": "Cette version Mac est en 32 bits, que les macOS récents ne lancent plus.",
+ "Switch to the Windows version…": "Passer à la version Windows…",
+ "Switch to the Windows version": "Passer à la version Windows",
+ "Switch %@ to the Windows version?": "Passer %@ à la version Windows ?",
+ "Epic keeps one version of a game installed at a time, so the Mac version is removed first, then the Windows version downloads into your environment.":
+ "Epic n’installe qu’une version d’un jeu à la fois : la version Mac est d’abord supprimée, puis la version Windows est téléchargée dans votre environnement.",
"Highball could not find the Mac version of %@ to open.": "Highball ne trouve pas la version Mac de %@ à ouvrir.",
"The Mac version of %@ did not start: %@": "La version Mac de %@ n’a pas démarré : %@",
+ "Removing the Windows version of %@": "Suppression de la version Windows de %@",
+ "Removing the Mac version of %@": "Suppression de la version Mac de %@",
+ "Switch %@ to the Mac version?": "Passer %@ à la version Mac ?",
+ "Switch to the Mac version": "Passer à la version Mac",
+ "Switch to the Mac version…": "Passer à la version Mac…",
+ "Epic keeps one version of a game installed at a time, so the Windows version is removed first, then the Mac version downloads. Your Highball settings for the game stay.":
+ "Epic n’installe qu’une version d’un jeu à la fois : la version Windows est d’abord supprimée, puis la version Mac est téléchargée. Vos réglages Highball pour ce jeu sont conservés.",
+ "Asking Epic about the Mac version": "Demande des informations sur la version Mac à Epic",
+ "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.":
+ "Highball n’a pas pu demander à Epic si une version Mac de ce jeu est disponible au téléchargement, donc rien n’a été modifié. Vérifiez votre connexion, puis réessayez.",
+ "Epic lists a Mac version of this game, but has no Mac build to download for your account, so nothing was changed.":
+ "Epic indique une version Mac de ce jeu, mais n’en propose aucune à télécharger pour votre compte, donc rien n’a été modifié.",
+ "Remove the Mac version of %@?": "Supprimer la version Mac de %@ ?",
+ "Remove the Mac version…": "Supprimer la version Mac…",
+ "Epic removes its files. Playing it again means downloading it again.": "Epic supprime ses fichiers. Pour y rejouer, il faudra le télécharger à nouveau.",
"Show the Windows version in Finder": "Afficher la version Windows dans le Finder",
"Show the Mac version in Finder": "Afficher la version Mac dans le Finder",
"Uninstall the Windows version…": "Désinstaller la version Windows…",
diff --git a/Sources/HighballApp/LibraryView.swift b/Sources/HighballApp/LibraryView.swift
index b392f08..934c687 100644
--- a/Sources/HighballApp/LibraryView.swift
+++ b/Sources/HighballApp/LibraryView.swift
@@ -307,7 +307,7 @@ struct LibraryTile: View {
.transition(.opacity)
}
SourceBadge(source: item.source, mac: state.macSteamBuild(for: item), macListed: item.macListed,
- macInstalled: item.source == .gog && item.installedOnMac)
+ macInstalled: (item.source == .gog || item.source == .epic) && item.installedOnMac)
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
.padding(6)
if let appid = item.steamAppID, state.session(forAppID: appid) != nil {
@@ -452,7 +452,7 @@ struct LibraryTile: View {
}
// Removing the game itself, not just the entry: asked for on r/macgaming because
// there was nowhere to do it (highball#185).
- if item.installed || (item.source == .gog && item.installedOnMac) { Divider() }
+ if item.installed || ((item.source == .gog || item.source == .epic) && item.installedOnMac) { Divider() }
if item.installed {
Button(item.installedOnMac ? L("Uninstall the Windows version…") : L("Uninstall…"), role: .destructive) { state.askUninstall(item) }
.disabled(state.uninstallWaitsFor(item) != nil)
@@ -463,6 +463,11 @@ struct LibraryTile: View {
Button(L("Move the Mac version to the Trash…"), role: .destructive) { state.pendingGOGMacTrash = item }
.disabled(state.busy)
}
+ // Epic's goes through legendary, so its library stays right.
+ if item.source == .epic, item.installedOnMac {
+ Button(L("Remove the Mac version…"), role: .destructive) { state.pendingEpicMacUninstall = item }
+ .disabled(state.busy)
+ }
}
.accessibilityLabel("\(item.title), \(item.source.rawValue)\(item.installedOnMac ? ", " + (item.source == .steam ? L("Installed in Steam for Mac") : L("Mac version installed")) : item.installed ? "" : ", " + L("Not installed"))")
}
diff --git a/Sources/HighballKit/EpicStore.swift b/Sources/HighballKit/EpicStore.swift
index 7dddede..a439254 100644
--- a/Sources/HighballKit/EpicStore.swift
+++ b/Sources/HighballKit/EpicStore.swift
@@ -171,6 +171,10 @@ public struct EpicStore: Sendable {
public var install_size: Int64? = nil
/// Where the game keeps the saves legendary syncs, once it has synced them.
public var save_path: String? = nil
+ /// "Windows" or "Mac": which build legendary installed (one per game).
+ public var platform: String? = nil
+
+ public var isMac: Bool { platform?.lowercased() == "mac" }
}
/// Everything legendary has installed, with where. Legendary's install state is global
@@ -203,8 +207,57 @@ public struct EpicStore: Sendable {
/// selective-download prompt (optional language packs), which `-y` does not cover and which
/// otherwise dies with EOFError the moment it reads stdin (Hogwarts Legacy on Epic, #110).
/// The defaults install the required data only; language packs can be added later.
- static func installArguments(appName: String, basePath: String) -> [String] {
- ["install", appName, "--platform", "Windows", "--base-path", basePath, "-y", "--skip-sdl"]
+ static func installArguments(appName: String, basePath: String, platform: String = "Windows") -> [String] {
+ ["install", appName, "--platform", platform, "--base-path", basePath, "-y", "--skip-sdl"]
+ }
+
+ /// Installs a game's Mac build into the Mac games folder, beside GOG's (GOGStore.macGamesDir).
+ /// legendary keeps one install per game, so the Windows one must be removed first, and only
+ /// once `hasMacBuild` said yes. Should legendary still fall back to the Windows build (its
+ /// install_platform_fallback, on by default and with no flag to turn it off, makes a missing
+ /// Mac asset a warning and downloads the Windows build into this folder, outside every
+ /// environment), it is stopped at that line, before the download, and the install fails.
+ @discardableResult
+ public func installMac(_ appName: String, control: LegendaryControl? = nil,
+ onLine: (@Sendable (String) -> Void)? = nil) throws -> Int32 {
+ let base = GOGStore.macGamesDir
+ try FileManager.default.createDirectory(at: base, withIntermediateDirectories: true)
+ let control = control ?? LegendaryControl()
+ let fellBack = Collector()
+ let status = try runStreaming(Self.installArguments(appName: appName, basePath: base.path, platform: "Mac"), control: control) { line in
+ if Self.fellBackToWindows(line) { fellBack.append(line); control.stop() }
+ onLine?(line)
+ }
+ guard fellBack.lines.isEmpty else {
+ throw HighballError.failed("Epic has no Mac build of this game to download for your account, so Highball stopped the install before Epic's tool downloaded the Windows build in its place.")
+ }
+ return status
+ }
+
+ /// legendary 0.21.0's warning before it installs the Windows build in place of a missing one:
+ /// `App has no asset for platform "Mac", falling back to "Windows".`
+ static func fellBackToWindows(_ line: String) -> Bool {
+ line.contains("has no asset for platform \"Mac\"") && line.contains("falling back")
+ }
+
+ /// Whether Epic has a Mac build of the game for this account to download: the check
+ /// legendary's install makes before it falls back to Windows (an asset for the platform),
+ /// read from `legendary info --platform Mac`. A catalog listing Mac (Game.listsMac) does not
+ /// promise one.
+ public func hasMacBuild(_ appName: String) throws -> Bool {
+ let out = try capture(["info", appName, "--json", "--platform", "Mac"])
+ return Self.listsBuild(Data(out.utf8), platform: "Mac")
+ }
+
+ /// legendary's `info --json` names a version for each platform the game has an asset for
+ /// (game.platform_versions, from the asset list its install checks). None for the platform,
+ /// or output that cannot be read, is no build.
+ static func listsBuild(_ data: Data, platform: String) -> Bool {
+ guard let start = data.firstIndex(of: UInt8(ascii: "{")),
+ let obj = try? JSONSerialization.jsonObject(with: data[start...]) as? [String: Any],
+ let game = obj["game"] as? [String: Any],
+ let versions = game["platform_versions"] as? [String: Any] else { return false }
+ return versions[platform] != nil
}
/// Installs a game's Windows build into the bottle at drive_c/Games/<folder>.
diff --git a/Sources/HighballKit/Library.swift b/Sources/HighballKit/Library.swift
index a36d45c..8d878c0 100644
--- a/Sources/HighballKit/Library.swift
+++ b/Sources/HighballKit/Library.swift
@@ -23,7 +23,8 @@ public struct LibraryItem: Identifiable, Sendable, Hashable {
public let bottleName: String?
public let installed: Bool
/// The native build is installed: Steam for Mac's (MacSteam), or for GOG the Mac build gogdl
- /// put in the Mac games folder (GOGStore.macInstalledGames). Play goes there first.
+ /// put in the Mac games folder (GOGStore.macInstalledGames), or for Epic the Mac build
+ /// legendary installed. Play goes there first.
public let installedOnMac: Bool
public let steamAppID: Int?
public let epicAppName: String?
@@ -262,6 +263,7 @@ public enum LibraryIndex {
gogInstalledByBottle: [String: [GOGStore.InstalledGame]] = [:],
gogLaunchChoice: [String: Int] = [:],
gogMacInstalled: Set<String> = [],
+ epicMacInstalled: Set<String> = [],
battleNetByBottle: [String: [BattleNetGame]] = [:],
plays: [String: LibraryStore.PlayRecord] = [:],
defaultBottle: String? = nil,
@@ -341,7 +343,7 @@ public enum LibraryIndex {
}
items.append(LibraryItem(
source: .epic, id: id, title: game.app_title, bottleName: home,
- installed: home != nil, epicAppName: game.app_name,
+ installed: home != nil, installedOnMac: epicMacInstalled.contains(game.app_name), epicAppName: game.app_name,
artworkTall: game.artworkTall, artworkWide: game.artworkWide,
lastPlayed: plays[id]?.lastPlayedAt, macListed: game.listsMac))
}
diff --git a/Tests/HighballKitTests/StoreMacVersionTests.swift b/Tests/HighballKitTests/StoreMacVersionTests.swift
index a5480c4..2aadf79 100644
--- a/Tests/HighballKitTests/StoreMacVersionTests.swift
+++ b/Tests/HighballKitTests/StoreMacVersionTests.swift
@@ -193,6 +193,59 @@ final class GOGMacBuildTests: XCTestCase {
}
}
+/// Epic's Mac builds through legendary: one build per game, the Mac one in the Mac games folder.
+final class EpicMacBuildTests: XCTestCase {
+ func testMacInstallAsksLegendaryForTheMacBuild() {
+ XCTAssertEqual(EpicStore.installArguments(appName: "Garlic", basePath: "/m", platform: "Mac"),
+ ["install", "Garlic", "--platform", "Mac", "--base-path", "/m", "-y", "--skip-sdl"])
+ XCTAssertEqual(EpicStore.installArguments(appName: "Garlic", basePath: "/w")[3], "Windows")
+ }
+
+ /// Epic's catalog can list Mac with no Mac asset, and legendary's install then falls back to
+ /// Windows: the Windows copy is removed only when `info` names a Mac version.
+ func testAMacBuildIsThereOnlyWhenLegendaryNamesAMacVersion() {
+ let both = #"[cli] INFO: Getting game metadata... {"game": {"app_name": "Garlic", "platform_versions": {"Windows": "1.0-w", "Mac": "1.0-m"}}, "install": null, "manifest": null}"#
+ let windowsOnly = #"{"game": {"app_name": "Duck", "platform_versions": {"Windows": "2.0"}}, "install": {"platform": "Windows"}, "manifest": {"disk_size": 5}}"#
+ XCTAssertTrue(EpicStore.listsBuild(Data(both.utf8), platform: "Mac"))
+ XCTAssertFalse(EpicStore.listsBuild(Data(windowsOnly.utf8), platform: "Mac"), "a Windows manifest from the install is not a Mac build")
+ XCTAssertFalse(EpicStore.listsBuild(Data(#"{"game": null, "install": null, "manifest": null}"#.utf8), platform: "Mac"))
+ XCTAssertFalse(EpicStore.listsBuild(Data("No game information available.".utf8), platform: "Mac"))
+ }
+
+ 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"..."#))
+ }
+
+ func testInstallRecordSaysWhichBuild() throws {
+ let json = #"[{"app_name":"Garlic","install_path":"/m/Enter the Gungeon","platform":"Mac"},{"app_name":"Duck","install_path":"/w","platform":"Windows"},{"app_name":"Old","install_path":"/o"}]"#
+ let games = try JSONDecoder().decode([EpicStore.InstalledGame].self, from: Data(json.utf8))
+ XCTAssertEqual(games.map(\.isMac), [true, false, false])
+ }
+
+ func testLibraryMarksTheMacBuildInstalled() {
+ let items = LibraryIndex.build(bottles: [], steamByBottle: [:],
+ epicOwned: [EpicStore.Game(app_name: "Garlic", app_title: "Enter the Gungeon", listsMac: true)],
+ epicInstalls: [:], epicMacInstalled: ["Garlic"])
+ let item = items.first { $0.id == "epic:Garlic" }
+ XCTAssertEqual(item?.installedOnMac, true)
+ XCTAssertEqual(item?.installed, false, "the Windows build is not")
+ }
+
+ /// legendary's Mac install path is the folder holding the app.
+ func testArchitectureOfAnAppInsideAFolder() throws {
+ let folder = FileManager.default.temporaryDirectory.appending(path: "epicmac-\(UUID().uuidString)")
+ defer { try? FileManager.default.removeItem(at: folder) }
+ let macos = folder.appending(path: "Game.app/Contents/MacOS")
+ try FileManager.default.createDirectory(at: macos, withIntermediateDirectories: true)
+ try #"<?xml version="1.0" encoding="UTF-8"?><plist version="1.0"><dict><key>CFBundleExecutable</key><string>Game</string></dict></plist>"#
+ .write(to: folder.appending(path: "Game.app/Contents/Info.plist"), atomically: true, encoding: .utf8)
+ try Data([0xCF, 0xFA, 0xED, 0xFE, 0x0C, 0x00, 0x00, 0x01] + [UInt8](repeating: 0, count: 64)).write(to: macos.appending(path: "Game"))
+ XCTAssertEqual(MacBinaryArch.ofApp(at: folder), .native)
+ XCTAssertEqual(MacBinaryArch.ofApp(at: folder.appending(path: "Game.app")), .native)
+ }
+}
+
/// A GOG Mac build's saves: GOG's Mac locations, when GOG syncs them for the Mac build.
final class GOGMacSavesTests: XCTestCase {
private func config(windows: String, mac: String) -> Data {