Skip to content

Commit

Permalink
SHERLOCK: Hook up saving and loading via GMM
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Apr 22, 2015
1 parent 8b0e8cd commit acf0b01
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 12 deletions.
7 changes: 7 additions & 0 deletions engines/sherlock/detection.cpp
Expand Up @@ -106,6 +106,13 @@ bool SherlockMetaEngine::hasFeature(MetaEngineFeature f) const {
(f == kSavesSupportThumbnail);
}

bool Sherlock::SherlockEngine::hasFeature(EngineFeature f) const {
return
(f == kSupportsRTL) ||
(f == kSupportsLoadingDuringRuntime) ||
(f == kSupportsSavingDuringRuntime);
}

SaveStateList SherlockMetaEngine::listSaves(const char *target) const {
return Sherlock::SaveManager(nullptr, "").getSavegameList(target);
}
Expand Down
4 changes: 0 additions & 4 deletions engines/sherlock/saveload.cpp
Expand Up @@ -383,10 +383,6 @@ void SaveManager::synchronize(Common::Serializer &s) {

if (screen.fontNumber() != oldFont)
journal.resetPosition();
/*
char room_flags[MAX_ROOMS * 9];
*/

_vm->_loadingSavedGame = true;
_justLoaded = true;
Expand Down
43 changes: 37 additions & 6 deletions engines/sherlock/sherlock.cpp
Expand Up @@ -51,6 +51,7 @@ SherlockEngine::SherlockEngine(OSystem *syst, const SherlockGameDescription *gam
_slowChess = false;
_keyPadSpeed = 0;
_loadGameSlot = -1;
_canLoadSave = false;
}

SherlockEngine::~SherlockEngine() {
Expand Down Expand Up @@ -147,8 +148,11 @@ void SherlockEngine::sceneLoop() {
// Handle any input from the keyboard or mouse
handleInput();

if (_scene->_hsavedPos.x == -1)
if (_scene->_hsavedPos.x == -1) {
_canLoadSave = true;
_scene->doBgAnim();
_canLoadSave = false;
}
}

_scene->freeScene();
Expand All @@ -160,7 +164,9 @@ void SherlockEngine::sceneLoop() {
* Handle all player input
*/
void SherlockEngine::handleInput() {
_canLoadSave = true;
_events->pollEventsAndWait();
_canLoadSave = false;

// See if a key or mouse button is pressed
_events->setButtonState();
Expand Down Expand Up @@ -190,15 +196,10 @@ void SherlockEngine::setFlags(int flagNum) {
_scene->checkSceneFlags(true);
}

void SherlockEngine::freeSaveGameList() {
// TODO
}

void SherlockEngine::saveConfig() {
// TODO
}


/**
* Synchronize the data for a savegame
*/
Expand All @@ -207,4 +208,34 @@ void SherlockEngine::synchronize(Common::Serializer &s) {
s.syncAsByte(_flags[idx]);
}

/**
* Returns true if a savegame can be loaded
*/
bool SherlockEngine::canLoadGameStateCurrently() {
return _canLoadSave;
}

/**
* Returns true if the game can be saved
*/
bool SherlockEngine::canSaveGameStateCurrently() {
return _canLoadSave;
}

/**
* Called by the GMM to load a savegame
*/
Common::Error SherlockEngine::loadGameState(int slot) {
_saves->loadGame(slot);
return Common::kNoError;
}

/**
* Called by the GMM to save the game
*/
Common::Error SherlockEngine::saveGameState(int slot, const Common::String &desc) {
_saves->saveGame(slot, desc);
return Common::kNoError;
}

} // End of namespace Comet
10 changes: 8 additions & 2 deletions engines/sherlock/sherlock.h
Expand Up @@ -80,6 +80,8 @@ class SherlockEngine : public Engine {
virtual void showOpening() = 0;

virtual void startScene() {}

virtual bool hasFeature(EngineFeature f) const;
public:
const SherlockGameDescription *_gameDescription;
Animation *_animation;
Expand Down Expand Up @@ -108,12 +110,18 @@ class SherlockEngine : public Engine {
bool _slowChess;
int _keyPadSpeed;
int _loadGameSlot;
bool _canLoadSave;
public:
SherlockEngine(OSystem *syst, const SherlockGameDescription *gameDesc);
virtual ~SherlockEngine();

virtual Common::Error run();

virtual bool canLoadGameStateCurrently();
virtual bool canSaveGameStateCurrently();
virtual Common::Error loadGameState(int slot);
virtual Common::Error saveGameState(int slot, const Common::String &desc);

int getGameType() const;
uint32 getGameID() const;
uint32 getGameFeatures() const;
Expand All @@ -128,8 +136,6 @@ class SherlockEngine : public Engine {

void setFlags(int flagNum);

void freeSaveGameList();

void saveConfig();

void synchronize(Common::Serializer &s);
Expand Down

0 comments on commit acf0b01

Please sign in to comment.