Skip to content

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

Library Phase 1: Epic games become first-class cards; per-bottle install truth

Gauthier Piarrettef4d8cb64955c
diff --git a/Sources/HighballApp/AppState.swift b/Sources/HighballApp/AppState.swift
index 15394f7..c020de4 100644
--- a/Sources/HighballApp/AppState.swift
+++ b/Sources/HighballApp/AppState.swift
@@ -51,7 +51,10 @@ final class AppState {
// Epic (via Legendary; see EpicStore)
var epicSignedIn = false
var epicOwned: [EpicStore.Game] = []
- var epicInstalled: Set<String> = []
+ /// app_name → install_path. Legendary's install state is global; which bottle a game
+ /// lives in is decided by its path, via epicInstalled(_:in:). (The old Set-of-names
+ /// showed Play in bottles that had no files.)
+ var epicInstalls: [String: String] = [:]
var epicLoading = false
private var epicFetchInFlight = false
var showEpicSignIn = false
@@ -358,22 +361,30 @@ final class AppState {
func epicRefresh() {
epicSignedIn = epicStore.isAuthenticated
- guard epicSignedIn else { epicOwned = []; epicInstalled = []; return }
+ guard epicSignedIn else { epicOwned = []; epicInstalls = [:]; return }
guard !epicFetchInFlight else { return }
epicFetchInFlight = true
epicLoading = epicOwned.isEmpty
Task.detached { [store = epicStore] in
let owned = (try? store.ownedGames()) ?? []
- let installed = (try? store.installedAppNames()) ?? []
+ let installed = (try? store.installedGames()) ?? []
await MainActor.run { [weak self] in
self?.epicOwned = owned.sorted { $0.app_title < $1.app_title }
- self?.epicInstalled = installed
+ self?.epicInstalls = Dictionary(uniqueKeysWithValues:
+ installed.compactMap { g in g.install_path.map { (g.app_name, $0) } })
self?.epicLoading = false
self?.epicFetchInFlight = false
}
}
}
+ /// Installed *in this bottle* — a game legendary installed into another bottle's
+ /// drive_c is not playable here.
+ func epicInstalled(_ appName: String, in bottle: Bottle) -> Bool {
+ guard let path = epicInstalls[appName] else { return false }
+ return EpicStore.isInstalled(path: path, inDriveC: bottle.driveC)
+ }
+
func epicSignIn(code: String) {
runBusy("Connecting your Epic account", showLogSheet: false) { [self] in
let store = epicStore
@@ -398,7 +409,8 @@ final class AppState {
}
}
- func epicPlay(_ game: EpicStore.Game, in bottle: Bottle, renderer: Renderer? = .dxvk) {
+ // renderer nil = the bottle's own renderer (the old hardcoded .dxvk default ignored it).
+ func epicPlay(_ game: EpicStore.Game, in bottle: Bottle, renderer: Renderer? = nil) {
guard let engine = engine(for: bottle) else { return }
runBusy("Running \(game.app_title)", showLogSheet: false) { [self] in
let store = epicStore
diff --git a/Sources/HighballApp/BottleView.swift b/Sources/HighballApp/BottleView.swift
index 213c7bd..51ff233 100644
--- a/Sources/HighballApp/BottleView.swift
+++ b/Sources/HighballApp/BottleView.swift
@@ -27,8 +27,11 @@ struct BottleView: View {
@Environment(AppState.self) private var state
let bottle: Bottle
+ // epic-games is deliberately absent: its installer cannot pass its permission audit
+ // under Wine (issue #14) — the Epic path is "Connect Epic account" (Legendary) below,
+ // and showing an "Install Epic Games" tile above it contradicted that.
static let launcherMeta: [(id: String, symbol: String, short: String)] = [
- ("steam", "gamecontroller.fill", "Steam"), ("epic-games", "e.circle.fill", "Epic Games"),
+ ("steam", "gamecontroller.fill", "Steam"),
("battle-net", "shield.fill", "Battle.net"), ("gog-galaxy", "g.circle.fill", "GOG Galaxy"),
("ea-app", "e.square.fill", "EA app"), ("ubisoft-connect", "u.circle.fill", "Ubisoft"),
("rockstar", "r.circle.fill", "Rockstar"),
@@ -144,35 +147,27 @@ struct BottleView: View {
Text(L("No games on this Epic account yet. Claimed games appear here."))
.font(.callout).foregroundStyle(.secondary)
} else {
- LazyVGrid(columns: [GridItem(.adaptive(minimum: 150, maximum: 210), spacing: 12)], spacing: 12) {
+ // Same card component and grid metrics as the Steam section: one visual
+ // language for games, whatever the store (library unification Phase 1).
+ LazyVGrid(columns: [GridItem(.adaptive(minimum: 280, maximum: 400), spacing: 16)], spacing: 16) {
ForEach(state.epicOwned, id: \.app_name) { g in
- let installed = state.epicInstalled.contains(g.app_name)
- VStack(alignment: .leading, spacing: 6) {
- Text(g.app_title).font(.callout.weight(.semibold)).lineLimit(2)
- .frame(maxWidth: .infinity, alignment: .leading)
- HStack {
- if installed {
- Button(L("Play")) { state.epicPlay(g, in: bottle) }
- .buttonStyle(.borderedProminent).controlSize(.small).disabled(state.busy)
- } else {
- Button(L("Install")) { state.epicInstall(g, in: bottle) }
- .controlSize(.small).disabled(state.busy)
- }
- Spacer()
- }
- }
- .padding(12)
- .background(RoundedRectangle(cornerRadius: 10).fill(HB.card))
+ let installed = state.epicInstalled(g.app_name, in: bottle)
+ GameCard(model: GameCardModel(title: g.app_title, artwork: g.artworkWide,
+ entry: nil, installed: installed),
+ busy: state.busy,
+ play: { state.epicPlay(g, in: bottle) },
+ install: { state.epicInstall(g, in: bottle) })
.contextMenu {
if installed {
- Button(L("Play with D3DMetal")) { state.epicPlay(g, in: bottle, renderer: .d3dmetal) }
- Button(L("Play with DXMT")) { state.epicPlay(g, in: bottle, renderer: .dxmt) }
+ ForEach(HighballKit.Renderer.allCases, id: \.self) { r in
+ Button(String(format: L("Play with %@"), r.rawValue.uppercased())) {
+ state.epicPlay(g, in: bottle, renderer: r)
+ }
+ }
}
}
}
}
- Text(L("Epic games launch with DXVK, the renderer that works for most of them. Right-click a game to try another."))
- .font(.caption).foregroundStyle(.secondary)
}
}
.sheet(isPresented: Binding(get: { state.showEpicSignIn }, set: { state.showEpicSignIn = $0 })) {
@@ -203,7 +198,9 @@ struct BottleView: View {
} else {
LazyVGrid(columns: [GridItem(.adaptive(minimum: 280, maximum: 400), spacing: 16)], spacing: 16) {
ForEach(games) { game in
- GameCard(game: game, entry: state.gameDB[game.appid], busy: state.busy) {
+ GameCard(model: GameCardModel(title: game.name, artwork: game.headerImage,
+ entry: state.gameDB[game.appid], installed: game.isReady),
+ busy: state.busy) {
state.launchGame(game, in: bottle)
}
}
@@ -297,15 +294,27 @@ struct BottleBackdrop: View {
// MARK: - Game card: artwork-first, Play on hover
+/// Source-neutral input for GameCard: one card component for every store, same geometry,
+/// same affordances (library unification Phase 1 — Steam and Epic stop speaking different
+/// visual languages on the same screen).
+struct GameCardModel {
+ var title: String
+ var artwork: URL?
+ var entry: GameDBEntry?
+ /// Installed in the current bottle. False shows the card dimmed with an install
+ /// affordance (when `install` is provided) instead of Play.
+ var installed: Bool
+}
+
struct GameCard: View {
- let game: SteamGame
- let entry: GameDBEntry?
+ let model: GameCardModel
let busy: Bool
let play: () -> Void
+ var install: (() -> Void)? = nil
@State private var hovering = false
private var verdict: (String, Color)? {
- switch entry?.status {
+ switch model.entry?.status {
case "verified-local": return (L("Verified"), HB.good)
case "reported-upstream": return (L("Reported"), Color(red: 0.55, green: 0.70, blue: 0.90))
case "community": return (L("Community"), HB.warn)
@@ -313,16 +322,17 @@ struct GameCard: View {
default: return nil
}
}
- private var blocked: Bool { entry?.isBlocked == true }
- private var playable: Bool { game.isReady && !blocked && !busy }
+ private var blocked: Bool { model.entry?.isBlocked == true }
+ private var playable: Bool { model.installed && !blocked && !busy }
+ private var installable: Bool { !model.installed && install != nil && !blocked && !busy }
var body: some View {
- Button(action: { if playable { play() } }) {
+ Button(action: { if playable { play() } else if installable { install?() } }) {
ZStack(alignment: .bottomLeading) {
Color.clear
.aspectRatio(460 / 215, contentMode: .fit)
.overlay(
- AsyncImage(url: game.headerImage) { phase in
+ AsyncImage(url: model.artwork) { phase in
switch phase {
case .success(let image):
image.resizable().scaledToFill()
@@ -333,7 +343,8 @@ struct GameCard: View {
}
}
}
- .saturation(blocked ? 0.15 : 1)
+ .saturation(blocked ? 0.15 : (model.installed ? 1 : 0.45))
+ .brightness(model.installed ? 0 : -0.08)
)
.clipped()
@@ -341,7 +352,7 @@ struct GameCard: View {
startPoint: .bottom, endPoint: .center)
VStack(alignment: .leading, spacing: 5) {
- Text(game.name)
+ Text(model.title)
.font(.system(size: 15, weight: .bold, design: .rounded))
.foregroundStyle(.white)
.lineLimit(1)
@@ -355,32 +366,37 @@ struct GameCard: View {
.overlay(Capsule().stroke(color.opacity(0.8), lineWidth: 1))
.foregroundStyle(color)
}
- if let r = entry?.renderer {
+ if let r = model.entry?.renderer {
Text(r.rawValue.uppercased())
.font(.system(size: 9.5, weight: .medium).monospaced())
.foregroundStyle(.white.opacity(0.75))
}
if blocked {
- Text(entry?.anticheat?.names.first ?? "anti-cheat")
+ Text(model.entry?.anticheat?.names.first ?? "anti-cheat")
.font(.system(size: 9.5).monospaced())
.foregroundStyle(HB.bad.opacity(0.9))
.lineLimit(1)
}
+ if installable {
+ Text(L("Not installed"))
+ .font(.system(size: 9.5).monospaced())
+ .foregroundStyle(.white.opacity(0.6))
+ }
}
}
.padding(12)
- if hovering && playable {
+ if hovering && (playable || installable) {
ZStack {
Color.black.opacity(0.25)
ZStack {
- Circle().fill(HB.amber)
+ Circle().fill(playable ? HB.amber : Color.white.opacity(0.88))
.frame(width: 52, height: 52)
.shadow(color: .black.opacity(0.45), radius: 10, y: 3)
- Image(systemName: "play.fill")
+ Image(systemName: playable ? "play.fill" : "arrow.down")
.font(.system(size: 21, weight: .bold))
.foregroundStyle(Color(red: 0.13, green: 0.08, blue: 0.01))
- .offset(x: 1.5)
+ .offset(x: playable ? 1.5 : 0)
}
}
.transition(.opacity)
@@ -388,14 +404,14 @@ struct GameCard: View {
}
.clipShape(RoundedRectangle(cornerRadius: 12))
.overlay(RoundedRectangle(cornerRadius: 12).stroke(hovering ? HB.amber.opacity(0.55) : HB.cardStroke, lineWidth: 1))
- .scaleEffect(hovering && playable ? 1.02 : 1)
+ .scaleEffect(hovering && (playable || installable) ? 1.02 : 1)
.shadow(color: .black.opacity(hovering ? 0.45 : 0.25), radius: hovering ? 14 : 7, y: 4)
}
.buttonStyle(.plain)
.animation(.spring(duration: 0.22), value: hovering)
.onHover { hovering = $0 }
- .help(entry?.notes ?? game.name)
- .accessibilityLabel("\(game.name), \(verdict?.0 ?? "")")
+ .help(model.entry?.notes ?? model.title)
+ .accessibilityLabel("\(model.title), \(verdict?.0 ?? (model.installed ? "" : L("Not installed")))")
}
}
diff --git a/Sources/HighballApp/L10n.swift b/Sources/HighballApp/L10n.swift
index 7344569..6fc2cd0 100644
--- a/Sources/HighballApp/L10n.swift
+++ b/Sources/HighballApp/L10n.swift
@@ -133,6 +133,9 @@ enum L10n {
"running for %d min": "en cours depuis %d min",
"active": "actif",
"quiet — can be normal, see Details": "silencieux — peut être normal, voir Détails",
+ // Unified game cards (library Phase 1)
+ "Not installed": "Non installé",
+ "Play with %@": "Jouer avec %@",
"Hide": "Masquer",
"Close": "Fermer",
"Details": "Détails",
diff --git a/Sources/HighballKit/EpicStore.swift b/Sources/HighballKit/EpicStore.swift
index 21b36bb..bccd18e 100644
--- a/Sources/HighballKit/EpicStore.swift
+++ b/Sources/HighballKit/EpicStore.swift
@@ -100,6 +100,45 @@ public struct EpicStore: Sendable {
public struct Game: Codable, Sendable {
public let app_name: String
public let app_title: String
+ /// Epic's own catalog art, embedded by legendary in `list --json` metadata.keyImages.
+ /// Wide (DieselGameBox) fits the 460:215 game card; tall (DieselGameBoxTall) is the
+ /// 2:3 cover for the future unified library. Same type mapping Heroic uses.
+ public let artworkWide: URL?
+ public let artworkTall: URL?
+
+ public init(app_name: String, app_title: String, artworkWide: URL? = nil, artworkTall: URL? = nil) {
+ self.app_name = app_name; self.app_title = app_title
+ self.artworkWide = artworkWide; self.artworkTall = artworkTall
+ }
+
+ private enum CodingKeys: String, CodingKey { case app_name, app_title, metadata }
+ private enum MetadataKeys: String, CodingKey { case keyImages }
+ private struct KeyImage: Codable { let type: String?; let url: String? }
+
+ public init(from decoder: Decoder) throws {
+ let c = try decoder.container(keyedBy: CodingKeys.self)
+ app_name = try c.decode(String.self, forKey: .app_name)
+ app_title = try c.decode(String.self, forKey: .app_title)
+ var images: [KeyImage] = []
+ if let md = try? c.nestedContainer(keyedBy: MetadataKeys.self, forKey: .metadata) {
+ images = (try? md.decode([KeyImage].self, forKey: .keyImages)) ?? []
+ }
+ func first(_ types: [String]) -> URL? {
+ for t in types {
+ if let u = images.first(where: { $0.type == t })?.url, let url = URL(string: u) { return url }
+ }
+ return nil
+ }
+ artworkWide = first(["DieselGameBox", "OfferImageWide"])
+ artworkTall = first(["DieselGameBoxTall", "OfferImageTall", "DieselStoreFrontTall"])
+ }
+
+ public func encode(to encoder: Encoder) throws {
+ // Artwork is derived from legendary's metadata on every decode; only identity persists.
+ var c = encoder.container(keyedBy: CodingKeys.self)
+ try c.encode(app_name, forKey: .app_name)
+ try c.encode(app_title, forKey: .app_title)
+ }
}
/// Games the account owns (Windows builds).
@@ -108,11 +147,25 @@ public struct EpicStore: Sendable {
return try JSONDecoder().decode([Game].self, from: Data(out.utf8))
}
- struct InstalledGame: Codable { let app_name: String }
- /// App names of installed games (this endpoint uses `title`, not `app_title`, so it gets its own type).
- public func installedAppNames() throws -> Set<String> {
+ public struct InstalledGame: Codable, Sendable {
+ public let app_name: String
+ public let install_path: String?
+ }
+
+ /// Everything legendary has installed, with where. Legendary's install state is global
+ /// across bottles; the bottle association lives in the path, so callers must check it
+ /// with `isInstalled(path:inDriveC:)` — a game installed in bottle A is NOT installed
+ /// in bottle B (the old Set-of-names API showed Play in bottles that had no files).
+ public func installedGames() throws -> [InstalledGame] {
let out = try capture(["list-installed", "--json"])
- return Set(try JSONDecoder().decode([InstalledGame].self, from: Data(out.utf8)).map(\.app_name))
+ return try JSONDecoder().decode([InstalledGame].self, from: Data(out.utf8))
+ }
+
+ /// True when an install path lies inside the given bottle's drive_c.
+ public static func isInstalled(path: String, inDriveC driveC: URL) -> Bool {
+ let p = URL(fileURLWithPath: path).standardizedFileURL.path + "/"
+ let c = driveC.standardizedFileURL.path + "/"
+ return p.hasPrefix(c)
}
/// Installs a game's Windows build into the bottle at drive_c/Games/<folder>.
diff --git a/Sources/highball/main.swift b/Sources/highball/main.swift
index f3d583a..74554ca 100644
--- a/Sources/highball/main.swift
+++ b/Sources/highball/main.swift
@@ -528,9 +528,13 @@ struct Epic: AsyncParsableCommand {
let store = EpicStore()
_ = try await store.ensureInstalled()
guard store.isAuthenticated else { fail("not signed in — run 'highball epic login' first") }
- let installed = (try? store.installedAppNames()) ?? []
+ // Flat account view: show where each installed game lives, since legendary's
+ // install state is global but the files belong to one bottle.
+ let installed = Dictionary(uniqueKeysWithValues:
+ ((try? store.installedGames()) ?? []).compactMap { g in g.install_path.map { (g.app_name, $0) } })
for g in try store.ownedGames().sorted(by: { $0.app_title < $1.app_title }) {
- print("\(installed.contains(g.app_name) ? "[installed] " : "")\(g.app_name)\t\(g.app_title)")
+ let mark = installed[g.app_name].map { "[installed: \(($0 as NSString).abbreviatingWithTildeInPath)] " } ?? ""
+ print("\(mark)\(g.app_name)\t\(g.app_title)")
}
}
}
diff --git a/Tests/HighballKitTests/RegressionTests.swift b/Tests/HighballKitTests/RegressionTests.swift
index 0c1345b..aa8d07d 100644
--- a/Tests/HighballKitTests/RegressionTests.swift
+++ b/Tests/HighballKitTests/RegressionTests.swift
@@ -300,4 +300,36 @@ extension RegressionTests {
let again = try JSONDecoder.highball.decode(Recipe.self, from: reencoded)
XCTAssertEqual(again.steps[0].slowHint, "takes 20-40 minutes and can look idle")
}
+
+ // Library Phase 1: Epic artwork comes from legendary's embedded catalog metadata
+ // (same keyImages mapping Heroic uses); a game without metadata must still decode.
+ func testEpicGameArtworkDecoding() throws {
+ let json = """
+ [{"app_name":"Duck","app_title":"Cardpocalypse","metadata":{"keyImages":[
+ {"type":"DieselGameBox","url":"https://cdn1.epicgames.com/item/x/wide.jpg"},
+ {"type":"DieselGameBoxTall","url":"https://cdn1.epicgames.com/item/x/tall.jpg"},
+ {"type":"Thumbnail","url":"https://cdn1.epicgames.com/item/x/thumb.jpg"}]}},
+ {"app_name":"Bare","app_title":"No Art"}]
+ """
+ let games = try JSONDecoder().decode([EpicStore.Game].self, from: Data(json.utf8))
+ XCTAssertEqual(games[0].artworkWide?.absoluteString, "https://cdn1.epicgames.com/item/x/wide.jpg")
+ XCTAssertEqual(games[0].artworkTall?.absoluteString, "https://cdn1.epicgames.com/item/x/tall.jpg")
+ XCTAssertNil(games[1].artworkWide, "missing metadata decodes, without artwork")
+ XCTAssertNil(games[1].artworkTall)
+ }
+
+ // Library Phase 1: legendary's install state is global; the bottle association is the
+ // install path. A game installed in bottle A must not read as installed in bottle B,
+ // and a sibling bottle whose name shares a prefix must not false-positive.
+ func testEpicInstallStateIsPerBottle() {
+ let a = URL(fileURLWithPath: "/tmp/bottles/actest/drive_c")
+ let b = URL(fileURLWithPath: "/tmp/bottles/spike/drive_c")
+ let path = "/tmp/bottles/actest/drive_c/Games/Cardpocalypse"
+ XCTAssertTrue(EpicStore.isInstalled(path: path, inDriveC: a))
+ XCTAssertFalse(EpicStore.isInstalled(path: path, inDriveC: b))
+ XCTAssertFalse(EpicStore.isInstalled(path: "/tmp/bottles/actest2/drive_c/Games/X",
+ inDriveC: a), "prefix of a sibling bottle must not match")
+ XCTAssertTrue(EpicStore.isInstalled(path: "/tmp/bottles/actest/drive_c", inDriveC: a),
+ "drive_c itself counts as inside")
+ }
}