SHERLOCK: Hook up savegames to launcher
This commit is contained in:
parent
0fc2997280
commit
8b0e8cd505
6 changed files with 31 additions and 10 deletions
|
@ -98,7 +98,12 @@ bool SherlockMetaEngine::createInstance(OSystem *syst, Engine **engine, const AD
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SherlockMetaEngine::hasFeature(MetaEngineFeature f) const {
|
bool SherlockMetaEngine::hasFeature(MetaEngineFeature f) const {
|
||||||
return false;
|
return
|
||||||
|
(f == kSupportsListSaves) ||
|
||||||
|
(f == kSupportsLoadingDuringStartup) ||
|
||||||
|
(f == kSupportsDeleteSave) ||
|
||||||
|
(f == kSavesSupportMetaInfo) ||
|
||||||
|
(f == kSavesSupportThumbnail);
|
||||||
}
|
}
|
||||||
|
|
||||||
SaveStateList SherlockMetaEngine::listSaves(const char *target) const {
|
SaveStateList SherlockMetaEngine::listSaves(const char *target) const {
|
||||||
|
@ -109,13 +114,13 @@ int SherlockMetaEngine::getMaximumSaveSlot() const {
|
||||||
return MAX_SAVEGAME_SLOTS;
|
return MAX_SAVEGAME_SLOTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SherlockMetaEngine::removeSaveState(const char *target, int slot) const {
|
void SherlockMetaEngine::removeSaveState(const char *target, int slot) const {
|
||||||
Common::String filename = Common::String::format("%s.%03d", target, slot);
|
Common::String filename = Sherlock::SaveManager(nullptr, target).generateSaveName(slot);
|
||||||
g_system->getSavefileManager()->removeSavefile(filename);
|
g_system->getSavefileManager()->removeSavefile(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
SaveStateDescriptor SherlockMetaEngine::querySaveMetaInfos(const char *target, int slot) const {
|
SaveStateDescriptor SherlockMetaEngine::querySaveMetaInfos(const char *target, int slot) const {
|
||||||
Common::String filename = Common::String::format("%s.%03d", target, slot);
|
Common::String filename = Sherlock::SaveManager(nullptr, target).generateSaveName(slot);
|
||||||
Common::InSaveFile *f = g_system->getSavefileManager()->openForLoading(filename);
|
Common::InSaveFile *f = g_system->getSavefileManager()->openForLoading(filename);
|
||||||
|
|
||||||
if (f) {
|
if (f) {
|
||||||
|
|
|
@ -1194,6 +1194,7 @@ void Journal::synchronize(Common::Serializer &s) {
|
||||||
s.syncAsSint16LE(_maxPage);
|
s.syncAsSint16LE(_maxPage);
|
||||||
|
|
||||||
int journalCount = _journal.size();
|
int journalCount = _journal.size();
|
||||||
|
s.syncAsUint16LE(journalCount);
|
||||||
if (s.isLoading())
|
if (s.isLoading())
|
||||||
_journal.resize(journalCount);
|
_journal.resize(journalCount);
|
||||||
|
|
||||||
|
|
|
@ -318,8 +318,6 @@ void SaveManager::loadGame(int slot) {
|
||||||
if (!saveFile)
|
if (!saveFile)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Common::Serializer s(saveFile, nullptr);
|
|
||||||
|
|
||||||
// Load the savaegame header
|
// Load the savaegame header
|
||||||
SherlockSavegameHeader header;
|
SherlockSavegameHeader header;
|
||||||
if (!readSavegameHeader(saveFile, header))
|
if (!readSavegameHeader(saveFile, header))
|
||||||
|
@ -331,6 +329,7 @@ void SaveManager::loadGame(int slot) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Synchronize the savegame data
|
// Synchronize the savegame data
|
||||||
|
Common::Serializer s(saveFile, nullptr);
|
||||||
synchronize(s);
|
synchronize(s);
|
||||||
|
|
||||||
delete saveFile;
|
delete saveFile;
|
||||||
|
@ -347,6 +346,7 @@ void SaveManager::saveGame(int slot, const Common::String &name) {
|
||||||
header._saveName = name;
|
header._saveName = name;
|
||||||
writeSavegameHeader(out, header);
|
writeSavegameHeader(out, header);
|
||||||
|
|
||||||
|
// Synchronize the savegame data
|
||||||
Common::Serializer s(nullptr, out);
|
Common::Serializer s(nullptr, out);
|
||||||
synchronize(s);
|
synchronize(s);
|
||||||
|
|
||||||
|
|
|
@ -58,8 +58,6 @@ private:
|
||||||
|
|
||||||
void createSavegameList();
|
void createSavegameList();
|
||||||
|
|
||||||
Common::String generateSaveName(int slot);
|
|
||||||
|
|
||||||
void synchronize(Common::Serializer &s);
|
void synchronize(Common::Serializer &s);
|
||||||
public:
|
public:
|
||||||
Common::StringArray _savegames;
|
Common::StringArray _savegames;
|
||||||
|
@ -76,6 +74,8 @@ public:
|
||||||
|
|
||||||
static SaveStateList getSavegameList(const Common::String &target);
|
static SaveStateList getSavegameList(const Common::String &target);
|
||||||
|
|
||||||
|
Common::String generateSaveName(int slot);
|
||||||
|
|
||||||
void writeSavegameHeader(Common::OutSaveFile *out, SherlockSavegameHeader &header);
|
void writeSavegameHeader(Common::OutSaveFile *out, SherlockSavegameHeader &header);
|
||||||
|
|
||||||
static bool readSavegameHeader(Common::InSaveFile *in, SherlockSavegameHeader &header);
|
static bool readSavegameHeader(Common::InSaveFile *in, SherlockSavegameHeader &header);
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "sherlock/sherlock.h"
|
#include "sherlock/sherlock.h"
|
||||||
#include "sherlock/graphics.h"
|
#include "sherlock/graphics.h"
|
||||||
#include "common/scummsys.h"
|
#include "common/scummsys.h"
|
||||||
|
#include "common/config-manager.h"
|
||||||
#include "common/debug-channels.h"
|
#include "common/debug-channels.h"
|
||||||
#include "engines/util.h"
|
#include "engines/util.h"
|
||||||
|
|
||||||
|
@ -49,6 +50,7 @@ SherlockEngine::SherlockEngine(OSystem *syst, const SherlockGameDescription *gam
|
||||||
_onChessboard = false;
|
_onChessboard = false;
|
||||||
_slowChess = false;
|
_slowChess = false;
|
||||||
_keyPadSpeed = 0;
|
_keyPadSpeed = 0;
|
||||||
|
_loadGameSlot = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SherlockEngine::~SherlockEngine() {
|
SherlockEngine::~SherlockEngine() {
|
||||||
|
@ -95,8 +97,20 @@ void SherlockEngine::initialize() {
|
||||||
Common::Error SherlockEngine::run() {
|
Common::Error SherlockEngine::run() {
|
||||||
initialize();
|
initialize();
|
||||||
|
|
||||||
// Temporarily disabled for now
|
// If requested, load a savegame instead of showing the intro
|
||||||
// showOpening();
|
if (ConfMan.hasKey("save_slot")) {
|
||||||
|
int saveSlot = ConfMan.getInt("save_slot");
|
||||||
|
if (saveSlot >= 1 && saveSlot <= MAX_SAVEGAME_SLOTS)
|
||||||
|
_loadGameSlot = saveSlot;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_loadGameSlot != -1) {
|
||||||
|
_saves->loadGame(_loadGameSlot);
|
||||||
|
_loadGameSlot = -1;
|
||||||
|
} else {
|
||||||
|
// Temporarily disabled for now
|
||||||
|
// showOpening();
|
||||||
|
}
|
||||||
|
|
||||||
while (!shouldQuit()) {
|
while (!shouldQuit()) {
|
||||||
// Prepare for scene, and handle any game-specific scenes. This allows
|
// Prepare for scene, and handle any game-specific scenes. This allows
|
||||||
|
|
|
@ -107,6 +107,7 @@ public:
|
||||||
bool _onChessboard;
|
bool _onChessboard;
|
||||||
bool _slowChess;
|
bool _slowChess;
|
||||||
int _keyPadSpeed;
|
int _keyPadSpeed;
|
||||||
|
int _loadGameSlot;
|
||||||
public:
|
public:
|
||||||
SherlockEngine(OSystem *syst, const SherlockGameDescription *gameDesc);
|
SherlockEngine(OSystem *syst, const SherlockGameDescription *gameDesc);
|
||||||
virtual ~SherlockEngine();
|
virtual ~SherlockEngine();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue