Skip to content

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

feat: visible 'Run a Windows program…' affordance (Reddit report)

Gauthier Piarrette4a4c4172a1e5
diff --git a/Sources/HighballApp/AppState.swift b/Sources/HighballApp/AppState.swift
index b50a8b2..9ea800a 100644
--- a/Sources/HighballApp/AppState.swift
+++ b/Sources/HighballApp/AppState.swift
@@ -1,3 +1,4 @@
+import AppKit
import Foundation
import HighballKit
import Observation
@@ -34,6 +35,17 @@ final class AppState {
var errorMessage: String?
+ /// A Windows program awaiting the run/pin choice (from drag-drop, the File menu, or the button).
+ var pendingRun: URL?
+
+ func chooseProgramToRun() {
+ let panel = NSOpenPanel()
+ panel.title = L("Choose a Windows program")
+ panel.allowedContentTypes = [.exe, .msi].compactMap { $0 }
+ panel.allowsMultipleSelection = false
+ if panel.runModal() == .OK, let url = panel.url { pendingRun = url }
+ }
+
let paths = HighballPaths()
var engineStore: EngineStore { EngineStore(paths: paths) }
var bottleStore: BottleStore { BottleStore(paths: paths) }
@@ -365,3 +377,10 @@ final class AppState {
static let launcherRecipes = ["steam", "epic-games", "battle-net", "gog-galaxy", "ea-app", "ubisoft-connect", "rockstar"]
}
+
+import UniformTypeIdentifiers
+
+extension UTType {
+ static let exe = UTType(filenameExtension: "exe")
+ static let msi = UTType(filenameExtension: "msi")
+}
diff --git a/Sources/HighballApp/BottleView.swift b/Sources/HighballApp/BottleView.swift
index 208a4c8..e701800 100644
--- a/Sources/HighballApp/BottleView.swift
+++ b/Sources/HighballApp/BottleView.swift
@@ -34,7 +34,6 @@ struct BottleView: View {
("rockstar", "r.circle.fill", "Rockstar"),
]
- @State private var droppedURL: URL?
@State private var showSettings = false
private var engine: InstalledEngine? { state.engine(for: bottle) }
@@ -69,6 +68,12 @@ struct BottleView: View {
gamesSection
launchersSection
if !customPins.isEmpty { programsSection }
+ HStack(spacing: 6) {
+ Button { state.chooseProgramToRun() } label: {
+ Label(L("Run a Windows program…"), systemImage: "folder")
+ }.buttonStyle(.link)
+ Text(L("— or drop any .exe or .msi on this window")).font(.caption).foregroundStyle(.secondary)
+ }
}
.padding(.horizontal, 28)
.padding(.top, 18)
@@ -94,16 +99,16 @@ struct BottleView: View {
guard let provider = providers.first else { return false }
_ = provider.loadObject(ofClass: URL.self) { url, _ in
guard let url, ["exe", "msi", "bat"].contains(url.pathExtension.lowercased()) else { return }
- Task { @MainActor in droppedURL = url }
+ Task { @MainActor in state.pendingRun = url }
}
return true
}
- .confirmationDialog("Run \(droppedURL?.lastPathComponent ?? "") in this bottle?",
- isPresented: .init(get: { droppedURL != nil }, set: { if !$0 { droppedURL = nil } }),
+ .confirmationDialog("Run \(state.pendingRun?.lastPathComponent ?? "") in this bottle?",
+ isPresented: .init(get: { state.pendingRun != nil }, set: { if !$0 { state.pendingRun = nil } }),
titleVisibility: .visible) {
- Button(L("Run")) { if let u = droppedURL { state.runDropped(u, in: bottle, andPin: false) }; droppedURL = nil }
- Button(L("Run and add to Programs")) { if let u = droppedURL { state.runDropped(u, in: bottle, andPin: true) }; droppedURL = nil }
- Button(L("Cancel"), role: .cancel) { droppedURL = nil }
+ Button(L("Run")) { if let u = state.pendingRun { state.runDropped(u, in: bottle, andPin: false) }; state.pendingRun = nil }
+ Button(L("Run and add to Programs")) { if let u = state.pendingRun { state.runDropped(u, in: bottle, andPin: true) }; state.pendingRun = nil }
+ Button(L("Cancel"), role: .cancel) { state.pendingRun = nil }
}
}
diff --git a/Sources/HighballApp/HighballApp.swift b/Sources/HighballApp/HighballApp.swift
index 9b2385c..93f6420 100644
--- a/Sources/HighballApp/HighballApp.swift
+++ b/Sources/HighballApp/HighballApp.swift
@@ -19,6 +19,11 @@ struct HighballApp: App {
}
.windowResizability(.contentSize)
.commands {
+ CommandGroup(after: .newItem) {
+ Button(L("Run Windows Program…")) { state.chooseProgramToRun() }
+ .keyboardShortcut("o")
+ .disabled(state.selectedBottle == nil)
+ }
CommandGroup(after: .appInfo) {
CheckForUpdatesView(updater: delegate.updaterController.updater)
// Cleanup after a crash or a "leave running" quit — no Activity Monitor needed.
diff --git a/Sources/HighballApp/L10n.swift b/Sources/HighballApp/L10n.swift
index 16325f3..528062b 100644
--- a/Sources/HighballApp/L10n.swift
+++ b/Sources/HighballApp/L10n.swift
@@ -43,6 +43,10 @@ enum L10n {
"Duplicate bottle": "Dupliquer la bouteille",
"Repair bottle (re-run first boot)": "Réparer la bouteille (relancer le premier démarrage)",
"Dependencies": "Dépendances",
+ "Run a Windows program…": "Lancer un programme Windows…",
+ "Run Windows Program…": "Lancer un programme Windows…",
+ "— or drop any .exe or .msi on this window": "— ou déposez un .exe ou .msi sur cette fenêtre",
+ "Choose a Windows program": "Choisir un programme Windows",
"Installed": "Installée",
"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.",