aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Page2008-08-10 22:53:43 +0000
committerChristopher Page2008-08-10 22:53:43 +0000
commitc9e0422722eadeabdd0fd0dfe8591f90a3f00e89 (patch)
tree9adb237ac2912c3048272678e406c2f96f7c02f8
parentfcc00f20b93d719c9f7bce848ed7c3600be982b9 (diff)
downloadscummvm-rg350-c9e0422722eadeabdd0fd0dfe8591f90a3f00e89.tar.gz
scummvm-rg350-c9e0422722eadeabdd0fd0dfe8591f90a3f00e89.tar.bz2
scummvm-rg350-c9e0422722eadeabdd0fd0dfe8591f90a3f00e89.zip
Added Autosave support for AGI
svn-id: r33772
-rw-r--r--engines/agi/agi.cpp2
-rw-r--r--engines/agi/agi.h2
-rw-r--r--engines/agi/cycle.cpp4
-rw-r--r--engines/agi/saveload.cpp20
4 files changed, 22 insertions, 6 deletions
diff --git a/engines/agi/agi.cpp b/engines/agi/agi.cpp
index d67e16d196..fc09e8ab09 100644
--- a/engines/agi/agi.cpp
+++ b/engines/agi/agi.cpp
@@ -734,6 +734,8 @@ void AgiEngine::initialize() {
_gfx->initVideo();
_sound->initSound();
+ _lastSaveTime = 0;
+
_timer->installTimerProc(agiTimerFunctionLow, 10 * 1000, NULL);
_game.ver = -1; /* Don't display the conf file warning */
diff --git a/engines/agi/agi.h b/engines/agi/agi.h
index ec290b812d..ff2b05ace1 100644
--- a/engines/agi/agi.h
+++ b/engines/agi/agi.h
@@ -746,6 +746,8 @@ protected:
int go();
void initialize();
+ uint32 _lastSaveTime;
+
public:
AgiEngine(OSystem *syst, const AGIGameDescription *gameDesc);
virtual ~AgiEngine();
diff --git a/engines/agi/cycle.cpp b/engines/agi/cycle.cpp
index 3ceaaa8c90..52c2ed8a78 100644
--- a/engines/agi/cycle.cpp
+++ b/engines/agi/cycle.cpp
@@ -355,6 +355,10 @@ int AgiEngine::playGame() {
if (quit() == 0xff)
ec = errRestartGame;
+ if (shouldPerformAutoSave(_lastSaveTime)) {
+ saveGame(getSavegameFilename(0), "Autosave");
+ }
+
} while (quit() == 0);
_sound->stopSound();
diff --git a/engines/agi/saveload.cpp b/engines/agi/saveload.cpp
index 1589611c01..0b308bb37b 100644
--- a/engines/agi/saveload.cpp
+++ b/engines/agi/saveload.cpp
@@ -214,6 +214,9 @@ int AgiEngine::saveGame(const char *fileName, const char *description) {
delete out;
debugC(3, kDebugLevelMain | kDebugLevelSavegame, "Closed %s", fileName);
+
+ _lastSaveTime = _system->getMillis();
+
return result;
}
@@ -699,13 +702,18 @@ int AgiEngine::saveGameDialog() {
sprintf(fileName, "%s", getSavegameFilename(slot));
- drawWindow(hp, vp, GFX_WIDTH - hp, GFX_HEIGHT - vp);
- printText("Select a slot in which you wish to\nsave the game:",
- 0, hm + 1, vm + 1, w, MSG_BOX_TEXT, MSG_BOX_COLOUR);
- slot = selectSlot();
- if (slot < 0)
- return errOK;
+ do {
+ drawWindow(hp, vp, GFX_WIDTH - hp, GFX_HEIGHT - vp);
+ printText("Select a slot in which you wish to\nsave the game:",
+ 0, hm + 1, vm + 1, w, MSG_BOX_TEXT, MSG_BOX_COLOUR);
+ slot = selectSlot();
+ if (slot == 0)
+ messageBox("That slot is for Autosave only.");
+ else if (slot < 0)
+ return errOK;
+ }
+ while (slot == 0);
drawWindow(hp, vp + 5 * CHAR_LINES, GFX_WIDTH - hp,
GFX_HEIGHT - vp - 9 * CHAR_LINES);