Skip to content

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

Games can be hidden from the library, and the games Steam for Mac installed can be left out of it (highball#445)

Gauthier Piarrette7e9e7442d9aa
diff --git a/Sources/HighballApp/AppState.swift b/Sources/HighballApp/AppState.swift
index 07dd3f0..232d468 100644
--- a/Sources/HighballApp/AppState.swift
+++ b/Sources/HighballApp/AppState.swift
@@ -278,7 +278,7 @@ final class AppState {
func rebuildLibrary() {
customNames = nameStore.names()
libraryItems = LibraryIndex.build(bottles: bottles, steamByBottle: gamesByBottle,
- steamOwnedByBottle: steamOwnedByBottle, macInstalled: macSteamGames,
+ steamOwnedByBottle: steamOwnedByBottle, macInstalled: includeMacSteam ? macSteamGames : [],
epicOwned: epicOwned, epicInstalls: epicInstalls,
plays: libraryPlays, defaultBottle: defaultBottle?.name,
pinExists: { bottle, pin in
@@ -290,6 +290,30 @@ final class AppState {
refreshMacFlags()
}
+ // MARK: Games kept out of the library (highball#445)
+
+ /// Library ids the player hid (LibraryStore). The library leaves them out unless its Hidden
+ /// filter is on; nothing else about the game changes.
+ var hiddenItems: Set<String> = []
+ func isHidden(_ item: LibraryItem) -> Bool { LibraryStore.isHidden(item.id, in: hiddenItems) }
+ func setHidden(_ hidden: Bool, for item: LibraryItem) {
+ guard hidden != isHidden(item) else { return }
+ libraryStore.setHidden(hidden, for: item.id)
+ hiddenItems = libraryStore.hiddenIDs()
+ appendLog("\(item.id): \(hidden ? "hidden from the library" : "back in the library")")
+ }
+
+ /// Whether the games Steam for Mac installed are listed. Off, Highball leaves Steam for Mac out:
+ /// its installs get no tile and count as not installed, so Play uses the Windows version.
+ var includeMacSteam = true
+ func setIncludeMacSteam(_ on: Bool) {
+ guard on != includeMacSteam else { return }
+ libraryStore.setIncludesMacSteam(on)
+ includeMacSteam = on
+ rebuildLibrary()
+ appendLog(on ? "games from Steam for Mac are listed in the library" : "games from Steam for Mac are left out of the library")
+ }
+
// MARK: Names people give their games
/// Custom names by item id (NameStore). A renamed game sorts, searches and shows under its
@@ -1054,6 +1078,8 @@ final class AppState {
libraryOverrides = libraryStore.rendererOverrides()
libraryLaunchArgs = libraryStore.launchArguments()
libraryDisplays = libraryStore.displayChoices()
+ hiddenItems = libraryStore.hiddenIDs()
+ includeMacSteam = libraryStore.includesMacSteam
rebuildLibrary()
steamOwnedRefresh()
epicRefresh()
diff --git a/Sources/HighballApp/GameDetailView.swift b/Sources/HighballApp/GameDetailView.swift
index dc3f7af..4d69e55 100644
--- a/Sources/HighballApp/GameDetailView.swift
+++ b/Sources/HighballApp/GameDetailView.swift
@@ -142,6 +142,18 @@ struct GameDetailView: View {
if let played = item.lastPlayed {
row(L("Last played"), played.formatted(date: .abbreviated, time: .shortened))
}
+ // Hiding keeps the game and its settings, it only leaves the library's grid and the
+ // installed row (highball#445).
+ HStack(alignment: .firstTextBaseline, spacing: 12) {
+ Text(L("Library")).font(.caption).foregroundStyle(.secondary).frame(width: 110, alignment: .leading)
+ if state.isHidden(item) {
+ Text(L("Hidden")).font(.callout)
+ Button(L("Show in library")) { state.setHidden(false, for: item) }.controlSize(.small)
+ } else {
+ Button(L("Hide from library")) { state.setHidden(true, for: item) }.controlSize(.small)
+ .help(L("Takes the game out of the library without touching it. The Hidden filter lists it again."))
+ }
+ }
}
.padding(18).frame(maxWidth: .infinity, alignment: .leading)
.background(HB.card, in: RoundedRectangle(cornerRadius: 12))
diff --git a/Sources/HighballApp/L10n.swift b/Sources/HighballApp/L10n.swift
index 41029b8..eb9bfd0 100644
--- a/Sources/HighballApp/L10n.swift
+++ b/Sources/HighballApp/L10n.swift
@@ -645,5 +645,12 @@ enum L10n {
"Programs here start with %@ until this is resolved: %@": "Les programmes d'ici démarrent avec %@ tant que ce n'est pas résolu : %@",
"-dx11 -skiplauncher \"an argument with spaces\"": "-dx11 -skiplauncher \"un argument avec des espaces\"",
"authorizationCode": "authorizationCode",
+ "Hidden": "Masqué",
+ "Hide from library": "Masquer de la bibliothèque",
+ "Show in library": "Afficher dans la bibliothèque",
+ "Shows the games you hid. Show in library on a game's menu brings it back.": "Affiche les jeux que vous avez masqués. Afficher dans la bibliothèque, dans le menu d’un jeu, le fait revenir.",
+ "Takes the game out of the library without touching it. The Hidden filter lists it again.": "Retire le jeu de la bibliothèque sans y toucher. Le filtre Masqué le montre de nouveau.",
+ "Show games from Steam for Mac": "Afficher les jeux de Steam pour Mac",
+ "Games Steam for Mac installed are listed next to your Windows games, and Play opens their Mac version. Off, the library lists only what Highball's environments hold, and Play uses the Windows version.": "Les jeux installés par Steam pour Mac apparaissent à côté de vos jeux Windows, et Jouer ouvre leur version Mac. Désactivé, la bibliothèque ne montre que le contenu des environnements de Highball, et Jouer utilise la version Windows.",
]
}
diff --git a/Sources/HighballApp/LibraryView.swift b/Sources/HighballApp/LibraryView.swift
index 46bd2da..95037da 100644
--- a/Sources/HighballApp/LibraryView.swift
+++ b/Sources/HighballApp/LibraryView.swift
@@ -22,6 +22,9 @@ struct LibraryView: View {
/// that read as a bug (highball#257).
@AppStorage("library.installedOnly") private var installedOnly = false
@AppStorage("library.verifiedOnly") private var verifiedOnly = false
+ /// Shows the games the player hid, and only them, so one can be brought back (highball#445).
+ /// Not kept across starts: a library that opened on its hidden games alone would look emptied.
+ @State private var showingHidden = false
#if DEBUG
/// HB_DEBUG_GAME="<title>": the first library item whose title contains it opens a few seconds after
/// launch, so a script can capture game pages without a click (highball#279's page was checked this
@@ -29,8 +32,13 @@ struct LibraryView: View {
@State private var debugGame: LibraryItem?
#endif
+ /// The library without the games the player hid, or with the Hidden filter on, those alone.
+ private var shown: [LibraryItem] {
+ LibraryIndex.visible(state.libraryItems, hidden: state.hiddenItems, showingHidden: showingHidden)
+ }
+
private var filtered: [LibraryItem] {
- state.libraryItems.filter { item in
+ shown.filter { item in
if let sourceFilter, item.source != sourceFilter { return false }
if installedOnly && !item.installedAnywhere { return false }
if verifiedOnly {
@@ -46,8 +54,8 @@ struct LibraryView: View {
/// piece taken from PR #230). Only once the grid holds more than the row, with a handful of
/// games and nothing owned besides them the row would repeat every tile.
private var homeItems: [LibraryItem] {
- let installed = LibraryIndex.installedForHome(state.libraryItems)
- guard state.libraryItems.count > 6, state.libraryItems.count > installed.count else { return [] }
+ let installed = LibraryIndex.installedForHome(shown)
+ guard shown.count > 6, shown.count > installed.count else { return [] }
return installed
}
@@ -58,7 +66,7 @@ struct LibraryView: View {
// Installed games first, large, with Play on the cover. The verdict stays under
// every cover, the grid below keeps every game, and the row steps aside as soon as
// a search or a filter is on.
- if !homeItems.isEmpty && search.isEmpty && sourceFilter == nil && !installedOnly && !verifiedOnly {
+ if !homeItems.isEmpty && search.isEmpty && sourceFilter == nil && !installedOnly && !verifiedOnly && !showingHidden {
VStack(alignment: .leading, spacing: 12) {
HStack(alignment: .firstTextBaseline, spacing: 8) {
HB.eyebrow(L("Installed games"))
@@ -126,6 +134,11 @@ struct LibraryView: View {
Divider().frame(height: 16)
FilterChip(label: L("Installed"), on: installedOnly) { installedOnly.toggle() }
FilterChip(label: L("Verified"), on: verifiedOnly) { verifiedOnly.toggle() }
+ // Only once a game in the library is hidden: the chip is the way back to it.
+ if showingHidden || state.libraryItems.contains(where: state.isHidden) {
+ FilterChip(label: L("Hidden"), on: showingHidden) { showingHidden.toggle() }
+ .help(L("Shows the games you hid. Show in library on a game's menu brings it back."))
+ }
Spacer()
}
}
@@ -386,6 +399,13 @@ struct LibraryTile: View {
if NameStore.name(for: item.id, in: state.customNames) != nil {
Button(L("Reset name")) { state.resetName(for: item) }
}
+ // Out of the library without touching the game (highball#445); the Hidden filter
+ // lists it again.
+ if state.isHidden(item) {
+ Button(L("Show in library")) { state.setHidden(false, for: item) }
+ } else {
+ Button(L("Hide from library")) { state.setHidden(true, for: item) }
+ }
// A program someone added by hand leaves the library from its tile, not only from
// the environment's programs list (highball-db#68). Steam and Epic entries follow
// their stores' libraries, so they have no such button.
diff --git a/Sources/HighballApp/SettingsView.swift b/Sources/HighballApp/SettingsView.swift
index 81c6edf..fb354de 100644
--- a/Sources/HighballApp/SettingsView.swift
+++ b/Sources/HighballApp/SettingsView.swift
@@ -281,6 +281,17 @@ struct EnginePane: View {
.font(.caption).foregroundStyle(.secondary)
}.frame(maxWidth: .infinity, alignment: .leading)
}
+ // Only where it means something: a Mac with Steam for Mac, or one where it was turned off.
+ if state.steamForMacInstalled || !state.includeMacSteam {
+ GroupBox {
+ VStack(alignment: .leading, spacing: 6) {
+ Toggle(L("Show games from Steam for Mac"), isOn: Binding(get: { state.includeMacSteam },
+ set: { state.setIncludeMacSteam($0) }))
+ Text(L("Games Steam for Mac installed are listed next to your Windows games, and Play opens their Mac version. Off, the library lists only what Highball's environments hold, and Play uses the Windows version."))
+ .font(.caption).foregroundStyle(.secondary).fixedSize(horizontal: false, vertical: true)
+ }.frame(maxWidth: .infinity, alignment: .leading)
+ }
+ }
if let update = state.engineUpdate {
GroupBox {
HStack {
diff --git a/Sources/HighballKit/Library.swift b/Sources/HighballKit/Library.swift
index 772f99c..ce6327d 100644
--- a/Sources/HighballKit/Library.swift
+++ b/Sources/HighballKit/Library.swift
@@ -79,6 +79,13 @@ public enum LibraryIndex {
}
}
+ /// What the library shows (highball#445): a hidden game stays out of the grid and the Home row,
+ /// and the Hidden filter shows the hidden ones alone, so each can be brought back.
+ public static func visible(_ items: [LibraryItem], hidden: Set<String>, showingHidden: Bool) -> [LibraryItem] {
+ guard !hidden.isEmpty || showingHidden else { return items }
+ return items.filter { LibraryStore.isHidden($0.id, in: hidden) == showingHidden }
+ }
+
/// Launcher pins are infrastructure, not games — they never appear in the library, and
/// launching one is not "playing" for the Continue shelf. Single source of truth for the
/// filter BottleView's Programs section shares.
@@ -264,6 +271,12 @@ public struct LibraryStore: Sendable {
/// The display one game's window is moved to after it opens, by library id (display UUID
/// string). Optional so older files still decode.
var displays: [String: String]?
+ /// Games the player hid from the library, by library id (highball#445: native Mac games,
+ /// demos and finished ones crowded the Windows games). Optional so older files still decode.
+ var hidden: [String]?
+ /// True when Steam for Mac's own installs stay out of the library (highball#445). Absent
+ /// means they are in, as before.
+ var macSteamExcluded: Bool?
}
public let paths: HighballPaths
@@ -314,6 +327,47 @@ public struct LibraryStore: Sendable {
if let data = try? JSONEncoder.highball.encode(shape) { try? data.write(to: fileURL, options: .atomic) }
}
+ public func hiddenIDs() -> Set<String> { Set(loadShape().hidden ?? []) }
+
+ /// Hides one game from the library, or shows it again. A program's id carries its environment's
+ /// name, so showing it again also drops a mark kept under an earlier name of that environment
+ /// (PinID), or the game would stay hidden after a rename.
+ public func setHidden(_ hidden: Bool, for id: String) {
+ var shape = loadShape()
+ var all = Set(shape.hidden ?? [])
+ if hidden {
+ all.insert(id)
+ } else {
+ all.remove(id)
+ if let uuid = PinID.uuid(in: id) { all = all.filter { !($0.hasPrefix("pin:") && $0.hasSuffix(":" + uuid)) } }
+ }
+ shape.hidden = all.isEmpty ? nil : all.sorted()
+ save(shape)
+ }
+
+ /// Whether an id is hidden in a loaded set: the id itself, or for a program the mark kept under
+ /// an earlier name of its environment (PinID).
+ public static func isHidden(_ id: String, in hidden: Set<String>) -> Bool {
+ if hidden.contains(id) { return true }
+ guard let uuid = PinID.uuid(in: id) else { return false }
+ return hidden.contains { $0.hasPrefix("pin:") && $0.hasSuffix(":" + uuid) }
+ }
+
+ /// Whether the games Steam for Mac installed are part of the library. On unless the player
+ /// turned it off (highball#445).
+ public var includesMacSteam: Bool { loadShape().macSteamExcluded != true }
+
+ public func setIncludesMacSteam(_ on: Bool) {
+ var shape = loadShape()
+ shape.macSteamExcluded = on ? nil : true
+ save(shape)
+ }
+
+ private func save(_ shape: FileShape) {
+ try? paths.ensure()
+ if let data = try? JSONEncoder.highball.encode(shape) { try? data.write(to: fileURL, options: .atomic) }
+ }
+
private func loadShape() -> FileShape {
guard let data = try? Data(contentsOf: fileURL),
let shape = try? JSONDecoder.highball.decode(FileShape.self, from: data) else { return FileShape() }
@@ -336,14 +390,17 @@ public struct LibraryStore: Sendable {
let keptOverrides = (whole.overrides ?? [:]).filter { validIDs.contains($0.key) }
let keptArgs = (whole.launchArgs ?? [:]).filter { validIDs.contains($0.key) }
let keptDisplays = (whole.displays ?? [:]).filter { validIDs.contains($0.key) }
+ let keptHidden = (whole.hidden ?? []).filter { validIDs.contains($0) }
guard keptItems.count != whole.items.count
|| keptOverrides.count != (whole.overrides ?? [:]).count
|| keptArgs.count != (whole.launchArgs ?? [:]).count
- || keptDisplays.count != (whole.displays ?? [:]).count else { return }
+ || keptDisplays.count != (whole.displays ?? [:]).count
+ || keptHidden.count != (whole.hidden ?? []).count else { return }
whole.items = keptItems
whole.overrides = keptOverrides.isEmpty ? nil : keptOverrides
whole.launchArgs = keptArgs.isEmpty ? nil : keptArgs
whole.displays = keptDisplays.isEmpty ? nil : keptDisplays
+ whole.hidden = keptHidden.isEmpty ? nil : keptHidden
if let data = try? JSONEncoder.highball.encode(whole) {
try? data.write(to: fileURL, options: .atomic)
}
diff --git a/Tests/HighballKitTests/LibraryHiddenTests.swift b/Tests/HighballKitTests/LibraryHiddenTests.swift
new file mode 100644
index 0000000..63e7e75
--- /dev/null
+++ b/Tests/HighballKitTests/LibraryHiddenTests.swift
@@ -0,0 +1,107 @@
+import XCTest
+@testable import HighballKit
+
+/// Games kept out of the library (highball#445): hidden ids and the Steam for Mac switch live in
+/// library.json beside the other per-game choices, older files decode as before, and the library
+/// shows a hidden game again only under the Hidden filter.
+final class LibraryHiddenTests: XCTestCase {
+ private var home: URL!
+ private var store: LibraryStore!
+
+ override func setUpWithError() throws {
+ home = FileManager.default.temporaryDirectory.appending(path: "hb-hidden-\(UUID().uuidString)")
+ try FileManager.default.createDirectory(at: home, withIntermediateDirectories: true)
+ store = LibraryStore(paths: HighballPaths(home: home))
+ }
+
+ override func tearDownWithError() throws { try? FileManager.default.removeItem(at: home) }
+
+ private func item(_ id: String, _ title: String) -> HighballKit.LibraryItem {
+ HighballKit.LibraryItem(source: id.hasPrefix("pin:") ? .pin : .steam, id: id, title: title, bottleName: "Games", installed: true)
+ }
+
+ func testNothingIsHiddenAndMacSteamIsInWithoutAFile() {
+ XCTAssertEqual(store.hiddenIDs(), [])
+ XCTAssertTrue(store.includesMacSteam)
+ }
+
+ func testAFileFromBeforeTheFieldsDecodesWithItsHistory() throws {
+ let old = #"{"formatVersion":1,"items":{"steam:620":{"lastPlayedAt":"2026-10-01T10:00:00Z","bottle":"Games"}},"launchArgs":{"steam:620":["-novid"]}}"#
+ try Data(old.utf8).write(to: home.appending(path: "library.json"))
+ XCTAssertEqual(store.hiddenIDs(), [])
+ XCTAssertTrue(store.includesMacSteam)
+ XCTAssertEqual(store.load()["steam:620"]?.bottle, "Games")
+ // Writing the new fields keeps what was there.
+ store.setHidden(true, for: "steam:620")
+ store.setIncludesMacSteam(false)
+ XCTAssertEqual(store.load()["steam:620"]?.bottle, "Games")
+ XCTAssertEqual(store.launchArguments()["steam:620"], ["-novid"])
+ }
+
+ func testHidingAndShowingAGameIsKeptAcrossStores() {
+ store.setHidden(true, for: "steam:620")
+ store.setHidden(true, for: "epic:Duck")
+ XCTAssertEqual(LibraryStore(paths: HighballPaths(home: home)).hiddenIDs(), ["steam:620", "epic:Duck"])
+ store.setHidden(false, for: "steam:620")
+ XCTAssertEqual(store.hiddenIDs(), ["epic:Duck"])
+ store.setHidden(false, for: "epic:Duck")
+ XCTAssertEqual(store.hiddenIDs(), [])
+ let text = (try? String(contentsOf: home.appending(path: "library.json"), encoding: .utf8)) ?? ""
+ XCTAssertFalse(text.contains("hidden"), "an empty list leaves the file as an older app wrote it")
+ }
+
+ /// A program's id carries its environment's name: hidden before a rename, it stays hidden
+ /// after, and showing it again clears the mark kept under the old name.
+ func testAProgramStaysHiddenAcrossAnEnvironmentRename() {
+ let uuid = "B43215E4-3490-4E8A-835B-3668A02B279F"
+ store.setHidden(true, for: "pin:Games:\(uuid)")
+ XCTAssertTrue(LibraryStore.isHidden("pin:Play:\(uuid)", in: store.hiddenIDs()))
+ XCTAssertFalse(LibraryStore.isHidden("pin:Play:00000000-0000-0000-0000-000000000001", in: store.hiddenIDs()))
+ store.setHidden(false, for: "pin:Play:\(uuid)")
+ XCTAssertEqual(store.hiddenIDs(), [])
+ }
+
+ func testTheSteamForMacSwitchRoundTrips() {
+ store.setIncludesMacSteam(false)
+ XCTAssertFalse(LibraryStore(paths: HighballPaths(home: home)).includesMacSteam)
+ store.setIncludesMacSteam(true)
+ XCTAssertTrue(store.includesMacSteam)
+ let text = (try? String(contentsOf: home.appending(path: "library.json"), encoding: .utf8)) ?? ""
+ XCTAssertFalse(text.contains("macSteamExcluded"), "back on is the default, not a stored value")
+ }
+
+ func testPruneDropsHiddenMarksOfGamesThatAreGone() {
+ store.setHidden(true, for: "steam:620")
+ store.setHidden(true, for: "steam:730")
+ store.prune(validIDs: ["steam:730"])
+ XCTAssertEqual(store.hiddenIDs(), ["steam:730"])
+ }
+
+ func testTheLibraryLeavesHiddenGamesOutAndTheFilterShowsThemAlone() {
+ let items = [item("steam:620", "Portal 2"), item("steam:730", "Counter-Strike 2"), item("epic:Duck", "Cardpocalypse")]
+ XCTAssertEqual(LibraryIndex.visible(items, hidden: [], showingHidden: false).map(\.id), items.map(\.id))
+ XCTAssertEqual(LibraryIndex.visible(items, hidden: ["steam:730"], showingHidden: false).map(\.id), ["steam:620", "epic:Duck"])
+ XCTAssertEqual(LibraryIndex.visible(items, hidden: ["steam:730"], showingHidden: true).map(\.id), ["steam:730"])
+ XCTAssertEqual(LibraryIndex.visible(items, hidden: [], showingHidden: true).map(\.id), [], "the filter with nothing hidden lists nothing")
+ // The Home row reads the same list, so a hidden installed game leaves it too.
+ XCTAssertFalse(LibraryIndex.installedForHome(LibraryIndex.visible(items, hidden: ["steam:620"], showingHidden: false)).contains { $0.id == "steam:620" })
+ }
+
+ /// Leaving Steam for Mac out is the index built without its installs: a game only it holds has
+ /// no tile, and one an environment also holds is no longer installed on the Mac, so Play takes
+ /// the Windows copy.
+ func testLeavingSteamForMacOutDropsItsGames() {
+ let bottle = Bottle(url: URL(fileURLWithPath: "/tmp/hb-hidden-tests/bottles/Games"), settings: BottleSettings(name: "Games", engineID: "e"))
+ let shared = SteamGame(appid: 620, name: "Portal 2", installdir: "Portal 2", sizeOnDisk: 1, stateFlags: 4, lastPlayed: nil)
+ let macOnly = SteamGame(appid: 400, name: "Portal", installdir: "Portal", sizeOnDisk: 1, stateFlags: 4, lastPlayed: nil)
+ let with = LibraryIndex.build(bottles: [bottle], steamByBottle: ["Games": [shared]], macInstalled: [shared, macOnly],
+ epicOwned: [], epicInstalls: [:])
+ XCTAssertEqual(with.map(\.id).sorted(), ["steam:400", "steam:620"])
+ XCTAssertTrue(with.first { $0.id == "steam:620" }!.installedOnMac)
+ let without = LibraryIndex.build(bottles: [bottle], steamByBottle: ["Games": [shared]], macInstalled: [],
+ epicOwned: [], epicInstalls: [:])
+ XCTAssertEqual(without.map(\.id), ["steam:620"])
+ XCTAssertFalse(without[0].installedOnMac)
+ XCTAssertTrue(without[0].installed)
+ }
+}