From 4c4cdff197cff1f50ed90e8247170a678949070d Mon Sep 17 00:00:00 2001 From: XargonWan Date: Fri, 9 Aug 2024 17:22:17 +0900 Subject: [PATCH] FEATURES: migrated compression_targets --- .../reference_lists/compression_targets.cfg | 43 ----------------- .../retrodeck/reference_lists/features.json | 48 +++++++++++++++++++ functions/compression.sh | 12 +++-- functions/global.sh | 1 - tools/configurator.sh | 2 +- 5 files changed, 57 insertions(+), 49 deletions(-) delete mode 100644 config/retrodeck/reference_lists/compression_targets.cfg diff --git a/config/retrodeck/reference_lists/compression_targets.cfg b/config/retrodeck/reference_lists/compression_targets.cfg deleted file mode 100644 index 4ae00365..00000000 --- a/config/retrodeck/reference_lists/compression_targets.cfg +++ /dev/null @@ -1,43 +0,0 @@ -[chd] -3do -amigacd32 -dreamcast -megacd -neogeocd -pcenginecd -pcfx -psp -psx -ps2 -saturn -saturnjp -segacd -tg-cd -[rvz] -gc -wii -[zip] -atari2600 -atari5200 -atari7800 -atari800 -atarijaguar -atarilynx -atarist -gamegear -gb -gba -gbc -genesis -mastersystem -n64 -nds -nes -ngp -ngpc -sega32x -sega32xjp -sega32xna -snes -snesna -tg16 diff --git a/config/retrodeck/reference_lists/features.json b/config/retrodeck/reference_lists/features.json index 8c32825c..e56b8416 100644 --- a/config/retrodeck/reference_lists/features.json +++ b/config/retrodeck/reference_lists/features.json @@ -147,6 +147,54 @@ "location": "$bios_folder/switch/firmware" } }, + "compression_targets": { + "chd": [ + "3do", + "amigacd32", + "dreamcast", + "megacd", + "neogeocd", + "pcenginecd", + "pcfx", + "psp", + "psx", + "ps2", + "saturn", + "saturnjp", + "segacd", + "tg-cd" + ], + "rvz": [ + "gc", + "wii" + ], + "zip": [ + "atari2600", + "atari5200", + "atari7800", + "atari800", + "atarijaguar", + "atarilynx", + "atarist", + "gamegear", + "gb", + "gba", + "gbc", + "genesis", + "mastersystem", + "n64", + "nds", + "nes", + "ngp", + "ngpc", + "sega32x", + "sega32xjp", + "sega32xna", + "snes", + "snesna", + "tg16" + ] + }, "system": { "3do": { "name": "3DO Interactive Multiplayer" diff --git a/functions/compression.sh b/functions/compression.sh index 4b0bcdd8..207ec3d0 100644 --- a/functions/compression.sh +++ b/functions/compression.sh @@ -56,13 +56,17 @@ find_compatible_compression_format() { 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 + local chd_systems=$(jq -r '.compression_targets.chd[]' $features) + local rvz_systems=$(jq -r '.compression_targets.rvz[]' $features) + local zip_systems=$(jq -r '.compression_targets.zip[]' $features) + + if [[ $(validate_for_chd "$1") == "true" ]] && echo "$chd_systems" | grep -q "\b$system\b"; 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 + elif grep -qF ".${normalized_filename##*.}" $zip_compressable_extensions && echo "$zip_systems" | grep -q "\b$system\b"; 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 + elif echo "$normalized_filename" | grep -qE '\.iso|\.gcm' && echo "$rvz_systems" | grep -q "\b$system\b"; then echo "rvz" - elif echo "$normalized_filename" | grep -qE '\.iso' && [[ $(sed -n '/^\[/{h;d};/\b'"$system"'\b/{g;s/\[\(.*\)\]/\1/p;q};' $compression_targets) == "cso" ]]; then + elif echo "$normalized_filename" | grep -qE '\.iso' && echo "$chd_systems" | grep -q "\b$system\b"; then echo "cso" else # If no compatible format can be found for the input file diff --git a/functions/global.sh b/functions/global.sh index a9e9d093..139171bc 100644 --- a/functions/global.sh +++ b/functions/global.sh @@ -27,7 +27,6 @@ config="/app/retrodeck/config" rd_defaults="$config/retrodeck/retrodeck.cfg" # A default RetroDECK config file rd_update_patch="/var/config/retrodeck/rd_update.patch" # A static location for the temporary patch file used during retrodeck.cfg updates bios_checklist="$config/retrodeck/reference_lists/bios_checklist.cfg" # A config file listing BIOS file information that can be verified -compression_targets="$config/retrodeck/reference_lists/compression_targets.cfg" # A config file containing supported compression types per system zip_compressable_extensions="$config/retrodeck/reference_lists/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! input_validation="$config/retrodeck/reference_lists/input_validation.cfg" # A config file listing valid CLI inputs finit_options_list="$config/retrodeck/reference_lists/finit_options_list.cfg" # A config file listing available optional installs during finit diff --git a/tools/configurator.sh b/tools/configurator.sh index 54d15453..eba15ddf 100644 --- a/tools/configurator.sh +++ b/tools/configurator.sh @@ -852,7 +852,7 @@ configurator_compress_single_game_dialog() { } configurator_compress_multiple_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 + # This dialog will display any games it finds to be compressable, from the systems listed under each compression type in features.json find_compatible_games "$1"