2013-09-06 01:28:11 +02:00
|
|
|
|
|
|
|
#include "stately.hxx"
|
|
|
|
|
|
|
|
#include "../jack.hxx"
|
|
|
|
#include "state.hxx"
|
|
|
|
|
|
|
|
extern Jack* jack;
|
|
|
|
|
2013-11-14 14:29:22 +01:00
|
|
|
int Stately::saveSuccess = 0;
|
|
|
|
int Stately::saveErrors = 0;
|
2013-09-06 01:28:11 +02:00
|
|
|
|
|
|
|
Stately::Stately()
|
|
|
|
{
|
|
|
|
jack->getState()->registerStately( this );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Stately::reset()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void Stately::save()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-11-14 14:29:22 +01:00
|
|
|
void Stately::checkCompletedSave()
|
2013-09-06 01:28:11 +02:00
|
|
|
{
|
2013-11-14 14:29:22 +01:00
|
|
|
if ( (saveSuccess + saveErrors) >= jack->getState()->getNumStatelys() )
|
2013-09-06 01:28:11 +02:00
|
|
|
{
|
|
|
|
jack->getState()->finish();
|
2013-11-14 14:29:22 +01:00
|
|
|
|
|
|
|
// reset in case of another save before quit
|
|
|
|
saveErrors = 0;
|
|
|
|
saveSuccess = 0;
|
2013-09-06 01:28:11 +02:00
|
|
|
}
|
|
|
|
}
|
2013-11-13 13:03:24 +01:00
|
|
|
|
2013-11-14 14:29:22 +01:00
|
|
|
void Stately::success()
|
|
|
|
{
|
|
|
|
saveSuccess++;
|
|
|
|
checkCompletedSave();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Stately::error(const char* errorString)
|
2013-11-13 13:03:24 +01:00
|
|
|
{
|
|
|
|
// CRITICAL FIXME: add error handling code, noting an error occured, perhaps prompt user?
|
2013-11-14 14:29:22 +01:00
|
|
|
saveErrors++;
|
|
|
|
checkCompletedSave();
|
2013-11-13 13:03:24 +01:00
|
|
|
}
|