Skip to content

Commit

Permalink
GameScope: Break some logic into separate function
Browse files Browse the repository at this point in the history
Created setGameScopeVars to help trim down GameScopeGui.
  • Loading branch information
sonic2kk committed Feb 15, 2023
1 parent 9bc5610 commit 5948c4a
Showing 1 changed file with 29 additions and 33 deletions.
62 changes: 29 additions & 33 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="v12.12.20230215-15 (gamescope-the-adventure-continues)"
PROGVERS="v12.12.20230215-16 (gamescope-the-adventure-continues)"
PROGCMD="${0##*/}"
SHOSTL="stl"
GHURL="https://github.com"
Expand Down Expand Up @@ -9605,13 +9605,7 @@ function checkXliveless {
fi
}

# NOTE: Logic for some options here could potentially be improved in future to avoid duplication
function GameScopeGui {

# ---
# TODO function that can replace all of the duplicated GameScope arg checks
# ---
# Untested prototype below:
function setGameScopeVars {
function getGameScopeArg {
ARGS="$1" # e.g. "$GAMESCOPE_ARGS"
UNESCAPED_FLAG="$2"
Expand All @@ -9638,6 +9632,8 @@ function GameScopeGui {
fi
}

### TODO: Replace this with `getGameScopeArg` (the "path" / "txt" check does exactly this)
#
# Gets the path passed to a flag e.g. '--cursor /home/gaben/half life 3/cursor.png'
# The other args use `tr ' ' '\n'`, but we can't use this when it comes to flags because a space in the path can cause issues
#
Expand Down Expand Up @@ -9920,45 +9916,51 @@ function GameScopeGui {
GSWAYLAND="$( getGameScopeArg "$GAMESCOPE_ARGS" "--expose-wayland" "$GSWAYLAND" "1" "0" )"
}

if [ -n "$1" ]; then
AID="$1"
setAIDCfgs
fi

if [ -n "$2" ]; then
GN="$2"
fixShowGnAid
fi

loadCfg "$STLGAMECFG"
export CURWIKI="$PPW/GameScope"
TITLE="${PROGNAME}-${FUNCNAME[0]}"
pollWinRes "$TITLE"
setShowPic
# Set storage vars
UL="unlimited"

FSRS_STR="\-\-fsr\-sharpness"

GSNORM="normal"
GSFOOROPTS="left!right!${GSNORM}!upsidedown"

GSDEF="default"
GSHOVER="hover:0"
GSLEFTCLICK="leftclick:1"
GSRIGHTCLICK="rightclick:2"
GSMIDDLECLICK="middleclick:3"
GSPASSTHRU="passthrough:4"
GSTOUCHMODES="${GSDEF}!${GSHOVER}!${GSLEFTCLICK}!${GSRIGHTCLICK}!${GSMIDDLECLICK}!${GSPASSTHRU}" # Corresponds to 0,1,2,3,4 respectively internally by GameScope -- Default is ingored and the flag is not passed to GameScope

GSDRMMODES="${GSDEF}!cvt!fixed"

# Get values for UI elements based on existing GameScope args
getGameScopeGeneralOpts
getGameScopeFilteringOpts
getGameScopeHDROpts
getGameScopeVROpts
getGameScopeEmbeddedOpts
getGameScopeAdvancedOpts
}

function GameScopeGui {
if [ -n "$1" ]; then
AID="$1"
setAIDCfgs
fi

if [ -n "$2" ]; then
GN="$2"
fixShowGnAid
fi

# Setup Yad UI stuff
loadCfg "$STLGAMECFG"
export CURWIKI="$PPW/GameScope"
TITLE="${PROGNAME}-${FUNCNAME[0]}"
pollWinRes "$TITLE"
setShowPic

# Get values for UI elements below
setGameScopeVars

# GameScope Yad options form
GASCOS="$("$YAD" --f1-action="$F1ACTION" --image "$SHOWPIC" --image-on-top --scroll --window-icon="$STLICON" --form --center --on-top $WINDECO \
--title="$TITLE" --separator="|" \
--text="$(spanFont "$(strFix "$GUI_GASCOSET" "$SGNAID")" "H")" \
Expand Down Expand Up @@ -10138,7 +10140,6 @@ function GameScopeGui {
fi
### GENERAL OPTIONS END ###


### FILTERING OPTIONS ###
if [ "$GSIS" == "TRUE" ]; then
GAMESCOPE_ARGS="${GAMESCOPE_ARGS} -i"
Expand Down Expand Up @@ -10169,7 +10170,6 @@ function GameScopeGui {
fi
## FILTERING OPTIONS END ###


### HDR OPTIONS ###
if [ "$GSHDR" == "TRUE" ]; then
# Possible to check if any HDR displays available and warn if not?
Expand Down Expand Up @@ -10209,7 +10209,6 @@ function GameScopeGui {
fi
### HDR OPTIONS END ###


### VR OPTIONS ###
if [ "$GSVR" == "TRUE" ]; then
GAMESCOPE_ARGS="${GAMESCOPE_ARGS} --openvr"
Expand Down Expand Up @@ -10250,7 +10249,6 @@ function GameScopeGui {
fi
### VR OPTIONS END


### EMBEDDED OPTIONS ###
#
# Don't pass default touch mode option if we left at default
Expand All @@ -10274,7 +10272,6 @@ function GameScopeGui {
fi
# EMBEDDED OPTIONS END


## ADVANCED OPTIONS ###
# Don't pass DRM mode if "default"
if [ ! "$GSDRMMODE" == "${GSDEF}" ]; then
Expand Down Expand Up @@ -10315,7 +10312,6 @@ function GameScopeGui {
fi
### ADVANCED OPTIONS END ###


GAMESCOPE_ARGS="${GAMESCOPE_ARGS} --"

writelog "INFO" "${FUNCNAME[0]} - Saving configured GAMESCOPE_ARGS '$GAMESCOPE_ARGS' into '$STLGAMECFG'"
Expand Down

0 comments on commit 5948c4a

Please sign in to comment.