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

Add Non-Steam Game: Add Option To Select Compatibility Tool #908

Merged
merged 19 commits into from
Sep 18, 2023
Merged
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
9b8e4b8
Add Non-Steam Game: Add text-based VDF interaction functions
sonic2kk Sep 16, 2023
0035b85
Add Non-Steam Game: Initial skeleton UI for selecting compatibility tool
sonic2kk Sep 16, 2023
2a5716a
Add Non-Steam Game: More UI work for Non-Steam Game Compatibility Tool
sonic2kk Sep 16, 2023
c0e36f1
Add Non-Steam Game: Initial logic for writing out chosen compat tool …
sonic2kk Sep 16, 2023
0ee7690
Add Non-Steam Game: Logging and checks/catches before writing out the…
sonic2kk Sep 16, 2023
f8c3405
Add Non-Steam Game: Update helpscreen
sonic2kk Sep 17, 2023
1b38d31
Add Non-Steam Game: Add more logging
sonic2kk Sep 17, 2023
2659483
Add Non-Steam Game: Get Internal Compatibility Tool Name from Proton …
sonic2kk Sep 17, 2023
272d908
Add Non-Steam Game: Display Compatibility Tools Accessible To Steam O…
sonic2kk Sep 17, 2023
a19b3a6
Add Non-Steam Game: Use NOSTCOMPATTOOLNAME as compatibility tool inte…
sonic2kk Sep 17, 2023
a3c1565
shellcheck fixes
sonic2kk Sep 17, 2023
5deab47
Add Non-Steam Game: Add logic to back up VDF file before writing out …
sonic2kk Sep 17, 2023
0649afb
Add Non-Steam Game: Use combobox entry for compatibility tool dropdown
sonic2kk Sep 17, 2023
49d7af0
update langfiles
sonic2kk Sep 17, 2023
50308e2
update langfiles with note to close the Steam client beforehand
sonic2kk Sep 17, 2023
9b38c42
minor ui fix
sonic2kk Sep 17, 2023
254ebad
Add Non-Steam Game: Add option to use the default Steam Compatibility…
sonic2kk Sep 17, 2023
69dca58
Add Non-Steam Game: update helpscreen
sonic2kk Sep 18, 2023
f513d4b
version bump
sonic2kk Sep 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 121 additions & 2 deletions steamtinkerlaunch
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
PREFIX="/usr"
PROGNAME="SteamTinkerLaunch"
NICEPROGNAME="Steam Tinker Launch"
PROGVERS="v14.0.20230917-3 (nonsteam-setcompattool)"
PROGVERS="v14.0.20230918-1 (nonsteam-setcompattool)"
PROGCMD="${0##*/}"
PROGINTERNALPROTNAME="Proton-stl"
SHOSTL="stl"
GHURL="https://github.com"
AGHURL="https://api.github.com"
Expand Down Expand Up @@ -2384,6 +2385,110 @@ function fillProtonCSV {
fi
}

