Skip to content

Free fork of NotProton: Windows Steam games in Mac Steam, on CodeWeavers' Wine and Apple's Game Porting Toolkit

feat(setup): Setup Assistant and one-click installer

raymondchins631b6de09ab0
diff --git a/.gitignore b/.gitignore
index 5fe2f49..82644e7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -25,3 +25,8 @@ DerivedData/
app/Sources/NotProtonApp/Resources/payload/
__pycache__/
+installer/NotProton.app/
+installer/gptk/
+installer/cache/
+installer/steam.dmg
+installer/GPTK-License.rtf
diff --git a/app/Sources/NotProtonApp/App.swift b/app/Sources/NotProtonApp/App.swift
index e431792..979bc9a 100644
--- a/app/Sources/NotProtonApp/App.swift
+++ b/app/Sources/NotProtonApp/App.swift
@@ -7,6 +7,7 @@ struct NotProtonApp: App {
@State private var status = SystemStatus()
@State private var prefixes = PrefixesModel()
@State private var pane: Pane = .status
+ @State private var showsSetup = false
private let updater = AppUpdater()
init() {
@@ -23,6 +24,14 @@ struct NotProtonApp: App {
.onChange(of: status.snapshot?.installedRunners.map(\.id)) {
if prefixes.hasLoaded { Task { await prefixes.load() } }
}
+ .onChange(of: status.snapshot == nil, initial: true) {
+ if SetupAssistant.shouldShow(status.snapshot) { showsSetup = true }
+ }
+ .sheet(isPresented: $showsSetup) {
+ SetupAssistantView()
+ .environment(status)
+ .interactiveDismissDisabled()
+ }
}
.defaultSize(width: 900, height: 760)
.commands { menus }
@@ -61,6 +70,11 @@ struct NotProtonApp: App {
}
CommandMenu("Setup") {
+ Button("Setup Assistant…") { showsSetup = true }
+ .disabled(!status.isIdle)
+
+ Divider()
+
Button("Install") { Task { await status.requestInstall() } }
.keyboardShortcut("i", modifiers: .command)
.disabled(!status.canInstall)
diff --git a/app/Sources/NotProtonApp/Model/SetupChecks.swift b/app/Sources/NotProtonApp/Model/SetupChecks.swift
new file mode 100644
index 0000000..0c7d6e6
--- /dev/null
+++ b/app/Sources/NotProtonApp/Model/SetupChecks.swift
@@ -0,0 +1,141 @@
+import Foundation
+
+// What the Setup Assistant checks and installs before NotProton itself: the Mac, Rosetta,
+// Steam and the user's Steam sign-in.
+enum SetupChecks {
+ static let minimumMacOS = 26
+ static let requiredBytes: Int64 = 3 * 1_000_000_000
+ static let steamInstaller = URL(string: "https://cdn.akamai.steamstatic.com/client/installer/steam.dmg")!
+
+ static var isAppleSilicon: Bool {
+ var value: Int32 = 0
+ var size = MemoryLayout<Int32>.size
+ return sysctlbyname("hw.optional.arm64", &value, &size, nil, 0) == 0 && value == 1
+ }
+
+ static var macOSVersion: OperatingSystemVersion { ProcessInfo.processInfo.operatingSystemVersion }
+
+ static var macOSDisplay: String {
+ let v = macOSVersion
+ return v.patchVersion == 0 ? "macOS \(v.majorVersion).\(v.minorVersion)" : "macOS \(v.majorVersion).\(v.minorVersion).\(v.patchVersion)"
+ }
+
+ static var chipName: String {
+ var size = 0
+ guard sysctlbyname("machdep.cpu.brand_string", nil, &size, nil, 0) == 0, size > 0 else { return "" }
+ var bytes = [CChar](repeating: 0, count: size)
+ guard sysctlbyname("machdep.cpu.brand_string", &bytes, &size, nil, 0) == 0 else { return "" }
+ return String(cString: bytes)
+ }
+
+ static func freeBytes(at url: URL = SupportPaths.home) -> Int64? {
+ let values = try? url.resourceValues(forKeys: [.volumeAvailableCapacityForImportantUsageKey])
+ return values?.volumeAvailableCapacityForImportantUsage
+ }
+
+ // Rosetta's runtime lives here once installed; its absence is what softwareupdate fixes.
+ static let rosettaRuntime = URL(filePath: "/Library/Apple/usr/libexec/oah/libRosettaRuntime")
+
+ static func rosettaInstalled(runtime: URL = rosettaRuntime) -> Bool {
+ FileManager.default.fileExists(atPath: runtime.path(percentEncoded: false))
+ }
+
+ // softwareupdate needs root, so this goes through the standard administrator prompt.
+ static func installRosetta() throws {
+ let script = "do shell script \"/usr/sbin/softwareupdate --install-rosetta --agree-to-license\" with administrator privileges"
+ try Shell.check("/usr/bin/osascript", ["-e", script])
+ }
+
+ static var loginUsers: URL {
+ SupportPaths.Steam.userData.appending(path: "config/loginusers.vdf")
+ }
+
+ // Steam writes every account that signed in on this Mac to loginusers.vdf.
+ static func steamSignedIn(loginUsers file: URL = loginUsers) -> Bool {
+ guard let text = try? String(contentsOf: file, encoding: .utf8) else { return false }
+ return text.range(of: "\"AccountName\"", options: .caseInsensitive) != nil
+ }
+
+ // Downloads Valve's installer image and copies Steam.app into /Applications.
+ static func installSteam(to app: URL = SupportPaths.Steam.defaultApp, report: @Sendable (String) -> Void) async throws {
+ report(String(localized: "Downloading Steam"))
+ let (download, response) = try await URLSession.shared.download(from: steamInstaller)
+ defer { try? FileManager.default.removeItem(at: download) }
+ if let http = response as? HTTPURLResponse, http.statusCode != 200 {
+ throw StepFailure(step: step, detail: "Valve answered \(http.statusCode).")
+ }
+ report(String(localized: "Installing Steam"))
+ try DiskImage.withMounted(download) { volume in
+ try Shell.check("/usr/bin/ditto", [volume.appending(path: "Steam.app").path(percentEncoded: false),
+ app.path(percentEncoded: false)])
+ }
+ }
+
+ static let step = String(localized: "Install Steam")
+}
+
+// Read-only disk image mounts that are always detached again.
+enum DiskImage {
+ static func withMounted<T>(_ image: URL, _ body: (URL) throws -> T) throws -> T {
+ let mount = FileManager.default.temporaryDirectory.appending(path: "notproton-\(UUID().uuidString)", directoryHint: .isDirectory)
+ try FileManager.default.createDirectory(at: mount, withIntermediateDirectories: true)
+ defer { try? FileManager.default.removeItem(at: mount) }
+ try Shell.check("/usr/bin/hdiutil", ["attach", "-nobrowse", "-readonly", "-noverify", "-quiet",
+ "-mountpoint", mount.path(percentEncoded: false), image.path(percentEncoded: false)])
+ defer { _ = try? Shell.run("/usr/bin/hdiutil", ["detach", "-quiet", "-force", mount.path(percentEncoded: false)]) }
+ return try body(mount)
+ }
+}
+
+// Copies Game Porting Toolkit's redist/lib out of Apple's disk image into the folder
+// WinecxD3DMetal.locate looks in first.
+enum GPTKImport {
+ static var downloads: URL { SupportPaths.home.appending(path: "Downloads", directoryHint: .isDirectory) }
+
+ // Apple names the image Game_Porting_Toolkit_<version>.dmg; the newest name sorts last.
+ static func candidates(in folder: URL = downloads) -> [URL] {
+ let names = (try? FileManager.default.contentsOfDirectory(atPath: folder.path(percentEncoded: false))) ?? []
+ return names
+ .filter { $0.hasPrefix("Game_Porting_Toolkit") && $0.lowercased().hasSuffix(".dmg") }
+ .sorted { $0.localizedStandardCompare($1) == .orderedDescending }
+ .map { folder.appending(path: $0) }
+ }
+
+ // The outer image holds "Evaluation environment for Windows games <version>.dmg", which
+ // holds redist/lib.
+ static func innerImage(in volume: URL) -> URL? {
+ let names = (try? FileManager.default.contentsOfDirectory(atPath: volume.path(percentEncoded: false))) ?? []
+ return names.first { $0.hasPrefix("Evaluation environment") && $0.lowercased().hasSuffix(".dmg") }
+ .map { volume.appending(path: $0) }
+ }
+
+ static func importImage(_ image: URL, into destination: URL = WinecxD3DMetal.userFolder) throws -> WinecxD3DMetal.Payload {
+ try DiskImage.withMounted(image) { outer in
+ let lib: (URL) throws -> Void = { volume in
+ let source = volume.appending(path: "redist/lib", directoryHint: .isDirectory)
+ guard FileManager.default.fileExists(atPath: source.path(percentEncoded: false)) else {
+ throw StepFailure(step: step, detail: "\(image.lastPathComponent) has no redist/lib folder.")
+ }
+ let staging = destination.deletingLastPathComponent().appending(path: ".gptk-import", directoryHint: .isDirectory)
+ try? FileManager.default.removeItem(at: staging)
+ try Shell.check("/usr/bin/ditto", [source.path(percentEncoded: false), staging.path(percentEncoded: false)])
+ for name in ["License.rtf"] where !FileManager.default.fileExists(atPath: staging.appending(path: name).path(percentEncoded: false)) {
+ try? FileManager.default.copyItem(at: volume.appending(path: name), to: staging.appending(path: name))
+ }
+ try? FileManager.default.removeItem(at: destination)
+ try FileManager.default.moveItem(at: staging, to: destination)
+ }
+ if let inner = innerImage(in: outer) {
+ try DiskImage.withMounted(inner, lib)
+ } else {
+ try lib(outer)
+ }
+ }
+ guard let payload = WinecxD3DMetal.locate(in: [destination]) else {
+ throw StepFailure(step: step, detail: "The copied Game Porting Toolkit is incomplete.")
+ }
+ return payload
+ }
+
+ static let step = String(localized: "Add the Game Porting Toolkit")
+}
diff --git a/app/Sources/NotProtonApp/Model/SteamDefaultTool.swift b/app/Sources/NotProtonApp/Model/SteamDefaultTool.swift
new file mode 100644
index 0000000..0d8aeeb
--- /dev/null
+++ b/app/Sources/NotProtonApp/Model/SteamDefaultTool.swift
@@ -0,0 +1,109 @@
+import Foundation
+
+// Steam's default compatibility tool: CompatToolMapping's "0" entry in config.vdf, which
+// applies to every app without a mapping of its own. Steam rewrites config.vdf when it quits,
+// so this is only written while Steam is closed.
+enum SteamDefaultTool {
+ static let globalPriority = "75"
+
+ static var config: URL {
+ SupportPaths.Steam.userData.appending(path: "config/config.vdf")
+ }
+
+ static func set(_ tool: String, in file: URL = config) throws {
+ guard let text = try? String(contentsOf: file, encoding: .utf8) else {
+ throw StepFailure(step: step, detail: "Steam has no config.vdf yet. Open Steam once, log in, quit it and run this again.")
+ }
+ guard let result = updated(text, tool: tool) else {
+ throw StepFailure(step: step, detail: "config.vdf has no InstallConfigStore > Software > Valve > Steam section.")
+ }
+ if result != text {
+ try result.write(to: file, atomically: true, encoding: .utf8)
+ }
+ }
+
+ static let step = "Set Steam's default compatibility tool"
+
+ // Replaces the "0" entry under CompatToolMapping, or adds it (and CompatToolMapping) when
+ // missing. nil when the file has no Valve > Steam section to put it in.
+ static func updated(_ text: String, tool: String) -> String? {
+ var lines = text.components(separatedBy: "\n")
+
+ if let mapping = keyLine(lines, "CompatToolMapping", from: 0) {
+ let depth = indent(lines[mapping])
+ guard let open = openBrace(lines, after: mapping), let close = closeBrace(lines, open: open) else { return nil }
+ let entryDepth = depth + 1
+ if let zero = (open + 1 ..< close).first(where: {
+ indent(lines[$0]) == entryDepth && key(lines[$0]) == "0"
+ }), let zeroOpen = openBrace(lines, after: zero), let zeroClose = closeBrace(lines, open: zeroOpen) {
+ lines.replaceSubrange(zero ... zeroClose, with: entry(tool, depth: entryDepth))
+ } else {
+ lines.insert(contentsOf: entry(tool, depth: entryDepth), at: open + 1)
+ }
+ return lines.joined(separator: "\n")
+ }
+
+ guard let valve = keyLine(lines, "Valve", from: 0),
+ let steam = keyLine(lines, "Steam", from: valve + 1),
+ let open = openBrace(lines, after: steam)
+ else { return nil }
+ let depth = indent(lines[steam]) + 1
+ let tabs = String(repeating: "\t", count: depth)
+ let block = ["\(tabs)\"CompatToolMapping\"", "\(tabs){"] + entry(tool, depth: depth + 1) + ["\(tabs)}"]
+ lines.insert(contentsOf: block, at: open + 1)
+ return lines.joined(separator: "\n")
+ }
+
+ private static func entry(_ tool: String, depth: Int) -> [String] {
+ let tabs = String(repeating: "\t", count: depth)
+ return [
+ "\(tabs)\"0\"",
+ "\(tabs){",
+ "\(tabs)\t\"name\"\t\t\"\(tool)\"",
+ "\(tabs)\t\"config\"\t\t\"\"",
+ "\(tabs)\t\"priority\"\t\t\"\(globalPriority)\"",
+ "\(tabs)}",
+ ]
+ }
+
+ // A line holding only a quoted key (a section name), compared case-insensitively as
+ // Steam's KeyValues does.
+ private static func key(_ line: String) -> String? {
+ let trimmed = line.trimmingCharacters(in: .whitespaces)
+ guard trimmed.count >= 2, trimmed.hasPrefix("\""), trimmed.hasSuffix("\""),
+ trimmed.dropFirst().dropLast().contains("\"") == false
+ else { return nil }
+ return String(trimmed.dropFirst().dropLast())
+ }
+
+ private static func keyLine(_ lines: [String], _ name: String, from start: Int) -> Int? {
+ guard start < lines.count else { return nil }
+ return (start ..< lines.count).first {
+ key(lines[$0])?.caseInsensitiveCompare(name) == .orderedSame
+ && openBrace(lines, after: $0) == $0 + 1
+ }
+ }
+
+ private static func openBrace(_ lines: [String], after line: Int) -> Int? {
+ let next = line + 1
+ guard next < lines.count, lines[next].trimmingCharacters(in: .whitespaces) == "{" else { return nil }
+ return next
+ }
+
+ private static func closeBrace(_ lines: [String], open: Int) -> Int? {
+ var depth = 0
+ for index in open ..< lines.count {
+ let trimmed = lines[index].trimmingCharacters(in: .whitespaces)
+ if trimmed == "{" { depth += 1 }
+ if trimmed == "}" {
+ depth -= 1
+ if depth == 0 { return index }
+ }
+ }
+ return nil
+ }
+
+ private static func indent(_ line: String) -> Int {
+ line.prefix { $0 == "\t" }.count
+ }
+}
diff --git a/app/Sources/NotProtonApp/SetupAssistant.swift b/app/Sources/NotProtonApp/SetupAssistant.swift
new file mode 100644
index 0000000..a3c1da9
--- /dev/null
+++ b/app/Sources/NotProtonApp/SetupAssistant.swift
@@ -0,0 +1,245 @@
+import AppKit
+import Foundation
+
+// Drives the Setup Assistant: checks first, asks only when a check fails, and runs the
+// same installs as the Status page (installIntoSteam, installWinecxEngine) in order.
+@MainActor
+@Observable
+final class SetupAssistant {
+
+ enum Step: Int, CaseIterable, Identifiable {
+ case mac, graphics, steam, finish, done
+ var id: Int { rawValue }
+
+ var title: String {
+ switch self {
+ case .mac: String(localized: "Your Mac")
+ case .graphics: String(localized: "Graphics")
+ case .steam: String(localized: "Steam")
+ case .finish: String(localized: "Set Up")
+ case .done: String(localized: "Done")
+ }
+ }
+ }
+
+ enum TaskState: Equatable { case waiting, running, done, failed(String) }
+
+ struct SetupTask: Identifiable, Equatable {
+ let id: String
+ let title: String
+ var state: TaskState = .waiting
+ }
+
+ static let finishedKey = "setupAssistantFinished"
+
+ var step: Step = .mac
+ var isWorking = false
+ var message: String?
+
+ // Mac
+ var rosettaInstalled = SetupChecks.rosettaInstalled()
+ let appleSilicon = SetupChecks.isAppleSilicon
+ let macOSSupported = SetupChecks.macOSVersion.majorVersion >= SetupChecks.minimumMacOS
+ let freeBytes = SetupChecks.freeBytes()
+
+ // Graphics
+ var gptk: WinecxD3DMetal.Payload? = WinecxD3DMetal.locate()
+ var gptkImages: [URL] = GPTKImport.candidates()
+ var skippedGraphics = false
+
+ // Steam
+ var steamInstalled = SteamBundle.isPresent
+ var signedIn = SetupChecks.steamSignedIn()
+ @ObservationIgnored private var signInWatch: Task<Void, Never>?
+
+ // Finish
+ var tasks: [SetupTask] = SetupAssistant.plannedTasks
+ var needsAppManagement = false
+ @ObservationIgnored private var permissionWatch: Task<Void, Never>?
+
+ static let plannedTasks = [
+ SetupTask(id: "steam", title: String(localized: "Add NotProton to Steam")),
+ SetupTask(id: "engine", title: String(localized: "Set up the WineCX engine")),
+ SetupTask(id: "default", title: String(localized: "Make WineCX Steam's default")),
+ ]
+
+ var macReady: Bool { appleSilicon && macOSSupported && rosettaInstalled && hasSpace }
+ var hasSpace: Bool { (freeBytes ?? .max) >= SetupChecks.requiredBytes }
+
+ static func shouldShow(_ snapshot: StatusSnapshot?, defaults: UserDefaults = .standard) -> Bool {
+ guard !defaults.bool(forKey: finishedKey), let snapshot else { return false }
+ let deployed: Bool = switch snapshot.steam {
+ case .installed, .outdated: true
+ default: false
+ }
+ return !(deployed && snapshot.currentFreeEngines.contains(FreeEngineWinecx.current.build))
+ }
+
+ func advance() {
+ guard let next = Step(rawValue: step.rawValue + 1) else { return }
+ message = nil
+ step = next
+ if step == .steam { watchSignIn() }
+ }
+
+ func back() {
+ guard step != .finish || !isWorking, let previous = Step(rawValue: step.rawValue - 1) else { return }
+ message = nil
+ step = previous
+ }
+
+ // MARK: Mac
+
+ func installRosetta() async {
+ isWorking = true
+ defer { isWorking = false }
+ do {
+ try await Task.detached(priority: .userInitiated) { try SetupChecks.installRosetta() }.value
+ } catch {
+ message = String(localized: "Rosetta wasn't installed. \(error.localizedDescription)")
+ }
+ rosettaInstalled = SetupChecks.rosettaInstalled()
+ }
+
+ // MARK: Graphics
+
+ func importGPTK(_ image: URL) async {
+ isWorking = true
+ defer { isWorking = false }
+ message = nil
+ do {
+ gptk = try await Task.detached(priority: .userInitiated) { try GPTKImport.importImage(image) }.value
+ } catch {
+ message = error.localizedDescription
+ }
+ }
+
+ // MARK: Steam
+
+ func installSteam() async {
+ isWorking = true
+ defer { isWorking = false }
+ message = nil
+ do {
+ try await SetupChecks.installSteam { _ in }
+ } catch {
+ message = String(localized: "Steam wasn't installed. \(error.localizedDescription)")
+ }
+ steamInstalled = SteamBundle.isPresent
+ }
+
+ func openSteam() {
+ NSWorkspace.shared.open(SupportPaths.Steam.app)
+ watchSignIn()
+ }
+
+ private func watchSignIn() {
+ signInWatch?.cancel()
+ guard !signedIn else { return }
+ signInWatch = Task { [weak self] in
+ while !Task.isCancelled {
+ try? await Task.sleep(for: .seconds(3))
+ guard let self else { return }
+ if SetupChecks.steamSignedIn() {
+ self.signedIn = true
+ return
+ }
+ }
+ }
+ }
+
+ // MARK: Finish
+
+ func finish(with status: SystemStatus) async {
+ guard !isWorking else { return }
+ isWorking = true
+ defer { isWorking = false }
+ needsAppManagement = false
+ message = nil
+ tasks = Self.plannedTasks
+
+ set("steam", .running)
+ await status.installIntoSteam()
+ if let failure = status.failure {
+ if status.failureRemedy == .appManagement {
+ needsAppManagement = true
+ set("steam", .failed(String(localized: "macOS needs your permission first.")))
+ watchPermission(status)
+ } else {
+ set("steam", .failed(failure))
+ }
+ return
+ }
+ set("steam", .done)
+
+ set("engine", .running)
+ await status.installWinecxEngine()
+ if let failure = status.failure {
+ set("engine", .failed(failure))
+ return
+ }
+ set("engine", .done)
+
+ set("default", .running)
+ if SteamBundle.isRunning {
+ set("default", .failed(String(localized: "Quit Steam, then press Try Again.")))
+ return
+ }
+ do {
+ if let tool = FreeEngineWinecx.current.runner.tools.first?.name {
+ try SteamDefaultTool.set(tool)
+ }
+ set("default", .done)
+ } catch {
+ set("default", .failed(error.localizedDescription))
+ return
+ }
+
+ UserDefaults.standard.set(true, forKey: Self.finishedKey)
+ step = .done
+ }
+
+ var notStarted: Bool { tasks.allSatisfy { $0.state == .waiting } }
+ var failed: Bool { tasks.contains { if case .failed = $0.state { true } else { false } } }
+
+ private func set(_ id: String, _ state: TaskState) {
+ guard let index = tasks.firstIndex(where: { $0.id == id }) else { return }
+ tasks[index].state = state
+ }
+
+ func openAppManagement() {
+ if let pane = Remedy.appManagement.settingsPane { Remedy.openSettings(pane) }
+ }
+
+ // Retries on its own as soon as macOS lets this app write into Steam.app.
+ private func watchPermission(_ status: SystemStatus) {
+ permissionWatch?.cancel()
+ permissionWatch = Task { [weak self] in
+ while !Task.isCancelled {
+ try? await Task.sleep(for: .seconds(2))
+ guard let self, self.needsAppManagement else { return }
+ if Self.canWriteSteam() {
+ await self.finish(with: status)
+ return
+ }
+ }
+ }
+ }
+
+ nonisolated static func canWriteSteam(app: URL = SupportPaths.Steam.app) -> Bool {
+ let probe = app.appending(path: "Contents/.notproton-write-probe")
+ guard FileManager.default.createFile(atPath: probe.path(percentEncoded: false), contents: Data()) else { return false }
+ try? FileManager.default.removeItem(at: probe)
+ return true
+ }
+
+ func openSteamAndClose() {
+ NSWorkspace.shared.open(SupportPaths.Steam.app)
+ }
+
+ func dismiss() {
+ signInWatch?.cancel()
+ permissionWatch?.cancel()
+ UserDefaults.standard.set(true, forKey: Self.finishedKey)
+ }
+}
diff --git a/app/Sources/NotProtonApp/Support/Launch.swift b/app/Sources/NotProtonApp/Support/Launch.swift
index 78565c9..49e7fd2 100644
--- a/app/Sources/NotProtonApp/Support/Launch.swift
+++ b/app/Sources/NotProtonApp/Support/Launch.swift
@@ -9,6 +9,9 @@ enum Launch {
if CommandLine.arguments.dropFirst().contains(InstallIntoSteamCommand.flag) {
InstallIntoSteamCommand.run()
}
+ if CommandLine.arguments.dropFirst().contains(SetupWinecxCommand.flag) {
+ SetupWinecxCommand.run()
+ }
NotProtonApp.main()
}
}
diff --git a/app/Sources/NotProtonApp/Support/SetupWinecxCommand.swift b/app/Sources/NotProtonApp/Support/SetupWinecxCommand.swift
new file mode 100644
index 0000000..4e1423d
--- /dev/null
+++ b/app/Sources/NotProtonApp/Support/SetupWinecxCommand.swift
@@ -0,0 +1,53 @@
+import Foundation
+
+// What the WineCX Engine row's "Download & Set Up" does, for scripts: installs the WineCX
+// engine (reusing any pinned archive already in the download cache), links a Game Porting
+// Toolkit when one is found, sets the compatibility tool up and makes it Steam's default.
+// Steam must be closed, since it rewrites config.vdf when it quits.
+enum SetupWinecxCommand {
+ static let flag = "--setup-winecx"
+
+ static func run() -> Never {
+ Task.detached { exit(await perform()) }
+ dispatchMain()
+ }
+
+ private static func perform() async -> Int32 {
+ do {
+ if SteamBundle.isRunning {
+ throw StepFailure(step: FreeEngineWinecx.step, detail: "Steam is running. Quit Steam and run this again.")
+ }
+ if DeploymentContent.current(version: AppVersion.bundled).blocksInstallation {
+ throw StepFailure(step: FreeEngineWinecx.step,
+ detail: "Installation is blocked. Use the NotProton app that installed this build.")
+ }
+ if RunnerStore.clonedBuilds().contains(where: {
+ RunnerInstaller.isRunning(from: SupportPaths.runnerRoot(forBuild: $0))
+ }) {
+ throw StepFailure(step: FreeEngineWinecx.step,
+ detail: "A game or Wine tool is running. Quit it before setting WineCX up.")
+ }
+ let lock = try DeploymentContent.acquireInstallationLock()
+ defer { lock.release() }
+
+ let install = try await FreeEngineWinecx.install { say($0.label) }
+ _ = try RunnerSetup.run(from: install, replacingExisting: true) { say($0.label) }
+ say(WinecxD3DMetal.linkedSource(root: install.crossOverRoot).map { "Game Porting Toolkit linked from \($0)." }
+ ?? "Game Porting Toolkit not found; games use DXMT.")
+
+ if let tool = FreeEngineWinecx.current.runner.tools.first?.name {
+ try SteamDefaultTool.set(tool)
+ say("Steam's default compatibility tool is \(tool).")
+ }
+ say("WineCX is set up.")
+ return 0
+ } catch {
+ FileHandle.standardError.write(Data("\(RemoveEverythingCommand.failureMessage(error))\n".utf8))
+ return 1
+ }
+ }
+
+ private static func say(_ line: String) {
+ FileHandle.standardOutput.write(Data("\(line)\n".utf8))
+ }
+}
diff --git a/app/Sources/NotProtonApp/Views/SetupAssistantView.swift b/app/Sources/NotProtonApp/Views/SetupAssistantView.swift
new file mode 100644
index 0000000..42a24bb
--- /dev/null
+++ b/app/Sources/NotProtonApp/Views/SetupAssistantView.swift
@@ -0,0 +1,359 @@
+import SwiftUI
+import UniformTypeIdentifiers
+
+// First-run Setup Assistant. Built from the Status page's own pieces (a grouped Form of
+// StatusRows with StatusTone dots and StatusActions) so it reads as part of the same app.
+// Each step checks first; buttons appear only for what a check could not do on its own.
+struct SetupAssistantView: View {
+ @Environment(SystemStatus.self) private var status
+ @Environment(\.dismiss) private var dismiss
+ @Environment(\.accessibilityReduceMotion) private var reduceMotion
+ @State private var model: SetupAssistant
+ // How many rows of the current step have resolved; the rest still show "Checking…".
+ @State private var revealed: Int
+ @State private var forward = true
+ private let fixedReveal: Int?
+
+ init(model: SetupAssistant = SetupAssistant(), revealed: Int? = nil) {
+ _model = State(initialValue: model)
+ _revealed = State(initialValue: revealed ?? 0)
+ fixedReveal = revealed
+ }
+
+ static let pageSpring = Animation.spring(response: 0.42, dampingFraction: 0.86)
+ static let rowSpring = Animation.spring(response: 0.32, dampingFraction: 0.8)
+
+ var body: some View {
+ VStack(spacing: 0) {
+ StepBar(current: model.step)
+ .padding(.horizontal, 24)
+ .padding(.top, 18)
+ .padding(.bottom, 4)
+ ZStack {
+ Form {
+ content
+ if let message = model.message {
+ Section {
+ StatusRow(title: String(localized: "Something went wrong"), value: message, tone: .bad)
+ }
+ }
+ }
+ .formStyle(.grouped)
+ .id(model.step)
+ .transition(pageTransition)
+ }
+ .clipped()
+ Divider()
+ footer
+ .padding(.horizontal, 20)
+ .padding(.vertical, 12)
+ }
+ .frame(width: 640, height: 560)
+ .task(id: model.step) { await wave() }
+ }
+
+ private var pageTransition: AnyTransition {
+ if reduceMotion { return .opacity }
+ return .asymmetric(
+ insertion: .move(edge: forward ? .trailing : .leading).combined(with: .opacity),
+ removal: .move(edge: forward ? .leading : .trailing).combined(with: .opacity)
+ )
+ }
+
+ // Rows resolve one after another so the checks read as work being done, not a wall of
+ // results. Reduce Motion shows them all at once.
+ private func wave() async {
+ if let fixedReveal { revealed = fixedReveal; return }
+ guard !reduceMotion else { revealed = .max; return }
+ revealed = 0
+ try? await Task.sleep(for: .milliseconds(260))
+ for index in 1...5 {
+ withAnimation(Self.rowSpring) { revealed = index }
+ try? await Task.sleep(for: .milliseconds(210))
+ }
+ revealed = .max
+ }
+
+ private func go(forward: Bool, _ change: () -> Void) {
+ self.forward = forward
+ withAnimation(reduceMotion ? .easeOut(duration: 0.2) : Self.pageSpring, change)
+ }
+
+ // One row of the wave: pending rows keep their title and show a spinner in place of the
+ // result, then swap in the real value and tone.
+ private func checked(_ index: Int, _ row: StatusRow) -> some View {
+ let pending = index >= revealed
+ var shown = row
+ if pending {
+ shown.value = String(localized: "Checking…")
+ shown.tone = .neutral
+ shown.detail = nil
+ shown.action = nil
+ shown.secondaryAction = nil
+ shown.trailing = nil
+ }
+ return shown
+ .frame(maxWidth: .infinity, alignment: .leading)
+ .overlay(alignment: .trailing) {
+ if pending {
+ ProgressView().controlSize(.small).transition(.opacity)
+ }
+ }
+ }
+
+ @ViewBuilder
+ private var content: some View {
+ switch model.step {
+ case .mac: macStep
+ case .graphics: graphicsStep
+ case .steam: steamStep
+ case .finish: finishStep
+ case .done: doneStep
+ }
+ }
+
+ // MARK: Steps
+
+ @ViewBuilder
+ private var macStep: some View {
+ Section {
+ checked(0, StatusRow(title: String(localized: "Apple silicon"),
+ value: model.appleSilicon ? SetupChecks.chipName : String(localized: "NotProton doesn't run on Intel Macs."),
+ tone: model.appleSilicon ? .ok : .bad))
+ checked(1, StatusRow(title: String(localized: "macOS \(SetupChecks.minimumMacOS) or later"),
+ value: model.macOSSupported ? SetupChecks.macOSDisplay : String(localized: "\(SetupChecks.macOSDisplay). Update macOS first."),
+ tone: model.macOSSupported ? .ok : .bad))
+ checked(2, StatusRow(title: String(localized: "Free space"),
+ value: model.freeBytes.map { String(localized: "\(ByteCountFormatter.string(fromByteCount: $0, countStyle: .file)) available, 3 GB needed") },
+ tone: model.hasSpace ? .ok : .bad))
+ checked(3, StatusRow(title: String(localized: "Rosetta 2"),
+ value: model.rosettaInstalled ? String(localized: "Installed.") : String(localized: "Apple's translator for Windows games. Asks for your Mac password."),
+ tone: model.rosettaInstalled ? .ok : .warning,
+ action: model.rosettaInstalled ? nil : StatusAction(
+ label: String(localized: "Install"), isProminent: true, isEnabled: !model.isWorking
+ ) { Task { await model.installRosetta() } }))
+ } header: {
+ StepHeader(title: "Check your Mac",
+ detail: "NotProton runs Windows games from your Steam library. First, a few quick checks.")
+ }
+ }
+
+ @ViewBuilder
+ private var graphicsStep: some View {
+ Section {
+ if let gptk = model.gptk {
+ StatusRow(title: String(localized: "Game Porting Toolkit"),
+ value: String(localized: "Ready from \(gptk.libRoot.path(percentEncoded: false))."),
+ tone: .ok, trailing: gptk.version)
+ } else {
+ if let image = model.gptkImages.first {
+ StatusRow(title: image.lastPathComponent, value: String(localized: "Found in Downloads."), tone: .info,
+ action: StatusAction(label: String(localized: "Use This"), isProminent: true, isEnabled: !model.isWorking) {
+ Task { await model.importGPTK(image) }
+ })
+ }
+ StatusRow(title: String(localized: "Choose a disk image"),
+ value: String(localized: "Drop Game_Porting_Toolkit .dmg on this window, or pick it from a folder."),
+ tone: .neutral,
+ secondaryAction: StatusAction(label: String(localized: "Get It from Apple")) {
+ NSWorkspace.shared.open(URL(string: "https://developer.apple.com/download/all/?q=Game%20Porting%20Toolkit")!)
+ },
+ action: StatusAction(label: String(localized: "Choose…"), isEnabled: !model.isWorking) { chooseImage() })
+ }
+ } header: {
+ StepHeader(title: "Add Apple's game graphics",
+ detail: "The Game Porting Toolkit (D3DMetal) runs DirectX 11 and 12 games on Metal. Apple gives it away for free with an Apple Account. Without it, games use DXMT.")
+ }
+ .dropDestination(for: URL.self) { urls, _ in
+ guard let url = urls.first(where: { $0.pathExtension.lowercased() == "dmg" }) else { return false }
+ Task { await model.importGPTK(url) }
+ return true
+ }
+ }
+
+ @ViewBuilder
+ private var steamStep: some View {
+ Section {
+ checked(0, StatusRow(title: String(localized: "Steam"),
+ value: model.steamInstalled ? SupportPaths.Steam.app.path(percentEncoded: false) : String(localized: "Not installed."),
+ tone: model.steamInstalled ? .ok : .warning,
+ action: model.steamInstalled ? nil : StatusAction(
+ label: String(localized: "Install Steam"), isProminent: true, isEnabled: !model.isWorking
+ ) { Task { await model.installSteam() } }))
+ checked(1, StatusRow(title: String(localized: "Steam account"),
+ value: model.signedIn ? String(localized: "Signed in.") : String(localized: "Waiting for you to sign in. NotProton never sees your password."),
+ tone: model.signedIn ? .ok : .info,
+ action: model.signedIn || !model.steamInstalled ? nil : StatusAction(label: String(localized: "Open Steam")) { model.openSteam() }))
+ } header: {
+ StepHeader(title: "Sign in to Steam",
+ detail: "Sign in with your account in Steam. NotProton continues on its own once you're in.")
+ }
+ }
+
+ @ViewBuilder
+ private var finishStep: some View {
+ Section {
+ ForEach(model.tasks) { task in
+ StatusRow(title: task.title, value: value(of: task), tone: tone(of: task))
+ .frame(maxWidth: .infinity, alignment: .leading)
+ .overlay(alignment: .trailing) {
+ if task.state == .running {
+ ProgressView().controlSize(.small).transition(.opacity)
+ }
+ }
+ .animation(Self.rowSpring, value: task.state)
+ }
+ } header: {
+ StepHeader(title: "Set up NotProton",
+ detail: "NotProton adds itself to Steam, sets up the WineCX engine and makes it Steam's default. Steam closes for a moment.")
+ } footer: {
+ let done = model.tasks.filter { $0.state == .done }.count
+ HStack(spacing: 12) {
+ ProgressView(value: Double(done), total: Double(model.tasks.count))
+ .tint(.accentColor)
+ .animation(Self.rowSpring, value: done)
+ Text("\(done) of \(model.tasks.count)")
+ .monospacedDigit()
+ .contentTransition(.numericText(value: Double(done)))
+ .animation(Self.rowSpring, value: done)
+ .foregroundStyle(.secondary)
+ }
+ .padding(.top, 6)
+ }
+ if model.needsAppManagement {
+ Section {
+ StatusRow(title: String(localized: "App Management"),
+ value: String(localized: "Turn on NotProton in Privacy & Security › App Management. Setup continues by itself once it's on."),
+ tone: .warning,
+ action: StatusAction(label: Remedy.settingsButton, isProminent: true) { model.openAppManagement() })
+ }
+ }
+ }
+
+ @ViewBuilder
+ private var doneStep: some View {
+ Section {
+ checked(0, StatusRow(title: String(localized: "NotProton"), value: String(localized: "Installed into Steam."), tone: .ok))
+ checked(1, StatusRow(title: String(localized: "WineCX Engine"), value: String(localized: "Steam's default for Windows games."), tone: .ok))
+ checked(2, StatusRow(title: String(localized: "Game Porting Toolkit"),
+ value: model.gptk == nil ? String(localized: "Skipped. Games use DXMT; add it later from Status.") : String(localized: "Linked."),
+ tone: model.gptk == nil ? .neutral : .ok))
+ } header: {
+ StepHeader(title: "You're all set",
+ detail: "Open Steam, install a Windows game and press Play. Status, Prefixes and Prefix Backups in this window change engines, fix a game or undo everything.")
+ }
+ }
+
+ private func value(of task: SetupAssistant.SetupTask) -> String? {
+ switch task.state {
+ case .waiting: nil
+ case .running: status.activity ?? String(localized: "Working…")
+ case .done: String(localized: "Done.")
+ case .failed(let reason): reason
+ }
+ }
+
+ private func tone(of task: SetupAssistant.SetupTask) -> StatusTone {
+ switch task.state {
+ case .waiting: .neutral
+ case .running: .info
+ case .done: .ok
+ case .failed: .bad
+ }
+ }
+
+ private func chooseImage() {
+ let panel = NSOpenPanel()
+ panel.allowedContentTypes = [UTType(filenameExtension: "dmg") ?? .diskImage]
+ panel.directoryURL = GPTKImport.downloads
+ panel.prompt = String(localized: "Use This")
+ if panel.runModal() == .OK, let url = panel.url { Task { await model.importGPTK(url) } }
+ }
+
+ // MARK: Footer
+
+ private var footer: some View {
+ HStack {
+ if model.step == .mac {
+ Button("Not Now") { model.dismiss(); dismiss() }
+ } else if model.step != .done {
+ Button("Back") { go(forward: false) { model.back() } }
+ .disabled(model.isWorking)
+ }
+ Spacer()
+ if model.isWorking { ProgressView().controlSize(.small).padding(.trailing, 6) }
+ switch model.step {
+ case .mac:
+ Button("Continue") { go(forward: true) { model.advance() } }
+ .disabled(!model.macReady || model.isWorking)
+ .keyboardShortcut(.defaultAction)
+ case .graphics:
+ if model.gptk == nil {
+ Button("Skip") { go(forward: true) { model.skippedGraphics = true; model.advance() } }.disabled(model.isWorking)
+ }
+ Button("Continue") { go(forward: true) { model.advance() } }
+ .disabled(model.gptk == nil || model.isWorking)
+ .keyboardShortcut(.defaultAction)
+ case .steam:
+ Button("Continue") { go(forward: true) { model.advance() } }
+ .disabled(!model.steamInstalled || !model.signedIn || model.isWorking)
+ .keyboardShortcut(.defaultAction)
+ case .finish:
+ Button(model.failed ? "Try Again" : "Set Up") { Task { await model.finish(with: status) } }
+ .disabled(model.isWorking || !(model.failed || model.notStarted))
+ .keyboardShortcut(.defaultAction)
+ case .done:
+ Button("Close") { model.dismiss(); dismiss() }
+ Button("Open Steam") { model.openSteamAndClose(); model.dismiss(); dismiss() }
+ .keyboardShortcut(.defaultAction)
+ }
+ }
+ }
+}
+
+// MARK: - Pieces
+
+private struct StepBar: View {
+ let current: SetupAssistant.Step
+ private let steps = SetupAssistant.Step.allCases
+
+ var body: some View {
+ VStack(alignment: .leading, spacing: 8) {
+ GeometryReader { proxy in
+ let fraction = CGFloat(current.rawValue + 1) / CGFloat(steps.count)
+ ZStack(alignment: .leading) {
+ Capsule().fill(.quaternary)
+ Capsule().fill(Color.accentColor)
+ .frame(width: max(6, proxy.size.width * fraction))
+ }
+ }
+ .frame(height: 3)
+ .animation(SetupAssistantView.pageSpring, value: current)
+ HStack(spacing: 0) {
+ ForEach(steps) { step in
+ Text(step.title)
+ .font(.caption.weight(step == current ? .semibold : .regular))
+ .foregroundStyle(step.rawValue <= current.rawValue ? .primary : .tertiary)
+ .frame(maxWidth: .infinity, alignment: .leading)
+ .animation(.easeOut(duration: 0.2), value: current)
+ }
+ }
+ }
+ .accessibilityElement(children: .ignore)
+ .accessibilityLabel("Step \(current.rawValue + 1) of \(steps.count), \(current.title)")
+ }
+}
+
+private struct StepHeader: View {
+ let title: LocalizedStringKey
+ let detail: LocalizedStringKey
+
+ var body: some View {
+ VStack(alignment: .leading, spacing: 6) {
+ Text(title).font(.title2.weight(.semibold)).foregroundStyle(.primary)
+ Text(detail).font(.body).foregroundStyle(.secondary).fixedSize(horizontal: false, vertical: true)
+ }
+ .textCase(nil)
+ .padding(.bottom, 8)
+ }
+}
diff --git a/app/Sources/NotProtonApp/Views/StatusView.swift b/app/Sources/NotProtonApp/Views/StatusView.swift
index 74c3415..ae80d46 100644
--- a/app/Sources/NotProtonApp/Views/StatusView.swift
+++ b/app/Sources/NotProtonApp/Views/StatusView.swift
@@ -62,6 +62,7 @@ struct StatusRow: View {
Image(systemName: tone.symbol)
.font(.system(size: 8))
.foregroundStyle(tone.color)
+ .contentTransition(.symbolEffect(.replace))
.frame(width: StatusMetrics.symbolWidth)
.accessibilityHidden(true)
} else {
@@ -74,6 +75,7 @@ struct StatusRow: View {
if let value {
Text(value)
.foregroundStyle(.secondary)
+ .contentTransition(.opacity)
}
if let detail {
Text(detail)
diff --git a/app/Tests/NotProtonAppTests/SetupAssistantSnapshots.swift b/app/Tests/NotProtonAppTests/SetupAssistantSnapshots.swift
new file mode 100644
index 0000000..e2cdc68
--- /dev/null
+++ b/app/Tests/NotProtonAppTests/SetupAssistantSnapshots.swift
@@ -0,0 +1,90 @@
+import AppKit
+import SwiftUI
+import Testing
+
+@testable import NotProtonApp
+
+// Renders the Setup Assistant's steps and the Status page to PNGs for review when
+// NOTPROTON_SNAPSHOTS names an output folder. Reads this Mac's state without changing it.
+@Suite("Setup Assistant snapshots", .enabled(if: ProcessInfo.processInfo.environment["NOTPROTON_SNAPSHOTS"] != nil))
+@MainActor
+struct SetupAssistantSnapshots {
+
+ private let out = URL(filePath: ProcessInfo.processInfo.environment["NOTPROTON_SNAPSHOTS"] ?? "/tmp", directoryHint: .isDirectory)
+
+ private func render(_ view: some View, _ name: String, size: CGSize, status: SystemStatus, chrome: NSWindow.StyleMask = [.borderless]) throws {
+ _ = NSApplication.shared
+ let host = NSHostingView(rootView: view.environment(status).environment(PrefixesModel()))
+ let window = NSWindow(contentRect: CGRect(origin: .zero, size: size), styleMask: chrome,
+ backing: .buffered, defer: false)
+ window.appearance = NSAppearance(named: .darkAqua)
+ window.contentView = host
+ window.setFrameOrigin(NSPoint(x: -20_000, y: -20_000))
+ window.orderFrontRegardless()
+ defer { window.orderOut(nil) }
+ RunLoop.main.run(until: Date().addingTimeInterval(1.0))
+ window.displayIfNeeded()
+ let bounds = try #require(window.contentView?.superview).bounds
+ let frameView = try #require(window.contentView?.superview)
+ let rep = try #require(frameView.bitmapImageRepForCachingDisplay(in: bounds))
+ frameView.cacheDisplay(in: bounds, to: rep)
+ try FileManager.default.createDirectory(at: out, withIntermediateDirectories: true)
+ try #require(rep.representation(using: .png, properties: [:])).write(to: out.appending(path: "\(name).png"))
+ }
+
+ private func wizard(_ name: String, status: SystemStatus = SystemStatus(), revealed: Int = .max,
+ _ configure: (SetupAssistant) -> Void) throws {
+ let model = SetupAssistant()
+ configure(model)
+ try render(SetupAssistantView(model: model, revealed: revealed), name, size: CGSize(width: 640, height: 560), status: status)
+ }
+
+ // Frames of the check wave and of Set Up progressing, stitched into GIFs for review.
+ @Test func motionFrames() throws {
+ for step in 0...4 {
+ try wizard("frames/wave-\(step)", revealed: step) { $0.step = .mac; $0.rosettaInstalled = false }
+ }
+ let states: [[SetupAssistant.TaskState]] = [
+ [.running, .waiting, .waiting], [.done, .running, .waiting], [.done, .done, .running], [.done, .done, .done],
+ ]
+ for (index, row) in states.enumerated() {
+ let busy = SystemStatus()
+ busy.activity = ["Stopping Steam", "Unpacking WineCX 11.17", "Writing config.vdf", nil][index]
+ try wizard("frames/setup-\(index)", status: busy) { m in
+ m.step = .finish
+ for (i, state) in row.enumerated() { m.tasks[i].state = state }
+ }
+ }
+ }
+
+ @Test func steps() throws {
+ try wizard("2-wizard-1-mac") { $0.step = .mac; $0.rosettaInstalled = false }
+ try wizard("2-wizard-2-graphics") { m in
+ m.step = .graphics; m.gptk = nil
+ m.gptkImages = [URL(filePath: "/Users/you/Downloads/Game_Porting_Toolkit_4.0_beta_2.dmg")]
+ }
+ try wizard("2-wizard-3-steam") { $0.step = .steam; $0.steamInstalled = true; $0.signedIn = false }
+ let busy = SystemStatus()
+ busy.activity = "Unpacking WineCX 11.17"
+ try wizard("2-wizard-4-setup", status: busy) { m in
+ m.step = .finish
+ m.tasks[0].state = .done
+ m.tasks[1].state = .running
+ }
+ try wizard("2-wizard-4b-permission") { m in
+ m.step = .finish
+ m.tasks[0].state = .failed("macOS needs your permission first.")
+ m.needsAppManagement = true
+ }
+ try wizard("2-wizard-5-done") { $0.step = .done }
+ }
+
+ @Test func statusPage() throws {
+ let status = SystemStatus()
+ status.snapshot = StatusSnapshot.capture(bundledVersion: AppVersion.bundled)
+ // The test build carries no payload; the installed app reports its files as current.
+ status.snapshot?.installContent = .current
+ try render(RootView(pane: .constant(.status)), "1-notproton-status", size: CGSize(width: 900, height: 900), status: status,
+ chrome: [.titled, .fullSizeContentView])
+ }
+}
diff --git a/app/Tests/NotProtonAppTests/SetupAssistantTests.swift b/app/Tests/NotProtonAppTests/SetupAssistantTests.swift
new file mode 100644
index 0000000..a39e241
--- /dev/null
+++ b/app/Tests/NotProtonAppTests/SetupAssistantTests.swift
@@ -0,0 +1,77 @@
+import Foundation
+import Testing
+
+@testable import NotProtonApp
+
+@Suite("Setup Assistant")
+struct SetupAssistantTests {
+
+ private func folder() throws -> URL {
+ let url = FileManager.default.temporaryDirectory.appending(path: "setup-\(UUID().uuidString)", directoryHint: .isDirectory)
+ try FileManager.default.createDirectory(at: url, withIntermediateDirectories: true)
+ return url
+ }
+
+ @Test("Steam counts as signed in once loginusers.vdf names an account")
+ func signIn() throws {
+ let dir = try folder()
+ let file = dir.appending(path: "loginusers.vdf")
+ #expect(!SetupChecks.steamSignedIn(loginUsers: file))
+ try "\"users\"\n{\n}\n".write(to: file, atomically: true, encoding: .utf8)
+ #expect(!SetupChecks.steamSignedIn(loginUsers: file))
+ try "\"users\"\n{\n\t\"7656\"\n\t{\n\t\t\"AccountName\"\t\t\"player\"\n\t}\n}\n".write(to: file, atomically: true, encoding: .utf8)
+ #expect(SetupChecks.steamSignedIn(loginUsers: file))
+ }
+
+ @Test("The newest Game Porting Toolkit image in Downloads comes first, other files are ignored")
+ func candidates() throws {
+ let dir = try folder()
+ for name in ["Game_Porting_Toolkit_4.0_beta_1.dmg", "Game_Porting_Toolkit_4.0_beta_2.dmg",
+ "Game_Porting_Toolkit_3.0.dmg", "Game_Porting_Toolkit_notes.pdf", "steam.dmg"] {
+ FileManager.default.createFile(atPath: dir.appending(path: name).path(percentEncoded: false), contents: Data())
+ }
+ #expect(GPTKImport.candidates(in: dir).map(\.lastPathComponent) == [
+ "Game_Porting_Toolkit_4.0_beta_2.dmg", "Game_Porting_Toolkit_4.0_beta_1.dmg", "Game_Porting_Toolkit_3.0.dmg",
+ ])
+ }
+
+ @Test("The evaluation environment image inside Apple's outer image is found")
+ func innerImage() throws {
+ let dir = try folder()
+ let inner = "Evaluation environment for Windows games 4.0 beta 2.dmg"
+ for name in [inner, "Metal Shader Converter 4.0 beta 2.pkg", "Read Me.webloc"] {
+ FileManager.default.createFile(atPath: dir.appending(path: name).path(percentEncoded: false), contents: Data())
+ }
+ #expect(GPTKImport.innerImage(in: dir)?.lastPathComponent == inner)
+ }
+
+ // Mounts Apple's real image, like FreeEngineWinecxTests.unpacksRealArchive, when
+ // NOTPROTON_GPTK_DMG points at Game_Porting_Toolkit_<version>.dmg.
+ @Test("Apple's Game Porting Toolkit image imports into a folder D3DMetal linking accepts",
+ .enabled(if: ProcessInfo.processInfo.environment["NOTPROTON_GPTK_DMG"] != nil))
+ func importsRealImage() throws {
+ let image = URL(filePath: try #require(ProcessInfo.processInfo.environment["NOTPROTON_GPTK_DMG"]))
+ let destination = try folder().appending(path: "gptk", directoryHint: .isDirectory)
+ let payload = try GPTKImport.importImage(image, into: destination)
+ #expect(payload.libRoot.standardizedFileURL == destination.standardizedFileURL)
+ #expect(FileManager.default.fileExists(atPath: destination.appending(path: "external/D3DMetal.framework").path(percentEncoded: false)))
+ #expect(payload.version != nil)
+ }
+
+ @Test("Rosetta counts as installed only when its runtime exists")
+ func rosetta() throws {
+ let dir = try folder()
+ let runtime = dir.appending(path: "libRosettaRuntime")
+ #expect(!SetupChecks.rosettaInstalled(runtime: runtime))
+ FileManager.default.createFile(atPath: runtime.path(percentEncoded: false), contents: Data())
+ #expect(SetupChecks.rosettaInstalled(runtime: runtime))
+ }
+
+ @Test("The assistant stays away once the user finished or dismissed it")
+ @MainActor
+ func finishedFlag() throws {
+ let defaults = try #require(UserDefaults(suiteName: "setup-\(UUID().uuidString)"))
+ defaults.set(true, forKey: SetupAssistant.finishedKey)
+ #expect(!SetupAssistant.shouldShow(nil, defaults: defaults))
+ }
+}
diff --git a/app/Tests/NotProtonAppTests/SteamDefaultToolTests.swift b/app/Tests/NotProtonAppTests/SteamDefaultToolTests.swift
new file mode 100644
index 0000000..d0af1d0
--- /dev/null
+++ b/app/Tests/NotProtonAppTests/SteamDefaultToolTests.swift
@@ -0,0 +1,66 @@
+import Foundation
+import Testing
+
+@testable import NotProtonApp
+
+@Suite("Steam default compatibility tool")
+struct SteamDefaultToolTests {
+
+ private static let head = """
+ "InstallConfigStore"
+ {
+ \t"Software"
+ \t{
+ \t\t"valve"
+ \t\t{
+ \t\t\t"Steam"
+ \t\t\t{
+ """
+ private static let tail = """
+ \t\t\t}
+ \t\t}
+ \t}
+ }
+ """
+
+ private static func entry(_ tool: String) -> String {
+ """
+ \t\t\t\t\t"0"
+ \t\t\t\t\t{
+ \t\t\t\t\t\t"name"\t\t"\(tool)"
+ \t\t\t\t\t\t"config"\t\t""
+ \t\t\t\t\t\t"priority"\t\t"75"
+ \t\t\t\t\t}
+ """
+ }
+
+ @Test("Adds CompatToolMapping with the default when Steam has none")
+ func addsMapping() throws {
+ let text = Self.head + "\n\t\t\t\t\"SentryFile\"\t\t\"x\"\n" + Self.tail
+ let result = try #require(SteamDefaultTool.updated(text, tool: "notproton-winecx-11.17"))
+ #expect(result == Self.head + "\n\t\t\t\t\"CompatToolMapping\"\n\t\t\t\t{\n" + Self.entry("notproton-winecx-11.17")
+ + "\n\t\t\t\t}\n\t\t\t\t\"SentryFile\"\t\t\"x\"\n" + Self.tail)
+ }
+
+ @Test("Adds the default beside per-app mappings and keeps them")
+ func keepsAppMappings() throws {
+ let app = "\t\t\t\t\t\"3764200\"\n\t\t\t\t\t{\n\t\t\t\t\t\t\"name\"\t\t\"other\"\n\t\t\t\t\t}"
+ let text = Self.head + "\n\t\t\t\t\"CompatToolMapping\"\n\t\t\t\t{\n" + app + "\n\t\t\t\t}\n" + Self.tail
+ let result = try #require(SteamDefaultTool.updated(text, tool: "t"))
+ #expect(result == Self.head + "\n\t\t\t\t\"CompatToolMapping\"\n\t\t\t\t{\n" + Self.entry("t") + "\n" + app
+ + "\n\t\t\t\t}\n" + Self.tail)
+ }
+
+ @Test("Replaces an existing default and is idempotent")
+ func replacesDefault() throws {
+ let text = Self.head + "\n\t\t\t\t\"CompatToolMapping\"\n\t\t\t\t{\n" + Self.entry("old") + "\n\t\t\t\t}\n" + Self.tail
+ let once = try #require(SteamDefaultTool.updated(text, tool: "new"))
+ #expect(once == Self.head + "\n\t\t\t\t\"CompatToolMapping\"\n\t\t\t\t{\n" + Self.entry("new") + "\n\t\t\t\t}\n" + Self.tail)
+ #expect(SteamDefaultTool.updated(once, tool: "new") == once)
+ }
+
+ @Test("Refuses a file without a Valve > Steam section")
+ func refusesUnknownLayout() {
+ #expect(SteamDefaultTool.updated("\"InstallConfigStore\"\n{\n}\n", tool: "t") == nil)
+ }
+}
diff --git a/installer/BACA DULU.txt b/installer/BACA DULU.txt
new file mode 100644
index 0000000..fd1bd1a
--- /dev/null
+++ b/installer/BACA DULU.txt
@@ -0,0 +1,17 @@
+Cara pasang NotProton
+
+Butuh: Mac Apple Silicon (M1 atau lebih baru), macOS 26 atau lebih baru, internet.
+
+1. Klik kanan "Install.command", pilih Open, lalu Open lagi.
+ (Cuma pertama kali. Kalau macOS tetap memblokir: System Settings > Privacy & Security,
+ scroll ke bawah, klik "Open Anyway".)
+2. NotProton terbuka dengan Setup Assistant. Ikuti saja:
+ - Your Mac: klik Install di Rosetta kalau diminta (minta password Mac).
+ - Graphics: sudah otomatis, klik Continue.
+ - Steam: login ke akun Steam kamu.
+ - Set Up: klik Set Up. Kalau diminta izin App Management, nyalakan NotProton
+ di jendela Settings yang terbuka. Setup lanjut sendiri.
+3. Klik Open Steam, pilih game Windows, Install, Play.
+
+Game Porting Toolkit (folder gptk) adalah milik Apple dan hanya boleh dipakai
+non-komersial. Lisensinya ada di GPTK-License.rtf.
diff --git a/installer/Install.command b/installer/Install.command
new file mode 100755
index 0000000..461e900
--- /dev/null
+++ b/installer/Install.command
@@ -0,0 +1,58 @@
+#!/bin/bash
+# NotProton one-click installer.
+# Copies NotProton, Apple's Game Porting Toolkit (D3DMetal), the WineCX engine (no download)
+# and the default configs, then opens NotProton, whose Setup Assistant does the rest:
+# Rosetta, Steam, sign-in, the App Management permission and the Steam setup.
+set -uo pipefail
+
+here="$(cd "$(dirname "$0")" && pwd)"
+support="$HOME/Library/Application Support/notproton"
+
+say() { printf '\n\033[1;32m==>\033[0m %s\n' "$*"; }
+die() { printf '\n\033[1;31mGagal:\033[0m %s\n' "$*" >&2; read -r -p "Tekan Enter untuk menutup..." _; exit 1; }
+
+xattr -dr com.apple.quarantine "$here" 2>/dev/null || true
+
+[ "$(sysctl -n hw.optional.arm64 2>/dev/null)" = "1" ] || die "Mac ini bukan Apple Silicon (M1/M2/M3/...). NotProton tidak jalan di Mac Intel."
+major="$(sw_vers -productVersion | cut -d. -f1)"
+[ "$major" -ge 26 ] || die "Butuh macOS 26 atau lebih baru (sekarang $(sw_vers -productVersion)). Update macOS dulu."
+
+say "Memasang NotProton..."
+osascript -e 'tell application id "com.notproton.NotProton" to quit' >/dev/null 2>&1 || true
+rm -rf /Applications/NotProton.app
+ditto "$here/NotProton.app" /Applications/NotProton.app || die "NotProton gagal disalin ke Applications."
+xattr -dr com.apple.quarantine /Applications/NotProton.app 2>/dev/null || true
+
+if [ ! -d /Applications/Steam.app ]; then
+ say "Memasang Steam..."
+ mnt="$(mktemp -d)"
+ hdiutil attach -nobrowse -readonly -quiet -mountpoint "$mnt" "$here/steam.dmg" || die "Installer Steam tidak bisa dibuka."
+ ditto "$mnt/Steam.app" /Applications/Steam.app; ok=$?
+ hdiutil detach -quiet "$mnt" 2>/dev/null; rmdir "$mnt" 2>/dev/null
+ [ $ok -eq 0 ] || die "Steam gagal disalin ke Applications."
+ xattr -dr com.apple.quarantine /Applications/Steam.app 2>/dev/null || true
+fi
+
+say "Menyalin Game Porting Toolkit, engine WineCX dan config (tanpa download)..."
+mkdir -p "$support/gamefixes" "$HOME/Library/Caches/notproton"
+rm -rf "$support/gptk"
+ditto "$here/gptk" "$support/gptk" || die "Game Porting Toolkit gagal disalin."
+# NotProton reuses any cached file whose hash matches its pin, so nothing is downloaded.
+ditto "$here/cache" "$HOME/Library/Caches/notproton" || die "File engine gagal disalin."
+# default.conf is always the bundled one (an existing different copy is kept as .bak);
+# per-game confs the user already has are left alone.
+if [ -f "$support/gamefixes/default.conf" ] && ! cmp -s "$here/config/gamefixes/default.conf" "$support/gamefixes/default.conf"; then
+ cp "$support/gamefixes/default.conf" "$support/gamefixes/default.conf.bak"
+fi
+cp "$here/config/gamefixes/default.conf" "$support/gamefixes/default.conf"
+cp -n "$here/config/gamefixes/"*.conf "$support/gamefixes/" 2>/dev/null || true
+cp -n "$here/config/gamecontrollerdb.txt" "$support/" 2>/dev/null || true
+xattr -dr com.apple.quarantine "$support" 2>/dev/null || true
+# Show the Setup Assistant again even if an earlier NotProton was dismissed.
+defaults delete com.notproton.NotProton setupAssistantFinished >/dev/null 2>&1 || true
+
+say "Selesai. NotProton terbuka, ikuti Setup Assistant-nya."
+open /Applications/NotProton.app
+sleep 2
+osascript -e 'tell application "Terminal" to close (every window whose name contains "Install.command")' >/dev/null 2>&1 &
+exit 0
diff --git a/installer/README.md b/installer/README.md
new file mode 100644
index 0000000..43aca3b
--- /dev/null
+++ b/installer/README.md
@@ -0,0 +1,17 @@
+# Installer
+
+`Install.command` installs the app, Apple's Game Porting Toolkit, the WineCX engine and the
+default configs from the folder it sits in, then opens the app's Setup Assistant.
+
+Assembled next to it at packaging time, never committed:
+
+| Path | Source |
+|---|---|
+| `NotProton.app` | `build/NotProton.app` from `scripts/build-local.sh` |
+| `gptk/` | `redist/lib` of Apple's Game Porting Toolkit DMG (Apple license, non-commercial) |
+| `GPTK-License.rtf` | From the same DMG |
+| `cache/` | `~/Library/Caches/notproton` after an engine install (files matching the pins) |
+| `steam.dmg` | Valve's macOS Steam installer |
+
+`config/` holds the bundled `gamefixes` and `gamecontrollerdb.txt`. `BACA DULU.txt` is the
+user guide shipped in the zip.
diff --git a/installer/config/gamecontrollerdb.txt b/installer/config/gamecontrollerdb.txt
new file mode 100644
index 0000000..a73a49a
--- /dev/null
+++ b/installer/config/gamecontrollerdb.txt
@@ -0,0 +1,5 @@
+# SDL mappings for pads SDL does not know. One per line. Read by the NotProton run script.
+# GameSir G7 Pro via its 2.4 GHz dongle, recorded with pad-mapper on 2026-10-10; axes renumbered to SDL IOKit order (X,Y,Z,Rz,Accel,Brake).
+03000000373500002210000000010000,GameSir G7 Pro (dongle),a:b0,b:b1,x:b3,y:b4,leftshoulder:b6,rightshoulder:b7,lefttrigger:a5,righttrigger:a4,back:b10,start:b11,leftstick:b13,rightstick:b14,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,platform:Mac OS X,
+# Same pad over Bluetooth (SDL reports bus 0x03, HID version 0x011b). Same X,Y,Z,Rz,Accel,Brake axes as the dongle; 16 buttons.
+0300000037350000221000001b010000,GameSir G7 Pro (Bluetooth),a:b0,b:b1,x:b3,y:b4,leftshoulder:b6,rightshoulder:b7,lefttrigger:a5,righttrigger:a4,back:b10,start:b11,leftstick:b13,rightstick:b14,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,platform:Mac OS X,
diff --git a/installer/config/gamefixes/1422450.conf b/installer/config/gamefixes/1422450.conf
new file mode 100644
index 0000000..a180a08
--- /dev/null
+++ b/installer/config/gamefixes/1422450.conf
@@ -0,0 +1,4 @@
+# Source 2 skips NGX when the game has a stdout (Plat_IsConsoleApplication)
+STDOUT_NULL=1
+# Deadlock audio: Source 2 autodetects a 1 ms mix-ahead under Wine
+ARGS=+snd_autodetect_latency 0 +snd_mixahead 0.05
diff --git a/installer/config/gamefixes/3669870.conf b/installer/config/gamefixes/3669870.conf
new file mode 100644
index 0000000..3cfbc5e
--- /dev/null
+++ b/installer/config/gamefixes/3669870.conf
@@ -0,0 +1,2 @@
+# CONTROL Resonant: D3DMetal's Metal 4 path renders broken 3D models (macresearch.org, 2026-10).
+D3DM_MTL4=0
diff --git a/installer/config/gamefixes/3764200.conf b/installer/config/gamefixes/3764200.conf
new file mode 100644
index 0000000..344cf73
--- /dev/null
+++ b/installer/config/gamefixes/3764200.conf
@@ -0,0 +1,4 @@
+# Resident Evil Requiem: RE Engine hides DLSS/XeSS when it detects Wine (re9.exe /WineDetectionEnabled switch).
+ARGS=/WineDetectionEnabled:False
+# RE9 locks its vsync off with frame generation on and tears; force display sync
+VSYNC=1
diff --git a/installer/config/gamefixes/default.conf b/installer/config/gamefixes/default.conf
new file mode 100644
index 0000000..32a3ff6
--- /dev/null
+++ b/installer/config/gamefixes/default.conf
@@ -0,0 +1,11 @@
+# Global defaults for every game (lowest precedence: per-game confs and Steam launch options win).
+MTL_HUD_ENABLED=1
+RETINA=1
+# Rosetta hides AVX/AVX2 unless asked; many games (Spider-Man 2 checks Launcher_CPUFeatureAVX2NotPresent) quit without it.
+ROSETTA_ADVERTISE_AVX=1
+# Exposes DLSS through MetalFX (D3DMetal); only takes effect when DLSS is switched on in the game.
+D3DM_ENABLE_METALFX=1
+# DLSS: turns on Apple's nvapi64 (and nvngx once the engine links it) on D3DMetal, so games offer DLSS (served by MetalFX).
+NVAPI=1
+# DLSS frame generation offered in Streamline games (Ray accepted the WindowServer hang risk, frankea/Whisky#231).
+DLSS_FG=1