2022-10-04 16:21:46 +00:00
#!/bin/bash
2022-10-07 17:46:48 +00:00
# VARIABLES SECTION
source /app/bin/global.sh # Grab global variables
source /app/libexec/functions.sh # Source global functions
# Config files for emulators with single config files
citraconf = "/var/config/citra-emu/qt-config.ini"
melondsconf = "/var/config/melonDS/melonDS.ini"
rpcs3conf = "/var/config/rpcs3/config.yml"
yuzuconf = "/var/config/yuzu/qt-config.ini"
2022-10-07 20:28:36 +00:00
source $rd_conf
2022-10-07 17:46:48 +00:00
2022-10-10 16:46:35 +00:00
# ES-DE config files
es_settings = "/var/config/emulationstation/.emulationstation/es_settings.xml"
# RetroArch config files
raconf = "/var/config/retroarch/retroarch.cfg"
ra_core_conf = "/var/config/retroarch/retroarch-core-options.cfg"
2022-10-07 17:46:48 +00:00
# Dolphin config files
dolphinconf = "/var/config/dolphin-emu/Dolphin.ini"
dolphingcpadconf = "/var/config/dolphin-emu/GCPadNew.ini"
dolphingfxconf = "/var/config/dolphin-emu/GFX.ini"
dolphinhkconf = "/var/config/dolphin-emu/Hotkeys.ini"
dolphinqtconf = "/var/config/dolphin-emu/Qt.ini"
# PCSX2 config files
pcsx2conf = "/var/config/PCSX2/inis/GS.ini"
pcsx2uiconf = "/var/config/PCSX2/inis/PCSX2_ui.ini"
pcsx2vmconf = "/var/config/PCSX2/inis/PCSX2_vm.ini"
# FUNCTION SECTION
browse( ) {
# Function for browsing directories, sets directory selected to variable $target for use in other functions
path_selected = false
while [ $path_selected = = false ]
do
target = " $( zenity --file-selection --title= " Choose target location to $action " --directory) "
echo " Path chosen: $target , answer= $? "
zenity --question --no-wrap --window-icon= "/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --title "RetroDECK" \
--cancel-label= "No" \
--ok-label "Yes" \
--text= " Your new directory will be:\n\n $target \n\nis that ok? "
if [ $? = = 0 ] #yes
then
path_selected = = true
break
else
zenity --question --no-wrap --window-icon= "/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --title "RetroDECK" --cancel-label= "No" --ok-label "Yes" --text= "Do you want to quit?"
if [ $? = = 0 ] # yes, quit
then
target =
exit 0
fi
fi
done
}
move( ) {
}
2022-10-07 20:28:36 +00:00
set_setting( ) {
2022-10-07 17:46:48 +00:00
# Function for editing settings
2022-10-07 20:28:36 +00:00
# USAGE: $(set_setting $setting_file $setting_name $new_setting_value $system) (needed as different systems use different config file syntax)
2022-10-07 17:46:48 +00:00
2022-10-07 20:28:36 +00:00
case $4 in
2022-10-07 17:46:48 +00:00
2022-10-07 20:28:36 +00:00
"retrodeck" )
2022-10-10 21:01:19 +00:00
sed -i " s% $2 =.*% $2 = $3 % " $1
; ;
2022-10-07 20:28:36 +00:00
"retroarch" )
2022-10-10 21:01:19 +00:00
sed -i " s% $2 = \".*\"% $2 = \" $3 \"% " $1
; ;
2022-10-07 17:46:48 +00:00
2022-10-07 20:28:36 +00:00
"dolphin" )
2022-10-10 21:01:19 +00:00
sed -i " s% $2 = .*% $2 = $3 % " $1
; ;
2022-10-07 17:46:48 +00:00
2022-10-07 20:28:36 +00:00
"duckstation" )
2022-10-10 21:01:19 +00:00
sed -i " s% $2 = .*% $2 = $3 % " $1
; ;
2022-10-07 17:46:48 +00:00
2022-10-07 20:28:36 +00:00
"pcsx2" )
2022-10-10 21:01:19 +00:00
sed -i " s% $2 = .*% $2 = $3 % " $1
; ;
2022-10-07 20:28:36 +00:00
"ppsspp" )
2022-10-10 21:01:19 +00:00
sed -i " s% $2 = .*% $2 = $3 % " $1
; ;
2022-10-07 20:28:36 +00:00
2022-10-10 21:01:19 +00:00
"rpcs3" ) # This does not currently work for settings with a $ in them
sed -i " s% $2 : .*% $2 : $3 % " $1
; ;
2022-10-07 20:28:36 +00:00
"yuzu" )
2022-10-10 21:01:19 +00:00
#sed -i "s%$2=.*%$2=$3%" $1
; ;
2022-10-07 17:46:48 +00:00
2022-10-07 20:28:36 +00:00
"citra" )
2022-10-10 21:01:19 +00:00
#sed -i "s%$2=.*%$2=$3%" $1
; ;
2022-10-07 17:46:48 +00:00
2022-10-07 20:28:36 +00:00
"melonds" )
2022-10-10 21:01:19 +00:00
sed -i " s% $2 =.*% $2 = $3 % " $1
; ;
2022-10-07 20:28:36 +00:00
"xemu" )
2022-10-10 21:01:19 +00:00
sed -i " s% $2 = .*% $2 = $3 % " $1
; ;
2022-10-07 20:28:36 +00:00
2022-10-10 16:46:35 +00:00
"emulationstation" )
2022-10-10 21:01:19 +00:00
sed -i " s% $2 \" \" value=\".*\"% $2 \" \" value=\" $3 \" " $1
; ;
2022-10-07 20:28:36 +00:00
esac
}
get_setting( ) {
# Function for getting the current value of a setting from a config file
# USAGE: $(get_setting $setting_file $setting_name $system) (needed as different systems use different config file syntax)
case $3 in
"retrodeck" )
2022-10-10 21:01:19 +00:00
echo $( grep " $2 " $1 | grep -o -P " (?<= $2 =).* " )
; ;
2022-10-10 16:46:35 +00:00
2022-10-07 20:28:36 +00:00
"retroarch" )
2022-10-10 21:01:19 +00:00
echo $( grep " $2 " $1 | grep -o -P " (?<= $2 = \").*(?=\") " )
; ;
2022-10-07 17:46:48 +00:00
2022-10-10 16:46:35 +00:00
"dolphin" ) # Use quotes when passing setting_name, as this config file contains special characters
2022-10-10 21:01:19 +00:00
echo $( grep " $2 " $1 | grep -o -P " (?<= $2 = ).* " )
; ;
2022-10-07 17:46:48 +00:00
"duckstation" )
2022-10-10 21:01:19 +00:00
echo $( grep " $2 " $1 | grep -o -P " (?<= $2 = ).* " )
; ;
2022-10-07 17:46:48 +00:00
"pcsx2" )
2022-10-10 21:01:19 +00:00
echo $( grep " $2 " $1 | grep -o -P " (?<= $2 = ).* " )
; ;
2022-10-07 17:46:48 +00:00
2022-10-10 21:01:19 +00:00
"ppsspp" ) # Use quotes when passing setting_name, as this config file contains spaces
echo $( grep " $2 " $1 | grep -o -P " (?<= $2 = ).* " )
; ;
2022-10-07 17:46:48 +00:00
2022-10-10 16:46:35 +00:00
"rpcs3" ) # Use quotes when passing setting_name, as this config file contains special characters and spaces
2022-10-10 21:01:19 +00:00
echo $( grep " $2 " $1 | grep -o -P " (?<= $2 : ).* " )
; ;
2022-10-07 17:46:48 +00:00
2022-10-10 16:46:35 +00:00
"yuzu" ) # Use quotes when passing setting_name, as this config file contains special characters
2022-10-10 21:01:19 +00:00
yuzu_setting = $( sed -e 's%\\%\\\\%g' <<< " $2 " ) # Accomodate for backslashes in setting names
echo $( grep " $yuzu_setting " $1 | grep -o -P " (?<= $yuzu_setting =).* " )
; ;
2022-10-10 16:46:35 +00:00
"citra" ) # Use quotes when passing setting_name, as this config file contains special characters
2022-10-10 21:01:19 +00:00
citra_setting = $( sed -e 's%\\%\\\\%g' <<< " $2 " ) # Accomodate for backslashes in setting names
echo $( grep " $citra_setting " $1 | grep -o -P " (?<= $citra_setting =).* " )
; ;
2022-10-07 17:46:48 +00:00
"melonds" )
2022-10-10 21:01:19 +00:00
echo $( grep " $2 " $1 | grep -o -P " (?<= $2 =).* " )
; ;
2022-10-07 17:46:48 +00:00
"xemu" )
2022-10-10 21:01:19 +00:00
echo $( grep " $2 " $1 | grep -o -P " (?<= $2 = ).* " )
; ;
2022-10-10 16:46:35 +00:00
"emulationstation" )
2022-10-10 21:01:19 +00:00
echo $( grep " $2 " $1 | grep -o -P " (?<= $2 \" value=\").*(?=\") " )
; ;
2022-10-07 17:46:48 +00:00
esac
}
# DIALOG SECTION
2022-10-04 16:21:46 +00:00
# Configurator Option Tree
# Welcome
# - Move Directories
2022-10-07 17:46:48 +00:00
# - Migrate ROM directory
# - Migrate downloaded_media
# - Migrate BIOS directory
# - Change Emulator Options
# - RetroArch
# - Change Rewind Setting
# - Add or Update Files
# - Add specific cores
# - Grab all missing cores
# - Update all cores to nightly
2022-10-04 16:21:46 +00:00
# - RetroAchivement login
2022-10-07 17:46:48 +00:00
# - Login prompt
2022-10-04 16:21:46 +00:00
# - Reset RetroDECK
2022-10-07 17:46:48 +00:00
# - Reset RetroArch
# - Reset Standalone Emulators
# - Reset Tools
# - Reset All
2022-10-04 16:21:46 +00:00
2022-10-07 17:46:48 +00:00
# Code for the menus should be put in reverse order, so functions for sub-menus exists before it is called by the parent menu
2022-10-04 16:21:46 +00:00
2022-10-07 17:46:48 +00:00
configurator_process_complete_dialog( ) {
zenity --icon-name= net.retrodeck.retrodeck --info --no-wrap \
--window-icon= "/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
--title "RetroDECK Configurator Utility - Process Complete" \
2022-10-10 21:01:19 +00:00
--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 return to RetroDECK. "
2022-10-07 17:46:48 +00:00
2022-10-10 21:01:19 +00:00
if [ $? = = 0 ] # OK button clicked
then
configurator_welcome_dialog
fi
2022-10-04 16:21:46 +00:00
}
2022-10-07 17:46:48 +00:00
configurator_progress_bar_dialog( ) {
2022-10-04 16:21:46 +00:00
}
2022-10-07 17:46:48 +00:00
configurator_reset_dialog( ) {
choice = $( zenity --list --title= "RetroDECK Configurator Utility - Reset Options" --cancel-label= "Back" \
--window-icon= "/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
--column= "Choice" --column= "Action" \
"Reset RetroArch" "Reset RetroArch to default settings" \
"Reset Standalones" "Reset standalone emulators to default settings" \
"Reset Tools" "Reset Tools menu entries" \
"Reset All" "Reset RetroDECK to default settings" )
2022-10-04 16:21:46 +00:00
2022-10-07 17:46:48 +00:00
case $choice in
"Reset RetroArch" )
ra_init
configurator_process_complete_dialog "resetting RetroArch"
; ;
"Reset Standalones" )
standalones_init
configurator_process_complete_dialog "resetting standalone emulators"
; ;
"Reset Tools" )
tools_init
configurator_process_complete_dialog "resetting the tools menu"
; ;
"Reset All" )
zenity --icon-name= net.retrodeck.retrodeck --info --no-wrap \
--window-icon= "/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
--title "RetroDECK Configurator Utility - Reset RetroDECK" \
--text= "You are resetting RetroDECK to its default state.\n\nAfter the process is complete you will need to exit RetroDECK and run it again."
rm -f " $lockfile "
configurator_process_complete_dialog "resetting RetroDECK"
; ;
"" ) # No selection made or Back button clicked
configurator_welcome_dialog
; ;
esac
}
configurator_retroachivement_dialog( ) {
login = $( zenity --forms --title= "RetroDECK Configurator Utility - RetroAchievements Login" --cancel-label= "Back" \
--window-icon= "/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
--text= "Enter your RetroAchievements Account details.\n\nBe aware that this tool cannot verify your login details.\nFor registration and more info visit\nhttps://retroachievements.org/\n" \
--separator= "=SEP=" \
--add-entry= "Username" \
--add-password= "Password" )
if [ $? = = 1 ] # Cancel button clicked
then
configurator_welcome_dialog
fi
arrIN = ( ${ login //=SEP=/ } )
user = ${ arrIN [0] }
pass = ${ arrIN [1] }
sed -i "s%cheevos_enable =.*%cheevos_enable = \"true\"%" $raconf
sed -i " s%cheevos_username =.*%cheevos_username = \" $user \"% " $raconf
sed -i " s%cheevos_password =.*%cheevos_password = \" $pass \"% " $raconf
2022-10-10 21:01:19 +00:00
configurator_process_complete_dialog "logging in to RetroAchievements"
2022-10-04 16:21:46 +00:00
}
configurator_update_dialog( ) {
}
2022-10-07 17:46:48 +00:00
configurator_power_user_changes_dialog( ) {
zenity --title "RetroDECK Configurator Utility - Power User Options" --question --no-wrap --cancel-label= "Back" \
--window-icon= "/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
--text= "Making manual changes to an emulators configuration may create serious issues,\nand some settings may be overwitten during RetroDECK updates.\n\nplease continue only if you know what you're doing.\n\nDo you want to continue?"
if [ $? = = 1 ] # Cancel button clicked
then
configurator_options_dialog
fi
emulator = " $( zenity --list \
--title "RetroDECK Configurator Utility - Power User Options" --cancel-label= "Back" \
--window-icon= "/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
--text= "Which emulator do you want to configure?" \
--hide-header \
--column= emulator \
"RetroArch" \
"Citra" \
"Dolphin" \
"Duckstation" \
"MelonDS" \
"PCSX2-QT" \
"PCSX2-Legacy" \
"PPSSPP" \
"RPCS3" \
"XEMU" \
"Yuzu" ) "
case $emulator in
"RetroArch" )
retroarch
; ;
"Citra" )
citra-qt
; ;
"Dolphin" )
dolphin-emu
; ;
"Duckstation" )
duckstation-qt
; ;
"MelonDS" )
melonDS
; ;
"PCSX2-QT" )
pcsx2-qt
; ;
"PCSX2-Legacy" )
pcsx2
; ;
"PPSSPP" )
PPSSPPSDL
; ;
"RPCS3" )
rpcs3
; ;
"XEMU" )
xemu
; ;
"Yuzu" )
yuzu
; ;
"" ) # No selection made or Back button clicked
configurator_options_dialog
; ;
2022-10-04 16:21:46 +00:00
2022-10-07 17:46:48 +00:00
esac
2022-10-04 16:21:46 +00:00
}
2022-10-07 20:28:36 +00:00
configurator_retroarch_rewind_dialog( ) {
if [ [ $( get_setting $raconf rewind_enable retroarch) = = "true" ] ] ; then
zenity --question \
--no-wrap --window-icon= "/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
--title "RetroDECK Configurator - Rewind" \
--text= "Rewind is currently enabled. Do you want to disable it?."
2022-10-07 17:46:48 +00:00
2022-10-07 20:28:36 +00:00
if [ $? = = 0 ]
then
set_setting $raconf rewind_enable true retroarch
2022-10-10 21:01:19 +00:00
configurator_process_complete_dialog "enabling Rewind"
2022-10-07 20:28:36 +00:00
else
configurator_options_dialog
fi
else
zenity --question \
--no-wrap --window-icon= "/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
--title "RetroDECK Configurator - Rewind" \
--text= "Rewind is currently disabled, do you want to enable it?\n\nNOTE:\nThis may impact performance expecially on the latest systems."
if [ $? = = 0 ]
then
set_setting $raconf rewind_enable false retroarch
2022-10-10 21:01:19 +00:00
configurator_process_complete_dialog "disabling Rewind"
2022-10-07 20:28:36 +00:00
else
configurator_options_dialog
fi
2022-10-07 17:46:48 +00:00
fi
}
2022-10-07 20:28:36 +00:00
configurator_retroarch_options_dialog( ) {
choice = $( zenity --list --title= "RetroDECK Configurator Utility - RetroArch Options" --cancel-label= "Back" \
--window-icon= "/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
--column= "Choice" --column= "Action" \
"Change Rewind Setting" "Enable or disable the Rewind function in RetroArch" )
case $choice in
"Change Rewind Setting" )
configurator_retroarch_rewind_dialog
; ;
"" ) # No selection made or Back button clicked
configurator_options_dialog
; ;
esac
}
2022-10-07 17:46:48 +00:00
configurator_options_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" \
--column= "Choice" --column= "Action" \
2022-10-07 20:28:36 +00:00
"Change RetroArch Settings" "Change settings specific to RetroArch" \
2022-10-07 17:46:48 +00:00
"Power User Changes" "Make changes directly in an emulator" )
case $choice in
2022-10-07 20:28:36 +00:00
"Change RetroArch Settings" )
configurator_retroarch_options_dialog
2022-10-07 17:46:48 +00:00
; ;
"Power User Changes" )
configurator_power_user_changes_dialog
; ;
"" ) # No selection made or Back button clicked
configurator_welcome_dialog
; ;
esac
}
2022-10-10 21:01:19 +00:00
configurator_move_dialog( ) {
choice = $( zenity --list --title= "RetroDECK Configurator Utility - Move Directories" --cancel-label= "Back" \
--window-icon= "/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
--column= "Choice" --column= "Action" \
"Move ROMs" "Move your ROMs directory to a new location" \
"Move BIOS" "Move your BIOS directory to a new location" \
"Move Downloaded Media" "Move your downloaded media directory to a new location" \
"Move Saves and States" "Move your save and state directories to a new location" )
case $choice in
"Move ROMs" )
; ;
"Move BIOS" )
; ;
"Move Downloaded Media" )
; ;
"Move Saves and States" )
; ;
"" ) # No selection made or Back button clicked
configurator_welcome_dialog
; ;
esac
2022-10-07 17:46:48 +00:00
}
configurator_welcome_dialog( ) {
# Clear the variables
2022-10-10 21:01:19 +00:00
source =
destination =
2022-10-07 17:46:48 +00:00
action =
2022-10-10 21:01:19 +00:00
setting =
2022-10-07 17:46:48 +00:00
setting_value =
choice = $( zenity --list --title= "RetroDECK Configurator Utility" --cancel-label= "Quit" \
--window-icon= "/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
--column= "Choice" --column= "Action" \
"Move Files" "Move files between internal/SD card or to custom locations" \
"Change Options" "Adjust how RetroDECK behaves" \
"Upgrade" "Upgrade parts of RetroDECK" \
"RetroAchivements" "Log in to RetroAchievements" \
"Reset" "Reset parts of RetroDECK" )
case $choice in
"Move Files" )
2022-10-10 21:01:19 +00:00
configurator_move_dialog
2022-10-07 17:46:48 +00:00
; ;
"Change Options" )
configurator_options_dialog
; ;
"Upgrade" )
configurator_update_dialog
; ;
"RetroAchivements" )
configurator_retroachivement_dialog
; ;
"Reset" )
configurator_reset_dialog
; ;
2022-10-10 21:01:19 +00:00
"" )
; ;
2022-10-07 17:46:48 +00:00
esac
}
# START THE CONFIGURATOR
2022-10-04 16:21:46 +00:00
2022-10-07 17:46:48 +00:00
configurator_welcome_dialog