#!/usr/bin/env bash launch_game() { pushd "${doomPath}" exec stdbuf -oL ${gzdoom} ${@} | speak popd } speak() { 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}" | spd-say -e ${spd_module} ${spd_pitch} ${spd_rate} ${spd_voice} ${spd_volume} -- > /dev/null 2>&1; fi done } # 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 "yadoom" ]]; then export gzdoom=$(readlink -f "yadoom") else export gzdoom="$(command -v gzdoom)" fi # Version of the accessibility mod export tobyVersion="7-5" # Doom Addons mapfile -t doomAddons < <(find "$gamePath/Addons/DOOM/" -type f -name "TobyV${tobyVersion%%-*}_*.pk3" find "$gamePath/Addons/MENU/" -type f -name "TobyV${tobyVersion%%-*}_*.pk3" ) # Heretic Addons mapfile -t hereticAddons < <(find "$gamePath/Addons/HERETIC/" -type f -name "TobyHeretic*.pk3" find "$gamePath/Addons/MENU/" -type f -name "TobyV${tobyVersion%%-*}_*.pk3" ) doomGames=( # Toby demo map "TobyAccMod_V${tobyVersion}.pk3 Toby-Demo-Level.wad ${doomAddons[*]}" "Freedoom Toby Demo Map" # Unmodified Doom with accessibility. "TobyAccMod_V${tobyVersion}.pk3 ${doomAddons[*]}" "Freedoom" # Toby accessibility mods "TobyAccMod_V${tobyVersion}.pk3 TobyDoomLevels.wad Toby-Doom-Level-Music-Renamer.pk3 ${doomAddons[*]}" "Freedoom Toby Delux Map Pack" # OperationMDK "TobyAccMod_V${tobyVersion}.pk3 OpMDK.wad ${doomAddons[*]}" "Freedoom OperationMDK" # Unmodified Heretic with accessibility "TobyAccMod_V${tobyVersion}.pk3 ${hereticAddons[*]}" "Classic Heretic" # Heretic accessibility mods "TobyAccMod_V${tobyVersion}.pk3 TobyHereticLevels.wad ${hereticAddons[*]}" "Toby Heretic" "custom_game" "Custom Game" ) export antiGrepStrings=( '-E' '-v' '-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)" ) 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" <