aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2008-11-06 15:41:38 +0000
committerMax Horn2008-11-06 15:41:38 +0000
commit8f33d4a40aef337673fe98bb3b44be300fe697e6 (patch)
tree0c5dfe2ec185fa37b8d44b4ef24e67c938471a63
parentedf9f249260b1fd4364f6727fa622991e81e8cf3 (diff)
downloadscummvm-rg350-8f33d4a40aef337673fe98bb3b44be300fe697e6.tar.gz
scummvm-rg350-8f33d4a40aef337673fe98bb3b44be300fe697e6.tar.bz2
scummvm-rg350-8f33d4a40aef337673fe98bb3b44be300fe697e6.zip
Implemented GMM loading (and, once the GMM supports it, saving) for SCUMM
svn-id: r34913
-rw-r--r--engines/dialogs.cpp9
-rw-r--r--engines/dialogs.h3
-rw-r--r--engines/engine.cpp2
-rw-r--r--engines/engine.h7
-rw-r--r--engines/queen/queen.cpp4
-rw-r--r--engines/queen/queen.h2
-rw-r--r--engines/scumm/detection.cpp5
-rw-r--r--engines/scumm/saveload.cpp26
-rw-r--r--engines/scumm/scumm.h8
-rw-r--r--engines/touche/saveload.cpp2
-rw-r--r--engines/touche/touche.h2
11 files changed, 52 insertions, 18 deletions
diff --git a/engines/dialogs.cpp b/engines/dialogs.cpp
index 0650896199..95be09184f 100644
--- a/engines/dialogs.cpp
+++ b/engines/dialogs.cpp
@@ -59,7 +59,7 @@ using GUI::WIDGET_ENABLED;
typedef GUI::OptionsDialog GUI_OptionsDialog;
typedef GUI::Dialog GUI_Dialog;
-GlobalDialog::GlobalDialog(String name) : GUI::Dialog(name) {}
+GlobalDialog::GlobalDialog(Common::String name) : GUI::Dialog(name) {}
enum {
kSaveCmd = 'SAVE',
@@ -134,7 +134,7 @@ void MainMenuDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
break;
case kLoadCmd:
{
- String gameId = ConfMan.get("gameid");
+ Common::String gameId = ConfMan.get("gameid");
const EnginePlugin *plugin = 0;
EngineMan.findGame(gameId, &plugin);
@@ -154,15 +154,16 @@ void MainMenuDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
break;
case kSaveCmd:
/*
- String gameId = ConfMan.get("gameid");
+ Common::String gameId = ConfMan.get("gameid");
const EnginePlugin *plugin = 0;
EngineMan.findGame(gameId, &plugin);
int slot = _saveDialog->runModal(plugin, ConfMan.getActiveDomainName());
+ Common::String desc = ... get desired description from _saveDialog ...
if (slot >= 0) {
- _engine->saveGameState(slot);
+ _engine->saveGameState(slot, desc.c_str());
close();
}
diff --git a/engines/dialogs.h b/engines/dialogs.h
index d38abeb3cf..e93b069636 100644
--- a/engines/dialogs.h
+++ b/engines/dialogs.h
@@ -37,9 +37,6 @@
class GlobalDialog : public GUI::Dialog {
public:
GlobalDialog(Common::String name);
-
-protected:
- typedef Common::String String;
};
diff --git a/engines/engine.cpp b/engines/engine.cpp
index e6a8e51b4c..52b4cc4ad3 100644
--- a/engines/engine.cpp
+++ b/engines/engine.cpp
@@ -265,7 +265,7 @@ bool Engine::canLoadGameStateCurrently() {
return false;
}
-int Engine::saveGameState(int slot) {
+int Engine::saveGameState(int slot, const char *desc) {
// Do nothing by default
return 0;
}
diff --git a/engines/engine.h b/engines/engine.h
index 5267eec792..2a631e069f 100644
--- a/engines/engine.h
+++ b/engines/engine.h
@@ -167,7 +167,9 @@ public:
/**
* Load a game state.
+ * @param slot the slot from which a savestate should be loaded
* @return returns 0 on success, anything else indicates failure
+ *
* @todo define proper error values
*/
virtual int loadGameState(int slot);
@@ -179,12 +181,13 @@ public:
/**
* Save a game state.
+ * @param slot the slot into which the savestate should be stored
+ * @param desc a description for the savestate, entered by the user
* @return returns 0 on success, anything else indicates failure
*
* @todo define proper error values
- * @todo actually we need to pass the user entered name to the engine
*/
- virtual int saveGameState(int slot);
+ virtual int saveGameState(int slot, const char *desc);
/**
* Indicates whether a game state can be saved.
diff --git a/engines/queen/queen.cpp b/engines/queen/queen.cpp
index 50936f8bb7..1232b12288 100644
--- a/engines/queen/queen.cpp
+++ b/engines/queen/queen.cpp
@@ -312,7 +312,7 @@ bool QueenEngine::canLoadOrSave() const {
return !_input->cutawayRunning() && !(_resource->isDemo() || _resource->isInterview());
}
-void QueenEngine::saveGameState(int slot, const char *desc) {
+int QueenEngine::saveGameState(int slot, const char *desc) {
debug(3, "Saving game to slot %d", slot);
char name[20];
makeGameStateName(slot, name);
@@ -351,6 +351,8 @@ void QueenEngine::saveGameState(int slot, const char *desc) {
} else {
warning("Can't create file '%s', game not saved", name);
}
+
+ return 0;
}
int QueenEngine::loadGameState(int slot) {
diff --git a/engines/queen/queen.h b/engines/queen/queen.h
index dcfc7b07a5..df218a64a2 100644
--- a/engines/queen/queen.h
+++ b/engines/queen/queen.h
@@ -106,7 +106,7 @@ public:
void update(bool checkPlayerInput = false);
bool canLoadOrSave() const;
- void saveGameState(int slot, const char *desc);
+ int saveGameState(int slot, const char *desc);
int loadGameState(int slot);
void makeGameStateName(int slot, char *buf) const;
int getGameStateSlot(const char *filename) const;
diff --git a/engines/scumm/detection.cpp b/engines/scumm/detection.cpp
index fc85e13250..6ca3406230 100644
--- a/engines/scumm/detection.cpp
+++ b/engines/scumm/detection.cpp
@@ -701,7 +701,10 @@ bool ScummMetaEngine::hasFeature(MetaEngineFeature f) const {
}
bool ScummEngine::hasFeature(EngineFeature f) const {
- return (f == kSupportsRTL);
+ return
+ (f == kSupportsRTL) ||
+ (f == kSupportsLoadingDuringRuntime) ||
+ (f == kSupportsSavingDuringRuntime);
}
GameList ScummMetaEngine::getSupportedGames() const {
diff --git a/engines/scumm/saveload.cpp b/engines/scumm/saveload.cpp
index 267e06dafd..bb8a6bac65 100644
--- a/engines/scumm/saveload.cpp
+++ b/engines/scumm/saveload.cpp
@@ -75,9 +75,31 @@ struct SaveInfoSection {
#pragma mark -
-void ScummEngine::requestSave(int slot, const char *name, bool temporary) {
+int ScummEngine::loadGameState(int slot) {
+ requestLoad(slot);
+ return 0;
+}
+
+bool ScummEngine::canLoadGameStateCurrently() {
+ // FIXME: For now always allow loading
+ return true;
+}
+
+int ScummEngine::saveGameState(int slot, const char *desc) {
+ requestSave(slot, desc);
+ return 0;
+}
+
+bool ScummEngine::canSaveGameStateCurrently() {
+ // FIXME: For now always allow saving
+ return true;
+ return 0;
+}
+
+
+void ScummEngine::requestSave(int slot, const char *name) {
_saveLoadSlot = slot;
- _saveTemporaryState = temporary;
+ _saveTemporaryState = false;
_saveLoadFlag = 1; // 1 for save
assert(name);
strncpy(_saveLoadName, name, sizeof(_saveLoadName));
diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h
index e12a99c0c9..80f5784351 100644
--- a/engines/scumm/scumm.h
+++ b/engines/scumm/scumm.h
@@ -449,6 +449,12 @@ public:
virtual GUI::Debugger *getDebugger();
virtual bool hasFeature(EngineFeature f) const;
virtual void syncSoundSettings();
+
+ virtual int loadGameState(int slot);
+ virtual bool canLoadGameStateCurrently();
+ virtual int saveGameState(int slot, const char *desc);
+ virtual bool canSaveGameStateCurrently();
+
virtual void pauseEngineIntern(bool pause);
protected:
@@ -628,7 +634,7 @@ public:
bool getSavegameName(int slot, Common::String &desc);
void listSavegames(bool *marks, int num);
- void requestSave(int slot, const char *name, bool temporary = false);
+ void requestSave(int slot, const char *name);
void requestLoad(int slot);
// thumbnail + info stuff
diff --git a/engines/touche/saveload.cpp b/engines/touche/saveload.cpp
index 011e739c35..0890d4688f 100644
--- a/engines/touche/saveload.cpp
+++ b/engines/touche/saveload.cpp
@@ -316,7 +316,7 @@ void ToucheEngine::loadGameStateData(Common::ReadStream *stream) {
debug(0, "Loaded state, current episode %d", _currentEpisodeNum);
}
-bool ToucheEngine::saveGameState(int num, const char *description) {
+int ToucheEngine::saveGameState(int num, const char *description) {
bool saveOk = false;
char gameStateFileName[64];
generateGameStateFileName(num, gameStateFileName, 63);
diff --git a/engines/touche/touche.h b/engines/touche/touche.h
index a5ff67dcc9..9d66d839a0 100644
--- a/engines/touche/touche.h
+++ b/engines/touche/touche.h
@@ -497,7 +497,7 @@ protected:
void saveGameStateData(Common::WriteStream *stream);
void loadGameStateData(Common::ReadStream *stream);
- bool saveGameState(int num, const char *description);
+ int saveGameState(int num, const char *description);
int loadGameState(int num);
void readGameStateDescription(int num, char *description, int len);
void generateGameStateFileName(int num, char *dst, int len, bool prefixOnly = false) const;