2022-10-04 16:21:46 +00:00
#!/bin/bash
2022-10-07 17:46:48 +00:00
# VARIABLES SECTION
2023-03-08 18:35:24 +00:00
source /app/libexec/global.sh
source /app/libexec/functions.sh
2022-10-07 17:46:48 +00:00
# DIALOG SECTION
2022-10-04 16:21:46 +00:00
# Configurator Option Tree
# Welcome
2023-03-08 19:58:19 +00:00
# - Move RetroDECK
2023-03-08 18:35:24 +00:00
# - Change RetroArch Options
# - Enable/Disable Rewind Setting
# - RetroAchivement Login
# - Login prompt
# - Change Standalone Emulator Options (Behind one-time power user warning dialog)
# - Launch RetroArch
# - Launch Citra
# - Launch Dolphin
# - Launch Duckstation
# - Launch MelonDS
# - Launch PCSX2
# - Launch PPSSPP
# - Launch Primehack
# - Launch RPCS3
# - Launch XEMU
# - Launch Yuzu
2023-03-07 15:06:08 +00:00
# - Compress Games
2023-03-08 18:35:24 +00:00
# - Manual single-game selection
2023-03-07 15:06:08 +00:00
# - Troubleshooting Tools
# - Multi-file game check
# - Reset
2023-03-08 18:35:24 +00:00
# - Reset Specific Emulator
# - Reset RetroArch
2022-12-31 16:37:12 +00:00
# - Reset Citra
2022-10-12 20:06:17 +00:00
# - Reset Dolphin
2022-12-31 16:37:12 +00:00
# - Reset Duckstation
2022-10-12 20:06:17 +00:00
# - Reset MelonDS
2022-12-31 16:37:12 +00:00
# - Reset PCSX2
# - Reset PPSSPP
# - Reset Primehack
2022-10-12 20:06:17 +00:00
# - Reset RPCS3
2022-12-09 18:37:02 +00:00
# - Reset Ryujinx
2022-10-12 20:06:17 +00:00
# - Reset XEMU
2022-12-31 16:37:12 +00:00
# - Reset Yuzu
2023-03-08 18:35:24 +00:00
# - Reset All Emulators
2022-10-07 17:46:48 +00:00
# - 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-12 20:06:17 +00:00
# DIALOG TREE FUNCTIONS
2022-10-04 16:21:46 +00:00
2022-10-07 17:46:48 +00:00
configurator_reset_dialog( ) {
2022-10-26 16:51:46 +00:00
choice = $( zenity --list --title= "RetroDECK Configurator Utility - Reset Options" --cancel-label= "Back" \
2023-01-05 16:56:40 +00:00
--window-icon= "/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --width= 1200 --height= 720 \
2022-10-26 16:51:46 +00:00
--column= "Choice" --column= "Action" \
2023-03-08 18:35:24 +00:00
"Reset Specific Emulator" "Reset only one specific emulator to default settings" \
"Reset All Emulators" "Reset all emulators to default settings" \
2022-10-26 16:51:46 +00:00
"Reset Tools" "Reset Tools menu entries" \
"Reset All" "Reset RetroDECK to default settings" )
case $choice in
2023-03-08 18:35:24 +00:00
"Reset Specific Emulator" )
2022-10-26 16:51:46 +00:00
emulator_to_reset = $( zenity --list \
--title "RetroDECK Configurator Utility - Reset Specific Standalone Emulator" --cancel-label= "Back" \
2023-01-05 16:56:40 +00:00
--window-icon= "/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --width= 1200 --height= 720 \
2022-10-26 16:51:46 +00:00
--text= "Which emulator do you want to reset to default?" \
2023-03-08 18:35:24 +00:00
--column= "Emulator" --column= "Action" \
"RetroArch" "Reset RetroArch to default settings" \
"Citra" "Reset Citra to default settings" \
"Dolphin" "Reset Dolphin to default settings" \
"Duckstation" "Reset Duckstation to default settings" \
"MelonDS" "Reset MelonDS to default settings" \
"PCSX2" "Reset PCSX2 to default settings" \
"PPSSPP" "Reset PPSSPP to default settings" \
"Primehack" "Reset Primehack to default settings" \
"RPCS3" "Reset RPCS3 to default settings" \
"XEMU" "Reset XEMU to default settings" \
"Yuzu" "Reset Yuzu to default settings" )
2022-10-07 17:46:48 +00:00
2022-10-26 16:51:46 +00:00
case $emulator_to_reset in
2022-10-07 17:46:48 +00:00
2023-03-08 18:35:24 +00:00
"RetroArch" )
2023-03-12 18:21:30 +00:00
if [ [ check_network_connectivity = = "true" ] ] ; then
ra_init
configurator_process_complete_dialog " resetting $emulator_to_reset "
else
configurator_generic_dialog "You do not appear to be connected to a network with internet access.\n\nThe RetroArch reset process requires some files from the internet to function properly.\n\nPlease retry this process once a network connection is available."
configurator_reset_dialog
fi
2023-03-08 18:35:24 +00:00
; ;
2022-10-07 17:46:48 +00:00
"Citra" )
2022-11-19 20:47:49 +00:00
citra_init
2022-10-26 16:51:46 +00:00
configurator_process_complete_dialog " resetting $emulator_to_reset "
; ;
2022-10-12 20:06:17 +00:00
2022-10-07 17:46:48 +00:00
"Dolphin" )
2022-11-19 20:47:49 +00:00
dolphin_init
2022-10-26 16:51:46 +00:00
configurator_process_complete_dialog " resetting $emulator_to_reset "
; ;
2022-10-12 20:06:17 +00:00
2022-10-07 17:46:48 +00:00
"Duckstation" )
2022-11-19 20:47:49 +00:00
duckstation_init
2022-10-26 16:51:46 +00:00
configurator_process_complete_dialog " resetting $emulator_to_reset "
; ;
2022-10-12 20:06:17 +00:00
2022-10-07 17:46:48 +00:00
"MelonDS" )
2022-11-19 20:47:49 +00:00
melonds_init
2022-10-26 16:51:46 +00:00
configurator_process_complete_dialog " resetting $emulator_to_reset "
; ;
2022-10-12 20:06:17 +00:00
2022-10-26 16:51:46 +00:00
"PCSX2" )
2022-11-19 20:47:49 +00:00
pcsx2_init
2022-10-26 16:51:46 +00:00
configurator_process_complete_dialog " resetting $emulator_to_reset "
; ;
2022-10-12 20:06:17 +00:00
2022-10-07 17:46:48 +00:00
"PPSSPP" )
2022-11-19 20:47:49 +00:00
ppssppsdl_init
2022-10-26 16:51:46 +00:00
configurator_process_complete_dialog " resetting $emulator_to_reset "
; ;
2022-10-12 20:06:17 +00:00
2022-12-31 16:37:12 +00:00
"Primehack" )
primehack_init
configurator_process_complete_dialog " resetting $emulator_to_reset "
; ;
2022-12-09 18:37:02 +00:00
"RPCS3" )
rpcs3_init
2022-12-09 09:10:56 +00:00
configurator_process_complete_dialog " resetting $emulator_to_reset "
; ;
2022-10-07 17:46:48 +00:00
"XEMU" )
2023-03-12 18:21:30 +00:00
if [ [ check_network_connectivity = = "true" ] ] ; then
xemu_init
configurator_process_complete_dialog " resetting $emulator_to_reset "
else
configurator_generic_dialog "You do not appear to be connected to a network with internet access.\n\nThe Xemu reset process requires some files from the internet to function properly.\n\nPlease retry this process once a network connection is available."
configurator_reset_dialog
fi
2022-10-26 16:51:46 +00:00
; ;
2022-10-12 20:06:17 +00:00
2022-10-07 17:46:48 +00:00
"Yuzu" )
2022-11-19 20:47:49 +00:00
yuzu_init
2022-10-26 16:51:46 +00:00
configurator_process_complete_dialog " resetting $emulator_to_reset "
; ;
2022-10-12 20:06:17 +00:00
2022-10-07 17:46:48 +00:00
"" ) # No selection made or Back button clicked
2022-10-26 16:51:46 +00:00
configurator_reset_dialog
; ;
2022-10-04 16:21:46 +00:00
2022-10-07 17:46:48 +00:00
esac
2022-10-26 16:51:46 +00:00
; ;
2023-03-08 18:35:24 +00:00
"Reset All Emulators" )
2023-03-12 18:21:30 +00:00
if [ [ check_network_connectivity = = "true" ] ] ; then
ra_init
standalones_init
configurator_process_complete_dialog "resetting all emulators"
else
configurator_generic_dialog "You do not appear to be connected to a network with internet access.\n\nThe all-emulator reset process requires some files from the internet to function properly.\n\nPlease retry this process once a network connection is available."
configurator_reset_dialog
fi
2022-10-26 16:51:46 +00:00
; ;
"Reset Tools" )
2022-11-19 20:47:49 +00:00
tools_init
2022-10-26 16:51:46 +00:00
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" \
2023-03-08 18:35:24 +00:00
--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, where you will go through the initial setup process again."
2022-11-19 20:47:49 +00:00
rm -f " $lockfile "
2022-10-26 16:51:46 +00:00
configurator_process_complete_dialog "resetting RetroDECK"
; ;
"" ) # No selection made or Back button clicked
configurator_welcome_dialog
; ;
esac
}
configurator_retroachivement_dialog( ) {
2022-11-19 20:47:49 +00:00
login = $( zenity --forms --title= "RetroDECK Configurator Utility - RetroArch RetroAchievements Login" --cancel-label= "Back" \
2023-01-05 16:56:40 +00:00
--window-icon= "/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --width= 1200 --height= 720 \
2022-11-19 20:47:49 +00:00
--text= "Enter your RetroAchievements Account details.\n\nBe aware that this tool cannot verify your login details and currently only supports logging in with RetroArch.\nFor registration and more info visit\nhttps://retroachievements.org/\n" \
2022-10-26 16:51:46 +00:00
--separator= "=SEP=" \
--add-entry= "Username" \
--add-password= "Password" )
2022-11-22 03:07:53 +00:00
if [ $? = = 0 ] ; then # OK button clicked
arrIN = ( ${ login //=SEP=/ } )
user = ${ arrIN [0] }
pass = ${ arrIN [1] }
2022-10-26 16:51:46 +00:00
2022-11-22 03:07:53 +00:00
set_setting_value $raconf cheevos_enable true retroarch
set_setting_value $raconf cheevos_username $user retroarch
set_setting_value $raconf cheevos_password $pass retroarch
2022-10-26 16:51:46 +00:00
2022-11-22 03:07:53 +00:00
configurator_process_complete_dialog "logging in to RetroArch RetroAchievements"
else
configurator_welcome_dialog
fi
2022-10-26 16:51:46 +00:00
}
2023-03-08 18:35:24 +00:00
configurator_power_user_warning_dialog( ) {
2023-03-13 14:09:01 +00:00
if [ [ $power_user_warning = = "true" ] ] ; then
choice = $( zenity --icon-name= net.retrodeck.retrodeck --info --no-wrap --ok-label= "Yes" --extra-button= "No" --extra-button= "Never show this again" \
--window-icon= "/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
--title "RetroDECK Desktop Mode Warning" \
--text= "Making manual changes to an emulators configuration may create serious issues,\nand some settings may be overwitten during RetroDECK updates.\n\nSome standalone emulator functions may not work properly outside of Desktop mode.\n\nPlease continue only if you know what you're doing.\n\nDo you want to continue?" )
fi
rc = $? # Capture return code, as "Yes" button has no text value
if [ [ $rc = = "0" ] ] ; then # If user clicked "Yes"
configurator_power_user_changes_dialog
else # If any button other than "Yes" was clicked
if [ [ $choice = = "No" ] ] ; then
configurator_welcome_dialog
elif [ [ $choice = = "Never show this again" ] ] ; then
set_setting_value $rd_conf "power_user_warning" "false" retrodeck # Store desktop mode warning variable for future checks
configurator_power_user_changes_dialog
fi
2023-03-08 18:35:24 +00:00
fi
}
configurator_power_user_changes_dialog( ) {
2023-03-13 14:09:01 +00:00
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" --width= 1200 --height= 720 \
--text= "Which emulator do you want to configure?" \
--hide-header \
--column= emulator \
"RetroArch" \
"Citra" \
"Dolphin" \
"Duckstation" \
"MelonDS" \
"PCSX2" \
"PPSSPP" \
"Primehack" \
"RPCS3" \
"XEMU" \
"Yuzu" )
case $emulator in
"RetroArch" )
retroarch
; ;
2022-10-26 16:51:46 +00:00
2023-03-13 14:09:01 +00:00
"Citra" )
citra-qt
; ;
2022-10-26 16:51:46 +00:00
2023-03-13 14:09:01 +00:00
"Dolphin" )
dolphin-emu
; ;
2022-10-26 16:51:46 +00:00
2023-03-13 14:09:01 +00:00
"Duckstation" )
duckstation-qt
; ;
2022-10-26 16:51:46 +00:00
2023-03-13 14:09:01 +00:00
"MelonDS" )
melonDS
; ;
2022-10-26 16:51:46 +00:00
2023-03-13 14:09:01 +00:00
"PCSX2" )
pcsx2-qt
; ;
2022-10-26 16:51:46 +00:00
2023-03-13 14:09:01 +00:00
"PPSSPP" )
PPSSPPSDL
; ;
2022-10-26 16:51:46 +00:00
2023-03-13 14:09:01 +00:00
"Primehack" )
primehack-wrapper
; ;
2022-12-31 16:37:12 +00:00
2023-03-13 14:09:01 +00:00
"RPCS3" )
rpcs3
; ;
2022-10-26 16:51:46 +00:00
2023-03-13 14:09:01 +00:00
"XEMU" )
xemu
; ;
2022-10-26 16:51:46 +00:00
2023-03-13 14:09:01 +00:00
"Yuzu" )
yuzu
; ;
2022-10-26 16:51:46 +00:00
2023-03-13 14:09:01 +00:00
"" ) # No selection made or Back button clicked
configurator_welcome_dialog
; ;
2022-11-22 03:07:53 +00:00
2023-03-13 14:09:01 +00:00
esac
2022-10-04 16:21:46 +00:00
}
2022-10-07 20:28:36 +00:00
configurator_retroarch_rewind_dialog( ) {
2022-10-26 16:51:46 +00:00
if [ [ $( get_setting_value $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?."
if [ $? = = 0 ]
then
2022-11-22 03:07:53 +00:00
set_setting_value $raconf "rewind_enable" "false" retroarch
configurator_process_complete_dialog "disabling Rewind"
2022-10-07 20:28:36 +00:00
else
2023-03-08 18:35:24 +00:00
configurator_retroarch_options_dialog
2022-10-07 17:46:48 +00:00
fi
2022-10-26 16:51:46 +00:00
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
2022-11-22 03:07:53 +00:00
set_setting_value $raconf "rewind_enable" "true" retroarch
configurator_process_complete_dialog "enabling Rewind"
2022-10-26 16:51:46 +00:00
else
2023-03-08 18:35:24 +00:00
configurator_retroarch_options_dialog
2022-10-26 16:51:46 +00:00
fi
fi
2022-10-07 17:46:48 +00:00
}
2022-10-07 20:28:36 +00:00
configurator_retroarch_options_dialog( ) {
2022-10-26 16:51:46 +00:00
choice = $( zenity --list --title= "RetroDECK Configurator Utility - RetroArch Options" --cancel-label= "Back" \
2023-01-05 16:56:40 +00:00
--window-icon= "/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --width= 1200 --height= 720 \
2022-10-26 16:51:46 +00:00
--column= "Choice" --column= "Action" \
2023-03-08 18:35:24 +00:00
"Change Rewind Setting" "Enable or disable the Rewind function in RetroArch." \
"Log in to RetroAchivements" "Log into the RetroAchievements service in RetroArch." )
2022-10-07 20:28:36 +00:00
2022-10-26 16:51:46 +00:00
case $choice in
2022-10-07 20:28:36 +00:00
2022-10-26 16:51:46 +00:00
"Change Rewind Setting" )
configurator_retroarch_rewind_dialog
; ;
2022-10-07 20:28:36 +00:00
2023-03-08 18:35:24 +00:00
"Log in to RetroAchivements" )
configurator_retroachivement_dialog
2022-10-26 16:51:46 +00:00
; ;
2022-10-07 17:46:48 +00:00
2022-10-26 16:51:46 +00:00
"" ) # No selection made or Back button clicked
2023-03-08 18:35:24 +00:00
configurator_options_dialog
2022-10-26 16:51:46 +00:00
; ;
2022-10-12 20:06:17 +00:00
2022-10-26 16:51:46 +00:00
esac
2022-10-07 17:46:48 +00:00
}
2023-03-07 15:06:08 +00:00
configurator_compress_single_game_dialog( ) {
2023-03-15 21:19:04 +00:00
local file = $( file_browse "Game to compress" )
if [ [ ! -z " $file " ] ] ; then
if [ [ $( validate_for_chd " $file " ) = = "true" ] ] ; then
local post_compression_cleanup = $( configurator_compression_cleanup_dialog)
local filename_no_path = $( basename " $file " )
local filename_no_extension = " ${ filename_no_path %.* } "
local source_file = $( dirname " $( realpath " $file " ) " ) "/" $( basename " $file " )
local dest_file = $( dirname " $( realpath " $file " ) " ) "/" " $filename_no_extension "
2023-03-08 15:33:38 +00:00
(
2023-03-15 21:19:04 +00:00
echo " # Compressing $filename_no_path , please wait... "
compress_to_chd " $source_file " " $dest_file "
if [ [ $post_compression_cleanup = = "true" ] ] ; then # Remove file(s) if requested
if [ [ " $file " = = *".cue" ] ] ; then
local cue_bin_files = $( grep -o -P " (?<=FILE \").*(?=\".* $) " " $file " )
local file_path = $( dirname " $( realpath " $file " ) " )
while IFS = read -r line
do
echo " # Removing file $line "
rm -f " $file_path / $line "
done < <( printf '%s\n' " $cue_bin_files " )
echo " # Removing file $filename_no_path "
rm -f " $file "
else
echo " # Removing file $filename_no_path "
rm -f " $file "
fi
fi
2023-03-08 15:33:38 +00:00
) |
zenity --icon-name= net.retrodeck.retrodeck --progress --no-cancel --pulsate --auto-close \
2023-03-15 21:19:04 +00:00
--window-icon= "/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
--title "RetroDECK Configurator Utility - Compression in Progress"
configurator_generic_dialog "The compression process is complete!"
configurator_compress_games_dialog
2023-03-07 15:06:08 +00:00
else
configurator_generic_dialog "File type not recognized. Supported file types are .cue, .gdi and .iso"
2023-03-15 21:19:04 +00:00
configurator_compress_games_dialog
2023-03-07 15:06:08 +00:00
fi
else
configurator_generic_dialog "No file selected, returning to main menu"
configurator_welcome_dialog
fi
}
2023-03-14 19:43:28 +00:00
configurator_compress_multi_game_dialog( ) {
2023-03-15 21:19:04 +00:00
# This dialog will display any games it finds to be compressable, from the systems listed under each compression type in
2023-03-14 19:43:28 +00:00
local compression_format = $1
local compressable_game = ""
2023-03-15 21:19:04 +00:00
local compressable_games_list = ( )
2023-03-14 19:43:28 +00:00
local all_compressable_games = ( )
2023-03-15 21:19:04 +00:00
local compressable_systems_list = $( sed -n '/\[' " $compression_format " '\]/, /\[/{ /\[' " $compression_format " '\]/! { /\[/! p } }' $compression_targets | sed '/^$/d' )
2023-03-14 19:43:28 +00:00
while IFS = read -r system # Find and validate all games that are able to be compressed with this compression type
do
if [ [ $compression_format = = "chd" ] ] ; then
compression_candidates = $( find " $roms_folder / $system " -type f \( -name "*.cue" -o -name "*.iso" -o -name "*.gdi" \) ! -path "*.m3u*" )
2023-03-15 21:19:04 +00:00
# TODO: Add ZIP file compression search here
2023-03-14 19:43:28 +00:00
fi
while IFS = read -r game
do
2023-03-15 21:19:04 +00:00
if [ [ $( validate_for_chd " $game " ) = = "true" ] ] ; then
all_compressable_games = ( " ${ all_compressable_games [@] } " " $game " )
compressable_games_list = ( " ${ compressable_games_list [@] } " "false" " ${ game # $roms_folder } " " $game " )
fi
2023-03-14 19:43:28 +00:00
done < <( printf '%s\n' " $compression_candidates " )
done < <( printf '%s\n' " $compressable_systems_list " )
choice = $( zenity \
--list --width= 1200 --height= 720 \
--checklist --hide-column= 3 --ok-label= "Compress Selected" --extra-button= "Compress All" \
--separator= "," --print-column= 3 \
--text= "Choose which games to compress:" \
--column "Compress?" \
--column "Game" \
--column "Game Full Path" \
2023-03-15 21:19:04 +00:00
" ${ compressable_games_list [@] } " )
2023-03-14 19:43:28 +00:00
local rc = $?
if [ [ $rc = = "0" && ! -z $choice ] ] ; then # User clicked "Compress Selected" with at least one game selected
2023-03-15 21:19:04 +00:00
local post_compression_cleanup = $( configurator_compression_cleanup_dialog)
2023-03-14 19:43:28 +00:00
IFS = "," read -ra games_to_compress <<< " $choice "
2023-03-15 21:19:04 +00:00
(
for file in " ${ games_to_compress [@] } " ; do
local filename_no_path = $( basename " $file " )
local filename_no_extension = " ${ filename_no_path %.* } "
local source_file = $( dirname " $( realpath " $file " ) " ) "/" $( basename " $file " )
local dest_file = $( dirname " $( realpath " $file " ) " ) "/" " $filename_no_extension "
echo " # Compressing $filename_no_path " # Update Zenity dialog text
compress_to_chd " $source_file " " $dest_file "
if [ [ $post_compression_cleanup = = "true" ] ] ; then # Remove file(s) if requested
if [ [ " $file " = = *".cue" ] ] ; then
local cue_bin_files = $( grep -o -P " (?<=FILE \").*(?=\".* $) " " $file " )
local file_path = $( dirname " $( realpath " $file " ) " )
while IFS = read -r line
do
echo " # Removing file $line "
rm -f " $file_path / $line "
done < <( printf '%s\n' " $cue_bin_files " )
echo " # Removing file $filename_no_path "
rm -f $( realpath " $file " )
else
echo " # Removing file $filename_no_path "
rm -f " $( realpath " $file " ) "
fi
fi
2023-03-14 19:43:28 +00:00
done
2023-03-15 21:19:04 +00:00
) |
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 - Compression in Progress"
2023-03-14 19:43:28 +00:00
else
2023-03-15 21:19:04 +00:00
if [ [ ! -z $choice ] ] ; then # User clicked "Compress All"
local post_compression_cleanup = $( configurator_compression_cleanup_dialog)
(
for file in " ${ all_compressable_games [@] } " ; do
local filename_no_path = $( basename " $file " )
local filename_no_extension = " ${ filename_no_path %.* } "
local source_file = $( dirname " $( realpath " $file " ) " ) "/" $( basename " $file " )
local dest_file = $( dirname " $( realpath " $file " ) " ) "/" " $filename_no_extension "
echo " # Compressing $filename_no_path " # Update Zenity dialog text
compress_to_chd " $source_file " " $dest_file "
if [ [ $post_compression_cleanup = = "true" ] ] ; then # Remove file(s) if requested
if [ [ " $file " = = *".cue" ] ] ; then
local cue_bin_files = $( grep -o -P " (?<=FILE \").*(?=\".* $) " " $file " )
local file_path = $( dirname " $( realpath " $file " ) " )
while IFS = read -r line
do
echo " # Removing file $line "
rm -f " $file_path / $line "
done < <( printf '%s\n' " $cue_bin_files " )
echo " # Removing file $filename_no_path "
rm -f $( realpath " $file " )
else
echo " # Removing file $filename_no_path "
rm -f $( realpath " $file " )
fi
fi
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 - Compression in Progress"
configurator_generic_dialog "The compression process is complete!"
configurator_compress_games_dialog
2023-03-14 19:43:28 +00:00
else
2023-03-15 21:19:04 +00:00
configurator_compress_games_dialog
2023-03-14 19:43:28 +00:00
fi
fi
}
2023-03-15 21:19:04 +00:00
configurator_compression_cleanup_dialog( ) {
zenity --icon-name= net.retrodeck.retrodeck --question --no-wrap --cancel-label= "No" --ok-label= "Yes" \
--window-icon= "/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
--title "RetroDECK Compression Cleanup" \
--text= "Do you want to remove old files after they are compressed?\n\nClicking \"No\" will leave all files behind which will need to be cleaned up manually and may result in game duplicates showing in the RetroDECK library."
local rc = $? # Capture return code, as "Yes" button has no text value
if [ [ $rc = = "0" ] ] ; then # If user clicked "Yes"
echo "true"
else # If "No" was clicked
echo "false"
fi
}
2023-03-07 15:06:08 +00:00
configurator_compress_games_dialog( ) {
2023-03-15 21:19:04 +00:00
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 \
--column= "Choice" --column= "Action" \
"Compress Single Game" "Compress a single game into a compatible format" \
"Compress Multiple Games - CHD" "Compress one or more games compatible with the CHD format" )
case $choice in
"Compress Single Game" )
configurator_compress_single_game_dialog
; ;
"Compress Multiple Games - CHD" )
configurator_compress_multi_game_dialog "chd"
; ;
# TODO: Add ZIP compression option
2023-03-12 18:21:30 +00:00
2023-03-15 21:19:04 +00:00
"" ) # No selection made or Back button clicked
configurator_welcome_dialog
; ;
esac
2023-03-07 15:06:08 +00:00
}
2023-03-07 19:55:24 +00:00
configurator_check_multifile_game_structure( ) {
local folder_games = ( $( find $roms_folder -maxdepth 2 -mindepth 2 -type d ! -name "*.m3u" ! -name "*.ps3" ) )
if [ [ ${# folder_games [@] } -gt 1 ] ] ; then
echo " $( find $roms_folder -maxdepth 2 -mindepth 2 -type d ! -name "*.m3u" ! -name "*.ps3" ) " > $logs_folder /multi_file_games_" $( date +"%Y_%m_%d_%I_%M_%p" ) .log "
zenity --icon-name= net.retrodeck.retrodeck --info --no-wrap \
--window-icon= "/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
--title "RetroDECK" \
--text= " The following games were found to have the incorrect folder structure:\n\n $( find $roms_folder -maxdepth 2 -mindepth 2 -type d ! -name "*.m3u" ! -name "*.ps3" ) \n\nIncorrect folder structure can result in failure to launch games or saves being in the incorrect location.\n\nPlease see the RetroDECK wiki for more details!\n\nYou can find this list of games in ~/retrodeck/.logs "
else
configurator_generic_dialog "No incorrect multi-file game folder structures found."
fi
configurator_troubleshooting_tools_dialog
}
2023-03-13 01:40:01 +00:00
configurator_check_bios_files_basic( ) {
2023-03-13 15:12:10 +00:00
configurator_generic_dialog "This check will look for BIOS files that RetroDECK has identified as working.\n\nThere may be additional BIOS files that will function with the emulators that are not checked.\n\nSome more advanced emulators such as Yuzu will have additional methods for verifiying the BIOS files are in working order."
2023-03-13 01:40:01 +00:00
bios_checked_list = ( )
2023-03-13 15:12:10 +00:00
while IFS = "^" read -r bios_file bios_subdir bios_hash bios_system bios_desc
2023-03-13 01:40:01 +00:00
do
bios_file_found = "No"
bios_hash_matched = "No"
2023-03-13 15:12:10 +00:00
if [ [ -f " $bios_dir / $bios_subdir $bios_file " ] ] ; then
2023-03-13 01:40:01 +00:00
bios_file_found = "Yes"
2023-03-13 15:12:10 +00:00
if [ [ $bios_hash = = "Unknown" ] ] ; then
bios_hash_matched = "Unknown"
elif [ [ $( md5sum " $bios_dir / $bios_subdir $bios_file " | awk '{ print $1 }' ) = = " $bios_hash " ] ] ; then
2023-03-13 01:40:01 +00:00
bios_hash_matched = "Yes"
fi
fi
2023-03-13 15:12:10 +00:00
if [ [ $bios_file_found = = "Yes" && ( $bios_hash_matched = = "Yes" || $bios_hash_matched = = "Unknown" ) && ! " ${ bios_checked_list [*] } " = ~ " ${ bios_system } " ] ] ; then
2023-03-13 01:40:01 +00:00
bios_checked_list = ( " ${ bios_checked_list [@] } " " $bios_system " )
fi
done < $bios_checklist
systems_with_bios = ${ bios_checked_list [@] }
configurator_generic_dialog " The following systems have been found to have at least one valid BIOS file.\n\n $systems_with_bios \n\nFor more information on the BIOS files found please use the Advanced check tool. "
configurator_troubleshooting_tools_dialog
}
configurator_check_bios_files_advanced( ) {
2023-03-13 15:12:10 +00:00
configurator_generic_dialog "This check will look for BIOS files that RetroDECK has identified as working.\n\nThere may be additional BIOS files that will function with the emulators that are not checked.\n\nSome more advanced emulators such as Yuzu will have additional methods for verifiying the BIOS files are in working order."
2023-03-08 22:08:57 +00:00
bios_checked_list = ( )
2023-03-13 15:12:10 +00:00
while IFS = "^" read -r bios_file bios_subdir bios_hash bios_system bios_desc
2023-03-08 22:08:57 +00:00
do
bios_file_found = "No"
bios_hash_matched = "No"
2023-03-13 15:12:10 +00:00
if [ [ -f " $bios_dir / $bios_subdir $bios_file " ] ] ; then
2023-03-08 22:08:57 +00:00
bios_file_found = "Yes"
2023-03-13 15:12:10 +00:00
if [ [ $bios_hash = = "Unknown" ] ] ; then
bios_hash_matched = "Unknown"
elif [ [ $( md5sum " $bios_dir / $bios_subdir $bios_file " | awk '{ print $1 }' ) = = " $bios_hash " ] ] ; then
2023-03-08 22:08:57 +00:00
bios_hash_matched = "Yes"
fi
fi
bios_checked_list = ( " ${ bios_checked_list [@] } " " $bios_file " " $bios_system " " $bios_file_found " " $bios_hash_matched " " $bios_desc " )
done < $bios_checklist
zenity --list --title= "RetroDECK Configurator Utility - Verify BIOS Files" --cancel-label= "Back" \
--window-icon= "/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --width= 1200 --height= 720 \
--column "BIOS File Name" \
--column "System" \
--column "BIOS File Found" \
--column "BIOS Hash Match" \
--column "BIOS File Description" \
" ${ bios_checked_list [@] } "
configurator_troubleshooting_tools_dialog
}
2023-03-07 15:06:08 +00:00
configurator_troubleshooting_tools_dialog( ) {
2023-03-07 19:55:24 +00:00
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 \
--column= "Choice" --column= "Action" \
2023-03-08 22:08:57 +00:00
"Multi-file game structure check" "Verify the proper structure of multi-file or multi-disc games" \
2023-03-13 01:40:01 +00:00
"Basic BIOS file check" "Show a list of systems that BIOS files are found for" \
"Advanced BIOS file check" "Show advanced information about common BIOS files" )
2023-03-07 15:06:08 +00:00
2023-03-07 19:55:24 +00:00
case $choice in
2023-03-07 15:06:08 +00:00
2023-03-07 19:55:24 +00:00
"Multi-file game structure check" )
configurator_check_multifile_game_structure
; ;
2023-03-13 01:40:01 +00:00
"Basic BIOS file check" )
configurator_check_bios_files_basic
; ;
"Advanced BIOS file check" )
configurator_check_bios_files_advanced
2023-03-08 22:08:57 +00:00
; ;
2023-03-07 19:55:24 +00:00
"" ) # No selection made or Back button clicked
configurator_welcome_dialog
; ;
esac
2023-03-07 15:06:08 +00:00
}
2022-10-10 21:01:19 +00:00
configurator_move_dialog( ) {
2022-10-26 16:59:36 +00:00
if [ [ -d $rdhome ] ] ; then
destination = $( configurator_destination_choice_dialog "RetroDECK Data" "Please choose a destination for the RetroDECK data folder." )
case $destination in
2022-11-20 21:09:13 +00:00
2022-10-26 16:59:36 +00:00
"Back" )
2022-10-26 16:51:46 +00:00
configurator_move_dialog
2022-10-26 16:59:36 +00:00
; ;
2022-11-20 21:09:13 +00:00
2022-10-26 16:59:36 +00:00
"Internal Storage" )
2022-11-20 21:09:13 +00:00
if [ [ ! -L " $HOME /retrodeck " && -d " $HOME /retrodeck " ] ] ; then
2022-10-26 16:59:36 +00:00
configurator_generic_dialog "The RetroDECK data folder is already at that location, please pick a new one."
2022-10-26 16:51:46 +00:00
configurator_move_dialog
2022-10-26 16:59:36 +00:00
else
configurator_generic_dialog " Moving RetroDECK data folder to $destination "
2022-11-20 21:09:13 +00:00
unlink $HOME /retrodeck # Remove symlink for $rdhome
move $rdhome " $HOME "
if [ [ ! -d $rdhome && -d $HOME /retrodeck ] ] ; then # If the move succeeded
rdhome = " $HOME /retrodeck "
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 "
2022-11-21 01:05:11 +00:00
emulators_post_move
2022-11-20 21:09:13 +00:00
conf_write
configurator_process_complete_dialog "moving the RetroDECK data directory to internal storage"
else
configurator_generic_dialog "The moving process was not completed, please try again."
fi
2022-10-26 16:59:36 +00:00
fi
; ;
2022-11-20 21:09:13 +00:00
2022-10-26 16:59:36 +00:00
"SD Card" )
2022-11-21 19:02:19 +00:00
if [ [ -L " $HOME /retrodeck " && -d " $sdcard /retrodeck " && " $rdhome " = = " $sdcard /retrodeck " ] ] ; then
2022-11-21 01:05:11 +00:00
configurator_generic_dialog "The RetroDECK data folder is already configured to that location, please pick a new one."
2022-10-26 16:51:46 +00:00
configurator_move_dialog
2022-10-26 16:59:36 +00:00
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."
configurator_welcome_dialog
2022-10-26 16:51:46 +00:00
else
2023-01-19 16:50:23 +00:00
if [ [ $( verify_space $rdhome $sdcard ) = = "true" ] ] ; then
2022-11-20 21:09:13 +00:00
configurator_generic_dialog " Moving RetroDECK data folder to $destination "
2022-11-21 01:05:11 +00:00
if [ [ -L " $HOME /retrodeck/roms " ] ] ; then # Check for ROMs symlink user may have created
unlink " $HOME /retrodeck/roms "
2022-11-20 21:09:13 +00:00
fi
2023-01-05 16:56:40 +00:00
unlink $HOME /retrodeck # Remove symlink for $rdhome
2022-11-20 21:09:13 +00:00
(
2022-11-21 01:05:11 +00:00
dir_prep " $sdcard /retrodeck " " $rdhome "
2022-11-20 21:09:13 +00:00
) |
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 - Move in Progress" \
--text= " Moving directory $rdhome to new location of $sdcard /retrodeck, please wait. "
2022-11-21 19:02:19 +00:00
if [ [ -L $rdhome && ! $rdhome = = " $HOME /retrodeck " ] ] ; then # Clean up extraneus symlinks from previous moves
unlink $rdhome
fi
if [ [ ! -L " $HOME /retrodeck " ] ] ; then # Always link back to original directory
2022-12-31 15:29:13 +00:00
ln -svf " $sdcard /retrodeck " " $HOME "
2022-11-21 19:02:19 +00:00
fi
2022-11-20 21:09:13 +00:00
rdhome = " $sdcard /retrodeck "
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 "
2022-11-21 01:05:11 +00:00
emulators_post_move
2022-11-20 21:09:13 +00:00
conf_write
configurator_process_complete_dialog "moving the RetroDECK data directory to SD card"
else
zenity --icon-name= net.retrodeck.retrodeck --error --no-wrap \
--window-icon= "/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
--title "RetroDECK Configurator Utility - Move Directories" \
--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
fi
; ;
"Custom Location" )
configurator_generic_dialog "Select the root folder you would like to store the RetroDECK data folder in.\n\nA new folder \"retrodeck\" will be created in the destination chosen."
2023-03-07 15:06:08 +00:00
custom_dest = $( directory_browse "RetroDECK directory location" )
2022-11-20 21:09:13 +00:00
if [ [ ! -w $custom_dest ] ] ; then
2023-01-10 16:42:55 +00:00
configurator_generic_dialog "The destination was found but is not writable\n\nThis can happen if RetroDECK does not have permission to write to this location.\n\nThis can typically be solved through the utility Flatseal, please make the needed changes and try the moving process again."
2022-11-20 21:09:13 +00:00
configurator_welcome_dialog
else
if [ [ $( verify_space $rdhome $custom_dest ) ] ] ; then
configurator_generic_dialog " Moving RetroDECK data folder to $custom_dest /retrodeck "
2022-10-26 16:59:36 +00:00
if [ [ -L $rdhome /roms ] ] ; then # Check for ROMs symlink user may have created
2022-11-20 21:09:13 +00:00
unlink $rdhome /roms
2022-10-26 16:59:36 +00:00
fi
2023-01-10 16:41:09 +00:00
2023-01-05 16:56:40 +00:00
unlink $HOME /retrodeck # Remove symlink for $rdhome if the previous location was not internal
2022-11-20 21:09:13 +00:00
(
2022-11-21 01:05:11 +00:00
dir_prep " $custom_dest /retrodeck " " $rdhome "
2022-11-20 21:09:13 +00:00
) |
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 - Move in Progress" \
--text= " Moving directory $rdhome to new location of $custom_dest /retrodeck, please wait. "
2022-11-21 19:02:19 +00:00
if [ [ ! -L " $HOME /retrodeck " ] ] ; then
2022-12-31 15:29:13 +00:00
ln -svf " $custom_dest /retrodeck " " $HOME "
2022-11-21 19:02:19 +00:00
fi
2023-01-10 16:41:09 +00:00
if [ [ -L $rdhome && ! $rdhome = = " $HOME /retrodeck " ] ] ; then # Clean up extraneus symlinks from previous moves
unlink $rdhome
fi
2022-11-20 21:09:13 +00:00
rdhome = " $custom_dest /retrodeck "
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 "
2022-11-21 01:05:11 +00:00
emulators_post_move
2022-11-19 20:47:49 +00:00
conf_write
2022-10-26 16:59:36 +00:00
configurator_process_complete_dialog "moving the RetroDECK data directory to SD card"
2022-11-20 21:09:13 +00:00
else
zenity --icon-name= net.retrodeck.retrodeck --error --no-wrap \
--window-icon= "/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
--title "RetroDECK Configurator Utility - Move Directories" \
--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."
2022-10-26 16:51:46 +00:00
fi
2022-10-26 16:59:36 +00:00
fi
; ;
2022-10-10 21:01:19 +00:00
2022-10-26 16:59:36 +00:00
esac
else
configurator_generic_dialog "The RetroDECK data 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 RetroDECK data folder."
2023-03-07 15:06:08 +00:00
rdhome = $( directory_browse "RetroDECK directory location" )
2022-11-20 21:09:13 +00:00
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 "
emulator_post_move
2022-11-19 20:47:49 +00:00
conf_write
2022-10-26 16:59:36 +00:00
configurator_generic_dialog " RetroDECK data folder now configured at $rdhome . Please start the moving process again. "
configurator_move_dialog
fi
2022-10-07 17:46:48 +00:00
}
configurator_welcome_dialog( ) {
2022-10-26 16:51:46 +00:00
# Clear the variables
destination =
choice = $( zenity --list --title= "RetroDECK Configurator Utility" --cancel-label= "Quit" \
2023-01-05 16:56:40 +00:00
--window-icon= "/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --width= 1200 --height= 720 \
2022-10-26 16:51:46 +00:00
--column= "Choice" --column= "Action" \
2023-03-08 18:35:24 +00:00
"Move Files" "Move files between internal/SD card or to custom locations." \
"Change RetroArch Options" "Change RetroArch presets, log into RetroAchievements etc." \
"Change Standalone Emulator Options" "Run emulators standalone to make advanced config changes." \
"Compress Games" "Compress games to CHD format for systems that support it." \
"Troubleshooting Tools" "Run RetroDECK troubleshooting tools for common issues." \
"Reset" "Reset specific parts or all of RetroDECK." )
2022-10-26 16:51:46 +00:00
case $choice in
"Move Files" )
2022-11-21 01:05:11 +00:00
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."
2022-10-26 16:51:46 +00:00
configurator_move_dialog
; ;
2023-03-08 18:35:24 +00:00
"Change RetroArch Options" )
configurator_retroarch_options_dialog
2022-10-26 16:51:46 +00:00
; ;
2023-03-08 18:35:24 +00:00
"Change Standalone Emulator Options" )
2023-03-13 14:09:01 +00:00
configurator_power_user_warning_dialog
2022-10-26 16:51:46 +00:00
; ;
2023-03-07 15:06:08 +00:00
"Compress Games" )
configurator_compress_games_dialog
; ;
"Troubleshooting Tools" )
configurator_troubleshooting_tools_dialog
; ;
2022-10-26 16:51:46 +00:00
"Reset" )
configurator_reset_dialog
; ;
esac
2022-10-07 17:46:48 +00:00
}
# START THE CONFIGURATOR
2022-10-04 16:21:46 +00:00
2022-10-07 17:46:48 +00:00
configurator_welcome_dialog