Skip to content

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

Point to the native Mac build when a Steam game has one

Kevinde6a93fe5f3b
diff --git a/Sources/HighballApp/AppState.swift b/Sources/HighballApp/AppState.swift
index 4988a05..3a3d328 100644
--- a/Sources/HighballApp/AppState.swift
+++ b/Sources/HighballApp/AppState.swift
@@ -238,10 +238,66 @@ final class AppState {
func rebuildLibrary() {
libraryItems = LibraryIndex.build(bottles: bottles, steamByBottle: gamesByBottle,
- steamOwnedByBottle: steamOwnedByBottle,
+ steamOwnedByBottle: steamOwnedByBottle, macInstalled: macSteamGames,
epicOwned: epicOwned, epicInstalls: epicInstalls,
plays: libraryPlays)
if let deferred = deferredPlayLink { resolvePlayLink(deferred.request) }
+ refreshMacFlags()
+ }
+
+ // MARK: Mac builds on Steam
+
+ /// What Steam for Mac has installed (MacSteam), refreshed with the bottles' own installs.
+ var macSteamGames: [SteamGame] = []
+
+ /// Steam for Mac is there to take steam:// URLs.
+ var steamForMacInstalled: Bool {
+ NSWorkspace.shared.urlForApplication(toOpen: URL(string: "steam://run/0")!) != nil
+ }
+
+ /// Starts the native build through Steam for Mac.
+ func playOnMac(_ item: LibraryItem) {
+ guard let appid = item.steamAppID else { return }
+ recordPlay(item)
+ NSWorkspace.shared.open(URL(string: "steam://run/\(appid)")!)
+ }
+
+ /// Hands the game to Steam for Mac, whose own dialog asks where to put it; without it, the
+ /// download page for Steam for Mac.
+ func installOnMac(_ item: LibraryItem) {
+ guard let appid = item.steamAppID else { return }
+ NSWorkspace.shared.open(steamForMacInstalled ? URL(string: "steam://install/\(appid)")!
+ : URL(string: "https://store.steampowered.com/about/")!)
+ }
+
+ /// Store `platforms.mac` per appid (MacFlagStore), for Steam games whose appinfo lists macOS.
+ var macFlags: [Int: Bool] = [:]
+ /// Asked this session, answered or not: a store outage must not turn every library rebuild
+ /// into another round of requests.
+ private var macFlagsAsked: Set<Int> = []
+ private var macFlagsTask: Task<Void, Never>?
+
+ func refreshMacFlags() {
+ var listsMac: [Int: Bool] = [:]
+ for game in steamOwnedByBottle.values.joined() { listsMac[game.appid] = game.listsMac }
+ let appids = MacFlagStore.worthAsking(libraryItems.compactMap { $0.source == .steam ? $0.steamAppID : nil },
+ listsMac: listsMac)
+ let ask = appids.filter { macFlags[$0] == nil && !macFlagsAsked.contains($0) }
+ guard !ask.isEmpty, macFlagsTask == nil else { return }
+ macFlagsAsked.formUnion(ask)
+ let store = MacFlagStore(paths: paths)
+ macFlagsTask = Task { [weak self] in
+ let flags = await store.refresh(ask)
+ self?.macFlags.merge(flags) { $1 }
+ self?.macFlagsTask = nil
+ self?.refreshMacFlags() // games that joined the library meanwhile (the owned list loads after installs)
+ }
+ }
+
+ func macSteamBuild(for item: LibraryItem) -> MacSteamBuild? {
+ guard item.source == .steam else { return nil }
+ return MacSteamBuild.resolve(entry: gameDB.entry(for: item), storeMac: item.steamAppID.flatMap { macFlags[$0] },
+ installedOnMac: item.installedOnMac)
}
/// The verified fix recipe for a library item, if the db has one (db entry id == recipe id).
@@ -259,7 +315,10 @@ final class AppState {
/// with heavy steps asks, with the cost stated.
/// `renderer` forces one graphics mode for this launch (the D3DMetal ask's "play with the
/// other mode"); nil lets the row and the environment decide.
- func play(_ item: LibraryItem, renderer: Renderer? = nil) {
+ /// `windowsBuild` plays the bottle's copy of a game Steam for Mac also has installed; without
+ /// it the native build goes first.
+ func play(_ item: LibraryItem, renderer: Renderer? = nil, windowsBuild: Bool = false) {
+ if item.installedOnMac, renderer == nil, !windowsBuild { playOnMac(item); return }
guard let bottleName = item.bottleName,
let found = bottles.first(where: { $0.name == bottleName }) else { return }
var bottle = found
@@ -635,7 +694,9 @@ final class AppState {
func refreshInstalledGames() {
// Re-arm first: a steamapps that did not exist at the last full refresh (Steam was
// installed after launch) is only watched from here on, and a replaced one is reopened.
- installWatcher?.watch(bottles.flatMap(installDirectories))
+ installWatcher?.watch(bottles.flatMap(installDirectories) + MacSteam.steamappsDirectories())
+ let mac = MacSteam.installedGames()
+ if mac != macSteamGames { macSteamGames = mac; rebuildLibrary() }
let games = Dictionary(bottles.map { ($0.name, SteamLibrary.games(in: $0)) }, uniquingKeysWith: { a, _ in a })
if games != gamesByBottle { gamesByBottle = games; rebuildLibrary() }
guard epicSignedIn, !epicFetchInFlight else { return }
@@ -680,7 +741,8 @@ final class AppState {
// Never trap on duplicate names (a Finder-duplicated bottle crashed the app at launch — issue #13).
gamesByBottle = Dictionary(bottles.map { ($0.name, SteamLibrary.games(in: $0)) }, uniquingKeysWith: { a, _ in a })
if installWatcher == nil { installWatcher = DirectoryWatcher { [weak self] in self?.refreshInstalledGames() } }
- installWatcher?.watch(bottles.flatMap(installDirectories))
+ installWatcher?.watch(bottles.flatMap(installDirectories) + MacSteam.steamappsDirectories())
+ macSteamGames = MacSteam.installedGames()
startSteamClientWatch()
libraryPlays = libraryStore.load()
libraryOverrides = libraryStore.rendererOverrides()
diff --git a/Sources/HighballApp/GameDetailView.swift b/Sources/HighballApp/GameDetailView.swift
index 84c4dd4..bc4654b 100644
--- a/Sources/HighballApp/GameDetailView.swift
+++ b/Sources/HighballApp/GameDetailView.swift
@@ -42,6 +42,7 @@ struct GameDetailView: View {
ScrollView {
VStack(alignment: .leading, spacing: 18) {
hero
+ if let macBuild { macBlock(macBuild) }
verdictBlock
playRow
if item.installed, !blocked { willDoCard }
@@ -122,6 +123,47 @@ struct GameDetailView: View {
}
}
+ private var macBuild: GamePageCopy.MacBuild? {
+ let v = ProcessInfo.processInfo.operatingSystemVersion
+ let os = v.patchVersion > 0 ? "\(v.majorVersion).\(v.minorVersion).\(v.patchVersion)" : "\(v.majorVersion).\(v.minorVersion)"
+ return GamePageCopy.macBuild(state.macSteamBuild(for: item), entry: entry, myChip: state.machineChip, macOS: os)
+ }
+
+ /// A native Mac build on Steam: what it is, why it matters, what it needs. Above the verdict,
+ /// which is about the Windows build.
+ private func macBlock(_ copy: GamePageCopy.MacBuild) -> some View {
+ HStack(alignment: .top, spacing: 10) {
+ Image(systemName: "apple.logo").foregroundStyle(.secondary).padding(.top, 2)
+ VStack(alignment: .leading, spacing: 6) {
+ Text(copy.headline).font(.callout.weight(.semibold))
+ Text(copy.detail).font(.callout).foregroundStyle(.secondary)
+ // This Mac only next to what the build asks for: the verdict below already names the chip.
+ if let requirements = copy.requirements {
+ Text(requirements).font(.callout).foregroundStyle(.secondary)
+ Text(copy.yourMac).font(.callout).foregroundStyle(.secondary)
+ }
+ HStack(spacing: 10) {
+ macButton
+ Text(copy.source).font(.caption).foregroundStyle(.tertiary)
+ }
+ .padding(.top, 2)
+ }
+ Spacer(minLength: 0)
+ }
+ .padding(12)
+ .background(HB.card, in: RoundedRectangle(cornerRadius: 10))
+ .overlay(RoundedRectangle(cornerRadius: 10).stroke(.white.opacity(0.35)))
+ }
+
+ /// Only when the Windows build is the installed one: otherwise the play row already offers
+ /// the Mac build (Play on Mac, Install on Mac).
+ @ViewBuilder private var macButton: some View {
+ if item.installed, !item.installedOnMac {
+ Button(state.steamForMacInstalled ? L("Install on Mac") : L("Get Steam for Mac")) { state.installOnMac(item) }
+ .controlSize(.small)
+ }
+ }
+
private var playRow: some View {
HStack(spacing: 14) {
if let running {
@@ -131,6 +173,18 @@ struct GameDetailView: View {
.map { String(format: L("Running for %d min"), $0) } ?? L("Running"))
.font(.callout).foregroundStyle(HB.good)
}
+ } else if item.installedOnMac {
+ // The native build first; a Windows copy in a bottle stays one click away.
+ Button { state.playOnMac(item) } label: {
+ Label(L("Play on Mac"), systemImage: "play.fill").frame(minWidth: 96)
+ }
+ .buttonStyle(.borderedProminent).controlSize(.large).tint(HB.amber)
+ if item.installed {
+ Button(L("Play the Windows version")) { state.play(item, windowsBuild: true) }
+ .controlSize(.large).disabled(state.busy || blocked)
+ } else {
+ Text(L("Starts through Steam for Mac.")).font(.callout).foregroundStyle(.secondary)
+ }
} else if item.installed {
Button { state.play(item) } label: {
Label(L("Play"), systemImage: "play.fill").frame(minWidth: 96)
@@ -143,6 +197,23 @@ struct GameDetailView: View {
Button(L("Install")) { state.install(item) }.buttonStyle(.borderedProminent).controlSize(.large).tint(HB.amber)
.disabled(state.busy)
Text(String(format: L("Installs into %@."), state.defaultBottle?.name ?? L("your environment"))).font(.callout).foregroundStyle(.secondary)
+ } else if item.source == .steam, !steamHasManifest, state.macSteamBuild(for: item) != nil {
+ // A native build exists: that's the install on offer; the Windows one is the
+ // way around it, not the default.
+ VStack(alignment: .leading, spacing: 6) {
+ HStack(spacing: 14) {
+ Button { state.installOnMac(item) } label: {
+ Label(state.steamForMacInstalled ? L("Install on Mac") : L("Get Steam for Mac"), systemImage: "apple.logo")
+ }
+ .buttonStyle(.borderedProminent).controlSize(.large).tint(HB.amber)
+ Text(state.steamForMacInstalled ? L("Steam for Mac asks where to put it.")
+ : L("The Mac build installs through Steam for Mac."))
+ .font(.callout).foregroundStyle(.secondary)
+ }
+ Button(L("Install the Windows version instead")) { state.install(item) }
+ .buttonStyle(.link).font(.callout).disabled(state.busy || blocked)
+ .help(L("For when the Mac build lags behind or a mod needs the Windows one."))
+ }
} else if item.source == .steam, !steamHasManifest {
// Owned, never installed here (highball#199): Steam's own dialog takes it from here.
Button(L("Install")) { state.install(item) }.buttonStyle(.borderedProminent).controlSize(.large).tint(HB.amber)
@@ -159,7 +230,8 @@ struct GameDetailView: View {
private var willDoCard: some View {
VStack(alignment: .leading, spacing: 8) {
- HB.eyebrow(L("When you press Play, Highball will"))
+ // Next to Play on Mac, "Play" alone would read as the Mac build's.
+ HB.eyebrow(item.installedOnMac ? L("When you play the Windows version, Highball will") : L("When you press Play, Highball will"))
ForEach(Array(willDo.enumerated()), id: \.offset) { _, line in
HStack(alignment: .firstTextBaseline, spacing: 8) {
Image(systemName: line.done ? "checkmark" : (line.cost == nil ? "checkmark" : "hourglass"))
diff --git a/Sources/HighballApp/L10n.swift b/Sources/HighballApp/L10n.swift
index 06548ed..8fddf9c 100644
--- a/Sources/HighballApp/L10n.swift
+++ b/Sources/HighballApp/L10n.swift
@@ -13,6 +13,19 @@ enum L10n {
"How frame generation works": "Comment fonctionne la génération d’images",
"Off": "Désactivé",
"Steam asks where to put it.": "Steam demande où l’installer.",
+ "Open in Steam for Mac": "Ouvrir dans Steam pour Mac",
+ "Native Mac build on Steam": "Version Mac native sur Steam",
+ "Get Steam for Mac": "Obtenir Steam pour Mac",
+ "Installed in Steam for Mac": "Installé dans Steam pour Mac",
+ "When you play the Windows version, Highball will": "Quand vous jouez à la version Windows, Highball va",
+ "Play on Mac": "Jouer sur Mac",
+ "Play the Windows version": "Jouer à la version Windows",
+ "Starts through Steam for Mac.": "Se lance via Steam pour Mac.",
+ "Install on Mac": "Installer sur Mac",
+ "Steam for Mac asks where to put it.": "Steam pour Mac demande où l’installer.",
+ "The Mac build installs through Steam for Mac.": "La version Mac s’installe via Steam pour Mac.",
+ "Install the Windows version instead": "Installer plutôt la version Windows",
+ "For when the Mac build lags behind or a mod needs the Windows one.": "Pour quand la version Mac est en retard ou qu’un mod demande la version Windows.",
"Force vsync": "Forcer la VSync",
"Warning": "Avertissement",
"What this setting does": "Ce que fait ce réglage",
diff --git a/Sources/HighballApp/LibraryView.swift b/Sources/HighballApp/LibraryView.swift
index 7c923bb..eb8485a 100644
--- a/Sources/HighballApp/LibraryView.swift
+++ b/Sources/HighballApp/LibraryView.swift
@@ -25,7 +25,7 @@ struct LibraryView: View {
private var filtered: [LibraryItem] {
state.libraryItems.filter { item in
if let sourceFilter, item.source != sourceFilter { return false }
- if installedOnly && !item.installed && (installedTouched || item.source == .steam) { return false }
+ if installedOnly && !item.installedAnywhere && (installedTouched || item.source == .steam) { return false }
if verifiedOnly {
guard state.gameDB.entry(for: item)?.status == "verified-local" else { return false }
}
@@ -38,7 +38,7 @@ struct LibraryView: View {
private var continueItems: [LibraryItem] {
guard state.libraryItems.count > 6 else { return [] }
return state.libraryItems
- .filter { $0.lastPlayed != nil && $0.installed }
+ .filter { $0.lastPlayed != nil && $0.installedAnywhere }
.sorted { ($0.lastPlayed ?? .distantPast) > ($1.lastPlayed ?? .distantPast) }
.prefix(10).map { $0 }
}
@@ -213,15 +213,16 @@ struct LibraryTile: View {
@State private var coverDropTargeted = false
private var blocked: Bool { entry?.isBlocked == true }
- private var playable: Bool { item.installed && !blocked && !state.busy }
+ /// Anti-cheat blocks the Windows build only: a native Mac one plays.
+ private var playable: Bool { (item.installedOnMac || (item.installed && !blocked)) && !state.busy }
var body: some View {
NavigationLink(value: item) {
VStack(alignment: .leading, spacing: 6) {
ZStack {
CoverArt(item: item)
- .saturation(blocked ? 0.15 : (item.installed ? 1 : 0.45))
- .brightness(item.installed ? 0 : -0.08)
+ .saturation(blocked && !item.installedOnMac ? 0.15 : (item.installedAnywhere ? 1 : 0.45))
+ .brightness(item.installedAnywhere ? 0 : -0.08)
if hovering && playable {
ZStack {
Color.black.opacity(0.25)
@@ -239,7 +240,7 @@ struct LibraryTile: View {
}
.transition(.opacity)
}
- SourceBadge(source: item.source)
+ SourceBadge(source: item.source, mac: state.macSteamBuild(for: item))
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
.padding(6)
if let appid = item.steamAppID, state.session(forAppID: appid) != nil {
@@ -251,7 +252,7 @@ struct LibraryTile: View {
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .bottomTrailing)
.padding(6)
}
- if !item.installed {
+ if !item.installedAnywhere {
Image(systemName: "arrow.down.circle.fill")
.foregroundStyle(.white.opacity(0.85))
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topTrailing)
@@ -294,7 +295,7 @@ struct LibraryTile: View {
} else if playable { Button(L("Play")) { state.play(item) } }
if MacAppStub.existing(for: item.title) != nil {
Button(L("Remove the Mac app")) { state.removeMacApp(title: item.title) }
- } else if playable, PlayLink.target(for: item) != nil {
+ } else if playable, item.installed, PlayLink.target(for: item) != nil {
Button(L("Make a Mac app…")) { state.makeMacApp(for: item) }
}
Button(L("Choose cover image…")) { state.chooseCover(for: item) }
@@ -317,7 +318,7 @@ struct LibraryTile: View {
Button(L("Uninstall…"), role: .destructive) { state.askUninstall(item) }
}
}
- .accessibilityLabel("\(item.title), \(item.source.rawValue)\(item.installed ? "" : ", " + L("Not installed"))")
+ .accessibilityLabel("\(item.title), \(item.source.rawValue)\(item.installedOnMac ? ", " + L("Installed in Steam for Mac") : item.installed ? "" : ", " + L("Not installed"))")
}
private var verdict: (String, Color)? { verdictLabel(entry?.status) }
@@ -336,17 +337,25 @@ func verdictLabel(_ status: String?) -> (String, Color)? {
struct SourceBadge: View {
let source: LibrarySource
+ /// A native Mac build on Steam (MacSteamBuild): an Apple logo in front of the label, and the
+ /// whole badge lit when Steam for Mac has it installed.
+ var mac: MacSteamBuild? = nil
private var label: String {
switch source { case .steam: "STEAM"; case .epic: "EPIC"; case .pin: "EXE" }
}
+ private var lit: Bool { mac == .installed }
var body: some View {
- Text(label)
- .font(.system(size: 8.5, weight: .medium).monospaced())
+ HStack(spacing: 3) {
+ if mac != nil { Image(systemName: "apple.logo").font(.system(size: 8, weight: .semibold)) }
+ Text(label)
+ }
+ .font(.system(size: 8.5, weight: lit ? .bold : .medium).monospaced())
.kerning(0.4)
.padding(.horizontal, 5).padding(.vertical, 2)
- .background(RoundedRectangle(cornerRadius: 4).fill(.black.opacity(0.55)))
- .overlay(RoundedRectangle(cornerRadius: 4).stroke(.white.opacity(0.18), lineWidth: 0.5))
- .foregroundStyle(.white.opacity(0.92))
+ .background(RoundedRectangle(cornerRadius: 4).fill(lit ? .white.opacity(0.92) : .black.opacity(0.55)))
+ .overlay(RoundedRectangle(cornerRadius: 4).stroke(.white.opacity(lit ? 0 : 0.18), lineWidth: 0.5))
+ .foregroundStyle(lit ? .black : .white.opacity(0.92))
+ .help(lit ? L("Installed in Steam for Mac") : mac != nil ? L("Native Mac build on Steam") : "")
}
}
diff --git a/Sources/HighballKit/GamePageCopy.swift b/Sources/HighballKit/GamePageCopy.swift
index a500d55..2181a30 100644
--- a/Sources/HighballKit/GamePageCopy.swift
+++ b/Sources/HighballKit/GamePageCopy.swift
@@ -45,6 +45,36 @@ public enum GamePageCopy {
}
}
+ /// The card for a game with a native Mac build on Steam. The Windows build stays available,
+ /// as a secondary action: it can still be the one someone wants (a port that lags behind,
+ /// an Intel-only one, mods).
+ public struct MacBuild: Equatable {
+ public var headline: String
+ public var detail: String
+ /// The row's note: the build's own requirements ("macOS 12 and M1 or later").
+ public var requirements: String?
+ public var yourMac: String
+ public var source: String
+ }
+
+ public static func macBuild(_ build: MacSteamBuild?, entry: GameDBEntry?, myChip: String, macOS: String) -> MacBuild? {
+ guard let build else { return nil }
+ let installed = build == .installed
+ let source = switch build {
+ case .installed: "Steam for Mac lists it as installed."
+ case .inDatabase: "From the compatibility database."
+ case .onStore: "Steam's store page lists macOS for it."
+ }
+ return MacBuild(
+ headline: installed ? "Installed in Steam for Mac." : "There is a native Mac build on Steam.",
+ detail: installed
+ ? "Play starts the Mac build through Steam for Mac, with no Windows layer in between."
+ : "It will beat running the Windows version through any compatibility layer, and your Steam purchase already includes it.",
+ requirements: entry?.nativeMac?.available == true ? entry?.nativeMac?.note : nil,
+ yourMac: "Your Mac is an \(shortChip(myChip)) on macOS \(macOS).",
+ source: source)
+ }
+
/// One line of "when you press Play, Highball will".
public struct WillDo: Equatable {
public var text: String
diff --git a/Sources/HighballKit/Library.swift b/Sources/HighballKit/Library.swift
index 5a6a107..5cdb636 100644
--- a/Sources/HighballKit/Library.swift
+++ b/Sources/HighballKit/Library.swift
@@ -22,6 +22,8 @@ public struct LibraryItem: Identifiable, Sendable, Hashable {
/// Where it lives. nil only for an Epic title owned but not installed in any bottle.
public let bottleName: String?
public let installed: Bool
+ /// Steam for Mac has its native build installed (MacSteam); Play goes there first.
+ public let installedOnMac: Bool
public let steamAppID: Int?
public let epicAppName: String?
public let pinID: UUID?
@@ -33,14 +35,18 @@ public struct LibraryItem: Identifiable, Sendable, Hashable {
public let lastPlayed: Date?
public init(source: LibrarySource, id: String, title: String, bottleName: String?,
- installed: Bool, steamAppID: Int? = nil, epicAppName: String? = nil,
+ installed: Bool, installedOnMac: Bool = false, steamAppID: Int? = nil, epicAppName: String? = nil,
pinID: UUID? = nil, artworkTall: URL? = nil, artworkWide: URL? = nil,
otherBottles: [String] = [], sizeOnDisk: Int64 = 0, lastPlayed: Date? = nil) {
self.source = source; self.id = id; self.title = title; self.bottleName = bottleName
- self.installed = installed; self.steamAppID = steamAppID; self.epicAppName = epicAppName
+ self.installed = installed; self.installedOnMac = installedOnMac
+ self.steamAppID = steamAppID; self.epicAppName = epicAppName
self.pinID = pinID; self.artworkTall = artworkTall; self.artworkWide = artworkWide
self.otherBottles = otherBottles; self.sizeOnDisk = sizeOnDisk; self.lastPlayed = lastPlayed
}
+
+ /// Playable here in either build: the Windows one in a bottle or the Mac one in Steam for Mac.
+ public var installedAnywhere: Bool { installed || installedOnMac }
}
public enum LibraryIndex {
@@ -58,13 +64,18 @@ public enum LibraryIndex {
/// the primary bottle is where it was last played, then a ready copy, then name order.
/// `steamOwnedByBottle` adds the account's games that aren't installed anywhere
/// (SteamOwnedLibrary, highball#199), homed in the first bottle whose Steam owns them.
+ /// `macInstalled` is what Steam for Mac has installed (MacSteam): those games count as
+ /// installed, and one no bottle knows gets a tile of its own.
public static func build(bottles: [Bottle],
steamByBottle: [String: [SteamGame]],
steamOwnedByBottle: [String: [OwnedSteamGame]] = [:],
+ macInstalled: [SteamGame] = [],
epicOwned: [EpicStore.Game],
epicInstalls: [String: String],
plays: [String: LibraryStore.PlayRecord] = [:]) -> [LibraryItem] {
var items: [LibraryItem] = []
+ let onMac = Dictionary(macInstalled.map { ($0.appid, $0) }, uniquingKeysWith: { a, _ in a })
+ let firstBottle = bottles.map(\.name).min { $0.localizedCaseInsensitiveCompare($1) == .orderedAscending }
// Steam: group by appid, pick a primary copy, remember the others.
var byAppID: [Int: [(bottle: String, game: SteamGame)]] = [:]
@@ -81,13 +92,13 @@ public enum LibraryIndex {
if a.game.isReady != b.game.isReady { return a.game.isReady }
return a.bottle.localizedCaseInsensitiveCompare(b.bottle) == .orderedAscending
}!
- let acfPlayed = copies.compactMap(\.game.lastPlayed).max()
+ let acfPlayed = (copies.compactMap(\.game.lastPlayed) + [onMac[appid]?.lastPlayed].compactMap { $0 }).max()
let recorded = plays[id]?.lastPlayedAt
// The client's cached art when it has it (see OwnedSteamGame), the CDN otherwise.
let owned = steamOwnedByBottle.values.lazy.compactMap { $0.first { $0.appid == appid } }.first
items.append(LibraryItem(
source: .steam, id: id, title: primary.game.name, bottleName: primary.bottle,
- installed: primary.game.isReady, steamAppID: appid,
+ installed: primary.game.isReady, installedOnMac: onMac[appid] != nil, steamAppID: appid,
artworkTall: owned?.localCapsule ?? primary.game.capsuleImage,
artworkWide: owned?.localHeader ?? primary.game.headerImage,
otherBottles: copies.map(\.bottle).filter { $0 != primary.bottle }.sorted(),
@@ -104,12 +115,23 @@ public enum LibraryIndex {
let id = "steam:\(game.appid)"
items.append(LibraryItem(
source: .steam, id: id, title: game.name, bottleName: bottle.name,
- installed: false, steamAppID: game.appid,
+ installed: false, installedOnMac: onMac[game.appid] != nil, steamAppID: game.appid,
artworkTall: game.capsuleImage, artworkWide: game.headerImage,
- lastPlayed: plays[id]?.lastPlayedAt))
+ lastPlayed: [onMac[game.appid]?.lastPlayed, plays[id]?.lastPlayedAt].compactMap { $0 }.max()))
}
}
+ // Installed in Steam for Mac and nowhere else Highball can see (no bottle's Steam signed
+ // in yet): still the player's game, homed where a Windows install would go.
+ for game in macInstalled where byAppID[game.appid] == nil && !ownedOnly.contains(game.appid) {
+ let id = "steam:\(game.appid)"
+ items.append(LibraryItem(
+ source: .steam, id: id, title: game.name, bottleName: firstBottle,
+ installed: false, installedOnMac: true, steamAppID: game.appid,
+ artworkTall: game.capsuleImage, artworkWide: game.headerImage,
+ lastPlayed: [game.lastPlayed, plays[id]?.lastPlayedAt].compactMap { $0 }.max()))
+ }
+
// Epic: legendary installs one copy; the owning bottle is whichever drive_c
// prefixes the install path (see EpicStore.isInstalled).
for game in epicOwned {
diff --git a/Sources/HighballKit/MacSteam.swift b/Sources/HighballKit/MacSteam.swift
new file mode 100644
index 0000000..5bea79f
--- /dev/null
+++ b/Sources/HighballKit/MacSteam.swift
@@ -0,0 +1,42 @@
+import Foundation
+
+/// The Mac Steam app's own installs, read from its appmanifests the same way a bottle's are:
+/// `~/Library/Application Support/Steam/steamapps` plus every library folder it lists in
+/// `libraryfolders.vdf` (an external drive, say). Read only.
+///
+/// A game installed there is played through Steam for Mac with `steam://run/<appid>`, and one
+/// that isn't is handed to it with `steam://install/<appid>`: bottles run with winemenubuilder
+/// disabled, so Wine's Steam registers no macOS URL handler and steam:// reaches the Mac app.
+public enum MacSteam {
+ public static var root: URL {
+ FileManager.default.homeDirectoryForCurrentUser.appending(path: "Library/Application Support/Steam")
+ }
+
+ /// Every `steamapps` folder the Mac client installs into, the default one first.
+ public static func steamappsDirectories(root: URL = root) -> [URL] {
+ var libraries = [root.standardizedFileURL]
+ if let text = try? String(contentsOf: root.appending(path: "steamapps/libraryfolders.vdf"), encoding: .utf8) {
+ let pattern = #/"path"\s+"((?:\\.|[^"\\])*)"/#
+ for match in text.matches(of: pattern) {
+ let path = String(match.1).replacingOccurrences(of: #"\\"#, with: #"\"#)
+ .replacingOccurrences(of: #"\""#, with: "\"")
+ let url = URL(fileURLWithPath: path).standardizedFileURL
+ if !libraries.contains(url) { libraries.append(url) }
+ }
+ }
+ return libraries.map { $0.appending(path: "steamapps") }
+ }
+
+ /// Games fully installed by Steam for Mac. Nothing when it isn't installed or signed in.
+ public static func installedGames(root: URL = root) -> [SteamGame] {
+ var seen = Set<Int>()
+ return steamappsDirectories(root: root)
+ .flatMap { dir in
+ ((try? FileManager.default.contentsOfDirectory(at: dir, includingPropertiesForKeys: nil)) ?? [])
+ .filter { $0.lastPathComponent.hasPrefix("appmanifest_") && $0.pathExtension == "acf" }
+ }
+ .compactMap { SteamLibrary.parseManifest($0) }
+ .filter { $0.isReady && $0.appid != 228980 && seen.insert($0.appid).inserted }
+ .sorted { $0.name.localizedCaseInsensitiveCompare($1.name) == .orderedAscending }
+ }
+}
diff --git a/Sources/HighballKit/MacSteamBuild.swift b/Sources/HighballKit/MacSteamBuild.swift
new file mode 100644
index 0000000..1a5d19e
--- /dev/null
+++ b/Sources/HighballKit/MacSteamBuild.swift
@@ -0,0 +1,117 @@
+import Foundation
+
+/// A native macOS build of a game on Steam: the same purchase the player already made, which the
+/// Mac Steam app installs and runs without Wine. Only Steam builds count; a native edition sold
+/// elsewhere (Death Stranding's on the Mac App Store) is a different purchase and isn't marked.
+///
+/// Two sources, curated first:
+/// - the database row's `nativeMac`, when its `where` names Steam; a row can also say
+/// `"available": false` for a port that no longer runs;
+/// - otherwise the Steam store's `platforms.mac` for the appid. The store page is what Valve and
+/// publishers keep current: Steam's own appinfo still lists macOS for Portal, whose 32-bit Mac
+/// build stopped running with Catalina, while the store page for 400 no longer does
+/// (checked 2026-09-24).
+public enum MacSteamBuild: Equatable, Sendable {
+ /// Steam for Mac has it installed (MacSteam): no need to ask anyone.
+ case installed
+ /// The database row says so (and may carry requirements in its note).
+ case inDatabase
+ /// Steam's store page lists macOS.
+ case onStore
+
+ /// Pure. nil: no Mac build on Steam known, or the store hasn't been asked yet.
+ public static func resolve(entry: GameDBEntry?, storeMac: Bool?, installedOnMac: Bool = false) -> MacSteamBuild? {
+ if installedOnMac { return .installed }
+ if let native = entry?.nativeMac {
+ guard native.available else { return nil }
+ // A list ("Steam, Mac App Store, GOG, Epic" for Cyberpunk 2077) counts when Steam is in it.
+ let stores = (native.where ?? "Steam").split(separator: ",").map { $0.trimmingCharacters(in: .whitespaces).lowercased() }
+ if stores.contains("steam") { return .inDatabase }
+ }
+ return storeMac == true ? .onStore : nil
+ }
+}
+
+/// The row field: `"nativeMac": {"available": true, "where": "Steam", "note": "…", "url": "…"}`.
+public struct NativeMacInfo: Codable, Sendable, Equatable {
+ public var available: Bool
+ public var `where`: String?
+ public var note: String?
+ public var url: String?
+}
+
+/// Store `platforms.mac` flags, cached in `mac-flags.json` for two weeks. Only Steam games whose
+/// appinfo lists macOS are asked about (worthAsking), one request each: the store API takes one
+/// appid per `platforms` request and allows about 200 requests per five minutes. A failed or
+/// refused request is "don't know", never "no Mac version", so it's asked again next time.
+public struct MacFlagStore: Sendable {
+ public struct Record: Codable, Sendable, Equatable {
+ public var mac: Bool
+ public var checked: Date
+ }
+
+ public static let maxAge: TimeInterval = 14 * 24 * 3600
+ public let file: URL
+
+ public init(paths: HighballPaths = HighballPaths()) {
+ file = paths.home.appending(path: "mac-flags.json")
+ }
+
+ public init(file: URL) { self.file = file }
+
+ /// Tolerant load: missing or corrupt file is an empty cache.
+ public func load(now: Date = Date()) -> [Int: Bool] {
+ guard let data = try? Data(contentsOf: file),
+ let records = try? JSONDecoder().decode([Int: Record].self, from: data) else { return [:] }
+ return records.filter { now.timeIntervalSince($0.value.checked) < Self.maxAge }.mapValues(\.mac)
+ }
+
+ func save(_ flags: [Int: Bool], now: Date = Date()) {
+ var records = (try? Data(contentsOf: file)).flatMap { try? JSONDecoder().decode([Int: Record].self, from: $0) } ?? [:]
+ for (appid, mac) in flags { records[appid] = Record(mac: mac, checked: now) }
+ guard let data = try? JSONEncoder().encode(records) else { return }
+ try? FileManager.default.createDirectory(at: file.deletingLastPathComponent(), withIntermediateDirectories: true)
+ try? data.write(to: file, options: .atomic)
+ }
+
+ /// The Steam games to ask the store about: the ones whose appinfo lists macOS, and any the
+ /// owned library can't speak for yet (an installed game before the client's cache has it).
+ /// A game appinfo doesn't list for macOS has no Mac build on Steam, so a library of hundreds
+ /// costs a handful of requests.
+ public static func worthAsking(_ appids: [Int], listsMac: [Int: Bool]) -> [Int] {
+ appids.filter { listsMac[$0] ?? true }
+ }
+
+ /// Asks the store about the appids not cached yet and returns every known flag.
+ public func refresh(_ appids: [Int], now: Date = Date()) async -> [Int: Bool] {
+ var known = load(now: now)
+ let missing = appids.filter { known[$0] == nil }
+ guard !missing.isEmpty else { return known }
+ let cfg = URLSessionConfiguration.ephemeral
+ cfg.timeoutIntervalForRequest = 15
+ let session = URLSession(configuration: cfg)
+ var fetched: [Int: Bool] = [:]
+ for appid in missing {
+ if Task.isCancelled { break }
+ let url = URL(string: "https://store.steampowered.com/api/appdetails?appids=\(appid)&filters=platforms")!
+ guard let (data, response) = try? await session.data(from: url) else { continue }
+ let status = (response as? HTTPURLResponse)?.statusCode
+ if status == 429 || status == 403 { break } // rate limited: the rest wait for next session
+ guard status == 200, let mac = Self.parse(data) else { continue }
+ fetched[appid] = mac
+ }
+ if !fetched.isEmpty { save(fetched, now: now) }
+ known.merge(fetched) { $1 }
+ return known
+ }
+
+ /// `{"400":{"success":true,"data":{"platforms":{"windows":true,"mac":false,"linux":false}}}}`.
+ /// nil when the store has no page for the appid (delisted, region-locked): that isn't a no.
+ static func parse(_ data: Data) -> Bool? {
+ guard let json = try? JSONSerialization.jsonObject(with: data) as? [String: Any],
+ let app = json.values.first as? [String: Any],
+ app["success"] as? Bool == true,
+ let platforms = (app["data"] as? [String: Any])?["platforms"] as? [String: Any] else { return nil }
+ return platforms["mac"] as? Bool
+ }
+}
diff --git a/Sources/HighballKit/SteamLibrary.swift b/Sources/HighballKit/SteamLibrary.swift
index cca8c17..2b50641 100644
--- a/Sources/HighballKit/SteamLibrary.swift
+++ b/Sources/HighballKit/SteamLibrary.swift
@@ -125,6 +125,9 @@ public struct GameDBEntry: Codable, Sendable {
public var detail: String?
}
public var rendererResults: [String: RendererResult]?
+ /// A native macOS edition. Highball marks the ones on Steam (the same purchase); `available:
+ /// false` marks a Mac port that no longer runs, which outranks the store's flag (MacSteamBuild).
+ public var nativeMac: NativeMacInfo?
public var isBlocked: Bool { status == "blocked-anticheat" }
diff --git a/Sources/HighballKit/SteamOwnedLibrary.swift b/Sources/HighballKit/SteamOwnedLibrary.swift
index db7af85..c4b0a54 100644
--- a/Sources/HighballKit/SteamOwnedLibrary.swift
+++ b/Sources/HighballKit/SteamOwnedLibrary.swift
@@ -7,9 +7,13 @@ public struct OwnedSteamGame: Sendable, Hashable {
/// The client's own copies of the artwork in librarycache, when it has them.
public var localCapsule: URL? = nil
public var localHeader: URL? = nil
+ /// appinfo's `common.oslist` names macOS. Not proof of a Mac build that still runs (Portal's
+ /// 32-bit one is still listed), only which games are worth asking the store about (MacFlagStore).
+ public var listsMac = false
- public init(appid: Int, name: String, localCapsule: URL? = nil, localHeader: URL? = nil) {
+ public init(appid: Int, name: String, localCapsule: URL? = nil, localHeader: URL? = nil, listsMac: Bool = false) {
self.appid = appid; self.name = name; self.localCapsule = localCapsule; self.localHeader = localHeader
+ self.listsMac = listsMac
}
/// Local art first: newer apps keep theirs at hashed store paths, so the fixed CDN name
@@ -52,7 +56,8 @@ public enum SteamOwnedLibrary {
guard let app = apps[appid], app.type?.lowercased() == "game", let name = app.name else { return nil }
let art = artwork(in: cache.appending(path: String(appid)))
return OwnedSteamGame(appid: appid, name: name, localCapsule: art["library_600x900.jpg"],
- localHeader: art["library_header.jpg"] ?? art["header.jpg"])
+ localHeader: art["library_header.jpg"] ?? art["header.jpg"],
+ listsMac: app.oslist?.lowercased().contains("macos") ?? false)
}
.sorted { $0.name.localizedCaseInsensitiveCompare($1.name) == .orderedAscending }
}
diff --git a/Tests/HighballKitTests/MacSteamBuildTests.swift b/Tests/HighballKitTests/MacSteamBuildTests.swift
new file mode 100644
index 0000000..b3676b7
--- /dev/null
+++ b/Tests/HighballKitTests/MacSteamBuildTests.swift
@@ -0,0 +1,133 @@
+import XCTest
+@testable import HighballKit
+
+final class MacSteamBuildTests: XCTestCase {
+ private func entry(_ json: String) throws -> GameDBEntry {
+ try JSONDecoder().decode(GameDBEntry.self, from: Data(json.utf8))
+ }
+
+ // MARK: Mac builds on Steam
+
+ func testStoreFlagAloneMarksIt() {
+ XCTAssertEqual(MacSteamBuild.resolve(entry: nil, storeMac: true), .onStore)
+ XCTAssertNil(MacSteamBuild.resolve(entry: nil, storeMac: false))
+ XCTAssertNil(MacSteamBuild.resolve(entry: nil, storeMac: nil), "not asked yet is not a Mac build")
+ }
+
+ func testRowNamingSteamMarksIt() throws {
+ let hades = try entry(#"{"id":"hades-ii","title":"Hades II","steam_appid":1145350,"status":"community","nativeMac":{"available":true,"where":"Steam","note":"Native Apple Silicon build, macOS 12 and M1 or later."}}"#)
+ XCTAssertEqual(MacSteamBuild.resolve(entry: hades, storeMac: nil), .inDatabase)
+ // Rows list every store; Steam among them is enough.
+ let cyberpunk = try entry(#"{"id":"cyberpunk-2077","title":"Cyberpunk 2077","steam_appid":1091500,"status":"community","nativeMac":{"available":true,"where":"Steam, Mac App Store, GOG, Epic"}}"#)
+ XCTAssertEqual(MacSteamBuild.resolve(entry: cyberpunk, storeMac: nil), .inDatabase)
+ }
+
+ func testInstalledInSteamForMacNeedsNoOneElse() throws {
+ XCTAssertEqual(MacSteamBuild.resolve(entry: nil, storeMac: nil, installedOnMac: true), .installed)
+ let retired = try entry(#"{"id":"x","title":"X","steam_appid":1,"status":"community","nativeMac":{"available":false}}"#)
+ XCTAssertEqual(MacSteamBuild.resolve(entry: retired, storeMac: false, installedOnMac: true), .installed,
+ "it's installed and the player has it: that outranks any row")
+ }
+
+ // MARK: Steam for Mac's installs
+
+ private func macSteam(_ manifests: [String: [(Int, String, Int)]], extraLibrary: URL? = nil) throws -> URL {
+ let root = FileManager.default.temporaryDirectory.appending(path: "hb-macsteam-\(UUID())/Steam")
+ addTeardownBlock { try? FileManager.default.removeItem(at: root.deletingLastPathComponent()) }
+ for (library, games) in manifests {
+ let dir = (library == "root" ? root : root.deletingLastPathComponent().appending(path: library)).appending(path: "steamapps")
+ try FileManager.default.createDirectory(at: dir, withIntermediateDirectories: true)
+ for (appid, name, flags) in games {
+ try #""AppState" { "appid" "\#(appid)" "name" "\#(name)" "StateFlags" "\#(flags)" "installdir" "\#(name)" }"#
+ .write(to: dir.appending(path: "appmanifest_\(appid).acf"), atomically: true, encoding: .utf8)
+ }
+ }
+ let other = root.deletingLastPathComponent().appending(path: "External Drive")
+ try #"""
+ "libraryfolders" { "0" { "path" "\#(root.path)" } "1" { "path" "\#(other.path)" } }
+ """#.write(to: root.appending(path: "steamapps/libraryfolders.vdf"), atomically: true, encoding: .utf8)
+ return root
+ }
+
+ func testReadsEveryMacLibraryFolderAndOnlyFinishedInstalls() throws {
+ let root = try macSteam([
+ "root": [(2379780, "Balatro", 4), (268910, "Cuphead", 1026), (228980, "Steamworks Common Redistributables", 4)],
+ "External Drive": [(588650, "Dead Cells", 4), (2379780, "Balatro", 4)],
+ ])
+ XCTAssertEqual(MacSteam.steamappsDirectories(root: root).count, 2, "the root listed again isn't a second library")
+ XCTAssertEqual(MacSteam.installedGames(root: root).map(\.appid), [2379780, 588650],
+ "Cuphead is still downloading; redistributables aren't a game; one Balatro")
+ }
+
+ func testNoSteamForMacIsNothingInstalled() {
+ let nowhere = FileManager.default.temporaryDirectory.appending(path: "hb-nosteam-\(UUID())")
+ XCTAssertEqual(MacSteam.installedGames(root: nowhere), [])
+ }
+
+ func testRowCanRetireAPortTheStoreStillLists() throws {
+ let retired = try entry(#"{"id":"x","title":"X","steam_appid":1,"status":"community","nativeMac":{"available":false,"note":"32-bit, stopped running with Catalina"}}"#)
+ XCTAssertNil(MacSteamBuild.resolve(entry: retired, storeMac: true))
+ }
+
+ func testEditionSoldElsewhereIsNotMarked() throws {
+ // Death Stranding's Mac edition is a separate Mac App Store purchase: not marked.
+ let ds = try entry(#"{"id":"death-stranding","title":"Death Stranding","steam_appid":1190460,"status":"community","nativeMac":{"available":true,"where":"Mac App Store only","note":"A native Director's Cut exists on the Mac App Store."}}"#)
+ XCTAssertNil(MacSteamBuild.resolve(entry: ds, storeMac: false))
+ }
+
+ // MARK: store
+
+ func testParsesStorePlatforms() {
+ let portal = #"{"400":{"success":true,"data":{"platforms":{"windows":true,"mac":false,"linux":true}}}}"#
+ let hades = #"{"1145360":{"success":true,"data":{"platforms":{"windows":true,"mac":true,"linux":false}}}}"#
+ XCTAssertEqual(MacFlagStore.parse(Data(portal.utf8)), false)
+ XCTAssertEqual(MacFlagStore.parse(Data(hades.utf8)), true)
+ XCTAssertNil(MacFlagStore.parse(Data(#"{"999":{"success":false}}"#.utf8)), "no store page is not a no")
+ XCTAssertNil(MacFlagStore.parse(Data("<html>".utf8)))
+ }
+
+ func testAsksOnlyAboutGamesAppinfoListsForMacOS() {
+ // 1145350 lists macOS, 570940 doesn't, 400 isn't in the owned list yet: asked, unknown.
+ XCTAssertEqual(MacFlagStore.worthAsking([1145350, 570940, 400], listsMac: [1145350: true, 570940: false]),
+ [1145350, 400])
+ }
+
+ func testCacheKeepsTwoWeeks() throws {
+ let file = FileManager.default.temporaryDirectory.appending(path: "mac-flags-\(UUID()).json")
+ defer { try? FileManager.default.removeItem(at: file) }
+ let store = MacFlagStore(file: file)
+ let then = Date(timeIntervalSince1970: 1_790_000_000)
+ store.save([400: false, 1145360: true], now: then)
+ XCTAssertEqual(store.load(now: then.addingTimeInterval(13 * 86400)), [400: false, 1145360: true])
+ XCTAssertEqual(store.load(now: then.addingTimeInterval(15 * 86400)), [:])
+ }
+
+ func testCorruptCacheIsEmpty() throws {
+ let file = FileManager.default.temporaryDirectory.appending(path: "mac-flags-\(UUID()).json")
+ defer { try? FileManager.default.removeItem(at: file) }
+ try Data("not json".utf8).write(to: file)
+ XCTAssertEqual(MacFlagStore(file: file).load(), [:])
+ }
+
+ // MARK: page copy
+
+ func testPageCopyNamesSourceAndRequirements() throws {
+ XCTAssertNil(GamePageCopy.macBuild(nil, entry: nil, myChip: "Apple M1 Pro", macOS: "26.6.2"))
+
+ let hades = try entry(#"{"id":"hades-ii","title":"Hades II","steam_appid":1145350,"status":"community","nativeMac":{"available":true,"where":"Steam","note":"Native Apple Silicon build, macOS 12 and M1 or later."}}"#)
+ let fromRow = try XCTUnwrap(GamePageCopy.macBuild(.inDatabase, entry: hades, myChip: "Apple M1 Pro", macOS: "26.6.2"))
+ XCTAssertEqual(fromRow.headline, "There is a native Mac build on Steam.")
+ XCTAssertEqual(fromRow.requirements, "Native Apple Silicon build, macOS 12 and M1 or later.")
+ XCTAssertEqual(fromRow.yourMac, "Your Mac is an M1 Pro on macOS 26.6.2.")
+ XCTAssertEqual(fromRow.source, "From the compatibility database.")
+
+ let fromStore = try XCTUnwrap(GamePageCopy.macBuild(.onStore, entry: nil, myChip: "Apple M1 Pro", macOS: "26.6.2"))
+ XCTAssertNil(fromStore.requirements)
+ XCTAssertEqual(fromStore.source, "Steam's store page lists macOS for it.")
+
+ let installed = try XCTUnwrap(GamePageCopy.macBuild(.installed, entry: hades, myChip: "Apple M1 Pro", macOS: "26.6.2"))
+ XCTAssertEqual(installed.headline, "Installed in Steam for Mac.")
+ XCTAssertEqual(installed.requirements, "Native Apple Silicon build, macOS 12 and M1 or later.")
+ XCTAssertEqual(installed.source, "Steam for Mac lists it as installed.")
+ }
+}
diff --git a/Tests/HighballKitTests/SteamOwnedLibraryTests.swift b/Tests/HighballKitTests/SteamOwnedLibraryTests.swift
index 3ff0280..beef174 100644
--- a/Tests/HighballKitTests/SteamOwnedLibraryTests.swift
+++ b/Tests/HighballKitTests/SteamOwnedLibraryTests.swift
@@ -89,6 +89,7 @@ final class SteamOwnedLibraryTests: XCTestCase {
let root = try steamRoot(owned: [1145360, 570940, 1145361, 228980, 999], appinfo: appinfo(apps))
let games = SteamOwnedLibrary.games(steamRoot: root)
XCTAssertEqual(games.map(\.appid), [570940, 1145360], "games only, by name")
+ XCTAssertEqual(games.map(\.listsMac), [false, true], "appinfo's oslist, for MacFlagStore")
XCTAssertEqual(games.first?.capsuleImage.absoluteString,
"https://cdn.akamai.steamstatic.com/steam/apps/570940/library_600x900.jpg")
}
@@ -148,4 +149,29 @@ final class SteamOwnedLibraryTests: XCTestCase {
XCTAssertFalse(hadesItem.installed)
XCTAssertEqual(hadesItem.bottleName, "a", "owned-only games live in the first bottle by name")
}
+
+ func testSteamForMacInstallsCountAsInstalled() {
+ let a = bottle("a"), b = bottle("b")
+ let windows = SteamGame(appid: 570940, name: "DARK SOULS™: REMASTERED", installdir: "DSR", sizeOnDisk: 1, stateFlags: 4, lastPlayed: nil)
+ let played = Date(timeIntervalSince1970: 1_790_000_000)
+ func mac(_ appid: Int, _ name: String, _ lastPlayed: Date? = nil) -> SteamGame {
+ SteamGame(appid: appid, name: name, installdir: name, sizeOnDisk: 1, stateFlags: 4, lastPlayed: lastPlayed)
+ }
+ let items = LibraryIndex.build(
+ bottles: [b, a],
+ steamByBottle: ["b": [windows]],
+ steamOwnedByBottle: ["a": [OwnedSteamGame(appid: 1145360, name: "Hades")]],
+ macInstalled: [mac(570940, "DARK SOULS™: REMASTERED"), mac(1145360, "Hades", played), mac(268910, "Cuphead")],
+ epicOwned: [], epicInstalls: [:])
+ XCTAssertEqual(items.map(\.id), ["steam:268910", "steam:570940", "steam:1145360"], "one tile per game, Mac or not")
+ let dsr = items.first { $0.steamAppID == 570940 }!
+ XCTAssertTrue(dsr.installed && dsr.installedOnMac, "both builds")
+ let hades = items.first { $0.steamAppID == 1145360 }!
+ XCTAssertFalse(hades.installed)
+ XCTAssertTrue(hades.installedAnywhere)
+ XCTAssertEqual(hades.lastPlayed, played, "Steam for Mac's LastPlayed feeds Continue")
+ let cuphead = items.first { $0.steamAppID == 268910 }!
+ XCTAssertTrue(cuphead.installedOnMac, "no bottle knows it: a tile of its own")
+ XCTAssertEqual(cuphead.bottleName, "a", "homed where a Windows install would go")
+ }
}