updated install games function. Inallations are now handled in files in the .install directory. This may be horribly broken, for stability, use the master branch.
This commit is contained in:
@ -337,31 +337,47 @@ add_launcher() {
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# Install games
|
||||
game_installer() {
|
||||
# Get list of installed games from config file
|
||||
mapfile -t installedGames < <(sed '/^$/d' "${configFile}" 2> /dev/null | cut -d '|' -f1)
|
||||
# Create the menu of installed games
|
||||
# Create the menu of available games by reading from .install directory
|
||||
declare -a menuList
|
||||
for i in "${gameList[@]}" ; do
|
||||
local menuItem="$i"
|
||||
for j in "${installedGames[@]}" ; do
|
||||
# Get all .sh files from .install directory, excluding those starting with #, and sort them
|
||||
mapfile -t sortedGames < <(for f in "${0%/*}/.install/"*.sh; do
|
||||
# Skip if first line starts with #
|
||||
[[ $(head -n1 "$f") == "#"* ]] && continue
|
||||
# Output filename without .sh extension
|
||||
echo "${f##*/}"
|
||||
done | sort)
|
||||
for i in "${sortedGames[@]}"; do
|
||||
local menuItem="${i%.sh}"
|
||||
# Check if game is already installed
|
||||
for j in "${installedGames[@]}"; do
|
||||
if [[ "$j" == "$menuItem" ]]; then
|
||||
unset menuItem
|
||||
break
|
||||
fi
|
||||
done
|
||||
# Add to menu if not installed
|
||||
if [[ -n "$menuItem" ]]; then
|
||||
menuList+=("$menuItem" "$menuItem")
|
||||
fi
|
||||
done
|
||||
# If all games are installed, exit
|
||||
if [[ ${#menuList[@]} -eq 0 ]]; then
|
||||
echo "All games are already installed."
|
||||
exit 0
|
||||
fi
|
||||
# Add donation option at the end
|
||||
menuList+=("Donate" "Donate")
|
||||
# Show game selection dialog
|
||||
game="$(dialog --backtitle "Game Installer" \
|
||||
--clear \
|
||||
--no-tags \
|
||||
--menu "Please select a game to install" 0 0 0 "${menuList[@]}" --stdout)"
|
||||
exit 0
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user