diff --git a/.scripts/FreeDoom.sh b/.scripts/FreeDoom.sh index 04bba59..efd9aa3 100755 --- a/.scripts/FreeDoom.sh +++ b/.scripts/FreeDoom.sh @@ -24,6 +24,25 @@ doomGames=( "${gzdoom} ${doomPath}/TobyAccMod_V${tobyVersion}.pk3 ${doomPath}/OpMDK.wad" "Freedoom OperationMDK" ) +grepStrings=( + '-E' + '-e' '^[0-9]+\. ' + '-e' '^"cl_run"' + '-e' '^Game saved. ' + '-e' '^A secret is revealed!$' + '-e' '^MAP[0-9]*' + '-e' '^Player was ' + '-e' '^Please select a game wad \(or 0 to exit\):' + '-e' '^You have no keys in your pocket!$' +) + +sedStrings=( + '-e' 's/"cl_run" = "true"/run/' + '-e' 's/"cl_run" = "false"/walk/' + '-e' 's/MAP0\([1-9]\)/Map \1/' + '-e' 's:.*/:Game saved. (:' +) + gameOption="$(dialog --backtitle "Select your Doom!" \ --clear \ --no-tags \ @@ -39,7 +58,9 @@ buttonCode=$? case ${buttonCode} in 1) # Death match setup - echo "Not yet implemented." + dialog --backtitle "Death Match" \ + --clear \ + --msgbox "Coming soon!" -1 -1 --stdout exit 1 ;; 2) @@ -48,23 +69,50 @@ case ${buttonCode} in ;; 3) # Co-op setup - echo "Not yet implemented." - exit 1 + ipAddress="$(dialog --backtitle "Co-op Options" \ + --clear \ + --no-tags \ + --ok-label "Join" \ + --cancel-label "Exit" \ + --extra-button \ + --extra-label "Host" \ + --inputbox "Enter ip or URL, required for join." -1 -1 --stdout)" + buttonCode=$? + [[ $buttonCode -eq 1 ]] && exit 0 + if [[ $buttonCode -eq 0 ]]; then + if [[ "${#ipAddress}" -lt 3 ]]; then + dialog --backtitle "Co-op" --clear --msgbox "No ip address or URL given." -1 -1 --stdout + exit 1 + fi + flags=('-join' "${ipAddress}") + else + # Get ip address + yourIpAddress="$(curl -4s https://icanhazip.com)" + players="$(dialog --backtitle "Host Co-op Game" \ + --clear \ + --ok-label "Next" \ + --cancel-label "Exit" \ + --rangebox "Select number of players. Remember to give them your IP address: ${yourIpAddress}" -1 -1 2 10 --stdout)" + [[ $? -eq 1 ]] && exit 0 + skillLevel="$(dialog --backtitle "Host Co-op Game" \ + --clear \ + --ok-label "Start" \ + --cancel-label "Exit" \ + --rangebox "Select difficulty. 1 easiest, 3 hardest." -1 -1 1 3 2 --stdout)" + [[ $? -eq 1 ]] && exit 0 + flags=( + '-host' "${players}" + '-skill' "${skillLevel}" + '+set' 'sv_cheats 1' + '+set' 'sv_weaponsstay 1' + '+set' 'sv_respawnprotect 1' + '-extratic' '-dup 3' + ) + fi + exec stdbuf -oL ${gameOption} "${flags[@]}" | stdbuf -oL grep "${grepStrings[@]}" | stdbuf -oL sed "${sedStrings[@]}" | spd-say -e ;; 0) - exec stdbuf -oL ${gameOption} | stdbuf -oL grep -E \ - -e '^[0-9]+\. ' \ - -e '^"cl_run"' \ - -e '^Game saved. ' \ - -e '^A secret is revealed!$' \ - -e '^MAP[0-9]*' \ - -e '^Player was ' \ - -e '^Please select a game wad \(or 0 to exit\):' \ - -e '^You have no keys in your pocket!$' | stdbuf -oL sed \ - -e 's/"cl_run" = "true"/run/' \ - -e 's/"cl_run" = "false"/walk/' \ - -e 's/MAP0\([1-9]\)/Map \1/' \ - -e 's:.*/:Game saved. (:' | spd-say -e + exec stdbuf -oL ${gameOption} | stdbuf -oL grep "${grepStrings[@]}" | stdbuf -oL sed "${sedStrings[@]}" | spd-say -e ;; esac