From 449e8bbe4fb52341b683e04398aee7bbd38b9705 Mon Sep 17 00:00:00 2001 From: icenine451 Date: Tue, 16 May 2023 10:21:23 -0400 Subject: [PATCH] Add missing "then" in Configurator Fix typo in preset deployment func Add current preset state builder Add moving Duckstation config folder to new location on update Disable post-update starter pack install Upgrade update_rd_conf to handle presets Enable borders by default --- emu-configs/defaults/retrodeck/retrodeck.cfg | 16 +++---- functions/functions.sh | 47 +++++++++++++++---- functions/post_update.sh | 14 +++--- functions/presets.sh | 48 ++++++++++---------- tools/configurator.sh | 2 +- 5 files changed, 79 insertions(+), 48 deletions(-) diff --git a/emu-configs/defaults/retrodeck/retrodeck.cfg b/emu-configs/defaults/retrodeck/retrodeck.cfg index d1d5f79a..97233497 100644 --- a/emu-configs/defaults/retrodeck/retrodeck.cfg +++ b/emu-configs/defaults/retrodeck/retrodeck.cfg @@ -39,14 +39,14 @@ pcsx2=false retroarch=false [borders] -gb=false -gba=false -gbc=false -genesis=false -gg=false -n64=false -psx_ra=false -snes=false +gb=true +gba=true +gbc=true +genesis=true +gg=true +n64=true +psx_ra=true +snes=true [widescreen] genesis=false diff --git a/functions/functions.sh b/functions/functions.sh index 13d8e012..b3627b34 100644 --- a/functions/functions.sh +++ b/functions/functions.sh @@ -120,11 +120,8 @@ update_rd_conf() { set_setting_value $rd_conf "version" "$hard_version" retrodeck # Set version of currently running RetroDECK to updated retrodeck.cfg rm -f $rd_update_patch # Cleanup temporary patch file conf_read # Read all settings into memory -} -conf_write() { - # This function will update the RetroDECK config file with matching variables from memory - # USAGE: conf_write + # STAGE 3: Eliminate any preset incompatibility with existing user settings and new defaults while IFS= read -r current_setting_line # Read the existing retrodeck.cfg do @@ -132,12 +129,18 @@ conf_write() { if [[ ! -z $(grep -o -P "^\[.+?\]$" <<< "$current_setting_line") ]]; then # If the line is a section header local current_section=$(sed 's^[][]^^g' <<< $current_setting_line) # Remove brackets from section name else - if [[ "$current_section" == "" || "$current_section" == "paths" || "$current_section" == "options" ]]; then - local current_setting_name=$(get_setting_name "$current_setting_line" "retrodeck") # Read the variable name from the current line - local current_setting_value=$(get_setting_value "$rd_conf" "$current_setting_name" "retrodeck" "$current_section") # Read the variables value from retrodeck.cfg - local memory_setting_value=$(eval "echo \$${current_setting_name}") # Read the variable names' value from memory - if [[ ! "$current_setting_value" == "$memory_setting_value" && ! -z "$memory_setting_value" ]]; then # If the values are different... - set_setting_value "$rd_conf" "$current_setting_name" "$memory_setting_value" "retrodeck" "$current_section" # Update the value in retrodeck.cfg + if [[ ! ("$current_section" == "" || "$current_section" == "paths" || "$current_section" == "options" || "$current_section" == "cheevos" || "$current_section" == "cheevos_hardcore") ]]; then + local system_name=$(get_setting_name "$current_setting_line" "retrodeck") # Read the variable name from the current line + local system_enabled=$(get_setting_value "$rd_conf" "$system_name" "retrodeck" "$current_section") # Read the variables value from active retrodeck.cfg + local default_setting=$(get_setting_value "$rd_defaults" "$system_name" "retrodeck" "$current_section") # Read the variable value from the retrodeck defaults + if [[ "$system_enabled" == "true" ]]; then + while IFS=: read -r preset_being_checked known_incompatible_preset; do + if [[ "$current_section" == "$preset_being_checked" ]]; then + if [[ $(get_setting_value "$rd_conf" "$system_name" "retrodeck" "$known_incompatible_preset") == "true" ]]; then + set_setting_value "$rd_conf" "$system_name" "false" "retrodeck" "$current_section" + fi + fi + done < "$incompatible_presets_reference_list" fi fi fi @@ -165,6 +168,29 @@ conf_read() { done < $rd_conf } +conf_write() { + # This function will update the RetroDECK config file with matching variables from memory + # USAGE: conf_write + + while IFS= read -r current_setting_line # Read the existing retrodeck.cfg + do + if [[ (! -z "$current_setting_line") && (! "$current_setting_line" == "#"*) && (! "$current_setting_line" == "[]") ]]; then # If the line has a valid entry in it + if [[ ! -z $(grep -o -P "^\[.+?\]$" <<< "$current_setting_line") ]]; then # If the line is a section header + local current_section=$(sed 's^[][]^^g' <<< $current_setting_line) # Remove brackets from section name + else + if [[ "$current_section" == "" || "$current_section" == "paths" || "$current_section" == "options" ]]; then + local current_setting_name=$(get_setting_name "$current_setting_line" "retrodeck") # Read the variable name from the current line + local current_setting_value=$(get_setting_value "$rd_conf" "$current_setting_name" "retrodeck" "$current_section") # Read the variables value from retrodeck.cfg + local memory_setting_value=$(eval "echo \$${current_setting_name}") # Read the variable names' value from memory + if [[ ! "$current_setting_value" == "$memory_setting_value" && ! -z "$memory_setting_value" ]]; then # If the values are different... + set_setting_value "$rd_conf" "$current_setting_name" "$memory_setting_value" "retrodeck" "$current_section" # Update the value in retrodeck.cfg + fi + fi + fi + fi + done < $rd_conf +} + dir_prep() { # This script is creating a symlink preserving old folder contents and moving them in the new one @@ -394,6 +420,7 @@ finit() { ( prepare_emulator "reset" "all" + build_retrodeck_current_presets # Optional actions based on user choices if [[ "$finit_options_choices" =~ (rpcs3_firmware|Enable All) ]]; then diff --git a/functions/post_update.sh b/functions/post_update.sh index e11e93e7..6da8f1e9 100644 --- a/functions/post_update.sh +++ b/functions/post_update.sh @@ -70,7 +70,7 @@ post_update() { if [[ $prev_version -le "070" ]]; then # In version 0.7.0b, the following changes were made that required config file updates/reset or other changes to the filesystem: # - Update retrodeck.cfg and set new paths to $rdhome by default - # - Update PCSX2 and Duckstation configs to latest templates (to accomadate RetroAchievements feature) + # - Update PCSX2 and Duckstation configs to latest templates (to accomadate RetroAchievements feature) and move Duckstation config folder from /var/data to /var/config # - New ~/retrodeck/mods and ~/retrodeck/texture_packs directories are added and symlinked to multiple different emulators (where supported) # - Expose ES-DE gamelists folder to user at ~/retrodeck/gamelists # - Copy new borders into RA config location @@ -94,6 +94,7 @@ post_update() { generate_single_patch "$emuconfigs/PCSX2/PCSX2.ini" "$pcsx2conf.bak" "/var/config/PCSX2/inis/PCSX2-cheevos-upgrade.patch" pcsx2 deploy_single_patch "$emuconfigs/PCSX2/PCSX2.ini" "/var/config/PCSX2/inis/PCSX2-cheevos-upgrade.patch" "$pcsx2conf" rm -f "/var/config/PCSX2/inis/PCSX2-cheevos-upgrade.patch" + dir_prep "/var/config/duckstation" "/var/data/duckstation" mv -f "$duckstationconf" "$duckstationconf.bak" generate_single_patch "$emuconfigs/duckstation/settings.ini" "$duckstationconf.bak" "/var/config/duckstation/duckstation-cheevos-upgrade.patch" pcsx2 deploy_single_patch "$emuconfigs/duckstation/settings.ini" "/var/config/duckstation/duckstation-cheevos-upgrade.patch" "$duckstationconf" @@ -118,9 +119,9 @@ post_update() { rsync -a --mkpath "$emuconfigs/defaults/retrodeck/presets/remaps/" "/var/config/retroarch/config/remaps/" - if [[ $(configurator_generic_question_dialog "RetroDECK Starter Pack" "The RetroDECK creators have put together a collection of classic retro games you might enjoy!\n\nWould you like to have them automatically added to your library?\n\nThis can always be done later through the Configurator.") == "true" ]]; then - install_retrodeck_starterpack - fi + # if [[ $(configurator_generic_question_dialog "RetroDECK Starter Pack" "The RetroDECK creators have put together a collection of classic retro games you might enjoy!\n\nWould you like to have them automatically added to your library?\n\nThis can always be done later through the Configurator.") == "true" ]]; then + # install_retrodeck_starterpack + # fi cp -f $emuconfigs/rpcs3/vfs.yml /var/config/rpcs3/vfs.yml sed -i 's^\^$(EmulatorDir): .*^$(EmulatorDir): '"$bios_folder/rpcs3/"'^' "$rpcs3vfsconf" @@ -148,14 +149,14 @@ post_update() { mkdir -p "$saves_folder/psx/duckstation/memcards" mv "$saves_folder/duckstation/"* "$saves_folder/psx/duckstation/memcards/" rmdir "$saves_folder/duckstation" # File-safe folder cleanup - unlink "/var/data/duckstation/memcards" + unlink "/var/config/duckstation/memcards" set_setting_value "$duckstationconf" "Card1Path" "$saves_folder/psx/duckstation/memcards/shared_card_1.mcd" "duckstation" "MemoryCards" set_setting_value "$duckstationconf" "Card2Path" "$saves_folder/psx/duckstation/memcards/shared_card_2.mcd" "duckstation" "MemoryCards" set_setting_value "$duckstationconf" "Directory" "$saves_folder/psx/duckstation/memcards" "duckstation" "MemoryCards" set_setting_value "$duckstationconf" "RecursivePaths" "$roms_folder/psx" "duckstation" "GameList" mkdir -p "$states_folder/psx" mv -t "$states_folder/psx/" "$states_folder/duckstation" - unlink "/var/data/duckstation/savestates" + unlink "/var/config/duckstation/savestates" dir_prep "$states_folder/psx/duckstation" "/var/config/duckstation/savestates" rm -rf /var/config/retrodeck/tools @@ -195,6 +196,7 @@ post_update() { fi update_splashscreens + build_retrodeck_current_presets ) | zenity --icon-name=net.retrodeck.retrodeck --progress --no-cancel --pulsate --auto-close \ --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \ diff --git a/functions/presets.sh b/functions/presets.sh index 9b35cbaa..b1ccfc26 100644 --- a/functions/presets.sh +++ b/functions/presets.sh @@ -75,28 +75,7 @@ change_preset_dialog() { fi } -resolve_preset_conflicts() { - # This function will resolve conflicts between setting presets. ie. borders and widescreen cannot both be enabled at the same time. - # The function will read the $section_that_was_just_enabled and $section_to_check_for_conflicts - # If a conflict is found (where two conflicting settings are both enabled) the $section_to_check_for_conflicts entry will be disabled - # USAGE: resolve_preset_conflict "$section_that_was_just_enabled" "$section_to_check_for_conflicts" "system" - - local section_being_enabled=$1 - local section_to_check_for_conflicts=$2 - local system=$3 - local enabled_section_results=$(sed -n '/\['"$section_being_enabled"'\]/, /\[/{ /\['"$section_being_enabled"'\]/! { /\[/! p } }' $rd_conf | sed '/^$/d') - - while IFS= read -r config_line - do - system_name=$(get_setting_name "$config_line" $system) - system_value=$(get_setting_value $rd_conf "$system_name" $system $section_being_enabled) - if [[ $system_value == "true" && $(get_setting_value $rd_conf "$(get_setting_name "$config_line" $system)" $system $section_to_check_for_conflicts) == "true" ]]; then - set_setting_value $rd_conf $system_name "false" retrodeck $section_to_check_for_conflicts - fi - done < <(printf '%s\n' "$enabled_section_results") -} - -build_preset_config(){ +build_preset_config() { # This function will apply one or more presets for a given system, as listed in retrodeck.cfg # USAGE: build_preset_config "system name" "preset class 1" "preset class 2" "preset class 3" @@ -183,7 +162,7 @@ build_preset_config(){ if [[ "$read_system_enabled" == "true" ]]; then enable_file "$read_setting_name" else - diable_file "$read_setting_name" + disable_file "$read_setting_name" fi fi ;; @@ -198,3 +177,26 @@ build_preset_config(){ done < <(printf '%s\n' "$preset_section") done } + +build_retrodeck_current_presets() { + # This function will read the presets sections of the retrodeck.cfg file and build the default state + # This can also be used to build the "current" state post-update after adding new systems + # USAGE: build_retrodeck_current_presets + + while IFS= read -r current_setting_line # Read the existing retrodeck.cfg + do + if [[ (! -z "$current_setting_line") && (! "$current_setting_line" == "#"*) && (! "$current_setting_line" == "[]") ]]; then # If the line has a valid entry in it + if [[ ! -z $(grep -o -P "^\[.+?\]$" <<< "$current_setting_line") ]]; then # If the line is a section header + local current_section=$(sed 's^[][]^^g' <<< $current_setting_line) # Remove brackets from section name + else + if [[ ! ("$current_section" == "" || "$current_section" == "paths" || "$current_section" == "options" || "$current_section" == "cheevos" || "$current_section" == "cheevos_hardcore") ]]; then + local system_name=$(get_setting_name "$current_setting_line" "retrodeck") # Read the variable name from the current line + local system_enabled=$(get_setting_value "$rd_conf" "$system_name" "retrodeck" "$current_section") # Read the variables value from active retrodeck.cfg + if [[ "$system_enabled" == "true" ]]; then + build_preset_config "$system_name" "$current_section" + fi + fi + fi + fi + done < $rd_conf +} diff --git a/tools/configurator.sh b/tools/configurator.sh index 2b698fe3..afbf5588 100644 --- a/tools/configurator.sh +++ b/tools/configurator.sh @@ -1252,7 +1252,7 @@ configurator_usb_import_dialog() { "${external_devices[@]}") if [[ ! -z "$choice" ]]; then - if [[ $(verify_space "$choice/ROMs" "$roms_folder") == "false" ]]; + if [[ $(verify_space "$choice/ROMs" "$roms_folder") == "false" ]]; then if [[ $(configurator_generic_question_dialog "RetroDECK Configurator Utility - USB Migration Tool" "You MAY not have enough free space to import this ROM library.\n\nThis utility only imports new additions from the USB device, so if there are a lot of the same ROMs in both locations you are likely going to be fine\nbut we are not able to verify how much data will be transferred before it happens.\n\nIf you are unsure, please verify your available free space before continuing.\n\nDo you want to continue now?") == "true" ]]; then ( rsync -a --mkpath "$choice/ROMs/"* "$roms_folder"