From 3392b1c2be092293ab891c9a12e7d5c658a49a49 Mon Sep 17 00:00:00 2001 From: icenine451 Date: Mon, 8 May 2023 15:20:06 -0400 Subject: [PATCH] Move presets folder Make presets engine able to handle changing core RA config (to apply preset to all cores) --- .../presets/Duckstation_presets.cfg | 0 .../{reference_lists => }/presets/PCSX2_presets.cfg | 0 .../retrodeck/presets/RetroArch_presets.cfg | 3 +++ .../{reference_lists => }/presets/SNES_presets.cfg | 2 +- .../{reference_lists => }/presets/example.txt | 0 functions.sh | 13 +++++++++++-- global.sh | 2 +- 7 files changed, 16 insertions(+), 4 deletions(-) rename emu-configs/defaults/retrodeck/{reference_lists => }/presets/Duckstation_presets.cfg (100%) rename emu-configs/defaults/retrodeck/{reference_lists => }/presets/PCSX2_presets.cfg (100%) create mode 100644 emu-configs/defaults/retrodeck/presets/RetroArch_presets.cfg rename emu-configs/defaults/retrodeck/{reference_lists => }/presets/SNES_presets.cfg (84%) rename emu-configs/defaults/retrodeck/{reference_lists => }/presets/example.txt (100%) diff --git a/emu-configs/defaults/retrodeck/reference_lists/presets/Duckstation_presets.cfg b/emu-configs/defaults/retrodeck/presets/Duckstation_presets.cfg similarity index 100% rename from emu-configs/defaults/retrodeck/reference_lists/presets/Duckstation_presets.cfg rename to emu-configs/defaults/retrodeck/presets/Duckstation_presets.cfg diff --git a/emu-configs/defaults/retrodeck/reference_lists/presets/PCSX2_presets.cfg b/emu-configs/defaults/retrodeck/presets/PCSX2_presets.cfg similarity index 100% rename from emu-configs/defaults/retrodeck/reference_lists/presets/PCSX2_presets.cfg rename to emu-configs/defaults/retrodeck/presets/PCSX2_presets.cfg diff --git a/emu-configs/defaults/retrodeck/presets/RetroArch_presets.cfg b/emu-configs/defaults/retrodeck/presets/RetroArch_presets.cfg new file mode 100644 index 00000000..da6b1e9c --- /dev/null +++ b/emu-configs/defaults/retrodeck/presets/RetroArch_presets.cfg @@ -0,0 +1,3 @@ +config_file_format^retroarch-all +target_file^$raconf +defaults_file^$emuconfigs/retroarch/retroarch.cfg diff --git a/emu-configs/defaults/retrodeck/reference_lists/presets/SNES_presets.cfg b/emu-configs/defaults/retrodeck/presets/SNES_presets.cfg similarity index 84% rename from emu-configs/defaults/retrodeck/reference_lists/presets/SNES_presets.cfg rename to emu-configs/defaults/retrodeck/presets/SNES_presets.cfg index cbce0528..0255c489 100644 --- a/emu-configs/defaults/retrodeck/reference_lists/presets/SNES_presets.cfg +++ b/emu-configs/defaults/retrodeck/presets/SNES_presets.cfg @@ -1,6 +1,6 @@ config_file_format^retroarch target_file^/var/config/retroarch/config/Snes9x/snes.cfg -defaults_file^$raconf +defaults_file^$emuconfigs/retroarch/retroarch.cfg change^cheevos^cheevos_enable^true change^cheevos^cheevos_token^$cheevos_token change^cheevos^cheevos_username^$cheevos_username diff --git a/emu-configs/defaults/retrodeck/reference_lists/presets/example.txt b/emu-configs/defaults/retrodeck/presets/example.txt similarity index 100% rename from emu-configs/defaults/retrodeck/reference_lists/presets/example.txt rename to emu-configs/defaults/retrodeck/presets/example.txt diff --git a/functions.sh b/functions.sh index 2d792662..836a4dbd 100644 --- a/functions.sh +++ b/functions.sh @@ -553,6 +553,9 @@ enable_file() { } 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" + local system_being_changed="$1" shift local presets_being_changed="$*" @@ -593,7 +596,7 @@ build_preset_config(){ if [[ "$new_setting_value" = \$* ]]; then eval new_setting_value=$new_setting_value fi - if [[ "$read_config_format" == "retroarch" ]]; then # Generate the override file + if [[ "$read_config_format" == "retroarch" ]]; then # If this is a RetroArch core, generate the override file if [[ -z $(grep "$read_setting_name" "$read_target_file") ]]; then if [[ ! -f "$read_target_file" ]]; then mkdir -p "$(realpath $(dirname "$read_target_file"))" @@ -605,6 +608,9 @@ build_preset_config(){ set_setting_value "$read_target_file" "$read_setting_name" "$new_setting_value" "$read_config_format" "$section" fi else + if [[ "$read_config_format" == "retroarch-all" ]]; then + read_config_format="retroarch" + fi set_setting_value "$read_target_file" "$read_setting_name" "$new_setting_value" "$read_config_format" "$section" fi else @@ -619,6 +625,9 @@ build_preset_config(){ fi fi else + if [[ "$read_config_format" == "retroarch-all" ]]; then + read_config_format="retroarch" + fi local default_setting_value=$(get_setting_value "$read_defaults_file" "$read_setting_name" "$read_config_format" "$section") set_setting_value "$read_target_file" "$read_setting_name" "$default_setting_value" "$read_config_format" "$section" fi @@ -631,7 +640,7 @@ build_preset_config(){ ;; esac - done < <(eval cat "$presets_reference_lists_dir/$read_system_name"_presets.cfg) + done < <(eval cat "$presets_dir/$read_system_name"_presets.cfg) fi done < <(printf '%s\n' "$preset_section") done diff --git a/global.sh b/global.sh index 864a58eb..c520856e 100755 --- a/global.sh +++ b/global.sh @@ -34,7 +34,7 @@ helper_files_list="$emuconfigs/defaults/retrodeck/reference_lists/helper_files_l 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 -presets_reference_lists_dir="$emuconfigs/defaults/retrodeck/reference_lists/presets" +presets_dir="$emuconfigs/defaults/retrodeck/presets" incompatible_presets_reference_list="$emuconfigs/defaults/retrodeck/reference_lists/incompatible_presets.cfg" # Config files for emulators with single config files