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
This commit is contained in:
icenine451 2023-05-16 10:21:23 -04:00
parent 43aa29adb7
commit 449e8bbe4f
5 changed files with 79 additions and 48 deletions

View file

@ -39,14 +39,14 @@ pcsx2=false
retroarch=false retroarch=false
[borders] [borders]
gb=false gb=true
gba=false gba=true
gbc=false gbc=true
genesis=false genesis=true
gg=false gg=true
n64=false n64=true
psx_ra=false psx_ra=true
snes=false snes=true
[widescreen] [widescreen]
genesis=false genesis=false

View file

@ -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 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 rm -f $rd_update_patch # Cleanup temporary patch file
conf_read # Read all settings into memory conf_read # Read all settings into memory
}
conf_write() { # STAGE 3: Eliminate any preset incompatibility with existing user settings and new defaults
# 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 while IFS= read -r current_setting_line # Read the existing retrodeck.cfg
do do
@ -132,12 +129,18 @@ conf_write() {
if [[ ! -z $(grep -o -P "^\[.+?\]$" <<< "$current_setting_line") ]]; then # If the line is a section header 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 local current_section=$(sed 's^[][]^^g' <<< $current_setting_line) # Remove brackets from section name
else else
if [[ "$current_section" == "" || "$current_section" == "paths" || "$current_section" == "options" ]]; then if [[ ! ("$current_section" == "" || "$current_section" == "paths" || "$current_section" == "options" || "$current_section" == "cheevos" || "$current_section" == "cheevos_hardcore") ]]; then
local current_setting_name=$(get_setting_name "$current_setting_line" "retrodeck") # Read the variable name from the current line local system_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 system_enabled=$(get_setting_value "$rd_conf" "$system_name" "retrodeck" "$current_section") # Read the variables value from active retrodeck.cfg
local memory_setting_value=$(eval "echo \$${current_setting_name}") # Read the variable names' value from memory local default_setting=$(get_setting_value "$rd_defaults" "$system_name" "retrodeck" "$current_section") # Read the variable value from the retrodeck defaults
if [[ ! "$current_setting_value" == "$memory_setting_value" && ! -z "$memory_setting_value" ]]; then # If the values are different... if [[ "$system_enabled" == "true" ]]; then
set_setting_value "$rd_conf" "$current_setting_name" "$memory_setting_value" "retrodeck" "$current_section" # Update the value in retrodeck.cfg 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 fi
fi fi
@ -165,6 +168,29 @@ conf_read() {
done < $rd_conf 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() { dir_prep() {
# This script is creating a symlink preserving old folder contents and moving them in the new one # 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" prepare_emulator "reset" "all"
build_retrodeck_current_presets
# Optional actions based on user choices # Optional actions based on user choices
if [[ "$finit_options_choices" =~ (rpcs3_firmware|Enable All) ]]; then if [[ "$finit_options_choices" =~ (rpcs3_firmware|Enable All) ]]; then

View file

@ -70,7 +70,7 @@ post_update() {
if [[ $prev_version -le "070" ]]; then 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: # 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 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) # - 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 # - Expose ES-DE gamelists folder to user at ~/retrodeck/gamelists
# - Copy new borders into RA config location # - 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 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" 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" rm -f "/var/config/PCSX2/inis/PCSX2-cheevos-upgrade.patch"
dir_prep "/var/config/duckstation" "/var/data/duckstation"
mv -f "$duckstationconf" "$duckstationconf.bak" mv -f "$duckstationconf" "$duckstationconf.bak"
generate_single_patch "$emuconfigs/duckstation/settings.ini" "$duckstationconf.bak" "/var/config/duckstation/duckstation-cheevos-upgrade.patch" pcsx2 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" 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/" 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 # 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 # install_retrodeck_starterpack
fi # fi
cp -f $emuconfigs/rpcs3/vfs.yml /var/config/rpcs3/vfs.yml cp -f $emuconfigs/rpcs3/vfs.yml /var/config/rpcs3/vfs.yml
sed -i 's^\^$(EmulatorDir): .*^$(EmulatorDir): '"$bios_folder/rpcs3/"'^' "$rpcs3vfsconf" sed -i 's^\^$(EmulatorDir): .*^$(EmulatorDir): '"$bios_folder/rpcs3/"'^' "$rpcs3vfsconf"
@ -148,14 +149,14 @@ post_update() {
mkdir -p "$saves_folder/psx/duckstation/memcards" mkdir -p "$saves_folder/psx/duckstation/memcards"
mv "$saves_folder/duckstation/"* "$saves_folder/psx/duckstation/memcards/" mv "$saves_folder/duckstation/"* "$saves_folder/psx/duckstation/memcards/"
rmdir "$saves_folder/duckstation" # File-safe folder cleanup 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" "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" "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" "Directory" "$saves_folder/psx/duckstation/memcards" "duckstation" "MemoryCards"
set_setting_value "$duckstationconf" "RecursivePaths" "$roms_folder/psx" "duckstation" "GameList" set_setting_value "$duckstationconf" "RecursivePaths" "$roms_folder/psx" "duckstation" "GameList"
mkdir -p "$states_folder/psx" mkdir -p "$states_folder/psx"
mv -t "$states_folder/psx/" "$states_folder/duckstation" 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" dir_prep "$states_folder/psx/duckstation" "/var/config/duckstation/savestates"
rm -rf /var/config/retrodeck/tools rm -rf /var/config/retrodeck/tools
@ -195,6 +196,7 @@ post_update() {
fi fi
update_splashscreens update_splashscreens
build_retrodeck_current_presets
) | ) |
zenity --icon-name=net.retrodeck.retrodeck --progress --no-cancel --pulsate --auto-close \ zenity --icon-name=net.retrodeck.retrodeck --progress --no-cancel --pulsate --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" \

View file

@ -75,28 +75,7 @@ change_preset_dialog() {
fi fi
} }
resolve_preset_conflicts() { build_preset_config() {
# 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(){
# This function will apply one or more presets for a given system, as listed in retrodeck.cfg # 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" # 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 if [[ "$read_system_enabled" == "true" ]]; then
enable_file "$read_setting_name" enable_file "$read_setting_name"
else else
diable_file "$read_setting_name" disable_file "$read_setting_name"
fi fi
fi fi
;; ;;
@ -198,3 +177,26 @@ build_preset_config(){
done < <(printf '%s\n' "$preset_section") done < <(printf '%s\n' "$preset_section")
done 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
}

View file

@ -1252,7 +1252,7 @@ configurator_usb_import_dialog() {
"${external_devices[@]}") "${external_devices[@]}")
if [[ ! -z "$choice" ]]; then 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 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" rsync -a --mkpath "$choice/ROMs/"* "$roms_folder"