audiogame-manager/audiogame-manager.sh

579 lines
22 KiB
Bash
Executable File

#!/bin/bash
# Dialog accessibility
export DIALOGOPTS='--no-lines --visit-items'
# Automatic update function
update() {
local filePath="$(command -v ${0})"
if file "${filePath}" | grep -q 'Bourne-Again shell script, ASCII text' ; then
return
fi
if [[ "$(wget --quiet -O - https://stormgames.wolfe.casa/downloads/audiogame-manager | sha256sum | cut -d ' ' -f1)" == "$(sha256sum "${filePath}" | cut -d ' ' -f1)" ]]; then
return
fi
echo "There is a new version of ${0##*/} available."
echo "Do you want to update now?"
read -r continue
if [[ "${continue,,}" =~ ^y|ye|yes$ ]]; then
if [[ -w "$0" ]]; then
wget --quiet -O "${filePath}" "https://stormgames.wolfe.casa/downloads/audiogame-manager"
else
sudo wget --quiet -O "${filePath}" "https://stormgames.wolfe.casa/downloads/audiogame-manager"
fi
echo "${0##*/} has been updated. Please launch the program again to use the latest version."
exit 0
fi
}
# Wine configuration section
checklist() {
declare -a errorList
echo "Checking your system..."
echo
if command -v wine &> /dev/null ; then
echo "Wine is installed."
else
errorList+=("Critical: Wine is not installed. You will not be able to play any games.")
fi
if command -v winetricks &> /dev/null ; then
echo "Winetricks is installed."
else
errorList+=("Critical: Winetricks is not installed. This means wine cannot be configured, dependancies cannot be installed, and only self-voicing games have any chance of working.")
fi
if command -v wget &> /dev/null ; then
echo "Wget is installed."
else
errorList+=("Critical: Wget is not installed. You will not be able to install any games.")
fi
for i in 7z cabextract unzip xz ; do
if command -v $i &> /dev/null ; then
echo "${i^} is installed."
else
errorList+=("Critical: ${i^} is not installed. You will not be able to install some games or their components.")
fi
done
if command -v ocrdesktop &> /dev/null ; then
echo "Ocrdesktop is installed."
else
errorList+=("Warning: ocrdesktop is not installed. It can help if the installer gets stuck to figure out what is happening.")
fi
if command -v unix2dos &> /dev/null ; then
echo "Dos2unix is installed."
else
errorList+=("Warning: unix2dos is not installed. Some games need a configuration file in dos format before they will run.")
fi
if [[ -d /usr/share/wine/gecko/ ]]; then
echo "Found wine gecko."
else
errorList+=("Warning: Wine gecko not found, some games may not work.")
fi
if [[ -d /usr/share/wine/mono/ ]]; then
echo "Found wine mono."
else
errorList+=("Warning: Wine mono not found, some games may not work.")
fi
if command -v xdotool &> /dev/null ; then
echo "Xdotool is installed."
else
errorList+=("Warning: Xdotool is not installed. Some installlers may not work or may need manual intervention.")
fi
# Show the results
if [[ ${#errorList[@]} -eq 0 ]]; then
echo "No problems found, you are good to go."
exit 0
fi
echo "Errors detected, here is a list along with the severity."
echo "Note that errors marked critical mean that you will not be able to install and play games until they are resolved."
for i in "${errorList[@]}" ; do
echo "$i"
done
exit 0
}
download() {
local source=($@)
for i in "${source[@]}" ; do
local dest="${i##*/}"
dest="${dest//%20/ }"
# 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
done
}
help() {
echo -e "Usage:\n"
echo "With no arguments, open the game launcher."
for i in "${!command[@]}" ; do
echo "-${i}: ${command[${i}]}"
done | sort
exit 0
}
install_wine_bottle() {
# 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="${WINEARCH:-win32}"
local bottle="${game,,}"
bottle="${bottle//[[:space:]]/-}"
mkdir -p "$HOME/.local/wine/${bottle}"
export WINEPREFIX="$HOME/.local/wine/${bottle}"
# Arguments to the function are dependancies to be installed.
(wine msiexec /i z:/usr/share/wine/mono/$(ls -1 /usr/share/wine/mono/) /silent
wine msiexec /i z:$(ls -1 /usr/share/wine/gecko/*x86.msi) /silent
# If the game requires speechsdk, get the espeak voices.
if [[ "$*" =~ speechsdk ]]; then
download "http://sourceforge.net/projects/espeak/files/espeak/espeak-1.48/setup_espeak-1.48.04.exe"
wine "${cache}/setup_espeak-1.48.04.exe" /silent
fi
winetricks -q $@ ${winVer:-winxp} ${winetricksSettings}) | dialog --progressbox "Installing wine bottle, please wait..." -1 -1
}
# Install games
game_installer() {
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
local menuItem="$i"
for j in "${installedGames[@]}" ; do
if [[ "$j" == "$menuItem" ]]; then
unset menuItem
fi
done
if [[ -n "$menuItem" ]]; then
menuList+=("$menuItem" "$menuItem")
fi
done
if [[ ${#menuList[@]} -eq 0 ]]; then
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 \
--menu "Please select a game to install" 0 0 0 "${menuList[@]}" --stdout)"
}
# remove games
game_removal() {
mapfile -t lines < <(sed '/^$/d' "${configFile}" 2> /dev/null)
if [[ ${#lines} -eq 0 ]]; then
echo "No games found."
exit 0
fi
# Create the menu of installed games
declare -a menuList
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 Removal" \
--clear \
--no-tags \
--menu "Please select a game to delete" 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=&currency_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
# remove the game
rm -rf "${HOME}/.local/wine/${game%|*}"
# remove the launcher
awk -i inplace -vLine="${game//\\/\\\\}" '!index($0,Line)' "$configFile"
echo "The selected game has been deleted."
fi
exit 0
}
# launch games that are installed
game_launcher() {
mapfile -t lines < <(sed '/^$/d' "${configFile}" 2> /dev/null)
if [[ ${#lines} -eq 0 ]]; then
echo "Install some games first."
exit 0
fi
# Create the menu of installed games
declare -a menuList
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=&currency_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
if command -v qjoypad &> /dev/null ; then
mkdir -p ~/.qjoypad3
touch "${HOME}/.qjoypad3/${game%|*}.lyt"
if pgrep qjoypad &> /dev/null ; then
qjoypad -T "${game%|*}" 2> /dev/null
else
qjoypad -T "${game%|*}" 2> /dev/null &
fi
fi
WINEPREFIX="${HOME}/.local/wine/${game%|*}" wine start /realtime /d "${winePath}" "$wineExec"
fi
exit 0
}
# main script
#functions
add_launcher() {
local launchSettings="${game,,}"
launchSettings="${launchSettings//[[:space:]]/-}|${1}|${game}"
if ! grep -F -q -x "${launchSettings}" "${configFile}" ; then
echo "${launchSettings}" >> "${configFile}"
sort -o "${configFile}" "${configFile}"
# Remove .lnk files because they don't work.
find ~/Desktop -type f -iname '*.lnk' -exec bash -c '
for f ; do
mimeType="$(file -b "$f")"
mimeType="${mimeType%%,*}"
if [[ "$mimeType" == "MS Windows shortcut" ]]; then
rm -v "$f"
fi
done' _ {} +
if [[ "${noCache}" == "true" ]]; then
rm -f "${cache}/${1##*\\}"
fi
fi
}
automate_installer() {
# Function arguments are the keys to be pressed.
sleep 15
declare -a keyList
for i in ${@} ; do
case "$i" in
"alt+f") keyList+=("sleep 15 key ${i}");;
"space") keyList+=("sleep 1 key ${i}");;
*"+"*) keyList+=("sleep 1 key ${i}");;
*) xdotool sleep 1 type ${i};;
esac
done
xdotool ${keyList[*]} &
# call wineserver -w in case something failed here, the user will have a chance to try to fix it.
wineserver -w
}
# Check for updates
update
# If display isn't set assume we are launching from console and an X environment is running using display :0
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%/*}"
# Turn off debug messages
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
# The list of games available for installation.
# Use menu friendly names.
gameList=(
"Adrian's Doom"
"Adventurers At C"
"AudioDisc"
"Battle Zone"
"Bloodshed"
"Crazy Party"
"Easter Quest"
#"Entombed"
"Finger Panic"
"Fuck That Bird"
"Kitchensinc Games"
"Light Cars"
"Lockpick"
"Manamon"
"Manamon 2"
"Pontes Kickups!"
"Run For Your Life"
"Shades of Doom"
"Super Egg Hunt"
"Super Liam"
"Swamp"
"The Blind Swordsman"
"Technoshock"
"Top Speed 3"
"Q9"
)
# With no arguments, open the game launcher.
if [[ $# -eq 0 ]]; then
game_launcher
fi
# Array of command line arguments
declare -A command=(
[c]="Check your system for necessary components."
[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."
)
# Convert the keys of the associative array to a format usable by getopts
args="${!command[*]}"
args="${args//[[:space:]]/}"
while getopts "${args}" i ; do
case "$i" in
c) checklist;;
h) help;;
i) game_installer;;
m) manualInstall="true";;
N) noCache="true";;
r) game_removal;;
esac
done
# Install game based on the selection above.
case "${game}" in
"Adrian's Doom")
install_wine_bottle speechsdk
download "https://agarchive.net/games/mt/adrian's%20doom.exe"
wine "${cache}/adrian's doom.exe" /silent
add_launcher "c:\Program Files\Two Caring Citizens\Adrian's Doom!\adrian.exe"
;;
"Battle Zone")
export winVer="win7"
install_wine_bottle speechsdk
download "https://www.agarchive.net/games/gameMadnessInteractive/battle%20zone%2013.5%20setup.exe"
wine "${cache}/battle zone 13.5 setup.exe" /silent
add_launcher "c:\Program Files\Battle Zone\ss.exe"
rm -fv "${WINEPREFIX}/drive_c/Program Files/Battle Zone/nvdaControllerClient32.dll"
;;
"Bloodshed")
install_wine_bottle speechsdk
download "http://www.samtupy.com/games/bloodshed.exe"
cp "${cache}/bloodshed.exe" "$WINEPREFIX/drive_c/Program Files/"
add_launcher "c:\Program Files\bloodshed.exe"
;;
"Adventurers At C")
install_wine_bottle speechsdk
download "http://www.vgstorm.com/aac/aac.zip" "https://www.agarchive.net/games/vg/adventure%20at%20c%20stages.7z"
unzip -d "$WINEPREFIX/drive_c/Program Files/aac" "${cache}/aac.zip"
7z e -o"$WINEPREFIX/drive_c/Program Files/aac/stages" "${cache}/adventure at c stages.7z"
add_launcher "c:\Program Files\aac\aac.exe"
;;
"AudioDisc")
install_wine_bottle
download "https://agarchive.net/games/other/audiodisc.zip"
unzip -d "$WINEPREFIX/drive_c/Program Files" "${cache}/audiodisc.zip"
add_launcher "c:\Program Files\audiodisc\disco.exe"
;;
"Crazy Party")
export winVer="win7"
install_wine_bottle speechsdk
download "http://pragmapragma.free.fr/crazy-party/Crazy-Party-beta73.zip"
unzip -d "$WINEPREFIX/drive_c/Program Files" "${cache}/Crazy-Party-beta73.zip"
add_launcher "c:\Program Files\Crazy-Party-beta73\Crazy Party.exe"
rm -f "${WINEPREFIX}/drive_c/Program Files/Crazy-Party-beta73/nvdaControllerClient32.dll"
;;
"Easter Quest")
install_wine_bottle
download "https://agarchive.net/games/mt/easter%20quest%20setup.exe"
wine "${cache}/easter quest setup.exe" /silent
add_launcher "c:\Program Files\MTGames\Easter Quest\easter.exe"
;;
"Entombed")
install_wine_bottle msvcrt40 speechsdk xna31
download "http://www.blind-games.com/EntombedSetup.exe" "http://www.blind-games.com/EntombedUpdate.exe"
wine "${cache}/EntombedSetup.exe" /silent
wine "${cache}/EntombedUpdate.exe" /silent
#add_launcher "c:\Program Files\MTGames\Easter Quest\easter.exe"
;;
"Finger Panic")
install_wine_bottle dx8vb vb6run
download "http://www.agarchive.net/games/bsc/FingerPanicSetup.exe"
if command -v xdotool &> /dev/null ; then
wine "${cache}/FingerPanicSetup.exe" /silent | xdotool sleep 10 key alt+y --clearmodifiers
else
wine "${cache}/FingerPanicSetup.exe" /silent
fi
add_launcher "c:\Program Files\Finger Panic 1.0\FingerPanic.exe"
;;
"Fuck That Bird")
export winVer="win7"
install_wine_bottle
download "http://oriolgomez.com/games/bird_en.zip"
unzip -d "$WINEPREFIX/drive_c/Program Files/fuck that bird" "${cache}/bird_en.zip"
add_launcher "c:\Program Files\fuck that bird/game.exe"
;;
"Kitchensinc Games")
install_wine_bottle vb6run speechsdk dx8vb
download "https://stormgames.wolfe.casa/downloads/kitchen.tar.xz"
echo "Extracting files..."
tar xf "${cache}/kitchen.tar.xz" -C "$WINEPREFIX/drive_c/Program Files/"
add_launcher "c:\Program Files\Kitchen's Sink\gamemenu.exe"
;;
"Light Cars")
install_wine_bottle dx8vb vb6run
download "https://www.agarchive.net/games/lighttech/light%20cars%20setup.exe"
if [[ -n "$manualInstall" ]]; then
wine "${cache}/light cars setup.exe"
else
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"
;;
"Lockpick")
install_wine_bottle vb6run dx8vb
download "http://files.l-works.net/lockpicksetup.exe"
wine "${cache}/lockpicksetup.exe" /silent
add_launcher "c:\Program Files\lWorks\Lockpick\lockpick.exe"
;;
"Manamon")
export winVer="win7"
install_wine_bottle speechsdk
download "https://www.vgstorm.com/manamon/manamon_installer.exe"
wine "${cache}/manamon_installer.exe" /silent
add_launcher "c:\Program Files\VGStorm.com\Manamon\rpg.exe"
;;
"Manamon 2")
export winVer="win7"
install_wine_bottle speechsdk
download "http://www.vgstorm.com/manamon2/manamon2_installer.exe"
wine "${cache}/manamon2_installer.exe" /silent
add_launcher "c:\Program Files\VGStorm.com\Manamon 2\rpg.exe"
;;
"Pontes Kickups!")
export winVer="win7"
install_wine_bottle speechsdk
download "http://www.pontes.ro/ro/divertisment/games/PontesKickUpsInstaller.exe"
wine "${cache}/PontesKickUpsInstaller.exe" /silent /q
rm -fv "${WINEPREFIX}/drive_c/Program Files/Pontes Games/Pontes Kick-ups/nvdaControllerClient32.dll"
add_launcher "c:\Program Files\Pontes Games\Pontes Kick-ups\PontesKickUps.exe"
;;
"Run For Your Life")
export winVer="win7"
install_wine_bottle
download "http://oriolgomez.com/games/rfyl_en.zip"
unzip -d "$WINEPREFIX/drive_c/Program Files/run for your life" "${cache}/rfyl_en.zip"
add_launcher "c:\Program Files\run for your life/game.exe"
;;
"Shades of Doom")
install_wine_bottle vcrun6
download "http://www.gmagames.com/sod20022.exe"
wine "${cache}/sod20022.exe" /silent
add_launcher "c:\Program Files\Shades of Doom 2.0\sod.exe"
;;
"Super Egg Hunt")
install_wine_bottle
download "http://files.l-works.net/superegghuntsetup.exe"
wine "${cache}/superegghuntsetup.exe" /silent
add_launcher "c:\Program Files\Lworks\super egg hunt\superegghunt.exe"
;;
"Super Liam")
install_wine_bottle vb6run dx8vb
download "http://files.l-works.net/superliamsetup.exe"
wine "${cache}/superliamsetup.exe" /silent
add_launcher "c:\Program Files\lWorks\Super Liam\sl.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" "${cache}/SwampPart1.zip"
unzip -d "$WINEPREFIX/drive_c/Program Files/swamp" "${cache}/SwampPart2.zip"
# make sure the latest version is installed.
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'
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" "${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" "${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"
;;
"Top Speed 3")
install_wine_bottle directplay
download "https://github.com/PlayingintheDark/TopSpeed/releases/download/h/Tspeed_3.0.3.exe"
wine "${cache}/Tspeed_3.0.3.exe" /silent
add_launcher "c:\Program Files\Playing in the dark\Top Speed 3\TopSpeed.exe"
;;
"Q9")
install_wine_bottle
download "http://www.blastbay.com/q9_english_installer.exe"
wine "${cache}/q9_english_installer.exe" /silent
add_launcher "c:\Program Files\Q9 Action Game\q9.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=&currency_code=USD&bn=PP-DonationsBF:btn_donateCC_LG.gif:NonHosted"
;;
"Become a Patron")
xdg-open "https://patreon.com/stormux"
;;
*)
exit 0
;;
esac
exit 0