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
Disc images open: an .iso dropped, opened or chosen is mounted read-only and the program chooser opens on it (highball#184). The game page's engine can be changed there, through the switch page that lists every program it moves, and says the engine belongs to the environment (highball#262). The Emulate display mode changes box no longer springs back unchecked while the environment runs: the value just written stands until Wine saves user.reg (highball-db#350)
Gauthier Piarrette2a03ac9742c5
diff --git a/Sources/HighballApp/AppState.swift b/Sources/HighballApp/AppState.swiftindex f7445b5..a36174e 100644--- a/Sources/HighballApp/AppState.swift+++ b/Sources/HighballApp/AppState.swift@@ -638,6 +638,7 @@ final class AppState {/// (issue #90). Same dialog as a dropped or chosen file: run it in the default environment,/// or run and keep it in Programs. Anything that is not a program says so instead of doing nothing.func openFile(_ url: URL) {+ if Self.isDiscImage(url) { openDiscImage(url, in: nil); return }guard ["exe", "msi", "bat"].contains(url.pathExtension.lowercased()) else {fail(HighballError.failed(String(format: L("'%@' isn't a Windows program. Highball opens .exe, .msi and .bat files."), url.lastPathComponent)))return@@ -652,9 +653,54 @@ final class AppState {func chooseProgramToRun(in bottle: String? = nil) {let panel = NSOpenPanel()panel.title = L("Choose a Windows program")- panel.allowedContentTypes = [.exe, .msi, .bat].compactMap { $0 }+ panel.allowedContentTypes = [.exe, .msi, .bat, UTType(filenameExtension: "iso")].compactMap { $0 }panel.allowsMultipleSelection = false- if panel.runModal() == .OK, let url = panel.url { pendingRunBottle = bottle; pendingRun = url }+ guard panel.runModal() == .OK, let url = panel.url else { return }+ if Self.isDiscImage(url) { openDiscImage(url, in: bottle); return }+ pendingRunBottle = bottle; pendingRun = url+ }++ /// A disc image (.iso), as old games and their installers often come: Highball mounts it the+ /// way a double-click in Finder would and asks for the program on it, then runs that like any+ /// other (highball#184, a player dropped "Chrome (Poland).iso" and only got an error). Wine+ /// sees the mounted disc under /Volumes like any other drive.+ static func isDiscImage(_ url: URL) -> Bool { url.pathExtension.lowercased() == "iso" }++ func openDiscImage(_ image: URL, in bottle: String?) {+ Task { [weak self] in+ let mounted = await Task.detached { () -> Result<URL, Error> in+ do {+ let out = try Shell.capture("/usr/bin/hdiutil", ["attach", "-readonly", "-plist", image.path])+ // macOS 27 prints a deprecation warning before the plist on the same stream.+ let xml = out.range(of: "<?xml").map { String(out[$0.lowerBound...]) } ?? out+ guard let data = xml.data(using: .utf8),+ let plist = try PropertyListSerialization.propertyList(from: data, format: nil) as? [String: Any],+ let entities = plist["system-entities"] as? [[String: Any]],+ let point = entities.compactMap({ $0["mount-point"] as? String }).first else {+ throw HighballError.failed(String(format: L("macOS could not open '%@' as a disc."), image.lastPathComponent))+ }+ return .success(URL(fileURLWithPath: point, isDirectory: true))+ } catch { return .failure(error) }+ }.value+ await MainActor.run {+ guard let self else { return }+ switch mounted {+ case let .failure(error): self.fail(error)+ case let .success(disc):+ self.appendLog("mounted \(image.lastPathComponent) at \(disc.path)")+ let panel = NSOpenPanel()+ panel.title = L("Choose the program on the disc")+ panel.message = L("Usually the disc's setup or install program.")+ panel.directoryURL = disc+ panel.allowedContentTypes = [.exe, .msi, .bat].compactMap { $0 }+ panel.allowsMultipleSelection = false+ NSApp.activate(ignoringOtherApps: true)+ guard panel.runModal() == .OK, let program = panel.url else { return }+ self.pendingRunBottle = bottle+ self.pendingRun = program+ }+ }+ }}let paths = HighballPaths()@@ -1542,6 +1588,11 @@ final class AppState {let reg = bottle.url.appending(path: "user.reg")let modified = (try? reg.resourceValues(forKeys: [.contentModificationDateKey]).contentModificationDate) ?? .distantPastlet key = bottle.name + "|" + exe.lastPathComponent+ // A write made while the environment runs sits in Wine's server until it saves user.reg,+ // seconds later or at exit, so the file still says off and the box sprang back+ // unchecked (highball-db#350: "it doesn't let me check the box"). What was just written+ // stands until the file is newer than the write.+ if let written = displayModeWritten[key], written.at > modified { return written.on }if let hit = displayModeCache[key], hit.modified == modified { return hit.on }let on = DisplayModeEmulation.isOn(in: bottle, executable: exe)displayModeCache[key] = (modified, on)@@ -1552,14 +1603,19 @@ final class AppState {let exe = programExecutable(for: item) else { return nil }return displayModeEmulation(in: bottle, executable: exe)}+ @ObservationIgnored private var displayModeWritten: [String: (on: Bool, at: Date)] = [:]func setDisplayModeEmulation(_ on: Bool, in bottle: Bottle, executable exe: URL) {guard let engine = engine(for: bottle) else { return }+ let key = bottle.name + "|" + exe.lastPathComponent+ displayModeWritten[key] = (on, Date())+ registryVersion += 1Task { @MainActor inlet runner = WineRunner(paths: paths, engine: engine, bottle: bottle)do {try await DisplayModeEmulation.set(on, in: runner, executable: exe)appendLog("\(exe.lastPathComponent): emulated display mode changes \(on ? "on" : "off") in \(bottle.name); the next launch uses it.")} catch {+ displayModeWritten[key] = nilfail(error, bottle: bottle)}registryVersion += 1diff --git a/Sources/HighballApp/BottleView.swift b/Sources/HighballApp/BottleView.swiftindex 224ae72..7c64c46 100644--- a/Sources/HighballApp/BottleView.swift+++ b/Sources/HighballApp/BottleView.swift@@ -89,6 +89,8 @@ struct BottleView: View {guard let url else { return }if ["exe", "msi", "bat"].contains(url.pathExtension.lowercased()) {Task { @MainActor in state.pendingRunBottle = bottle.name; state.pendingRun = url }+ } else if AppState.isDiscImage(url) {+ Task { @MainActor in state.openDiscImage(url, in: bottle.name) }} else {// Silently ignoring a drop reads as "nothing happened" (Reddit report) — say why.Task { @MainActor indiff --git a/Sources/HighballApp/GameDetailView.swift b/Sources/HighballApp/GameDetailView.swiftindex 0a421ff..c7218e3 100644--- a/Sources/HighballApp/GameDetailView.swift+++ b/Sources/HighballApp/GameDetailView.swift@@ -342,7 +342,33 @@ struct GameDetailView: View {}}}- row(L("Engine"), (state.engine(for: bottle)?.displayName).map { "\($0) · \(bottle.settings.engineID)" } ?? bottle.settings.engineID)+ // The engine is the environment's, so the page says so and can change it+ // through the same switch page as the environment's settings, which lists+ // every program that moves along (highball#262: an engine shown here that+ // could not be changed read as a dead end).+ let offered = state.offeredEngines(for: bottle)+ HStack(alignment: .top, spacing: 12) {+ Text(L("Engine")).font(.caption).foregroundStyle(.secondary).frame(width: 110, alignment: .leading).padding(.top, offered.count > 1 ? 4 : 0)+ VStack(alignment: .leading, spacing: 4) {+ if offered.count > 1 {+ Picker("", selection: Binding(+ get: { bottle.settings.engineID },+ set: { newID in+ guard newID != bottle.settings.engineID else { return }+ state.engineTransition = AppState.EngineTransition(bottleName: bottle.name, targetID: newID)+ })) {+ ForEach(offered, id: \.id) { e in+ Text(verbatim: e.missing ? "\(e.id) (\(L("missing")))" : e.installed ? e.id : "\(e.id) (\(L("download")))").tag(e.id)+ }+ }.labelsHidden().frame(maxWidth: 360).disabled(state.busy)+ } else {+ Text(verbatim: (state.engine(for: bottle)?.displayName).map { "\($0) · \(bottle.settings.engineID)" } ?? bottle.settings.engineID)+ .font(.callout)+ }+ Text(String(format: L("The engine belongs to the environment '%@', so a change here applies to every game in it. The page that opens lists them before anything moves."), bottle.name))+ .font(.caption).foregroundStyle(.secondary).fixedSize(horizontal: false, vertical: true)+ }+ }// Variables a fix scoped to this game (highball#198): the environment's own// editor shows only the environment-wide ones, so the page says what this// game gets on top of them.diff --git a/Sources/HighballApp/HighballApp.swift b/Sources/HighballApp/HighballApp.swiftindex e853cae..c6213a4 100644--- a/Sources/HighballApp/HighballApp.swift+++ b/Sources/HighballApp/HighballApp.swift@@ -201,6 +201,8 @@ struct ContentView: View {guard let url else { return }if ["exe", "msi", "bat"].contains(url.pathExtension.lowercased()) {Task { @MainActor in state.pendingRunBottle = nil; state.pendingRun = url }+ } else if AppState.isDiscImage(url) {+ Task { @MainActor in state.openDiscImage(url, in: nil) }} else {Task { @MainActor instate.fail(HighballError.failed(String(format: L("'%@' isn't a Windows program. You can drop .exe, .msi or .bat files here."), url.lastPathComponent)))diff --git a/Sources/HighballApp/L10n.swift b/Sources/HighballApp/L10n.swiftindex 2232a51..1573aee 100644--- a/Sources/HighballApp/L10n.swift+++ b/Sources/HighballApp/L10n.swift@@ -522,6 +522,10 @@ enum L10n {// An environment that already fits a game's engine, and the windows Highball brings forward (highball-db#318, highball#264)"%d installed": "%d installés","Play there": "Y jouer",+ "The engine belongs to the environment '%@', so a change here applies to every game in it. The page that opens lists them before anything moves.": "Le moteur appartient à l'environnement « %@ » : le changer ici l'applique à tous ses jeux. La page qui s'ouvre les liste avant tout changement.",+ "Choose the program on the disc": "Choisissez le programme du disque",+ "Usually the disc's setup or install program.": "En général le programme d'installation du disque.",+ "macOS could not open '%@' as a disc.": "macOS n'a pas pu ouvrir « %@ » comme un disque.","This program's file isn't there. Plug in the drive it is on, or remove it from the environment's programs.": "Le fichier de ce programme est introuvable. Branchez le disque où il se trouve, ou retirez-le des programmes de l'environnement.","Use '%@'": "Utiliser « %@ »","'%@' is already on the %@ engine and has the game installed, so it plays there. This environment stays as it is.": "« %@ » utilise déjà le moteur %@ et le jeu y est installé, il s'y lance donc. Cet environnement reste tel quel.",