-
-
Notifications
You must be signed in to change notification settings - Fork 444
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[UX] Filter settings that don't apply to current platform and game #3997
base: main
Are you sure you want to change the base?
Conversation
looks good, but you should reduce the amount of repeated code in the filtering function |
I made a comment about the repetition of the code in the PR description, I intentionally left it repeated (and I can reduce this if we agree it's not good, but I feel it's more clear this way) |
oh whoops I missed that |
src/backend/logger/logger.ts
Outdated
delete gameSettings['wineCrossoverBottle'] | ||
|
||
if (notNative) { | ||
const wineType = gameSettings['wineVersion'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const wineType = gameSettings['wineVersion'] | |
const wineVersion = gameSettings['wineVersion'] |
src/backend/logger/logger.ts
Outdated
notNative: boolean | ||
): Partial<GameSettings> { | ||
// remove gamescope settings if it's disabled | ||
const gscope = gameSettings['gamescope'] as Partial<GameScopeSettings> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const gscope = gameSettings['gamescope'] as Partial<GameScopeSettings> | |
const gscope: Partial<GameScopeSettings> | undefined = gameSettings['gamescope'] |
This may seem a little excessive, but always avoid as
if you can do it somehow.
Why? Try changing 'gamescope'
to 'someOtherNonexistantName'
. No errors! Alternatively, try changing the GameSettings
type, changing or removing gamescope
. Again, no error here
src/backend/logger/logger.ts
Outdated
@@ -507,7 +635,11 @@ class GameLogWriter extends LogWriter { | |||
|
|||
// log game settings | |||
const gameSettings = await gameManagerMap[runner].getSettings(app_name) | |||
const gameSettingsString = JSON.stringify(gameSettings, null, '\t') | |||
const gameSettingsString = JSON.stringify( | |||
this.filterGameSettingsForLog({ ...gameSettings }, notNative), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.filterGameSettingsForLog({ ...gameSettings }, notNative), | |
this.filterGameSettingsForLog(structuredClone(gameSettings), notNative), |
Right now, this will only shallow-clone the settings object
src/backend/logger/logger.ts
Outdated
delete gscope['windowType'] | ||
} | ||
} | ||
|
||
// remove settings that are not used on Linux | ||
if (isLinux) { | ||
delete gameSettings['enableMsync'] | ||
delete gameSettings['wineCrossoverBottle'] | ||
|
||
if (notNative) { | ||
const wineType = gameSettings['wineVersion'] | ||
if (wineType) { | ||
if (wineType['type'] === 'proton') { | ||
delete gameSettings['autoInstallDxvk'] | ||
delete gameSettings['autoInstallVkd3d'] | ||
} | ||
} | ||
} else { | ||
// remove settings that are not used on native Linux games | ||
delete gameSettings['wineVersion'] | ||
delete gameSettings['winePrefix'] | ||
delete gameSettings['autoInstallDxvk'] | ||
delete gameSettings['autoInstallDxvkNvapi'] | ||
delete gameSettings['autoInstallVkd3d'] | ||
delete gameSettings['enableFsync'] | ||
delete gameSettings['enableEsync'] | ||
delete gameSettings['enableFSR'] | ||
delete gameSettings['showFps'] | ||
delete gameSettings['enableDXVKFpsLimit'] | ||
delete gameSettings['eacRuntime'] | ||
delete gameSettings['battlEyeRuntime'] | ||
delete gameSettings['useGameMode'] | ||
} | ||
} | ||
|
||
// remove settings that are not used on Mac | ||
if (isMac) { | ||
delete gameSettings['useGameMode'] | ||
delete gameSettings['gamescope'] | ||
delete gameSettings['nvidiaPrime'] | ||
delete gameSettings['battlEyeRuntime'] | ||
delete gameSettings['eacRuntime'] | ||
delete gameSettings['enableFSR'] | ||
delete gameSettings['showMangohud'] | ||
delete gameSettings['showFps'] | ||
|
||
if (notNative) { | ||
const wineType = gameSettings['wineVersion'] | ||
if (wineType) { | ||
if (wineType['type'] === 'wine') { | ||
delete gameSettings['wineCrossoverBottle'] | ||
} | ||
|
||
if (wineType['type'] === 'toolkit') { | ||
delete gameSettings['autoInstallDxvk'] | ||
delete gameSettings['autoInstallDxvkNvapi'] | ||
delete gameSettings['autoInstallVkd3d'] | ||
} | ||
|
||
if (wineType['type'] === 'crossover') { | ||
delete gameSettings['autoInstallDxvk'] | ||
delete gameSettings['autoInstallDxvkNvapi'] | ||
delete gameSettings['autoInstallVkd3d'] | ||
} | ||
} | ||
|
||
delete gameSettings['wineVersion'] | ||
delete gameSettings['winePrefix'] | ||
} else { | ||
// remove settings that are not used on native Mac games | ||
delete gameSettings['enableDXVKFpsLimit'] | ||
delete gameSettings['wineVersion'] | ||
delete gameSettings['winePrefix'] | ||
delete gameSettings['wineCrossoverBottle'] | ||
} | ||
} | ||
|
||
// remove settings that are not used on Windows | ||
if (isWindows) { | ||
delete gameSettings['enableMsync'] | ||
delete gameSettings['enableFSR'] | ||
delete gameSettings['enableEsync'] | ||
delete gameSettings['enableFsync'] | ||
delete gameSettings['enableDXVKFpsLimit'] | ||
delete gameSettings['DXVKFpsCap'] | ||
delete gameSettings['autoInstallDxvk'] | ||
delete gameSettings['autoInstallDxvkNvapi'] | ||
delete gameSettings['autoInstallVkd3d'] | ||
delete gameSettings['gamescope'] | ||
delete gameSettings['useGameMode'] | ||
delete gameSettings['showMangohud'] | ||
delete gameSettings['showFps'] | ||
delete gameSettings['preferSystemLibs'] | ||
delete gameSettings['wineCrossoverBottle'] | ||
delete gameSettings['winePrefix'] | ||
delete gameSettings['wineVersion'] | ||
delete gameSettings['battlEyeRuntime'] | ||
delete gameSettings['eacRuntime'] | ||
delete gameSettings['nvidiaPrime'] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole function should use dot notation to access properties. Bracket notation currently hides some errors, since we have noUncheckedIndexedAccess
turned on in our tsconfig
7f607ec
to
2cfbcaa
Compare
This PR changes the behavior of the Game logger to remove settings from the output when the settings don't make sense for a given game and platform.
For example: it will filter out all the wine-related settings for native games, or hide the gamescope settings when the parent gamescope setting is disabled.
The idea behind this is that these settings that don't make any sense for a given situation are still displayed in the logs, adding noise and confusing the users and during support.
I think this is a good enough first iteration, I think there are probably more settings that can be removed specially on windows, but I don't have a machine with windows to verify (I was looking at the code of the different settings only).
Note: I know the code is kinda verbose, but it was intentional to make it super clear which elements are being removed an in which conditions. I could refactor this to set settings in an array and looping but I kinda felt this was better. I can change this if we don't agree.
Use the following Checklist if you have changed something on the Backend or Frontend: