Skip to content

Commit

Permalink
ModOrganizer 2: Add option to change Silent Mode Executable (#1131)
Browse files Browse the repository at this point in the history
  • Loading branch information
sonic2kk authored Jun 23, 2024
1 parent 2d51012 commit f9d72ed
Show file tree
Hide file tree
Showing 10 changed files with 75 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lang/chinese.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1289,3 +1289,5 @@ GUI_STLSHMDIR="Current session logging directory"
GUI_STLPERGAMELOGSDIR="Per-game log files"
GUI_CUSTOMCMD_USESLR="Use Steam Linux Runtime with Custom Command"
DESC_CUSTOMCMD_USESLR="runs Custom Commands in the Steam Linux Runtime container that games use to improve compatibility, particularly for commands running via Proton (but it works for native commands as well). This option might get in the way of inter-process communication (i.e. an app that looks for a game process) and may be unnecessary for Linux shell scripts"
GUI_MO2SILENTMODEEXEOVERRIDE="Override ModOrganizer 2 Silent Mode Executable Configuration"
DESC_MO2SILENTMODEEXEOVERRIDE="use a different executable configuration in Silent Mode (i.e. launch 'SKSE64' instead of 'Skyrim Special Edition') -- When 'none' by default, ModOrganizer 2 will launch the configuation matching the name of the INI (i.e. Skyrim Special Edition)"
2 changes: 2 additions & 0 deletions lang/dutch.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1286,3 +1286,5 @@ GUI_STLSHMDIR="Current session logging directory"
GUI_STLPERGAMELOGSDIR="Per-game log files"
GUI_CUSTOMCMD_USESLR="Use Steam Linux Runtime with Custom Command"
DESC_CUSTOMCMD_USESLR="runs Custom Commands in the Steam Linux Runtime container that games use to improve compatibility, particularly for commands running via Proton (but it works for native commands as well). This option might get in the way of inter-process communication (i.e. an app that looks for a game process) and may be unnecessary for Linux shell scripts"
GUI_MO2SILENTMODEEXEOVERRIDE="Override ModOrganizer 2 Silent Mode Executable Configuration"
DESC_MO2SILENTMODEEXEOVERRIDE="use a different executable configuration in Silent Mode (i.e. launch 'SKSE64' instead of 'Skyrim Special Edition') -- When 'none' by default, ModOrganizer 2 will launch the configuation matching the name of the INI (i.e. Skyrim Special Edition)"
2 changes: 2 additions & 0 deletions lang/english.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1288,3 +1288,5 @@ GUI_STLSHMDIR="Current session logging directory"
GUI_STLPERGAMELOGSDIR="Per-game log files"
GUI_CUSTOMCMD_USESLR="Use Steam Linux Runtime with Custom Command"
DESC_CUSTOMCMD_USESLR="runs Custom Commands in the Steam Linux Runtime container that games use to improve compatibility, particularly for commands running via Proton (but it works for native commands as well). This option might get in the way of inter-process communication (i.e. an app that looks for a game process) and may be unnecessary for Linux shell scripts"
GUI_MO2SILENTMODEEXEOVERRIDE="Override ModOrganizer 2 Silent Mode Executable Configuration"
DESC_MO2SILENTMODEEXEOVERRIDE="use a different executable configuration in Silent Mode (i.e. launch 'SKSE64' instead of 'Skyrim Special Edition') -- When 'none' by default, ModOrganizer 2 will launch the configuation matching the name of the INI (i.e. Skyrim Special Edition)"
2 changes: 2 additions & 0 deletions lang/englishUK.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1290,3 +1290,5 @@ GUI_STLSHMDIR="Current session logging directory"
GUI_STLPERGAMELOGSDIR="Per-game log files"
GUI_CUSTOMCMD_USESLR="Use Steam Linux Runtime with Custom Command"
DESC_CUSTOMCMD_USESLR="runs Custom Commands in the Steam Linux Runtime container that games use to improve compatibility, particularly for commands running via Proton (but it works for native commands as well). This option might get in the way of inter-process communication (i.e. an app that looks for a game process) and may be unnecessary for Linux shell scripts"
GUI_MO2SILENTMODEEXEOVERRIDE="Override ModOrganizer 2 Silent Mode Executable Configuration"
DESC_MO2SILENTMODEEXEOVERRIDE="use a different executable configuration in Silent Mode (i.e. launch 'SKSE64' instead of 'Skyrim Special Edition') -- When 'none' by default, ModOrganizer 2 will launch the configuation matching the name of the INI (i.e. Skyrim Special Edition)"
2 changes: 2 additions & 0 deletions lang/french.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1287,3 +1287,5 @@ GUI_STLSHMDIR="Current session logging directory"
GUI_STLPERGAMELOGSDIR="Per-game log files"
GUI_CUSTOMCMD_USESLR="Use Steam Linux Runtime with Custom Command"
DESC_CUSTOMCMD_USESLR="runs Custom Commands in the Steam Linux Runtime container that games use to improve compatibility, particularly for commands running via Proton (but it works for native commands as well). This option might get in the way of inter-process communication (i.e. an app that looks for a game process) and may be unnecessary for Linux shell scripts"
GUI_MO2SILENTMODEEXEOVERRIDE="Override ModOrganizer 2 Silent Mode Executable Configuration"
DESC_MO2SILENTMODEEXEOVERRIDE="use a different executable configuration in Silent Mode (i.e. launch 'SKSE64' instead of 'Skyrim Special Edition') -- When 'none' by default, ModOrganizer 2 will launch the configuation matching the name of the INI (i.e. Skyrim Special Edition)"
2 changes: 2 additions & 0 deletions lang/german.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1290,3 +1290,5 @@ GUI_STLSHMDIR="Current session logging directory"
GUI_STLPERGAMELOGSDIR="Per-game log files"
GUI_CUSTOMCMD_USESLR="Use Steam Linux Runtime with Custom Command"
DESC_CUSTOMCMD_USESLR="runs Custom Commands in the Steam Linux Runtime container that games use to improve compatibility, particularly for commands running via Proton (but it works for native commands as well). This option might get in the way of inter-process communication (i.e. an app that looks for a game process) and may be unnecessary for Linux shell scripts"
GUI_MO2SILENTMODEEXEOVERRIDE="Override ModOrganizer 2 Silent Mode Executable Configuration"
DESC_MO2SILENTMODEEXEOVERRIDE="use a different executable configuration in Silent Mode (i.e. launch 'SKSE64' instead of 'Skyrim Special Edition') -- When 'none' by default, ModOrganizer 2 will launch the configuation matching the name of the INI (i.e. Skyrim Special Edition)"
2 changes: 2 additions & 0 deletions lang/italian.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1288,3 +1288,5 @@ GUI_STLSHMDIR="Current session logging directory"
GUI_STLPERGAMELOGSDIR="Per-game log files"
GUI_CUSTOMCMD_USESLR="Use Steam Linux Runtime with Custom Command"
DESC_CUSTOMCMD_USESLR="runs Custom Commands in the Steam Linux Runtime container that games use to improve compatibility, particularly for commands running via Proton (but it works for native commands as well). This option might get in the way of inter-process communication (i.e. an app that looks for a game process) and may be unnecessary for Linux shell scripts"
GUI_MO2SILENTMODEEXEOVERRIDE="Override ModOrganizer 2 Silent Mode Executable Configuration"
DESC_MO2SILENTMODEEXEOVERRIDE="use a different executable configuration in Silent Mode (i.e. launch 'SKSE64' instead of 'Skyrim Special Edition') -- When 'none' by default, ModOrganizer 2 will launch the configuation matching the name of the INI (i.e. Skyrim Special Edition)"
2 changes: 2 additions & 0 deletions lang/polish.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1288,3 +1288,5 @@ GUI_STLSHMDIR="Current session logging directory"
GUI_STLPERGAMELOGSDIR="Per-game log files"
GUI_CUSTOMCMD_USESLR="Use Steam Linux Runtime with Custom Command"
DESC_CUSTOMCMD_USESLR="runs Custom Commands in the Steam Linux Runtime container that games use to improve compatibility, particularly for commands running via Proton (but it works for native commands as well). This option might get in the way of inter-process communication (i.e. an app that looks for a game process) and may be unnecessary for Linux shell scripts"
GUI_MO2SILENTMODEEXEOVERRIDE="Override ModOrganizer 2 Silent Mode Executable Configuration"
DESC_MO2SILENTMODEEXEOVERRIDE="use a different executable configuration in Silent Mode (i.e. launch 'SKSE64' instead of 'Skyrim Special Edition') -- When 'none' by default, ModOrganizer 2 will launch the configuation matching the name of the INI (i.e. Skyrim Special Edition)"
2 changes: 2 additions & 0 deletions lang/russian.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1288,3 +1288,5 @@ GUI_STLSHMDIR="Current session logging directory"
GUI_STLPERGAMELOGSDIR="Per-game log files"
GUI_CUSTOMCMD_USESLR="Use Steam Linux Runtime with Custom Command"
DESC_CUSTOMCMD_USESLR="runs Custom Commands in the Steam Linux Runtime container that games use to improve compatibility, particularly for commands running via Proton (but it works for native commands as well). This option might get in the way of inter-process communication (i.e. an app that looks for a game process) and may be unnecessary for Linux shell scripts"
GUI_MO2SILENTMODEEXEOVERRIDE="Override ModOrganizer 2 Silent Mode Executable Configuration"
DESC_MO2SILENTMODEEXEOVERRIDE="use a different executable configuration in Silent Mode (i.e. launch 'SKSE64' instead of 'Skyrim Special Edition') -- When 'none' by default, ModOrganizer 2 will launch the configuation matching the name of the INI (i.e. Skyrim Special Edition)"
59 changes: 57 additions & 2 deletions steamtinkerlaunch
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
PREFIX="/usr"
PROGNAME="SteamTinkerLaunch"
NICEPROGNAME="Steam Tinker Launch"
PROGVERS="v14.0.20240621-1"
PROGVERS="v14.0.20240623-1"
PROGCMD="${0##*/}"
PROGINTERNALPROTNAME="Proton-stl"
SHOSTL="stl"
Expand Down Expand Up @@ -3364,6 +3364,7 @@ function setDefaultCfgValues {
if [ -z "$SORTGARGS" ] ; then SORTGARGS="0"; fi
if [ -z "$MO2MODE" ] ; then MO2MODE="disabled"; fi
if [ -z "$WAITMO2" ] ; then WAITMO2="2"; fi
if [ -z "$MO2SILENTMODEEXEOVERRIDE" ] ; then MO2SILENTMODEEXEOVERRIDE="$NON"; fi
if [ -z "$USESPECIALK" ] ; then USESPECIALK="0"; fi
if [ -z "$SPEKDLLNAME" ] ; then SPEKDLLNAME="$AUTO"; fi
if [ -z "$USERESHSPEKPLUGIN" ] ; then USERESHSPEKPLUGIN="1"; fi
Expand Down Expand Up @@ -4079,6 +4080,8 @@ function saveCfg {
echo "SORTGARGS=\"$SORTGARGS\""
echo "## $DESC_WAITMO2"
echo "WAITMO2=\"$WAITMO2\""
echo "## $DESC_MO2SILENTMODEEXEOVERRIDE"
echo "MO2SILENTMODEDESC_MO2SILENTMODEEXEOVERRIDE=\"$MO2SILENTMODEDESC_MO2SILENTMODEEXEOVERRIDE\""
echo "## $DESC_MO2MODE"
echo "MO2MODE=\"$MO2MODE\""
echo "## $DESC_USESPECIALK"
Expand Down Expand Up @@ -5970,6 +5973,7 @@ function AllSettingsEntriesDummyFunction {
--field=" $GUI_MO2CUSTOMINSTALLER!$DESC_MO2CUSTOMINSTALLER ('MO2CUSTOMINSTALLER')":FL "${MO2CUSTOMINSTALLER/#-/ -}" `#CAT_MO2` `#SUB_Directories` `#MENU_GLOBAL` \
--field=" $GUI_MO2MODE!$DESC_MO2MODE ('MO2MODE')":CB "$(cleanDropDown "${MO2MODE/#-/ -}" "disabled!gui!silent")" `#CAT_MO2` `#MENU_GAME` \
--field=" $GUI_WAITMO2!$DESC_WAITMO2 ('WAITMO2')":NUM "${WAITMO2/#-/ -}" `#CAT_MO2` `#MENU_GAME` \
--field=" $GUI_MO2SILENTMODEEXEOVERRIDE!$DESC_MO2SILENTMODEEXEOVERRIDE ('MO2SILENTMODEEXEOVERRIDE')":CBE "$(cleanDropDown "${MO2SILENTMODEEXEOVERRIDE/#-/ -}" "$MO2SILENTMODEEXEPROFILES" )" `#CAT_MO2` `#MENU_GAME` \
#ENDSETENTRIES
}

Expand Down Expand Up @@ -6365,6 +6369,7 @@ function MainMenu {
writelog "INFO" "${FUNCNAME[0]} - Preparing to load Main Menu"

createDLReShadeList
createMO2SilentModeExeProfilesList
prepareMenu "$@"

setShowPic
Expand Down Expand Up @@ -17731,6 +17736,37 @@ function prepareMO2 {
fi
}

function createMO2SilentModeExeProfilesList {
# Get all of the ModOrganizer 2 executables launch configurations in the instance's INI
# The user can use this to override which 'moshortcut://' is launched in Silent Mode
MO2SILENTMODEEXEPROFILES="$NON"
MO2GAMES="$GLOBALMISCDIR/mo2games.txt"

# Taken from manageMO2GInstance
MO2GA1="$(grep -m1 "\"$AID\"" "$MO2GAMES" | cut -d ';' -f1)"
MO2GAM="${MO2GA1//\"}"
if [ -z "$MO2GAM" ]; then
writelog "SKIP" "${FUNCNAME[0]} - Does not appear that '$AID' is a ModOrganizer 2 game, nothing to do"
return
fi

# MO2COMPDATA taken from setMO2Vars
MOIN="${MO2COMPDATA//\"/}/pfx/$DRCU/$STUS/$ADLO/$MO/${MO2GAM}/${MO}.ini"
writelog "INFO" "${FUNCNAME[0]} - MOIN is '${MOIN}'"
if [ ! -f "$MOIN" ]; then
writelog "SKIP" "${FUNCNAME[0]} - Nothing to do, ModOrganizer 2 instance INI for '$MO2GAM ($AID)' doesn't exist at '$MOIN' -- Perhaps this game has never been managed with MO2 before?"
return
fi

# Executables are stored in INI in format '1\title=Executable Name', where '1' is its position in the MO2 executable profile list
while read -r MO2EXEPROF; do
# Remove \r with Windows line encoding in INI (\n should already be removed)
MO2SILENTMODEEXEPROFILES="${MO2SILENTMODEEXEPROFILES}!${MO2EXEPROF//$'\r'/}"
done <<< "$( sed -n 's/^[0-9]\\title=//p' "$MOIN" )"

writelog "INFO" "${FUNCNAME[0]} - MO2SILENTMODEEXEPROFILES list is '${MO2SILENTMODEEXEPROFILES}'"
}

function startMO2 {
prepareMO2 "$NON" "gui"
if [ -d "${MO2EXE%/*}" ] ; then
Expand Down Expand Up @@ -20010,7 +20046,26 @@ function prepMO2 {
notiShow "$(strFix "$NOTY_NOMO" "$GN" "$AID")"
MO2MODE="gui"
else
RUNCMD=("${RUNCMD[@]}" "$MO2EXE" "moshortcut://:$MO2GAMINI")
MO2SILENTMODERUN="$MO2GAMINI" # Executable profile to use in silent mode, defaults to INI but can be overridden

# Check if MO2 Silent Mode executable has been overwritten
if [ -n "$MO2SILENTMODEEXEOVERRIDE" ] && [ "$MO2SILENTMODEEXEOVERRIDE" != "$NON" ]; then
writelog "INFO" "${FUNCNAME[0]} - Overridding ModOrganizer 2 Silent Mode shortcut with '$MO2SILENTMODEEXEOVERRIDE' because it is defined and is not '$NON'"
MO2SILENTMODERUN="$MO2SILENTMODEEXEOVERRIDE"
fi

# Run MO2 EXE with 'moshortcut://:' in for Silent Mode, as this will run a given Executable Profile
# This defaults to the Executable profile that matches the INI filename. We infer this from mo2games.txt
#
# For example, 'Oblivion' will always have 'Oblivion.ini' because we make sure we name the entries in mo2games.txt correctly,
# and MO2 will always create an Executable profile for *just* the game without its launcher (in this case, 'Oblivion'), so we can assume
# the INI name will always have a corresponding Executable profile (unless manually removed by the user, and in such a case, the override option allows them to fix that)
#
# Some games (like Skyrim Special Edition) may need to use another executable profile, like SKSE64, so a user can override this value and the command
# would become 'moshortcut://:SKSE64'
#
# If a given executable name is invalid, ModOrganizer 2 will show an error dialog stating so and will exit
RUNCMD=("${RUNCMD[@]}" "$MO2EXE" "moshortcut://:$MO2SILENTMODERUN")

writelog "INFO" "${FUNCNAME[0]} - Starting '$SGNAID' with $MO enabled mods with command '${RUNCMD[*]}'"
notiShow "$(strFix "$NOTY_STARTSIMO" "$GN" "$AID")"
Expand Down

0 comments on commit f9d72ed

Please sign in to comment.