Compression tool upgrades

This commit is contained in:
icenine451 2023-03-29 15:51:27 -04:00
parent db6d28d64f
commit 0186ded2b9
6 changed files with 392 additions and 170 deletions

View file

@ -1,38 +1,35 @@
[chd]
dreamcast
psx
ps2
[chd-maybe]
3do
amiga
amiga1200
amiga600
amigacd32
cdimono1
cdtv
dreamcast
gamegear
genesis
mame-advmame
mame-mame4all
mastersystem
megacd
megacdjp
megadrive
mess
neogeo
neogeocd
neogeocdjp
pcengine
pcenginecd
pcfx
ps2
psx
ps2
saturn
saturnjp
segacd
sg-1000
supergrafx
tg16
tg-cd
[rvz]
gc
wii
[zip]
atari2600
atari5200
atari7800
atari800
atarijaguar
atarilynx
atarist
gamegear
gb
gba
gbc
genesis
mastersystem
nds
nes
snes
snesna

View file

@ -0,0 +1,60 @@
.32x
.68k
.NDS
.a26
.a52
.a78
.abs
.agb
.atr
.atx
.bin
.bml
.bms
.bs
.bsx
.cas
.cdm
.cgb
.cof
.col
.dim
.dmg
.dx2
.fds
.fig
.gb
.gba
.gbc
.gd3
.gd7
.gen
.gg
.ipf
.j64
.jag
.lnx
.md
.mdx
.mgd
.msa
.nds
.nes
.o
.prg
.rom
.sfc
.sg
.sgb
.sgd
.smc
.smd
.sms
.st
.st
.stx
.swc
.unf
.unif
.xex
.xfd

View file

