SaveStateCheck script
-
Updated to v1.10
This is a masive rewrite! And should work now with all versions of RetroPie.
You can now change style how the the stats are viewed!- via dialog windows
- just a text list (I prefer this one)
Hello fellows,
I created a small script that checks your ROMs SaveStates during gamestart and shows how much gamestates were saved for your launchend ROM. If there is at least one savestate an AUTO Savestate or a SRM-file a small blue box will tell you.
SRM files are the battery saves. I created this because sometimes I can't remember if I used some savegames. So this script will
- Shows you the number of GameStates saves
- Which GameSlot is used
- Is there is an ingame save (SRM)
You need the script add to
runcommand-onstart.sh
and parse parameters to it.- Save the code from box below to a place you like maybe
/home/pi/RetroPie/scripts/SaveStateCheck.sh
- Make the script executable with
chmod +x home/pi/RetroPie/scripts/SaveStateCheck.sh
- Enter
nano /opt/retropie/configs/all/runcommand-onstart.sh
- Enter line
/home/pi/RetroPie/scripts/SaveStateCheck.sh "$3" "$1" "light" "5"
4.1 $3 = rompath parsed by runcommand MANDATORY!
4.2 $1 = systemname (fba, gb...) parsed by runcommand you can also enterall
MANDATORY!
4.3 Choose between windows or light. This parameter can be left free then windows is default
4.4 This number is sleepcommand to show the infobox or text for x seconds. Can also left blank then 3 seconds are default - If there is no gamesave the box/test won't show up
# SaveStateCheck 1.1 (for status and SRM files data) # by cyperghost # # Parameter 1: RomPath parsed by RetroPie as $3 -- Mandatory! # Parameter 2: Is system name parsed by RetroPie as $1 or all -- Mandatory! # Parameter 3: How states are displayed. Choose between 'light' and 'window' (default) # Parameter 4: How long states are diplayed. Default is 3 seconds # # So for exp. ./SaveStateCheck.sh "$3" $1 window 5 or ./SaveStateCheck.sh "$3" all light 5 or ./SaveStateCheck.sh "$3" $1 # # Precheck if parameters are setted, if not we exit with error [ -z "$1" ] && echo "SaveState Check: Please parse rompath! Error!" >&2 && exit 1 [ -z "$2" ] && echo "SaveState Check: Please parse system parameter! Error!" >&2 && exit 1 rom="$1" system="$2" dialog="$3" pause="$4" [ -z "$3" ] && dialog="windows" [ -z "$4" ] && pause=3 rom_name="$(basename "$rom")" rom_path="$(dirname "$rom")" rom_no_ext="${rom_name%.*}" config_dir="/opt/retropie/configs/$system" config_file="$config_dir/retroarch.cfg" # This will determine path of SRM and STATUS directory # This is part of hiuilits Boilerplate script, with small modification # if '~' is detected then expand full homepath func_get_config() { config="$(grep -Po "(?<=^$1 = ).*" "$config_file")" config="${config%\"}" config="${config#\"}" [ "${config:0:1}" = "~" ] && config="${config#??}" && config=~/"$config" } # This will check extracted pathes and make them conform by removing last slash func_get_savepathes() { # GET SRM file location func_get_config "savefile_directory" [ -z "${config##*/}" ] && config="${config%?}" [ "${config:0:1}" = "/" ] && srm_path="$config" || srm_path="$rom_path" # GET STATE file location func_get_config "savestate_directory" [ -z "${config##*/}" ] && config="${config%?}" [ "${config:0:1}" = "/" ] && status_path="$config" || status_path="$rom_path" } func_get_savepathes # Get number of Statussavegames = Array size! # Build Array with search path of SaveStates # Get srm file with testcommand -f # Is Array valid? z=("$status_path/$rom_no_ext.state"*) [ "${z#*.state}" != "*" ] && status_array+=("${z[@]}") unset z idx=${#status_array[@]} #Get Array size # Build messages # Select if array entry contains '.auto' # Add SRM savestate to array if it is a valid file z=0 while [ $z -lt $idx ] do status_array[$z]="${status_array[$z]#*.state}" [ "${status_array[$z]}" != ".auto" ] && number=$(printf "%03d" ${status_array[$z]}) || number="ASv" status_array[$z]="\nGame Slot $number found" z=$((z+1)) done [ -f "$srm_path/$rom_no_ext.srm" ] && status_array+=("\nSRM Savestate found") # Check array, if it is zero then exit [ ${#status_array[@]} = 0 ] && exit # Better looking ROMnames rom_name="${rom_name%%[*}" rom_name="${rom_name%%(*}" # Building Screenoutput case "$dialog" in "window") dialog --title "SaveStateCheck" --infobox \ "Loaded ROM:\n$rom_name\n\nConsits of $idx SaveStates\n${status_array[*]}" 17 50 ;; "light") echo -e "$idx SaveStates found:\n-------------------${status_array[*]}" ;; esac # Show message for $pause seconds (default=3) sleep $pause
Greetings fly out to @meleu and @hiulit
This script can be optimized and is intendent to do so :DHave fun and happy gaming!
-
Just forget one picture says more than 1000 words
Example picture of starting screen with Kid Icarus for GameBoy
So you see. The game gets one SRM savefile and my forst Gameslot is not 0 it's the 1 ;)
So you see it's always good to know where are your savestats and which slot they use ;)Dialog Screen paresed by
window
parameterText list via
light
parameter parsed -
I wish this could be shown in ES as a metadata field
-
@lilbud Well this is also possible but needs to add some flags to the each
gamelists.xml
and then it needs to be featured in ES and in each theme. So it isn't a task that can be done alone and in a 4 hours coding-straight.Maybe it can be added in
runcommand.sh
itself if buzz decides to do so. The advantage is it would look much sleeker.Maybe @hiulit can do a rework - instead of a fun-fact screen it could be a savestat-fact screen ;) Who knows?
-
@cyperghost Or maybe instead of tying into the splashscreen or runcommand, maybe a OSD message can pop up while Retroarch starts that says how many save are available for said game.
Something like:
There are 3 save states for this game
-
@lilbud I see it more complex as ES is standalone and RetroArch is standalone. The creation of the
save.state*
-files is a task of RetroArch. I think it won't be a good idea to integrate ES much deeper into RetroArch.You loose flexibility and independence if you rely on settings that are made by programm X to work with programm Y.
See... in my script I tried to make the determination of the pathes 100% save in case if it's the default state. It doesn't matter if the default is written
deFault, DEFAULT, dEfAuLt... default
as I set it to uppercase and compare the string withDEFAULT
so it's always a match.But this was an easy task .... in this case!
All in all it's very difficult to make every case water-proof ;) -
Updated the script:
- now removes (...) and [...] in gamenames (a bit bare!)
- removed some typos
- if parameter for sleeptimer is missing, default timer will be set to 3 seconds
- rearanged the text itself a bit
Have fun!
Thanks for any feedback -
Old version for archive - Awful piece of script!
Very complicated in a try to avoid function calls!# SaveStateCheck (for status and SRM files data) # by cyperghost # # rom=$3, is first parameter # system=$1, is second parameter # Last parameter is sleeptimer in seconds # So for exp. ./savestate.sh $1 $3 5 or ./savestate.sh $1 all 3 # Precheck if parameters are setted, if not we exit with error [ -z "$2" ] && echo "SaveState Check: Please parse system parameter! Error!" >&2 && exit 1 [ -z "$1" ] && echo "SaveState Check: Please parse rompath! Error!" >&2 && exit 1 rom="$1" system="$2" rom_name="$(basename "$rom")" rom_path="$(dirname "$rom")" rom_no_ext="${rom_name%.*}" config_dir="/opt/retropie/configs/$system" config_file="$config_dir/retroarch.cfg" # This sniplet is part of hiulits Boilerplate script thank you! # This will determine path of SRM and STATUS directory func_get_config() { config="$(grep -Po "(?<=^$1 = ).*" "$config_file")" config="${config%\"}" config="${config#\"}" } # GET SRM file location func_get_config "savefile_directory" if [ "${config^^}" = "DEFAULT" ]; then srm_path="$rom_path" else srm_path="$config" fi # GET STATE file location func_get_config "savestate_directory" if [ "${config^^}" = "DEFAULT" ]; then status_path="$rom_path" else status_path="$config" fi # Determinine number of Statussavegames! # Build Array - last file could be state.auto status_array=("$status_path/$rom_no_ext.state"*) #Build Array idx=${#status_array[@]} #Get Array size # Check for presence of SRM file if [ -f "$srm_path/$rom_no_ext.srm" ]; then status_array[$idx]="\nSRM found! Use ingame saves!" srm=1 fi # Check for presence of state.auto by using latest index number if [ "${status_array[$idx-1]#*.state.}" = "auto" ]; then status_array[$idx-1]="\nGame Slot Autosave" idx=$(( $idx - 1 )) fi # Check if Array is valid [ "${status_array[$idx-1]#*.state}" = "*" ] && idx=-1 \ && [ $srm ] && status_array[0]="" # Is there something to display? # Means Array is not valid and there is no SRM then exit [ $idx -lt 0 ] && [ -z $srm ] && exit # Build messages # Remeber the idx number, if array is invalid there is nothing to convert # As -1 is less than 0 z=0 while [ $z -lt $idx ] do status_array[$z]=${status_array[$z]#*.state} number=$(printf "%03d" ${status_array[$z]}) #convert 1 >> 001 status_array[$z]="\nGame Slot $number found" z=$(( $z + 1 )) done # Better looking ROMnames rom_name="${rom_name%%[*}" rom_name="${rom_name%%(*}" # Building Dialog dialog --title "SaveStateCheck" --infobox \ "Loaded ROM:\n$rom_name\n\nConsits of $idx SaveStates\n${status_array[*]}" 0 0 sleep $3 [ -z "$3" ] && sleep 3
-
You should open a GitHub account and create repositories for your scripts there :D
-
@hiulit I have a github account ;)
Thanks for feedback
As I'm not a professional programmer I do coding just for fun. But my hope is that maybe you can improve this script.I saw your coding style...
And I think you do coding professional or have a strong attitude to this ;) -
@cyperghost Well, what are you waiting for then! Create repositories for all your scripts! :D
Actually I am a programmer, but I'm also a noob at shell scripting, so we are all noobs ;) -
@hiulit Here you are ;)
https://github.com/crcerror/
My best repo is the binary archive for old ES versions ;)
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.