## Get internal name for a Proton version, first by checking for a 'compatibilitytool.vdf' file in its root directory, then for a Proton version file
## Right now this is only used by addNonSteamGame
## TODO at some point maybe we should store this in the ProtonCSV as well? Then the format would be 'versionfilename;protonpath;internalname'
function getProtonInternalName {
## Tools are not necessarily guaranteed to have this comment, but I checked several and they all had it:
## - SteamTinkerLaunch (naturally)
## - All GE-Proton8 releases
## - Standard Proton-tkg releases
## - Luxtorpeda
##
## Steam Linux Runtime 1.0 (scout) / Native Linux Steam Linux Runtime is identified as 'steamlinuxruntime'
## No idea where the Steam Client gets this from, maybe it's just hardcoded, I couldn't find a string anywhere in the SteamLinuxRuntime installation folder or the 'appmanifest_1070560.acf'
function getProtonInternalNameVdf {
CTVPATH="$1"
if [ -f "$CTVPATH" ]; then
grep -i "// internal" "$CTVPATH" | sed 's-// Internal name of this tool--' | xargs
else
writelog "WARN" "${FUNCNAME[0]} - Could not find compatibilitytool.vdf file for Proton version at '$CTVPATH'"
echo ""
fi
}

## Get the Proton version version text file
function getProtonInternalNameVersionFile {
PPVPATH="$1"
if [ -f "$PPV" ]; then
awk '{print $2}' < "$PPV"
else
writelog "WARN" "${FUNCNAME[0]} - Could not find Proton version file at '$PPVPATH'"
fi
}

## Check if the path provided is for a Valve Proton version, by making some assumptions around the directory structure
function checkIsValveProton {
VPP="$1" # Valve Proton Path

writelog "INFO" "${FUNCNAME[0]} - Checking if Proton version at '$VPP' is a Valve Proton version"
if [ -d "$VPP/dist" ] && [ ! -f "$VPP/$CTVDF" ]; then
writelog "INFO" "${FUNCNAME[0]} - Looks like we have a Valve Proton release here"
return 0
else
writelog "INFO" "${FUNCNAME[0]} - Doesn't look like a Valve Proton release, no 'dist' folder in the Proton path and we have a '$CTVDF'"
sonic2kk marked this conversation as resolved.
Show resolved Hide resolved
return 1
fi
}

## Build the Valve Proton internal name based on its version + some hardcoding for Experimental and Hotfix
function getValveProtonInternalName {
BASEPRTNAM="$1"
INTPROTNAM="proton_"
FINALINTPROTNAM=""

writelog "INFO" "${FUNCNAME[0]} - Building Proton version internal name using version information"
PRTVERS="$( echo "${BASEPRTNAM%-*}" | cut -d '-' -f2 )" # Turn proton-8.0-3c into proton-8.0, then into 8.0

PRTMAJORVERS="$( echo "$PRTVERS" | cut -d '.' -f1 )" # Get minor version e.g. '8' from '8.0', '4' from '4.11'
PRTMINORVERS="$( echo "$PRTVERS" | cut -d '.' -f2 )" # Get minor version e.g. '0' from '8.0', '11' from '4.11'

## If minor vers > 0, we need to include it in the internal name -- Defaults to just major version
INTPROTVERSUFFIX="${PRTMAJORVERS}"
if [ "$PRTMINORVERS" -gt 0 ]; then
INTPROTVERSUFFIX+="${PRTMINORVERS}"
fi

FINALINTPROTNAM="${INTPROTNAM}${INTPROTVERSUFFIX}"

writelog "INFO" "${FUNCNAME[0]} - Final Internal Proton name for given Proton name '$BASEPRTNAM' string is '$FINALINTPROTNAM'"
echo "$FINALINTPROTNAM"
}

PROTCSVSTR="$1"

PRTVERS="$( echo "$PROTCSVSTR" | cut -d ';' -f1 )"
PRTPATH="$( echo "$PROTCSVSTR" | cut -d ';' -f2 )"
PRTPATHDIR="$( dirname "$PRTPATH" )"

CTVDFPA="$PRTPATHDIR/$CTVDF"
PPV="$PRTPATHDIR/version"

INTPROTNAME="$( getProtonInternalNameVdf "$CTVDFPA" )" # First attempt to get the internal name from compatibilitytool.vdf
if [ -n "$INTPROTNAME" ]; then
writelog "INFO" "${FUNCNAME[0]} - Got Proton Internal name '$INTPROTNAME' from '$CTVDFPA'"
echo "$INTPROTNAME"
elif [[ $PRTVERS == experimental* ]]; then # Experimental hardcode
writelog "INFO" "${FUNCNAME[0]} - Looks like we have Proton Experimental -- Hardcoding internal name 'proton_experimental'"
echo "proton_experimental"
elif [[ $PRTVERS == hotfix* ]]; then # Hotfix hardcode
writelog "INFO" "${FUNCNAME[0]} - Looks like we have Proton Hotfix here -- Hardcoding internal name to 'proton_hotfix'"
echo "proton_hotfix"
else
writelog "INFO" "${FUNCNAME[0]} - Could not get internal Proton name for '$PRTVERS' from '$CTVDF' - Maybe it didn't have this file"
writelog "INFO" "${FUNCNAME[0]} - Checking if we have a Valve Proton version here to build the internal name from"

if checkIsValveProton "$PRTPATHDIR"; then
writelog "INFO" "${FUNCNAME[0]} - Seems we have a Valve Proton version, building internal name manually"
getValveProtonInternalName "$PRTVERS"
else
writelog "INFO" "${FUNCNAME[0]} - Doesn't seem like we have a Valve Proton version"
writelog "INFO" "${FUNCNAME[0]} - Still could not find Proton internal name from '$CTVDF' - Giving up and falling back to the Proton version, some tools use this as their internal name"
echo "$PRTVERS"
fi
fi
}

