From 99d4f1030e0c0c3ee24d1d5809908df252eb48e6 Mon Sep 17 00:00:00 2001 From: Eamonn Rea Date: Tue, 3 Oct 2023 00:47:43 +0100 Subject: [PATCH] Add Non-Steam Game: Add Option to Find Artwork in EXE Directory (#926) --- lang/chinese.txt | 2 ++ lang/dutch.txt | 2 ++ lang/english.txt | 2 ++ lang/englishUK.txt | 2 ++ lang/french.txt | 2 ++ lang/german.txt | 2 ++ lang/italian.txt | 2 ++ lang/polish.txt | 2 ++ lang/russian.txt | 2 ++ steamtinkerlaunch | 63 ++++++++++++++++++++++++++++++++++++++-------- 10 files changed, 70 insertions(+), 11 deletions(-) diff --git a/lang/chinese.txt b/lang/chinese.txt index 4a58a28c..dcf35eb2 100644 --- a/lang/chinese.txt +++ b/lang/chinese.txt @@ -1235,3 +1235,5 @@ DESC_RSSPEKVERS="Version of ReShade to use when installing ReShade as a SpecialK GUI_USERESHSPEKPLUGIN="Load ReShade as SpecialK Plugin" DESC_USERESHSPEKPLUGIN="copy ReShade DLLs without renaming them and let SpecialK manage loading them - If disabled, ReShade will be loaded by the game instead of SpecialK and will IGNORE any Global SpecialK ReShade Override Version, which may be more desirable in some cases" NOTY_RESHADEINSTALLING="Installing ReShade..." +GUI_NOSTGEXEARTWORKFALLBACK="Search EXE Directory for Fallback Artwork" +DESC_NOSTGEXEARTWORKFALLBACK="Look for image files named 'hero', 'logo', 'boxart', and 'tenfoot' in the same folder as the game executable, and use this for game artwork if no artwork is selected above - This will respect the chosen copy method option above" diff --git a/lang/dutch.txt b/lang/dutch.txt index 2669373a..f37169d4 100644 --- a/lang/dutch.txt +++ b/lang/dutch.txt @@ -1234,3 +1234,5 @@ DESC_RSSPEKVERS="Version of ReShade to use when installing ReShade as a SpecialK GUI_USERESHSPEKPLUGIN="Load ReShade as SpecialK Plugin" DESC_USERESHSPEKPLUGIN="copy ReShade DLLs without renaming them and let SpecialK manage loading them - If disabled, ReShade will be loaded by the game instead of SpecialK and will IGNORE any Global SpecialK ReShade Override Version, which may be more desirable in some cases" NOTY_RESHADEINSTALLING="Installing ReShade..." +GUI_NOSTGEXEARTWORKFALLBACK="Search EXE Directory for Fallback Artwork" +DESC_NOSTGEXEARTWORKFALLBACK="Look for image files named 'hero', 'logo', 'boxart', and 'tenfoot' in the same folder as the game executable, and use this for game artwork if no artwork is selected above - This will respect the chosen copy method option above" diff --git a/lang/english.txt b/lang/english.txt index 96fdc1ec..5a43f9bc 100644 --- a/lang/english.txt +++ b/lang/english.txt @@ -1235,3 +1235,5 @@ DESC_RSSPEKVERS="Version of ReShade to use when installing ReShade as a SpecialK GUI_USERESHSPEKPLUGIN="Load ReShade as SpecialK Plugin" DESC_USERESHSPEKPLUGIN="copy ReShade DLLs without renaming them and let SpecialK manage loading them - If disabled, ReShade will be loaded by the game instead of SpecialK and will IGNORE any Global SpecialK ReShade Override Version, which may be more desirable in some cases" NOTY_RESHADEINSTALLING="Installing ReShade..." +GUI_NOSTGEXEARTWORKFALLBACK="Search EXE Directory for Fallback Artwork" +DESC_NOSTGEXEARTWORKFALLBACK="Look for image files named 'hero', 'logo', 'boxart', and 'tenfoot' in the same folder as the game executable, and use this for game artwork if no artwork is selected above - This will respect the chosen copy method option above" diff --git a/lang/englishUK.txt b/lang/englishUK.txt index 38a988e3..17f41a9f 100644 --- a/lang/englishUK.txt +++ b/lang/englishUK.txt @@ -1234,3 +1234,5 @@ DESC_RSSPEKVERS="Version of ReShade to use when installing ReShade as a SpecialK GUI_USERESHSPEKPLUGIN="Load ReShade as SpecialK Plugin" DESC_USERESHSPEKPLUGIN="copy ReShade DLLs without renaming them and let SpecialK manage loading them - If disabled, ReShade will be loaded by the game instead of SpecialK and will IGNORE any Global SpecialK ReShade Override Version, which may be more desirable in some cases" NOTY_RESHADEINSTALLING="Installing ReShade..." +GUI_NOSTGEXEARTWORKFALLBACK="Search EXE Directory for Fallback Artwork" +DESC_NOSTGEXEARTWORKFALLBACK="Look for image files named 'hero', 'logo', 'boxart', and 'tenfoot' in the same folder as the game executable, and use this for game artwork if no artwork is selected above - This will respect the chosen copy method option above" diff --git a/lang/french.txt b/lang/french.txt index ac64421b..f0e3d100 100644 --- a/lang/french.txt +++ b/lang/french.txt @@ -1233,3 +1233,5 @@ DESC_RSSPEKVERS="Version of ReShade to use when installing ReShade as a SpecialK GUI_USERESHSPEKPLUGIN="Load ReShade as SpecialK Plugin" DESC_USERESHSPEKPLUGIN="copy ReShade DLLs without renaming them and let SpecialK manage loading them - If disabled, ReShade will be loaded by the game instead of SpecialK and will IGNORE any Global SpecialK ReShade Override Version, which may be more desirable in some cases" NOTY_RESHADEINSTALLING="Installing ReShade..." +GUI_NOSTGEXEARTWORKFALLBACK="Search EXE Directory for Fallback Artwork" +DESC_NOSTGEXEARTWORKFALLBACK="Look for image files named 'hero', 'logo', 'boxart', and 'tenfoot' in the same folder as the game executable, and use this for game artwork if no artwork is selected above - This will respect the chosen copy method option above" diff --git a/lang/german.txt b/lang/german.txt index 2a6ebcad..bff80886 100644 --- a/lang/german.txt +++ b/lang/german.txt @@ -1236,3 +1236,5 @@ DESC_RSSPEKVERS="Version of ReShade to use when installing ReShade as a SpecialK GUI_USERESHSPEKPLUGIN="Load ReShade as SpecialK Plugin" DESC_USERESHSPEKPLUGIN="copy ReShade DLLs without renaming them and let SpecialK manage loading them - If disabled, ReShade will be loaded by the game instead of SpecialK and will IGNORE any Global SpecialK ReShade Override Version, which may be more desirable in some cases" NOTY_RESHADEINSTALLING="Installing ReShade..." +GUI_NOSTGEXEARTWORKFALLBACK="Search EXE Directory for Fallback Artwork" +DESC_NOSTGEXEARTWORKFALLBACK="Look for image files named 'hero', 'logo', 'boxart', and 'tenfoot' in the same folder as the game executable, and use this for game artwork if no artwork is selected above - This will respect the chosen copy method option above" diff --git a/lang/italian.txt b/lang/italian.txt index e2d7d9d7..3b255c91 100644 --- a/lang/italian.txt +++ b/lang/italian.txt @@ -1234,3 +1234,5 @@ DESC_RSSPEKVERS="Version of ReShade to use when installing ReShade as a SpecialK GUI_USERESHSPEKPLUGIN="Load ReShade as SpecialK Plugin" DESC_USERESHSPEKPLUGIN="copy ReShade DLLs without renaming them and let SpecialK manage loading them - If disabled, ReShade will be loaded by the game instead of SpecialK and will IGNORE any Global SpecialK ReShade Override Version, which may be more desirable in some cases" NOTY_RESHADEINSTALLING="Installing ReShade..." +GUI_NOSTGEXEARTWORKFALLBACK="Search EXE Directory for Fallback Artwork" +DESC_NOSTGEXEARTWORKFALLBACK="Look for image files named 'hero', 'logo', 'boxart', and 'tenfoot' in the same folder as the game executable, and use this for game artwork if no artwork is selected above - This will respect the chosen copy method option above" diff --git a/lang/polish.txt b/lang/polish.txt index 4631b9ea..5b963713 100644 --- a/lang/polish.txt +++ b/lang/polish.txt @@ -1234,3 +1234,5 @@ DESC_RSSPEKVERS="Version of ReShade to use when installing ReShade as a SpecialK GUI_USERESHSPEKPLUGIN="Load ReShade as SpecialK Plugin" DESC_USERESHSPEKPLUGIN="copy ReShade DLLs without renaming them and let SpecialK manage loading them - If disabled, ReShade will be loaded by the game instead of SpecialK and will IGNORE any Global SpecialK ReShade Override Version, which may be more desirable in some cases" NOTY_RESHADEINSTALLING="Installing ReShade..." +GUI_NOSTGEXEARTWORKFALLBACK="Search EXE Directory for Fallback Artwork" +DESC_NOSTGEXEARTWORKFALLBACK="Look for image files named 'hero', 'logo', 'boxart', and 'tenfoot' in the same folder as the game executable, and use this for game artwork if no artwork is selected above - This will respect the chosen copy method option above" diff --git a/lang/russian.txt b/lang/russian.txt index 983fdcf7..71e7842d 100644 --- a/lang/russian.txt +++ b/lang/russian.txt @@ -1234,3 +1234,5 @@ DESC_RSSPEKVERS="Version of ReShade to use when installing ReShade as a SpecialK GUI_USERESHSPEKPLUGIN="Load ReShade as SpecialK Plugin" DESC_USERESHSPEKPLUGIN="copy ReShade DLLs without renaming them and let SpecialK manage loading them - If disabled, ReShade will be loaded by the game instead of SpecialK and will IGNORE any Global SpecialK ReShade Override Version, which may be more desirable in some cases" NOTY_RESHADEINSTALLING="Installing ReShade..." +GUI_NOSTGEXEARTWORKFALLBACK="Search EXE Directory for Fallback Artwork" +DESC_NOSTGEXEARTWORKFALLBACK="Look for image files named 'hero', 'logo', 'boxart', and 'tenfoot' in the same folder as the game executable, and use this for game artwork if no artwork is selected above - This will respect the chosen copy method option above" diff --git a/steamtinkerlaunch b/steamtinkerlaunch index 9f2da513..d785205f 100755 --- a/steamtinkerlaunch +++ b/steamtinkerlaunch @@ -6,7 +6,7 @@ PREFIX="/usr" PROGNAME="SteamTinkerLaunch" NICEPROGNAME="Steam Tinker Launch" -PROGVERS="v14.0.20230928-1" +PROGVERS="v14.0.20231003-1" PROGCMD="${0##*/}" PROGINTERNALPROTNAME="Proton-stl" SHOSTL="stl" @@ -22790,6 +22790,7 @@ function addNonSteamGameGui { --field=" $GUI_SGABOXART!$DESC_SGABOXART ('NOSTGBOXART')":FL "${NOSTGBOXART/#-/ -}" \ --field=" $GUI_SGATENFOOT!$DESC_SGATENFOOT ('NOSTGTENFOOT')":FL "${NOSTGTENFOOT/#-/ -}" \ --field=" $GUI_SGASETACTION!$DESC_SGASETACTION ('NOSTGSETACTION')":CB "$( cleanDropDown "copy" "$SGASETACTIONS" )" \ + --field=" $GUI_NOSTGEXEARTWORKFALLBACK!$DESC_NOSTGEXEARTWORKFALLBACK ('NOSTGEXEARTWORKFALLBACK')":CHK "${NOSTGEXEARTWORKFALLBACK/#-/ -}" \ --field="$(spanFont "$GUI_NOSTGPROPS" "H")":LBL " " \ --field=" $GUI_NOSTGCOMPATTOOL!$DESC_NOSTGCOMPATTOOL ('NOSTCOMPATTOOL')":CBE "$( cleanDropDown "$NON" "$NSGPROTYADLIST" )" \ --field=" $GUI_NOSTGLAOP!$DESC_NOSTGLAOP ('NOSTGLAOP')" "${NOSTGLAOP/#-/ -}" \ @@ -22824,23 +22825,29 @@ function addNonSteamGameGui { NOSTGBOXART="${NSGSETARR[9]}" NOSTGTENFOOT="${NSGSETARR[10]}" NOSTGSETACTION="${NSGSETARR[11]}" - # NSGSETARR[12] is Properties heading - NOSTCOMPATTOOL="${NSGSETARR[13]}" - NOSTGLAOP="${NSGSETARR[14]}" - NOSTTAGS="${NSGSETARR[15]}" - NOSTGHIDE="$( retBool "${NSGSETARR[16]}" )" - NOSTGADC="$( retBool "${NSGSETARR[17]}" )" - NOSTGAO="$( retBool "${NSGSETARR[18]}" )" - NOSTGVR="$( retBool "${NSGSETARR[19]}" )" + NOSTGEXEARTWORKFALLBACK="$( retBool "${NSGSETARR[12]}" )" + # NSGSETARR[13] is Properties heading + NOSTCOMPATTOOL="${NSGSETARR[14]}" + NOSTGLAOP="${NSGSETARR[15]}" + NOSTTAGS="${NSGSETARR[16]}" + NOSTGHIDE="$( retBool "${NSGSETARR[17]}" )" + NOSTGADC="$( retBool "${NSGSETARR[18]}" )" + NOSTGAO="$( retBool "${NSGSETARR[19]}" )" + NOSTGVR="$( retBool "${NSGSETARR[20]}" )" ## Makes sure we ignore none compatibility tool if [[ "$NOSTCOMPATTOOL" = "$NON" ]]; then NOSTCOMPATTOOL="" fi + NOSTARTEXECMD="" # This dummy command does nothing + if [ "$NOSTGEXEARTWORKFALLBACK" -eq 1 ]; then + NOSTARTEXECMD="--auto-artwork" + fi + ## Arguments here like -hr, -lg, etc are made to match setGameArt - writelog "INFO" "${FUNCNAME[0]} - addNonSteamGame -an=\"$NOSTGAPPNAME\" -ep=\"$NOSTGEXEPATH\" -sd=\"$NOSTGSTDIR\" -ip=\"$NOSTGICONPATH\" -lo=\"$NOSTGLAOP\" -hd=\"$NOSTGHIDE\" -adc=\"$NOSTGADC\" -ao=\"$NOSTGAO\" -vr=\"$NOSTGVR\" -t=\"$NOSTTAGS\" -ct=\"$NOSTCOMPATTOOL\" -hr=\"$NOSTGHERO\" -lg=\"$NOSTGLOGO\" -ba=\"$NOSTGBOXART\" -tf=\"$NOSTGTENFOOT\" \"--${NOSTGSETACTION}\"" - addNonSteamGame -an="$NOSTGAPPNAME" -ep="$NOSTGEXEPATH" -sd="$NOSTGSTDIR" -ip="$NOSTGICONPATH" -lo="$NOSTGLAOP" -hd="$NOSTGHIDE" -adc="$NOSTGADC" -ao="$NOSTGAO" -vr="$NOSTGVR" -t="$NOSTTAGS" -ct="$NOSTCOMPATTOOL" -hr="$NOSTGHERO" -lg="$NOSTGLOGO" -ba="$NOSTGBOXART" -tf="$NOSTGTENFOOT" "--${NOSTGSETACTION}" + writelog "INFO" "${FUNCNAME[0]} - addNonSteamGame -an=\"$NOSTGAPPNAME\" -ep=\"$NOSTGEXEPATH\" -sd=\"$NOSTGSTDIR\" -ip=\"$NOSTGICONPATH\" -lo=\"$NOSTGLAOP\" -hd=\"$NOSTGHIDE\" -adc=\"$NOSTGADC\" -ao=\"$NOSTGAO\" -vr=\"$NOSTGVR\" -t=\"$NOSTTAGS\" -ct=\"$NOSTCOMPATTOOL\" -hr=\"$NOSTGHERO\" -lg=\"$NOSTGLOGO\" -ba=\"$NOSTGBOXART\" -tf=\"$NOSTGTENFOOT\" \"--${NOSTGSETACTION}\" \"$NOSTARTEXECMD\"" + addNonSteamGame -an="$NOSTGAPPNAME" -ep="$NOSTGEXEPATH" -sd="$NOSTGSTDIR" -ip="$NOSTGICONPATH" -lo="$NOSTGLAOP" -hd="$NOSTGHIDE" -adc="$NOSTGADC" -ao="$NOSTGAO" -vr="$NOSTGVR" -t="$NOSTTAGS" -ct="$NOSTCOMPATTOOL" -hr="$NOSTGHERO" -lg="$NOSTGLOGO" -ba="$NOSTGBOXART" -tf="$NOSTGTENFOOT" "--${NOSTGSETACTION}" "$NOSTARTEXECMD" fi ;; esac @@ -22915,11 +22922,27 @@ function addNonSteamGame { done } + ## Return first image file matching passed name (i.e "hero") in game EXE dir + ## Used to find named artwork files in the game EXE folder for Non-Steam Games as a fallback if no artwork is provided + function findGameArtInExeDir { + NOSTSEARCHDIR="$1" + NOSTARTFILENAME="${2%%.*}" # e.x. "hero", "logo" + NOSTORGFILENAME="${3}" # Used to return in case no artwork is found, so the original name is used as a fallback + + NOSTFOUNDARTWORK="$( realpath "$( find "$NOSTSEARCHDIR" -name "$NOSTARTFILENAME.*" | head -n1 )" 2>/dev/null )" + if grep -q "image data" <<< "$( file "$NOSTFOUNDARTWORK" )"; then + echo "$NOSTFOUNDARTWORK" + else + echo "$NOSTORGFILENAME" + fi + } + NOSTHIDE=0 # Does hide still work? Didn't seem to in my tests NOSTADC=1 NOSTAO=1 NOSTVR=0 NOSTSTLLO=0 + NOSTAUTOARTWORK=0 for i in "$@"; do case $i in @@ -22998,6 +23021,9 @@ function addNonSteamGame { -tf=*|--tenfoot=*) NOSTGTENFOOT="${i#*=}" # .png -- Used as small boxart for e.g. most recently played banner shift ;; + --auto-artwork) + NOSTAUTOARTWORK=1 # Look for artwork with matching names from game EXE folder (hero/logo/boxart/tenfoot.png/jpg/jpeg/gif) + shift ;; ## Used to pass to setGameArt to define how we want to set game artwork (essentially giving a Non-Steam Game UI the functionality of setGameArt since we call it here anyway) --copy) SGACOPYMETHOD="--copy" # Copy file to grid folder -- Default @@ -23063,6 +23089,7 @@ function addNonSteamGame { writelog "INFO" "${FUNCNAME[0]} - Boxart Artwork: '${NOSTGBOXART}'" writelog "INFO" "${FUNCNAME[0]} - Tenfoot Artwork: '${NOSTGTENFOOT}'" writelog "INFO" "${FUNCNAME[0]} - Copy Method for Artwork: '${SGACOPYMETHOD}'" + writelog "INFO" "${FUNCNAME[0]} - EXE Dir Fallback Artwork: '${NOSTGEXEARTWORKFALLBACK}'" if [ -f "$SCPATH" ]; then writelog "INFO" "${FUNCNAME[0]} - The file '$SCPATH' already exists, creating a backup, then removing the 2 closing backslashes at the end" @@ -23077,6 +23104,20 @@ function addNonSteamGame { NEWSET=0 fi + # Match any image file in same folder as EXE name hero, logo, boxart, tenfoot + # Matches will override selected options + # If not found it will fall back to the selected value (such as the actual file path provided), meaning + # only artwork that exists will be used + if [ "$NOSTAUTOARTWORK" -eq 1 ]; then + NOSTEXEBASEDIR="$( dirname "$NOSTEXEPATH" | cut -d '"' -f2 )" + + NOSTGHERO="$( findGameArtInExeDir "$NOSTEXEBASEDIR" "hero" "$NOSTGHERO" )" + NOSTGLOGO="$( findGameArtInExeDir "$NOSTEXEBASEDIR" "logo" "$NOSTGLOGO" )" + NOSTGBOXART="$( findGameArtInExeDir "$NOSTEXEBASEDIR" "boxart" "$NOSTGBOXART" )" + NOSTGTENFOOT="$( findGameArtInExeDir "$NOSTEXEBASEDIR" "tenfoot" "$NOSTGTENFOOT" )" + NOSTICONPATH="$( findGameArtInExeDir "$NOSTEXEBASEDIR" "icon" "$NOSTICONPATH" )" + fi + writelog "INFO" "${FUNCNAME[0]} - Adding new set '$NEWSET'" ## TODO refactor to use a function for generating each line to write out, it would be a bit cleaner than this