mirror of
https://github.com/RetroDECK/RetroDECK.git
synced 2024-11-22 05:55:38 +00:00
Compression tool upgrades
This commit is contained in:
parent
db6d28d64f
commit
0186ded2b9
|
@ -1,38 +1,35 @@
|
||||||
[chd]
|
[chd]
|
||||||
dreamcast
|
|
||||||
psx
|
|
||||||
ps2
|
|
||||||
[chd-maybe]
|
|
||||||
3do
|
3do
|
||||||
amiga
|
|
||||||
amiga1200
|
|
||||||
amiga600
|
|
||||||
amigacd32
|
amigacd32
|
||||||
cdimono1
|
|
||||||
cdtv
|
|
||||||
dreamcast
|
dreamcast
|
||||||
gamegear
|
|
||||||
genesis
|
|
||||||
mame-advmame
|
|
||||||
mame-mame4all
|
|
||||||
mastersystem
|
|
||||||
megacd
|
megacd
|
||||||
megacdjp
|
|
||||||
megadrive
|
|
||||||
mess
|
|
||||||
neogeo
|
|
||||||
neogeocd
|
neogeocd
|
||||||
neogeocdjp
|
|
||||||
pcengine
|
|
||||||
pcenginecd
|
pcenginecd
|
||||||
pcfx
|
pcfx
|
||||||
ps2
|
|
||||||
psx
|
psx
|
||||||
|
ps2
|
||||||
saturn
|
saturn
|
||||||
saturnjp
|
saturnjp
|
||||||
segacd
|
segacd
|
||||||
sg-1000
|
|
||||||
supergrafx
|
|
||||||
tg16
|
|
||||||
tg-cd
|
tg-cd
|
||||||
[zip]
|
[rvz]
|
||||||
|
gc
|
||||||
|
wii
|
||||||
|
[zip]
|
||||||
|
atari2600
|
||||||
|
atari5200
|
||||||
|
atari7800
|
||||||
|
atari800
|
||||||
|
atarijaguar
|
||||||
|
atarilynx
|
||||||
|
atarist
|
||||||
|
gamegear
|
||||||
|
gb
|
||||||
|
gba
|
||||||
|
gbc
|
||||||
|
genesis
|
||||||
|
mastersystem
|
||||||
|
nds
|
||||||
|
nes
|
||||||
|
snes
|
||||||
|
snesna
|
|
@ -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
|
195
functions.sh
195
functions.sh
|
@ -116,103 +116,184 @@ move() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
compress_to_chd () {
|
compress_game() {
|
||||||
# Function for compressing one or more files to .chd format
|
# 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"
|
if [[ "$1" == "chd" ]]; then
|
||||||
/app/bin/chdman createcd -i "$1" -o "$2".chd
|
/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
|
# Function for validating chd compression candidates, and compresses if validation passes. Supports .cue, .iso and .gdi formats ONLY
|
||||||
# USAGE: validate_for_chd $input_file
|
# USAGE: validate_for_chd $input_file
|
||||||
|
|
||||||
local file="$1"
|
local file="$1"
|
||||||
local normalized_filename=$(echo "$file" | tr '[:upper:]' '[:lower:]')
|
local normalized_filename=$(echo "$file" | tr '[:upper:]' '[:lower:]')
|
||||||
local file_validated="false"
|
local file_validated="false"
|
||||||
current_run_log_file="chd_compression_$(basename "$file").log"
|
chd_validation_log_file="compression_$(basename "$file").log"
|
||||||
echo "Validating file:" "$file" > "$logs_folder/$current_run_log_file"
|
echo "Validating file:" "$file" > "$logs_folder/$chd_validation_log_file"
|
||||||
if [[ "$normalized_filename" == *".cue" ]] || [[ "$normalized_filename" == *".gdi" ]] || [[ "$normalized_filename" == *".iso" ]]; then
|
if echo "$normalized_filename" | grep -qE '\.iso|\.cue|\.gdi'; then
|
||||||
echo ".cue/.iso/.gdi file detected" >> "$logs_folder/$current_run_log_file"
|
echo ".cue/.iso/.gdi file detected" >> "$logs_folder/$chd_validation_log_file"
|
||||||
local file_path=$(dirname "$(realpath "$file")")
|
local file_path=$(dirname "$(realpath "$file")")
|
||||||
local file_base_name=$(basename "$file")
|
local file_base_name=$(basename "$file")
|
||||||
local file_name=${file_base_name%.*}
|
local file_name=${file_base_name%.*}
|
||||||
if [[ "$normalized_filename" == *".cue" ]]; then # Validate .cue file
|
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")
|
local cue_bin_files=$(grep -o -P "(?<=FILE \").*(?=\".*$)" "$file")
|
||||||
echo "Associated bin files read:" >> "$logs_folder/$current_run_log_file"
|
echo "Associated bin files read:" >> "$logs_folder/$chd_validation_log_file"
|
||||||
printf '%s\n' "$cue_bin_files" >> "$logs_folder/$current_run_log_file"
|
printf '%s\n' "$cue_bin_files" >> "$logs_folder/$chd_validation_log_file"
|
||||||
while IFS= read -r line
|
if [[ ! -z "$cue_bin_files" ]]; then
|
||||||
do
|
while IFS= read -r line
|
||||||
echo "looking for $file_path/$line" >> "$logs_folder/$current_run_log_file"
|
do
|
||||||
if [[ -f "$file_path/$line" ]]; then
|
echo "looking for $file_path/$line" >> "$logs_folder/$chd_validation_log_file"
|
||||||
echo ".bin file found at $file_path/$line" >> "$logs_folder/$current_run_log_file"
|
if [[ -f "$file_path/$line" ]]; then
|
||||||
file_validated="true"
|
echo ".bin file found at $file_path/$line" >> "$logs_folder/$chd_validation_log_file"
|
||||||
else
|
file_validated="true"
|
||||||
echo ".bin file NOT found at $file_path/$line" >> "$logs_folder/$current_run_log_file"
|
else
|
||||||
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"
|
echo ".bin file NOT found at $file_path/$line" >> "$logs_folder/$chd_validation_log_file"
|
||||||
file_validated="false"
|
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"
|
||||||
break
|
file_validated="false"
|
||||||
fi
|
break
|
||||||
done < <(printf '%s\n' "$cue_bin_files")
|
fi
|
||||||
if [[ $file_validated == "true" ]]; then
|
done < <(printf '%s\n' "$cue_bin_files")
|
||||||
echo $file_validated
|
|
||||||
fi
|
fi
|
||||||
|
echo $file_validated
|
||||||
else # If file is a .iso or .gdi
|
else # If file is a .iso or .gdi
|
||||||
file_validated="true"
|
file_validated="true"
|
||||||
echo $file_validated
|
echo $file_validated
|
||||||
fi
|
fi
|
||||||
else
|
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
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
cli_compress_file() {
|
cli_compress_single_game() {
|
||||||
# This function will compress a single file passed from the CLI arguments
|
# This function will compress a single file passed from the CLI arguments
|
||||||
# USAGE: cli_compress_file $full_file_path
|
# USAGE: cli_compress_single_game $full_file_path
|
||||||
local file="$1"
|
local file=$(realpath "$1")
|
||||||
echo "Looking for" "$file"
|
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
|
||||||
current_run_log_file="chd_compression_$(basename "$file").log"
|
read -p "RetroDECK will now attempt to compress your selected game. Press Enter key to continue..."
|
||||||
if [[ ! -z "$file" ]]; then
|
if [[ ! -z "$file" ]]; then
|
||||||
if [[ -f "$file" ]]; then
|
if [[ -f "$file" ]]; then
|
||||||
if [[ $(validate_for_chd "$file") == "true" ]]; then
|
check_system=$(echo "$file" | grep -oE "$roms_folder/[^/]+" | grep -oE "[^/]+$")
|
||||||
read -p "RetroDECK will now attempt to compress your selected game. Press Enter key to continue..."
|
local compatible_compression_format=$(find_compatible_compression_format "$file")
|
||||||
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
|
if [[ ! $compatible_compression_format == "none" ]]; then
|
||||||
local filename_no_path=$(basename "$file")
|
echo "$(basename "$file") can be compressed to $compatible_compression_format"
|
||||||
local filename_no_extension="${filename_no_path%.*}"
|
compress_game "$compatible_compression_format" "$file"
|
||||||
local source_file=$(dirname "$(realpath "$file")")"/"$(basename "$file")
|
if [[ $post_compression_cleanup == [yY] ]]; then # Remove file(s) if requested
|
||||||
local dest_file=$(dirname "$(realpath "$file")")"/""$filename_no_extension"
|
if [[ $(basename "$file") == *".cue" ]]; then
|
||||||
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
|
|
||||||
local cue_bin_files=$(grep -o -P "(?<=FILE \").*(?=\".*$)" "$file")
|
local cue_bin_files=$(grep -o -P "(?<=FILE \").*(?=\".*$)" "$file")
|
||||||
local file_path=$(dirname "$(realpath "$file")")
|
local file_path=$(dirname "$(realpath "$file")")
|
||||||
while IFS= read -r line
|
while IFS= read -r line
|
||||||
do # Remove associated .bin files
|
do # Remove associated .bin files
|
||||||
echo "Removing file "$line""
|
echo "Removing original file "$file_path/$line""
|
||||||
rm -f "$file_path/$line"
|
rm -f "$file_path/$line"
|
||||||
done < <(printf '%s\n' "$cue_bin_files") # Remove original .cue file
|
done < <(printf '%s\n' "$cue_bin_files") # Remove original .cue file
|
||||||
echo "Removing file "$filename_no_path""
|
echo "Removing original file $(basename "$file")"
|
||||||
rm -f $(realpath "$file")
|
rm -f "$file"
|
||||||
else
|
else
|
||||||
echo "Removing file "$filename_no_path""
|
echo "Removing original file $(basename "$file")"
|
||||||
rm -f $(realpath "$file")
|
rm -f "$file"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
printf "An error occured during the compression process. Please see the following log entries for details:\n\n"
|
echo "$(basename "$file") does not have any compatible compression formats."
|
||||||
cat "$logs_folder/$current_run_log_file"
|
fi
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
echo "File not found, please specify the full path to the file to be compressed."
|
echo "File not found, please specify the full path to the file to be compressed."
|
||||||
fi
|
fi
|
||||||
else
|
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
|
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() {
|
desktop_mode_warning() {
|
||||||
# This function is a generic warning for issues that happen when running in desktop mode.
|
# 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
|
# Running in desktop mode can be verified with the following command: if [[ ! $XDG_CURRENT_DESKTOP == "gamescope" ]]; then
|
||||||
|
|
|
@ -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
|
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
|
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
|
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
|
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
|
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
|
splashscreen_dir="/var/config/emulationstation/.emulationstation/resources/graphics/extra-splashes" # The default location of extra splash screens
|
||||||
|
|
10
retrodeck.sh
10
retrodeck.sh
|
@ -18,7 +18,8 @@ Arguments:
|
||||||
-v, --version Print RetroDECK version
|
-v, --version Print RetroDECK version
|
||||||
--info-msg Print paths and config informations
|
--info-msg Print paths and config informations
|
||||||
--configurator Starts the RetroDECK Configurator
|
--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-emulator <emulator> Reset one or more emulator configs to the default values
|
||||||
--reset-retrodeck Starts the initial RetroDECK installer (backup your data first!)
|
--reset-retrodeck Starts the initial RetroDECK installer (backup your data first!)
|
||||||
|
|
||||||
|
@ -39,10 +40,13 @@ https://retrodeck.net
|
||||||
cat $rd_conf
|
cat $rd_conf
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
--compress*)
|
--compress-one*)
|
||||||
cli_compress_file "$2"
|
cli_compress_single_game "$2"
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
|
--compress-all*)
|
||||||
|
cli_compress_all_games "$2"
|
||||||
|
;;
|
||||||
--configurator*)
|
--configurator*)
|
||||||
sh /app/tools/configurator.sh
|
sh /app/tools/configurator.sh
|
||||||
exit
|
exit
|
||||||
|
|
|
@ -421,28 +421,32 @@ configurator_retroarch_options_dialog() {
|
||||||
configurator_compress_single_game_dialog() {
|
configurator_compress_single_game_dialog() {
|
||||||
local file=$(file_browse "Game to compress")
|
local file=$(file_browse "Game to compress")
|
||||||
if [[ ! -z "$file" ]]; then
|
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 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..."
|
if [[ $compatible_compression_format == "chd" ]]; then
|
||||||
compress_to_chd "$source_file" "$dest_file"
|
if [[ $(validate_for_chd "$file") == "true" ]]; then
|
||||||
if [[ $post_compression_cleanup == "true" ]]; then # Remove file(s) if requested
|
echo "# Compressing $(basename "$file") to $compatible_compression_format format"
|
||||||
if [[ "$file" == *".cue" ]]; then
|
compress_game "chd" "$file"
|
||||||
local cue_bin_files=$(grep -o -P "(?<=FILE \").*(?=\".*$)" "$file")
|
if [[ $post_compression_cleanup == "true" ]]; then # Remove file(s) if requested
|
||||||
local file_path=$(dirname "$(realpath "$file")")
|
if [[ "$file" == *".cue" ]]; then
|
||||||
while IFS= read -r line
|
local cue_bin_files=$(grep -o -P "(?<=FILE \").*(?=\".*$)" "$file")
|
||||||
do
|
local file_path=$(dirname "$(realpath "$file")")
|
||||||
echo "# Removing file $line"
|
while IFS= read -r line
|
||||||
rm -f "$file_path/$line"
|
do
|
||||||
done < <(printf '%s\n' "$cue_bin_files")
|
rm -f "$file_path/$line"
|
||||||
echo "# Removing file $filename_no_path"
|
done < <(printf '%s\n' "$cue_bin_files")
|
||||||
rm -f "$file"
|
rm -f "$file"
|
||||||
else
|
else
|
||||||
echo "# Removing file $filename_no_path"
|
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"
|
rm -f "$file"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -452,8 +456,9 @@ configurator_compress_single_game_dialog() {
|
||||||
--title "RetroDECK Configurator Utility - Compression in Progress"
|
--title "RetroDECK Configurator Utility - Compression in Progress"
|
||||||
configurator_generic_dialog "The compression process is complete!"
|
configurator_generic_dialog "The compression process is complete!"
|
||||||
configurator_compress_games_dialog
|
configurator_compress_games_dialog
|
||||||
|
|
||||||
else
|
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
|
configurator_compress_games_dialog
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
@ -462,27 +467,55 @@ configurator_compress_single_game_dialog() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
configurator_compress_multi_game_dialog() {
|
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
|
# This dialog will display any games it finds to be compressable, from the systems listed under each compression type in compression_targets.cfg
|
||||||
local compression_format=$1
|
|
||||||
local compressable_game=""
|
|
||||||
local compressable_games_list=()
|
local compressable_games_list=()
|
||||||
local all_compressable_games=()
|
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
|
while IFS= read -r system # Find and validate all games that are able to be compressed with this compression type
|
||||||
do
|
do
|
||||||
if [[ $compression_format == "chd" ]]; then
|
compression_candidates=$(find "$roms_folder/$system" -type f -not -iname "*.txt")
|
||||||
compression_candidates=$(find "$roms_folder/$system" -type f \( -name "*.cue" -o -name "*.iso" -o -name "*.gdi" \) ! -path "*.m3u*")
|
if [[ ! -z $compression_candidates ]]; then
|
||||||
# TODO: Add ZIP file compression search here
|
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
|
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")
|
done < <(printf '%s\n' "$compressable_systems_list")
|
||||||
|
|
||||||
choice=$(zenity \
|
choice=$(zenity \
|
||||||
|
@ -497,76 +530,104 @@ configurator_compress_multi_game_dialog() {
|
||||||
|
|
||||||
local rc=$?
|
local rc=$?
|
||||||
if [[ $rc == "0" && ! -z $choice ]]; then # User clicked "Compress Selected" with at least one game selected
|
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"
|
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
|
for file in "${games_to_compress[@]}"; do
|
||||||
local filename_no_path=$(basename "$file")
|
local compression_format=$(find_compatible_compression_format "$file")
|
||||||
local filename_no_extension="${filename_no_path%.*}"
|
echo "# Compressing $(basename "$file") into $compression_format format" # Update Zenity dialog text
|
||||||
local source_file=$(dirname "$(realpath "$file")")"/"$(basename "$file")
|
progress=$(( 100 - (( 100 / "$total_games_to_compress" ) * "$games_left_to_compress" )))
|
||||||
local dest_file=$(dirname "$(realpath "$file")")"/""$filename_no_extension"
|
echo $progress
|
||||||
echo "# Compressing $filename_no_path" # Update Zenity dialog text
|
games_left_to_compress=$((games_left_to_compress-1))
|
||||||
compress_to_chd "$source_file" "$dest_file"
|
compress_game "$compression_format" "$file"
|
||||||
if [[ $post_compression_cleanup == "true" ]]; then # Remove file(s) if requested
|
if [[ $post_compression_cleanup == "true" ]]; then # Remove file(s) if requested
|
||||||
if [[ "$file" == *".cue" ]]; then
|
if [[ "$file" == *".cue" ]]; then
|
||||||
local cue_bin_files=$(grep -o -P "(?<=FILE \").*(?=\".*$)" "$file")
|
local cue_bin_files=$(grep -o -P "(?<=FILE \").*(?=\".*$)" "$file")
|
||||||
local file_path=$(dirname "$(realpath "$file")")
|
local file_path=$(dirname "$(realpath "$file")")
|
||||||
while IFS= read -r line
|
while IFS= read -r line
|
||||||
do
|
do
|
||||||
echo "# Removing file $line"
|
|
||||||
rm -f "$file_path/$line"
|
rm -f "$file_path/$line"
|
||||||
done < <(printf '%s\n' "$cue_bin_files")
|
done < <(printf '%s\n' "$cue_bin_files")
|
||||||
echo "# Removing file $filename_no_path"
|
|
||||||
rm -f $(realpath "$file")
|
rm -f $(realpath "$file")
|
||||||
else
|
else
|
||||||
echo "# Removing file $filename_no_path"
|
|
||||||
rm -f "$(realpath "$file")"
|
rm -f "$(realpath "$file")"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
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" \
|
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
|
||||||
--title "RetroDECK Configurator Utility - Compression in Progress"
|
--title "RetroDECK Configurator Utility - Compression in Progress"
|
||||||
configurator_generic_dialog "The compression process is complete!"
|
configurator_generic_dialog "The compression process is complete!"
|
||||||
configurator_compress_games_dialog
|
configurator_compress_games_dialog
|
||||||
else
|
else
|
||||||
if [[ ! -z $choice ]]; then # User clicked "Compress All"
|
configurator_compress_games_dialog
|
||||||
local post_compression_cleanup=$(configurator_compression_cleanup_dialog)
|
fi
|
||||||
(
|
}
|
||||||
for file in "${all_compressable_games[@]}"; do
|
|
||||||
local filename_no_path=$(basename "$file")
|
configurator_compress_all_games_dialog() {
|
||||||
local filename_no_extension="${filename_no_path%.*}"
|
# This dialog compress all games found in all compatible roms folders into compatible formats
|
||||||
local source_file=$(dirname "$(realpath "$file")")"/"$(basename "$file")
|
|
||||||
local dest_file=$(dirname "$(realpath "$file")")"/""$filename_no_extension"
|
local all_compressable_games=()
|
||||||
echo "# Compressing $filename_no_path" # Update Zenity dialog text
|
local compressable_systems_list=$(cat $compression_targets | sed '/^$/d' | sed '/^\[/d')
|
||||||
compress_to_chd "$source_file" "$dest_file"
|
|
||||||
if [[ $post_compression_cleanup == "true" ]]; then # Remove file(s) if requested
|
while IFS= read -r system # Find and validate all games that are able to be compressed with this compression type
|
||||||
if [[ "$file" == *".cue" ]]; then
|
do
|
||||||
local cue_bin_files=$(grep -o -P "(?<=FILE \").*(?=\".*$)" "$file")
|
compression_candidates=$(find "$roms_folder/$system" -type f -not -iname "*.txt")
|
||||||
local file_path=$(dirname "$(realpath "$file")")
|
if [[ ! -z $compression_candidates ]]; then
|
||||||
while IFS= read -r line
|
while IFS= read -r game
|
||||||
do
|
do
|
||||||
echo "# Removing file $line"
|
local compatible_compression_format=$(find_compatible_compression_format "$game")
|
||||||
rm -f "$file_path/$line"
|
if [[ ! $compatible_compression_format == "none" ]]; then
|
||||||
done < <(printf '%s\n' "$cue_bin_files")
|
all_compressable_games=("${all_compressable_games[@]}" "$game")
|
||||||
echo "# Removing file $filename_no_path"
|
|
||||||
rm -f $(realpath "$file")
|
|
||||||
else
|
|
||||||
echo "# Removing file $filename_no_path"
|
|
||||||
rm -f $(realpath "$file")
|
|
||||||
fi
|
|
||||||
fi
|
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" \
|
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
|
||||||
--title "RetroDECK Configurator Utility - Compression in Progress"
|
--title "RetroDECK Configurator Utility - Compression in Progress"
|
||||||
configurator_generic_dialog "The compression process is complete!"
|
configurator_generic_dialog "The compression process is complete!"
|
||||||
configurator_compress_games_dialog
|
configurator_compress_games_dialog
|
||||||
else
|
else
|
||||||
configurator_compress_games_dialog
|
configurator_generic_dialog "There were no games found that could be compressed."
|
||||||
fi
|
|
||||||
fi
|
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 \
|
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --width=1200 --height=720 \
|
||||||
--column="Choice" --column="Action" \
|
--column="Choice" --column="Action" \
|
||||||
"Compress Single Game" "Compress a single game into a compatible format" \
|
"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
|
case $choice in
|
||||||
|
|
||||||
|
@ -597,10 +662,24 @@ configurator_compress_games_dialog() {
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"Compress Multiple Games - CHD" )
|
"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
|
"" ) # No selection made or Back button clicked
|
||||||
configurator_welcome_dialog
|
configurator_welcome_dialog
|
||||||
|
@ -620,7 +699,7 @@ configurator_check_multifile_game_structure() {
|
||||||
else
|
else
|
||||||
configurator_generic_dialog "No incorrect multi-file game folder structures found."
|
configurator_generic_dialog "No incorrect multi-file game folder structures found."
|
||||||
fi
|
fi
|
||||||
configurator_troubleshooting_tools_dialog
|
configurator_tools_and_troubleshooting_dialog
|
||||||
}
|
}
|
||||||
|
|
||||||
configurator_check_bios_files_basic() {
|
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_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() {
|
configurator_check_bios_files_advanced() {
|
||||||
|
@ -678,10 +757,10 @@ configurator_check_bios_files_advanced() {
|
||||||
--column "BIOS File Description" \
|
--column "BIOS File Description" \
|
||||||
"${bios_checked_list[@]}"
|
"${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" \
|
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 \
|
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --width=1200 --height=720 \
|
||||||
--column="Choice" --column="Action" \
|
--column="Choice" --column="Action" \
|
||||||
|
@ -1017,7 +1096,7 @@ configurator_welcome_dialog() {
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"Tools and Troubleshooting" )
|
"Tools and Troubleshooting" )
|
||||||
configurator_troubleshooting_tools_dialog
|
configurator_tools_and_troubleshooting_dialog
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"Reset" )
|
"Reset" )
|
||||||
|
|
Loading…
Reference in a new issue