audiogame-manager/audiogame-manager.sh

229 lines
8.7 KiB
Bash
Raw Normal View History

2020-08-27 15:42:24 -04:00
#!/bin/bash
# Wine configuration section
install_wine_bottle() {
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
winetricks -q $@ ${winVer:-winxp} ${winetricksSettings}) | dialog --progressbox "Installing wine bottle, please wait..." -1 -1
}
# 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)
# 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
game="$(dialog --backtitle "Audio Game Installer" \
--clear \
--no-tags \
--menu "Please select a game to install" 0 0 0 "${menuList[@]}" --stdout)"
}
# 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')
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
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
local winePath="${game#*|}"
winePath="${winePath%\\*.exe}"
local wineExec="${game#*|}"
wineExec="${wineExec%|*}"
wineExec="${wineExec##*\\}"
WINEPREFIX="${HOME}/.local/wine/${game%|*}" wine start /d "${winePath}" "$wineExec"
fi
exit 0
}
# main script
#functions
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"
fi
}
automate_installer() {
# Function arguments are the keys to be pressed.
declare -a keyList=("sleep 15")
for i in ${@} ; do
case "$i" in
"alt+f") keyList+=("key ${i}");;
"alt+i") keyList+=("sleep 10 key ${i}");;
"alt+"*) keyList+=("key ${i} sleep 2");;
*"+"*) keyList+=("key ${i} sleep 2");;
*) xdotool type ${i};;
esac
done
xdotool ${keyList[*]}
}
# 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
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"
# The list of games available for installation.
# Use menu friendly names.
gameList=(
"Chopper Challenge"
"Kitchensinc Games"
"River Raiders"
"Super Egg Hunt"
"The Blind Swordsman"
"Top Speed 3"
"Q9"
"RS Games"
)
# With no arguments, open the game launcher.
if [[ $# -eq 0 ]]; then
game_launcher
fi
# Array of command line arguments
command=(
"i" # Install
)
while getopts "${command[@]//[[:space:]]/}" i ; do
case "$i" in
h) show_help;;
i) game_installer
esac
done
# Install game based on the selection above.
case "${game}" in
"Chopper Challenge")
install_wine_bottle vb6run dx8vb
wget -O "$WINEPREFIX/drive_c/Program Files/chopper challenge setup.exe" "https://www.agarchive.net/games/XSight/chopper%20challenge%20setup.exe"
wine "$WINEPREFIX/drive_c/Program Files/chopper challenge setup.exe" &
sleep 5
xdotool type y
xdotool key --clearmodifiers --delay 1000 alt+n alt+n alt+n alt+i alt+f
add_launcher "c:\Program Files\x-sight interactive\chopper challenge\Chopper.exe"
echo 'Linux|n/a' >> "$WINEPREFIX/drive_c/Program Files/x-sight interactive/chopper challenge/config.dat" &
rm -f "$WINEPREFIX/drive_c/Program Files/chopper challenge setup.exe"
;;
"Kitchensinc Games")
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"
wine "$WINEPREFIX/drive_c/Program Files/Kitchensinc complete Setup.exe" &
xdotool sleep 5 key y sleep 2 key alt+n sleep 2 key alt+n sleep 2 key alt+n sleep 2 key alt+n sleep 2 key alt+i sleep 10 key alt+f
#automate_installer y alt+n alt+n alt+n alt+n alt+i alt+f
add_launcher "c:\Program Files\Kitchen's Sink\gamemenu.exe"
#rm -f "$WINEPREFIX/drive_c/Program Files/Kitchensinc complete Setup.exe"
;;
"River Raiders")
install_wine_bottle
wget -O "$WINEPREFIX/drive_c/Program Files/River Raiders.exe" "https://www.agarchive.net/games/XSight/River%20Raiders%201.3.5.exe"
wine "c:\Program Files\River Raiders.exe" /silent &
sleep 5
xdotool type y
xdotool key --delay 1000 alt+y alt+n alt+n alt+n alt+i alt+f
rm -f "c:\Program Files\River Raiders.exe"
add_launcher "c:\Program Files\River Raiders\raid.exe"
;;
"Super Egg Hunt")
install_wine_bottle
wget -O "$WINEPREFIX/drive_c/Program Files/superegghuntsetup.exe" "http://files.l-works.net/superegghuntsetup.exe"
wine "$WINEPREFIX/drive_c/Program Files/superegghuntsetup.exe" /silent
add_launcher "c:\Program Files\Lworks\super egg hunt\superegghunt.exe"
rm -f "$WINEPREFIX/drive_c/Program Files/superegghuntsetup.exe"
;;
"The Blind Swordsman")
install_wine_bottle
wget -O "$WINEPREFIX/drive_c/Program Files/theblindswordsmanPC.zip" "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"
add_launcher "c:\Program Files\TheBlindSwordsman.exe"
;;
"Top Speed 3")
install_wine_bottle
wget -O "$WINEPREFIX/drive_c/Program Files/Tspeed_3.0.3.exe" "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
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
wget -O "$WINEPREFIX/drive_c/Program Files/q9_english_installer.exe" "http://www.blastbay.com/q9_english_installer.exe"
wine "$WINEPREFIX/drive_c/Program Files/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")
install_wine_bottle speechsdk
wget -O "$WINEPREFIX/drive_c/Program Files/rsgames-client-setup-2.01.exe" "http://rsgames.org/rsdownloads/rsgclient/rsgames-client-setup-2.01.exe"
wine "$WINEPREFIX/drive_c/Program Files/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"
;;
*)
exit 0
;;
esac
# End of program, after the exit line, game information begins.
# Field order bottle|path|Display Name
exit 0