Fixed an error in game removal. Fixed an error where it would try to launch an empty file name if escape were pressed to close the menu.

This commit is contained in:
Storm Dragon
2025-08-05 01:44:56 -04:00
parent d49ca8a86b
commit 5adce756a1

View File

@@ -96,13 +96,16 @@ game_removal() {
open_url "https://2mb.games/product/2mb-patron/" open_url "https://2mb.games/product/2mb-patron/"
exit 0 exit 0
fi fi
# Parse game info before create_game_array overwrites $game
local selectedGame="$game"
local winePath="${game#*|}" local winePath="${game#*|}"
export winePath="${winePath%\\*.exe}" export winePath="${winePath%\\*.exe}"
local wineExec="${game#*|}" local wineExec="${game#*|}"
wineExec="${wineExec%|*}" wineExec="${wineExec%|*}"
wineExec="${wineExec##*\\}" wineExec="${wineExec##*\\}"
# With shared bottles, always remove only the game files, never the entire bottle # With shared bottles, always remove only the game files, never the entire bottle
create_game_array "$game" create_game_array "$selectedGame"
if [[ ${#game[@]} -gt 0 ]]; then if [[ ${#game[@]} -gt 0 ]]; then
# Set up wine environment for this game # Set up wine environment for this game
source .includes/bottle.sh source .includes/bottle.sh
@@ -126,9 +129,9 @@ game_removal() {
fi fi
fi fi
fi fi
# remove the launcher # remove the launcher using the original selected game info
gawk -i inplace -vLine="${game//\\/\\\\}" '!index($0,Line)' "$configFile" gawk -i inplace -vLine="${selectedGame//\\/\\\\}" '!index($0,Line)' "$configFile"
echo "The selected item has been deleted." agm_msgbox "Game Removal" "" "\"${game[2]}\" has been successfully removed."
fi fi
exit 0 exit 0
} }
@@ -311,9 +314,15 @@ game_launcher() {
if [[ $menuCode -eq 1 ]] || [[ $menuCode -eq 255 ]]; then if [[ $menuCode -eq 1 ]] || [[ $menuCode -eq 255 ]]; then
exit 0 exit 0
elif [[ $menuCode -eq 3 ]]; then elif [[ $menuCode -eq 3 ]]; then
source .includes/help.sh # Make available in this function source .includes/help.sh # Make available in this function
documentation "$game" "$(echo "$game" | cut -d '|' -f2)" documentation "$game" "$(echo "$game" | cut -d '|' -f2)"
fi fi
# Safety check: don't proceed if game is empty
if [[ -z "$game" ]]; then
exit 0
fi
create_game_array "$game" create_game_array "$game"
else else
create_game_array "$game" create_game_array "$game"