Skip to content

Commit

Permalink
Implemented kill and askkill for TDF_MULTIPLE_INSTANCES
Browse files Browse the repository at this point in the history
  • Loading branch information
adolfintel committed Dec 27, 2024
1 parent 9969d90 commit f73fe7e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ Possible values:
* `askcmd` (default): don't launch the game but ask the user if they want to launch a command prompt in the running instance
* `cmd`: same as `askcmd` but without asking first
* `allow`: allow multiple instances of the game to be running at the same time (generally a bad idea)
* `kill`: terminate previous instance and start a new one
* `askkill` : ask the user if they want to terminate the previous instance and start a new one or exit

__`TDF_IGNORE_EXIST_CHECKS`__
By default, TDF checks whether the executable specified in `game_exe` actually exists before trying to launch it, but this is not always desirable and can be disabled, which can be useful to run certain commands.
Expand Down
1 change: 1 addition & 0 deletions template-base/system/localization/en.conf
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ TDF_LOCALE_WINE_WINVER_INVALID='Invalid TDF_LOCALE_WINE_WINVER. Valid values are
TDF_LOCALE_WINE_THEME_NOTFOUND='Theme not found, check TDF_WINE_THEME in your configuration'
TDF_LOCALE_ALREADYRUNNING_ERROR='This application is already running'
TDF_LOCALE_ALREADYRUNNING_ASKCMD='This wineprefix is already running.\nOpen a command prompt inside it?'
TDF_LOCALE_ALREADYRUNNING_ASKKILL='This wineprefix is already running.\nDo you want to KILL WINE AND RESTART IT?'
TDF_LOCALE_WINE_WRONGARCH='TDF_WINE_ARCH mismatch\n\nThis wineprefix was created with $_pfxarch, but $WINEARCH was requested.\n\nTDF_WINE_ARCH cannot be changed after the wineprefix has been initialized'
TDF_LOCALE_OS_WRONGARCH='This application requires an x86_64 system'
TDF_LOCALE_OS_WRONGOS='This is a Linux application'
Expand Down
1 change: 1 addition & 0 deletions template-base/system/localization/it.conf
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ TDF_LOCALE_WINE_WINVER_INVALID='TDF_LOCALE_WINE_WINVER non valido. I valori vali
TDF_LOCALE_WINE_THEME_NOTFOUND='Tema non trovato, controlla TDF_WINE_THEME nella tua configurazione'
TDF_LOCALE_ALREADYRUNNING_ERROR='Questa applicazione è già in esecuzione'
TDF_LOCALE_ALREADYRUNNING_ASKCMD='Questo wineprefix è già in esecuzione.\nVuoi aprire un prompt dei comandi all'\''interno?'
TDF_LOCALE_ALREADYRUNNING_ASKKILL='Questo wineprefix è già in esecuzione.\nVuoi TERMINARE WINE E RIAVVIARLO?'
TDF_LOCALE_WINE_WRONGARCH='TDF_WINE_ARCH non valido\n\nQuesto wineprefix è stato creato con $_pfxarch, ma è stato richiesto $WINEARCH.\n\nTDF_WINE_ARCH non può essere cambiaro dopo l'\''inizializzazione del wineprefix'
TDF_LOCALE_OS_WRONGARCH='Questa applicazione richiede un sistema x86_64'
TDF_LOCALE_OS_WRONGOS='Questa è un'\''applicazione per Linux'
Expand Down
12 changes: 11 additions & 1 deletion template-base/system/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ game_workingDir=''
TDF_VERSION="$(cat system/version)"
TDF_TITLE="$(_loc "$TDF_LOCALE_DEFAULTTITLE")"
TDF_DETAILED_PROGRESS=1
TDF_MULTIPLE_INSTANCES="askcmd" #deny=exit without error messages, error=show an error message and close, askcmd=ask the user if they want to run cmd inside the running prefix, cmd=run command prompt inside the running prefix, allow=allow multiple instances of the game
TDF_MULTIPLE_INSTANCES="askcmd" #deny=exit without error messages, error=show an error message and close, askcmd=ask the user if they want to run cmd inside the running prefix, cmd=run command prompt inside the running prefix, allow=allow multiple instances of the game, kill=kill previous instance, askkill=ask the user if they want to kill the previous instance
TDF_IGNORE_EXIST_CHECKS=0
TDF_HIDE_GAME_RUNNING_DIALOG=0
TDF_SHOW_PLAY_TIME=0
Expand Down Expand Up @@ -1203,6 +1203,16 @@ function _tdfmain {
exit
elif [ "$TDF_MULTIPLE_INSTANCES" = "allow" ]; then
_skipInitializations=1
elif [ "$TDF_MULTIPLE_INSTANCES" = "kill" ]; then
wineserver -k -w
wait
elif [ "$TDF_MULTIPLE_INSTANCES" = "askkill" ]; then
if zenity --question --width=400 --text="$(_loc "$TDF_LOCALE_ALREADYRUNNING_ASKKILL")"; then
wineserver -k -w
wait
else
exit
fi
else
exit
fi
Expand Down
2 changes: 1 addition & 1 deletion template-base/vars.conf
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ game_exe=''
#TDF_DETAILED_PROGRESS=0 #1=Shows detailed info (for example: "Installing DXVK"). | 0=Shows only a "Launching..." message.
#TDF_HIDE_GAME_RUNNING_DIALOG=0 #1=Hide the dialog that says "Game running" while the application is running | 0=Show the dialog
#TDF_IGNORE_EXIST_CHECKS=0 #1=Skips the check that game_exe actually exists before launching the game.
#TDF_MULTIPLE_INSTANCES="askcmd" #deny=Exits without error messages. | error=Shows an error message and closes. | askcmd=Asks the user if it wants to run cmd inside the running prefix. | cmd=Runs command prompt inside the running prefix. | allow=Allows multiple instances of the game.
#TDF_MULTIPLE_INSTANCES="askcmd" #deny=Exits without error messages. | error=Shows an error message and closes. | askcmd=Asks the user if it wants to run cmd inside the running prefix. | cmd=Runs command prompt inside the running prefix. | allow=Allows multiple instances of the game | kill=Kills previous instance of the game | askkill=Asks the user if they want to kill the running instance and restart it.
#TDF_SHOW_PLAY_TIME=0 #1=Shows how long you've been playing when you close the game.

# [CALLBACKS]
Expand Down

0 comments on commit f73fe7e

Please sign in to comment.