All games updated to the new launch system. Game launcher function updated to totally use the new system. Temporary migration function added to make sure everyone gets updated to the new system without having to do it manually.
This commit is contained in:
parent
97057bb1f2
commit
81eb291bea
@ -489,35 +489,17 @@ game_update() {
|
|||||||
# launch games that are installed
|
# launch games that are installed
|
||||||
game_launcher() {
|
game_launcher() {
|
||||||
# Initialize array for menu construction
|
# Initialize array for menu construction
|
||||||
declare -a menuList
|
mapfile -t menuList < <(
|
||||||
# Read both config file and .launch files into lines array
|
|
||||||
mapfile -t lines < <(
|
|
||||||
sed '/^$/d' "${configFile}" 2> /dev/null
|
|
||||||
if [[ -d ".launch" ]]; then
|
if [[ -d ".launch" ]]; then
|
||||||
find -L "${0%/*}/.launch" -maxdepth 1 -type f -iname "*.sh" -exec bash -c '
|
find -L "${0%/*}/.launch" -maxdepth 1 -type f -iname "*.sh" -print0 | sort -z | xargs -0 bash -c '
|
||||||
for f; do
|
for f; do
|
||||||
[[ $(head -n1 "$f") =~ ^#$ ]] && continue
|
[[ $(head -n1 "$f") =~ ^#$ ]] && continue
|
||||||
name="${f##*/}"
|
name="${f##*/}"
|
||||||
echo "${name%.sh}|$f"
|
echo "$f"
|
||||||
done
|
echo "${name%.sh}"
|
||||||
' _ {} \;
|
done' _
|
||||||
fi
|
fi
|
||||||
)
|
)
|
||||||
# Add all entries to menu
|
|
||||||
for i in "${lines[@]}"; do
|
|
||||||
menuList+=("${i#*|}" "${i%|*}")
|
|
||||||
done
|
|
||||||
# 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 i in "${sortedList[@]}"; do
|
|
||||||
menuList+=("${i#*|}" "${i%|*}")
|
|
||||||
done
|
|
||||||
# Create the menu of all games
|
# Create the menu of all games
|
||||||
selectedGame="$(dialog --backtitle "Linux Game Launcher" \
|
selectedGame="$(dialog --backtitle "Linux Game Launcher" \
|
||||||
--clear \
|
--clear \
|
||||||
@ -527,29 +509,41 @@ game_launcher() {
|
|||||||
if [[ $menuCode -eq 1 ]]; then
|
if [[ $menuCode -eq 1 ]]; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
# Remove any trailing | from selectedGame variable
|
pushd "${selectedGame%/*}"
|
||||||
selectedGame="${selectedGame%|}"
|
if file "${selectedGame##*/}" | grep -q "ELF.*x86-64"; then
|
||||||
case "${selectedGame}" in
|
if [[ "$(uname -m)" != "x86_64" ]]; then
|
||||||
*.sh)
|
exec FEXLoader -- "${selectedGame#./}"
|
||||||
. "${selectedGame}"
|
else
|
||||||
;;
|
. "./${selectedGame##*/}"
|
||||||
*)
|
fi
|
||||||
pushd "${selectedGame%/*}"
|
else
|
||||||
if file "${selectedGame##*/}" | grep -q "ELF.*x86-64"; then
|
. "./${selectedGame##*/}"
|
||||||
if [[ "$(uname -m)" != "x86_64" ]]; then
|
fi
|
||||||
exec FEXLoader -- ${selectedGame}
|
|
||||||
else
|
|
||||||
exec ${selectedGame}
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
exec ${selectedGame}
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
migrate_launcher() {
|
||||||
|
# Check if config file exists
|
||||||
|
[[ -f "${configFile}" ]] || return
|
||||||
|
# Process each line of the config file
|
||||||
|
while IFS= read -r line; do
|
||||||
|
# Skip empty lines
|
||||||
|
[[ -z "${line}" ]] && continue
|
||||||
|
# Extract game name and path
|
||||||
|
gameName="${line%|*}"
|
||||||
|
# Create launcher script if it doesn't exist
|
||||||
|
if [[ ! -L "${0%/*}/.launch/${gameName}.sh" ]]; then
|
||||||
|
ln -srf "${0%/*}/.launch/${gameName}.game" "${0%/*}/.launch/${gameName}.sh"
|
||||||
|
fi
|
||||||
|
done < <(sed '/^$/d' "${configFile}")
|
||||||
|
# Move the old config file and notify user
|
||||||
|
mv "${configFile}" "${configFile}.bak"
|
||||||
|
dialog --backtitle "Linux Game manager" --msgbox \
|
||||||
|
"Games have been converted to the new launch system.\nThe old game launch information has been moved to ${configFile}.bak\nIf everything works like you expect, feel free to delete ${configFile}" -1 -1
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# If display isn't set assume we are launching from console and an X environment is running using display :0
|
# If display isn't set assume we are launching from console and an X environment is running using display :0
|
||||||
# Warning, launching games from console is not recommended.
|
# Warning, launching games from console is not recommended.
|
||||||
if [[ -z "$DISPLAY" ]]; then
|
if [[ -z "$DISPLAY" ]]; then
|
||||||
@ -574,6 +568,7 @@ export spd_rate="${spd_rate:+ -r ${spd_rate}}"
|
|||||||
export spd_voice="${spd_voice:+ -y ${spd_voice}}"
|
export spd_voice="${spd_voice:+ -y ${spd_voice}}"
|
||||||
export spd_volume="${spd_volume:+ -i ${spd_volume}}"
|
export spd_volume="${spd_volume:+ -i ${spd_volume}}"
|
||||||
mkdir -p "${installPath}"
|
mkdir -p "${installPath}"
|
||||||
|
migrate_launcher
|
||||||
|
|
||||||
|
|
||||||
# Check for required packages
|
# Check for required packages
|
||||||
|
Loading…
Reference in New Issue
Block a user