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
Add per-bottle display-scaling (DPI) slider, replacing the Retina on/off toggle
Gauthier Piarrette327fc61593ef
diff --git a/Sources/HighballApp/AppState.swift b/Sources/HighballApp/AppState.swiftindex a9f6a99..4d98e90 100644--- a/Sources/HighballApp/AppState.swift+++ b/Sources/HighballApp/AppState.swift@@ -398,13 +398,13 @@ final class AppState {}}- func setRetina(_ on: Bool, in bottle: Bottle) {+ func setDpi(_ scale: Int, in bottle: Bottle) {guard let engine = engine(for: bottle) else { return }var copy = bottle- copy.settings.retinaMode = on+ copy.settings.dpiScale = scaleupdate(copy)- runBusy(on ? "Enabling Retina mode" : "Disabling Retina mode", showLogSheet: false) { [self] in- try await WineRunner(paths: paths, engine: engine, bottle: copy).setRetinaMode(on)+ runBusy("Applying display scaling", showLogSheet: false) { [self] in+ try await WineRunner(paths: paths, engine: engine, bottle: copy).setDpi(logPixels: scale)}}diff --git a/Sources/HighballApp/BottleView.swift b/Sources/HighballApp/BottleView.swiftindex a29e654..0489854 100644--- a/Sources/HighballApp/BottleView.swift+++ b/Sources/HighballApp/BottleView.swift@@ -500,7 +500,11 @@ struct BottleSettingsSheet: View {@Environment(\.dismiss) private var dismisslet bottle: Bottle@State private var confirmDelete = false+ /// Live slider value while dragging; nil means "read the saved dpiScale". Applied on release+ /// only, so dragging doesn't fire a wine registry write on every step.+ @State private var dpiDraft: Double? = nil+ private var currentDpi: Int { (state.bottles.first { $0.name == bottle.name } ?? bottle).settings.dpiScale }private var engine: InstalledEngine? { state.engine(for: bottle) }private var d3dmetalAvailable: Bool { engine?.rendererDir("d3dmetal") != nil }private var d3dmetalPossible: Bool {@@ -546,8 +550,24 @@ struct BottleSettingsSheet: View {Text("60 fps").tag(60)Text("120 fps").tag(120)}- Toggle(L("Retina mode (native resolution)"), isOn: retinaBinding)- Text(L("Crisper text and UI at your display's full resolution. Heavy games may run slower — pair with the frame rate cap."))+ VStack(alignment: .leading, spacing: 4) {+ HStack {+ Text(L("Display scaling"))+ Spacer()+ Text("\(Int(((dpiDraft ?? Double(currentDpi)) / 96 * 100).rounded()))%")+ .foregroundStyle(.secondary).monospacedDigit()+ }+ Slider(+ value: Binding(get: { dpiDraft ?? Double(currentDpi) }, set: { dpiDraft = $0 }),+ in: 96...240, step: 24,+ onEditingChanged: { editing in+ if !editing, let v = dpiDraft {+ state.setDpi(Int(v.rounded()), in: state.bottles.first { $0.name == bottle.name } ?? bottle)+ dpiDraft = nil+ }+ })+ }+ Text(L("Scales the Windows desktop and UI, 100% to 250%. Launchers and desktop apps follow it; many full-screen games set their own resolution and won't. Above 100% uses native Retina pixels, so heavy games may run slower.")).font(.caption).foregroundStyle(.secondary)}Section(L("Compatibility")) {@@ -606,12 +626,6 @@ struct BottleSettingsSheet: View {}}- private var retinaBinding: Binding<Bool> {- Binding(- get: { (state.bottles.first { $0.name == bottle.name } ?? bottle).settings.retinaMode },- set: { on in state.setRetina(on, in: state.bottles.first { $0.name == bottle.name } ?? bottle) })- }-private func binding<T>(_ keyPath: WritableKeyPath<BottleSettings, T>) -> Binding<T> {Binding(get: { (state.bottles.first { $0.name == bottle.name } ?? bottle).settings[keyPath: keyPath] },diff --git a/Sources/HighballApp/L10n.swift b/Sources/HighballApp/L10n.swiftindex b770a56..8e322bb 100644--- a/Sources/HighballApp/L10n.swift+++ b/Sources/HighballApp/L10n.swift@@ -33,11 +33,10 @@ enum L10n {"Stop Everything & Quit": "Tout arrêter et quitter","Leave Running & Quit": "Laisser tourner et quitter","Stop All Windows Processes": "Arrêter tous les processus Windows",- "Retina mode (native resolution)": "Mode Retina (résolution native)",- "Crisper text and UI at your display's full resolution. Heavy games may run slower — pair with the frame rate cap.":- "Texte et interface plus nets à la pleine résolution de votre écran. Les jeux exigeants peuvent ralentir — combinez avec la limite d'images par seconde.",- "Enabling Retina mode": "Activation du mode Retina",- "Disabling Retina mode": "Désactivation du mode Retina",+ "Display scaling": "Mise à l'échelle de l'affichage",+ "Scales the Windows desktop and UI, 100% to 250%. Launchers and desktop apps follow it; many full-screen games set their own resolution and won't. Above 100% uses native Retina pixels, so heavy games may run slower.":+ "Met à l'échelle le bureau et l'interface Windows, de 100 % à 250 %. Les lanceurs et applications de bureau la suivent ; beaucoup de jeux en plein écran définissent leur propre résolution et l'ignorent. Au-delà de 100 %, le rendu utilise les pixels Retina natifs, donc les jeux exigeants peuvent ralentir.",+ "Applying display scaling": "Application de la mise à l'échelle","Report a Problem…": "Signaler un problème…","Report this problem…": "Signaler ce problème…","Duplicate bottle": "Dupliquer la bouteille",diff --git a/Sources/HighballKit/Bottle.swift b/Sources/HighballKit/Bottle.swiftindex 446accb..b49f55f 100644--- a/Sources/HighballKit/Bottle.swift+++ b/Sources/HighballKit/Bottle.swift@@ -156,8 +156,10 @@ public struct BottleSettings: Codable, Sendable {public var dxvkAsync: Bool = true/// Cap the frame rate (0 = uncapped). Applied per renderer (DXVK_FRAME_RATE / DXMT_CONFIG).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+ /// Windows UI scale as a DPI value (LogPixels): 96 = 100% (1x), up to 240 = 250%. Above 96 the+ /// Mac driver switches to native Retina pixels so the scaled UI stays crisp. Applied to the prefix+ /// registry on change. Supersedes the old on/off retinaMode (which was just 96 / 192).+ public var dpiScale: Int = 96/// Extra WINEDLLOVERRIDES entries, e.g. "version=n,b" for Cyber Engine Tweaks. Appended to/// whatever the renderer sets, semicolon separated.public var dllOverrides: String = ""@@ -183,13 +185,23 @@ public struct BottleSettings: Codable, Sendable {advertiseAVX = try c.decodeIfPresent(Bool.self, forKey: .advertiseAVX) ?? falsedxvkAsync = try c.decodeIfPresent(Bool.self, forKey: .dxvkAsync) ?? truefpsCap = try c.decodeIfPresent(Int.self, forKey: .fpsCap) ?? 0- retinaMode = try c.decodeIfPresent(Bool.self, forKey: .retinaMode) ?? false+ // dpiScale supersedes the old retinaMode toggle (on == 200% == LogPixels 192).+ if let dpi = try c.decodeIfPresent(Int.self, forKey: .dpiScale) {+ dpiScale = dpi+ } else {+ let legacyRetina = (try? decoder.container(keyedBy: LegacyCodingKeys.self)+ .decodeIfPresent(Bool.self, forKey: .retinaMode)) ?? nil+ dpiScale = legacyRetina == true ? 192 : 96+ }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) ?? []created = try c.decodeIfPresent(Date.self, forKey: .created) ?? Date()}++ /// Legacy key for migrating pre-dpiScale bottles that stored `retinaMode`.+ private enum LegacyCodingKeys: String, CodingKey { case retinaMode }}public struct Bottle: Sendable {diff --git a/Sources/HighballKit/WineRunner.swift b/Sources/HighballKit/WineRunner.swiftindex 311d595..63d8a5d 100644--- a/Sources/HighballKit/WineRunner.swift+++ b/Sources/HighballKit/WineRunner.swift@@ -145,11 +145,20 @@ public struct WineRunner: Sendable {return line.split(whereSeparator: \.isWhitespace).last.map(String.init)}- /// Wine's Mac driver renders at 1x by default. Retina mode exposes native pixels (crisper,- /// ~4x GPU work at native res) with a 192 DPI bump so Windows UI stays readable.- public func setRetinaMode(_ on: Bool) async throws {- try await regAdd(key: #"HKCU\Software\Wine\Mac Driver"#, name: "RetinaMode", type: "REG_SZ", data: on ? "y" : "n")- try await regAdd(key: #"HKCU\Control Panel\Desktop"#, name: "LogPixels", type: "REG_DWORD", data: on ? "192" : "96")+ /// Windows UI scaling. LogPixels is the Windows system DPI (96 = 100%, 240 = 250%): DPI-aware+ /// apps and launchers follow it, though many full-screen games set their own render resolution and+ /// ignore it. At 96 the Mac driver renders at 1x; above that it switches to native Retina pixels+ /// (crisper, ~4x GPU work at native res) so the scaled UI stays sharp. Clamped to the 96..240 range+ /// Wine accepts. Pure so the mapping is unit-tested without touching a prefix.+ public static func dpiRegistry(for logPixels: Int) -> (retinaMode: String, logPixels: Int) {+ let clamped = min(max(logPixels, 96), 240)+ return (clamped > 96 ? "y" : "n", clamped)+ }++ public func setDpi(logPixels: Int) async throws {+ let v = Self.dpiRegistry(for: logPixels)+ try await regAdd(key: #"HKCU\Software\Wine\Mac Driver"#, name: "RetinaMode", type: "REG_SZ", data: v.retinaMode)+ try await regAdd(key: #"HKCU\Control Panel\Desktop"#, name: "LogPixels", type: "REG_DWORD", data: String(v.logPixels))}/// Wine's fallback D3D reports a fake NVIDIA GPU (GeForce 8800 GTX class) when it can'tdiff --git a/Sources/highball/main.swift b/Sources/highball/main.swiftindex 7c33401..4f9d5bb 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, dlloverrides, env KEY=VALUE")+ static let configuration = CommandConfiguration(abstract: "Change a bottle setting: renderer, winver, sync, hud, avx, dpi, dlloverrides, env KEY=VALUE")@Argument var name: String@Argument var setting: String@Argument var value: String@@ -129,11 +129,11 @@ struct Bottle: AsyncParsableCommand {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+ case "dpi":+ guard let scale = Int(value) else { fail("dpi expects a number (96..240; 96 = 100%, 192 = 200%)") }+ b.settings.dpiScale = scalelet eng = try EngineStore().engine(b.settings.engineID)- try await WineRunner(engine: eng, bottle: b).setRetinaMode(on)+ try await WineRunner(engine: eng, bottle: b).setDpi(logPixels: scale)case "env":let parts = value.split(separator: "=", maxSplits: 1).map(String.init)guard parts.count == 2 else { fail("env expects KEY=VALUE") }diff --git a/Tests/HighballKitTests/RegressionTests.swift b/Tests/HighballKitTests/RegressionTests.swiftindex c00a4bb..475fee0 100644--- a/Tests/HighballKitTests/RegressionTests.swift+++ b/Tests/HighballKitTests/RegressionTests.swift@@ -44,7 +44,7 @@ final class RegressionTests: XCTestCase {let old = #"{"formatVersion":1,"name":"aged","engineID":"x64-test","renderer":"dxmt","windowsVersion":"win10","sync":"msync","metalHUD":false,"advertiseAVX":false,"pins":[{"id":"6B1F0D2A-0000-4000-8000-000000000001","name":"Steam","path":"Program Files (x86)/Steam/steam.exe"}],"environment":{},"recipes":[]}"#let s = try JSONDecoder.highball.decode(BottleSettings.self, from: Data(old.utf8))XCTAssertEqual(s.name, "aged")- XCTAssertEqual(s.retinaMode, false, "field added in 0.7.x must default off")+ XCTAssertEqual(s.dpiScale, 96, "no dpi field on an old bottle must default to 96 (100%)")XCTAssertEqual(s.dllOverrides, "", "field added in 0.7.2 must default empty")XCTAssertEqual(s.fpsCap, 0)XCTAssertEqual(s.dxvkAsync, true)@@ -53,6 +53,33 @@ final class RegressionTests: XCTestCase {XCTAssertNil(s.pins.first?.renderer)}+ // The retinaMode on/off toggle became a dpiScale slider in 0.7.8. A bottle that had+ // retinaMode:true must migrate to 200% (LogPixels 192), not silently reset to 100%.+ func testRetinaModeMigratesToDpiScale() throws {+ let on = try JSONDecoder.highball.decode(BottleSettings.self,+ from: Data(#"{"name":"a","engineID":"e","retinaMode":true}"#.utf8))+ XCTAssertEqual(on.dpiScale, 192, "legacy retinaMode:true -> 200% (LogPixels 192)")+ let off = try JSONDecoder.highball.decode(BottleSettings.self,+ from: Data(#"{"name":"a","engineID":"e","retinaMode":false}"#.utf8))+ XCTAssertEqual(off.dpiScale, 96, "legacy retinaMode:false -> 100%")+ let explicit = try JSONDecoder.highball.decode(BottleSettings.self,+ from: Data(#"{"name":"a","engineID":"e","dpiScale":144,"retinaMode":true}"#.utf8))+ XCTAssertEqual(explicit.dpiScale, 144, "an explicit dpiScale wins over the legacy key")+ }++ // The DPI slider generalizes the old 96/192 pair: native Retina pixels only above 100%,+ // and values clamped to Wine's usable 96..240 range so a bad input can't write garbage.+ func testDpiRegistryMappingAndClamp() {+ XCTAssertEqual(WineRunner.dpiRegistry(for: 96).logPixels, 96)+ XCTAssertEqual(WineRunner.dpiRegistry(for: 96).retinaMode, "n", "100% stays 1x")+ XCTAssertEqual(WineRunner.dpiRegistry(for: 144).logPixels, 144)+ XCTAssertEqual(WineRunner.dpiRegistry(for: 144).retinaMode, "y", "above 100% switches to native pixels")+ XCTAssertEqual(WineRunner.dpiRegistry(for: 50).logPixels, 96, "below range clamps up to 96")+ XCTAssertEqual(WineRunner.dpiRegistry(for: 50).retinaMode, "n")+ XCTAssertEqual(WineRunner.dpiRegistry(for: 999).logPixels, 240, "above range clamps to 240")+ XCTAssertEqual(WineRunner.dpiRegistry(for: 999).retinaMode, "y")+ }+// Steam writes StateFlags 1026 while downloading; the game card must not offer Play.func testACFDownloadingNotReady() throws {let acf = """