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

Commandline: Refactor getTitleFromID to be more reliable with Non-Steam Games #1011

Merged
merged 2 commits into from
Jan 12, 2024

Conversation

sonic2kk
Copy link
Owner

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 on shortcuts.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 to shortcuts.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:

  • By default, FOUNDGAMETITLE is blank.
  • If we have a SteamTinkerLaunch metadata file, search for the game title in it and store the result in FOUNDGAMETITLE.
  • If FOUNDGAMETITLE is still blank after this, search the Steam AppManifest file for a name key and store the result in FOUNDGAMETITLE again.
  • If FOUNDGAMETITLE is once again still blank, and if we have Steam Shortcuts that we have enabled searching on (SEARCHSTEAMSHORTCUTS), then search shortcuts.vdf for the Game Title. If we get a match, store the Game Title for this shortcut entry in FOUNDGAMETITLE
    • If there are no shortcuts OR if searching on Steam Shortcuts is disabled, this step is skipped
  • If after all of this, FOUNDGAMETITLE is still empty, display that no game is found.
  • Otherwise, echo out the game title at the end of the function.

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 with getExe and it still works correctly.

@sonic2kk sonic2kk force-pushed the refactor-gettitlefromid branch from b87469f to d63e65a Compare January 12, 2024 22:49
@sonic2kk
Copy link
Owner Author

sonic2kk commented Jan 12, 2024

This seems to work fine. We will need to update usage of getTitleFromID in various places (getSteamGridDBArtworkGUI, setGameArt, fixShowGnAid) to search on Steam Shortcuts as well as currently they will not display the title for Non-Steam Games. That change will go after this PR though.

@sonic2kk
Copy link
Owner Author

Tested and this doesn't break displaying the game name on the Wait Requester/Main Menu, generating a fresh meta file also works for these games. Should be a safe merge.

@sonic2kk sonic2kk merged commit d4dc283 into master Jan 12, 2024
@sonic2kk
Copy link
Owner Author

Following this PR, fixed the mentioned functions above not pulling Non-Steam Game titles when using getTitleFromID (2fb17b8).

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.

1 participant