Saving and loading from the GMM is now supported in the sky engine

svn-id: r35024
This commit is contained in:
Filippos Karapetis 2008-11-12 20:41:19 +00:00
parent c0f82d3518
commit 6bfee1bae4
3 changed files with 52 additions and 5 deletions

View File

@ -191,6 +191,12 @@ public:
uint16 quickXRestore(uint16 slot);
bool loadSaveAllowed(void);
uint16 _selectedGame;
uint16 saveGameToFile(void);
void loadDescriptions(Common::StringList &list);
void saveDescriptions(const Common::StringList &list);
private:
int displayMessage(const char *altButton, const char *message, ...);
@ -216,14 +222,10 @@ private:
void drawCross(uint16 x, uint16 y);
uint16 saveRestorePanel(bool allowSave);
void loadDescriptions(Common::StringList &list);
void saveDescriptions(const Common::StringList &list);
void setUpGameSprites(const Common::StringList &saveGameNames, dataFileHeader **nameSprites, uint16 firstNum, uint16 selectedGame);
void showSprites(dataFileHeader **nameSprites, bool allowSave);
void handleKeyPress(Common::KeyState kbd, Common::String &textBuf);
uint16 _selectedGame;
uint16 saveGameToFile(void);
uint32 prepareSaveData(uint8 *destBuf);
bool autoSaveExists(void);

View File

@ -93,7 +93,9 @@ bool SkyMetaEngine::hasFeature(MetaEngineFeature f) const {
bool Sky::SkyEngine::hasFeature(EngineFeature f) const {
return
(f == kSupportsRTL);
(f == kSupportsRTL) ||
(f == kSupportsLoadingDuringRuntime) ||
(f == kSupportsSavingDuringRuntime);
}
GameList SkyMetaEngine::getSupportedGames() const {
@ -223,3 +225,41 @@ int SkyMetaEngine::getMaximumSaveSlot() const { return MAX_SAVE_GAMES; }
#else
REGISTER_PLUGIN_STATIC(SKY, PLUGIN_TYPE_ENGINE, SkyMetaEngine);
#endif
namespace Sky {
Common::Error SkyEngine::loadGameState(int slot) {
uint16 result = _skyControl->quickXRestore(slot);
return (result == GAME_RESTORED) ? Common::kNoError : Common::kUnknownError;
}
Common::Error SkyEngine::saveGameState(int slot, const char *desc) {
if (slot == 0)
return Common::kWritePermissionDenied; // we can't overwrite the auto save
// Set the save slot and save the game
_skyControl->_selectedGame = slot - 1;
if (_skyControl->saveGameToFile() != GAME_SAVED)
return Common::kWritePermissionDenied;
// Load current save game descriptions
Common::StringList saveGameTexts;
saveGameTexts.resize(MAX_SAVE_GAMES+1);
_skyControl->loadDescriptions(saveGameTexts);
// Update the save game description at the given slot
saveGameTexts[slot - 1] = desc;
// Save the updated descriptions
_skyControl->saveDescriptions(saveGameTexts);
return Common::kNoError;
}
bool SkyEngine::canLoadGameStateCurrently() {
return _systemVars.pastIntro && _skyControl->loadSaveAllowed();
}
bool SkyEngine::canSaveGameStateCurrently() {
return _systemVars.pastIntro && _skyControl->loadSaveAllowed();
}
} // End of namespace Sky

View File

@ -82,6 +82,11 @@ public:
static bool isDemo(void);
static bool isCDVersion(void);
Common::Error loadGameState(int slot);
Common::Error saveGameState(int slot, const char *desc);
bool canLoadGameStateCurrently();
bool canSaveGameStateCurrently();
static void *fetchItem(uint32 num);
static void *_itemList[300];