Added option for audio manual.

This commit is contained in:
Storm Dragon 2024-12-28 17:52:24 -05:00
parent 9fbc149e19
commit e0e240848d

View File

@ -32,6 +32,58 @@ speak() {
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'
@ -180,7 +232,9 @@ if [[ "$doomLanguage" != "en" ]]; then
init_translation_db
fi
gameOption="$(dialog --backtitle "Select your Doom!" \
doomGames+=("manual" "Audio Manual")
while [[ -z "${gameOption}" ]] || [[ "${gameOption}" == "manual" ]]; do
gameOption="$(dialog --backtitle "Select your Doom!" \
--clear \
--no-tags \
--ok-label "Single Player" \
@ -190,7 +244,11 @@ gameOption="$(dialog --backtitle "Select your Doom!" \
--help-button \
--help-label "Exit" \
--menu "Please select one" 0 0 0 "${doomGames[@]}" --stdout)"
buttonCode=$?
buttonCode=$?
if [[ "${gameOption}" == "manual" ]]; then
audio_manual
fi
done
if [[ -e "${gamePath}/DoomMetalVol7.wad" ]]; then
gameOption+=" DoomMetalVol7.wad"
elif [[ -e "${gamePath}/DoomMetalVol6.wad" ]]; then