diff --git a/.launch/FreeDoom.game b/.launch/FreeDoom.game index 9dab81f..4324353 100755 --- a/.launch/FreeDoom.game +++ b/.launch/FreeDoom.game @@ -1,417 +1,11 @@ #!/usr/bin/env bash -launch_game() { - pushd "${gamePath}" - #echo "exec stdbuf -oL ${gzdoom} ${@} | speak" - exec stdbuf -oL ${gzdoom} ${@} | speak - popd -} - -speak() { - if pgrep cthulhu ; then - speechProvider="socat - UNIX-CLIENT:/tmp/cthulhu.sock" - else - speechProvider="spd-say -e ${spd_module} ${spd_pitch} ${spd_rate} ${spd_voice} ${spd_volume} --" - fi - startSpeech=1 - while IFS= read -r line; do - echo "$line" - if [[ $startSpeech -eq 1 ]] && [[ "$line" =~ ^-{5,}$ ]]; then - startSpeech=0 - continue - fi - if [[ $startSpeech -eq 0 ]]; then - line=$(echo "${line}" | - grep "${antiGrepStrings[@]}" | - sed "${sedStrings[@]}") - if [[ "$doomLanguage" != "en" ]]; then - line=$(translate_text "$line") - fi - echo "${line}" | $speechProvider - fi - done -} - - -audio_manual() { - if command -v mpv &> /dev/null ; then - mediaPlayer=("mpv" "--really-quiet" "--no-video") - else - mediaPlayer=("play" "-qV0") - fi - local manualPath="${gamePath}/Manual" - declare -a menuList - for i in "${manualPath}"/*/ ; do - local path="${i%/}" - local name="${i/${manualPath}\//}" - local name="${name% *}" - menuList+=("$path" "$name") - done - manualPath="$(dialog --backtitle "Select a Manual" \ - --clear \ - --no-tags \ - --menu "Please select one" 0 0 0 "${menuList[@]}" --stdout)" - [[ $? -ne 0 ]] && exit 0 - # If user selected a manual, show the audio file menu - if [[ -n "$manualPath" ]]; then - declare -a audioList=("all" "Play All") # Start with "All" option - # Add all mp3 files to the menu - while IFS= read -r file; do - local filename="${file##*/}" - local menuname="${filename%.mp3}" - audioList+=("$file" "$menuname") - done < <(find "$manualPath" -name "*.mp3" | sort) - local selection - selection="$(dialog --backtitle "Select Audio Track" \ - --clear \ - --no-tags \ - --menu "Please select one" 0 0 0 "${audioList[@]}" --stdout)" - [[ $? -ne 0 ]] && exit 0 - if [[ -n "$selection" ]]; then - if [[ "$selection" == "all" ]]; then - # Play all files in order - find "$manualPath" -name "*.mp3" -print0 | sort -z | \ - while IFS= read -r -d '' file; do - "${mediaPlayer[@]}" "$file" - done - else - # Play selected file - "${mediaPlayer[@]}" "$selection" - return - fi - fi - fi -} - - -# Dialog setup: -DIALOG_ITEM_HELP="" -export DIALOGOPTS='--no-lines --visit-items' - - -# Toby games path -export gamePath=~/.local/games/doom -# Path where doom wads are stored -export doomPath="$(find /usr/share -type d -name "doom" 2> /dev/null | head -1)" - -# Path to gzdoom or yadoom. -if [[ -x "${BASH_SOURCE[0]%/*}/yadoom" ]]; then - export gzdoom="$(readlink -f "${BASH_SOURCE[0]%/*}/yadoom")" +gamePath=~/.local/games/doom +check_dependencies python-pyside6:PySide6 python-setproctitle:setproctitle +pushd "${gamePath}" +if ! [[ -d "toby-doom-launcher" ]]; then + git clone https://git.stormux.org/storm/toby-doom-launcher.git else - export gzdoom="$(command -v gzdoom)" + git -C "${gamePath}/toby-doom-launcher" pull fi - -# Version of the accessibility mod -export tobyVersion="8-0" - - -# Doom Addons -mapfile -t doomAddons < <(find "$gamePath/Addons/DOOM/" -type f -name "Toby*.pk3" - find "$gamePath/Addons/MENU/" -type f -name "Toby*.pk3" -) -# Heretic Addons -mapfile -t hereticAddons < <(find "$gamePath/Addons/HERETIC/" -type f -name "TobyHeretic*.pk3" - find "$gamePath/Addons/MENU/" -type f -name "Toby*.pk3" -) -# Hexen Addons -mapfile -t hexenAddons < <(find "$gamePath/Addons/HEXEN/" -type f -name "TobyHexen*.pk3" - find "$gamePath/Addons/MENU/" -type f -name "Toby*.pk3" -) - -doomGames=( - # Toby demo map - "${gamePath}/TobyAccMod_V${tobyVersion}.pk3 ${gamePath}/Addons/MAPS/Toby-Demo-Level.wad ${doomAddons[*]}" "Freedoom Toby Demo Map" - # Unmodified Doom with accessibility. - "${gamePath}/TobyAccMod_V${tobyVersion}.pk3 ${doomAddons[*]}" "Freedoom" - # Toby accessibility mods - "${gamePath}/TobyAccMod_V${tobyVersion}.pk3 ${gamePath}/Addons/MAPS/TobyDoomLevels.wad ${doomAddons[*]}" "Freedoom Toby Delux Map Pack" - # OperationMDK - "${gamePath}/TobyAccMod_V${tobyVersion}.pk3 ${gamePath}/OpMDK.wad ${doomAddons[*]}" "Freedoom OperationMDK" - # Unmodified Heretic with accessibility - "${gamePath}/TobyAccMod_V${tobyVersion}.pk3 ${hereticAddons[*]}" "Classic Heretic" - # Heretic accessibility mods - "${gamePath}/TobyAccMod_V${tobyVersion}.pk3 ${gamePath}/Addons/MAPS/TobyHereticLevels.wad ${hereticAddons[*]}" "Toby Heretic" - # Unmodified Hexen with accessibility - "${gamePath}/TobyAccMod_V${tobyVersion}.pk3 ${hexenAddons[*]}" "Classic Hexen" - # Heretic accessibility mods - "${gamePath}/TobyAccMod_V${tobyVersion}.pk3 ${gamePath}/Addons/MAPS/TobyHexen.pk3 ${hexenAddons[*]}" "Toby Hexen" - "custom_game" "Custom Game" -) - -export antiGrepStrings=( - '-E' '-v' - '-e' '^----+$' - '-e' '^$' - '-e' '^[0-9]' - '-e' '^P_StartScript:' - '-e' '^(Facing |fluidsynth |INTRO|MAP[0-9]+|Music "|Unknown)' - '-e' '^(\[Toby Accessibility Mod\] )?READ.*' - '-e' '^ *TITLEMAP' - '-e' '^\[Toby Accessibility Mod\] (INTRO|READMe)([0-9]+).*' - '-e' 'key card' - '-e' '^New PDA Entry:' - '-e' "^(As |Computer Voice:|Holy|I |I've|Monorail|Sector |Ugh|What|Where)" - '-e' 'Script warning, "' - '-e' 'Tried to define' -) - -export sedStrings=('-E' - '-e' 's/^\[Toby Accessibility Mod\] M_/[Toby Accessibility Mod] /' - '-e' 's/^\[Toby Accessibility Mod\] //' - '-e' 's/^MessageBoxMenu$/Confirmation menu: Press Y for yes or N for no/' - '-e' 's/^Mainmenu$/Main menu/' - '-e' 's/^Skillmenu$/Difficulty menu/' - '-e' 's/^NGAME$/New game/' - '-e' 's/^(LOAD|SAVE|QUIT)G$/\1 game/' - '-e' 's/"cl_run" = "true"/run/' - '-e' 's/"cl_run" = "false"/walk/' - #'-e' 's:.*/:Game saved. \(:' - '-e' 's/UAC/U A C/' - '-e' 's/^\+//' - '-e' 's/ ?\*+ ?//g' -) - -# Translation stuff -doomLanguage="${doomLanguage:-en}" -cache="${cache:-${XDG_CACHE_HOME:-$HOME/.cache}/linux-game-manager}" -translationDB="${cache}/doom_${doomLanguage}.sqlite" - -# Function to initialize SQLite database -init_translation_db() { - mkdir -p "$cache" - if [[ ! -f "$translationDB" ]]; then - sqlite3 "$translationDB" <