2016-08-31 20:54:38 -04:00
|
|
|
#include "stdafx.h"
|
|
|
|
#include "AutoSaveManager.h"
|
|
|
|
#include "Console.h"
|
|
|
|
#include "EmulationSettings.h"
|
|
|
|
#include "SaveStateManager.h"
|
|
|
|
|
2018-07-01 15:21:05 -04:00
|
|
|
AutoSaveManager::AutoSaveManager(shared_ptr<Console> console)
|
2016-08-31 20:54:38 -04:00
|
|
|
{
|
|
|
|
_stopThread = false;
|
|
|
|
_timer.Reset();
|
|
|
|
_autoSaveThread = std::thread([=]() {
|
|
|
|
while(!_stopThread) {
|
|
|
|
bool showMessage = false;
|
|
|
|
uint32_t autoSaveDelay = EmulationSettings::GetAutoSaveDelay(showMessage) * 60 * 1000;
|
|
|
|
if(autoSaveDelay > 0) {
|
|
|
|
if(_timer.GetElapsedMS() > autoSaveDelay) {
|
2018-07-01 15:21:05 -04:00
|
|
|
if(!console->IsDebuggerAttached()) {
|
|
|
|
console->GetSaveStateManager()->SaveState(_autoSaveSlot, showMessage);
|
2016-11-26 18:04:09 -05:00
|
|
|
}
|
2016-08-31 20:54:38 -04:00
|
|
|
_timer.Reset();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
_timer.Reset();
|
|
|
|
}
|
2017-04-10 22:21:16 -04:00
|
|
|
|
|
|
|
if(!_stopThread) {
|
|
|
|
_signal.Wait(1000);
|
|
|
|
}
|
2016-08-31 20:54:38 -04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
AutoSaveManager::~AutoSaveManager()
|
|
|
|
{
|
|
|
|
_stopThread = true;
|
2017-04-10 22:21:16 -04:00
|
|
|
_signal.Signal();
|
2016-08-31 20:54:38 -04:00
|
|
|
_autoSaveThread.join();
|
|
|
|
}
|