GZDOOM: fixed iwad recognition

This commit is contained in:
XargonWan 2023-12-19 13:56:53 +01:00
parent ba5cf403dc
commit 7a6320b5f3

View file

@ -11,15 +11,20 @@ IWAD_FILES=("DOOM1.WAD" "DOOM.WAD" "DOOM2.WAD" "DOOM2F.WAD" "DOOM64.WAD" "TNT.WA
# Function to log messages to terminal and a log file # Function to log messages to terminal and a log file
log() { log() {
local message="$1" local message="$1"
echo "$(date +"[%Y-%m-%d %H:%M:%S]"): $message" local logfile="$rdhome/.logs/gzdoom.log"
echo "$(date +"[%Y-%m-%d %H:%M:%S]"): $message" >> "$rdhome/.logs/gzdoom.log" local timestamp="$(date +[%Y-%m-%d\ %H:%M:%S])"
echo "$timestamp $message" | tee -a "$logfile"
} }
# Function to check if a file is an IWAD # Function to check if a file is an IWAD
is_iwad() { is_iwad() {
local file="$1" local file="$1"
local lowercase_file="$(basename "${file,,}")"
for iwad in "${IWAD_FILES[@]}"; do for iwad in "${IWAD_FILES[@]}"; do
if [[ "${iwad,,}" == "$(basename "${file,,}")" ]]; then if [[ "${iwad,,}" == "$lowercase_file" ]]; then
echo "true" echo "true"
return return
fi fi
@ -38,13 +43,14 @@ search_file_recursive() {
found_file="$directory/$file" found_file="$directory/$file"
else else
# Search recursively # Search recursively
found_file=$(find "$directory" -type f -name "$file" | head -n 1) local lowercase_file="$(echo "$file" | tr '[:upper:]' '[:lower:]')"
found_file=$(find "$directory" -type f -iname "$lowercase_file" | head -n 1)
fi fi
echo "$found_file" echo "$found_file"
} }
# Main script # Main script
log "[INFO] RetroDECK GZDOOM wrapper init"
# Check if $1 is not a .doom file # Check if $1 is not a .doom file
if [[ "${1##*.}" != "doom" ]]; then if [[ "${1##*.}" != "doom" ]]; then
@ -56,7 +62,8 @@ if [[ "${1##*.}" != "doom" ]]; then
fi fi
# Log the command # Log the command
log "Command: $command" log "[INFO] Loading: \"$1\""
log "[INFO] Executing command \"$command\""
# Execute the command # Execute the command
eval "$command" eval "$command"
@ -64,10 +71,11 @@ if [[ "${1##*.}" != "doom" ]]; then
# Check if $1 is a .doom file # Check if $1 is a .doom file
else else
doom_file="$1" doom_file="$1"
log "[INFO] Found a doom file: \"$1\""
# Check if the .doom file exists # Check if the .doom file exists
if [[ ! -e "$doom_file" ]]; then if [[ ! -e "$doom_file" ]]; then
log "Error: .doom file not found - $doom_file" log "[Error] doom file not found in \"$doom_file\""
zenity --error --no-wrap \ zenity --error --no-wrap \
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \ --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
--title "RetroDECK" \ --title "RetroDECK" \
@ -84,7 +92,7 @@ else
# If the file is not found, exit with an error # If the file is not found, exit with an error
if [[ -z "$found_file" ]]; then if [[ -z "$found_file" ]]; then
log "Error: File not found - $line" log "[ERROR] File not found in \"$line\""
zenity --error --no-wrap \ zenity --error --no-wrap \
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \ --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
--title "RetroDECK" \ --title "RetroDECK" \
@ -95,13 +103,15 @@ else
# Check if the file is an IWAD # Check if the file is an IWAD
if [[ $(is_iwad "$found_file") == "true" ]]; then if [[ $(is_iwad "$found_file") == "true" ]]; then
command+=" -iwad $found_file" command+=" -iwad $found_file"
log "[INFO] Appending the param \"-iwad $found_file\""
else else
command+=" -file $found_file" command+=" -file $found_file"
log "[INFO] Appending the param \"-file $found_file\""
fi fi
done < "$doom_file" done < "$doom_file"
# Log the command # Log the command
log "Command: $command" log "[INFO] Executing command \"$command\""
# Execute the command # Execute the command
eval "$command" eval "$command"