mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 05:19:56 +00:00
Added "oldest save" and "slots 1-5" as options for "auto load savestate"
This commit is contained in:
parent
28e3152fdc
commit
7fd7afeba9
@ -398,7 +398,7 @@ static ConfigSetting generalSettings[] = {
|
||||
ConfigSetting("ForceLagSync", &g_Config.bForceLagSync, false, true, true),
|
||||
|
||||
ReportedConfigSetting("NumWorkerThreads", &g_Config.iNumWorkerThreads, &DefaultNumWorkers, true, true),
|
||||
ConfigSetting("EnableAutoLoad", &g_Config.bEnableAutoLoad, false, true, true),
|
||||
ConfigSetting("AutoLoadSaveState", &g_Config.iAutoLoadSaveState, 0, true, true),
|
||||
ReportedConfigSetting("EnableCheats", &g_Config.bEnableCheats, false, true, true),
|
||||
ConfigSetting("CwCheatRefreshRate", &g_Config.iCwCheatRefreshRate, 77, true, true),
|
||||
|
||||
|
@ -175,7 +175,7 @@ public:
|
||||
int iCurrentStateSlot;
|
||||
int iRewindFlipFrequency;
|
||||
bool bEnableStateUndo;
|
||||
bool bEnableAutoLoad;
|
||||
int iAutoLoadSaveState; // 0 = off, 1 = oldest, 2 = newest, >2 = slot number + 3
|
||||
bool bEnableCheats;
|
||||
bool bReloadCheats;
|
||||
int iCwCheatRefreshRate;
|
||||
|
@ -71,3 +71,9 @@ enum class SmallDisplayZoom {
|
||||
AUTO = 2,
|
||||
MANUAL = 3,
|
||||
};
|
||||
|
||||
enum AutoLoadSaveState {
|
||||
OFF = 0,
|
||||
OLDEST = 1,
|
||||
NEWEST = 2,
|
||||
};
|
||||
|
@ -550,6 +550,27 @@ namespace SaveState
|
||||
return false;
|
||||
}
|
||||
|
||||
bool operator > (const tm &t1, const tm &t2) {
|
||||
if (t1.tm_year > t2.tm_year) return true;
|
||||
if (t1.tm_year < t2.tm_year) return false;
|
||||
if (t1.tm_mon > t2.tm_mon) return true;
|
||||
if (t1.tm_mon < t2.tm_mon) return false;
|
||||
if (t1.tm_mday > t2.tm_mday) return true;
|
||||
if (t1.tm_mday < t2.tm_mday) return false;
|
||||
if (t1.tm_hour > t2.tm_hour) return true;
|
||||
if (t1.tm_hour < t2.tm_hour) return false;
|
||||
if (t1.tm_min > t2.tm_min) return true;
|
||||
if (t1.tm_min < t2.tm_min) return false;
|
||||
if (t1.tm_sec > t2.tm_sec) return true;
|
||||
if (t1.tm_sec < t2.tm_sec) return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool operator ! (const tm &t1) {
|
||||
if (t1.tm_year || t1.tm_mon || t1.tm_mday || t1.tm_hour || t1.tm_min || t1.tm_sec) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
int GetNewestSlot(const std::string &gameFilename) {
|
||||
int newestSlot = -1;
|
||||
tm newestDate = {0};
|
||||
@ -567,6 +588,23 @@ namespace SaveState
|
||||
return newestSlot;
|
||||
}
|
||||
|
||||
int GetOldestSlot(const std::string &gameFilename) {
|
||||
int oldestSlot = -1;
|
||||
tm oldestDate = {0};
|
||||
for (int i = 0; i < NUM_SLOTS; i++) {
|
||||
std::string fn = GenerateSaveSlotFilename(gameFilename, i, STATE_EXTENSION);
|
||||
if (File::Exists(fn)) {
|
||||
tm time;
|
||||
bool success = File::GetModifTime(fn, time);
|
||||
if (success && (!oldestDate || oldestDate > time)) {
|
||||
oldestDate = time;
|
||||
oldestSlot = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return oldestSlot;
|
||||
}
|
||||
|
||||
std::string GetSlotDateAsString(const std::string &gameFilename, int slot) {
|
||||
std::string fn = GenerateSaveSlotFilename(gameFilename, slot, STATE_EXTENSION);
|
||||
if (File::Exists(fn)) {
|
||||
|
@ -51,9 +51,10 @@ namespace SaveState
|
||||
|
||||
int GetCurrentSlot();
|
||||
|
||||
// Returns -1 if there's no newest slot.
|
||||
// Returns -1 if there's no oldest/newest slot.
|
||||
int GetNewestSlot(const std::string &gameFilename);
|
||||
|
||||
int GetOldestSlot(const std::string &gameFilename);
|
||||
|
||||
std::string GetSlotDateAsString(const std::string &gameFilename, int slot);
|
||||
std::string GenerateSaveSlotFilename(const std::string &gameFilename, int slot, const char *extension);
|
||||
|
||||
|
@ -1337,11 +1337,26 @@ void EmuScreen::renderUI() {
|
||||
}
|
||||
|
||||
void EmuScreen::autoLoad() {
|
||||
int autoSlot = -1;
|
||||
|
||||
//check if save state has save, if so, load
|
||||
int lastSlot = SaveState::GetNewestSlot(gamePath_);
|
||||
if (g_Config.bEnableAutoLoad && lastSlot != -1) {
|
||||
SaveState::LoadSlot(gamePath_, lastSlot, &AfterSaveStateAction);
|
||||
g_Config.iCurrentStateSlot = lastSlot;
|
||||
switch (g_Config.iAutoLoadSaveState) {
|
||||
case AutoLoadSaveState::OFF: // "AutoLoad Off"
|
||||
return;
|
||||
case AutoLoadSaveState::OLDEST: // "Oldest Save"
|
||||
autoSlot = SaveState::GetOldestSlot(gamePath_);
|
||||
break;
|
||||
case AutoLoadSaveState::NEWEST: // "Newest Save"
|
||||
autoSlot = SaveState::GetNewestSlot(gamePath_);
|
||||
break;
|
||||
default: // try the specific save state slot specified
|
||||
autoSlot = (SaveState::HasSaveInSlot(gamePath_, g_Config.iAutoLoadSaveState - 3)) ? (g_Config.iAutoLoadSaveState - 3) : -1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (g_Config.iAutoLoadSaveState && autoSlot != -1) {
|
||||
SaveState::LoadSlot(gamePath_, autoSlot, &AfterSaveStateAction);
|
||||
g_Config.iCurrentStateSlot = autoSlot;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -734,8 +734,8 @@ void GameSettingsScreen::CreateViews() {
|
||||
|
||||
systemSettings->Add(new Choice(sy->T("Restore Default Settings")))->OnClick.Handle(this, &GameSettingsScreen::OnRestoreDefaultSettings);
|
||||
systemSettings->Add(new CheckBox(&g_Config.bEnableStateUndo, sy->T("Savestate slot backups")));
|
||||
systemSettings->Add(new CheckBox(&g_Config.bEnableAutoLoad, sy->T("Auto Load Newest Savestate")));
|
||||
|
||||
static const char *autoLoadSaveStateChoices[] = { "Off", "Oldest Save", "Newest Save", "Slot 1", "Slot 2", "Slot 3", "Slot 4", "Slot 5" };
|
||||
systemSettings->Add(new PopupMultiChoice(&g_Config.iAutoLoadSaveState, sy->T("Auto Load Savestate"), autoLoadSaveStateChoices, 0, ARRAY_SIZE(autoLoadSaveStateChoices), sy->GetName(), screenManager()));
|
||||
#if defined(USING_WIN_UI)
|
||||
systemSettings->Add(new CheckBox(&g_Config.bBypassOSKWithKeyboard, sy->T("Enable Windows native keyboard", "Enable Windows native keyboard")));
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user