From cdfcf7aacf626e230333b6ad2199cddef5965557 Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Sat, 21 Dec 2024 12:09:13 -0500 Subject: [PATCH] first code for moving to new game launch system, stuff is likely broken. --- .launch/Aliens.sh | 1 + .launch/Battle Weary.sh | 1 + .launch/Cacophony.sh | 1 + .launch/Donate.sh | 1 + {.scripts => .launch}/FreeDoom.sh | 0 .launch/QuentinC Play Room.sh | 1 + {.scripts => .launch}/SlayTheSpire.sh | 0 {.scripts => .launch}/TobyCustom/' | 0 .../TobyCustom/.dependencies | 0 {.scripts => .launch}/TobyCustom/.mapmenu | 0 .../TobyCustom/ArmyOfDarknessDoom.sh | 0 .../TobyCustom/Custom_Death_Match.sh | 0 .../TobyCustom/GoMidievilOnTheirAss.sh | 0 .../TobyCustom/Project_Brutality.sh | 0 .../TobyCustom/Project_BrutalityLatest.sh | 0 {.scripts => .launch}/TobyCustom/StarWars.sh | 0 .../TobyCustom/WolfenDoom.sh | 0 .launch/Trigaea.sh | 1 + {.scripts => .launch}/yadoom | 0 linux-game-manager.sh | 112 +++++++++--------- 20 files changed, 63 insertions(+), 55 deletions(-) create mode 100644 .launch/Aliens.sh create mode 100644 .launch/Battle Weary.sh create mode 100644 .launch/Cacophony.sh create mode 100644 .launch/Donate.sh rename {.scripts => .launch}/FreeDoom.sh (100%) create mode 100644 .launch/QuentinC Play Room.sh rename {.scripts => .launch}/SlayTheSpire.sh (100%) rename {.scripts => .launch}/TobyCustom/' (100%) rename {.scripts => .launch}/TobyCustom/.dependencies (100%) rename {.scripts => .launch}/TobyCustom/.mapmenu (100%) rename {.scripts => .launch}/TobyCustom/ArmyOfDarknessDoom.sh (100%) rename {.scripts => .launch}/TobyCustom/Custom_Death_Match.sh (100%) rename {.scripts => .launch}/TobyCustom/GoMidievilOnTheirAss.sh (100%) rename {.scripts => .launch}/TobyCustom/Project_Brutality.sh (100%) rename {.scripts => .launch}/TobyCustom/Project_BrutalityLatest.sh (100%) rename {.scripts => .launch}/TobyCustom/StarWars.sh (100%) rename {.scripts => .launch}/TobyCustom/WolfenDoom.sh (100%) create mode 100644 .launch/Trigaea.sh rename {.scripts => .launch}/yadoom (100%) diff --git a/.launch/Aliens.sh b/.launch/Aliens.sh new file mode 100644 index 0000000..5f37fd8 --- /dev/null +++ b/.launch/Aliens.sh @@ -0,0 +1 @@ +open_url "https://files.jantrid.net/aliens/" diff --git a/.launch/Battle Weary.sh b/.launch/Battle Weary.sh new file mode 100644 index 0000000..7fb1575 --- /dev/null +++ b/.launch/Battle Weary.sh @@ -0,0 +1 @@ +open_url "https://lonespelunker.itch.io/battle-weary" diff --git a/.launch/Cacophony.sh b/.launch/Cacophony.sh new file mode 100644 index 0000000..df3481e --- /dev/null +++ b/.launch/Cacophony.sh @@ -0,0 +1 @@ +open_url "https://tianmaru.itch.io/cacophony" diff --git a/.launch/Donate.sh b/.launch/Donate.sh new file mode 100644 index 0000000..bd3c40b --- /dev/null +++ b/.launch/Donate.sh @@ -0,0 +1 @@ +open_url "https://ko-fi.com/stormux" diff --git a/.scripts/FreeDoom.sh b/.launch/FreeDoom.sh similarity index 100% rename from .scripts/FreeDoom.sh rename to .launch/FreeDoom.sh diff --git a/.launch/QuentinC Play Room.sh b/.launch/QuentinC Play Room.sh new file mode 100644 index 0000000..a7fbb4e --- /dev/null +++ b/.launch/QuentinC Play Room.sh @@ -0,0 +1 @@ +open_url "https://qcsalon.net/" diff --git a/.scripts/SlayTheSpire.sh b/.launch/SlayTheSpire.sh similarity index 100% rename from .scripts/SlayTheSpire.sh rename to .launch/SlayTheSpire.sh diff --git a/.scripts/TobyCustom/' b/.launch/TobyCustom/' similarity index 100% rename from .scripts/TobyCustom/' rename to .launch/TobyCustom/' diff --git a/.scripts/TobyCustom/.dependencies b/.launch/TobyCustom/.dependencies similarity index 100% rename from .scripts/TobyCustom/.dependencies rename to .launch/TobyCustom/.dependencies diff --git a/.scripts/TobyCustom/.mapmenu b/.launch/TobyCustom/.mapmenu similarity index 100% rename from .scripts/TobyCustom/.mapmenu rename to .launch/TobyCustom/.mapmenu diff --git a/.scripts/TobyCustom/ArmyOfDarknessDoom.sh b/.launch/TobyCustom/ArmyOfDarknessDoom.sh similarity index 100% rename from .scripts/TobyCustom/ArmyOfDarknessDoom.sh rename to .launch/TobyCustom/ArmyOfDarknessDoom.sh diff --git a/.scripts/TobyCustom/Custom_Death_Match.sh b/.launch/TobyCustom/Custom_Death_Match.sh similarity index 100% rename from .scripts/TobyCustom/Custom_Death_Match.sh rename to .launch/TobyCustom/Custom_Death_Match.sh diff --git a/.scripts/TobyCustom/GoMidievilOnTheirAss.sh b/.launch/TobyCustom/GoMidievilOnTheirAss.sh similarity index 100% rename from .scripts/TobyCustom/GoMidievilOnTheirAss.sh rename to .launch/TobyCustom/GoMidievilOnTheirAss.sh diff --git a/.scripts/TobyCustom/Project_Brutality.sh b/.launch/TobyCustom/Project_Brutality.sh similarity index 100% rename from .scripts/TobyCustom/Project_Brutality.sh rename to .launch/TobyCustom/Project_Brutality.sh diff --git a/.scripts/TobyCustom/Project_BrutalityLatest.sh b/.launch/TobyCustom/Project_BrutalityLatest.sh similarity index 100% rename from .scripts/TobyCustom/Project_BrutalityLatest.sh rename to .launch/TobyCustom/Project_BrutalityLatest.sh diff --git a/.scripts/TobyCustom/StarWars.sh b/.launch/TobyCustom/StarWars.sh similarity index 100% rename from .scripts/TobyCustom/StarWars.sh rename to .launch/TobyCustom/StarWars.sh diff --git a/.scripts/TobyCustom/WolfenDoom.sh b/.launch/TobyCustom/WolfenDoom.sh similarity index 100% rename from .scripts/TobyCustom/WolfenDoom.sh rename to .launch/TobyCustom/WolfenDoom.sh diff --git a/.launch/Trigaea.sh b/.launch/Trigaea.sh new file mode 100644 index 0000000..95fd31f --- /dev/null +++ b/.launch/Trigaea.sh @@ -0,0 +1 @@ +open_url "https://ryngm.itch.io/trigaea" diff --git a/.scripts/yadoom b/.launch/yadoom similarity index 100% rename from .scripts/yadoom rename to .launch/yadoom diff --git a/linux-game-manager.sh b/linux-game-manager.sh index 2eacdf2..c4f7622 100755 --- a/linux-game-manager.sh +++ b/linux-game-manager.sh @@ -485,20 +485,37 @@ game_update() { # launch games that are installed game_launcher() { - mapfile -t lines < <(sed '/^$/d' "${configFile}" 2> /dev/null) - # Create the menu of installed games + # Initialize array for menu construction 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%|*}") done - # Web based games and donation - menuList+=("Aliens" "Aliens") - menuList+=("Cacophony" "Cacophony") - menuList+=("Battle Weary" "Battle Weary") - menuList+=("QuentinC Play Room" "QuentinC Play Room") - menuList+=("Trigaea" "Trigaea") - menuList+=("Donate" "Donate") - game="$(dialog --backtitle "Linux Game Launcher" \ + # Sort the menu + mapfile -t sortedList < <( + for ((i=0; i<${#menuList[@]}; i+=2)); do + echo "${menuList[i+1]}|${menuList[i]}" + done | sort -f + ) + # Rebuild menuList from sorted entries + menuList=() + for entry in "${sortedList[@]}"; do + menuList+=("${entry#*|}" "${entry%|*}") + done + # Create the menu of all games + selectedGame="$(dialog --backtitle "Linux Game Launcher" \ --clear \ --no-tags \ --menu "Please select a game to play" 0 0 0 "${menuList[@]}" --stdout)" @@ -506,54 +523,39 @@ game_launcher() { if [[ $menuCode -eq 1 ]]; then exit 0 fi - # Remove any trailing | from game variable. - game="${game%|}" - case "${game}" in - "Aliens") - open_url "https://files.jantrid.net/aliens/" - ;; - "Battle Weary") - open_url "https://lonespelunker.itch.io/battle-weary" + # Remove any trailing | from selectedGame variable + selectedGame="${selectedGame%|}" + case "${selectedGame}" in + *".tin") + git -C "${selectedGame%/*}" pull | \ + dialog --progressbox "Checking for updates, please wait..." -1 -1 + if [[ -n "${COLORTERM}" ]]; then + terminal_emulator tt++ ${selectedGame##*/} + else + pushd "${selectedGame%/*}" + exec tt++ ${selectedGame##*/} + fi ;; - "Cacophony") - open_url "https://tianmaru.itch.io/cacophony" + *"main.py") + pushd "${selectedGame%/*}" + git pull -q | dialog --progressbox "Checking for updates, please wait..." -1 -1 + python3 ${selectedGame} ;; - "QuentinC Play Room") - open_url "https://qcsalon.net/" - ;; - "Trigaea") - open_url "https://ryngm.itch.io/trigaea" - ;; - "Donate") - open_url "https://ko-fi.com/stormux" - ;; - *".tin") - git -C "${game%/*}" pull | \ - dialog --progressbox "Checking for updates, please wait..." -1 -1 - if [[ -n "${COLORTERM}" ]]; then - terminal_emulator tt++ ${game##*/} + *.sh) + . "${selectedGame}" + ;; + *) + pushd "${selectedGame%/*}" + if file "${selectedGame##*/}" | grep -q "ELF.*x86-64"; then + if [[ "$(uname -m)" != "x86_64" ]]; then + exec FEXLoader -- ${selectedGame} else - pushd "${game%/*}" - exec tt++ ${game##*/} + exec ${selectedGame} fi - ;; - *"main.py") - pushd "${game%/*}" - 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 - ;; + else + exec ${selectedGame} + fi + ;; esac exit 0 }