From c085855202b7a0fc7ba9a6b5309a6e0229d6dccd Mon Sep 17 00:00:00 2001 From: stormdragon2976 Date: Thu, 8 Dec 2022 15:50:28 -0500 Subject: [PATCH] -r added for game removal. --- linux-game-manager.sh | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/linux-game-manager.sh b/linux-game-manager.sh index 8891a00..a84fa42 100755 --- a/linux-game-manager.sh +++ b/linux-game-manager.sh @@ -278,6 +278,43 @@ 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+=("Donate" "Donate") + 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" == "Donate" ]]; then + open_url "https://ko-fi.com/stormux" + exit 0 + fi + if [[ "$game" == "Become a Patron" ]]; then + open_url "https://2mb.games/product/2mb-patron/" + exit 0 + fi + fi + dialog --backtitle "Linux Game Manager" \ + --yesno "mThis will remove the directory \"${game%/*}\" and all of its contents. Do you want to continue?." -1 -1 --stdout || exit 0 + { rm -rfv "${game%/*}"; + sed -i "/${game//\//\\/}/d" "$configFile"; } | dialog --backtitle "Linux Game Manager" --progressbox "Removing game..." -1 -1 + exit 0 +} + + # launch games that are installed game_launcher() { mapfile -t lines < <(sed '/^$/d' "${configFile}" 2> /dev/null) @@ -425,6 +462,7 @@ declare -A command=( [L]="Display license information." [N]="No cache, delete the installer after it has been extracted." [R]="Redownload. Removes old versions of packages from cache before installing." + [r]="Remove game. Remove a game and its menu entry." [t]="Total games. Show how many games are currently available." ) @@ -440,6 +478,7 @@ while getopts "${args}" i ; do L) license ;; N) noCache="true" ;; R) redownload="true" ;; + r) game_removal ;; t) dialog --backtitle "Linux Game Manager" \ --infobox "There are currently ${#gameList[@]} games available." -1 -1