Run Windows games on Apple Silicon — free, open source, with an open compatibility database that tells you what actually works.
Swift apple-silicond3dmetaldxmtdxvkfexgame-porting-toolkitgamingmac-gamingmacosmetalmoltenvksteamswiftuivkd3d-protonwhisky-alternativewindows-gameswinewine-wrapper
Play means 'make it work': auto-apply verified fixes at Play; per-app DXVK config as data
Gauthier Piarrette2f305bea4661
diff --git a/GameDetailView.swiftdeps~ b/GameDetailView.swiftdeps~index 2e02c37..80311a3 100644Binary files a/GameDetailView.swiftdeps~ and b/GameDetailView.swiftdeps~ differdiff --git a/LibraryTests.swiftdeps~ b/LibraryTests.swiftdeps~new file mode 100644index 0000000..f9a9ae2Binary files /dev/null and b/LibraryTests.swiftdeps~ differdiff --git a/LibraryView.swiftdeps~ b/LibraryView.swiftdeps~index 2a53dbe..aee60e5 100644Binary files a/LibraryView.swiftdeps~ and b/LibraryView.swiftdeps~ differdiff --git a/Sources/HighballApp/AppState.swift b/Sources/HighballApp/AppState.swiftindex f435dff..e9d84ee 100644--- a/Sources/HighballApp/AppState.swift+++ b/Sources/HighballApp/AppState.swift@@ -64,15 +64,70 @@ final class AppState {plays: libraryPlays)}+ /// The verified fix recipe for a library item, if the db has one (db entry id == recipe id).+ func fixRecipe(for item: LibraryItem) -> HighballKit.Recipe? {+ guard let appid = item.steamAppID, let entry = gameDB[appid],+ let recipe = Self.recipe(entry.id), recipe.kind == .game else { return nil }+ return recipe+ }++ /// A heavy fix waiting on the user's word before Play continues (installer/winetricks+ /// class — honest prompt with the time cost instead of a silent 30-minute surprise).+ var pendingHeavyFix: (item: LibraryItem, recipe: HighballKit.Recipe)?+/// The "never pick a bottle first" guarantee: every Play in the library resolves the- /// item's own bottle and dispatches by source.+ /// item's own bottle and dispatches by source. Play also means "make it work the way+ /// the db verified it": an unapplied fix recipe whose steps are all harmless (config+ /// files, renderer — no wine processes, no installs) is applied silently first; one+ /// with heavy steps asks, with the cost stated.func play(_ item: LibraryItem) {guard let bottleName = item.bottleName,let bottle = bottles.first(where: { $0.name == bottleName }) else { return }+ if let recipe = fixRecipe(for: item), !bottle.settings.recipes.contains(recipe.id),+ let engine = engine(for: bottle) {+ if recipe.isAutoApplicable {+ Task { @MainActor in+ var runner = RecipeRunner(paths: paths, engine: engine, bottle: bottle)+ if let notes = try? await runner.apply(recipe) {+ logLines.append("applied the \(recipe.title) fix")+ for n in notes { logLines.append("note: \(n)") }+ }+ refresh()+ let fresh = bottles.first { $0.name == bottleName } ?? runner.bottle+ launch(item, in: fresh)+ }+ return+ }+ pendingHeavyFix = (item, recipe)+ return // Play continues via confirmHeavyFix or skipHeavyFix+ }+ launch(item, in: bottle)+ }++ /// User confirmed the heavy fix: apply it (busy sheet shows progress), then launch.+ func confirmHeavyFix() {+ guard let (item, recipe) = pendingHeavyFix else { return }+ pendingHeavyFix = nil+ guard let bottleName = item.bottleName,+ let bottle = bottles.first(where: { $0.name == bottleName }) else { return }+ applyRecipe(recipe.id, to: bottle)+ // The user presses Play again after the install — auto-chaining a launch onto a+ // 30-minute install would fire it long after they stopped watching.+ }++ func skipHeavyFix() {+ guard let (item, _) = pendingHeavyFix else { return }+ pendingHeavyFix = nil+ guard let bottleName = item.bottleName,+ let bottle = bottles.first(where: { $0.name == bottleName }) else { return }+ launch(item, in: bottle)+ }++ private func launch(_ item: LibraryItem, in bottle: Bottle) {recordPlay(item)switch item.source {case .steam:- guard let game = (gamesByBottle[bottleName] ?? []).first(where: { $0.appid == item.steamAppID }) else { return }+ guard let game = (gamesByBottle[bottle.name] ?? []).first(where: { $0.appid == item.steamAppID }) else { return }launchGame(game, in: bottle)case .epic:guard let game = epicOwned.first(where: { $0.app_name == item.epicAppName }) else { return }diff --git a/Sources/HighballApp/GameDetailView.swift b/Sources/HighballApp/GameDetailView.swiftindex dfdaf1d..a646068 100644--- a/Sources/HighballApp/GameDetailView.swift+++ b/Sources/HighballApp/GameDetailView.swift@@ -11,11 +11,9 @@ struct GameDetailView: View {private var entry: GameDBEntry? { item.steamAppID.flatMap { state.gameDB[$0] } }private var bottle: Bottle? { item.bottleName.flatMap { name in state.bottles.first { $0.name == name } } }private var blocked: Bool { entry?.isBlocked == true }- /// A game recipe shares its id with the db entry (portal-2, assetto-corsa…). When one- /// exists, the page offers it — this was CLI-only, which no first-time user finds.- private var fixRecipe: HighballKit.Recipe? {- entry.flatMap { AppState.recipe($0.id) }.flatMap { $0.kind == .game ? $0 : nil }- }+ /// Light fixes auto-apply at Play; this button remains the manual (re-)apply path,+ /// mostly useful for heavy recipes and repair.+ private var fixRecipe: HighballKit.Recipe? { state.fixRecipe(for: item) }private var fixApplied: Bool {guard let fixRecipe, let bottle else { return false }return bottle.settings.recipes.contains(fixRecipe.id)diff --git a/Sources/HighballApp/HighballApp.swift b/Sources/HighballApp/HighballApp.swiftindex 67ea7ab..dfcd14e 100644--- a/Sources/HighballApp/HighballApp.swift+++ b/Sources/HighballApp/HighballApp.swift@@ -227,6 +227,21 @@ struct ContentView: View {.sheet(isPresented: $state.showLog) { LogSheet() }.sheet(isPresented: $state.showGPTKLicense) { GPTKLicenseSheet() }.sheet(isPresented: $state.showEpicSignIn) { EpicSignInSheet() }+ // Heavy fix at Play: installs take real time, so the cost is stated, never silent.+ .confirmationDialog(+ String(format: L("%@ needs a one-time setup to run the way it was verified."),+ state.pendingHeavyFix?.item.title ?? ""),+ isPresented: .init(get: { state.pendingHeavyFix != nil },+ set: { if !$0 { state.pendingHeavyFix = nil } }),+ titleVisibility: .visible+ ) {+ Button(L("Install the fix first")) { state.confirmHeavyFix() }+ Button(L("Play without it")) { state.skipHeavyFix() }+ Button(L("Cancel"), role: .cancel) { state.pendingHeavyFix = nil }+ } message: {+ Text(state.pendingHeavyFix?.recipe.steps.compactMap(\.slowHint).first+ ?? L("This installs the dependencies the compatibility database verified."))+ }.alert(L("Something went wrong"), isPresented: .init(get: { state.errorMessage != nil },set: { if !$0 { state.errorMessage = nil } })) {diff --git a/Sources/HighballApp/L10n.swift b/Sources/HighballApp/L10n.swiftindex 98e15f3..bd3abb9 100644--- a/Sources/HighballApp/L10n.swift+++ b/Sources/HighballApp/L10n.swift@@ -156,6 +156,12 @@ enum L10n {"Reset cover": "Réinitialiser la couverture","Choose a cover image for %@": "Choisir une image de couverture pour %@","Apply %@ fix": "Appliquer le correctif %@",+ "%@ needs a one-time setup to run the way it was verified.":+ "%@ nécessite une configuration unique pour fonctionner comme vérifié.",+ "Install the fix first": "Installer d'abord le correctif",+ "Play without it": "Jouer sans",+ "This installs the dependencies the compatibility database verified.":+ "Ceci installe les dépendances vérifiées par la base de compatibilité.","Sets this game up the way the compatibility database verified it — renderer, settings, dependencies.":"Configure ce jeu tel que la base de compatibilité l'a vérifié : moteur de rendu, réglages, dépendances.","Hide": "Masquer",diff --git a/Sources/HighballKit/Bottle.swift b/Sources/HighballKit/Bottle.swiftindex 1865094..e248e4e 100644--- a/Sources/HighballKit/Bottle.swift+++ b/Sources/HighballKit/Bottle.swift@@ -167,6 +167,9 @@ public struct BottleSettings: Codable, Sendable {/// Extra WINEDLLOVERRIDES entries, e.g. "version=n,b" for Cyber Engine Tweaks. Appended to/// whatever the renderer sets, semicolon separated.public var dllOverrides: String = ""+ /// Per-app DXVK options (exe → key/value), set by recipe `dxvkconfig` steps and rendered+ /// into dxvk.conf at every DXVK launch. Data-driven successor to hardcoded [exe] sections.+ public var dxvkAppConfig: [String: [String: String]] = [:]/// The dllOverrides value last mirrored into the prefix registry. The env var only reaches/// process trees Highball spawns itself; a game started by an already-running Steam client/// inherits Steam's environment from before the setting changed and never sees it@@ -189,6 +192,7 @@ public struct BottleSettings: Codable, Sendable {engineID = try c.decode(String.self, forKey: .engineID)renderer = try c.decodeIfPresent(Renderer.self, forKey: .renderer) ?? .dxmtrendererExplicit = try c.decodeIfPresent(Bool.self, forKey: .rendererExplicit) ?? false+ dxvkAppConfig = try c.decodeIfPresent([String: [String: String]].self, forKey: .dxvkAppConfig) ?? [:]windowsVersion = try c.decodeIfPresent(WindowsVersion.self, forKey: .windowsVersion) ?? .win10sync = try c.decodeIfPresent(SyncMode.self, forKey: .sync) ?? .msyncmetalHUD = try c.decodeIfPresent(Bool.self, forKey: .metalHUD) ?? false@@ -289,26 +293,39 @@ public struct Bottle: Sendable {/// Radeon device id to pair with the AMD vendor id DXVK's built-in csgo profile/// already forces, so the game's dxsupport.cfg picks a concrete GPU profile instead/// of unknown-device failsafe. Later lines win, so the section must follow the global.- public static func dxvkConfig(async: Bool) -> String {- """+ public static func dxvkConfig(async: Bool, appConfig: [String: [String: String]] = [:]) -> String {+ // FALLBACK, kept deliberately (do not delete yet): legacy CS:GO froze at map load+ // with async on (issue #21), and legacy CS:GO can ONLY launch via Steam's own+ // chooser (CEG DRM) — it never passes the app's Play-gate, so bottles without the+ // counter-strike-2 recipe still need this. The same knowledge now ships as data+ // (recipe dxvkconfig step); recipe-set values OVERRIDE this fallback. Remove after+ // a deprecation window once recipe coverage is the norm.+ let csgoFallback = ["dxvk.enableAsync": "False", "d3d9.maxAvailableMemory": "2048",+ "d3d9.customDeviceId": "73BF"]+ var merged = appConfig+ merged["csgo.exe"] = csgoFallback.merging(merged["csgo.exe"] ?? [:]) { _, recipe in recipe }++ var out = """# Written by Highball before each DXVK launch — edits here are overwritten.- # The bottle's "DXVK async shader compilation" toggle sets the global line.+ # The bottle's "DXVK async shader compilation" toggle sets the global line;+ # per-app sections come from recipe dxvkconfig steps (plus the csgo fallback).dxvk.enableAsync = \(async ? "True" : "False")- # Legacy CS:GO froze at map load with async compile on (issue #21).- [csgo.exe]- dxvk.enableAsync = False- d3d9.maxAvailableMemory = 2048- d3d9.customDeviceId = 73BF-"""+ for exe in merged.keys.sorted() {+ out += "\n[\(exe)]\n"+ for key in merged[exe]!.keys.sorted() {+ out += "\(key) = \(merged[exe]![key]!)\n"+ }+ }+ return out}/// Writes the generated dxvk.conf into the prefix (idempotent, compare-then-write).public func writeDxvkConfig() throws {let dir = dxvkConfigURL.deletingLastPathComponent()try FileManager.default.createDirectory(at: dir, withIntermediateDirectories: true)- let content = Self.dxvkConfig(async: settings.dxvkAsync)+ let content = Self.dxvkConfig(async: settings.dxvkAsync, appConfig: settings.dxvkAppConfig)if (try? String(contentsOf: dxvkConfigURL, encoding: .utf8)) != content {try content.write(to: dxvkConfigURL, atomically: true, encoding: .utf8)}diff --git a/Sources/HighballKit/Recipe.swift b/Sources/HighballKit/Recipe.swiftindex 4db4d29..ef04dca 100644--- a/Sources/HighballKit/Recipe.swift+++ b/Sources/HighballKit/Recipe.swift@@ -30,8 +30,12 @@ public struct Recipe: Codable, Sendable, Identifiable {case pin(Pin)/// Free-text instruction the UI surfaces to the user after install.case note(String)+ /// Per-app DXVK options ("csgo.exe" → dxvk.enableAsync=False…), stored on the bottle+ /// and rendered into its dxvk.conf at every DXVK launch. This is how game-specific+ /// DXVK knowledge ships as data instead of app code.+ case dxvkConfig(exe: String, options: [String: String])- private enum CodingKeys: String, CodingKey { case type, url, sha256, arguments, label, slow, key, name, value, valueType, data, verbs, renderer, sync, winver, path, contents, pin, text }+ private enum CodingKeys: String, CodingKey { case type, url, sha256, arguments, label, slow, key, name, value, valueType, data, verbs, renderer, sync, winver, path, contents, pin, text, exe, options }public init(from decoder: Decoder) throws {let c = try decoder.container(keyedBy: CodingKeys.self)@@ -54,6 +58,8 @@ public struct Recipe: Codable, Sendable, Identifiable {case "file": self = .file(path: try c.decode(String.self, forKey: .path), contents: try c.decode(String.self, forKey: .contents))case "pin": self = .pin(try c.decode(Pin.self, forKey: .pin))case "note": self = .note(try c.decode(String.self, forKey: .text))+ case "dxvkconfig": self = .dxvkConfig(exe: try c.decode(String.self, forKey: .exe),+ options: try c.decode([String: String].self, forKey: .options))case let other: throw HighballError.invalid("unknown recipe step type '\(other)'")}}@@ -78,6 +84,9 @@ public struct Recipe: Codable, Sendable, Identifiable {case let .file(path, contents): try c.encode("file", forKey: .type); try c.encode(path, forKey: .path); try c.encode(contents, forKey: .contents)case let .pin(p): try c.encode("pin", forKey: .type); try c.encode(p, forKey: .pin)case let .note(t): try c.encode("note", forKey: .type); try c.encode(t, forKey: .text)+ case let .dxvkConfig(exe, options):+ try c.encode("dxvkconfig", forKey: .type); try c.encode(exe, forKey: .exe)+ try c.encode(options, forKey: .options)}}@@ -87,7 +96,7 @@ public struct Recipe: Codable, Sendable, Identifiable {case let .installer(_, _, _, label, _): return labelcase let .winetricks(verbs, _): return verbs.joined(separator: " ")case .registry: return nil- case .environment, .renderer, .sync, .winver, .file, .pin, .note: return nil+ case .environment, .renderer, .sync, .winver, .file, .pin, .note, .dxvkConfig: return nil}}@@ -99,8 +108,23 @@ public struct Recipe: Codable, Sendable, Identifiable {default: return nil}}++ /// True when the step is safe to run silently at Play time: touches no wine process+ /// (registry/winver spawn wine and can die on the msync mismatch, issue #32) and+ /// takes no meaningful time (installer/winetricks can take 20-40 minutes).+ public var isAutoApplicable: Bool {+ switch self {+ case .file, .renderer, .sync, .environment, .pin, .note, .dxvkConfig: return true+ case .installer, .winetricks, .registry, .winver: return false+ }+ }}+ /// True when every step can run silently at Play time — the app then applies the recipe+ /// as part of pressing Play ("make it work like the db verified it"), no clicks needed.+ /// Recipes with heavy or wine-touching steps get an honest prompt instead.+ public var isAutoApplicable: Bool { steps.allSatisfy(\.isAutoApplicable) }+public struct KnownIssue: Codable, Sendable {public var symptom: Stringpublic var cause: String?@@ -238,6 +262,8 @@ public struct RecipeRunner: Sendable {if !bottle.settings.pins.contains(where: { $0.path == p.path }) { bottle.settings.pins.append(p) }case let .note(t):notes.append(t)+ case let .dxvkConfig(exe, options):+ bottle.settings.dxvkAppConfig[exe] = options}}if !bottle.settings.recipes.contains(recipe.id) { bottle.settings.recipes.append(recipe.id) }diff --git a/Tests/HighballKitTests/RegressionTests.swift b/Tests/HighballKitTests/RegressionTests.swiftindex 5852714..8da13e7 100644--- a/Tests/HighballKitTests/RegressionTests.swift+++ b/Tests/HighballKitTests/RegressionTests.swift@@ -333,6 +333,48 @@ extension RegressionTests {"drive_c itself counts as inside")}+ // Play-gate: only provably harmless steps may run silently at Play (no wine process —+ // the msync trap #32 — and no long installs). Heavy or wine-touching steps must prompt.+ func testRecipeAutoApplyClassification() throws {+ let light = """+ {"id":"l","kind":"game","title":"L","steps":[+ {"type":"file","path":"a/b.cfg","contents":"x"},+ {"type":"renderer","renderer":"dxvk"},+ {"type":"dxvkconfig","exe":"csgo.exe","options":{"dxvk.enableAsync":"False"}},+ {"type":"note","text":"n"}]}+ """+ XCTAssertTrue(try JSONDecoder.highball.decode(Recipe.self, from: Data(light.utf8)).isAutoApplicable)+ for heavyStep in [+ #"{"type":"winetricks","verbs":["dotnet48"]}"#,+ #"{"type":"installer","url":"https://x.com/a.exe","label":"a"}"#,+ #"{"type":"registry","key":"HKCU\\X","name":"n","data":"1"}"#,+ #"{"type":"winver","winver":"win10"}"#,+ ] {+ let json = #"{"id":"h","kind":"game","title":"H","steps":[\#(heavyStep)]}"#+ let r = try JSONDecoder.highball.decode(Recipe.self, from: Data(json.utf8))+ XCTAssertFalse(r.isAutoApplicable, "step must not auto-apply: \(heavyStep)")+ }+ }++ // Tech-debt migration (#21): per-app DXVK options are data now. Recipe-set values+ // override the built-in csgo fallback, other exes render their own sections, and the+ // fallback survives untouched for bottles without the recipe.+ func testDxvkAppConfigDataDriven() {+ // No data: fallback exactly as 0.7.10 shipped it (covered by testDxvkConfigContent too).+ let plain = Bottle.dxvkConfig(async: true)+ XCTAssertTrue(plain.contains("[csgo.exe]"))+ // Recipe data overrides the fallback key but keeps un-overridden fallback keys.+ let merged = Bottle.dxvkConfig(async: true, appConfig: [+ "csgo.exe": ["d3d9.maxAvailableMemory": "3072"],+ "portal2.exe": ["d3d9.deferSurfaceCreation": "True"],+ ])+ XCTAssertTrue(merged.contains("d3d9.maxAvailableMemory = 3072"), "recipe value wins")+ XCTAssertFalse(merged.contains("d3d9.maxAvailableMemory = 2048"))+ XCTAssertTrue(merged.contains("d3d9.customDeviceId = 73BF"), "fallback keys survive")+ XCTAssertTrue(merged.contains("[portal2.exe]"))+ XCTAssertTrue(merged.contains("d3d9.deferSurfaceCreation = True"))+ }+// Issue #29: a recipe's renderer is a default, never an override — the Steam recipe// silently reset an explicitly-d3dmetal bottle to dxmt, black-screening AC.func testRecipeRendererNeverOverridesExplicitChoice() {