mirror of
https://github.com/RetroDECK/RetroDECK.git
synced 2024-11-22 14:05:39 +00:00
Extract preset change selection from Zenity for use in Godot
This commit is contained in:
parent
2374d6e7fe
commit
8411e064d1
|
@ -53,6 +53,7 @@ pretty_system_names_reference_list="$emuconfigs/defaults/retrodeck/reference_lis
|
||||||
# Godot data transfer temp files
|
# Godot data transfer temp files
|
||||||
|
|
||||||
godot_bios_files_checked="/var/config/retrodeck/godot/godot_bios_files_checked.tmp"
|
godot_bios_files_checked="/var/config/retrodeck/godot/godot_bios_files_checked.tmp"
|
||||||
|
godot_current_preset_settings="/var/config/retrodeck/godot/godot_current_preset_settings.tmp"
|
||||||
|
|
||||||
# Config files for emulators with single config files
|
# Config files for emulators with single config files
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,43 @@ change_preset_dialog() {
|
||||||
# This function will build a list of all systems compatible with a given preset, their current enable/disabled state and allow the user to change one or more
|
# This function will build a list of all systems compatible with a given preset, their current enable/disabled state and allow the user to change one or more
|
||||||
# USAGE: change_preset_dialog "$preset"
|
# USAGE: change_preset_dialog "$preset"
|
||||||
|
|
||||||
|
build_preset_list_options "$1"
|
||||||
|
|
||||||
|
choice=$(zenity \
|
||||||
|
--list --width=1200 --height=720 \
|
||||||
|
--checklist \
|
||||||
|
--separator="," \
|
||||||
|
--hide-column=3 --print-column=3 \
|
||||||
|
--text="Enable $pretty_preset_name:" \
|
||||||
|
--column "Enabled" \
|
||||||
|
--column "Emulator" \
|
||||||
|
--column "internal_system_name" \
|
||||||
|
"${current_preset_settings[@]}")
|
||||||
|
|
||||||
|
local rc=$?
|
||||||
|
|
||||||
|
if [[ ! -z $choice || "$rc" == 0 ]]; then
|
||||||
|
(
|
||||||
|
make_preset_changes
|
||||||
|
) |
|
||||||
|
zenity --icon-name=net.retrodeck.retrodeck --progress --no-cancel --pulsate --auto-close \
|
||||||
|
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
|
||||||
|
--title "RetroDECK Configurator Utility - Presets Configuration" \
|
||||||
|
--text="Setting up your presets, please wait..."
|
||||||
|
else
|
||||||
|
echo "No choices made"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
build_preset_list_options() {
|
||||||
|
# This function will build a list of all the systems available for a given preset
|
||||||
|
# The list will be generated into a Godot temp file and the variable $current_preset_settings
|
||||||
|
|
||||||
|
if [[ -f "$godot_current_preset_settings" ]]; then
|
||||||
|
rm -f "$godot_current_preset_settings" # Godot data transfer temp files
|
||||||
|
fi
|
||||||
|
touch "$godot_current_preset_settings"
|
||||||
|
|
||||||
local preset="$1"
|
local preset="$1"
|
||||||
pretty_preset_name=${preset//_/ } # Preset name prettification
|
pretty_preset_name=${preset//_/ } # Preset name prettification
|
||||||
pretty_preset_name=$(echo $pretty_preset_name | awk '{for(i=1;i<=NF;i++){$i=toupper(substr($i,1,1))substr($i,2)}}1') # Preset name prettification
|
pretty_preset_name=$(echo $pretty_preset_name | awk '{for(i=1;i<=NF;i++){$i=toupper(substr($i,1,1))substr($i,2)}}1') # Preset name prettification
|
||||||
|
@ -25,23 +62,14 @@ change_preset_dialog() {
|
||||||
current_disabled_systems=("${current_disabled_systems[@]}" "$system_name")
|
current_disabled_systems=("${current_disabled_systems[@]}" "$system_name")
|
||||||
fi
|
fi
|
||||||
current_preset_settings=("${current_preset_settings[@]}" "$system_value" "$(make_name_pretty $system_name)" "$system_name")
|
current_preset_settings=("${current_preset_settings[@]}" "$system_value" "$(make_name_pretty $system_name)" "$system_name")
|
||||||
|
echo "$system_value"^"$(make_name_pretty $system_name)"^"$system_name" >> "$godot_current_preset_settings"
|
||||||
done < <(printf '%s\n' "$section_results")
|
done < <(printf '%s\n' "$section_results")
|
||||||
|
}
|
||||||
|
|
||||||
choice=$(zenity \
|
|
||||||
--list --width=1200 --height=720 \
|
|
||||||
--checklist \
|
|
||||||
--separator="," \
|
|
||||||
--hide-column=3 --print-column=3 \
|
|
||||||
--text="Enable $pretty_preset_name:" \
|
|
||||||
--column "Enabled" \
|
|
||||||
--column "Emulator" \
|
|
||||||
--column "internal_system_name" \
|
|
||||||
"${current_preset_settings[@]}")
|
|
||||||
|
|
||||||
local rc=$?
|
make_preset_changes() {
|
||||||
|
# This function will take an array $choices, which contains the names of systems that have been enabled for this preset and enable them in the backend
|
||||||
|
|
||||||
if [[ ! -z $choice || "$rc" == 0 ]]; then
|
|
||||||
(
|
|
||||||
IFS="," read -ra choices <<< "$choice"
|
IFS="," read -ra choices <<< "$choice"
|
||||||
for emulator in "${all_systems[@]}"; do
|
for emulator in "${all_systems[@]}"; do
|
||||||
if [[ " ${choices[*]} " =~ " ${emulator} " && ! " ${current_enabled_systems[*]} " =~ " ${emulator} " ]]; then
|
if [[ " ${choices[*]} " =~ " ${emulator} " && ! " ${current_enabled_systems[*]} " =~ " ${emulator} " ]]; then
|
||||||
|
@ -71,14 +99,6 @@ change_preset_dialog() {
|
||||||
for emulator in "${changed_systems[@]}"; do
|
for emulator in "${changed_systems[@]}"; do
|
||||||
build_preset_config $emulator ${changed_presets[*]}
|
build_preset_config $emulator ${changed_presets[*]}
|
||||||
done
|
done
|
||||||
) |
|
|
||||||
zenity --icon-name=net.retrodeck.retrodeck --progress --no-cancel --pulsate --auto-close \
|
|
||||||
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
|
|
||||||
--title "RetroDECK Configurator Utility - Presets Configuration" \
|
|
||||||
--text="Setting up your presets, please wait..."
|
|
||||||
else
|
|
||||||
echo "No choices made"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
build_preset_config() {
|
build_preset_config() {
|
||||||
|
|
Loading…
Reference in a new issue