diff --git a/source/ngc/filebrowser.cpp b/source/ngc/filebrowser.cpp index 56d884b..628c18d 100644 --- a/source/ngc/filebrowser.cpp +++ b/source/ngc/filebrowser.cpp @@ -36,6 +36,8 @@ extern "C" { #include "gcunzip.h" #include "wiiusbsupport.h" +void AutoLoad(int method); + BROWSERINFO browser; BROWSERENTRY * browserList = NULL; // list of files/folders in browser @@ -214,7 +216,7 @@ bool MakeFilePath(char filepath[], int type, int method, char * filename, int fi if(type == FILE_SRAM) sprintf(ext, "sav"); else sprintf(ext, "sgm"); - if(filenum >= 0) + if(filenum >= -1) { if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB) { @@ -223,7 +225,9 @@ bool MakeFilePath(char filepath[], int type, int method, char * filename, int fi } else { - if(filenum == 0) + if(filenum == -1) + sprintf(file, "%s.%s", filename, ext); + else if(filenum == 0) sprintf(file, "%s Auto.%s", filename, ext); else sprintf(file, "%s %i.%s", filename, filenum, ext); @@ -446,6 +450,8 @@ int BrowserLoadFile(int method) } else { + AutoLoad(method); // Load SRAM (battery backed RAM) or save state + ResetBrowser(); } CancelAction(); diff --git a/source/ngc/filebrowser.h b/source/ngc/filebrowser.h index 4d6f3d8..62835d3 100644 --- a/source/ngc/filebrowser.h +++ b/source/ngc/filebrowser.h @@ -43,7 +43,7 @@ extern bool ROMLoaded; extern char szpath[MAXPATHLEN]; extern bool inSz; -bool MakeFilePath(char filepath[], int type, int method, char * filename = NULL, int filenum = -1); +bool MakeFilePath(char filepath[], int type, int method, char * filename = NULL, int filenum = -2); int UpdateDirName(int method); int OpenGameList(); int autoLoadMethod(); diff --git a/source/ngc/menu.cpp b/source/ngc/menu.cpp index b035522..6be5ea3 100644 --- a/source/ngc/menu.cpp +++ b/source/ngc/menu.cpp @@ -534,6 +534,32 @@ void AutoSave() } } +/**************************************************************************** + * AutoLoad + * + * Automatically loads SRAM/snapshot when choosing a game from the menu + ***************************************************************************/ +void AutoLoad(int method) +{ + if (GCSettings.AutoLoad == 1) + { + LoadBatteryOrStateAuto(method, FILE_SRAM, SILENT); // save battery + } + else if (GCSettings.AutoLoad == 2) + { + if (WindowPrompt("Load", "Load Snapshot?", "Load", "Don't Load") ) + LoadBatteryOrStateAuto(method, FILE_SNAPSHOT, NOTSILENT); // save state + } + else if (GCSettings.AutoLoad == 3) + { + if (WindowPrompt("Load", "Load SRAM and Snapshot?", "Load", "Don't Load") ) + { + LoadBatteryOrStateAuto(method, FILE_SRAM, NOTSILENT); // save battery + LoadBatteryOrStateAuto(method, FILE_SNAPSHOT, NOTSILENT); // save state + } + } +} + /**************************************************************************** * OnScreenKeyboard * diff --git a/source/ngc/vbasupport.cpp b/source/ngc/vbasupport.cpp index a4b6642..9fcc598 100644 --- a/source/ngc/vbasupport.cpp +++ b/source/ngc/vbasupport.cpp @@ -320,7 +320,13 @@ bool LoadBatteryOrStateAuto(int method, int action, bool silent) if(!MakeFilePath(filepath, action, method, ROMFilename, 0)) return false; - return LoadBatteryOrState(filepath, method, action, silent); + if (action==FILE_SRAM) { + if (!LoadBatteryOrState(filepath, method, action, SILENT)) { + if(!MakeFilePath(filepath, action, method, ROMFilename, -1)) + return false; + return LoadBatteryOrState(filepath, method, action, silent); + } else return true; + } else return LoadBatteryOrState(filepath, method, action, silent); } /****************************************************************************