Commandline: Refactor getTitleFromID to be more reliable with Non-Steam Games #1011
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.
Overview
I noticed an issue with a Non-Steam Game that I have launched with SteamTinkerLaunch before not returning the game title correctly with
getTitleFromID
. I found this while working on #1007, where using it for Non-Steam Games sometimes had a blank name. I narrowed the cause down to the game having an STL meta file that was missing the title (since we don't have the title for Non-Steam Games). If we didn't find the title in the meta file, we weren't continuing to search, which was causing the issue since Non-Steam Games have a meta file but not a title, and so we were never continuing beyond this to search onshortcuts.vdf
.This PR refactors
getTitleFromID
significantly, making it less nested and now checking on SteamTinkerLaunch meta file, then falling back to appmanifest, and then falling back toshortcuts.vdf
to try and find the corresponding Title for a given AppID. Previously, we were checking only one of these. This meant if there was a meta file without a title (which is potentially the case for Non-Steam Games), we would not find the App Name.Implementation
The function has been refactored so that we use a variable to track the game title. We set this each time we search for the game title. If it is blank, we assume we can move onto the next search method. It works like this:
FOUNDGAMETITLE
is blank.FOUNDGAMETITLE
.FOUNDGAMETITLE
is still blank after this, search the Steam AppManifest file for aname
key and store the result inFOUNDGAMETITLE
again.FOUNDGAMETITLE
is once again still blank, and if we have Steam Shortcuts that we have enabled searching on (SEARCHSTEAMSHORTCUTS
), then searchshortcuts.vdf
for the Game Title. If we get a match, store the Game Title for this shortcut entry inFOUNDGAMETITLE
FOUNDGAMETITLE
is still empty, display that no game is found.To me, this is much more logical and also easier to read.
This PR needs a bit more testing before merging. We need to test that game names are still displayed correctly on the Game Menu, and ensure that any parts of the code that use
getTitleFromID
still function correctly. I tested quickly withgetExe
and it still works correctly.