Free fork of NotProton: Windows Steam games in Mac Steam, on CodeWeavers' Wine and Apple's Game Porting Toolkit
Swift apple-silicond3dmetaldxmtdxvkgame-porting-toolkitgptkmac-gamingmacosmetalfxrosetta-2steamsteam-playwinewinecx
UI improvements
NotProtonNot6348a9abdcce
diff --git a/app/Sources/NotProtonApp/App.swift b/app/Sources/NotProtonApp/App.swiftindex 8b3bd59..04eb401 100644--- a/app/Sources/NotProtonApp/App.swift+++ b/app/Sources/NotProtonApp/App.swift@@ -126,7 +126,7 @@ struct NotProtonApp: App {if prefixes.tools.count > 1 {Menu(PrefixPrompt.rebuildButton(selectionTargets)) {ForEach(prefixes.tools) { tool in- Button(tool.display) {+ Button(tool.shortDisplay) {prefixes.pendingConfirmation = .rebuild(selectionTargets, tool)}}diff --git a/app/Sources/NotProtonApp/Model/PrefixPrompt.swift b/app/Sources/NotProtonApp/Model/PrefixPrompt.swiftindex 88ba45b..349f7ec 100644--- a/app/Sources/NotProtonApp/Model/PrefixPrompt.swift+++ b/app/Sources/NotProtonApp/Model/PrefixPrompt.swift@@ -33,7 +33,7 @@ enum PrefixPrompt {}static func rebuildTitle(_ targets: [WinePrefix], for tool: InstalledTool? = nil) -> String {- let with = tool.map { " with \($0.display)" } ?? ""+ let with = tool.map { " with \($0.shortDisplay)" } ?? ""switch targets.count {case 0: return "Rebuild prefix\(with)?"case 1: return "Rebuild the prefix for \(targets[0].title)\(with)?"diff --git a/app/Sources/NotProtonApp/Model/SupportedRunner.swift b/app/Sources/NotProtonApp/Model/SupportedRunner.swiftindex deaf3d7..22b6a8e 100644--- a/app/Sources/NotProtonApp/Model/SupportedRunner.swift+++ b/app/Sources/NotProtonApp/Model/SupportedRunner.swift@@ -38,16 +38,21 @@ struct RunnerBuild: Sendable, Equatable, Identifiable {}struct CompatTool: Sendable, Hashable, Identifiable {- enum Flavor: String, Sendable {- case fex+ enum Flavor: String, Sendable, CaseIterable {case rosetta+ case fex++ var name: String { self == .fex ? "FEX" : "Rosetta" }+ var unixDir: String { self == .fex ? "aarch64-unix" : "x86_64-unix" }}let name: Stringlet flavor: Flavorlet display: String+ var short: String? = nilvar id: String { name }+ var shortDisplay: String { short ?? display }var prefixArch: PrefixArch { flavor == .fex ? .arm64 : .x86_64 }}@@ -59,6 +64,7 @@ struct InstalledTool: Sendable, Hashable, Identifiable {var id: String { tool.name }var name: String { tool.name }var display: String { tool.display }+ var shortDisplay: String { tool.shortDisplay }}enum SupportedRunners {@@ -90,7 +96,7 @@ enum SupportedRunners {build.tools.enumerated().map { index, tool inlet name = build.id == holder && index == 0 ? legacyToolName : tool.namereturn InstalledTool(- tool: CompatTool(name: name, flavor: tool.flavor, display: tool.display), build: build.id+ tool: CompatTool(name: name, flavor: tool.flavor, display: tool.display, short: tool.short), build: build.id)}}@@ -134,7 +140,7 @@ enum SupportedRunners {.i386Windows: "25bfde1f50ee96485763968ef10b9d9ad35e38214232f17ebdc009b098af44a0",],tools: [- CompatTool(name: "notproton-preview", flavor: .rosetta, display: "CrossOver Preview (Rosetta-only version)"),+ CompatTool(name: "notproton-preview", flavor: .rosetta, display: "CrossOver Preview - X86 Build (Rosetta)", short: "x86 Preview (Rosetta)"),]),RunnerBuild(@@ -153,8 +159,8 @@ enum SupportedRunners {.aarch64Windows: "f40810193a5ef2520774288f354a8604f5ba91828315f643b3ee6688b873dc3f",],tools: [- CompatTool(name: "notproton-fex", flavor: .fex, display: "CrossOver Preview (FEX)"),- CompatTool(name: "notproton-fex-rosetta", flavor: .rosetta, display: "CrossOver Preview (Rosetta)"),+ CompatTool(name: "notproton-fex", flavor: .fex, display: "CrossOver Preview - ARM64 Build (FEX)", short: "ARM64 Preview (FEX)"),+ CompatTool(name: "notproton-fex-rosetta", flavor: .rosetta, display: "CrossOver Preview - ARM64 Build (Rosetta)", short: "ARM64 Preview (Rosetta)"),]),]diff --git a/app/Sources/NotProtonApp/PrefixesModel.swift b/app/Sources/NotProtonApp/PrefixesModel.swiftindex 914ad17..636bc3f 100644--- a/app/Sources/NotProtonApp/PrefixesModel.swift+++ b/app/Sources/NotProtonApp/PrefixesModel.swift@@ -22,7 +22,10 @@ final class PrefixesModel {stale.contains(prefix.id)}+ private(set) var currentTools: [String: InstalledTool] = [:]+func lastTool(_ prefix: WinePrefix) -> String? {+ if let tool = currentTools[prefix.id] { return tool.shortDisplay }guard let record = records[prefix.id] else { return nil }return record.display ?? SupportedRunners.displayVersion(forID: record.build)}@@ -92,18 +95,23 @@ final class PrefixesModel {let found = await Task.detached { PrefixStore.all(libraries: roots) }.valueguard run == loadGeneration else { return }prefixes = found- usage = [:]+ usage = usage.filter { id, _ in found.contains { $0.id == id } }let listTools = installedTools- (tools, records, stale) = await Task.detached {+ (tools, records, stale, currentTools) = await Task.detached {let tools = listTools()var records: [String: PrefixBuildRecord] = [:]var stale = Set<String>()+ var current: [String: InstalledTool] = [:]for prefix in found {guard let record = PrefixTools.lastBuild(of: prefix) else { continue }records[prefix.id] = record- if PrefixTools.tool(for: prefix, among: tools) == nil { stale.insert(prefix.id) }+ if let tool = PrefixTools.tool(for: prefix, among: tools) {+ current[prefix.id] = tool+ } else {+ stale.insert(prefix.id)+ }}- return (tools, records, stale)+ return (tools, records, stale, current)}.valueguard run == loadGeneration else { return }selection = selection.filter { id in found.contains { $0.id == id } }diff --git a/app/Sources/NotProtonApp/Support/SupportPaths.swift b/app/Sources/NotProtonApp/Support/SupportPaths.swiftindex 1f92790..cbcb75b 100644--- a/app/Sources/NotProtonApp/Support/SupportPaths.swift+++ b/app/Sources/NotProtonApp/Support/SupportPaths.swift@@ -55,12 +55,11 @@ enum SupportPaths {}static func prefixTemplates(forBuild build: String, in library: SteamLibrary) -> [URL] {- [.rosetta, .fex].map { prefixTemplate(forBuild: build, flavor: $0, in: library) }+ CompatTool.Flavor.allCases.map { prefixTemplate(forBuild: build, flavor: $0, in: library) }}static func prefixTemplate(forBuild build: String, flavor: CompatTool.Flavor, in library: SteamLibrary) -> URL {- let unix = flavor == .fex ? "aarch64-unix" : "x86_64-unix"- return library.compatdata.appending(path: prefixTemplateFolder).appending(path: "crossover-\(build)-\(unix)")+ library.compatdata.appending(path: prefixTemplateFolder).appending(path: "crossover-\(build)-\(flavor.unixDir)")}static let prefixTemplateFolder = "notproton-template"diff --git a/app/Sources/NotProtonApp/SystemStatus.swift b/app/Sources/NotProtonApp/SystemStatus.swiftindex 779f607..85ddfb7 100644--- a/app/Sources/NotProtonApp/SystemStatus.swift+++ b/app/Sources/NotProtonApp/SystemStatus.swift@@ -510,7 +510,7 @@ final class SystemStatus {var info = stat()guard lstat(folder.path(percentEncoded: false), &info) == 0,info.st_mode & S_IFMT == S_IFDIR else { return }- for flavor in [CompatTool.Flavor.rosetta, .fex] {+ for flavor in CompatTool.Flavor.allCases {let template = SupportPaths.prefixTemplate(forBuild: build, flavor: flavor, in: library)totals[flavor, default: 0] += PrefixStore.directoryBytes(template, metric: .allocated)}diff --git a/app/Sources/NotProtonApp/Views/PrefixesView.swift b/app/Sources/NotProtonApp/Views/PrefixesView.swiftindex b3a432a..2a1aff3 100644--- a/app/Sources/NotProtonApp/Views/PrefixesView.swift+++ b/app/Sources/NotProtonApp/Views/PrefixesView.swift@@ -6,6 +6,7 @@ struct PrefixesView: View {@Environment(PrefixesModel.self) private var model@Environment(\.colorSchemeContrast) private var contrast+ @State private var sortOrder = [KeyPathComparator(\PrefixRow.lastUsed, order: .reverse)]var body: some View {Group {@@ -199,10 +200,38 @@ struct PrefixesView: View {return widest + TextWidth.cellPadding}+ private struct PrefixRow: Identifiable {+ let prefix: WinePrefix+ let tool: String+ let appID: Int+ let size: Int64+ let title: String+ let library: String+ let lastUsed: Date++ var id: WinePrefix.ID { prefix.id }+ }++ private var rows: [PrefixRow] {+ model.prefixes.map { prefix in+ PrefixRow(+ prefix: prefix,+ tool: model.lastTool(prefix) ?? "",+ appID: Int(prefix.appID) ?? 0,+ size: model.usage[prefix.id]?.bytes ?? -1,+ title: prefix.title,+ library: prefix.library.displayName,+ lastUsed: prefix.lastUsed ?? .distantPast+ )+ }+ .sorted(using: sortOrder)+ }+private var table: some View {@Bindable var model = model- return Table(model.prefixes, selection: $model.selection) {- TableColumn("Game") { prefix in+ return Table(rows, selection: $model.selection, sortOrder: $sortOrder) {+ TableColumn("Game", value: \.title) { row in+ let prefix = row.prefixHStack(spacing: 6) {if model.isStale(prefix) {Menu {@@ -234,7 +263,8 @@ struct PrefixesView: View {}.width(min: 60, ideal: gameWidth)- TableColumn("Tool") { prefix in+ TableColumn("Tool", value: \.tool) { row in+ let prefix = row.prefixif let tool = model.lastTool(prefix) {Text(tool).foregroundStyle(.secondary).help(tool)} else {@@ -244,20 +274,20 @@ struct PrefixesView: View {}.width(min: 60, ideal: toolWidth)- TableColumn("App ID") { prefix in- Text(prefix.appID).monospacedDigit().foregroundStyle(.secondary)+ TableColumn("App ID", value: \.appID) { row in+ Text(row.prefix.appID).monospacedDigit().foregroundStyle(.secondary)}.width(min: 50, ideal: 80)- TableColumn("Library") { prefix in- Text(prefix.library.displayName)+ TableColumn("Library", value: \.library) { row in+ Text(row.library).foregroundStyle(.secondary)- .help(prefix.library.displayName)+ .help(row.library)}.width(min: 44, ideal: libraryWidth)- TableColumn("Private Size") { prefix in- if let usage = model.usage[prefix.id] {+ TableColumn("Private Size", value: \.size) { row in+ if let usage = model.usage[row.id] {Text(usage.bytes.formatted(.byteCount(style: .file))).monospacedDigit().foregroundStyle(.secondary)@@ -269,14 +299,13 @@ struct PrefixesView: View {}.width(min: 56, ideal: 90)- TableColumn("Last used") { prefix in- Text(lastUsed(prefix))+ TableColumn("Last used", value: \.lastUsed) { row in+ Text(lastUsed(row.prefix)).foregroundStyle(.secondary)- .help(lastUsed(prefix))+ .help(lastUsed(row.prefix))}.width(min: 60, ideal: lastUsedWidth)-}.contextMenu(forSelectionType: WinePrefix.ID.self) { ids inactions(for: ids)@@ -319,7 +348,7 @@ struct PrefixesView: View {@ViewBuilderprivate func rebuildChoices(_ targets: [WinePrefix], label: String? = nil) -> some View {ForEach(model.tools) { tool in- Button(label ?? tool.display) {+ Button(label ?? tool.shortDisplay) {model.pendingConfirmation = .rebuild(targets, tool)}}diff --git a/app/Sources/NotProtonApp/Views/StatusView.swift b/app/Sources/NotProtonApp/Views/StatusView.swiftindex 364df09..5d3888b 100644--- a/app/Sources/NotProtonApp/Views/StatusView.swift+++ b/app/Sources/NotProtonApp/Views/StatusView.swift@@ -343,8 +343,6 @@ struct StatusView: View {dangerSection}.formStyle(.grouped)- .frame(maxWidth: 680)- .frame(maxWidth: .infinity)}private var dangerSection: some View {@@ -577,7 +575,7 @@ struct StatusView: View {var lines: [String] = []if row.copy == .ready || row.copy == .unpatched {let names = tools.filter { $0.build == row.buildID }.map(\.display)- if !names.isEmpty { lines.append(names.joined(separator: ", ")) }+ lines.append(contentsOf: names)}if row.copy == .none, row.licensed == false { lines.append("Open CrossOver to activate it.") }if let install = row.install {@@ -657,8 +655,7 @@ struct StatusView: View {if flavors.count > 1 {lines = flavors.compactMap { flavor inguard let bytes = templates[flavor], bytes > 0 else { return nil }- let name = flavor == .fex ? "FEX" : "Rosetta"- return "\(name) templates \(bytes.formatted(.byteCount(style: .file)))"+ return "\(flavor.name) templates \(bytes.formatted(.byteCount(style: .file)))"}} else {let bytes = templates.values.reduce(0, +)diff --git a/app/Tests/NotProtonAppTests/PrefixesModelTests.swift b/app/Tests/NotProtonAppTests/PrefixesModelTests.swiftindex e0403ad..defb517 100644--- a/app/Tests/NotProtonAppTests/PrefixesModelTests.swift+++ b/app/Tests/NotProtonAppTests/PrefixesModelTests.swift@@ -128,6 +128,38 @@ struct PrefixesModelTests {#expect(model.lastTool(try prefix("447700")) == nil)}+ @Test("The Prefixes table shows the short name of the tool that runs each prefix")+ func showsShortToolName() async throws {+ let (dir, library) = try makeLibrary(appIDs: ["1574480", "253750"])+ defer { try? FileManager.default.removeItem(at: dir) }++ let build = try #require(SupportedRunners.all.first { $0.tools.count == 2 })+ let tools = build.tools.map { InstalledTool(tool: $0, build: build.id) }+ let named = [+ ("1574480", "CrossOver Preview - ARM64 Build (FEX)", UInt16(0xAA64)),+ ("253750", "CrossOver Preview - ARM64 Build (Rosetta)", UInt16(0x8664)),+ ]+ for (appID, old, machine) in named {+ let root = library.compatdata.appending(path: appID)+ try write("\(build.id)\n\(old)\n", to: root.appending(path: PrefixTools.buildRecordName))+ var bytes = [UInt8](repeating: 0, count: 0x40)+ bytes[0x3c] = 0x40+ bytes += [0x50, 0x45, 0x00, 0x00, UInt8(machine & 0xff), UInt8(machine >> 8)]+ try FileManager.default.createDirectory(+ at: root.appending(path: "pfx/drive_c/windows/system32"), withIntermediateDirectories: true)+ try Data(bytes).write(to: root.appending(path: "pfx/drive_c/windows/system32/ntdll.dll"))+ }++ let model = PrefixesModel(libraries: { [library] }, installedTools: { tools })+ await model.load()++ func shown(_ appID: String) throws -> String? {+ model.lastTool(try #require(model.prefixes.first { $0.appID == appID }))+ }+ #expect(try shown("1574480") == "ARM64 Preview (FEX)")+ #expect(try shown("253750") == "ARM64 Preview (Rosetta)")+ }+@Test("A load lists the prefixes and measures each one")func loadsAndMeasures() async throws {let (dir, library) = try makeLibrary(appIDs: ["1574480", "1649240"])