mirror of
https://github.com/RetroDECK/RetroDECK.git
synced 2025-01-18 06:45:38 +00:00
Multi-user support for saves/states ONLY,
no multi-user config support yet
This commit is contained in:
parent
39152e7099
commit
501889e954
|
@ -14,4 +14,7 @@ sdcard=/run/media/mmcblk0p1
|
|||
power_user_warning=true
|
||||
desktop_mode_warning=true
|
||||
network_features=false
|
||||
multi_user=false
|
||||
ask_default_user=true
|
||||
default_user=
|
||||
developer_options=false
|
119
functions.sh
119
functions.sh
|
@ -666,6 +666,123 @@ resolve_preset_conflicts() {
|
|||
done < <(printf '%s\n' "$enabled_section_results")
|
||||
}
|
||||
|
||||
multi_user_set_default_dialog() {
|
||||
chosen_user="$1"
|
||||
choice=$(zenity --icon-name=net.retrodeck.retrodeck --info --no-wrap --ok-label="Yes" --extra-button="No" --extra-button="No and don't ask again" \
|
||||
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
|
||||
--title "RetroDECK Default User" \
|
||||
--text="Would you like to set $chosen_user as the default user?\n\nIf the current user cannot be determined from the system, the default will be used.\nThis normally only happens in Desktop Mode.\n\nIf you would like to be asked which user is playing every time, click \"No and don't ask again\"")
|
||||
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 and don't ask again" ]]; then
|
||||
set_setting_value $rd_conf "ask_default_user" "false" retrodeck
|
||||
fi
|
||||
else # User clicked "Yes"
|
||||
set_setting_value $rd_conf "default_user" "$chosen_user" retrodeck
|
||||
fi
|
||||
}
|
||||
|
||||
load_current_user_saves_and_states() {
|
||||
if [[ $(get_setting_value $rd_conf "multi_user" retrodeck) == "true" ]]; then # If multi-user environment is enabled in rd_conf
|
||||
if [[ -f "$rd_userlist" ]]; then # If userlist already exists
|
||||
if [[ ! -z $SteamAppUser ]]; then # If running in Game Mode and this variable exists
|
||||
if [[ -z $(grep "$SteamAppUser" "$rd_userlist") ]]; then # If the user was not found in a list of known users
|
||||
add_setting $rd_userlist $SteamAppUser retrodeck # Add the user to the list
|
||||
unlink "$saves_folder"
|
||||
unlink "$states_folder"
|
||||
dir_prep "$multi_user_data_folder/$SteamAppUser/saves" "$saves_folder"
|
||||
dir_prep "$multi_user_data_folder/$SteamAppUser/states" "$states_folder"
|
||||
else # User was found on the list
|
||||
if [[ -L "$saves_folder" ]]; then # and saves folder was already a symlink
|
||||
ln -sfT "$multi_user_data_folder/$SteamAppUser/saves" "$saves_folder"
|
||||
else # If saves folder was not a symlink (user may have disabled multi_user before and is renabling it now)
|
||||
dir_prep "$multi_user_data_folder/$SteamAppUser/saves" "$saves_folder"
|
||||
fi
|
||||
if [[ -L "$states_folder" ]]; then # and saves folder was already a symlink
|
||||
ln -sfT "$multi_user_data_folder/$SteamAppUser/states" "$states_folder"
|
||||
else # If saves folder was not a symlink (user may have disabled multi_user before and is renabling it now)
|
||||
dir_prep "$multi_user_data_folder/$SteamAppUser/states" "$states_folder"
|
||||
fi
|
||||
fi
|
||||
else # Unable to find Steam user ID
|
||||
if [[ $(cat "$rd_userlist" | sed '/^\s*$/d' | wc -l) -gt 1 ]]; then # If there is more than one user on the list...
|
||||
if [[ -z $default_user ]]; then # And a default user is not set
|
||||
configurator_generic_dialog "The current user could not be determined from the system, and there are multiple users registered.\n\nPlease select which user is currently playing in the next dialog."
|
||||
SteamAppUser=$(multi_user_choose_current_user_dialog)
|
||||
if [[ ! -z $SteamAppUser ]]; then # User was chosen from dialog
|
||||
if [[ -L "$saves_folder" ]]; then # and saves folder was already a symlink
|
||||
ln -sfT "$multi_user_data_folder/$SteamAppUser/saves" "$saves_folder"
|
||||
else # If saves folder was not a symlink (user may have disabled multi_user before and is renabling it now)
|
||||
dir_prep "$multi_user_data_folder/$SteamAppUser/saves" "$saves_folder"
|
||||
fi
|
||||
if [[ -L "$states_folder" ]]; then # and saves folder was already a symlink
|
||||
ln -sfT "$multi_user_data_folder/$SteamAppUser/states" "$states_folder"
|
||||
else # If saves folder was not a symlink (user may have disabled multi_user before and is renabling it now)
|
||||
dir_prep "$multi_user_data_folder/$SteamAppUser/states" "$states_folder"
|
||||
fi
|
||||
else
|
||||
configurator_generic_dialog "No user was chosen, RetroDECK will launch with the files from the user who played most recently."
|
||||
fi
|
||||
else # The default user is set
|
||||
if [[ ! -z $(ls -1 $multi_user_data_folder | grep "$default_user") ]]; then # Confirm user data folder exists
|
||||
SteamAppUser=$default_user
|
||||
if [[ -L "$saves_folder" ]]; then # and saves folder was already a symlink
|
||||
ln -sfT "$multi_user_data_folder/$SteamAppUser/saves" "$saves_folder"
|
||||
else # If saves folder was not a symlink (user may have disabled multi_user before and is renabling it now)
|
||||
dir_prep "$multi_user_data_folder/$SteamAppUser/saves" "$saves_folder"
|
||||
fi
|
||||
if [[ -L "$states_folder" ]]; then # and saves folder was already a symlink
|
||||
ln -sfT "$multi_user_data_folder/$SteamAppUser/states" "$states_folder"
|
||||
else # If saves folder was not a symlink (user may have disabled multi_user before and is renabling it now)
|
||||
dir_prep "$multi_user_data_folder/$SteamAppUser/states" "$states_folder"
|
||||
fi
|
||||
else
|
||||
echo "Default user $default_user has no data folder, something has gone horribly wrong."
|
||||
fi
|
||||
fi
|
||||
else # If there is only 1 user in the userlist, default to that user
|
||||
SteamAppUser=$(cat "$rd_userlist" | sed '/^\s*$/d')
|
||||
if [[ -L "$saves_folder" ]]; then # and saves folder was already a symlink
|
||||
ln -sfT "$multi_user_data_folder/$SteamAppUser/saves" "$saves_folder"
|
||||
else # If saves folder was not a symlink (user may have disabled multi_user before and is renabling it now)
|
||||
dir_prep "$multi_user_data_folder/$SteamAppUser/saves" "$saves_folder"
|
||||
fi
|
||||
if [[ -L "$states_folder" ]]; then # and saves folder was already a symlink
|
||||
ln -sfT "$multi_user_data_folder/$SteamAppUser/states" "$states_folder"
|
||||
else # If saves folder was not a symlink (user may have disabled multi_user before and is renabling it now)
|
||||
dir_prep "$multi_user_data_folder/$SteamAppUser/states" "$states_folder"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
else # If the userlist file doesn't exist yet, create it and add the current user
|
||||
if [[ ! -z $SteamAppUser ]]; then
|
||||
dir_prep "$multi_user_data_folder/$SteamAppUser/saves" "$saves_folder"
|
||||
dir_prep "$multi_user_data_folder/$SteamAppUser/states" "$states_folder"
|
||||
else # If running in Desktop mode for the first time
|
||||
configurator_generic_dialog "The current user could not be determined from the system and there is no existing userlist.\n\nPlease enter the Steam account username (not profile name) into the next dialog, or run RetroDECK in game mode."
|
||||
if zenity --entry \
|
||||
--title="Specify Steam username" \
|
||||
--text="Enter Steam username:"
|
||||
then # User clicked "OK"
|
||||
SteamAppUser=$?
|
||||
if [[ ! -z $SteamAppUser ]]; then
|
||||
dir_prep "$multi_user_data_folder/$SteamAppUser/saves" "$saves_folder"
|
||||
dir_prep "$multi_user_data_folder/$SteamAppUser/states" "$states_folder"
|
||||
else # But dialog box was blank
|
||||
configurator_generic_dialog "No username was entered, so multi-user data folder cannot be created.\n\nDisabling multi-user mode, please try the process again."
|
||||
set_setting_value $rd_conf "multi_user" "false" retrodeck
|
||||
fi
|
||||
else # User clicked "Cancel"
|
||||
configurator_generic_dialog "Cancelling multi-user mode activation."
|
||||
set_setting_value $rd_conf "multi_user" "false" retrodeck
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
else
|
||||
configurator_generic_dialog "Multi-user mode is not currently enabled"
|
||||
fi
|
||||
}
|
||||
|
||||
conf_write() {
|
||||
# writes the variables in the retrodeck config file
|
||||
|
||||
|
@ -1620,4 +1737,4 @@ configurator_destination_choice_dialog() {
|
|||
--text="$2")
|
||||
|
||||
echo $choice
|
||||
}
|
||||
}
|
|
@ -10,12 +10,14 @@ rd_conf_backup="/var/config/retrodeck/retrodeck.bak"
|
|||
emuconfigs="/app/retrodeck/emu-configs" # folder with all the default emulator configs
|
||||
rd_defaults="$emuconfigs/defaults/retrodeck/retrodeck.cfg" # A default RetroDECK config file
|
||||
rd_update_patch="/var/config/retrodeck/rd_update.patch" # A static location for the temporary patch file used during retrodeck.cfg updates
|
||||
bios_checklist="$emuconfigs/defaults/retrodeck/bios_checklist.cfg" # A config file listing BIOS file information that can be verified
|
||||
bios_checklist="$emuconfigs/defaults/retrodeck/bios_checklist.cfg" # A config file listing BIOS file information that can be verified
|
||||
compression_targets="$emuconfigs/defaults/retrodeck/compression_targets.cfg" # A config file containing supported compression types per system
|
||||
easter_egg_checklist="$emuconfigs/defaults/retrodeck/easter_egg_checklist.cfg" # A config file listing days and times when special splash screens should show up
|
||||
easter_egg_checklist="$emuconfigs/defaults/retrodeck/easter_egg_checklist.cfg" # A config file listing days and times when special splash screens should show up
|
||||
splashscreen_dir="/var/config/emulationstation/.emulationstation/resources/graphics/extra-splashes" # The default location of extra splash screens
|
||||
current_splash_file="/var/config/emulationstation/.emulationstation/resources/graphics/splash.svg" # The active splash file that will be shown on boot
|
||||
default_splash_file="/var/config/emulationstation/.emulationstation/resources/graphics/splash-orig.svg" # The default RetroDECK splash screen
|
||||
multi_user_data_folder="$rdhome/multi-user-data" # The default location of multi-user environment profiles
|
||||
rd_userlist="/var/config/retrodeck/userlist.cfg" # A list of all known Steam users, for multi-user functionality
|
||||
lockfile="/var/config/retrodeck/.lock" # where the lockfile is located
|
||||
default_sd="/run/media/mmcblk0p1" # Steam Deck SD default path
|
||||
hard_version="$(cat '/app/retrodeck/version')" # hardcoded version (in the readonly filesystem)
|
||||
|
|
|
@ -804,6 +804,61 @@ configurator_move_dialog() {
|
|||
fi
|
||||
}
|
||||
|
||||
configurator_retrodeck_multiuser_dialog() {
|
||||
if [[ $(get_setting_value $rd_conf "multi_user" retrodeck) == "true" ]]; then
|
||||
zenity --question \
|
||||
--no-wrap --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
|
||||
--title "RetroDECK Configurator - RetroDECK Multi-user Support" \
|
||||
--text="Multi-user support is current enabled. Do you want to disable it?\n\nIf there are more than one user configured,\nyou will be given a choice of which to use as the single RetroDECK user.\n\nAll existing saves will be retained in the \"retrodeck/multi-user-data\" folder."
|
||||
|
||||
if [ $? == 0 ] # User clicked "Yes"
|
||||
then # Load full userlist for selection
|
||||
full_userlist=()
|
||||
while IFS= read -r user
|
||||
do
|
||||
full_userlist=("${full_userlist[@]}" "$user")
|
||||
done < <(cat "$rd_userlist")
|
||||
|
||||
single_user=$(zenity \
|
||||
--list --width=1200 --height=720 \
|
||||
--ok-label="Select User" \
|
||||
--text="Choose the current user:" \
|
||||
--column "Steam Username" --print-column=1 \
|
||||
"${full_userlist[@]}")
|
||||
|
||||
if [[ ! -z $single_user ]]; then # Single user was selected
|
||||
unlink "$saves_folder"
|
||||
unlink "$states_folder"
|
||||
mkdir "$saves_folder"
|
||||
mkdir "$states_folder"
|
||||
cp -r "$multi_user_data_folder/$single_user/saves/." "$saves_folder"
|
||||
cp -r "$multi_user_data_folder/$single_user/states/." "$states_folder"
|
||||
set_setting_value $rd_conf "multi_user" "false" retrodeck
|
||||
configurator_process_complete_dialog "disabling multi-user support"
|
||||
else
|
||||
configurator_generic_dialog "No single user was selected, please try the process again."
|
||||
configurator_retrodeck_multiuser_dialog
|
||||
fi
|
||||
else
|
||||
configurator_developer_dialog
|
||||
fi
|
||||
else
|
||||
zenity --question \
|
||||
--no-wrap --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
|
||||
--title "RetroDECK Configurator - RetroDECK Multi-user support" \
|
||||
--text="Multi-user support is current disabled. Do you want to enable it?\n\nThe current users saves and states will be backed up and then moved to the \"retrodeck/multi-user-data\" folder.\nAdditional users will automatically be stored in their own folder here as they are added."
|
||||
|
||||
if [ $? == 0 ]
|
||||
then
|
||||
set_setting_value $rd_conf "multi_user" "true" retrodeck
|
||||
load_current_user_saves_and_states
|
||||
configurator_process_complete_dialog "enabling multi-user support"
|
||||
else
|
||||
configurator_retroarch_options_dialog
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
configurator_developer_dialog() {
|
||||
choice=$(zenity --list --title="RetroDECK Configurator Utility - Change Options" --cancel-label="Back" \
|
||||
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --width=1200 --height=720 \
|
||||
|
@ -813,7 +868,7 @@ configurator_developer_dialog() {
|
|||
case $choice in
|
||||
|
||||
"Change Multi-user mode" )
|
||||
echo "TODO: Multi-user mode menu"
|
||||
configurator_retrodeck_multiuser_dialog
|
||||
;;
|
||||
|
||||
"" ) # No selection made or Back button clicked
|
||||
|
|
Loading…
Reference in a new issue