Fixed bug (of new menu) with saves never loading and automatically being erased.

Now when you choose a game it looks for a save with "Auto" on the end to load, and if it doesn't find one, it looks for a save with nothing on the end and loads that instead.
This commit is contained in:
Carl.Kenner 2009-04-08 22:58:21 +00:00
parent 0fcc7edce5
commit 32fe744ae7
4 changed files with 42 additions and 4 deletions

View File

@ -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();

View File

@ -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();

View File

@ -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
*

View File

@ -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);
}
/****************************************************************************