From 00ee6e12798c39b5cce14fe6d823d855bc27420e Mon Sep 17 00:00:00 2001 From: icenine451 Date: Wed, 26 Jun 2024 12:43:33 -0400 Subject: [PATCH 1/4] Add "no compessable files found" dialog --- tools/configurator.sh | 44 +++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/tools/configurator.sh b/tools/configurator.sh index 2dfa47d7..16088c63 100644 --- a/tools/configurator.sh +++ b/tools/configurator.sh @@ -855,29 +855,33 @@ configurator_compress_multiple_games_dialog() { find_compatible_games "$1" - if [[ ! "$target_selection" == "everything" ]]; then # If the user chose to not auto-compress everything - choice=$(zenity \ - --list --width=1200 --height=720 --title "RetroDECK Configurator - RetroDECK: Compression Tool" \ - --checklist --hide-column=3 --ok-label="Compress Selected" --extra-button="Compress All" \ - --separator="," --print-column=3 \ - --text="Choose which games to compress:" \ - --column "Compress?" \ - --column "Game" \ - --column "Game Full Path" \ - "${compressable_games_list[@]}") + if [[ ! $(echo "${#all_compressable_games[@]}") == "0" ]]; then + if [[ ! "$target_selection" == "everything" ]]; then # If the user chose to not auto-compress everything + choice=$(zenity \ + --list --width=1200 --height=720 --title "RetroDECK Configurator - RetroDECK: Compression Tool" \ + --checklist --hide-column=3 --ok-label="Compress Selected" --extra-button="Compress All" \ + --separator="," --print-column=3 \ + --text="Choose which games to compress:" \ + --column "Compress?" \ + --column "Game" \ + --column "Game Full Path" \ + "${compressable_games_list[@]}") - local rc=$? - if [[ $rc == "0" && ! -z $choice ]]; then # User clicked "Compress Selected" with at least one game selected - 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" + local rc=$? + if [[ $rc == "0" && ! -z $choice ]]; then # User clicked "Compress Selected" with at least one game selected + 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 + else # The user chose to auto-compress everything games_to_compress=("${all_compressable_games[@]}") - local total_games_to_compress=${#all_compressable_games[@]} - local games_left_to_compress=$total_games_to_compress fi - else # The user chose to auto-compress everything - games_to_compress=("${all_compressable_games[@]}") + else + configurator_generic_dialog "RetroDECK Configurator - RetroDECK: Compression Tool" "No compressable files were found." fi if [[ ! $(echo "${#games_to_compress[@]}") == "0" ]]; then From 7f62bd089b019acd2250b92d9191dfd8f62ad6c8 Mon Sep 17 00:00:00 2001 From: icenine451 Date: Wed, 26 Jun 2024 12:43:56 -0400 Subject: [PATCH 2/4] Add check for existing compressed format when building compressable files list --- functions/compression.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/functions/compression.sh b/functions/compression.sh index d33f5a2d..ccb5a44c 100644 --- a/functions/compression.sh +++ b/functions/compression.sh @@ -155,19 +155,19 @@ find_compatible_games() { do local compatible_compression_format=$(find_compatible_compression_format "$game") if [[ $compression_format == "chd" ]]; then - if [[ $compatible_compression_format == "chd" ]]; then + if [[ $compatible_compression_format == "chd" && ! -f "$(echo ${game%.*}.chd)" ]]; then all_compressable_games=("${all_compressable_games[@]}" "$game") compressable_games_list=("${compressable_games_list[@]}" "false" "${game#$roms_folder}" "$game") echo "${game}"^"$compatible_compression_format" >> "$godot_compression_compatible_games" fi elif [[ $compression_format == "zip" ]]; then - if [[ $compatible_compression_format == "zip" ]]; then + if [[ $compatible_compression_format == "zip" && ! -f "$(echo ${game%.*}.zip)" ]]; then all_compressable_games=("${all_compressable_games[@]}" "$game") compressable_games_list=("${compressable_games_list[@]}" "false" "${game#$roms_folder}" "$game") echo "${game}"^"$compatible_compression_format" >> "$godot_compression_compatible_games" fi elif [[ $compression_format == "rvz" ]]; then - if [[ $compatible_compression_format == "rvz" ]]; then + if [[ $compatible_compression_format == "rvz" && ! -f "$(echo ${game%.*}.rvz)" ]]; then all_compressable_games=("${all_compressable_games[@]}" "$game") compressable_games_list=("${compressable_games_list[@]}" "false" "${game#$roms_folder}" "$game") echo "${game}"^"$compatible_compression_format" >> "$godot_compression_compatible_games" From 1057f091d64313536fa138697786bbc7e7ac3501 Mon Sep 17 00:00:00 2001 From: icenine451 Date: Wed, 26 Jun 2024 12:44:39 -0400 Subject: [PATCH 3/4] Fix "files left" counting when compressing all files --- tools/configurator.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/configurator.sh b/tools/configurator.sh index 16088c63..5435f44c 100644 --- a/tools/configurator.sh +++ b/tools/configurator.sh @@ -879,6 +879,8 @@ configurator_compress_multiple_games_dialog() { fi else # The user chose to auto-compress everything games_to_compress=("${all_compressable_games[@]}") + total_games_to_compress=${#all_compressable_games[@]} + games_left_to_compress=$total_games_to_compress fi else configurator_generic_dialog "RetroDECK Configurator - RetroDECK: Compression Tool" "No compressable files were found." From e850715a42fef7b62bab7f8a2746acb028464d5c Mon Sep 17 00:00:00 2001 From: icenine451 Date: Wed, 26 Jun 2024 12:50:35 -0400 Subject: [PATCH 4/4] Localize some compression math variables --- tools/configurator.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/configurator.sh b/tools/configurator.sh index 5435f44c..2cdb24cd 100644 --- a/tools/configurator.sh +++ b/tools/configurator.sh @@ -879,8 +879,8 @@ configurator_compress_multiple_games_dialog() { fi else # The user chose to auto-compress everything games_to_compress=("${all_compressable_games[@]}") - total_games_to_compress=${#all_compressable_games[@]} - games_left_to_compress=$total_games_to_compress + local total_games_to_compress=${#all_compressable_games[@]} + local games_left_to_compress=$total_games_to_compress fi else configurator_generic_dialog "RetroDECK Configurator - RetroDECK: Compression Tool" "No compressable files were found."