Skip to content
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

Non-Steam Game: Add non-steam|nsg filter to list Command #1121

Merged
merged 5 commits into from
Jun 8, 2024

Conversation

sonic2kk
Copy link
Owner

@sonic2kk sonic2kk commented Jun 7, 2024

Work for #960.

Overview

This PR adds a non-steam filter (with nsg shorthand) to the steamtinkerlaunch list command. Now all Non-Steam Games in the library can be listed with the list command as AppID, name, path, count, or all of the above.

The usage is exactly the same as it is for using owned (o) or installed (i), but now we can use non-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 and owned, and start by getting all of the Non-Steam Game AppIDs and then storing this in an LISTAIDSARR array. To do this, we have a new function to get all Non-Steam AppIDs, named listNonSteamGameIDs. This prints each AppID parsed from shortcuts.vdf in a while read loop the same way we do for getOwnedAids and listInstalledGameIDs.

From there the rest of the program just falls through the rest of the logic that it already does for installed and owned.

The regular logic here calls getTitleFromID and getGameDir, 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 the non-steam and nsg filter, so if we do this, we set SEARCHSTEAMSHORTCUTS equal to 1. It is 0 by default. This value is given to getTitleFromID and getGameDir, as they expect 0/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 to getTitleFromID and getGameDir.

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 now non-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:

  • Check if wiki needs updated
  • Version bump

@sonic2kk
Copy link
Owner Author

sonic2kk commented Jun 8, 2024

Confirmed again that this works and doesn't cause any regressions. Commands that may depend on existing functionality like vortex list-installed seem to be fine and haven't regressed since adding ${SEARCHSTEAMSHORTCUTS}.

I'll double-check the wiki and make any needed updates, then bump the version and merge this.

@sonic2kk
Copy link
Owner Author

sonic2kk commented Jun 8, 2024

Added a small section about this command on the "Add Non-Steam Game" wiki page. I think this plus the help screen update to note this usage is enough.

With a version bump this will be ready to merge.

@sonic2kk sonic2kk merged commit 3fabf6a into master Jun 8, 2024
2 checks passed
@sonic2kk sonic2kk linked an issue Jun 8, 2024 that may be closed by this pull request
11 tasks
sonic2kk added a commit that referenced this pull request Jun 9, 2024
sonic2kk added a commit that referenced this pull request Jun 9, 2024
Was overdue, meant to do it in #1121 but forgot.
@sonic2kk sonic2kk deleted the list-all-nonsteam-games branch June 10, 2024 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] Non-Steam Game Improvements
1 participant