From 82e752803759a4ff4b79a0c115a3aa623f933f18 Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Tue, 1 Sep 2020 14:39:39 -0400 Subject: [PATCH] Changed to a file based configuration system for installed games. Added donation options. --- audiogame-manager.sh | 63 ++++++++++++++++++++++++++------------------ 1 file changed, 38 insertions(+), 25 deletions(-) diff --git a/audiogame-manager.sh b/audiogame-manager.sh index 3195bfd..db46a9f 100755 --- a/audiogame-manager.sh +++ b/audiogame-manager.sh @@ -54,13 +54,7 @@ install_wine_bottle() { # Install games game_installer() { - # Find the last line of the script. - local lastLine="$(grep -n '^exit 0' $0)" - # Convert lastLine to a number andd increment it by 1. - lastLine=${lastLine%%:*} - lastLine=$((lastLine + 1)) - # An array of infromation from the end of the file, we'll parse it to make the menu. - mapfile -t installedGames < <(tail +${lastLine} "$0" | sed '/^$/d' | cut -d '|' -f3) + mapfile -t installedGames < <(sed '/^$/d' "${configFile}" 2> /dev/null | cut -d '|' -f3) # Create the menu of installed games declare -a menuList for i in "${gameList[@]}" ; do @@ -78,6 +72,8 @@ game_installer() { echo "All games are already installed." exit 0 fi + menuList+=("Make a One Time Donation" "Make a One Time Donation") + menuList+=("Become a Patron" "Become a Patron") game="$(dialog --backtitle "Audio Game Installer" \ --clear \ --no-tags \ @@ -86,13 +82,7 @@ game_installer() { # launch games that are installed game_launcher() { - # Find the last line of the script. - local lastLine="$(grep -n '^exit 0' $0)" - # Convert lastLine to a number andd increment it by 1. - lastLine=${lastLine%%:*} - lastLine=$((lastLine + 1)) - # An array of infromation from the end of the file, we'll parse it to make the menu. - mapfile -t lines < <(tail +${lastLine} "$0" | sed '/^$/d') + mapfile -t lines < <(sed '/^$/d' "${configFile}" 2> /dev/null) if [[ ${#lines} -eq 0 ]]; then echo "Install some games first." exit 0 @@ -102,16 +92,29 @@ game_launcher() { for i in "${lines[@]}" ; do menuList+=("${i%|*}" "${i##*|}") done + menuList+=("Make a One Time Donation" "Make a One Time Donation") + menuList+=("Become a Patron" "Become a Patron") local game="$(dialog --backtitle "Audio Game Launcher" \ --clear \ --no-tags \ --menu "Please select a game to play" 0 0 0 "${menuList[@]}" --stdout)" if [[ ${#game} -gt 0 ]]; then + if [[ "$game" == "Make a One Time Donation" ]]; then + xdg-open "https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=stormdragon2976@gmail.com&lc=US&item_name=Donation+to+Storm+Games&no_note=0&cn=¤cy_code=USD&bn=PP-DonationsBF:btn_donateCC_LG.gif:NonHosted" + exit 0 + fi + if [[ "$game" == "Become a Patron" ]]; then + xdg-open "https://patreon.com/stormux" + exit 0 + fi local winePath="${game#*|}" winePath="${winePath%\\*.exe}" local wineExec="${game#*|}" wineExec="${wineExec%|*}" wineExec="${wineExec##*\\}" + # kill any previous existing wineservers for this prefix in case they didn't shut down properly. + WINEPREFIX="${HOME}/.local/wine/${game%|*}" wineserver -k + # launch the game WINEPREFIX="${HOME}/.local/wine/${game%|*}" wine start /d "${winePath}" "$wineExec" fi exit 0 @@ -125,13 +128,8 @@ game_launcher() { add_launcher() { local launchSettings="${game,,}" launchSettings="${launchSettings//[[:space:]]/-}|${1}|${game}" - # Find the last line of the script. - local lastLine="$(grep -n '^exit 0' $0)" - # Convert lastLine to a number andd increment it by 1. - lastLine=${lastLine%%:*} - lastLine=$((lastLine + 1)) - if ! tail +${lastLine} "$0" | grep -F -q -x "${launchSettings}" ; then - echo "${launchSettings}" >> "$0" + if ! grep -F -q -x "${launchSettings}" "${configFile}" ; then + echo "${launchSettings}" >> "${configFile}" fi } @@ -150,6 +148,9 @@ automate_installer() { xdotool ${keyList[*]} & } +# Settings file +configFile="${XDG_CONFIG_HOME:-$HOME/.config}/storm-games/audiogame-manager/games.conf" +mkdir -p "${configFile%/*}" # 32 bit installations work best and are the default here, if you need to override it, do it in the game specific installation steps. export WINEARCH=win32 # Turn off debug messages @@ -169,6 +170,7 @@ gameList=( "Light Cars" "Rail Racer" "River Raiders" + "Shades of Doom" "Super Egg Hunt" "Super Liam" "The Blind Swordsman" @@ -238,9 +240,9 @@ case "${game}" in install_wine_bottle vb6run speechsdk wget -O "$WINEPREFIX/drive_c/Program Files/Kitchensinc complete Setup.exe" "https://www.agarchive.net/games/kitchensinc/Kitchensinc%20complete%20Setup.exe" #automate_installer y alt+n alt+n alt+n alt+n alt+i alt+f - wine "$WINEPREFIX/drive_c/Program Files/Kitchensinc complete Setup.exe" + wine "$WINEPREFIX/drive_c/Program Files/Kitchensinc complete Setup.exe" /q add_launcher "c:\Program Files\Kitchen's Sink\gamemenu.exe" - #rm -f "$WINEPREFIX/drive_c/Program Files/Kitchensinc complete Setup.exe" + rm -f "$WINEPREFIX/drive_c/Program Files/Kitchensinc complete Setup.exe" ;; "Light Cars") install_wine_bottle dx8vb @@ -267,6 +269,13 @@ case "${game}" in rm -f "c:\Program Files\River Raiders.exe" add_launcher "c:\Program Files\River Raiders\raid.exe" ;; + "Shades of Doom") + install_wine_bottle vcrun6 + wget -O "$WINEPREFIX/drive_c/Program Files/sod20022.exe" "http://www.gmagames.com/sod20022.exe" + wine "$WINEPREFIX/drive_c/Program Files/sod20022.exe" /silent + add_launcher "c:\Program Files\Shades of Doom 2.0\sod.exe" + rm -f "$WINEPREFIX/drive_c/Program Files/sod20022.exe" + ;; "Super Egg Hunt") install_wine_bottle wget -O "$WINEPREFIX/drive_c/Program Files/superegghuntsetup.exe" "http://files.l-works.net/superegghuntsetup.exe" @@ -338,11 +347,15 @@ case "${game}" in rm -f "$WINEPREFIX/drive_c/Program Files/undead_assault.zip" add_launcher "c:\Program Files\Undead Assault.exe" ;; + "Make a One Time Donation" + xdg-open "https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=stormdragon2976@gmail.com&lc=US&item_name=Donation+to+Storm+Games&no_note=0&cn=¤cy_code=USD&bn=PP-DonationsBF:btn_donateCC_LG.gif:NonHosted" + ;; + "Become a Patron" + xdg-open "https://patreon.com/stormux" + ;; *) exit 0 ;; esac -# End of program, after the exit line, game information begins. -# Field order bottle|path|Display Name exit 0