Added option for audio manual.
This commit is contained in:
parent
9fbc149e19
commit
e0e240848d
@ -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,6 +232,8 @@ if [[ "$doomLanguage" != "en" ]]; then
|
||||
init_translation_db
|
||||
fi
|
||||
|
||||
doomGames+=("manual" "Audio Manual")
|
||||
while [[ -z "${gameOption}" ]] || [[ "${gameOption}" == "manual" ]]; do
|
||||
gameOption="$(dialog --backtitle "Select your Doom!" \
|
||||
--clear \
|
||||
--no-tags \
|
||||
@ -191,6 +245,10 @@ gameOption="$(dialog --backtitle "Select your Doom!" \
|
||||
--help-label "Exit" \
|
||||
--menu "Please select one" 0 0 0 "${doomGames[@]}" --stdout)"
|
||||
buttonCode=$?
|
||||
if [[ "${gameOption}" == "manual" ]]; then
|
||||
audio_manual
|
||||
fi
|
||||
done
|
||||
if [[ -e "${gamePath}/DoomMetalVol7.wad" ]]; then
|
||||
gameOption+=" DoomMetalVol7.wad"
|
||||
elif [[ -e "${gamePath}/DoomMetalVol6.wad" ]]; then
|
||||
|
Loading…
Reference in New Issue
Block a user