first code for moving to new game launch system, stuff is likely broken.

This commit is contained in:
Storm Dragon 2024-12-21 12:09:13 -05:00
parent 42b40489ce
commit cdfcf7aacf
20 changed files with 63 additions and 55 deletions

1
.launch/Aliens.sh Normal file
View File

@ -0,0 +1 @@
open_url "https://files.jantrid.net/aliens/"

1
.launch/Battle Weary.sh Normal file
View File

@ -0,0 +1 @@
open_url "https://lonespelunker.itch.io/battle-weary"

1
.launch/Cacophony.sh Normal file
View File

@ -0,0 +1 @@
open_url "https://tianmaru.itch.io/cacophony"

1
.launch/Donate.sh Normal file
View File

@ -0,0 +1 @@
open_url "https://ko-fi.com/stormux"

View File

@ -0,0 +1 @@
open_url "https://qcsalon.net/"

1
.launch/Trigaea.sh Normal file
View File

@ -0,0 +1 @@
open_url "https://ryngm.itch.io/trigaea"

View File

@ -485,20 +485,37 @@ game_update() {
# launch games that are installed # launch games that are installed
game_launcher() { game_launcher() {
mapfile -t lines < <(sed '/^$/d' "${configFile}" 2> /dev/null) # Initialize array for menu construction
# Create the menu of installed games
declare -a menuList declare -a menuList
for i in "${lines[@]}" ; do # Read both config file and .launch files into lines array
mapfile -t lines < <(
sed '/^$/d' "${configFile}" 2> /dev/null
if [[ -d ".launch" ]]; then
find "${0%/*}/.launch" -maxdepth 1 -type f -iname "*.sh" -exec bash -c '
for f; do
name="${f##*/}"
echo "${name%.sh}|$f"
done
' bash {} \;
fi
)
# Add all entries to menu
for i in "${lines[@]}"; do
menuList+=("${i#*|}" "${i%|*}") menuList+=("${i#*|}" "${i%|*}")
done done
# Web based games and donation # Sort the menu
menuList+=("Aliens" "Aliens") mapfile -t sortedList < <(
menuList+=("Cacophony" "Cacophony") for ((i=0; i<${#menuList[@]}; i+=2)); do
menuList+=("Battle Weary" "Battle Weary") echo "${menuList[i+1]}|${menuList[i]}"
menuList+=("QuentinC Play Room" "QuentinC Play Room") done | sort -f
menuList+=("Trigaea" "Trigaea") )
menuList+=("Donate" "Donate") # Rebuild menuList from sorted entries
game="$(dialog --backtitle "Linux Game Launcher" \ menuList=()
for entry in "${sortedList[@]}"; do
menuList+=("${entry#*|}" "${entry%|*}")
done
# Create the menu of all games
selectedGame="$(dialog --backtitle "Linux Game Launcher" \
--clear \ --clear \
--no-tags \ --no-tags \
--menu "Please select a game to play" 0 0 0 "${menuList[@]}" --stdout)" --menu "Please select a game to play" 0 0 0 "${menuList[@]}" --stdout)"
@ -506,54 +523,39 @@ game_launcher() {
if [[ $menuCode -eq 1 ]]; then if [[ $menuCode -eq 1 ]]; then
exit 0 exit 0
fi fi
# Remove any trailing | from game variable. # Remove any trailing | from selectedGame variable
game="${game%|}" selectedGame="${selectedGame%|}"
case "${game}" in case "${selectedGame}" in
"Aliens") *".tin")
open_url "https://files.jantrid.net/aliens/" git -C "${selectedGame%/*}" pull | \
;; dialog --progressbox "Checking for updates, please wait..." -1 -1
"Battle Weary") if [[ -n "${COLORTERM}" ]]; then
open_url "https://lonespelunker.itch.io/battle-weary" terminal_emulator tt++ ${selectedGame##*/}
else
pushd "${selectedGame%/*}"
exec tt++ ${selectedGame##*/}
fi
;; ;;
"Cacophony") *"main.py")
open_url "https://tianmaru.itch.io/cacophony" pushd "${selectedGame%/*}"
git pull -q | dialog --progressbox "Checking for updates, please wait..." -1 -1
python3 ${selectedGame}
;; ;;
"QuentinC Play Room") *.sh)
open_url "https://qcsalon.net/" . "${selectedGame}"
;; ;;
"Trigaea") *)
open_url "https://ryngm.itch.io/trigaea" pushd "${selectedGame%/*}"
;; if file "${selectedGame##*/}" | grep -q "ELF.*x86-64"; then
"Donate") if [[ "$(uname -m)" != "x86_64" ]]; then
open_url "https://ko-fi.com/stormux" exec FEXLoader -- ${selectedGame}
;;
*".tin")
git -C "${game%/*}" pull | \
dialog --progressbox "Checking for updates, please wait..." -1 -1
if [[ -n "${COLORTERM}" ]]; then
terminal_emulator tt++ ${game##*/}
else else
pushd "${game%/*}" exec ${selectedGame}
exec tt++ ${game##*/}
fi fi
;; else
*"main.py") exec ${selectedGame}
pushd "${game%/*}" fi
git pull -q | dialog --progressbox "Checking for updates, please wait..." -1 -1 ;;
python3 ${game}
;;
*)
pushd "${game%/*}"
if file "${game##*/}" | grep -q "ELF.*x86-64"; then
if [[ "$(uname -m)" != "x86_64" ]]; then
exec FEXLoader -- ${game}
else
exec ${game}
fi
else
exec ${game}
fi
;;
esac esac
exit 0 exit 0
} }