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
Highlight CrossOver version in UI
NotProtonNot36e17928001b
diff --git a/app/Sources/NotProtonApp/Model/CrossOverRow.swift b/app/Sources/NotProtonApp/Model/CrossOverRow.swiftindex ac44c17..6928ed9 100644--- a/app/Sources/NotProtonApp/Model/CrossOverRow.swift+++ b/app/Sources/NotProtonApp/Model/CrossOverRow.swift@@ -82,4 +82,13 @@ struct CrossOverRow: Identifiable, Equatable {}return rows}++ // The row a picked copy already shows up under. Supported copies match by build, since+ // the app at a listed path can be swapped for another build.+ static func listing(_ install: CrossOverInstall, in rows: [CrossOverRow]) -> CrossOverRow? {+ if case .supported(let build) = install.support {+ return rows.first { $0.buildID == build.id && $0.install != nil }+ }+ return rows.first { $0.install.map { CrossOverSource.same($0.bundle, install.bundle) } ?? false }+ }}diff --git a/app/Sources/NotProtonApp/Model/CrossOverSource.swift b/app/Sources/NotProtonApp/Model/CrossOverSource.swiftindex fbf88f4..ea4b67c 100644--- a/app/Sources/NotProtonApp/Model/CrossOverSource.swift+++ b/app/Sources/NotProtonApp/Model/CrossOverSource.swift@@ -65,7 +65,7 @@ enum CrossOverSource {return searchRoots.contains { same($0, parent) }}- private static func same(_ a: URL, _ b: URL) -> Bool {+ static func same(_ a: URL, _ b: URL) -> Bool {a.standardizedFileURL.path(percentEncoded: false) == b.standardizedFileURL.path(percentEncoded: false)}diff --git a/app/Sources/NotProtonApp/SystemStatus.swift b/app/Sources/NotProtonApp/SystemStatus.swiftindex 31e8477..6ba75df 100644--- a/app/Sources/NotProtonApp/SystemStatus.swift+++ b/app/Sources/NotProtonApp/SystemStatus.swift@@ -60,6 +60,8 @@ final class SystemStatus {var isRefreshing = falsevar activity: String?var outcome: String?+ private(set) var highlightedRow: String?+ @ObservationIgnored private var highlightReset: Task<Void, Never>?private(set) var failure: String?private(set) var failureRemedy: Remedy?@@ -271,16 +273,28 @@ final class SystemStatus {return}- let found = snapshot?.crossOver.contains {- $0.bundle.standardizedFileURL == picked.standardizedFileURL- } ?? false- if !found {- CrossOverSource.addManualBundle(picked)- AppLog.note("crossOver added: \(picked.path(percentEncoded: false))")+ await refresh()+ if let row = CrossOverRow.listing(CrossOverSource.inspect(bundle: picked), in: crossOverRows) {+ AppLog.note("crossOver already listed: \(picked.path(percentEncoded: false))")+ highlight(row)+ return}+ CrossOverSource.addManualBundle(picked)+ AppLog.note("crossOver added: \(picked.path(percentEncoded: false))")await refresh()}+ private func highlight(_ row: CrossOverRow) {+ AccessibilityNotification.Announcement("\(row.title) is already listed.").post()+ highlightReset?.cancel()+ highlightedRow = row.id+ highlightReset = Task { [weak self] in+ try? await Task.sleep(for: .seconds(2))+ guard !Task.isCancelled else { return }+ self?.highlightedRow = nil+ }+ }+func removeFromList(_ install: CrossOverInstall) async {guard isIdle else { return }clearFailure()diff --git a/app/Sources/NotProtonApp/Views/StatusView.swift b/app/Sources/NotProtonApp/Views/StatusView.swiftindex b00d18f..9f64096 100644--- a/app/Sources/NotProtonApp/Views/StatusView.swift+++ b/app/Sources/NotProtonApp/Views/StatusView.swift@@ -284,6 +284,16 @@ struct StatusView: View {}private func statusForm(_ snapshot: StatusSnapshot) -> some View {+ ScrollViewReader { proxy in+ form(snapshot)+ .onChange(of: status.highlightedRow) { _, row in+ guard let row else { return }+ withAnimation { proxy.scrollTo(row, anchor: .center) }+ }+ }+ }++ private func form(_ snapshot: StatusSnapshot) -> some View {Form {if let failure = status.failure {StatusRow(@@ -540,6 +550,14 @@ struct StatusView: View {action: crossOverAction(row, prominent: snapshot.runner == .none),menu: crossOverMenu(row))+ .background {+ RoundedRectangle(cornerRadius: 6)+ .fill(Color.accentColor.opacity(0.2))+ .padding(-6)+ .opacity(status.highlightedRow == row.id ? 1 : 0)+ }+ .animation(.easeInOut(duration: 0.3), value: status.highlightedRow == row.id)+ .id(row.id)}if case .ready = snapshot.runner, !snapshot.payload.missing(origin: .patched).isEmpty {StatusRow(@@ -566,7 +584,7 @@ struct StatusView: View {case .none: return build + (row.licensed == false ? ", not set up or activated" : ", not set up")case .unpatched: return build + ", not patched"case .damaged: return build + ", copy damaged"- case .unsupported: return build + ", no longer supported"+ case .unsupported: return build + ", not supported"}}diff --git a/app/Tests/NotProtonAppTests/CrossOverRowTests.swift b/app/Tests/NotProtonAppTests/CrossOverRowTests.swiftindex 1535c59..721ac0a 100644--- a/app/Tests/NotProtonAppTests/CrossOverRowTests.swift+++ b/app/Tests/NotProtonAppTests/CrossOverRowTests.swift@@ -93,6 +93,29 @@ struct CrossOverRowTests {#expect(made.map(\.install?.id) == [first.id])}+ @Test("A picked copy is found under the row for its path or its build")+ func pickedCopyListing() {+ let first = install("CrossOver", Self.release)+ let second = install("CrossOver", Self.release, root: "/Volumes/Spare")+ let preview = install("CrossOver Preview", Self.preview, root: "/Volumes/Spare")++ let made = rows([first], installed: [Self.release, Self.preview])++ #expect(CrossOverRow.listing(first, in: made)?.id == first.id)+ #expect(CrossOverRow.listing(second, in: made)?.id == first.id)+ #expect(CrossOverRow.listing(preview, in: made) == nil)++ let swapped = install("CrossOver", Self.preview)+ #expect(CrossOverRow.listing(swapped, in: made) == nil)++ let old = CrossOverInstall(+ bundle: URL(filePath: "/Applications/CrossOver 24.app"), releaseVersion: "24.0.5",+ support: .unsupportedBuild("24.0.5")+ )+ #expect(CrossOverRow.listing(old, in: rows([old]))?.id == old.id)+ #expect(CrossOverRow.listing(old, in: made) == nil)+ }+@Test("An app NotProton doesn't support is listed with its version and nothing to set up")func unsupportedApp() {let old = CrossOverInstall(