diff --git a/steamtinkerlaunch b/steamtinkerlaunch index c5fa2c4a..8b8139cd 100755 --- a/steamtinkerlaunch +++ b/steamtinkerlaunch @@ -6,7 +6,7 @@ PREFIX="/usr" PROGNAME="SteamTinkerLaunch" NICEPROGNAME="Steam Tinker Launch" -PROGVERS="v14.0.20231108-4" +PROGVERS="v14.0.20231109-1" PROGCMD="${0##*/}" PROGINTERNALPROTNAME="Proton-stl" SHOSTL="stl" @@ -7948,6 +7948,8 @@ function getValueFromAppManifest { # Returns game install directory in the format "Game (AppID) -> /path/to/gamefolder" function getGameDir { ONLYPATH="$2" + SEARCHSTEAMSHORTCUTS="${3:-0}" # Default to not searching Steam shortcuts + FOUNDINSTEAMSHORTCUTS=0 if [ -z "$1" ]; then echo "A Game ID or Game Title is required as argument" @@ -7965,9 +7967,13 @@ function getGameDir { SEARCHMANIFEST="$( listAppManifests | grep -m1 "appmanifest_${SEARCHAID}.acf" )" if [ -z "$SEARCHMANIFEST" ]; then - writelog "ERROR" "${FUNCNAME[0]} - Could not find game directory for '$1' - Maybe it is not installed" - echo "Could not find game directory for '$1'" - return 1 + if [ "$SEARCHSTEAMSHORTCUTS" -eq 0 ]; then + writelog "ERROR" "${FUNCNAME[0]} - Could not find game directory for '$1' - Maybe it is not installed" + echo "Could not find game directory for '$1'" + return 1 + else + writelog "WARN" "${FUNCNAME[0]} - Could not find game directory for '$1' - Will search on Steam Shortcuts next" + fi else writelog "INFO" "${FUNCNAME[0]} - Found matching App Manifest '$SEARCHMANIFEST'" fi @@ -7975,13 +7981,42 @@ function getGameDir { writelog "INFO" "${FUNCNAME[0]} - Found matching App Manifest file for presumed entered AppID '$1' - Manifest file is '$SEARCHMANIFEST'" fi - APPMAINSTDIR="$( getValueFromAppManifest "installdir" "$SEARCHMANIFEST" )" + APPMAINSTDIR="$( getValueFromAppManifest "installdir" "$SEARCHMANIFEST" 2>/dev/null )" APPMALIBFLDR="$( dirname "$SEARCHMANIFEST" )" GAMINSTDIR="$APPMALIBFLDR/common/$APPMAINSTDIR" MUSINSTDIR="$APPMALIBFLDR/music/$APPMAINSTDIR" # Fixes a not found error for installed soundtracks + + # If still not found, optionally search Steam shortcuts + if [ ! -d "$GAMINSTDIR" ] && [ "$SEARCHSTEAMSHORTCUTS" -eq 1 ] && haveAnySteamShortcuts ; then + while read -r SCVDFE; do + SCVDFEAID="$( parseSteamShortcutEntryAppID "$SCVDFE" )" + SCVDFENAME="$( parseSteamShortcutEntryAppName "$SCVDFE" )" + SCVDFEEXE="$( parseSteamShortcutEntryExe "$SCVDFE" )" + + ## If we have a match, build a hardcoded compatdata pointing at the Steam Root compatdata dir and if it exists, return that + ## Seems like this is always where Steam generates compatdata for Non-Steam Games + ## may instead be primary drive which defaults to Steam Root, but for now looks like Steam Root is the main place, so should work most of the time + if [ "$SCVDFEAID" -eq "$1" ] 2>/dev/null || [[ ${SCVDFENAME,,} == *"${1,,}"* ]]; then + APPMAGN="${SCVDFENAME}" + APPMAAID="${SCVDFEAID}" + GAMINSTDIR="$( dirname "${SCVDFEEXE}" )" # Could still fail if EXE dir no longer exists, but edge case + + # TODO make this a function later, we use this a lot + GAMINSTDIR="${GAMINSTDIR#\"}" + GAMINSTDIR="${GAMINSTDIR%\"}" + + FOUNDINSTEAMSHORTCUTS=1 + break + fi + done <<< "$( getSteamShortcutHex )" + fi + if [ -d "$GAMINSTDIR" ] || [ -d "$MUSINSTDIR" ]; then - APPMAGN="$( getValueFromAppManifest "name" "$SEARCHMANIFEST" )" - APPMAAID="$( getValueFromAppManifest "appid" "$SEARCHMANIFEST" )" + # Don't fetch these if we found and set the information already from a Steam shortcuts + if [ "$FOUNDINSTEAMSHORTCUTS" -eq 0 ]; then + APPMAGN="$( getValueFromAppManifest "name" "$SEARCHMANIFEST" )" + APPMAAID="$( getValueFromAppManifest "appid" "$SEARCHMANIFEST" )" + fi if [ -z "$ONLYPATH" ]; then printf "%s (%s) -> %s\n" "$APPMAGN" "$APPMAAID" "$GAMINSTDIR" @@ -22044,9 +22079,9 @@ function commandline { getCompatData "$2" "1" elif [ "$1" == "getgamedir" ] || [ "$1" == "gg" ]; then if [ "$3" == "only" ]; then - getGameDir "$2" "X" + getGameDir "$2" "X" "1" else - getGameDir "$2" + getGameDir "$2" "" "1" fi elif [ "$1" == "help" ] || [ "$1" == "--help" ] || [ "$1" == "-h" ]; then howto