function printProtonArr {
printf "%s\n" "${ProtonCSV[@]//\"/}"
}
Expand Down Expand Up @@ -22262,6 +22367,20 @@ function addNonSteamGameGui {
NOSTGSTDIR="${NOSTGEXEPATH%/*}"
fi

## Generate list of internal Proton names
## TODO in future, store this in ProtonCSV?
INTPROTNAMSARR=("$NON")
for PROTVERNAM in "${ProtonCSV[@]}"; do
INTPROTNAMSARR+=("$( getProtonInternalName "$PROTVERNAM" )")
done

# These two have to be hardcoded
INTPROTNAMSARR+=("steamlinuxruntime") # Native Steam Linux Runtime
INTPROTNAMSARR+=("$PROGINTERNALPROTNAME") # SteamTinkerLaunch as compat tool

# Create '!' delimited string
INTPROTNAMS="$(printf "!%s\n" "${INTPROTNAMSARR[@]//\"/}" | sort -u | cut -d ';' -f1 | tr -d '\n' | sed "s:^!::" | sed "s:!$::")"

# icon default
if grep -q "^NOSTEAMSTLDEF=\"1\"" "$STLDEFGLOBALCFG"; then
NOSTGICONPATH="$STLICON"
Expand Down Expand Up @@ -22303,7 +22422,7 @@ function addNonSteamGameGui {
--field=" $GUI_SGATENFOOT!$DESC_SGATENFOOT ('NOSTGTENFOOT')":FL "${NOSTGTENFOOT/#-/ -}" \
--field=" $GUI_SGASETACTION!$DESC_SGASETACTION ('NOSTGSETACTION')":CB "$( cleanDropDown "copy" "$SGASETACTIONS" )" \
--field="$(spanFont "$GUI_NOSTGPROPS" "H")":LBL " " \
--field=" $GUI_NOSTGCOMPATTOOL!$DESC_NOSTGCOMPATTOOL ('NOSTCOMPATTOOL')":CB "$( cleanDropDown "$NON" "$NON!Proton-stl!proton_8!proton_7" )" \
--field=" $GUI_NOSTGCOMPATTOOL!$DESC_NOSTGCOMPATTOOL ('NOSTCOMPATTOOL')":CB "$( cleanDropDown "$NON" "$INTPROTNAMS" )" \
--field=" $GUI_NOSTGLAOP!$DESC_NOSTGLAOP ('NOSTGLAOP')" "${NOSTGLAOP/#-/ -}" \
--field=" $GUI_NOSTTAGS!$DESC_NOSTTAGS ('NOSTTAGS')":CBE "$(cleanDropDown "${NOSTTAGS/#-/ -}" "$VALIDTAGS")" \
--field=" $GUI_NOSTGHIDE!$DESC_NOSTGHIDE ('NOSTGHIDE')":CHK "${NOSTGHIDE/#-/ -}" \
Expand Down