@ -116,103 +116,184 @@ move() {
fi
}
compress_to_chd () {
compress_game() {
# Function for compressing one or more files to .chd format
# USAGE: compress_to_chd $full_path_to_input_file $full_path_to_output_file
# USAGE: compress_game $format $full_path_to_input_file
local file="$2"
local filename_no_path=$(basename "$file")
local filename_no_extension="${filename_no_path%.*}"
local source_file=$(dirname "$(realpath "$file")")"/"$(basename "$file")
local dest_file=$(dirname "$(realpath "$file")")"/""$filename_no_extension"
echo "Compressing file $1 to $2.chd"
/app/bin/chdman createcd -i "$1" -o "$2".chd
if [[ "$1" == "chd" ]]; then
/app/bin/chdman createcd -i "$source_file" -o "$dest_file".chd
elif [[ "$1" == "zip" ]]; then
zip -jq9 "$dest_file".zip "$source_file"
elif [[ "$1" == "rvz" ]]; then
dolphin-tool convert -f rvz -b 131072 -c zstd -l 5 -i "$source_file" -o "$dest_file.rvz"
fi
}
validate_for_chd () {
find_compatible_compression_format() {
# This function will determine what compression format, if any, the file and system are compatible with
# USAGE: find_compatible_compression_format "$file"
local normalized_filename=$(echo "$1" | tr '[:upper:]' '[:lower:]')
local system=$(echo "$1" | grep -oE "$roms_folder/[^/]+" | grep -oE "[^/]+$")
if [[ $(validate_for_chd "$1") == "true" ]] && [[ $(sed -n '/^\[/{h;d};/\b'"$system"'\b/{g;s/\[\(.*\)\]/\1/p;q};' $compression_targets) == "chd" ]]; then
echo "chd"
elif grep -qF ".${normalized_filename##*.}" $zip_compressable_extensions && [[ $(sed -n '/^\[/{h;d};/\b'"$system"'\b/{g;s/\[\(.*\)\]/\1/p;q};' $compression_targets) == "zip" ]]; then
echo "zip"
elif echo "$normalized_filename" | grep -qE '\.iso|\.gcm' && [[ $(sed -n '/^\[/{h;d};/\b'"$system"'\b/{g;s/\[\(.*\)\]/\1/p;q};' $compression_targets) == "rvz" ]]; then
echo "rvz"
else
# If no compatible format can be found for the input file
echo "none"
fi
}
validate_for_chd() {
# Function for validating chd compression candidates, and compresses if validation passes. Supports .cue, .iso and .gdi formats ONLY
# USAGE: validate_for_chd $input_file
local file="$1"
local normalized_filename=$(echo "$file" | tr '[:upper:]' '[:lower:]')
local normalized_filename=$(echo "$file" | tr '[:upper:]' '[:lower:]')
local file_validated="false"
current_run_log_file="chd_compression_$(basename "$file").log"
echo "Validating file:" "$file" > "$logs_folder/$current_run_log_file"
if [[ "$normalized_filename" == *".cue" ]] || [[ "$normalized_filename" == *".gdi" ]] || [[ "$normalized_filename" == *".iso" ]]; then
echo ".cue/.iso/.gdi file detected" >> "$logs_folder/$current_run_log_file"
chd_validation_log_file="compression_$(basename "$file").log"
echo "Validating file:" "$file" > "$logs_folder/$chd_validation_log_file"
if echo "$normalized_filename" | grep -qE '\.iso|\.cue|\.gdi'; then
echo ".cue/.iso/.gdi file detected" >> "$logs_folder/$chd_validation_log_file"
local file_path=$(dirname "$(realpath "$file")")
local file_base_name=$(basename "$file")
local file_name=${file_base_name%.*}
if [[ "$normalized_filename" == *".cue" ]]; then # Validate .cue file
echo "Validating .cue associated .bin files" >> "$logs_folder/$current_run_log_file"
echo "Validating .cue associated .bin files" >> "$logs_folder/$chd_validation_log_file"
local cue_bin_files=$(grep -o -P "(?<=FILE \").*(?=\".*$)" "$file")
echo "Associated bin files read:" >> "$logs_folder/$current_run_log_file"
printf '%s\n' "$cue_bin_files" >> "$logs_folder/$current_run_log_file"
while IFS= read -r line
do
echo "looking for $file_path/$line" >> "$logs_folder/$current_run_log_file"
if [[ -f "$file_path/$line" ]]; then
echo ".bin file found at $file_path/$line" >> "$logs_folder/$current_run_log_file"
file_validated="true"
else
echo ".bin file NOT found at $file_path/$line" >> "$logs_folder/$current_run_log_file"
echo ".cue file could not be validated. Please verify your .cue file contains the correct corresponding .bin file information and retry." >> "$logs_folder/$current_run_log_file"
file_validated="false"
break
fi
done < <(printf '%s\n' "$cue_bin_files")
if [[ $file_validated == "true" ]]; then
echo $file_validated
echo "Associated bin files read:" >> "$logs_folder/$chd_validation_log_file"
printf '%s\n' "$cue_bin_files" >> "$logs_folder/$chd_validation_log_file"
if [[ ! -z "$cue_bin_files" ]]; then
while IFS= read -r line
do
echo "looking for $file_path/$line" >> "$logs_folder/$chd_validation_log_file"
if [[ -f "$file_path/$line" ]]; then
echo ".bin file found at $file_path/$line" >> "$logs_folder/$chd_validation_log_file"
file_validated="true"
else
echo ".bin file NOT found at $file_path/$line" >> "$logs_folder/$chd_validation_log_file"
echo ".cue file could not be validated. Please verify your .cue file contains the correct corresponding .bin file information and retry." >> "$logs_folder/$chd_validation_log_file"
file_validated="false"
break
fi
done < <(printf '%s\n' "$cue_bin_files")
fi
echo $file_validated
else # If file is a .iso or .gdi
file_validated="true"
echo $file_validated
fi
else
echo "File type not recognized. Supported file types are .cue, .gdi and .iso" >> "$logs_folder/$current_run_log_file"
echo "File type not recognized. Supported file types are .cue, .gdi and .iso" >> "$logs_folder/$chd_validation_log_file"
echo $file_validated
fi
}
cli_compress_file() {
cli_compress_single_game() {
# This function will compress a single file passed from the CLI arguments
# USAGE: cli_compress_file $full_file_path
local file="$1"
echo "Looking for" "$file"
current_run_log_file="chd_compression_$(basename "$file").log"
# USAGE: cli_compress_single_game $full_file_path
local file=$(realpath "$1")
read -p "Do you want to have the original file removed after compression is complete? Please answer y/n and press Enter: " post_compression_cleanup
read -p "RetroDECK will now attempt to compress your selected game. Press Enter key to continue..."
if [[ ! -z "$file" ]]; then
if [[ -f "$file" ]]; then
if [[ $(validate_for_chd "$file") == "true" ]]; then
read -p "RetroDECK will now attempt to compress your selected game. Press Enter key to continue..."
read -p "Do you want to have the original file removed after compression is complete? Please answer y/n and press Enter: " post_compression_cleanup
local filename_no_path=$(basename "$file")
local filename_no_extension="${filename_no_path%.*}"
local source_file=$(dirname "$(realpath "$file")")"/"$(basename "$file")
local dest_file=$(dirname "$(realpath "$file")")"/""$filename_no_extension"
echo "Compressing $filename_no_path"
compress_to_chd "$source_file" "$dest_file"
if [[ $post_compression_cleanup == [yY] ]]; then # Remove file(s) if requested
if [[ "$file" == *".cue" ]]; then
check_system=$(echo "$file" | grep -oE "$roms_folder/[^/]+" | grep -oE "[^/]+$")
local compatible_compression_format=$(find_compatible_compression_format "$file")
if [[ ! $compatible_compression_format == "none" ]]; then
echo "$(basename "$file") can be compressed to $compatible_compression_format"
compress_game "$compatible_compression_format" "$file"
if [[ $post_compression_cleanup == [yY] ]]; then # Remove file(s) if requested
if [[ $(basename "$file") == *".cue" ]]; then
local cue_bin_files=$(grep -o -P "(?<=FILE \").*(?=\".*$)" "$file")
local file_path=$(dirname "$(realpath "$file")")
while IFS= read -r line
do # Remove associated .bin files
echo "Removing file "$line""
do # Remove associated .bin files
echo "Removing original file "$file_path/$line""
rm -f "$file_path/$line"
done < <(printf '%s\n' "$cue_bin_files") # Remove original .cue file
echo "Removing file "$filename_no_path""
rm -f $(realpath "$file")
echo "Removing original file $(basename "$file")"
rm -f "$file"
else
echo "Removing file "$filename_no_path""
rm -f $(realpath "$file")
echo "Removing original file $(basename "$file")"
rm -f "$file"
fi
fi
else
printf "An error occured during the compression process. Please see the following log entries for details:\n\n"
cat "$logs_folder/$current_run_log_file"
fi
fi
else
echo "$(basename "$file") does not have any compatible compression formats."
fi
else
echo "File not found, please specify the full path to the file to be compressed."
fi
else
echo "Please use this command format \"--compress <cue/gdi/iso file to compress>\""
echo "Please use this command format \"--compress-one <path to file to compress>\""
fi
}
cli_compress_all_games() {
if echo "$1" | grep -qE 'chd|rvz|zip'; then
local compression_format="$1"
elif [[ "$1" == "all" ]]; then
local compression_format="all"
else
echo "Please enter a supported compression format. Options are \"chd\", \"rvz\", \"zip\" or \"all\""
exit 1
fi
local compressable_game=""
local all_compressable_games=()
if [[ $compression_format == "all" ]]; then
local compressable_systems_list=$(cat $compression_targets | sed '/^$/d' | sed '/^\[/d')
else
local compressable_systems_list=$(sed -n '/\['"$compression_format"'\]/, /\[/{ /\['"$compression_format"'\]/! { /\[/! p } }' $compression_targets | sed '/^$/d')
fi
read -p "Do you want to have the original files removed after compression is complete? Please answer y/n and press Enter: " post_compression_cleanup
read -p "RetroDECK will now attempt to compress all compatible games. Press Enter key to continue..."
while IFS= read -r system # Find and validate all games that are able to be compressed with this compression type
do
local compression_candidates=$(find "$roms_folder/$system" -type f -not -iname "*.txt")
if [[ ! -z "$compression_candidates" ]]; then
echo "Checking files for $system"
while IFS= read -r file
do
local compatible_compression_format=$(find_compatible_compression_format "$file")
if [[ ! "$compatible_compression_format" == "none" ]]; then
echo "$(basename "$file") can be compressed to $compatible_compression_format"
compress_game "$compatible_compression_format" "$file"
if [[ $post_compression_cleanup == [yY] ]]; then # Remove file(s) if requested
if [[ "$file" == *".cue" ]]; then
local cue_bin_files=$(grep -o -P "(?<=FILE \").*(?=\".*$)" "$file")
local file_path=$(dirname "$(realpath "$file")")
while IFS= read -r line
do # Remove associated .bin files
echo "Removing original file "$file_path/$line""
rm -f "$file_path/$line"
done < <(printf '%s\n' "$cue_bin_files") # Remove original .cue file
echo "Removing original file "$file""
rm -f $(realpath "$file")
else
echo "Removing original file "$file""
rm -f $(realpath "$file")
fi
fi
else
echo "No compatible compression format found for $(basename "$file")"
fi
done < <(printf '%s\n' "$compression_candidates")
else
echo "No compatible files found for compression in $system"
fi
done < <(printf '%s\n' "$compressable_systems_list")
}
desktop_mode_warning() {
# This function is a generic warning for issues that happen when running in desktop mode.
# Running in desktop mode can be verified with the following command: if [[ ! $XDG_CURRENT_DESKTOP == "gamescope" ]]; then

View file

@ -12,6 +12,7 @@ rd_defaults="$emuconfigs/defaults/retrodeck/retrodeck.cfg"
rd_update_patch="/var/config/retrodeck/rd_update.patch" # A static location for the temporary patch file used during retrodeck.cfg updates
bios_checklist="$emuconfigs/defaults/retrodeck/bios_checklist.cfg" # A config file listing BIOS file information that can be verified
compression_targets="$emuconfigs/defaults/retrodeck/compression_targets.cfg" # A config file containing supported compression types per system
zip_compressable_extensions="$emuconfigs/defaults/retrodeck/zip_compressable_extensions.cfg" # A config file containing every file extension that is allowed to be compressed to .zip format, because there are a lot!
easter_egg_checklist="$emuconfigs/defaults/retrodeck/easter_egg_checklist.cfg" # A config file listing days and times when special splash screens should show up
input_validation="$emuconfigs/defaults/retrodeck/input_validation.cfg" # List of valid CLI inputs
splashscreen_dir="/var/config/emulationstation/.emulationstation/resources/graphics/extra-splashes" # The default location of extra splash screens

View file

@ -18,7 +18,8 @@ Arguments:
-v, --version Print RetroDECK version
--info-msg Print paths and config informations
--configurator Starts the RetroDECK Configurator
--compress <file> Compresses target file to .chd format. Supports .cue, .iso and .gdi formats
--compress-one <file> Compresses target file to a compatible format
--compress-all <format> Compresses all supported games into compatible format. Available formats are \"chd\", \"zip\", \"rvz\" and \"all\".
--reset-emulator <emulator> Reset one or more emulator configs to the default values
--reset-retrodeck Starts the initial RetroDECK installer (backup your data first!)
@ -39,10 +40,13 @@ https://retrodeck.net
cat $rd_conf
exit
;;
--compress*)
cli_compress_file "$2"
--compress-one*)
cli_compress_single_game "$2"
exit
;;
--compress-all*)
cli_compress_all_games "$2"
;;
--configurator*)
sh /app/tools/configurator.sh
exit

