Added -r to remove installed games.

This commit is contained in:
Storm Dragon 2020-09-04 23:32:26 -04:00
parent 37a7ae2ccc
commit 15ec1bcb92

View File

@ -97,6 +97,49 @@ game_installer() {
--menu "Please select a game to install" 0 0 0 "${menuList[@]}" --stdout)" --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 "${game##*|} has been deleted."
fi
exit 0
}
# launch games that are installed # launch games that are installed
game_launcher() { game_launcher() {
mapfile -t lines < <(sed '/^$/d' "${configFile}" 2> /dev/null) mapfile -t lines < <(sed '/^$/d' "${configFile}" 2> /dev/null)
@ -210,6 +253,7 @@ command=(
"c" # Check wine environment "c" # Check wine environment
"i" # Install games "i" # Install games
"m" # Manually handle install screens "m" # Manually handle install screens
"r" # Remove a game
) )
while getopts "${command[*]//[[:space:]]/}" i ; do while getopts "${command[*]//[[:space:]]/}" i ; do
@ -217,7 +261,8 @@ while getopts "${command[*]//[[:space:]]/}" i ; do
c) checklist;; c) checklist;;
h) show_help;; h) show_help;;
i) game_installer;; i) game_installer;;
m) manualInstall="true" m) manualInstall="true";;
r) game_removal;;
esac esac
done done