From 44d693f40e883649be663682c3726d170fc4f76d Mon Sep 17 00:00:00 2001 From: XargonWan Date: Wed, 7 Aug 2024 22:27:54 +0900 Subject: [PATCH] FEATURES: migrated deploy_helper_files and find_empty_rom_folders --- functions/configurator_functions.sh | 14 +++++--------- functions/global.sh | 1 - functions/other_functions.sh | 14 +++++++++----- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/functions/configurator_functions.sh b/functions/configurator_functions.sh index 768215b8..32f11a7f 100644 --- a/functions/configurator_functions.sh +++ b/functions/configurator_functions.sh @@ -44,14 +44,9 @@ find_empty_rom_folders() { empty_rom_folders_list=() all_empty_folders=() - all_helper_files=() - while IFS='^' read -r file dest || [[ -n "$file" ]]; - do - if [[ ! "$file" == "#"* ]] && [[ ! -z "$file" ]]; then - all_helper_files=("${all_helper_files[@]}" "$file") - fi - done < "$helper_files_list" + # Extract helper file names using jq and populate the all_helper_files array + all_helper_files=($(jq -r '.helper_files | to_entries | .[] | .value.filename' "$features")) for system in $(find "$roms_folder" -mindepth 1 -maxdepth 1 -type d -printf '%f\n') do @@ -70,8 +65,8 @@ find_empty_rom_folders() { all_empty_folders=("${all_empty_folders[@]}" "$(realpath $dir)") echo "$(realpath $dir)" >> "$godot_empty_roms_folders" # Godot data transfer temp file elif [[ $count -eq 2 ]] && [[ "$files" =~ "systeminfo.txt" ]]; then - # Directory contains 2 files, one of which is "systeminfo.txt" - for helper_file in ${all_helper_files[@]} # Compare helper file list to dir file list + contains_helper_file="false" + for helper_file in "${all_helper_files[@]}" # Compare helper file list to dir file list do if [[ "$files" =~ "$helper_file" ]]; then contains_helper_file="true" # Helper file was found @@ -87,3 +82,4 @@ find_empty_rom_folders() { fi done } + diff --git a/functions/global.sh b/functions/global.sh index 4f282f40..932e4822 100644 --- a/functions/global.sh +++ b/functions/global.sh @@ -45,7 +45,6 @@ remote_network_target_1="https://flathub.org" remote_network_target_2="$rd_repo" # The URL of a common internet target for testing network access remote_network_target_3="https://one.one.one.one" # The URL of a common internet target for testing network access helper_files_folder="$config/retrodeck/helper_files" # The parent folder of RetroDECK documentation files for deployment -helper_files_list="$config/retrodeck/reference_lists/helper_files_list.cfg" # The list of files to be deployed and where they go rd_appdata="/app/share/appdata/net.retrodeck.retrodeck.appdata.xml" # The shipped appdata XML file for this version rpcs3_firmware="http://dus01.ps3.update.playstation.net/update/ps3/image/us/2023_0228_05fe32f5dc8c78acbcd84d36ee7fdc5b/PS3UPDAT.PUP" RA_API_URL="https://retroachievements.org/dorequest.php" # API URL for RetroAchievements.org diff --git a/functions/other_functions.sh b/functions/other_functions.sh index e84fbaea..5b169f29 100644 --- a/functions/other_functions.sh +++ b/functions/other_functions.sh @@ -570,18 +570,22 @@ update_splashscreens() { } deploy_helper_files() { - # This script will distribute helper documentation files throughout the filesystem according to the $helper_files_list + # This script will distribute helper documentation files throughout the filesystem according to the JSON configuration # USAGE: deploy_helper_files - while IFS='^' read -r file dest || [[ -n "$file" ]]; - do - if [[ ! "$file" == "#"* ]] && [[ ! -z "$file" ]]; then + # Extract helper files information using jq + helper_files=$(jq -r '.helper_files | to_entries | map("\(.value.filename)^\(.value.location)")[]' "$features") + + # Iterate through each helper file entry + while IFS='^' read -r file dest; do + if [[ ! -z "$file" ]] && [[ ! -z "$dest" ]]; then eval current_dest="$dest" cp -f "$helper_files_folder/$file" "$current_dest/$file" fi - done < "$helper_files_list" + done <<< "$helper_files" } + splash_screen() { # This function will replace the RetroDECK startup splash screen with a different image if the day and time match a listing in the JSON data. # USAGE: splash_screen