diff --git a/audiogame-manager.sh b/audiogame-manager.sh index d60d8ff..554fd12 100755 --- a/audiogame-manager.sh +++ b/audiogame-manager.sh @@ -97,6 +97,49 @@ game_installer() { --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=¤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 + # 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 game_launcher() { mapfile -t lines < <(sed '/^$/d' "${configFile}" 2> /dev/null) @@ -210,6 +253,7 @@ command=( "c" # Check wine environment "i" # Install games "m" # Manually handle install screens + "r" # Remove a game ) while getopts "${command[*]//[[:space:]]/}" i ; do @@ -217,7 +261,8 @@ while getopts "${command[*]//[[:space:]]/}" i ; do c) checklist;; h) show_help;; i) game_installer;; - m) manualInstall="true" + m) manualInstall="true";; + r) game_removal;; esac done