Skip to content

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

feat: DLL overrides and environment variables per bottle (#17)

Gauthier Piarrette4d6a4c82eacf
diff --git a/Sources/HighballApp/BottleView.swift b/Sources/HighballApp/BottleView.swift
index 87e9635..0faf4ee 100644
--- a/Sources/HighballApp/BottleView.swift
+++ b/Sources/HighballApp/BottleView.swift
@@ -553,6 +553,15 @@ struct BottleSettingsSheet: View {
Text(L("Games run with the bottle’s sync (msync is fastest). Opening the Steam window restarts Windows processes with sync off — its interface needs it."))
.font(.caption).foregroundStyle(.secondary)
}
+ Section(L("Advanced")) {
+ TextField(L("DLL overrides"), text: binding(\.dllOverrides), prompt: Text(verbatim: "version=n,b;winmm=n,b"))
+ .font(.body.monospaced())
+ Text(L("Extra Wine DLL overrides for this bottle, semicolon separated. Mods like Cyber Engine Tweaks need version=n,b."))
+ .font(.caption).foregroundStyle(.secondary)
+ EnvEditor(bottle: bottle)
+ Text(L("Environment variables, one KEY=VALUE per line. Applied to everything launched in this bottle."))
+ .font(.caption).foregroundStyle(.secondary)
+ }
let tweaks = AppState.tweakRecipes()
if !tweaks.isEmpty {
Section(L("Dependencies")) {
@@ -728,3 +737,37 @@ struct EpicSignInSheet: View {
.padding(24)
}
}
+
+
+/// Bottle environment editor: one KEY=VALUE per line, saved on every keystroke batch.
+struct EnvEditor: View {
+ @Environment(AppState.self) private var state
+ let bottle: Bottle
+ @State private var text: String = ""
+ @State private var loaded = false
+
+ var body: some View {
+ TextEditor(text: $text)
+ .font(.body.monospaced())
+ .frame(height: 72)
+ .overlay(RoundedRectangle(cornerRadius: 6).stroke(.quaternary))
+ .onAppear {
+ guard !loaded else { return }
+ loaded = true
+ let env = (state.bottles.first { $0.name == bottle.name } ?? bottle).settings.environment
+ text = env.sorted { $0.key < $1.key }.map { "\($0.key)=\($0.value)" }.joined(separator: "\n")
+ }
+ .onChange(of: text) { _, newValue in
+ var env: [String: String] = [:]
+ for line in newValue.split(separator: "\n") {
+ let parts = line.split(separator: "=", maxSplits: 1).map(String.init)
+ if parts.count == 2, !parts[0].trimmingCharacters(in: .whitespaces).isEmpty {
+ env[parts[0].trimmingCharacters(in: .whitespaces)] = parts[1]
+ }
+ }
+ var copy = state.bottles.first { $0.name == bottle.name } ?? bottle
+ copy.settings.environment = env
+ state.update(copy)
+ }
+ }
+}
diff --git a/Sources/HighballApp/L10n.swift b/Sources/HighballApp/L10n.swift
index b9202d9..b770a56 100644
--- a/Sources/HighballApp/L10n.swift
+++ b/Sources/HighballApp/L10n.swift
@@ -69,6 +69,12 @@ enum L10n {
"Connect": "Connecter",
"Connecting your Epic account": "Connexion de votre compte Epic",
"Loading your Epic library…": "Chargement de votre bibliothèque Epic…",
+ "Advanced": "Avancé",
+ "DLL overrides": "Surcharges de DLL",
+ "Extra Wine DLL overrides for this bottle, semicolon separated. Mods like Cyber Engine Tweaks need version=n,b.":
+ "Surcharges de DLL Wine supplémentaires pour cette bouteille, séparées par des points-virgules. Des mods comme Cyber Engine Tweaks demandent version=n,b.",
+ "Environment variables, one KEY=VALUE per line. Applied to everything launched in this bottle.":
+ "Variables d'environnement, une paire CLE=VALEUR par ligne. Appliquées à tout ce qui se lance dans cette bouteille.",
"Windows runtimes some games need. Install them when a game complains about a missing runtime or refuses to start.":
"Des composants Windows dont certains jeux ont besoin. Installez-les quand un jeu se plaint d'un composant manquant ou refuse de démarrer.",
"Steam crashed at a known spot — relaunching to resume the update":
diff --git a/Sources/HighballKit/Bottle.swift b/Sources/HighballKit/Bottle.swift
index 2af8fd3..0a7fa29 100644
--- a/Sources/HighballKit/Bottle.swift
+++ b/Sources/HighballKit/Bottle.swift
@@ -75,6 +75,9 @@ public struct BottleSettings: Codable, Sendable {
public var fpsCap: Int = 0
/// Wine Mac driver Retina mode: expose native pixels + 192 DPI (applied via registry on toggle).
public var retinaMode: Bool = false
+ /// Extra WINEDLLOVERRIDES entries, e.g. "version=n,b" for Cyber Engine Tweaks. Appended to
+ /// whatever the renderer sets, semicolon separated.
+ public var dllOverrides: String = ""
public var environment: [String: String] = [:]
public var pins: [Pin] = []
public var recipes: [String] = []
@@ -98,6 +101,7 @@ public struct BottleSettings: Codable, Sendable {
dxvkAsync = try c.decodeIfPresent(Bool.self, forKey: .dxvkAsync) ?? true
fpsCap = try c.decodeIfPresent(Int.self, forKey: .fpsCap) ?? 0
retinaMode = try c.decodeIfPresent(Bool.self, forKey: .retinaMode) ?? false
+ dllOverrides = try c.decodeIfPresent(String.self, forKey: .dllOverrides) ?? ""
environment = try c.decodeIfPresent([String: String].self, forKey: .environment) ?? [:]
pins = try c.decodeIfPresent([Pin].self, forKey: .pins) ?? []
recipes = try c.decodeIfPresent([String].self, forKey: .recipes) ?? []
@@ -154,6 +158,7 @@ public struct Bottle: Sendable {
default: break
}
}
+ if !settings.dllOverrides.isEmpty { merge(&env, ["WINEDLLOVERRIDES+": settings.dllOverrides]) }
merge(&env, settings.environment)
merge(&env, try (renderer ?? settings.renderer).environment(engine: engine))
merge(&env, extra)
diff --git a/Sources/highball/main.swift b/Sources/highball/main.swift
index 857b06a..c5dd023 100644
--- a/Sources/highball/main.swift
+++ b/Sources/highball/main.swift
@@ -109,7 +109,7 @@ struct Bottle: AsyncParsableCommand {
}
struct Set: AsyncParsableCommand {
- static let configuration = CommandConfiguration(abstract: "Change a bottle setting: renderer, winver, sync, hud, avx, retina, env KEY=VALUE")
+ static let configuration = CommandConfiguration(abstract: "Change a bottle setting: renderer, winver, sync, hud, avx, retina, dlloverrides, env KEY=VALUE")
@Argument var name: String
@Argument var setting: String
@Argument var value: String
@@ -127,6 +127,8 @@ struct Bottle: AsyncParsableCommand {
case "sync": guard let s = SyncMode(rawValue: value) else { fail("bad sync") }; b.settings.sync = s
case "hud": b.settings.metalHUD = (value == "1" || value == "true")
case "avx": b.settings.advertiseAVX = (value == "1" || value == "true")
+ case "dlloverrides":
+ b.settings.dllOverrides = value
case "retina":
let on = (value == "1" || value == "true")
b.settings.retinaMode = on