View file

@ -421,28 +421,32 @@ configurator_retroarch_options_dialog() {
configurator_compress_single_game_dialog() {
local file=$(file_browse "Game to compress")
if [[ ! -z "$file" ]]; then
if [[ $(validate_for_chd "$file") == "true" ]]; then
local compatible_compression_format=$(find_compatible_compression_format "$file")
if [[ ! $compatible_compression_format == "none" ]]; then
local post_compression_cleanup=$(configurator_compression_cleanup_dialog)
local filename_no_path=$(basename "$file")
local filename_no_extension="${filename_no_path%.*}"
local source_file=$(dirname "$(realpath "$file")")"/"$(basename "$file")
local dest_file=$(dirname "$(realpath "$file")")"/""$filename_no_extension"
(
echo "# Compressing $filename_no_path, please wait..."
compress_to_chd "$source_file" "$dest_file"
if [[ $post_compression_cleanup == "true" ]]; then # Remove file(s) if requested
if [[ "$file" == *".cue" ]]; then
local cue_bin_files=$(grep -o -P "(?<=FILE \").*(?=\".*$)" "$file")
local file_path=$(dirname "$(realpath "$file")")
while IFS= read -r line
do
echo "# Removing file $line"
rm -f "$file_path/$line"
done < <(printf '%s\n' "$cue_bin_files")
echo "# Removing file $filename_no_path"
rm -f "$file"
else
echo "# Removing file $filename_no_path"
if [[ $compatible_compression_format == "chd" ]]; then
if [[ $(validate_for_chd "$file") == "true" ]]; then
echo "# Compressing $(basename "$file") to $compatible_compression_format format"
compress_game "chd" "$file"
if [[ $post_compression_cleanup == "true" ]]; then # Remove file(s) if requested
if [[ "$file" == *".cue" ]]; then
local cue_bin_files=$(grep -o -P "(?<=FILE \").*(?=\".*$)" "$file")
local file_path=$(dirname "$(realpath "$file")")
while IFS= read -r line
do
rm -f "$file_path/$line"
done < <(printf '%s\n' "$cue_bin_files")
rm -f "$file"
else
rm -f "$file"
fi
fi
fi
else
echo "# Compressing $(basename "$file") to $compatible_compression_format format"
compress_game "$compatible_compression_format" "$file"
if [[ $post_compression_cleanup == "true" ]]; then # Remove file(s) if requested
rm -f "$file"
fi
fi
@ -452,8 +456,9 @@ configurator_compress_single_game_dialog() {
--title "RetroDECK Configurator Utility - Compression in Progress"
configurator_generic_dialog "The compression process is complete!"
configurator_compress_games_dialog
else
configurator_generic_dialog "File type not recognized. Supported file types are .cue, .gdi and .iso"
configurator_generic_dialog "The selected file does not have any compatible compressed format."
configurator_compress_games_dialog
fi
else
@ -462,27 +467,55 @@ configurator_compress_single_game_dialog() {
fi
}
configurator_compress_multi_game_dialog() {
# This dialog will display any games it finds to be compressable, from the systems listed under each compression type in
local compression_format=$1
local compressable_game=""
configurator_compress_some_games_dialog() {
# This dialog will display any games it finds to be compressable, from the systems listed under each compression type in compression_targets.cfg
local compressable_games_list=()
local all_compressable_games=()
local compressable_systems_list=$(sed -n '/\['"$compression_format"'\]/, /\[/{ /\['"$compression_format"'\]/! { /\[/! p } }' $compression_targets | sed '/^$/d')
local games_to_compress=()
if [[ ! -z "$1" ]]; then
local compression_format="$1"
else
local compression_format="all"
fi
if [[ $compression_format == "all" ]]; then
local compressable_systems_list=$(cat $compression_targets | sed '/^$/d' | sed '/^\[/d')
else
local compressable_systems_list=$(sed -n '/\['"$compression_format"'\]/, /\[/{ /\['"$compression_format"'\]/! { /\[/! p } }' $compression_targets | sed '/^$/d')
fi
while IFS= read -r system # Find and validate all games that are able to be compressed with this compression type
do
if [[ $compression_format == "chd" ]]; then
compression_candidates=$(find "$roms_folder/$system" -type f \( -name "*.cue" -o -name "*.iso" -o -name "*.gdi" \) ! -path "*.m3u*")
# TODO: Add ZIP file compression search here
compression_candidates=$(find "$roms_folder/$system" -type f -not -iname "*.txt")
if [[ ! -z $compression_candidates ]]; then
while IFS= read -r game
do
local compatible_compression_format=$(find_compatible_compression_format "$game")
if [[ $compression_format == "chd" ]]; then
if [[ $compatible_compression_format == "chd" ]]; then
all_compressable_games=("${all_compressable_games[@]}" "$game")
compressable_games_list=("${compressable_games_list[@]}" "false" "${game#$roms_folder}" "$game")
fi
elif [[ $compression_format == "zip" ]]; then
if [[ $compatible_compression_format == "zip" ]]; then
all_compressable_games=("${all_compressable_games[@]}" "$game")
compressable_games_list=("${compressable_games_list[@]}" "false" "${game#$roms_folder}" "$game")
fi
elif [[ $compression_format == "rvz" ]]; then
if [[ $compatible_compression_format == "rvz" ]]; then
all_compressable_games=("${all_compressable_games[@]}" "$game")
compressable_games_list=("${compressable_games_list[@]}" "false" "${game#$roms_folder}" "$game")
fi
elif [[ $compression_format == "all" ]]; then
if [[ ! $compatible_compression_format == "none" ]]; then
all_compressable_games=("${all_compressable_games[@]}" "$game")
compressable_games_list=("${compressable_games_list[@]}" "false" "${game#$roms_folder}" "$game")
fi
fi
done < <(printf '%s\n' "$compression_candidates")
fi
while IFS= read -r game
do
if [[ $(validate_for_chd "$game") == "true" ]]; then
all_compressable_games=("${all_compressable_games[@]}" "$game")
compressable_games_list=("${compressable_games_list[@]}" "false" "${game#$roms_folder}" "$game")
fi
done < <(printf '%s\n' "$compression_candidates")
done < <(printf '%s\n' "$compressable_systems_list")
choice=$(zenity \
@ -497,76 +530,104 @@ configurator_compress_multi_game_dialog() {
local rc=$?
if [[ $rc == "0" && ! -z $choice ]]; then # User clicked "Compress Selected" with at least one game selected
local post_compression_cleanup=$(configurator_compression_cleanup_dialog)
IFS="," read -ra games_to_compress <<< "$choice"
local total_games_to_compress=${#games_to_compress[@]}
local games_left_to_compress=$total_games_to_compress
elif [[ ! -z $choice ]]; then # User clicked "Compress All"
games_to_compress=("${all_compressable_games[@]}")
local total_games_to_compress=${#all_compressable_games[@]}
local games_left_to_compress=$total_games_to_compress
fi
if [[ ! $(echo "${#games_to_compress[@]}") == "0" ]]; then
local post_compression_cleanup=$(configurator_compression_cleanup_dialog)
(
for file in "${games_to_compress[@]}"; do
local filename_no_path=$(basename "$file")
local filename_no_extension="${filename_no_path%.*}"
local source_file=$(dirname "$(realpath "$file")")"/"$(basename "$file")
local dest_file=$(dirname "$(realpath "$file")")"/""$filename_no_extension"
echo "# Compressing $filename_no_path" # Update Zenity dialog text
compress_to_chd "$source_file" "$dest_file"
local compression_format=$(find_compatible_compression_format "$file")
echo "# Compressing $(basename "$file") into $compression_format format" # Update Zenity dialog text
progress=$(( 100 - (( 100 / "$total_games_to_compress" ) * "$games_left_to_compress" )))
echo $progress
games_left_to_compress=$((games_left_to_compress-1))
compress_game "$compression_format" "$file"
if [[ $post_compression_cleanup == "true" ]]; then # Remove file(s) if requested
if [[ "$file" == *".cue" ]]; then
local cue_bin_files=$(grep -o -P "(?<=FILE \").*(?=\".*$)" "$file")
local file_path=$(dirname "$(realpath "$file")")
while IFS= read -r line
do
echo "# Removing file $line"
rm -f "$file_path/$line"
done < <(printf '%s\n' "$cue_bin_files")
echo "# Removing file $filename_no_path"
rm -f $(realpath "$file")
else
echo "# Removing file $filename_no_path"
rm -f "$(realpath "$file")"
fi
fi
done
) |
zenity --icon-name=net.retrodeck.retrodeck --progress --no-cancel --pulsate --auto-close \
zenity --icon-name=net.retrodeck.retrodeck --progress --no-cancel --auto-close \
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
--title "RetroDECK Configurator Utility - Compression in Progress"
configurator_generic_dialog "The compression process is complete!"
configurator_compress_games_dialog
else
if [[ ! -z $choice ]]; then # User clicked "Compress All"
local post_compression_cleanup=$(configurator_compression_cleanup_dialog)
(
for file in "${all_compressable_games[@]}"; do
local filename_no_path=$(basename "$file")
local filename_no_extension="${filename_no_path%.*}"
local source_file=$(dirname "$(realpath "$file")")"/"$(basename "$file")
local dest_file=$(dirname "$(realpath "$file")")"/""$filename_no_extension"
echo "# Compressing $filename_no_path" # Update Zenity dialog text
compress_to_chd "$source_file" "$dest_file"
if [[ $post_compression_cleanup == "true" ]]; then # Remove file(s) if requested
if [[ "$file" == *".cue" ]]; then
local cue_bin_files=$(grep -o -P "(?<=FILE \").*(?=\".*$)" "$file")
local file_path=$(dirname "$(realpath "$file")")
while IFS= read -r line
do
echo "# Removing file $line"
rm -f "$file_path/$line"
done < <(printf '%s\n' "$cue_bin_files")
echo "# Removing file $filename_no_path"
rm -f $(realpath "$file")
else
echo "# Removing file $filename_no_path"
rm -f $(realpath "$file")
fi
configurator_compress_games_dialog
fi
}
configurator_compress_all_games_dialog() {
# This dialog compress all games found in all compatible roms folders into compatible formats
local all_compressable_games=()
local compressable_systems_list=$(cat $compression_targets | sed '/^$/d' | sed '/^\[/d')
while IFS= read -r system # Find and validate all games that are able to be compressed with this compression type
do
compression_candidates=$(find "$roms_folder/$system" -type f -not -iname "*.txt")
if [[ ! -z $compression_candidates ]]; then
while IFS= read -r game
do
local compatible_compression_format=$(find_compatible_compression_format "$game")
if [[ ! $compatible_compression_format == "none" ]]; then
all_compressable_games=("${all_compressable_games[@]}" "$game")
fi
done
done < <(printf '%s\n' "$compression_candidates")
fi
done < <(printf '%s\n' "$compressable_systems_list")
if [[ ! $(echo ${all_compressable_games[@]}) == "0" ]]; then
local post_compression_cleanup=$(configurator_compression_cleanup_dialog)
total_games_to_compress=${#all_compressable_games[@]}
games_left_to_compress=$total_games_to_compress
(
for file in "${all_compressable_games[@]}"; do
local compression_format=$(find_compatible_compression_format "$file")
echo "# Compressing $(basename "$file") into $compression_format format" # Update Zenity dialog text
progress=$(( 100 - (( 100 / "$total_games_to_compress" ) * "$games_left_to_compress" )))
echo $progress
games_left_to_compress=$((games_left_to_compress-1))
compress_game "$compression_format" "$file"
if [[ $post_compression_cleanup == "true" ]]; then # Remove file(s) if requested
if [[ "$file" == *".cue" ]]; then
local cue_bin_files=$(grep -o -P "(?<=FILE \").*(?=\".*$)" "$file")
local file_path=$(dirname "$(realpath "$file")")
while IFS= read -r line
do
rm -f "$file_path/$line"
done < <(printf '%s\n' "$cue_bin_files")
rm -f $(realpath "$file")
else
rm -f $(realpath "$file")
fi
fi
done
) |
zenity --icon-name=net.retrodeck.retrodeck --progress --no-cancel --pulsate --auto-close \
zenity --icon-name=net.retrodeck.retrodeck --progress --no-cancel --auto-close \
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
--title "RetroDECK Configurator Utility - Compression in Progress"
configurator_generic_dialog "The compression process is complete!"
configurator_compress_games_dialog
else
configurator_compress_games_dialog
fi
else
configurator_generic_dialog "There were no games found that could be compressed."
fi
}
@ -588,7 +649,11 @@ configurator_compress_games_dialog() {
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --width=1200 --height=720 \
--column="Choice" --column="Action" \
"Compress Single Game" "Compress a single game into a compatible format" \
"Compress Multiple Games - CHD" "Compress one or more games compatible with the CHD format" )
"Compress Multiple Games - CHD" "Compress one or more games compatible with the CHD format" \
"Compress Multiple Games - ZIP" "Compress one or more games compatible with the ZIP format" \
"Compress Multiple Games - RVZ" "Compress one or more games compatible with the RVZ format" \
"Compress Multiple Games - All Formats" "Compress one or more games compatible with any format" \
"Compress All Games" "Compress all games into compatible formats" )
case $choice in
@ -597,10 +662,24 @@ configurator_compress_games_dialog() {
;;
"Compress Multiple Games - CHD" )
configurator_compress_multi_game_dialog "chd"
configurator_compress_some_games_dialog "chd"
;;
# TODO: Add ZIP compression option
"Compress Multiple Games - ZIP" )
configurator_compress_some_games_dialog "zip"
;;
"Compress Multiple Games - RVZ" )
configurator_compress_some_games_dialog "rvz"
;;
"Compress Multiple Games - All Formats" )
configurator_compress_some_games_dialog "all"
;;
"Compress All Games" )
configurator_compress_all_games_dialog
;;
"" ) # No selection made or Back button clicked
configurator_welcome_dialog
@ -620,7 +699,7 @@ configurator_check_multifile_game_structure() {
else
configurator_generic_dialog "No incorrect multi-file game folder structures found."
fi
configurator_troubleshooting_tools_dialog
configurator_tools_and_troubleshooting_dialog
}
configurator_check_bios_files_basic() {
@ -647,7 +726,7 @@ configurator_check_bios_files_basic() {
configurator_generic_dialog "The following systems have been found to have at least one valid BIOS file.\n\n$systems_with_bios\n\nFor more information on the BIOS files found please use the Advanced check tool."
configurator_troubleshooting_tools_dialog
configurator_tools_and_troubleshooting_dialog
}
configurator_check_bios_files_advanced() {
@ -678,10 +757,10 @@ configurator_check_bios_files_advanced() {
--column "BIOS File Description" \
"${bios_checked_list[@]}"
configurator_troubleshooting_tools_dialog
configurator_tools_and_troubleshooting_dialog
}
configurator_troubleshooting_tools_dialog() {
configurator_tools_and_troubleshooting_dialog() {
choice=$(zenity --list --title="RetroDECK Configurator Utility - Change Options" --cancel-label="Back" \
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --width=1200 --height=720 \
--column="Choice" --column="Action" \
@ -1017,7 +1096,7 @@ configurator_welcome_dialog() {
;;
"Tools and Troubleshooting" )
configurator_troubleshooting_tools_dialog
configurator_tools_and_troubleshooting_dialog
;;
"Reset" )