--text="The process of $1 is now complete.\n\nYou may need to quit and restart RetroDECK for your changes to take effect\n\nClick OK to return to the Main Menu or Quit to quit RetroDECK."
# This dialog is for making things easy for new users to move files to common locations. Gives the options for "Internal", "SD Card" and "Custom" locations.
# USAGE: $(configurator_destination_choice_dialog "folder being moved" "action text")
# This function returns one of the values: "Back" "Internal Storage" "SD Card" "Custom Location"
# This dialog will take a folder variable name from retrodeck.cfg and move it to a new location. The variable will be updated in retrodeck.cfg as well as any emulator configs where it occurs.
localrd_dir_name="$1"# The folder variable name from retrodeck.cfg
localdir_to_move="$(get_setting_value "$rd_conf""$rd_dir_name""retrodeck""paths")/"# The path of that folder variable
localsource_root="$(echo$dir_to_move| sed -e 's/\(.*\)\/retrodeck\/.*/\1/')"# The root path of the folder, excluding retrodeck/<folder name>. So /home/deck/retrodeck/roms becomes /home/deck
if[[ ! "$rd_dir_name"=="rdhome"]];then# If a sub-folder is being moved, find it's path without the source_root. So /home/deck/retrodeck/roms becomes retrodeck/roms
localrd_dir_path="$(echo"$dir_to_move"| sed "s/.*\(retrodeck\/.*\)/\1/; s/\/$//")"
else# Otherwise just set the retrodeck root folder
localrd_dir_path="$(basename $dir_to_move)"
fi
if[[ -d "$dir_to_move"]];then# If the directory selected to move already exists at the expected location pulled from retrodeck.cfg
choice=$(configurator_destination_choice_dialog "RetroDECK Data""Please choose a destination for the $(basename $dir_to_move) folder.")
case$choice in
"Internal Storage"|"SD Card"|"Custom Location")# If the user picks a location
if[["$choice"=="Internal Storage"]];then# If the user wants to move the folder to internal storage, set the destination target as HOME
localdest_root="$HOME"
elif[["$choice"=="SD Card"]];then# If the user wants to move the folder to the predefined SD card location, set the target as sdcard from retrodeck.cfg
localdest_root="$sdcard"
else
configurator_generic_dialog "RetroDECK Configurator - Move Folder""Select the parent folder you would like to store the $(basename $dir_to_move) folder in."
localdest_root=$(directory_browse "RetroDECK directory location")# Set the destination root as the selected custom location
fi
if[[(! -z "$dest_root")&&( -w "$dest_root")]];then# If user picked a destination and it is writable
if[[(-d "$dest_root/$rd_dir_path")&&(! -L "$dest_root/$rd_dir_path")&&(! $rd_dir_name=="rdhome")]]||[["$(realpath $dir_to_move)"=="$dest_root/$rd_dir_path"]];then# If the user is trying to move the folder to where it already is (excluding symlinks that will be unlinked)
configurator_generic_dialog "RetroDECK Configurator - Move Folder""The $(basename $dir_to_move) folder is already at that location, please pick a new one."
configurator_move_folder_dialog "$rd_dir_name"
else
if[[$(verify_space "$(echo$dir_to_move| sed 's/\/$//')""$dest_root")]];then# Make sure there is enough space at the destination
--text="The destination directory you have selected does not have enough free space for the files you are trying to move.\n\nPlease select a new destination or free up some space."
fi
fi
else# If the user didn't pick any custom destination, or the destination picked is unwritable
if[[ ! -z "$dest_root"]];then
configurator_generic_dialog "RetroDECK Configurator - Move Folder""No destination was chosen, so no files have been moved."
else
configurator_generic_dialog "RetroDECK Configurator - Move Folder""The chosen destination is not writable.\nNo files have been moved.\n\nThis can happen when trying to select a location that RetroDECK does not have permission to write.\nThis can normally be fixed by adding the desired path to the RetroDECK permissions with Flatseal."
fi
fi
;;
esac
else# The folder to move was not found at the path pulled from retrodeck.cfg and it needs to be reconfigured manually.
configurator_generic_dialog "RetroDECK Configurator - Move Folder""The $(basename $dir_to_move) folder was not found at the expected location.\n\nThis may have happened if the folder was moved manually.\n\nPlease select the current location of the folder."
# This function will pull the changelog notes from the version it is passed (which must match the appdata version tag) from the net.retrodeck.retrodeck.appdata.xml file
# The function also accepts "all" as a version, and will print the entire changelog
--text="You appear to be running RetroDECK in the Steam Deck's Desktop mode!\n\nSome functions of RetroDECK may not work properly in Desktop mode, such as the Steam Deck's normal controls.\n\nRetroDECK is best enjoyed in Game mode!\n\nDo you still want to proceed?")
rc=$?# Capture return code, as "Yes" button has no text value
if[[$rc=="1"]];then# If any button other than "Yes" was clicked
if[[$choice=="No"]];then
exit1
elif[[$choice=="Never show this again"]];then
set_setting_value $rd_conf"desktop_mode_warning""false" retrodeck "options"# Store desktop mode warning variable for future checks
fi
fi
fi
}
low_space_warning(){
# This function will verify that the drive with the $HOME path on it has at least 10% space free, so the user can be warned before it fills up
--text="Your main drive is over 90% full!\n\nIf your drive fills completely this can lead to data loss or system crash.\n\nPlease consider moving some RetroDECK folders to other storage locations using the Configurator.")
if[[$choice=="Never show this again"]];then
set_setting_value $rd_conf"low_space_warning""false" retrodeck "options"# Store low space warning variable for future checks