Non-Steam Game: Add non-steam|nsg
filter to list
Command
#1121
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Work for #960.
Overview
This PR adds a
non-steam
filter (withnsg
shorthand) to thesteamtinkerlaunch list
command. Now all Non-Steam Games in the library can be listed with thelist
command as AppID, name, path, count, or all of the above.The usage is exactly the same as it is for using
owned
(o
) orinstalled
(i
), but now we can usenon-steam
(nsg
) with this command too.Non-Steam Games are NOT printed alongside owned/installed AppIDs, they are ONLY printed when the
non-steam
/nsg
filter is used.As an aside, this also fixes a small formatting bug where
printf
wasn't taking a newline properly, which resulted in some ugly output, and the function has been flattened slightly.Implementation
We follow the same pattern as we do for
installed
andowned
, and start by getting all of the Non-Steam Game AppIDs and then storing this in anLISTAIDSARR
array. To do this, we have a new function to get all Non-Steam AppIDs, namedlistNonSteamGameIDs
. This prints each AppID parsed fromshortcuts.vdf
in awhile
read loop the same way we do forgetOwnedAids
andlistInstalledGameIDs
.From there the rest of the program just falls through the rest of the logic that it already does for
installed
andowned
.The regular logic here calls
getTitleFromID
andgetGameDir
, however these two functions have separate parameters to know whether they should search for Non-Steam Games or not. This was implemented because these functions are used in the codebase in situations where Non-Steam Games should not be returned (such as for Vortex game detection checks). Therefore searching on Non-Steam Games is disabled by default.Likewise, we don't want
installed
/owned
to return Non-Steam Games, so we only want to have these functions return Non-Steam Games when we search for them.In order to get these functions to only return the Non-Steam Game AppIDs when we search for Non-Steam Games, we have a conditional variable to control this. We only call
listNonSteamGameIDs
if we pass thenon-steam
andnsg
filter, so if we do this, we setSEARCHSTEAMSHORTCUTS
equal to1
. It is0
by default. This value is given togetTitleFromID
andgetGameDir
, as they expect0
/1
values. This allows us to control when these calls return Non-Steam Games, allowing us to only return Non-Steam Games when we explicitly want to find them.Concerns
This implementation is not very efficient in particular for Non-Steam Games. We fetch the list of AppIDs by parsing
shortcuts.vdf
, and then we have to do this all over again for each call togetTitleFromID
andgetGameDir
.This is the most inefficient for the default, where we want to get name and path for Non-Steam Games. With how the function is currently implemented, I don't see a clean way to refactor this. We are probably best off making separate functions for listing owned, installed, and Non-Steam games at some point in the future, but it's overkill for now.
The performance hit is undesirable but acceptable for now until I find time to re-evaluate
listSteamGames
. If people complain about it being slow, and something downstream depends on it being faster, refactoring will be prioritized.This PR has been tested and it seems to still work fine in my testing with
owned
,installed
, and nownon-steam
with no regressions or issues.This will probably be ready to merge soon, pending a version bump. This is one of the last remaining tasks for the Non-Steam Game integration overhaul!
TODO: