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
feat(app): add Game Defaults, settings for every game in one place (#1439)
Raymond Chind0ddfe10f4d9
diff --git a/app/Sources/BridgeplayApp/App.swift b/app/Sources/BridgeplayApp/App.swiftindex cc60350..a18f7d9 100644--- a/app/Sources/BridgeplayApp/App.swift+++ b/app/Sources/BridgeplayApp/App.swift@@ -77,19 +77,21 @@ struct BridgeplayApp: App {.keyboardShortcut("3", modifiers: .command)Button("Guide") { pane = .guide }.keyboardShortcut("4", modifiers: .command)+ Button("Game Defaults") { pane = .gameDefaults }+ .keyboardShortcut("5", modifiers: .command)Divider()Button("Refresh") {Task {switch pane {- case .status, .guide: await status.refresh()+ case .status, .guide, .gameDefaults: await status.refresh()case .prefixes, .backups: await prefixes.load()}}}.keyboardShortcut("r", modifiers: .command)- .disabled(pane == .status || pane == .guide ? !status.isIdle : prefixes.isLoading)+ .disabled(pane == .status || pane == .guide || pane == .gameDefaults ? !status.isIdle : prefixes.isLoading)Divider()}diff --git a/app/Sources/BridgeplayApp/Model/BrandMigration.swift b/app/Sources/BridgeplayApp/Model/BrandMigration.swiftindex df3be94..1ffe3b5 100644--- a/app/Sources/BridgeplayApp/Model/BrandMigration.swift+++ b/app/Sources/BridgeplayApp/Model/BrandMigration.swift@@ -459,7 +459,7 @@ struct BrandMigration: Sendable {// MARK: Text helpers// A line holding only a quoted key, as in SteamDefaultTool.- private static func quotedKey(_ line: String) -> String? {+ static func quotedKey(_ line: String) -> String? {let trimmed = line.trimmingCharacters(in: .whitespaces)guard trimmed.count >= 2, trimmed.hasPrefix("\""), trimmed.hasSuffix("\""),!trimmed.dropFirst().dropLast().contains("\"")diff --git a/app/Sources/BridgeplayApp/Model/SteamInstaller.swift b/app/Sources/BridgeplayApp/Model/SteamInstaller.swiftindex ddf5704..6f455f5 100644--- a/app/Sources/BridgeplayApp/Model/SteamInstaller.swift+++ b/app/Sources/BridgeplayApp/Model/SteamInstaller.swift@@ -172,6 +172,12 @@ enum SteamInstaller {}pruneGamefixes(keeping: payload.gamefixes.map(\.lastPathComponent),in: deployedVersion.deletingLastPathComponent().appending(path: "gamefixes-default"))+ // The shipped defaults now sit in gamefixes-default/, so the user's file keeps only their own.+ do {+ try GameDefaults.splitShipped(in: support)+ } catch {+ AppLog.note("game defaults: could not split the shipped defaults out: \(error.localizedDescription)")+ }try removeStaleFonts(in: fonts, keeping: payload.fonts)var backedUp = falsediff --git a/app/Sources/BridgeplayApp/Resources/Localization/Localizable.xcstrings b/app/Sources/BridgeplayApp/Resources/Localization/Localizable.xcstringsindex 600fe9b..d8070b5 100644--- a/app/Sources/BridgeplayApp/Resources/Localization/Localizable.xcstrings+++ b/app/Sources/BridgeplayApp/Resources/Localization/Localizable.xcstrings@@ -1004,18 +1004,34 @@}}},- "A game's own settings in Steam Properties › Bridgeplay win over these." : {+ "A game with launch options goes back to these defaults with Use Bridgeplay defaults in its Steam Properties › Bridgeplay." : {"localizations" : {"it" : {"stringUnit" : {"state" : "translated",- "value" : "Le impostazioni di un gioco in Proprietà di Steam › Bridgeplay hanno la precedenza su queste."+ "value" : "Un gioco con opzioni di avvio torna a queste impostazioni con Usa le impostazioni predefinite di Bridgeplay in Proprietà di Steam › Bridgeplay."}},"zh-Hans" : {"stringUnit" : {"state" : "translated",- "value" : "单个游戏在 Steam 属性 › Bridgeplay 中的设置优先于这里。"+ "value" : "设置了启动选项的游戏,可在其 Steam 属性 › Bridgeplay 中点按“使用 Bridgeplay 默认设置”恢复为这些默认值。"+ }+ }+ }+ },+ "A game's own settings in Steam Properties › Bridgeplay win over these. Game Defaults has the rest." : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Le impostazioni di un gioco in Proprietà di Steam › Bridgeplay hanno la precedenza su queste. Le altre sono in Impostazioni predefinite dei giochi."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "单个游戏在 Steam 属性 › Bridgeplay 中的设置优先于这里。其余设置位于“游戏默认设置”。"}}}@@ -1132,6 +1148,22 @@}}},+ "Adaptive" : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Adattiva"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "自适应"+ }+ }+ }+ },"Add" : {"localizations" : {"it" : {@@ -1292,6 +1324,22 @@}}},+ "Advanced" : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Avanzate"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "高级"+ }+ }+ }+ },"Advertise AVX2 to Rosetta" : {"localizations" : {"it" : {@@ -1596,6 +1644,22 @@}}},+ "Apply" : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Applica"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "应用"+ }+ }+ }+ },"Are you sure you want to back up these prefixes?" : {"localizations" : {"it" : {@@ -1692,6 +1756,38 @@}}},+ "Automatic follows the engine." : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Automatico segue il motore."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "“自动”跟随引擎设置。"+ }+ }+ }+ },+ "Automatic picks D3DMetal when the Game Porting Toolkit is linked, and DXMT otherwise." : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Automatico sceglie D3DMetal quando il Game Porting Toolkit è collegato, altrimenti DXMT."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "“自动”会在已链接 Game Porting Toolkit 时选择 D3DMetal,否则选择 DXMT。"+ }+ }+ }+ },"Automatic reports are sent only when the log makes the result clear. You can turn them off in the Prefix menu." : {"localizations" : {"it" : {@@ -2207,6 +2303,22 @@}}},+ "Bridgeplay doesn't know this value." : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Bridgeplay non riconosce questo valore."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Bridgeplay 无法识别此值。"+ }+ }+ }+ },"Bridgeplay doesn't run on Intel Macs." : {"localizations" : {"it" : {@@ -2271,6 +2383,54 @@}}},+ "Bridgeplay ignores a value over 1024 characters." : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Bridgeplay ignora un valore più lungo di 1024 caratteri."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Bridgeplay 会忽略超过 1024 个字符的值。"+ }+ }+ }+ },+ "Bridgeplay ignores a value with a backtick, $( or a quote." : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Bridgeplay ignora un valore con un backtick, $( o un apice."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Bridgeplay 会忽略含有反引号、$( 或引号的值。"+ }+ }+ }+ },+ "Bridgeplay ignores a value with a control character." : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Bridgeplay ignora un valore con un carattere di controllo."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Bridgeplay 会忽略含有控制字符的值。"+ }+ }+ }+ },"Bridgeplay is installed in %@. Use Repair Steam to remove it before choosing another copy of Steam." : {"localizations" : {"it" : {@@ -2383,6 +2543,22 @@}}},+ "Bridgeplay removes these settings from the game's conf and keeps a copy in its backups folder." : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Bridgeplay rimuove queste impostazioni dal conf del gioco e ne conserva una copia nella sua cartella dei backup."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Bridgeplay 会从该游戏的 conf 中移除这些设置,并在其备份文件夹中保留一份副本。"+ }+ }+ }+ },"Bridgeplay runs Windows games from your Steam library. First, a few quick checks." : {"localizations" : {"it" : {@@ -2463,6 +2639,22 @@}}},+ "Bridgeplay's default." : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Predefinito di Bridgeplay."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Bridgeplay 默认值。"+ }+ }+ }+ },"Build %@" : {"localizations" : {"it" : {@@ -2607,6 +2799,22 @@}}},+ "Changes apply the next time a game starts. A game's own settings in Steam Properties › Bridgeplay win over these." : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Le modifiche valgono dal prossimo avvio di un gioco. Le impostazioni di un gioco in Proprietà di Steam › Bridgeplay hanno la precedenza su queste."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "更改将在游戏下次启动时生效。单个游戏在 Steam 属性 › Bridgeplay 中的设置优先于这里。"+ }+ }+ }+ },"Check for Updates…" : {"localizations" : {"it" : {@@ -3474,6 +3682,54 @@}}},+ "DLL Overrides" : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Override delle DLL"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "DLL 覆盖"+ }+ }+ }+ },+ "DLSS through MetalFX" : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "DLSS tramite MetalFX"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "通过 MetalFX 提供 DLSS"+ }+ }+ }+ },+ "Default Compatibility Tool" : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Strumento di compatibilità predefinito"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "默认兼容性工具"+ }+ }+ }+ },"Delete" : {"localizations" : {"it" : {@@ -3858,6 +4114,22 @@}}},+ "Display" : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Schermo"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "显示"+ }+ }+ }+ },"Do not run. Their anti-cheat needs a Windows driver." : {"localizations" : {"it" : {@@ -4194,6 +4466,22 @@}}},+ "Every game uses these defaults." : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Tutti i giochi usano queste impostazioni predefinite."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "所有游戏都使用这些默认设置。"+ }+ }+ }+ },"Every setting on the Bridgeplay tab" : {"localizations" : {"it" : {@@ -4210,6 +4498,38 @@}}},+ "Every setting on this page goes back to Bridgeplay's default." : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Ogni impostazione di questa pagina torna a quella predefinita di Bridgeplay."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "此页面上的每项设置都会恢复为 Bridgeplay 的默认值。"+ }+ }+ }+ },+ "Experimental. Adds input lag." : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Sperimentale. Aumenta la latenza dei comandi."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "实验性功能,会增加输入延迟。"+ }+ }+ }+ },"Extracting" : {"localizations" : {"it" : {@@ -4242,6 +4562,22 @@}}},+ "Fast-Motion Fallback" : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Ripiego nei movimenti rapidi"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "快速运动回退"+ }+ }+ }+ },"Fast-motion fallback (skips frames that would smear)" : {"localizations" : {"it" : {@@ -4402,6 +4738,22 @@}}},+ "Force VSync" : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Forza VSync"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "强制垂直同步"+ }+ }+ }+ },"Found. Set it up in Status to play on it." : {"localizations" : {"it" : {@@ -4418,6 +4770,22 @@}}},+ "Frame Generation" : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Generazione di fotogrammi"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "帧生成"+ }+ }+ }+ },"Frame Generation (Experimental. Adds input lag)" : {"localizations" : {"it" : {@@ -4482,6 +4850,22 @@}}},+ "Game Defaults" : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Impostazioni predefinite dei giochi"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "游戏默认设置"+ }+ }+ }+ },"Game Porting Toolkit" : {"localizations" : {"it" : {@@ -4546,6 +4930,22 @@}}},+ "Games with Their Own Settings" : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Giochi con impostazioni proprie"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "有单独设置的游戏"+ }+ }+ }+ },"Games with kernel anti-cheat" : {"localizations" : {"it" : {@@ -4626,6 +5026,22 @@}}},+ "Graphics Backend" : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Backend grafico"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "图形后端"+ }+ }+ }+ },"Graphics glitches" : {"localizations" : {"it" : {@@ -4802,6 +5218,22 @@}}},+ "Ignored: %@" : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Ignorato: %@"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "已忽略:%@"+ }+ }+ }+ },"In your Mac's Steam." : {"localizations" : {"it" : {@@ -5218,6 +5650,22 @@}}},+ "Keeps static HUD and menus sharp." : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Mantiene nitidi HUD statici e menu."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "保持静态 HUD 和菜单清晰。"+ }+ }+ }+ },"Keeps your controller working after Bridgeplay updates. Adds a certificate for this Mac to your login keychain. If macOS then asks for your password, choose Always Allow." : {"localizations" : {"it" : {@@ -5298,6 +5746,22 @@}}},+ "Launch options, account %@" : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Opzioni di avvio, account %@"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "启动选项,账户 %@"+ }+ }+ }+ },"Launcher, sign-in or anti-cheat" : {"localizations" : {"it" : {@@ -5330,6 +5794,22 @@}}},+ "Lets games offer DLSS, served by MetalFX. Some games take NVIDIA-only paths with it." : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Permette ai giochi di offrire DLSS, gestito da MetalFX. Con questa opzione alcuni giochi seguono percorsi solo NVIDIA."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "让游戏提供由 MetalFX 实现的 DLSS。开启后,部分游戏会走仅限 NVIDIA 的路径。"+ }+ }+ }+ },"Lets the game offer NVIDIA DLSS. Apple's MetalFX does the upscaling, and DLSS Frame Generation is experimental and off by default. Turn DLSS on in the game's own settings as well." : {"localizations" : {"it" : {@@ -5586,6 +6066,22 @@}}},+ "Many games quit without it." : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Molti giochi si chiudono senza."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "没有它,许多游戏会直接退出。"+ }+ }+ }+ },"Metal HUD" : {"localizations" : {"it" : {@@ -5778,6 +6274,22 @@}}},+ "Needs the Game Porting Toolkit. Without it, games use DXMT." : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Richiede il Game Porting Toolkit. Senza, i giochi usano DXMT."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "需要 Game Porting Toolkit。没有它时,游戏使用 DXMT。"+ }+ }+ }+ },"Never" : {"localizations" : {"it" : {@@ -5970,6 +6482,22 @@}}},+ "Not set" : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Non impostato"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "未设置"+ }+ }+ }+ },"Not set up yet" : {"localizations" : {"it" : {@@ -6034,34 +6562,50 @@}}},- "OK" : {+ "OK" : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "OK"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "好"+ }+ }+ }+ },+ "Off" : {"localizations" : {"it" : {"stringUnit" : {"state" : "translated",- "value" : "OK"+ "value" : "Disattivato"}},"zh-Hans" : {"stringUnit" : {"state" : "translated",- "value" : "好"+ "value" : "关闭"}}}},- "Off" : {+ "On" : {"localizations" : {"it" : {"stringUnit" : {"state" : "translated",- "value" : "Disattivato"+ "value" : "Attivato"}},"zh-Hans" : {"stringUnit" : {"state" : "translated",- "value" : "关闭"+ "value" : "开启"}}}@@ -6114,6 +6658,22 @@}}},+ "Only takes effect when DLSS is switched on in the game." : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Ha effetto solo quando DLSS è attivo nel gioco."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "仅在游戏中开启 DLSS 时生效。"+ }+ }+ }+ },"Open %@" : {"localizations" : {"it" : {@@ -6258,6 +6818,22 @@}}},+ "Open in Steam" : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Apri in Steam"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "在 Steam 中打开"+ }+ }+ }+ },"Opened %@ in %@." : {"localizations" : {"it" : {@@ -6290,6 +6866,22 @@}}},+ "Other lines in gamefixes/default.conf are kept as they are." : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Le altre righe di gamefixes/default.conf restano come sono."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "gamefixes/default.conf 中的其他行保持不变。"+ }+ }+ }+ },"Overlay shim" : {"localizations" : {"it" : {@@ -6322,6 +6914,22 @@}}},+ "Own conf" : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Conf proprio"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "自有 conf"+ }+ }+ }+ },"Patch ntdll" : {"localizations" : {"it" : {@@ -6418,6 +7026,22 @@}}},+ "Performance" : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Prestazioni"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "性能"+ }+ }+ }+ },"Please run CrossOver and try again." : {"localizations" : {"it" : {@@ -6546,6 +7170,22 @@}}},+ "Protect UI" : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Proteggi l'interfaccia"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "保护界面"+ }+ }+ }+ },"Protect UI (keeps static HUD and menus sharp)" : {"localizations" : {"it" : {@@ -7442,6 +8082,22 @@}}},+ "Report an NVIDIA GPU" : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Segnala una GPU NVIDIA"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "报告为 NVIDIA GPU"+ }+ }+ }+ },"Report on GitHub" : {"localizations" : {"it" : {@@ -7490,6 +8146,22 @@}}},+ "Reset All" : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Ripristina tutto"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "全部重置"+ }+ }+ }+ },"Reset controller permission" : {"localizations" : {"it" : {@@ -7506,6 +8178,38 @@}}},+ "Reset every game default?" : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Ripristinare tutte le impostazioni predefinite dei giochi?"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "要重置所有游戏默认设置吗?"+ }+ }+ }+ },+ "Reset to Bridgeplay's Default" : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Ripristina il predefinito di Bridgeplay"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "恢复为 Bridgeplay 默认值"+ }+ }+ }+ },"Resetting Steam's controller permission" : {"localizations" : {"it" : {@@ -7906,6 +8610,22 @@}}},+ "Set by you." : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Impostato da te."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "由你设置。"+ }+ }+ }+ },"Set up Bridgeplay" : {"localizations" : {"it" : {@@ -8338,6 +9058,22 @@}}},+ "Skips generated frames that would smear." : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Salta i fotogrammi generati che risulterebbero sbavati."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "跳过会产生拖影的生成帧。"+ }+ }+ }+ },"Smooth" : {"localizations" : {"it" : {@@ -8901,6 +9637,22 @@}}},+ "Steam runs every game without a tool of its own with this one. Change it in the Setup Assistant while Steam is closed." : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Steam usa questo strumento per ogni gioco che non ne ha uno proprio. Cambialo nell'Assistente di configurazione mentre Steam è chiuso."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Steam 会用此工具运行所有未单独指定工具的游戏。请在 Steam 关闭时于设置助理中更改。"+ }+ }+ }+ },"Steam updated" : {"localizations" : {"it" : {@@ -10261,6 +11013,38 @@}}},+ "Use Defaults" : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Usa predefinite"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "使用默认设置"+ }+ }+ }+ },+ "Use Defaults…" : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Usa predefinite…"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "使用默认设置…"+ }+ }+ }+ },"Use This" : {"localizations" : {"it" : {@@ -10277,6 +11061,22 @@}}},+ "Use Wine's syntax, for example dinput8=n,b;xinput1_3=n." : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Usa la sintassi di Wine, per esempio dinput8=n,b;xinput1_3=n."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "请使用 Wine 的语法,例如 dinput8=n,b;xinput1_3=n。"+ }+ }+ }+ },"Use a copy of Steam from another folder or drive." : {"localizations" : {"it" : {@@ -10293,6 +11093,22 @@}}},+ "Use the defaults for this game?" : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Usare le impostazioni predefinite per questo gioco?"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "要让此游戏使用默认设置吗?"+ }+ }+ }+ },"Use the newer Bridgeplay app to update or repair the installed files." : {"localizations" : {"it" : {@@ -10421,6 +11237,22 @@}}},+ "Waits for the display even when a game turns VSync off." : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Attende lo schermo anche quando un gioco disattiva VSync."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "即使游戏关闭了垂直同步,也会等待显示器刷新。"+ }+ }+ }+ },"What went wrong? Optional, and public with the report." : {"localizations" : {"it" : {@@ -10533,6 +11365,22 @@}}},+ "Wine syntax. A game's own conf replaces these; its launch options win per DLL." : {+ "localizations" : {+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Sintassi di Wine. Il conf di un gioco li sostituisce; le sue opzioni di avvio prevalgono DLL per DLL."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Wine 语法。单个游戏自己的 conf 会替换这些设置;其启动选项按 DLL 逐个优先。"+ }+ }+ }+ },"WineCX Engine" : {"localizations" : {"it" : {diff --git a/app/Sources/BridgeplayApp/SetupAssistant.swift b/app/Sources/BridgeplayApp/SetupAssistant.swiftindex f5a37d3..ba991e3 100644--- a/app/Sources/BridgeplayApp/SetupAssistant.swift+++ b/app/Sources/BridgeplayApp/SetupAssistant.swift@@ -63,7 +63,7 @@ final class SetupAssistant {var needsAppManagement = false@ObservationIgnored private var permissionWatch: Task<Void, Never>?- // Done: settings for every game, read from and written to gamefixes/default.conf.+ // Done: two of the settings for every game (GameDefaults); the rest are on the Game Defaults page.var metalHUD = GameDefaults.isOn(.metalHUD)var highResolution = GameDefaults.isOn(.highResolution)@@ -110,6 +110,7 @@ final class SetupAssistant {switch setting {case .metalHUD: metalHUD = oncase .highResolution: highResolution = on+ default: return}guard !isPreview else { return }do {diff --git a/app/Sources/BridgeplayApp/Support/GameDefaults.swift b/app/Sources/BridgeplayApp/Support/GameDefaults.swiftindex f37b7b5..5728836 100644--- a/app/Sources/BridgeplayApp/Support/GameDefaults.swift+++ b/app/Sources/BridgeplayApp/Support/GameDefaults.swift@@ -1,67 +1,475 @@import Foundation-// The few settings the Setup Assistant and the Status page offer for every game. They live-// in the user's gamefixes/default.conf, the lowest layer the run script reads (launch-// options, then <appid>.conf, then the shipped per-game defaults all win over it). Only the-// lines for these keys are rewritten: every other line, comment or setting the user wrote-// stays as it is. A setting that is off is removed rather than written as 0, so the engine's-// own default applies.+// The settings Game Defaults, the Setup Assistant and the Status page offer for every game.+// Bridgeplay ships its own in gamefixes-default/default.conf, replaced on every install, and+// the user's choices live in gamefixes/default.conf over them. The run script reads both+// before the per-game confs and the launch options, which win over them. Only the lines for+// these keys are rewritten: every other line, comment or setting the user wrote stays as it+// is. A choice that matches what the layers below already give writes no line, so a later+// change to Bridgeplay's shipped defaults still reaches the user.enum GameDefaults {- enum Setting: CaseIterable, Sendable {- case metalHUD+ enum Kind: Equatable, Sendable {+ case toggle+ // The values the page offers, in its order.+ case choice([String])+ case dllOverrides+ }++ enum Requirement: Sendable {+ // WineCX with a Game Porting Toolkit linked in.+ case d3dmetal+ }++ enum Setting: String, CaseIterable, Identifiable, Sendable {+ case backendcase highResolution+ case metalHUD+ case nvapi+ case metalFX+ case advertiseAVX+ case msync+ case vsync+ case frameGen+ case frameGenQuality+ case frameGenUI+ case frameGenFallback+ case frameGenEngine+ case dllOverrides++ var id: String { rawValue }// The first spelling is the one written; the others are read and replaced.var keys: [String] {switch self {- case .metalHUD: ["MTL_HUD_ENABLED"]+ case .backend: ["BACKEND"]case .highResolution: ["RETINA", "BRIDGEPLAY_RETINA"]+ case .metalHUD: ["MTL_HUD_ENABLED"]+ case .nvapi: ["NVAPI"]+ case .metalFX: ["D3DM_ENABLE_METALFX"]+ case .advertiseAVX: ["ROSETTA_ADVERTISE_AVX"]+ case .msync: ["MSYNC"]+ case .vsync: ["VSYNC", "BRIDGEPLAY_VSYNC"]+ case .frameGen: ["FRAMEGEN", "BRIDGEPLAY_FRAMEGEN"]+ case .frameGenQuality: ["FRAMEGEN_QUALITY", "BRIDGEPLAY_FRAMEGEN_QUALITY"]+ case .frameGenUI: ["FRAMEGEN_UI", "BRIDGEPLAY_FRAMEGEN_UI"]+ case .frameGenFallback: ["FRAMEGEN_FALLBACK", "BRIDGEPLAY_FRAMEGEN_FALLBACK"]+ case .frameGenEngine: ["FRAMEGEN_ENGINE", "BRIDGEPLAY_FRAMEGEN_ENGINE"]+ case .dllOverrides: ["DLLOVERRIDES"]+ }+ }++ // The same setting in a game's launch options, where it wins over every conf.+ // NVAPI has no launch-option spelling, and WINEDLLOVERRIDES adds to DLLOVERRIDES+ // per DLL instead of replacing it.+ var launchKeys: [String] {+ switch self {+ case .backend: ["BRIDGEPLAY_BACKEND", "NOTPROTON_BACKEND", "CX_GRAPHICS_BACKEND"]+ case .metalHUD, .metalFX, .advertiseAVX: keys+ case .msync: ["WINEMSYNC"]+ case .nvapi, .dllOverrides: []+ case .highResolution, .vsync, .frameGen, .frameGenQuality, .frameGenUI, .frameGenFallback, .frameGenEngine:+ ["BRIDGEPLAY_\(keys[0])", "NOTPROTON_\(keys[0])"]+ }+ }++ var kind: Kind {+ switch self {+ case .backend: .choice(["dxmt", "dxvk", "wined3d", "d3dmetal"])+ case .msync: .choice(["1", "0"])+ case .frameGen: .choice(["0", "2", "3", "adaptive"])+ case .frameGenQuality: .choice(["performance", "balanced", "quality"])+ case .frameGenEngine: .choice(["own", "metalfx"])+ case .dllOverrides: .dllOverrides+ default: .toggle+ }+ }++ // What the run script accepts in a conf (gamefix_reason); nil takes any safe value.+ var accepted: [String]? {+ switch self {+ case .metalHUD, .metalFX, .dllOverrides: nil+ case .backend: ["dxmt", "dxvk", "wined3d", "d3dmetal"]+ case .frameGen: ["0", "1", "2", "3", "adaptive"]+ case .frameGenQuality: ["performance", "balanced", "quality"]+ case .frameGenEngine: ["own", "metalfx"]+ default: ["0", "1"]+ }+ }++ // What a game gets when no conf sets the key; nil when the run script decides per+ // game or engine (the backend is auto-detected, msync follows the engine).+ var fallback: String? {+ switch self {+ case .backend, .msync, .dllOverrides: nil+ case .frameGenUI, .frameGenFallback: "1"+ case .frameGenQuality: "balanced"+ case .frameGenEngine: "own"+ default: "0"+ }+ }++ var requirement: Requirement? {+ switch self {+ case .nvapi, .metalFX: .d3dmetal+ default: nil}}}+ // Where the value a game gets comes from.+ enum Source: Equatable, Sendable {+ case engine+ case bridgeplay+ case user+ }++ struct Resolved: Equatable, Sendable {+ var value: String?+ var source: Source+ }++ struct Refused: LocalizedError, Equatable {+ var reason: String+ var errorDescription: String? { reason }+ }++ struct Problem: Equatable, Sendable {+ var setting: Setting+ var value: String+ var reason: String+ }+static var file: URL { SupportPaths.gamefixes.appending(path: "default.conf") }+ static var shippedFile: URL { SupportPaths.gamefixesDefault.appending(path: "default.conf") }static let header = "# Settings for every game. Per-game confs and Steam launch options win over these."- // Last assignment wins, as in the run script.- static func isOn(_ setting: Setting, in text: String) -> Bool {- var on = false+ // MARK: Reading++ // The last accepted assignment wins, as in the run script, which skips a refused line.+ static func value(_ setting: Setting, in text: String) -> String? {+ var found: String?+ for line in text.split(separator: "\n", omittingEmptySubsequences: false) {+ guard let (key, value) = assignment(line), setting.keys.contains(key),+ refusal(value, for: setting) == nil+ else { continue }+ found = value+ }+ // The first frame generation release spelled 2x as 1.+ if setting == .frameGen, found == "1" { return "2" }+ return found+ }++ static func resolve(_ setting: Setting, user: String, shipped: String) -> Resolved {+ if let found = Self.value(setting, in: user) { return Resolved(value: found, source: .user) }+ if let found = Self.value(setting, in: shipped) { return Resolved(value: found, source: .bridgeplay) }+ return Resolved(value: setting.fallback, source: .engine)+ }++ static func isOn(_ setting: Setting, in text: String, shipped: String = "") -> Bool {+ resolve(setting, user: text, shipped: shipped).value == "1"+ }++ static func isOn(_ setting: Setting, at url: URL = file, shipped: URL = shippedFile) -> Bool {+ isOn(setting, in: read(url), shipped: read(shipped))+ }++ // Lines for these keys that the run script refuses, with the reason.+ static func problems(in text: String) -> [Problem] {+ var found: [Problem] = []for line in text.split(separator: "\n", omittingEmptySubsequences: false) {- guard let (key, value) = assignment(line), setting.keys.contains(key) else { continue }- on = value == "1"+ guard let (key, value) = assignment(line),+ let setting = Setting.allCases.first(where: { $0.keys.contains(key) }),+ let reason = refusal(value, for: setting)+ else { continue }+ found.append(Problem(setting: setting, value: value, reason: reason))}- return on+ return found}- static func setting(_ setting: Setting, to on: Bool, in text: String) -> String {+ // MARK: Writing++ // nil resets the setting: its lines go and the layers below apply again.+ static func setting(_ setting: Setting, to value: String?, in text: String, shipped: String = "") -> String {var lines = text.isEmpty ? [] : text.components(separatedBy: "\n")if lines.last == "" { lines.removeLast() }lines.removeAll { line in assignment(Substring(line)).map { setting.keys.contains($0.0) } ?? false }- if on {+ let below = Self.value(setting, in: shipped) ?? setting.fallback+ if let value, value != below {if lines.isEmpty { lines.append(header) }- lines.append("\(setting.keys[0])=1")+ lines.append("\(setting.keys[0])=\(value)")}return lines.isEmpty ? "" : lines.joined(separator: "\n") + "\n"}- static func isOn(_ setting: Setting, at url: URL = file) -> Bool {- isOn(setting, in: (try? String(contentsOf: url, encoding: .utf8)) ?? "")+ static func setting(_ setting: Setting, to on: Bool, in text: String, shipped: String = "") -> String {+ Self.setting(setting, to: on ? "1" : "0", in: text, shipped: shipped)+ }++ // Every setting back to Bridgeplay's defaults; lines for other keys stay.+ static func resettingAll(in text: String) -> String {+ Setting.allCases.reduce(text) { Self.setting($1, to: nil, in: $0) }+ }++ static func set(_ setting: Setting, to on: Bool, at url: URL = file, shipped: URL = shippedFile) throws {+ try set(setting, to: on ? "1" : "0", at: url, shipped: shipped)+ }++ static func set(_ setting: Setting, to value: String?, at url: URL = file, shipped: URL = shippedFile) throws {+ if let value, let reason = refusal(value, for: setting) { throw Refused(reason: reason) }+ let current = read(url)+ try write(Self.setting(setting, to: value, in: current, shipped: read(shipped)), replacing: current, at: url)+ AppLog.note("game defaults: \(setting.keys[0]) \(value ?? "reset")")+ }++ static func resetAll(at url: URL = file) throws {+ let current = read(url)+ try write(resettingAll(in: current), replacing: current, at: url)+ AppLog.note("game defaults: all reset")}- static func set(_ setting: Setting, to on: Bool, at url: URL = file) throws {- let current = (try? String(contentsOf: url, encoding: .utf8)) ?? ""- let updated = Self.setting(setting, to: on, in: current)+ private static func write(_ updated: String, replacing current: String, at url: URL) throws {guard updated != current else { return }try FileManager.default.createDirectory(at: url.deletingLastPathComponent(), withIntermediateDirectories: true)try Data(updated.utf8).write(to: url, options: .atomic)- AppLog.note("game defaults: \(setting.keys[0]) \(on ? "on" : "off")")+ }++ // MARK: Validation, as gamefix_reason in compat_run.sh++ static func refusal(_ value: String, for setting: Setting) -> String? {+ if value.contains("`") || value.contains("$(") || value.contains("\"") || value.contains("'") {+ return String(localized: "Bridgeplay ignores a value with a backtick, $( or a quote.")+ }+ if value.unicodeScalars.contains(where: { CharacterSet.controlCharacters.contains($0) }) {+ return String(localized: "Bridgeplay ignores a value with a control character.")+ }+ if value.count > 1024 {+ return String(localized: "Bridgeplay ignores a value over 1024 characters.")+ }+ if let accepted = setting.accepted, !accepted.contains(value) {+ return String(localized: "Bridgeplay doesn't know this value.")+ }+ if setting == .dllOverrides, !validDLLOverrides(value) {+ return String(localized: "Use Wine's syntax, for example dinput8=n,b;xinput1_3=n.")+ }+ return nil+ }++ // name[,name...]=[n|b|n,b|b,n|d] entries joined by semicolons (valid_dll_overrides).+ static func validDLLOverrides(_ text: String) -> Bool {+ guard !text.isEmpty else { return false }+ let nameCharacters = Set("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_.,+-")+ for entry in text.split(separator: ";") {+ guard let equals = entry.firstIndex(of: "=") else { return false }+ let names = entry[..<equals]+ let mode = String(entry[entry.index(after: equals)...])+ if names.isEmpty || names.hasPrefix(",") || names.hasSuffix(",") || names.contains(",,") { return false }+ if names.contains(where: { !nameCharacters.contains($0) }) { return false }+ if !["n", "b", "d", "n,b", "b,n"].contains(mode) { return false }+ }+ return true+ }++ // MARK: Moving Bridgeplay's defaults out of the user's file++ // Earlier installers wrote Bridgeplay's shipped defaults into the user's own+ // gamefixes/default.conf, where they masked every later change to them. Once the shipped+ // file sits in gamefixes-default/, the user's file keeps only what the user changed: a+ // copy nobody edited goes, and so do lines identical to the copy last installed, while a+ // shipped KEY=1 the user deleted from that recorded copy becomes KEY=0, the off it meant.+ // The original is backed up first, and a marker makes this run once.+ static let splitMarker = ".installer/defaults-split"+ // What the first installers shipped, before .installer/default.conf recorded it.+ static let firstShippedHash = "442803b868fc31b188aa7f650c711efc6b8d2d63cb47399312d028c92be7b130"++ // nil when nothing of the user's is left. Without a record of the installed copy a+ // missing key says nothing: the app writes the file too, so it may never have been there.+ static func splitText(_ user: String, baseline: String, recorded: Bool = true) -> String? {+ if user == baseline { return nil }+ let baseLines = Set(baseline.split(separator: "\n").map { $0.trimmingCharacters(in: .whitespacesAndNewlines) })+ var lines = user.components(separatedBy: "\n")+ if lines.last == "" { lines.removeLast() }+ // Keys the user still sets, shipped value or not, before the shipped lines go.+ let userKeys = Set(lines.compactMap { assignment(Substring($0))?.0 })+ lines.removeAll { line in+ let trimmed = line.trimmingCharacters(in: .whitespacesAndNewlines)+ return !trimmed.isEmpty && baseLines.contains(trimmed)+ }+ for line in baseline.split(separator: "\n") where recorded {+ guard let (key, value) = assignment(line), value == "1", !userKeys.contains(key) else { continue }+ lines.append("\(key)=0")+ }+ guard lines.contains(where: { assignment(Substring($0)) != nil }) else { return nil }+ while lines.first?.trimmingCharacters(in: .whitespaces).isEmpty == true { lines.removeFirst() }+ return lines.joined(separator: "\n") + "\n"+ }++ // true when it changed the user's file.+ @discardableResult+ static func splitShipped(in support: URL, now: Date = Date()) throws -> Bool {+ let files = FileManager.default+ let marker = support.appending(path: splitMarker)+ let shipped = support.appending(path: "gamefixes-default/default.conf")+ guard !files.fileExists(atPath: marker.path(percentEncoded: false)),+ files.fileExists(atPath: shipped.path(percentEncoded: false))+ else { return false }+ let user = support.appending(path: "gamefixes/default.conf")+ var changed = false+ if files.fileExists(atPath: user.path(percentEncoded: false)) {+ let text = read(user)+ let recorded = support.appending(path: ".installer/default.conf")+ let hasRecord = files.fileExists(atPath: recorded.path(percentEncoded: false))+ let baseline = hasRecord ? read(recorded) : read(shipped)+ let unedited = (try? Digest.sha256(of: user)) == firstShippedHash+ let kept = unedited ? nil : splitText(text, baseline: baseline, recorded: hasRecord)+ if kept != text {+ let backup = support.appending(path: "backups/default.conf.\(Int(now.timeIntervalSince1970))")+ try files.createDirectory(at: backup.deletingLastPathComponent(), withIntermediateDirectories: true)+ if !files.fileExists(atPath: backup.path(percentEncoded: false)) {+ try files.copyItem(at: user, to: backup)+ }+ if let kept {+ try Data(kept.utf8).write(to: user, options: .atomic)+ } else {+ try files.removeItem(at: user)+ }+ changed = true+ }+ }+ try files.createDirectory(at: marker.deletingLastPathComponent(), withIntermediateDirectories: true)+ try Data().write(to: marker, options: .atomic)+ AppLog.note("game defaults: shipped defaults split out\(changed ? ", the user's file reduced" : "")")+ return changed+ }++ // MARK: Games with their own settings++ struct Override: Equatable, Sendable, Identifiable {+ enum Place: Hashable, Sendable {+ // gamefixes/<appid>.conf+ case conf+ // The launch options one Steam account keeps in its localconfig.vdf.+ case launchOptions(account: String)+ }++ var appID: String+ var place: Place+ var settings: [Setting]+ // From the game's appmanifest, or a non-Steam shortcut's name; nil when not installed.+ var name: String? = nil++ var id: String {+ switch place {+ case .conf: "\(appID)/conf"+ case .launchOptions(let account): "\(appID)/\(account)"+ }+ }+ }++ static func confOverrides(_ text: String) -> [Setting] {+ Setting.allCases.filter { Self.value($0, in: text) != nil }+ }++ // The NAME=value words before %command%, which the launch reads as the environment.+ // Without %command% Steam passes the options as the game's arguments, so none count.+ static func launchVariables(_ options: String) -> [String] {+ var names: [String] = []+ for word in options.split(whereSeparator: { $0 == " " || $0 == "\t" }) {+ if word.lowercased() == "%command%" { return names }+ guard let equals = word.firstIndex(of: "="), equals != word.startIndex else { continue }+ let name = word[..<equals]+ if name.first?.isNumber == false,+ name.allSatisfy({ $0.isASCII && ($0.isLetter || $0.isNumber || $0 == "_") }) {+ names.append(String(name))+ }+ }+ return []+ }++ static func launchOverrides(_ options: String) -> [Setting] {+ let names = Set(launchVariables(options))+ return Setting.allCases.filter { !Set($0.launchKeys).isDisjoint(with: names) }+ }++ // LaunchOptions by app id in one localconfig.vdf: the closest numeric key above it+ // names the app, as in the apps block Steam writes.+ static func launchOptions(inLocalConfig text: String) -> [String: String] {+ var found: [String: String] = [:]+ var app: String?+ for line in text.components(separatedBy: "\n") {+ if let key = BrandMigration.quotedKey(line) {+ if !key.isEmpty, key.allSatisfy(\.isNumber) { app = key }+ continue+ }+ guard let app, let (key, value, _) = BrandMigration.keyValue(line),+ key.caseInsensitiveCompare("LaunchOptions") == .orderedSame+ else { continue }+ found[app] = value.replacingOccurrences(of: "\\\"", with: "\"").replacingOccurrences(of: "\\\\", with: "\\")+ }+ return found+ }++ // Read only; a game is listed once per place it sets something of these.+ static func overrides(gamefixes: URL = SupportPaths.gamefixes,+ steamUserData: URL = SupportPaths.Steam.userData,+ libraries: [SteamLibrary] = PrefixStore.libraries()) -> [Override] {+ let files = FileManager.default+ var found: [Override] = []+ var shortcuts: [String: String]?+ func gameName(_ appID: String) -> String? {+ if let name = libraries.lazy.compactMap({ PrefixStore.appName(appID: appID, in: $0) }).first { return name }+ guard let id = UInt32(appID), id & 0x8000_0000 != 0 else { return nil }+ if shortcuts == nil { shortcuts = PrefixStore.shortcutNames(userdata: steamUserData.appending(path: "userdata")) }+ return shortcuts?[appID]+ }+ let confs = (try? files.contentsOfDirectory(atPath: gamefixes.path(percentEncoded: false))) ?? []+ for name in confs.sorted() where name.hasSuffix(".conf") {+ let appID = String(name.dropLast(".conf".count))+ guard !appID.isEmpty, appID.allSatisfy(\.isNumber) else { continue }+ let settings = confOverrides(read(gamefixes.appending(path: name)))+ if !settings.isEmpty { found.append(Override(appID: appID, place: .conf, settings: settings, name: gameName(appID))) }+ }+ let userdata = steamUserData.appending(path: "userdata")+ let accounts = (try? files.contentsOfDirectory(atPath: userdata.path(percentEncoded: false))) ?? []+ for account in accounts.sorted() where !account.isEmpty && account.allSatisfy(\.isNumber) {+ let text = read(userdata.appending(path: "\(account)/config/localconfig.vdf"))+ for (appID, options) in launchOptions(inLocalConfig: text).sorted(by: { $0.key < $1.key }) {+ let settings = launchOverrides(options)+ if !settings.isEmpty {+ found.append(Override(appID: appID, place: .launchOptions(account: account),+ settings: settings, name: gameName(appID)))+ }+ }+ }+ return found+ }++ // Use Defaults for a game's own conf: its lines for these settings go, after a backup.+ static func clearConf(appID: String, gamefixes: URL = SupportPaths.gamefixes,+ backups: URL = SupportPaths.backups, now: Date = Date()) throws {+ let url = gamefixes.appending(path: "\(appID).conf")+ let current = read(url)+ let updated = resettingAll(in: current)+ guard updated != current else { return }+ let backup = backups.appending(path: "\(appID).conf.\(Int(now.timeIntervalSince1970))")+ try FileManager.default.createDirectory(at: backups, withIntermediateDirectories: true)+ if !FileManager.default.fileExists(atPath: backup.path(percentEncoded: false)) {+ try FileManager.default.copyItem(at: url, to: backup)+ }+ try Data(updated.utf8).write(to: url, options: .atomic)+ AppLog.note("game defaults: \(appID).conf now uses the defaults")+ }++ // MARK: Text helpers++ static func read(_ url: URL) -> String {+ (try? String(contentsOf: url, encoding: .utf8)) ?? ""}// KEY=VALUE with surrounding whitespace trimmed, as the run script reads it.private static func assignment(_ line: Substring) -> (String, String)? {- let trimmed = line.trimmingCharacters(in: .whitespaces)+ let trimmed = line.trimmingCharacters(in: .whitespacesAndNewlines)guard let equals = trimmed.firstIndex(of: "="), !trimmed.hasPrefix("#") else { return nil }return (String(trimmed[..<equals]), String(trimmed[trimmed.index(after: equals)...]))}diff --git a/app/Sources/BridgeplayApp/Views/GameDefaultsView.swift b/app/Sources/BridgeplayApp/Views/GameDefaultsView.swiftnew file mode 100644index 0000000..224d498--- /dev/null+++ b/app/Sources/BridgeplayApp/Views/GameDefaultsView.swift@@ -0,0 +1,324 @@+// 'Game Defaults' view: the settings every game gets unless it has its own, see GameDefaults+import AppKit+import BridgeplayUI+import SwiftUI++struct GameDefaultsView: View {+ @Environment(SystemStatus.self) private var status+ // gamefixes/default.conf and gamefixes-default/default.conf, read when the page opens;+ // every change writes the user's file straight away.+ @State private var user = ""+ @State private var shipped = ""+ @State private var dllDraft = ""+ @State private var overrides: [GameDefaults.Override] = []+ @State private var defaultTool: String?+ @State private var failure: String?+ @State private var confirmsReset = false+ @State private var clearing: GameDefaults.Override?++ private var hasD3DMetal: Bool { status.snapshot?.gptkSource != nil }++ var body: some View {+ Form {+ Section {+ choiceRow(.backend)+ toggleRow(.metalFX)+ toggleRow(.nvapi)+ choiceRow(.msync)+ toggleRow(.advertiseAVX)+ } header: {+ Text("Graphics")+ } footer: {+ Text("Changes apply the next time a game starts. A game's own settings in Steam Properties › Bridgeplay win over these.")+ }+ Section {+ toggleRow(.highResolution)+ toggleRow(.metalHUD)+ toggleRow(.vsync)+ } header: {+ Text("Display")+ }+ Section {+ choiceRow(.frameGen)+ if resolved(.frameGen).value != "0" {+ choiceRow(.frameGenQuality)+ toggleRow(.frameGenUI)+ toggleRow(.frameGenFallback)+ choiceRow(.frameGenEngine)+ }+ } header: {+ Text("Frame Generation")+ } footer: {+ Text("Experimental. Adds input lag.")+ }+ Section {+ dllRow+ ForEach(Array(GameDefaults.problems(in: user).enumerated()), id: \.offset) { _, problem in+ StatusRow(title: Self.title(problem.setting),+ value: String(localized: "Ignored: \(problem.reason)"), tone: .warning)+ }+ } header: {+ Text("Advanced")+ } footer: {+ Text("Other lines in gamefixes/default.conf are kept as they are.")+ }+ Section {+ StatusRow(title: String(localized: "Default Compatibility Tool"),+ value: defaultTool ?? String(localized: "Not set"))+ } footer: {+ Text("Steam runs every game without a tool of its own with this one. Change it in the Setup Assistant while Steam is closed.")+ }+ overridesSection+ if let failure {+ Section {+ StatusRow(title: String(localized: "Something went wrong"), value: failure, tone: .bad,+ menu: ErrorReport.actions(failure, in: "Game Defaults"))+ }+ }+ }+ .formStyle(.grouped)+ .navigationTitle("Game Defaults")+ .toolbar {+ ToolbarItem(placement: .primaryAction) {+ Button("Reset All") { confirmsReset = true }+ .disabled(GameDefaults.resettingAll(in: user) == user)+ }+ }+ .confirmationDialog(String(localized: "Reset every game default?"), isPresented: $confirmsReset,+ titleVisibility: .visible) {+ Button("Reset All", role: .destructive) { resetAll() }+ Button("Cancel", role: .cancel) {}+ } message: {+ Text("Every setting on this page goes back to Bridgeplay's default.")+ }+ .confirmationDialog(String(localized: "Use the defaults for this game?"),+ isPresented: Binding(get: { clearing != nil }, set: { if !$0 { clearing = nil } }),+ titleVisibility: .visible, presenting: clearing) { item in+ Button("Use Defaults", role: .destructive) { clear(item) }+ Button("Cancel", role: .cancel) {}+ } message: { _ in+ Text("Bridgeplay removes these settings from the game's conf and keeps a copy in its backups folder.")+ }+ .task { await load() }+ }++ // MARK: Rows++ private func resolved(_ setting: GameDefaults.Setting) -> GameDefaults.Resolved {+ GameDefaults.resolve(setting, user: user, shipped: shipped)+ }++ private func caption(_ setting: GameDefaults.Setting) -> String {+ var parts = [Self.summary(setting)]+ switch resolved(setting).source {+ case .user: parts.append(String(localized: "Set by you."))+ case .bridgeplay: parts.append(String(localized: "Bridgeplay's default."))+ case .engine: break+ }+ let needsD3DMetal = setting.requirement == .d3dmetal || (setting == .backend && resolved(setting).value == "d3dmetal")+ if needsD3DMetal, !hasD3DMetal {+ parts.append(String(localized: "Needs the Game Porting Toolkit. Without it, games use DXMT."))+ }+ return parts.filter { !$0.isEmpty }.joined(separator: " ")+ }++ private func resetActions(_ setting: GameDefaults.Setting) -> [StatusAction] {+ guard resolved(setting).source == .user else { return [] }+ return [StatusAction(label: String(localized: "Reset to Bridgeplay's Default")) { save(setting, nil) }]+ }++ private func toggleRow(_ setting: GameDefaults.Setting) -> some View {+ StatusRow(title: Self.title(setting), value: caption(setting), menu: resetActions(setting),+ toggle: Binding(get: { resolved(setting).value == "1" }, set: { save(setting, $0 ? "1" : "0") }))+ }++ private func label(_ setting: GameDefaults.Setting) -> some View {+ VStack(alignment: .leading, spacing: 2) {+ Text(Self.title(setting))+ .font(BP.sans(13, .semibold))+ .tracking(-0.1)+ Text(caption(setting))+ .foregroundStyle(.secondary)+ }+ .padding(.leading, StatusMetrics.textInset)+ }++ private func choiceRow(_ setting: GameDefaults.Setting) -> some View {+ HStack(alignment: .center, spacing: 0) {+ label(setting)+ Spacer(minLength: 12)+ Picker(Self.title(setting), selection: Binding(+ get: { resolved(setting).value ?? "" },+ set: { save(setting, $0.isEmpty ? nil : $0) }+ )) {+ if setting.fallback == nil {+ Text("Automatic").tag("")+ }+ ForEach(Self.options(setting), id: \.self) { option in+ Text(Self.optionLabel(option, for: setting)).tag(option)+ }+ }+ .labelsHidden()+ .fixedSize()+ }+ .contextMenu {+ ForEach(resetActions(setting), id: \.label) { action in+ Button(action.label, action: action.perform)+ }+ }+ }++ private var dllRow: some View {+ HStack(alignment: .center, spacing: 8) {+ label(.dllOverrides)+ Spacer(minLength: 12)+ TextField(Self.title(.dllOverrides), text: $dllDraft, prompt: Text(verbatim: "dinput8=n,b"))+ .labelsHidden()+ .frame(maxWidth: 220)+ .onSubmit(saveDLLOverrides)+ Button("Apply", action: saveDLLOverrides)+ .disabled(dllDraft == (resolved(.dllOverrides).value ?? ""))+ }+ }++ private var overridesSection: some View {+ Section {+ if overrides.isEmpty {+ StatusRow(title: String(localized: "None"), value: String(localized: "Every game uses these defaults."))+ }+ ForEach(overrides) { item in+ StatusRow(title: item.name ?? String(localized: "App \(item.appID)"),+ value: item.settings.map(Self.title).joined(separator: ", "),+ trailing: Self.place(item.place),+ action: StatusAction(label: String(localized: "Open in Steam")) { Self.openInSteam(item.appID) },+ menu: item.place == .conf+ ? [StatusAction(label: String(localized: "Use Defaults…")) { clearing = item }] : [])+ }+ } header: {+ Text("Games with Their Own Settings")+ } footer: {+ Text("A game with launch options goes back to these defaults with Use Bridgeplay defaults in its Steam Properties › Bridgeplay.")+ }+ }++ // MARK: Actions++ private func load() async {+ user = GameDefaults.read(GameDefaults.file)+ shipped = GameDefaults.read(GameDefaults.shippedFile)+ dllDraft = resolved(.dllOverrides).value ?? ""+ defaultTool = SteamDefaultTool.current(in: GameDefaults.read(SteamDefaultTool.config))?.name+ overrides = await Task.detached(priority: .utility) { GameDefaults.overrides() }.value+ }++ private func save(_ setting: GameDefaults.Setting, _ value: String?) {+ do {+ try GameDefaults.set(setting, to: value)+ user = GameDefaults.read(GameDefaults.file)+ failure = nil+ } catch {+ failure = String(localized: "Bridgeplay could not save this setting. \(error.localizedDescription)")+ }+ }++ private func saveDLLOverrides() {+ let text = dllDraft.trimmingCharacters(in: .whitespaces)+ save(.dllOverrides, text.isEmpty ? nil : text)+ dllDraft = resolved(.dllOverrides).value ?? ""+ }++ private func resetAll() {+ do {+ try GameDefaults.resetAll()+ user = GameDefaults.read(GameDefaults.file)+ dllDraft = resolved(.dllOverrides).value ?? ""+ failure = nil+ } catch {+ failure = String(localized: "Bridgeplay could not save this setting. \(error.localizedDescription)")+ }+ }++ private func clear(_ item: GameDefaults.Override) {+ do {+ try GameDefaults.clearConf(appID: item.appID)+ overrides.removeAll { $0.id == item.id }+ failure = nil+ } catch {+ failure = String(localized: "Bridgeplay could not save this setting. \(error.localizedDescription)")+ }+ }++ private static func openInSteam(_ appID: String) {+ if let url = URL(string: "steam://nav/games/details/\(appID)") {+ NSWorkspace.shared.open(url)+ }+ }++ // MARK: Names++ static func title(_ setting: GameDefaults.Setting) -> String {+ switch setting {+ case .backend: String(localized: "Graphics Backend")+ case .highResolution: String(localized: "High Resolution")+ case .metalHUD: String(localized: "Metal HUD")+ case .nvapi: String(localized: "Report an NVIDIA GPU")+ case .metalFX: String(localized: "DLSS through MetalFX")+ case .advertiseAVX: String(localized: "Advertise AVX2 to Rosetta")+ case .msync: "MSync"+ case .vsync: String(localized: "Force VSync")+ case .frameGen: String(localized: "Frame Generation")+ case .frameGenQuality: String(localized: "Quality")+ case .frameGenUI: String(localized: "Protect UI")+ case .frameGenFallback: String(localized: "Fast-Motion Fallback")+ case .frameGenEngine: String(localized: "Engine")+ case .dllOverrides: String(localized: "DLL Overrides")+ }+ }++ static func summary(_ setting: GameDefaults.Setting) -> String {+ switch setting {+ case .backend: String(localized: "Automatic picks D3DMetal when the Game Porting Toolkit is linked, and DXMT otherwise.")+ case .highResolution: String(localized: "Sharper on Retina displays, but games run slower.")+ case .metalHUD: String(localized: "Shows frame rate and GPU details in a corner while you play.")+ case .nvapi: String(localized: "Lets games offer DLSS, served by MetalFX. Some games take NVIDIA-only paths with it.")+ case .metalFX: String(localized: "Only takes effect when DLSS is switched on in the game.")+ case .advertiseAVX: String(localized: "Many games quit without it.")+ case .msync: String(localized: "Automatic follows the engine.")+ case .vsync: String(localized: "Waits for the display even when a game turns VSync off.")+ case .frameGen, .frameGenQuality, .frameGenEngine: ""+ case .frameGenUI: String(localized: "Keeps static HUD and menus sharp.")+ case .frameGenFallback: String(localized: "Skips generated frames that would smear.")+ case .dllOverrides: String(localized: "Wine syntax. A game's own conf replaces these; its launch options win per DLL.")+ }+ }++ static func options(_ setting: GameDefaults.Setting) -> [String] {+ if case .choice(let values) = setting.kind { return values }+ return []+ }++ static func optionLabel(_ option: String, for setting: GameDefaults.Setting) -> String {+ switch (setting, option) {+ case (.backend, "d3dmetal"): "D3DMetal"+ case (.backend, "wined3d"): "WineD3D"+ case (.backend, _): option.uppercased()+ case (.msync, "1"): String(localized: "On")+ case (.msync, _), (.frameGen, "0"): String(localized: "Off")+ case (.frameGen, "adaptive"): String(localized: "Adaptive")+ case (.frameGen, _): "\(option)x"+ case (.frameGenQuality, "performance"): String(localized: "Performance")+ case (.frameGenQuality, "quality"): String(localized: "Quality")+ case (.frameGenQuality, _): String(localized: "Balanced")+ case (.frameGenEngine, "metalfx"): "MetalFX"+ case (.frameGenEngine, _): String(localized: "Built-in optical flow")+ default: option+ }+ }++ static func place(_ place: GameDefaults.Override.Place) -> String {+ switch place {+ case .conf: String(localized: "Own conf")+ case .launchOptions(let account): String(localized: "Launch options, account \(account)")+ }+ }+}diff --git a/app/Sources/BridgeplayApp/Views/RootView.swift b/app/Sources/BridgeplayApp/Views/RootView.swiftindex d3f10f4..5e1b48e 100644--- a/app/Sources/BridgeplayApp/Views/RootView.swift+++ b/app/Sources/BridgeplayApp/Views/RootView.swift@@ -3,6 +3,7 @@ import BridgeplayUIenum Pane: String, CaseIterable, Identifiable, Hashable {case status+ case gameDefaultscase prefixescase backupscase guide@@ -12,6 +13,7 @@ enum Pane: String, CaseIterable, Identifiable, Hashable {var label: String {switch self {case .status: String(localized: "Status")+ case .gameDefaults: String(localized: "Game Defaults")case .prefixes: String(localized: "Prefixes")case .backups: String(localized: "Prefix Backups")case .guide: String(localized: "Guide")@@ -21,6 +23,7 @@ enum Pane: String, CaseIterable, Identifiable, Hashable {var symbol: String {switch self {case .status: "checklist"+ case .gameDefaults: "slider.horizontal.3"case .prefixes: "externaldrive"case .backups: "externaldrive.badge.timemachine"case .guide: "book"@@ -77,6 +80,7 @@ struct RootView: View {Group {switch pane {case .status: StatusView()+ case .gameDefaults: GameDefaultsView()case .prefixes: PrefixesView()case .backups: BackupsView()case .guide: GuideView()diff --git a/app/Sources/BridgeplayApp/Views/StatusView.swift b/app/Sources/BridgeplayApp/Views/StatusView.swiftindex 96d2731..574687f 100644--- a/app/Sources/BridgeplayApp/Views/StatusView.swift+++ b/app/Sources/BridgeplayApp/Views/StatusView.swift@@ -165,7 +165,7 @@ struct StatusRow: View {struct StatusView: View {@Environment(SystemStatus.self) private var status- // gamefixes/default.conf, read when the page opens; the switches write it straight away.+ // Two of the Game Defaults (GameDefaults), read when the page opens; the switches write them straight away.@State private var metalHUD = GameDefaults.isOn(.metalHUD)@State private var highResolution = GameDefaults.isOn(.highResolution)@State private var gameDefaultsError: String?@@ -461,7 +461,7 @@ struct StatusView: View {} header: {Text("For Every Game")} footer: {- Text("A game's own settings in Steam Properties › Bridgeplay win over these.")+ Text("A game's own settings in Steam Properties › Bridgeplay win over these. Game Defaults has the rest.")}}diff --git a/app/Tests/BridgeplayAppTests/GameDefaultsAgreementTests.swift b/app/Tests/BridgeplayAppTests/GameDefaultsAgreementTests.swiftnew file mode 100644index 0000000..cddaa61--- /dev/null+++ b/app/Tests/BridgeplayAppTests/GameDefaultsAgreementTests.swift@@ -0,0 +1,90 @@+import Foundation+import Testing++@testable import BridgeplayApp++// GameDefaults validates what it writes the way gamefix_reason in compat_run.sh reads it,+// so a value the page saves is never one the run script throws away.+@Suite("Game Defaults agreement")+struct GameDefaultsAgreementTests {++ private static func source(_ path: String) throws -> String {+ let repo = URL(filePath: #filePath)+ .deletingLastPathComponent()+ .deletingLastPathComponent()+ .deletingLastPathComponent()+ .deletingLastPathComponent()+ return try String(contentsOf: repo.appending(path: path), encoding: .utf8)+ }++ struct Arm {+ var patterns: [String]+ var body: String++ func matches(_ key: String) -> Bool {+ patterns.contains { $0 == key || ($0.hasSuffix("_?*") && key.hasPrefix($0.dropLast(2))) }+ }++ // The values of its `case "$2" in a|b)`, nil when it takes any value.+ var values: Set<String>? {+ guard let start = body.range(of: "case \"$2\" in ") else { return nil }+ let rest = body[start.upperBound...]+ guard let close = rest.firstIndex(of: ")") else { return nil }+ return Set(rest[..<close].split(separator: "|").map(String.init))+ }+ }++ // The arms of gamefix_reason's `case "$1" in`, each with the lines up to the next arm.+ static func arms(in run: String) throws -> [Arm] {+ let start = try #require(run.range(of: "gamefix_reason() {\n"))+ let end = try #require(run.range(of: "\n}\n", range: start.upperBound..<run.endIndex))+ let keyCharacters = Set("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_?*|")+ var arms: [Arm] = []+ for line in run[start.upperBound..<end.lowerBound].split(separator: "\n") {+ let trimmed = line.trimmingCharacters(in: .whitespaces)+ if line.hasPrefix(" "), !line.hasPrefix(" "),+ let close = trimmed.firstIndex(of: ")"), close != trimmed.startIndex,+ trimmed[..<close].allSatisfy({ keyCharacters.contains($0) }) {+ arms.append(Arm(patterns: trimmed[..<close].split(separator: "|").map(String.init),+ body: String(trimmed[trimmed.index(after: close)...])))+ } else if !arms.isEmpty {+ arms[arms.count - 1].body += "\n" + trimmed+ }+ }+ return arms+ }++ @Test("Every setting's key and values are the ones the run script accepts")+ func valuesAgree() throws {+ let arms = try Self.arms(in: Self.source("dylib/feats/compat_run.sh"))+ #expect(arms.count >= 8, "found \(arms.count) arms, the parse looks wrong")+ for setting in GameDefaults.Setting.allCases {+ let key = setting.keys[0]+ let arm = try #require(arms.first { $0.matches(key) && $0.patterns != ["*"] }, "\(key) is not on the allow-list")+ if setting == .dllOverrides {+ #expect(arm.body.contains("valid_dll_overrides"))+ } else {+ #expect(arm.values == setting.accepted.map { Set($0) }, "\(key): \(String(describing: arm.values))")+ }+ if case .choice(let offered) = setting.kind {+ #expect(Set(offered).isSubset(of: arm.values ?? []), "\(key) offers a value the run script refuses")+ }+ }+ }++ @Test("Every other spelling a setting reads is one gamefix_read maps to its key")+ func aliasesAgree() throws {+ let run = try Self.source("dylib/feats/compat_run.sh")+ let start = try #require(run.range(of: " case \"$key\" in\n BRIDGEPLAY_"))+ let line = run[run.index(start.lowerBound, offsetBy: " case \"$key\" in\n".count)...].prefix { $0 != "\n" }+ let close = try #require(line.firstIndex(of: ")"))+ let patterns = line[..<close].trimmingCharacters(in: .whitespaces).split(separator: "|").map(String.init)+ let alias = Arm(patterns: patterns, body: "")+ for setting in GameDefaults.Setting.allCases {+ for spelling in setting.keys.dropFirst() {+ #expect(alias.matches(spelling), "\(spelling) is not read as \(setting.keys[0])")+ #expect(spelling == "BRIDGEPLAY_" + setting.keys[0])+ }+ }+ }+}diff --git a/app/Tests/BridgeplayAppTests/GameDefaultsTests.swift b/app/Tests/BridgeplayAppTests/GameDefaultsTests.swiftindex 5bf328f..a7da077 100644--- a/app/Tests/BridgeplayAppTests/GameDefaultsTests.swift+++ b/app/Tests/BridgeplayAppTests/GameDefaultsTests.swift@@ -29,9 +29,252 @@ import Testinglet dir = FileManager.default.temporaryDirectory.appending(path: "gamedefaults-\(UUID().uuidString)")defer { try? FileManager.default.removeItem(at: dir) }let url = dir.appending(path: "gamefixes/default.conf")- try GameDefaults.set(.highResolution, to: true, at: url)- #expect(GameDefaults.isOn(.highResolution, at: url))- try GameDefaults.set(.highResolution, to: false, at: url)- #expect(!GameDefaults.isOn(.highResolution, at: url))+ let shipped = dir.appending(path: "gamefixes-default/default.conf")+ try GameDefaults.set(.highResolution, to: true, at: url, shipped: shipped)+ #expect(GameDefaults.isOn(.highResolution, at: url, shipped: shipped))+ try GameDefaults.set(.highResolution, to: false, at: url, shipped: shipped)+ #expect(!GameDefaults.isOn(.highResolution, at: url, shipped: shipped))+ }++ // MARK: Over Bridgeplay's shipped defaults++ @Test func offOverAShippedOnIsWrittenAsZero() {+ let shipped = "NVAPI=1\nROSETTA_ADVERTISE_AVX=1\n"+ #expect(GameDefaults.isOn(.nvapi, in: "", shipped: shipped))+ let off = GameDefaults.setting(.nvapi, to: false, in: "", shipped: shipped)+ #expect(off == GameDefaults.header + "\nNVAPI=0\n")+ #expect(!GameDefaults.isOn(.nvapi, in: off, shipped: shipped))+ // Back on is what the shipped file already gives, so the line goes.+ #expect(GameDefaults.setting(.nvapi, to: true, in: off, shipped: shipped) == GameDefaults.header + "\n")+ }++ @Test func resetRemovesTheLineWhateverItSays() {+ let text = "# mine\nBACKEND=dxvk\nFRAMEGEN=3\n"+ #expect(GameDefaults.setting(.backend, to: nil, in: text) == "# mine\nFRAMEGEN=3\n")+ #expect(GameDefaults.resettingAll(in: text + "WINEDEBUG=-all\n") == "# mine\nWINEDEBUG=-all\n")+ }++ @Test func choicesAndTheirFallbacks() {+ #expect(GameDefaults.setting(.backend, to: "dxvk", in: "") == GameDefaults.header + "\nBACKEND=dxvk\n")+ // Protect UI is on when unset, so on writes nothing and off writes 0.+ #expect(GameDefaults.setting(.frameGenUI, to: true, in: "") == "")+ #expect(GameDefaults.setting(.frameGenUI, to: false, in: "") == GameDefaults.header + "\nFRAMEGEN_UI=0\n")+ #expect(GameDefaults.setting(.frameGenQuality, to: "balanced", in: "") == "")+ #expect(GameDefaults.value(.frameGen, in: "BRIDGEPLAY_FRAMEGEN=1\n") == "2")+ }++ @Test func layersResolveAsTheRunScriptReadsThem() {+ let shipped = "NVAPI=1\nBACKEND=dxmt\n"+ let user = "BACKEND=dxvk\n"+ #expect(GameDefaults.resolve(.backend, user: user, shipped: shipped) == .init(value: "dxvk", source: .user))+ #expect(GameDefaults.resolve(.nvapi, user: user, shipped: shipped) == .init(value: "1", source: .bridgeplay))+ #expect(GameDefaults.resolve(.metalHUD, user: user, shipped: shipped) == .init(value: "0", source: .engine))+ #expect(GameDefaults.resolve(.msync, user: user, shipped: shipped) == .init(value: nil, source: .engine))+ }++ @Test func refusedValuesAreSkippedAndReported() throws {+ // The run script skips a refused line, so the one before it still applies.+ #expect(GameDefaults.value(.backend, in: "BACKEND=dxvk\nBACKEND=vulkan\n") == "dxvk")+ #expect(GameDefaults.value(.metalHUD, in: "MTL_HUD_ENABLED=$(evil)\n") == nil)+ let problems = GameDefaults.problems(in: "BACKEND=vulkan\nRETINA=yes\nWINEDEBUG=-all\n")+ #expect(problems.map(\.setting) == [.backend, .highResolution])+ #expect(GameDefaults.refusal("dxvk", for: .backend) == nil)+ #expect(GameDefaults.refusal("a\"b", for: .dllOverrides) != nil)+ #expect(GameDefaults.refusal(String(repeating: "a", count: 1025), for: .metalHUD) != nil)+ #expect(GameDefaults.refusal("2", for: .metalHUD) == nil)+ #expect(GameDefaults.refusal("2", for: .nvapi) != nil)++ let dir = FileManager.default.temporaryDirectory.appending(path: "gamedefaults-\(UUID().uuidString)")+ defer { try? FileManager.default.removeItem(at: dir) }+ let url = dir.appending(path: "default.conf")+ #expect(throws: GameDefaults.Refused.self) {+ try GameDefaults.set(.backend, to: "vulkan", at: url, shipped: dir.appending(path: "none"))+ }+ #expect(!FileManager.default.fileExists(atPath: url.path))+ }++ @Test func dllOverridesFollowWineSyntax() {+ for good in ["dinput8=n,b", "dinput8=n,b;xinput1_3=n", "d3d9,d3d11=b", "a.dll=d", ";"] {+ #expect(GameDefaults.validDLLOverrides(good), "\(good)")+ }+ for bad in ["", "dinput8", "dinput8=x", ",a=n", "a,=n", "a,,b=n", "a b=n", "=n"] {+ #expect(!GameDefaults.validDLLOverrides(bad), "\(bad)")+ }+ }++ // MARK: Splitting the shipped defaults out of the user's file++ private static let shipped = "# Global defaults\n# Rosetta hides AVX\nROSETTA_ADVERTISE_AVX=1\nD3DM_ENABLE_METALFX=1\nNVAPI=1\n"++ @Test func anUneditedCopyLeavesNothing() {+ #expect(GameDefaults.splitText(Self.shipped, baseline: Self.shipped) == nil)+ }++ @Test func anEditedCopyKeepsOnlyTheUsersChanges() {+ // The user turned on the HUD, set their own backend and deleted NVAPI=1.+ let user = "# Global defaults\n# Rosetta hides AVX\nROSETTA_ADVERTISE_AVX=1\nD3DM_ENABLE_METALFX=1\n" ++ "# my HUD\nMTL_HUD_ENABLED=1\nBACKEND=dxvk\n"+ #expect(GameDefaults.splitText(user, baseline: Self.shipped) == "# my HUD\nMTL_HUD_ENABLED=1\nBACKEND=dxvk\nNVAPI=0\n")+ // A shipped value the user changed stays theirs.+ #expect(GameDefaults.splitText(Self.shipped.replacingOccurrences(of: "NVAPI=1", with: "NVAPI=0"),+ baseline: Self.shipped) == "NVAPI=0\n")+ }++ @Test func splitsOnceWithABackup() throws {+ let support = try scratchDirectory("gamedefaults-split")+ defer { try? FileManager.default.removeItem(at: support) }+ func put(_ path: String, _ text: String) throws {+ let url = support.appending(path: path)+ try FileManager.default.createDirectory(at: url.deletingLastPathComponent(), withIntermediateDirectories: true)+ try Data(text.utf8).write(to: url)+ }+ let user = support.appending(path: "gamefixes/default.conf")+ try put("gamefixes/default.conf", Self.shipped + "MTL_HUD_ENABLED=1\n")+ try put(".installer/default.conf", Self.shipped)+ // Nothing happens before the shipped file is installed.+ #expect(try !GameDefaults.splitShipped(in: support))+ #expect(!FileManager.default.fileExists(atPath: support.appending(path: GameDefaults.splitMarker).path))++ try put("gamefixes-default/default.conf", Self.shipped)+ let now = Date(timeIntervalSince1970: 1_800_000_000)+ #expect(try GameDefaults.splitShipped(in: support, now: now))+ #expect(GameDefaults.read(user) == "MTL_HUD_ENABLED=1\n")+ #expect(GameDefaults.read(support.appending(path: "backups/default.conf.1800000000")) == Self.shipped + "MTL_HUD_ENABLED=1\n")+ #expect(FileManager.default.fileExists(atPath: support.appending(path: GameDefaults.splitMarker).path))++ // Once only: a later edit that matches a shipped line is the user's now.+ try put("gamefixes/default.conf", "NVAPI=1\n")+ #expect(try !GameDefaults.splitShipped(in: support, now: now))+ #expect(GameDefaults.read(user) == "NVAPI=1\n")+ }++ @Test func anUneditedFileIsRemoved() throws {+ let support = try scratchDirectory("gamedefaults-unedited")+ defer { try? FileManager.default.removeItem(at: support) }+ for path in ["gamefixes/default.conf", "gamefixes-default/default.conf"] {+ let url = support.appending(path: path)+ try FileManager.default.createDirectory(at: url.deletingLastPathComponent(), withIntermediateDirectories: true)+ try Data(Self.shipped.utf8).write(to: url)+ }+ #expect(try GameDefaults.splitShipped(in: support))+ #expect(!FileManager.default.fileExists(atPath: support.appending(path: "gamefixes/default.conf").path))+ let backups = try FileManager.default.contentsOfDirectory(atPath: support.appending(path: "backups").path)+ #expect(backups.count == 1)+ }++ @Test func onlyARecordedCopyTurnsADeletedKeyOff() throws {+ func split(_ text: String, record: String?) throws -> String {+ let support = try scratchDirectory("gamedefaults-record")+ defer { try? FileManager.default.removeItem(at: support) }+ var files = ["gamefixes/default.conf": text, "gamefixes-default/default.conf": Self.shipped]+ if let record { files[".installer/default.conf"] = record }+ for (path, text) in files {+ let url = support.appending(path: path)+ try FileManager.default.createDirectory(at: url.deletingLastPathComponent(), withIntermediateDirectories: true)+ try Data(text.utf8).write(to: url)+ }+ try GameDefaults.splitShipped(in: support)+ return GameDefaults.read(support.appending(path: "gamefixes/default.conf"))+ }+ // The app wrote these, not an installer: nothing was deleted, so nothing is turned off.+ #expect(try split("MTL_HUD_ENABLED=1\n", record: nil) == "MTL_HUD_ENABLED=1\n")+ #expect(try split("", record: nil) == "")+ // The user deleted NVAPI=1 from the copy the installer recorded, or wrote NVAPI=0.+ #expect(try split(Self.shipped.replacingOccurrences(of: "NVAPI=1\n", with: ""), record: Self.shipped) == "NVAPI=0\n")+ #expect(try split(Self.shipped.replacingOccurrences(of: "NVAPI=1", with: "NVAPI=0"), record: Self.shipped) == "NVAPI=0\n")+ }++ // MARK: Games with their own settings++ @Test func launchVariablesAreTheWordsBeforeCommand() {+ #expect(GameDefaults.launchVariables("CX_GRAPHICS_BACKEND=dxvk FOO=1 %command% -BAR=1") == ["CX_GRAPHICS_BACKEND", "FOO"])+ #expect(GameDefaults.launchVariables("-novid MTL_HUD_ENABLED=1") == [])+ #expect(GameDefaults.launchOverrides("NOTPROTON_RETINA=1 WINEMSYNC=0 %COMMAND%") == [.highResolution, .msync])+ }++ @Test func scansConfsAndEveryAccountsLaunchOptions() throws {+ let root = try scratchDirectory("gamedefaults-overrides")+ defer { try? FileManager.default.removeItem(at: root) }+ func put(_ path: String, _ text: String) throws {+ let url = root.appending(path: path)+ try FileManager.default.createDirectory(at: url.deletingLastPathComponent(), withIntermediateDirectories: true)+ try Data(text.utf8).write(to: url)+ }+ try put("gamefixes/1245620.conf", "BACKEND=dxvk\nWINEDEBUG=-all\n")+ try put("gamefixes/990080.conf", "WINEDEBUG=-all\n")+ try put("gamefixes/default.conf", "BACKEND=dxmt\n")+ let localconfig = """+ "UserLocalConfigStore"+ {+ \t"Software"+ \t{+ \t\t"Valve"+ \t\t{+ \t\t\t"Steam"+ \t\t\t{+ \t\t\t\t"apps"+ \t\t\t\t{+ \t\t\t\t\t"287700"+ \t\t\t\t\t{+ \t\t\t\t\t\t"LaunchOptions"\t\t"CX_GRAPHICS_BACKEND=dxmt BRIDGEPLAY_FRAMEGEN=2 %command%"+ \t\t\t\t\t}+ \t\t\t\t\t"440"+ \t\t\t\t\t{+ \t\t\t\t\t\t"LaunchOptions"\t\t"-novid"+ \t\t\t\t\t}+ \t\t\t\t}+ \t\t\t}+ \t\t}+ \t}+ }+ """+ try put("steam/userdata/111/config/localconfig.vdf", localconfig)+ try put("steam/userdata/222/config/localconfig.vdf", localconfig.replacingOccurrences(of: "CX_GRAPHICS_BACKEND=dxmt ", with: ""))++ let found = GameDefaults.overrides(gamefixes: root.appending(path: "gamefixes"),+ steamUserData: root.appending(path: "steam"), libraries: [])+ #expect(found == [+ .init(appID: "1245620", place: .conf, settings: [.backend]),+ .init(appID: "287700", place: .launchOptions(account: "111"), settings: [.backend, .frameGen]),+ .init(appID: "287700", place: .launchOptions(account: "222"), settings: [.frameGen]),+ ])+ }++ @Test func namesEachGameFromItsManifestOrShortcut() throws {+ let root = try scratchDirectory("gamedefaults-names")+ defer { try? FileManager.default.removeItem(at: root) }+ func put(_ path: String, _ data: Data) throws {+ let url = root.appending(path: path)+ try FileManager.default.createDirectory(at: url.deletingLastPathComponent(), withIntermediateDirectories: true)+ try data.write(to: url)+ }+ for appID in ["3372060", "990080", "3000000000"] {+ try put("gamefixes/\(appID).conf", Data("MTL_HUD_ENABLED=0\n".utf8))+ }+ let library = SteamLibrary(root: root.appending(path: "external"))+ try put("external/steamapps/appmanifest_3372060.acf",+ Data("\"AppState\"\n{\n\t\"appid\"\t\t\"3372060\"\n\t\"name\"\t\t\"Hell \\\"Maiden\\\"\"\n}\n".utf8))+ var vdf: [UInt8] = [0x00] + Array("shortcuts".utf8) + [0] + [0x00, 0x30, 0]+ vdf += [0x02] + Array("appid".utf8) + [0] + withUnsafeBytes(of: UInt32(3_000_000_000).littleEndian, Array.init)+ vdf += [0x01] + Array("AppName".utf8) + [0] + Array("Postal2".utf8) + [0]+ vdf += [0x08, 0x08, 0x08]+ try put("steam/userdata/111/config/shortcuts.vdf", Data(vdf))++ let found = GameDefaults.overrides(gamefixes: root.appending(path: "gamefixes"),+ steamUserData: root.appending(path: "steam"), libraries: [library])+ #expect(found.map(\.name) == ["Postal2", "Hell \"Maiden\"", nil])+ }++ @Test func useDefaultsForAConfKeepsOtherLinesAndABackup() throws {+ let root = try scratchDirectory("gamedefaults-clear")+ defer { try? FileManager.default.removeItem(at: root) }+ let gamefixes = root.appending(path: "gamefixes")+ try FileManager.default.createDirectory(at: gamefixes, withIntermediateDirectories: true)+ try Data("# fix\nBACKEND=dxvk\nWINEDEBUG=-all\n".utf8).write(to: gamefixes.appending(path: "42.conf"))+ let backups = root.appending(path: "backups")+ try GameDefaults.clearConf(appID: "42", gamefixes: gamefixes, backups: backups,+ now: Date(timeIntervalSince1970: 5))+ #expect(GameDefaults.read(gamefixes.appending(path: "42.conf")) == "# fix\nWINEDEBUG=-all\n")+ #expect(GameDefaults.read(backups.appending(path: "42.conf.5")) == "# fix\nBACKEND=dxvk\nWINEDEBUG=-all\n")}}diff --git a/docs/GAMEFIXES.md b/docs/GAMEFIXES.mdindex 78ebbed..64a2953 100644--- a/docs/GAMEFIXES.md+++ b/docs/GAMEFIXES.md@@ -1,12 +1,29 @@# Per-game fixes and graphics backends-The `run` script reads two optional files for each game, named after its Steam app id:--1. `~/Library/Application Support/bridgeplay/gamefixes-default/<appid>.conf`, shipped with Bridgeplay-2. `~/Library/Application Support/bridgeplay/gamefixes/<appid>.conf`, your own--The later file wins per key. A variable you set in the game's Steam launch options-(`NAME=value %command%`) wins over both files.+The `run` script reads up to four optional files when a game starts. The first two apply to+every game, and the last two are named after the game's Steam app id:++1. `~/Library/Application Support/bridgeplay/gamefixes-default/default.conf`, Bridgeplay's defaults for every game+2. `~/Library/Application Support/bridgeplay/gamefixes/default.conf`, your own defaults for every game+3. `~/Library/Application Support/bridgeplay/gamefixes-default/<appid>.conf`, shipped with Bridgeplay+4. `~/Library/Application Support/bridgeplay/gamefixes/<appid>.conf`, your own++A later file wins per key. A variable you set in the game's Steam launch options+(`NAME=value %command%`) wins over all four files. Bridgeplay replaces the files in+`gamefixes-default/` on every install and never writes to your `<appid>.conf`.++The Game Defaults page in the app edits file 2. It rewrites only the lines for the settings+it shows and keeps every other line and comment. When you pick what files below it already+give, it removes the line instead of writing it, so a later change to Bridgeplay's defaults+still reaches you. Turning off a setting that Bridgeplay turns on writes `KEY=0`. The page+also lists the games that set something of their own, in a conf or in their launch options.+In Steam, Properties › Bridgeplay has a Use Bridgeplay defaults button that removes those+settings from a game's launch options.++Installers before the split copied Bridgeplay's defaults into file 2. The app trims that copy+once, after saving the original in `backups/`. It drops the lines identical to the copy last+installed (`.installer/default.conf`) and writes `KEY=0` for a shipped `KEY=1` you had+deleted, so your file keeps only your own changes.Bridgeplay's own variables are spelled `BRIDGEPLAY_*` (`BRIDGEPLAY_RETINA=1`). The`NOTPROTON_*` spelling from before 3.0.0 still works, in launch options and in conf files.@@ -34,8 +51,8 @@ logged, when:| `FRAMEGEN_UI` | `0`, `1` | Same as `BRIDGEPLAY_FRAMEGEN_UI`, Protect UI: keeps static HUD and menus sharp. On when unset || `FRAMEGEN_FALLBACK` | `0`, `1` | Same as `BRIDGEPLAY_FRAMEGEN_FALLBACK`, Fast-motion fallback: skips generated frames that would smear. On when unset || `FRAMEGEN_ENGINE` | `own`, `metalfx` | Same as `BRIDGEPLAY_FRAMEGEN_ENGINE`: the built-in optical flow (`own`, the default) or MetalFX frame interpolation |-| `NVAPI` | `0`, `1` | `1` turns on Apple's `nvapi64` and `nvngx` (DLSS on MetalFX) on an engine with a linked Game Porting Toolkit, for `d3dmetal` only, and makes D3DMetal report an NVIDIA GeForce RTX 4090 (`D3DM_VENDOR_ID=0x10de`, `D3DM_DEVICE_ID=0x2684`, `D3DM_DEVICE_DESCRIPTION`; a `D3DM_*` from a conf or the launch options wins) and a driver version of 32.0.15.9541 (`NOTPROTON_DRIVER_VERSION`), since games offer DLSS only on an NVIDIA adapter. Without the key, the run script treats it as `0`. Bridgeplay's shipped global `default.conf` sets `NVAPI=1`, so it is on for every game unless a game's conf or launch options say `NVAPI=0`. An nvapi that answers sends some games down NVIDIA-only paths, which is the reason to turn it off |-| `DLSS_FG` | `0`, `1` | With `NVAPI=1` on `d3dmetal`, `1` sets `CX_ACTIVE_GRAPHICS_BACKEND=d3dmetal` so WineCX reports hardware GPU scheduling, which DLSS frame generation requires. Experimental and off by default (the global `default.conf` leaves it out): [frankea/Whisky#231](https://github.com/frankea/Whisky/pull/231) saw MetalFX frame interpolation on an M5 with D3DMetal 4.0b2 hang WindowServer |+| `NVAPI` | `0`, `1` | `1` turns on Apple's `nvapi64` and `nvngx` (DLSS on MetalFX) on an engine with a linked Game Porting Toolkit, for `d3dmetal` only, and makes D3DMetal report an NVIDIA GeForce RTX 4090 (`D3DM_VENDOR_ID=0x10de`, `D3DM_DEVICE_ID=0x2684`, `D3DM_DEVICE_DESCRIPTION`; a `D3DM_*` from a conf or the launch options wins) and a driver version of 32.0.15.9541 (`NOTPROTON_DRIVER_VERSION`), since games offer DLSS only on an NVIDIA adapter. Without the key, the run script treats it as `0`. Bridgeplay's `gamefixes-default/default.conf` sets `NVAPI=1`, so it is on for every game unless a game's conf or launch options say `NVAPI=0`. An nvapi that answers sends some games down NVIDIA-only paths, which is the reason to turn it off |+| `DLSS_FG` | `0`, `1` | With `NVAPI=1` on `d3dmetal`, `1` sets `CX_ACTIVE_GRAPHICS_BACKEND=d3dmetal` so WineCX reports hardware GPU scheduling, which DLSS frame generation requires. Experimental and off by default (`gamefixes-default/default.conf` leaves it out): [frankea/Whisky#231](https://github.com/frankea/Whisky/pull/231) saw MetalFX frame interpolation on an M5 with D3DMetal 4.0b2 hang WindowServer || `STDOUT_NULL` | `0`, `1` | `1` starts the game without a stdout handle, as Steam on Windows does. Source 2 treats any stdout as a console build (`Plat_IsConsoleApplication`) and then skips NGX, so Deadlock offers no DLSS || `VSYNC` | `0`, `1` | `1` makes the game's Metal layer wait for the display even when the game turns vsync off, like forcing vsync in the NVIDIA control panel. For games that lock vsync off with frame generation on (Resident Evil Requiem) and tear above the refresh rate || `HIDE_WINE_EXPORTS` | `0`, `1` | `1` makes `GetProcAddress` fail for ntdll's `wine_*` exports on the WineCX 11.17 engine (`hide-wine-exports-patch/`), like Wine Staging's `HideWineExports`. For games that turn features off under Wine: The Witcher 3 5.0 skips NVIDIA Streamline, so no DLSS |diff --git a/dylib/feats/compat_run.sh b/dylib/feats/compat_run.shindex 381bf07..042f6d6 100755--- a/dylib/feats/compat_run.sh+++ b/dylib/feats/compat_run.sh@@ -371,9 +371,11 @@ $pad_maps"}np_pad_mappings-# Per-game fixes: the shipped gamefixes-default/<appid>.conf, then the user's-# gamefixes/<appid>.conf, the later file winning per key. KEY=VALUE lines are checked-# against an allow-list and never sourced, and the launch options win over both files.+# Settings for every game, then per-game fixes, the later file winning per key: the shipped+# gamefixes-default/default.conf, the user's gamefixes/default.conf (Game Defaults in the+# app), the shipped gamefixes-default/<appid>.conf, then the user's gamefixes/<appid>.conf.+# KEY=VALUE lines are checked against an allow-list and never sourced, and the launch+# options win over every file.gamefix_keys=""gamefix_backend=""gamefix_dlloverrides=""@@ -487,6 +489,7 @@ gamefix_apply_env() {load_gamefixes() {case "$app_id" in ''|0) return 0 ;; esac+ gamefix_read "$np_support/gamefixes-default/default.conf" shipped-globalgamefix_read "$np_support/gamefixes/default.conf" globalgamefix_read "$np_support/gamefixes-default/$app_id.conf" defaultgamefix_read "$np_support/gamefixes/$app_id.conf" user@@ -714,7 +717,8 @@ select_backend() {fiif [ -z "$wanted" ] && [ -n "$gamefix_backend" ]; thenwanted=$gamefix_backend- backend_from="BACKEND in the gamefix conf"+ # Names the layer, so a fallback from a Game Defaults choice reads as one in the log.+ backend_from="BACKEND in the ${gamefix_from_BACKEND:-gamefix} conf"fi# A helper has no game to inspect, so it keeps what the game last ran with.if [ -z "$wanted" ] && [ "$verb" != waitforexitandrun ] \diff --git a/dylib/feats/webpatch.c b/dylib/feats/webpatch.cindex f8b28f0..ae6a38f 100644--- a/dylib/feats/webpatch.c+++ b/dylib/feats/webpatch.c@@ -466,7 +466,13 @@ static int out_expand(np_out_t *o, const char *replace, const np_cap_t *caps) {"{data:\"d3dmetal\",label:\"D3DMetal\"}," \"{data:\"dxmt\",label:\"DXMT\"}," \"{data:\"dxvk\",label:\"DXVK\"}," \- "{data:\"wined3d\",label:\"WineD3D\"}].filter(x=>!fex||x.data!==\"d3dmetal\");" \+ "{data:\"wined3d\",label:\"WineD3D\"}].filter(x=>!fex||x.data!==\"d3dmetal\")," \+ /* The settings Game Defaults in the app also sets: the ones this game sets for itself, \+ which Use Bridgeplay defaults drops (DXMT_CONFIG keeps entries other than the factor). */ \+ "OV=[\"CX_GRAPHICS_BACKEND\",\"MTL_HUD_ENABLED\",\"D3DM_ENABLE_METALFX\",\"DXMT_ENABLE_NVEXT\"," \+ "\"ROSETTA_ADVERTISE_AVX\",\"WINEMSYNC\",\"BRIDGEPLAY_RETINA\",\"DXMT_METALFX_SPATIAL_SWAPCHAIN\",\"DXMT_CONFIG\"," \+ "\"BRIDGEPLAY_FRAMEGEN\",\"BRIDGEPLAY_FRAMEGEN_QUALITY\",\"BRIDGEPLAY_FRAMEGEN_UI\",\"BRIDGEPLAY_FRAMEGEN_FALLBACK\"," \+ "\"BRIDGEPLAY_FRAMEGEN_ENGINE\",\"BRIDGEPLAY_VSYNC\",\"BRIDGEPLAY_BACKEND\"].filter(k=>\"DXMT_CONFIG\"===k?fe.some(fk):!!A(k));" \"if(nat)return(0," RT ".jsx)(\"div\",{className:\"MSCXPanel\",children:(0," RT ".jsxs)(" RT ".Fragment,{children:[" \"(0," RT ".jsx)(\"style\",{children:" NP_CX_OPTIONS_CSS "})," \"T([\"MTL_HUD_ENABLED\"],\"Metal HUD\",\"1\"),FG()," \@@ -506,7 +512,10 @@ static int out_expand(np_out_t *o, const char *replace, const np_cap_t *caps) {"]},\"ctl\")," \"fex&&(0," RT ".jsx)(" BARREL ".XY,{label:\"FEX\"," \"children:X(\"FEX_X87REDUCEDPRECISION\"," \- "\"Reduced x87 Precision (Reducing precision improves game performance, is enabled by default in CrossOver Preview)\")},\"fex\")" \+ "\"Reduced x87 Precision (Reducing precision improves game performance, is enabled by default in CrossOver Preview)\")},\"fex\")," \+ "OV.length>0&&(0," RT ".jsx)(\"div\",{className:\"MSCXBtns\",children:(0," RT ".jsx)(\"button\",{className:\"MSCXBtn\"," \+ "onClick:()=>s(OV.map(k=>[k,\"DXMT_CONFIG\"===k?fx(\"\"):\"\"]))," \+ "children:npL(\"Use Bridgeplay defaults\",\"使用 Bridgeplay 默认设置\",\"Usa le impostazioni predefinite di Bridgeplay\")})},\"npdef\")" \"]})})}"#define NP_CX_OPTIONS_CAPTURE(RT, BARREL) \@@ -822,7 +831,7 @@ int np_webpatch_should_patch(const char *path) {// The panel shows what a launch will actually use. The run script resolves each setting as// launch options > gamefixes/<appid>.conf > gamefixes-default/<appid>.conf >-// gamefixes/default.conf > the engine, so the values below the launch options are handed to+// gamefixes/default.conf > gamefixes-default/default.conf > the engine, so the values below the launch options are handed to// the page as globalThis.MSCXFx when Steam loads it (a later conf edit shows after a restart).// Native games go through np-native instead, which reads gamefixes/native/<appid>.conf over// gamefixes/native-default.conf with variable names as they are; those land in ng and na.@@ -1039,7 +1048,10 @@ static int fx_build(char *buf, size_t cap) {if (n < 0 || (size_t)n >= cap) return 0;len = (size_t)n;+ // Every game: Bridgeplay's shipped defaults, then the user's Game Defaults over them.fx_set_t global = {0};+ snprintf(path, sizeof(path), "%s/gamefixes-default/default.conf", root);+ fx_read(path, &global, 0);snprintf(path, sizeof(path), "%s/gamefixes/default.conf", root);fx_read(path, &global, 0);if (!fx_json_set(buf, cap, &len, &global)) return 0;diff --git a/dylib/tests/gamefixescheck.sh b/dylib/tests/gamefixescheck.shindex 13ccd87..ef83820 100644--- a/dylib/tests/gamefixescheck.sh+++ b/dylib/tests/gamefixescheck.sh@@ -656,6 +656,40 @@ is "a file is left alone" "644" "$(stat -f %Lp "$wine_dir")"has "and is warned about" "is not a directory (Regular File), left alone" "$heal_log"rm "$wine_dir"+echo "== layers: shipped and user defaults for every game"+new_case+full_engine+global_conf() { printf '%s\n' "$@" > "$case_dir/support/gamefixes-default/default.conf"; }+user_global_conf() { printf '%s\n' "$@" > "$case_dir/support/gamefixes/default.conf"; }+global_conf 'BACKEND=dxvk' 'RETINA=1' 'WINEDEBUG=-all' 'FRAMEGEN=2'+user_global_conf 'RETINA=0' 'FRAMEGEN=adaptive'+default_conf 'FRAMEGEN=3'+launch waitforexitandrun "$case_dir/game/game.exe"+is "the shipped global conf applies" "dxvk" "$(got backend)"+is "the shipped global conf exports" "-all" "$(got WINEDEBUG)"+is "the user's global conf wins over the shipped one" "0" "$(got NOTPROTON_RETINA)"+is "a shipped per-game conf wins over both global confs" "3" "$(got NOTPROTON_FRAMEGEN)"+has "the shipped global conf is read first" "reading the shipped-global conf" "$case_dir/log"+has "the log names the shipped global layer" "BACKEND in the shipped-global conf" "$case_dir/log"+has "the log names the user's global layer" "applied NOTPROTON_RETINA=0 from the global conf" "$case_dir/log"++new_case+full_engine+global_conf 'BACKEND=dxvk' 'RETINA=1'+user_global_conf 'MTL_HUD_ENABLED=1'+user_conf 'BACKEND=dxmt'+launch waitforexitandrun "$case_dir/game/game.exe" BRIDGEPLAY_RETINA=0 MTL_HUD_ENABLED=0+is "a user per-game conf wins over the global confs" "dxmt" "$(got backend)"+is "launch options win over the shipped global conf" "0" "$(got NOTPROTON_RETINA)"+is "launch options win over the user's global conf" "0" "$(got MTL_HUD_ENABLED)"++new_case+full_engine+user_global_conf 'BACKEND=d3dmetal'+launch waitforexitandrun "$case_dir/game/game.exe"+is "a global d3dmetal on an engine without it falls back" "dxmt" "$(got backend)"+has "the fallback names the global layer" "BACKEND in the global conf, fell back from d3dmetal" "$case_dir/log"+if [ "$fails" -eq 0 ]; thenecho "==> gamefixescheck: all assertions hold"elsediff --git a/dylib/tests/panel-behavior/behavior.js b/dylib/tests/panel-behavior/behavior.jsindex 54396f2..5706278 100644--- a/dylib/tests/panel-behavior/behavior.js+++ b/dylib/tests/panel-behavior/behavior.js@@ -353,6 +353,27 @@ for (const form of Object.keys(FORMS)) {`no home: the old launcher is found and kept (${last()})`);delete globalThis.MSCXFx;+ // Use Bridgeplay defaults: only for a game that sets one of them, and it drops just those.+ const reset = ns => ns.find(x => x.type === 'button' && x.props.className === 'MSCXBtn');+ t.ok(!reset(nodes('')) && !reset(nodes('FOO=1 BRIDGEPLAY_RAW_CONTROLLERS=1')),+ 'no Use Bridgeplay defaults button when the game sets none of them');+ written.length = 0;+ reset(nodes('CX_GRAPHICS_BACKEND=dxvk FOO=bar NOTPROTON_RETINA=1 BRIDGEPLAY_FRAMEGEN=3 BRIDGEPLAY_RAW_CONTROLLERS=1')+ ).props.onClick();+ t.ok(last().trim() === 'FOO=bar BRIDGEPLAY_RAW_CONTROLLERS=1 %command%',+ `Use Bridgeplay defaults drops only those settings, either spelling (${last()})`);+ written.length = 0;+ reset(nodes('NOTPROTON_VSYNC=1 FOO=bar BRIDGEPLAY_BACKEND=dxvk')).props.onClick();+ t.ok(last().trim() === 'FOO=bar %command%',+ `Use Bridgeplay defaults also drops vsync and the backend's own spelling (${last()})`);+ written.length = 0;+ reset(nodes('CX_GRAPHICS_BACKEND=dxmt DXMT_CONFIG="d3d11.metalSpatialUpscaleFactor=2.0;dxgi.x=1"')).props.onClick();+ t.ok(last().trim() === 'DXMT_CONFIG=dxgi.x=1 %command%',+ `Use Bridgeplay defaults keeps other DXMT_CONFIG entries (${last()})`);+ written.length = 0;+ reset(nodes('MTL_HUD_ENABLED=1')).props.onClick();+ t.ok(last() === '', `a line left with only %command% is cleared (${JSON.stringify(last())})`);+const css = nodes('').filter(x => x.type === 'style');t.ok(css.length === 1 && css[0].props.children.includes('.MSCXPanel .MSCXRow{'),'the panel carries one stylesheet defining the row rule');diff --git a/dylib/tests/panel-behavior/effective.js b/dylib/tests/panel-behavior/effective.jsindex 1ce306d..b16edce 100644--- a/dylib/tests/panel-behavior/effective.js+++ b/dylib/tests/panel-behavior/effective.js@@ -29,6 +29,8 @@ put('gamefixes/default.conf','D3DM_ENABLE_METALFX=1\n' +'FRAMEGEN=1\nFRAMEGEN_QUALITY=quality\nFRAMEGEN_UI=0\nFRAMEGEN_FALLBACK=0\nFRAMEGEN_ENGINE=metalfx\n');put('gamefixes-default/1888930.conf', 'ROSETTA_ADVERTISE_AVX=1\n');+// Bridgeplay's shipped defaults for every game sit under the user's Game Defaults.+put('gamefixes-default/default.conf', 'MTL_HUD_ENABLED=0\nDXMT_ENABLE_NVEXT=1\nRETINA=0\n');// The run script's short keys also take the BRIDGEPLAY_ name.put('gamefixes/1778821.conf', 'BRIDGEPLAY_FRAMEGEN=0\n');// np-native's own confs: raw variable names, export and quotes allowed, and the pre-3.0@@ -81,6 +83,10 @@ t0.ok(!!fx && JSON.stringify(fx.g).includes('"BRIDGEPLAY_FRAMEGEN":"1"') &&fx.g.BRIDGEPLAY_FRAMEGEN_QUALITY === 'quality' && fx.g.BRIDGEPLAY_FRAMEGEN_UI === '0' &&fx.g.BRIDGEPLAY_FRAMEGEN_FALLBACK === '0' && fx.g.BRIDGEPLAY_FRAMEGEN_ENGINE === 'metalfx','the FRAMEGEN conf keys map to their variables');+t0.ok(!!fx && fx.g.DXMT_ENABLE_NVEXT === '1' && fx.g.MTL_HUD_ENABLED === '1' && fx.g.BRIDGEPLAY_RETINA === '1',+ `the shipped global conf is read under the user's (${fx && JSON.stringify(fx.g)})`);+t0.ok(!!fx && !Object.prototype.hasOwnProperty.call(fx.a, 'default'),+ 'the shipped default.conf is not taken for a game');t0.ok(!!fx && fx.d.BRIDGEPLAY_FRAMEGEN_UI === '1' && fx.d.BRIDGEPLAY_FRAMEGEN_FALLBACK === '1','Protect UI and the fast-motion fallback default on');t0.ok(!!fx && JSON.stringify(fx.ng) === '{"MTL_HUD_ENABLED":"1","NP_PAD_MODE":"hid","BRIDGEPLAY_FRAMEGEN":"3"}',diff --git a/installer/config/gamefixes/default.conf b/gamefixes/default.confsimilarity index 74%rename from installer/config/gamefixes/default.confrename to gamefixes/default.confindex d5f2e50..8bf8aca 100644--- a/installer/config/gamefixes/default.conf+++ b/gamefixes/default.conf@@ -1,7 +1,8 @@-# Global defaults for every game (lowest precedence: per-game confs and Steam launch options win).+# Bridgeplay's defaults for every game, the lowest layer: the user's Game Defaults+# (gamefixes/default.conf), per-game confs and Steam launch options all win over these.# Metal HUD, High Resolution (RETINA) and DLSS frame generation (DLSS_FG) stay off: they cost# GPU and heat, and frame generation can hang WindowServer (frankea/Whisky#231). Turn them on per-# game or in Setup.+# game or on the Game Defaults page.# 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.diff --git a/installer/Install.command b/installer/Install.commandindex 6a84b0e..26389b8 100755--- a/installer/Install.command+++ b/installer/Install.command@@ -154,23 +154,11 @@ for old in 1422450:3ec703897532711d09717384333bce001642c16e9b33875e20f685af8fd09rm -f "$f" || die "Config game lama tidak bisa dihapus: $f"done-# default.conf is the user's global file. It follows the bundled one unless the user has-# edited it: .installer/default.conf records the copy last installed, and a default.conf-# that still matches it, or the one every earlier installer shipped, is replaced. An-# edited one is kept and the new bundled file is put next to it as default.conf.new.-shipped="$here/config/gamefixes/default.conf"-current="$support/gamefixes/default.conf"-record="$support/.installer/default.conf"-first_shipped=442803b868fc31b188aa7f650c711efc6b8d2d63cb47399312d028c92be7b130-if [ ! -f "$current" ] || cmp -s "$current" "$shipped" \- || { [ -f "$record" ] && cmp -s "$current" "$record"; } \- || [ "$(shasum -a 256 "$current" | cut -d' ' -f1)" = "$first_shipped" ]; then- cp -f "$shipped" "$current" || die "default.conf gagal disalin."-else- cp -f "$shipped" "$current.new" || die "default.conf gagal disalin."- say "default.conf kamu sudah diubah, jadi tidak ditimpa. Versi terbaru disimpan sebagai default.conf.new di $support/gamefixes."-fi-cp -f "$shipped" "$record" || die "default.conf gagal dicatat."+# Bridgeplay's defaults for every game are gamefixes-default/default.conf, copied above with+# the per-game confs. The user's gamefixes/default.conf holds only their own changes and is+# never written here. On its next start the app trims a copy earlier installers wrote there,+# using .installer/default.conf, the record of that copy, which therefore stays as it is.+# The user's own controller mappings: only seeded when there are none yet.if [ ! -f "$support/gamecontrollerdb.txt" ]; thencp "$here/config/gamecontrollerdb.txt" "$support/" || die "gamecontrollerdb.txt gagal disalin."diff --git a/installer/README.md b/installer/README.mdindex 33c8ce0..545c477 100644--- a/installer/README.md+++ b/installer/README.md@@ -38,11 +38,11 @@ which migrates them on first launch.Every Mach-O file in `gptk/` must pass `codesign --verify --strict -R 'anchor apple'`(Apple's own signature) or the script stops.-`Install.command` puts the per-game confs in `gamefixes-default/`, the folder the app owns-and refreshes on update, never in the user's `gamefixes/`. `config/gamefixes/default.conf`-(the global file, installer-only) replaces the user's copy unless the user has edited it-since the last install (`.installer/default.conf` records that copy); an edited one is kept-and the new file lands next to it as `default.conf.new`.+`Install.command` puts the confs from the repository's `gamefixes/`, `default.conf` (Bridgeplay's+defaults for every game) included, in `gamefixes-default/`, the folder the app owns and+refreshes on update. It never writes to the user's `gamefixes/`. Earlier installers copied+`default.conf` there and recorded that copy in `.installer/default.conf`; the app uses the+record once to trim the user's file down to their own changes.Never shipped: Valve's Steam client and the Steam packages in `valve-packages/` (the appdownloads those from Valve's CDN) and the WineCX runtime (the app downloads it fromdiff --git a/scripts/package-installer.sh b/scripts/package-installer.shindex b115d03..e05fac4 100755--- a/scripts/package-installer.sh+++ b/scripts/package-installer.sh@@ -108,11 +108,11 @@ done <"$gptk_list"# --- gamefixes ---------------------------------------------------------------------# Per-game confs come from gamefixes/, the same files the app ships into-# gamefixes-default/, so the installer can never carry a divergent copy. default.conf (the-# global file in the user's gamefixes/) is installer-only and lives in installer/config/.+# The confs come from gamefixes/, the same files the app ships into gamefixes-default/, so+# the installer can never carry a divergent copy. default.conf there is Bridgeplay's+# defaults for every game; the user's own gamefixes/default.conf is never shipped.ls gamefixes/*.conf >/dev/null 2>&1 || die "no gamefixes/*.conf in the repository"-[ -s installer/config/gamefixes/default.conf ] || die "missing installer/config/gamefixes/default.conf"+[ -s gamefixes/default.conf ] || die "missing gamefixes/default.conf"# --- stage ------------------------------------------------------------------------