From c9f1b2e336c004effc5a22d61effcbe2f216ca47 Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Sun, 6 Sep 2020 19:20:14 -0400 Subject: [PATCH] Added game caching system. Lots of code cleanup and updates. --- audiogame-manager.sh | 76 ++++++++++++++++++++------------------------ 1 file changed, 35 insertions(+), 41 deletions(-) diff --git a/audiogame-manager.sh b/audiogame-manager.sh index 5fb4332..01da3fc 100755 --- a/audiogame-manager.sh +++ b/audiogame-manager.sh @@ -62,7 +62,9 @@ download() { for i in "${source[@]}" ; do local dest="${i##*/}" dest="${dest//%20/ }" - if ! wget -O "$WINEPREFIX/drive_c/Program Files/${dest}" "${i}" ; then + # Return if the game is in cache. + test -e "${cache}/${dest}" && return + if ! wget -O "${cache}/${dest}" "${i}" ; then echo "Could not download game." exit 1 fi @@ -221,6 +223,9 @@ add_launcher() { rm -v "$f" fi done' _ {} + + if [[ "${noCache}" == "true" ]]; then + rm -f "${cache}/${1##*\\}" + fi fi } @@ -246,7 +251,9 @@ if [[ -z "$DISPLAY" ]]; then export DISPLAY=":0" fi # Settings file +cache="${XDG_CONFIG_HOME:-$HOME/.config}/storm-games/audiogame-manager/cache" configFile="${XDG_CONFIG_HOME:-$HOME/.config}/storm-games/audiogame-manager/games.conf" +mkdir -p "${cache}" 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 @@ -255,6 +262,8 @@ export WINEDEBUG="-all" # During installation, you can set winVer to the versions available. # To set winetricks arguments, such as virtual desktop, set the winetricksSettings variable. # Example: winetricksSettings="vd=1024x768" +# Files are cached unless -N no cache is set. +unset noCache # Manual installation is not default, make sure it's unset unset manualInstall @@ -291,6 +300,7 @@ declare -A command=( [h]="This help screen." [i]="Install games." [m]="Manually handle install screens instead of using xdotools." + [N]="No cache, delete the installer after it has been extracted." [r]="Remove a game. This will delete all game data." ) @@ -312,142 +322,126 @@ case "${game}" in "Adrian's Doom") install_wine_bottle speechsdk download "https://agarchive.net/games/mt/adrian's%20doom.exe" - wine "$WINEPREFIX/drive_c/Program Files/adrian's doom.exe" /silent + wine "${cache}/adrian's doom.exe" /silent add_launcher "c:\Program Files\Two Caring Citizens\Adrian's Doom!\adrian.exe" - rm -f "$WINEPREFIX/drive_c/Program Files/adrian's doom.exe" ;; "Battle Zone") # Speech not working through sapi. export winVer="win7" install_wine_bottle speechsdk download "https://www.agarchive.net/games/gameMadnessInteractive/battle%20zone%2013.5%20setup.exe" - wine "$WINEPREFIX/drive_c/Program Files/battle zone 13.5 setup.exe" /silent + wine "${cache}/battle zone 13.5 setup.exe" /silent add_launcher "c:\Program Files\Battle Zone\ss.exe" - rm -f "$WINEPREFIX/drive_c/Program Files/battle zone 13.5 setup.exe" ;; "Bloodshed") install_wine_bottle speechsdk download "http://www.samtupy.com/games/bloodshed.exe" - add_launcher "c:\Program Files\bloodshed.exe" + cp "${cache}/bloodshed.exe" "$WINEPREFIX/drive_c/Program Files/" ;; "Easter Quest") install_wine_bottle download "https://agarchive.net/games/mt/easter%20quest%20setup.exe" - wine "$WINEPREFIX/drive_c/Program Files/easter quest setup.exe" /silent + wine "${cache}/easter quest setup.exe" /silent add_launcher "c:\Program Files\MTGames\Easter Quest\easter.exe" - rm -f "$WINEPREFIX/drive_c/Program Files/easter quest setup.exe" ;; "Kitchensinc Games") install_wine_bottle vb6run speechsdk dx8vb download "https://stormgames.wolfe.casa/downloads/kitchen.tar.xz" echo "Extracting files..." - tar xf "$WINEPREFIX/drive_c/Program Files/Kitchen.tar.xz" -C "$WINEPREFIX/drive_c/Program Files/" + tar xf "${cache}/kitchen.tar.xz" -C "$WINEPREFIX/drive_c/Program Files/" add_launcher "c:\Program Files\Kitchen's Sink\gamemenu.exe" - rm -f "$WINEPREFIX/drive_c/Program Files/kitchen.tar.xz" ;; "Light Cars") install_wine_bottle dx8vb vb6run download "https://www.agarchive.net/games/lighttech/light%20cars%20setup.exe" if [[ -n "$manualInstall" ]]; then - wine "$WINEPREFIX/drive_c/Program Files/light cars setup.exe" + wine "${cache}/light cars setup.exe" else - wine "$WINEPREFIX/drive_c/Program Files/light cars setup.exe" & + wine "${cache}/light cars setup.exe" & automate_installer alt+n alt+a space alt+n alt+n alt+i alt+f fi echo -e "${USER} ${HOST}\nna@na.na\nUS" > ~/.local/wine/light-cars/drive_c/Program\ Files/Lighttech\ Interactive/Light\ Cars/config.dat unix2dos ~/.local/wine/light-cars/drive_c/Program\ Files/Lighttech\ Interactive/Light\ Cars/config.dat add_launcher "c:\Program Files\Lighttech Interactive\Light Cars\lightCars.exe" - rm -f "$WINEPREFIX/drive_c/Program Files/light cars setup.exe" ;; "Lockpick") install_wine_bottle vb6run dx8vb - wget "http://files.l-works.net/lockpicksetup.exe" - wine "$WINEPREFIX/drive_c/Program Files/lockpicksetup.exe" /silent + download "http://files.l-works.net/lockpicksetup.exe" + wine "${cache}/lockpicksetup.exe" /silent add_launcher "c:\Program Files\lWorks\Lockpick\lockpick.exe" - rm -f "$WINEPREFIX/drive_c/Program Files/lockpicksetup.exe" ;; "Shades of Doom") install_wine_bottle vcrun6 download "http://www.gmagames.com/sod20022.exe" - wine "$WINEPREFIX/drive_c/Program Files/sod20022.exe" /silent + wine "${cache}/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 download "http://files.l-works.net/superegghuntsetup.exe" - wine "$WINEPREFIX/drive_c/Program Files/superegghuntsetup.exe" /silent + wine "${cache}/superegghuntsetup.exe" /silent add_launcher "c:\Program Files\Lworks\super egg hunt\superegghunt.exe" - rm -f "$WINEPREFIX/drive_c/Program Files/superegghuntsetup.exe" ;; "Super Liam") install_wine_bottle vb6run dx8vb download "http://files.l-works.net/superliamsetup.exe" - wine "$WINEPREFIX/drive_c/Program Files/superliamsetup.exe" /silent + wine "${cache}/superliamsetup.exe" /silent add_launcher "c:\Program Files\lWorks\Super Liam\sl.exe" - rm -f "$WINEPREFIX/drive_c/Program Files/superliam.exe" ;; "Swamp") winetricksSettings="vd=1024x768" install_wine_bottle vb6run dx8vb quartz speechsdk corefonts download "https://kaldobsky.com/audiogames/SwampPart1.zip" "https://kaldobsky.com/audiogames/SwampPart2.zip" - unzip -d "$WINEPREFIX/drive_c/Program Files/swamp" "$WINEPREFIX/drive_c/Program Files/SwampPart1.zip" - unzip -d "$WINEPREFIX/drive_c/Program Files/swamp" "$WINEPREFIX/drive_c/Program Files/SwampPart2.zip" + unzip -d "$WINEPREFIX/drive_c/Program Files/swamp" "${cache}/SwampPart1.zip" + unzip -d "$WINEPREFIX/drive_c/Program Files/swamp" "${cache}/SwampPart2.zip" # make sure the latest version is installed. - #if wget -O "$WINEPREFIX/drive_c/Program Files/SwampPatch.zip" "https://www.kaldobsky.com/audiogames/SwampPatch.zip" ; then - #unzip -o -d "$WINEPREFIX/drive_c/Program Files/swamp" "$WINEPREFIX/drive_c/Program Files/SwampPatch.zip" - #fi + if wget -O "${cache}/SwampPatch.zip" "https://www.kaldobsky.com/audiogames/SwampPatch.zip" ; then + unzip -o -d "$WINEPREFIX/drive_c/Program Files/swamp" "${cache}/SwampPatch.zip" + fi wine cmd.exe /c 'cd /d c:\Program Files\swamp && Windows32bit.bat' - rm -f "$WINEPREFIX/drive_c/Program Files/Swamp.zip" add_launcher "c:\Program Files\swamp\Swamp.exe" ;; "The Blind Swordsman") install_wine_bottle download "http://www.evildogserver.com/theblindswordsman/theblindswordsmanPC.zip" - unzip -d "$WINEPREFIX/drive_c/Program Files" "$WINEPREFIX/drive_c/Program Files/theblindswordsmanPC.zip" - rm -f "$WINEPREFIX/drive_c/Program Files/theblindswordsmanPC.zip" + unzip -d "$WINEPREFIX/drive_c/Program Files" "${cache}/theblindswordsmanPC.zip" add_launcher "c:\Program Files\TheBlindSwordsman.exe" ;; "Technoshock") install_wine_bottle download "http://tiflocomp.ru/download/games/technoshock_140b_en.zip" "http://tiflocomp.ru/download/games/technoshock140b_en_update.zip" - unzip -d "$WINEPREFIX/drive_c/Program Files" "$WINEPREFIX/drive_c/Program Files/technoshock_140b_en.zip" - unzip -d "$WINEPREFIX/drive_c/Program Files" "$WINEPREFIX/drive_c/Program Files/technoshock_140b_en_update.zip" + unzip -d "$WINEPREFIX/drive_c/Program Files" "${cache}/technoshock_140b_en.zip" + unzip -d "$WINEPREFIX/drive_c/Program Files" "${cache}/technoshock_140b_en_update.zip" wine "$WINEPREFIX/drive_c/Program Files/setup_eng.exe" /silent wineserver -w wine "$WINEPREFIX/drive_c/Program Files/setup_eng_update_pack.exe" /silent add_launcher "c:\Program Files\Tiflocomp Games\Technoshock\ts.exe" - rm -f "$WINEPREFIX/drive_c/Program Files/setup_eng.exe" "$WINEPREFIX/drive_c/Program Files/setup_eng_update_pack.exe" "$WINEPREFIX/drive_c/Program Files/technoshock_140b_en.zip" "$WINEPREFIX/drive_c/Program Files/technoshock_140b_en_update.zip" ;; "Top Speed 3") install_wine_bottle directplay download "https://github.com/PlayingintheDark/TopSpeed/releases/download/h/Tspeed_3.0.3.exe" - wine "$WINEPREFIX/drive_c/Program Files/Tspeed_3.0.3.exe" /silent + wine "${cache}/Tspeed_3.0.3.exe" /silent add_launcher "c:\Program Files\Playing in the dark\Top Speed 3\TopSpeed.exe" - rm -f "$WINEPREFIX/drive_c/Program Files/Tspeed_3.0.3.exe" ;; "Q9") install_wine_bottle download "http://www.blastbay.com/q9_english_installer.exe" - wine "$WINEPREFIX/drive_c/Program Files/q9_english_installer.exe" /silent + wine "${cache}/q9_english_installer.exe" /silent add_launcher "c:\Program Files\Q9 Action Game\q9.exe" - rm -f "$WINEPREFIX/drive_c/Program Files/q9_english_installer.exe" ;; "RS Games") # Does not speak with sapi. export winetricksSettings="vd=1024x768" install_wine_bottle speechsdk vcrun6 download "http://rsgames.org/rsdownloads/rsgclient/rsgames-client-setup-2.01.exe" - wine "$WINEPREFIX/drive_c/Program Files/rsgames-client-setup-2.01.exe" /silent + wine "${cache}/rsgames-client-setup-2.01.exe" /silent add_launcher "c:\Program Files\RS Games Client\rsg.exe" - rm -f "$WINEPREFIX/drive_c/Program Files/rsgames-client-setup-2.01.exe" ;; "Undead Assault") # Does not speak with sapi. install_wine_bottle speechsdk vcrun6sp6 download "http://undead-assault.com/static/files/public/undead_assault.zip" - unzip -d "$WINEPREFIX/drive_c/Program Files" "$WINEPREFIX/drive_c/Program Files/undead_assault.zip" - rm -f "$WINEPREFIX/drive_c/Program Files/undead_assault.zip" + unzip -d "$WINEPREFIX/drive_c/Program Files" "${cache}/undead_assault.zip" add_launcher "c:\Program Files\Undead Assault.exe" ;; "Make a One Time Donation")