New -u option added for updating games. This is experimental, watch for bugs. Currently contains only 1 entry.

This commit is contained in:
stormdragon2976 2022-12-09 00:45:14 -05:00
parent c085855202
commit 3694c82e21
2 changed files with 51 additions and 1 deletions

View File

@ -0,0 +1,14 @@
run_update() {
local installPath="${HOME}/.local/games"
local gameName=""periphery-synthetic-ep-linux-x64.zip""
for i in ~/Downloads ~/Desktop ; do
find $i -type f -name "$gameName" -exec mv -v {} "${cache}/" \;
done
# If the file is still not available abort.
if [[ ! -f "${cache}/$gameName" ]]; then
dialog --backtitle "Linux Game Manager" --msgbox "Couldn't find $gameName. Please download the file and try again." -1 -1
exit 1
fi
mkdir -p "${installPath}/periphery-synthetic-ep"
unzip -od "${installPath}/periphery-synthetic-ep" "${cache}/periphery-synthetic-ep-linux-x64.zip"
}

View File

@ -315,6 +315,40 @@ game_removal() {
}
# update games
game_update() {
mapfile -t lines < <(find .update -type f -iname '*.sh' 2> /dev/null)
if [[ ${#lines} -eq 0 ]]; then
echo "No games found."
exit 0
fi
# Create the menu of updatable 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 Updater" \
--clear \
--no-tags \
--menu "Please select a game to update" 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
source "${game}"
run_update
exit 0
}
# launch games that are installed
game_launcher() {
mapfile -t lines < <(sed '/^$/d' "${configFile}" 2> /dev/null)
@ -374,7 +408,7 @@ game_launcher() {
;;
*"main.py")
pushd "${game%/*}"
git pull -q
git pull -q | dialog --progressbox "Checking for updates, please wait..." -1 -1
python3 ${game}
;;
*)
@ -464,6 +498,7 @@ declare -A command=(
[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."
[u]="Update games. Run available game update scripts."
)
# Convert the keys of the associative array to a format usable by getopts
@ -484,6 +519,7 @@ while getopts "${args}" i ; do
--infobox "There are currently ${#gameList[@]} games available." -1 -1
exit 0
;;
u) game_update ;;
esac
done