MYST3: Add support for loading savegames from the launcher and the GMM.

This commit is contained in:
Bastien Bouclet 2012-01-23 20:53:41 +01:00
parent 6e02a8c3be
commit 211fee89ac
3 changed files with 44 additions and 3 deletions

View File

@ -24,6 +24,8 @@
#include "engines/myst3/myst3.h"
#include "common/savefile.h"
namespace Myst3 {
struct Myst3GameDescription {
@ -91,6 +93,26 @@ public:
return "Myst III Game (C) Presto Studios";
}
virtual bool hasFeature(MetaEngineFeature f) const {
return
(f == kSupportsListSaves) ||
(f == kSupportsLoadingDuringStartup);
}
virtual SaveStateList listSaves(const char *target) const {
SaveStateList saveList;
Common::StringArray filenames = g_system->getSavefileManager()->listSavefiles("*.m3s");
for (uint32 i = 0; i < filenames.size(); i++)
saveList.push_back(SaveStateDescriptor(i, filenames[i]));
return saveList;
}
virtual int getMaximumSaveSlot() const {
return 999;
}
virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;
};

View File

@ -110,7 +110,8 @@ Myst3Engine::~Myst3Engine() {
bool Myst3Engine::hasFeature(EngineFeature f) const {
return
(f == kSupportsRTL);
(f == kSupportsRTL) ||
(f == kSupportsLoadingDuringRuntime);
}
Common::Error Myst3Engine::run() {
@ -148,8 +149,13 @@ Common::Error Myst3Engine::run() {
font->free();
delete font;
// Game init script, loads the menu
loadNode(1, 101, 1);
if (ConfMan.hasKey("save_slot")) {
// Load game from specified slot, if any
loadGameState(ConfMan.getInt("save_slot"));
} else {
// Game init script, loads the menu
loadNode(1, 101, 1);
}
while (!shouldQuit() && !_shouldQuit) {
_sound->update();
@ -781,9 +787,21 @@ int16 Myst3Engine::openDialog(uint16 id) {
return result;
}
bool Myst3Engine::canLoadGameStateCurrently() {
return true;
}
Common::Error Myst3Engine::loadGameState(int slot) {
if (_state->load(_saveFileMan->listSavefiles("*.M3S")[slot])) {
_inventory->loadFromState();
_state->setLocationNextAge(_state->getMenuSavedAge());
_state->setLocationNextRoom(_state->getMenuSavedRoom());
_state->setLocationNextNode(_state->getMenuSavedNode());
_state->setMenuSavedAge(0);
_state->setMenuSavedRoom(0);
_state->setMenuSavedNode(0);
goToNode(0, 1);
return Common::kNoError;
}

View File

@ -86,6 +86,7 @@ public:
virtual ~Myst3Engine();
bool hasFeature(EngineFeature f) const;
bool canLoadGameStateCurrently();
Common::Error loadGameState(int slot);
const DirectorySubEntry *getFileDescription(const char* room, uint16 index, uint16 face, DirectorySubEntry::ResourceType type);