RetroDECK/emu-configs/gzdoom/gzdoom.sh

49 lines
1.6 KiB
Bash
Raw Normal View History

2023-11-23 09:59:00 +00:00
#!/bin/bash
LOG_FILE="$rdhome/.logs/gzdoom.log"
2023-11-24 23:13:07 +00:00
if [ -e "$LOG_FILE" ]; then
rm "$LOG_FILE"
fi
echo "RetroDECK GZDOOM wrapper init." | tee -a "$LOG_FILE"
2023-11-24 13:01:40 +00:00
# List of IWAD files
IWAD_FILES=("DOOM1.WAD" "DOOM.WAD" "DOOM2.WAD" "DOOM2F.WAD" "DOOM64.WAD" "TNT.WAD"
"PLUTONIA.WAD" "HERETIC1.WAD" "HERETIC.WAD" "HEXEN.WAD" "HEXDD.WAD"
"STRIFE0.WAD" "STRIFE1.WAD" "VOICES.WAD" "CHEX.WAD"
2023-11-30 08:37:26 +00:00
"CHEX3.WAD" "HACX.WAD" "freedoom1.wad" "freedoom2.wad" "freedm.wad" # unlicensed iwads
"doom_complete.pk3" # this includes them all
)
2023-11-23 09:59:00 +00:00
2023-11-24 23:13:07 +00:00
echo "Trying to load \"$1\"." | tee -a "$LOG_FILE"
if [ ! -e "$1" ]; then
echo "$1 not found. Quitting." | tee -a "$LOG_FILE"
exit 0
fi
2023-11-24 23:13:07 +00:00
filename=$(basename "$1") # Extracts only the filename from the full path
2023-11-30 08:37:26 +00:00
extension="${filename##*.}" # Extracts the file extension
2023-11-24 23:13:07 +00:00
2023-11-30 08:37:26 +00:00
if [ "$extension" == "doom" ]; then
map_file="$1"
iwad="-iwad $(head -n 1 "$map_file")"
file="-file $(tail -n +2 "$map_file" | sed 's/.*/-file &/')"
echo "Found a .doom file: $1, parsing it." | tee -a "$LOG_FILE"
echo "Calling GZDoom with: \"$iwad $file\"." | tee -a "$LOG_FILE"
gzdoom -config /var/config/gzdoom/gzdoom.ini $iwad $file | tee -a "$LOG_FILE"
2023-11-23 09:59:00 +00:00
else
2023-11-30 08:37:26 +00:00
shopt -s nocasematch # Enable case-insensitive matching
if [[ "${IWAD_FILES[@]}" =~ "$filename" ]]; then
type="iwad"
else
type="file"
fi
shopt -u nocasematch # Disable case-insensitive matching after use
echo "Found $type: $1, loading it." | tee -a "$LOG_FILE"
gzdoom -config /var/config/gzdoom/gzdoom.ini -$type "$1" | tee -a "$LOG_FILE"
2023-11-24 23:13:07 +00:00
fi