mirror of
https://github.com/RetroDECK/RetroDECK.git
synced 2025-03-06 14:27:48 +00:00
Mover upgrades and add conf_read
This commit is contained in:
parent
697ee2b959
commit
1ada7e1191
56
functions.sh
56
functions.sh
|
@ -786,7 +786,7 @@ update_rd_conf() {
|
|||
deploy_single_patch $rd_defaults $rd_update_patch $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
|
||||
source $rd_conf
|
||||
conf_read
|
||||
}
|
||||
|
||||
resolve_preset_conflicts() {
|
||||
|
@ -1076,6 +1076,24 @@ conf_write() {
|
|||
done < $rd_conf
|
||||
}
|
||||
|
||||
conf_read() {
|
||||
# This function will read the RetroDECK config file into memory
|
||||
# USAGE: conf_read
|
||||
|
||||
while IFS= read -r current_setting_line # Read the existing retrodeck.cfg
|
||||
do
|
||||
if [[ (! -z "$current_setting_line") && (! "$current_setting_line" == "#!/bin/bash") && (! "$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
|
||||
current_section=$(sed 's^[][]^^g' <<< $current_setting_line) # Remove brackets from section name
|
||||
else
|
||||
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
|
||||
eval "$current_setting_name=$current_setting_value" # Write the current setting name and value to memory
|
||||
fi
|
||||
fi
|
||||
done < $rd_conf
|
||||
}
|
||||
|
||||
dir_prep() {
|
||||
# This script is creating a symlink preserving old folder contents and moving them in the new one
|
||||
|
||||
|
@ -1131,6 +1149,19 @@ dir_prep() {
|
|||
echo -e "$symlink is now $real\n"
|
||||
}
|
||||
|
||||
consolidate_retrodeck_folders() {
|
||||
# This script will find folders that may have been moved out of the main RetroDECK folder individually and move them home
|
||||
# USAGE: consolidate_retrodeck_folders
|
||||
|
||||
while read -r path; do
|
||||
if realpath "$path" | grep -q "^$main_path/"; then
|
||||
echo "$path is a subfolder of $main_path"
|
||||
else
|
||||
echo "$path is not a subfolder of $main_path"
|
||||
fi
|
||||
done < <(grep -v '^\s*$' $rd_conf | awk '/^\[paths\]/{f=1;next} /^\[/{f=0} f')
|
||||
}
|
||||
|
||||
update_splashscreens() {
|
||||
# This script will purge any existing ES graphics and reload them from RO space into somewhere ES will look for it
|
||||
# USAGE: update_splashscreens
|
||||
|
@ -1153,6 +1184,22 @@ prepare_emulator() {
|
|||
emulator="$2"
|
||||
call_source="$3"
|
||||
|
||||
if [[ "$emulator" == "retrodeck" ]]; then # For use after RetroDECK is consolidated and moved
|
||||
if [[ "$action" == "postmove" ]]; then
|
||||
roms_folder=$rdhome/roms
|
||||
saves_folder=$rdhome/saves
|
||||
states_folder=$rdhome/states
|
||||
bios_folder=$rdhome/bios
|
||||
media_folder=$rdhome/downloaded_media
|
||||
themes_folder=$rdhome/themes
|
||||
logs_folder=$rdhome/.logs
|
||||
screenshots_folder=$rdhome/screenshots
|
||||
mods_folder=$rdhome/mods
|
||||
texture_packs_folder=$rdhome/texture_packs
|
||||
borders_folder=$rdhome/borders
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$emulator" =~ ^(retroarch|RetroArch|all)$ ]]; then
|
||||
if [[ "$action" == "reset" ]]; then # Run reset-only commands
|
||||
if [[ $(check_network_connectivity) == "true" ]]; then
|
||||
|
@ -2149,7 +2196,12 @@ configurator_destination_choice_dialog() {
|
|||
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
|
||||
--text="$2")
|
||||
|
||||
echo $choice
|
||||
local rc=$?
|
||||
if [[ $rc == "0" ]] && [[ -z "$choice" ]]; then
|
||||
echo "Back"
|
||||
else
|
||||
echo $choice
|
||||
fi
|
||||
}
|
||||
|
||||
configurator_reset_confirmation_dialog() {
|
||||
|
|
10
global.sh
10
global.sh
|
@ -119,13 +119,13 @@ then
|
|||
echo "RetroDECK config file initialized. Contents:"
|
||||
echo
|
||||
cat $rd_conf
|
||||
source $rd_conf # Load new variables into memory
|
||||
conf_read # Load new variables into memory
|
||||
|
||||
# If the config file is existing i just read the variables (source it)
|
||||
# If the config file is existing i just read the variables
|
||||
else
|
||||
echo "Found RetroDECK config file in $rd_conf"
|
||||
echo "Loading it"
|
||||
source "$rd_conf"
|
||||
conf_read
|
||||
|
||||
# Verify rdhome is where it is supposed to be.
|
||||
if [[ ! -d $rdhome ]]; then
|
||||
|
@ -133,7 +133,7 @@ else
|
|||
configurator_generic_dialog "The RetroDECK data folder was not found in the expected location.\nThis may happen when SteamOS is updated.\n\nPlease browse to the current location of the \"retrodeck\" folder."
|
||||
new_home_path=$(directory_browse "RetroDECK folder location")
|
||||
sed -i 's#'$prev_home_path'#'$new_home_path'#g' $rd_conf
|
||||
source "$rd_conf"
|
||||
emulators_post_move
|
||||
conf_read
|
||||
prepare_emulator "all" "postmove"
|
||||
fi
|
||||
fi
|
||||
|
|
|
@ -196,7 +196,7 @@ configurator_power_user_warning_dialog() {
|
|||
configurator_welcome_dialog
|
||||
elif [[ $choice == "Never show this again" ]]; then
|
||||
set_setting_value $rd_conf "power_user_warning" "false" retrodeck "options" # Store desktop mode warning variable for future checks
|
||||
source $rd_conf
|
||||
conf_read
|
||||
configurator_power_user_changes_dialog
|
||||
fi
|
||||
fi
|
||||
|
@ -761,7 +761,7 @@ configurator_tools_and_troubleshooting_dialog() {
|
|||
|
||||
"Move RetroDECK" )
|
||||
configurator_generic_dialog "This option will move the RetroDECK data folder (ROMs, saves, BIOS etc.) to a new location.\n\nPlease choose where to move the RetroDECK data folder."
|
||||
configurator_move_dialog
|
||||
configurator_move_retrodeck_dialog
|
||||
;;
|
||||
|
||||
"Multi-file game structure check" )
|
||||
|
@ -822,7 +822,7 @@ configurator_tools_and_troubleshooting_dialog() {
|
|||
esac
|
||||
}
|
||||
|
||||
configurator_move_dialog() {
|
||||
configurator_move_retrodeck_dialog() {
|
||||
if [[ -d $rdhome ]]; then
|
||||
destination=$(configurator_destination_choice_dialog "RetroDECK Data" "Please choose a destination for the RetroDECK data folder.")
|
||||
case $destination in
|
||||
|
@ -834,11 +834,11 @@ configurator_move_dialog() {
|
|||
"Internal Storage" )
|
||||
if [[ ! -L "$HOME/retrodeck" && -d "$HOME/retrodeck" ]]; then
|
||||
configurator_generic_dialog "The RetroDECK data folder is already at that location, please pick a new one."
|
||||
configurator_move_dialog
|
||||
configurator_move_retrodeck_dialog
|
||||
else
|
||||
configurator_generic_dialog "Moving RetroDECK data folder to $destination"
|
||||
unlink $HOME/retrodeck # Remove symlink for $rdhome
|
||||
move $rdhome "$HOME"
|
||||
#move $rdhome "$HOME"
|
||||
if [[ ! -d $rdhome && -d $HOME/retrodeck ]]; then # If the move succeeded
|
||||
rdhome="$HOME/retrodeck"
|
||||
roms_folder="$rdhome/roms"
|
||||
|
@ -847,7 +847,7 @@ configurator_move_dialog() {
|
|||
bios_folder="$rdhome/bios"
|
||||
media_folder="$rdhome/downloaded_media"
|
||||
themes_folder="$rdhome/themes"
|
||||
emulators_post_move
|
||||
prepare_emulator "all" "postmove"
|
||||
conf_write
|
||||
|
||||
configurator_process_complete_dialog "moving the RetroDECK data directory to internal storage"
|
||||
|
@ -860,7 +860,7 @@ configurator_move_dialog() {
|
|||
"SD Card" )
|
||||
if [[ -L "$HOME/retrodeck" && -d "$sdcard/retrodeck" && "$rdhome" == "$sdcard/retrodeck" ]]; then
|
||||
configurator_generic_dialog "The RetroDECK data folder is already configured to that location, please pick a new one."
|
||||
configurator_move_dialog
|
||||
configurator_move_retrodeck_dialog
|
||||
else
|
||||
if [[ ! -w $sdcard ]]; then
|
||||
configurator_generic_dialog "The SD card was found but is not writable\nThis can happen with cards formatted on PC or for other reasons.\nPlease format the SD card through the Steam Deck's Game Mode and try the moving process again."
|
||||
|
@ -896,7 +896,7 @@ configurator_move_dialog() {
|
|||
bios_folder="$rdhome/bios"
|
||||
media_folder="$rdhome/downloaded_media"
|
||||
themes_folder="$rdhome/themes"
|
||||
emulators_post_move
|
||||
prepare_emulator "all" "postmove"
|
||||
conf_write
|
||||
configurator_process_complete_dialog "moving the RetroDECK data directory to SD card"
|
||||
else
|
||||
|
@ -947,7 +947,7 @@ configurator_move_dialog() {
|
|||
bios_folder="$rdhome/bios"
|
||||
media_folder="$rdhome/downloaded_media"
|
||||
themes_folder="$rdhome/themes"
|
||||
emulators_post_move
|
||||
prepare_emulator "all" "postmove"
|
||||
conf_write
|
||||
configurator_process_complete_dialog "moving the RetroDECK data directory to SD card"
|
||||
else
|
||||
|
@ -972,7 +972,7 @@ configurator_move_dialog() {
|
|||
emulator_post_move
|
||||
conf_write
|
||||
configurator_generic_dialog "RetroDECK data folder now configured at $rdhome. Please start the moving process again."
|
||||
configurator_move_dialog
|
||||
configurator_move_retrodeck_dialog
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue