IOS7: Properly restore state when the process has been terminated
This commit is contained in:
parent
ecaa8e5440
commit
947db98d9b
8 changed files with 64 additions and 31 deletions
|
@ -245,10 +245,8 @@ void OSystem_iOS7::suspendLoop() {
|
|||
if (iOS7_fetchEvent(&event)) {
|
||||
if (event.type == kInputApplicationResumed)
|
||||
done = true;
|
||||
else if (event.type == kInputApplicationEnteredBackground)
|
||||
handleEvent_applicationEnteredBackground();
|
||||
else if (event.type == kInputApplicationEnteredForeground)
|
||||
handleEvent_applicationEnteredForeground();
|
||||
else if (event.type == kInputApplicationSaveState)
|
||||
handleEvent_applicationSaveState();
|
||||
}
|
||||
usleep(100000);
|
||||
}
|
||||
|
@ -260,11 +258,7 @@ void OSystem_iOS7::suspendLoop() {
|
|||
|
||||
void OSystem_iOS7::saveState() {
|
||||
// Clear any previous restore state to avoid having and obsolete one if we don't save it again below.
|
||||
if (ConfMan.hasKey("restore_target", Common::ConfigManager::kApplicationDomain) &&
|
||||
ConfMan.hasKey("restore_slot", Common::ConfigManager::kApplicationDomain)) {
|
||||
ConfMan.removeKey("restore_target", Common::ConfigManager::kApplicationDomain);
|
||||
ConfMan.removeKey("restore_slot", Common::ConfigManager::kApplicationDomain);
|
||||
}
|
||||
clearState();
|
||||
|
||||
// If there is an engine running and it accepts autosave, do an autosave and add the current
|
||||
// running target to the config file.
|
||||
|
@ -285,9 +279,7 @@ void OSystem_iOS7::restoreState() {
|
|||
ConfMan.hasKey("restore_slot", Common::ConfigManager::kApplicationDomain)) {
|
||||
target = ConfMan.get("restore_target", Common::ConfigManager::kApplicationDomain);
|
||||
slot = ConfMan.getInt("restore_slot", Common::ConfigManager::kApplicationDomain);
|
||||
ConfMan.removeKey("restore_target", Common::ConfigManager::kApplicationDomain);
|
||||
ConfMan.removeKey("restore_slot", Common::ConfigManager::kApplicationDomain);
|
||||
ConfMan.flushToDisk();
|
||||
clearState();
|
||||
}
|
||||
|
||||
// If the g_engine is still running (i.e. the application was not terminated) we don't need to do anything.
|
||||
|
@ -302,6 +294,15 @@ void OSystem_iOS7::restoreState() {
|
|||
}
|
||||
}
|
||||
|
||||
void OSystem_iOS7::clearState() {
|
||||
if (ConfMan.hasKey("restore_target", Common::ConfigManager::kApplicationDomain) &&
|
||||
ConfMan.hasKey("restore_slot", Common::ConfigManager::kApplicationDomain)) {
|
||||
ConfMan.removeKey("restore_target", Common::ConfigManager::kApplicationDomain);
|
||||
ConfMan.removeKey("restore_slot", Common::ConfigManager::kApplicationDomain);
|
||||
ConfMan.flushToDisk();
|
||||
}
|
||||
}
|
||||
|
||||
uint32 OSystem_iOS7::getMillis(bool skipRecord) {
|
||||
CFTimeInterval timeInSeconds = CACurrentMediaTime();
|
||||
return (uint32) ((timeInSeconds - _startTime) * 1000.0) - _timeSuspended;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue