Skip to content

Commit

Permalink
Add Non-Steam Game: Add Option to Find Artwork in EXE Directory (#926)
Browse files Browse the repository at this point in the history
  • Loading branch information
sonic2kk authored Oct 2, 2023
1 parent 85975d7 commit 99d4f10
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 11 deletions.
2 changes: 2 additions & 0 deletions lang/chinese.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 2 additions & 0 deletions lang/dutch.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 2 additions & 0 deletions lang/english.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 2 additions & 0 deletions lang/englishUK.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 2 additions & 0 deletions lang/french.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 2 additions & 0 deletions lang/german.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 2 additions & 0 deletions lang/italian.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 2 additions & 0 deletions lang/polish.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 2 additions & 0 deletions lang/russian.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
63 changes: 52 additions & 11 deletions steamtinkerlaunch
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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/#-/ -}" \
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -22998,6 +23021,9 @@ function addNonSteamGame {
-tf=*|--tenfoot=*)
NOSTGTENFOOT="${i#*=}" # <appid>.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
Expand Down Expand Up @@ -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"
Expand All @@ -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
Expand Down

0 comments on commit 99d4f10

Please sign in to comment.