SWORD25: Standardised savegame filenames, start on advanced engine features
svn-id: r53901
This commit is contained in:
parent
f772de04f9
commit
b53d12da23
4 changed files with 41 additions and 17 deletions
|
@ -24,10 +24,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "base/plugins.h"
|
#include "base/plugins.h"
|
||||||
|
#include "common/savefile.h"
|
||||||
|
#include "common/system.h"
|
||||||
#include "engines/advancedDetector.h"
|
#include "engines/advancedDetector.h"
|
||||||
|
|
||||||
#include "sword25/sword25.h"
|
#include "sword25/sword25.h"
|
||||||
|
#include "sword25/kernel/persistenceservice.h"
|
||||||
|
|
||||||
namespace Sword25 {
|
namespace Sword25 {
|
||||||
uint32 Sword25Engine::getGameFlags() const { return _gameDescription->flags; }
|
uint32 Sword25Engine::getGameFlags() const { return _gameDescription->flags; }
|
||||||
|
@ -114,6 +116,8 @@ public:
|
||||||
|
|
||||||
virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;
|
virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;
|
||||||
virtual bool hasFeature(MetaEngineFeature f) const;
|
virtual bool hasFeature(MetaEngineFeature f) const;
|
||||||
|
virtual int getMaximumSaveSlot() const { return Sword25::PersistenceService::getSlotCount(); }
|
||||||
|
virtual SaveStateList listSaves(const char *target) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool Sword25MetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
|
bool Sword25MetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
|
||||||
|
@ -124,20 +128,29 @@ bool Sword25MetaEngine::createInstance(OSystem *syst, Engine **engine, const ADG
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Sword25MetaEngine::hasFeature(MetaEngineFeature f) const {
|
bool Sword25MetaEngine::hasFeature(MetaEngineFeature f) const {
|
||||||
return false;
|
|
||||||
// TODO: Implement some of these features!?
|
|
||||||
#if 0
|
|
||||||
return
|
return
|
||||||
(f == kSupportsListSaves) ||
|
(f == kSupportsListSaves);
|
||||||
(f == kSupportsLoadingDuringStartup) ||
|
|
||||||
(f == kSupportsDeleteSave) ||
|
|
||||||
(f == kSavesSupportMetaInfo) ||
|
|
||||||
(f == kSavesSupportThumbnail) ||
|
|
||||||
(f == kSavesSupportCreationDate) ||
|
|
||||||
(f == kSavesSupportPlayTime);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SaveStateList Sword25MetaEngine::listSaves(const char *target) const {
|
||||||
|
Common::String pattern = target;
|
||||||
|
pattern = pattern + ".???";
|
||||||
|
SaveStateList saveList;
|
||||||
|
|
||||||
|
Sword25::PersistenceService ps;
|
||||||
|
Sword25::setGameTarget(target);
|
||||||
|
|
||||||
|
ps.reloadSlots();
|
||||||
|
|
||||||
|
for (uint i = 0; i < ps.getSlotCount(); ++i) {
|
||||||
|
if (ps.isSlotOccupied(i)) {
|
||||||
|
Common::String desc = ps.getSavegameDescription(i);
|
||||||
|
saveList.push_back(SaveStateDescriptor(i, desc));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return saveList;
|
||||||
|
}
|
||||||
|
|
||||||
#if PLUGIN_ENABLED_DYNAMIC(SWORD25)
|
#if PLUGIN_ENABLED_DYNAMIC(SWORD25)
|
||||||
REGISTER_PLUGIN_DYNAMIC(SWORD25, PLUGIN_TYPE_ENGINE, Sword25MetaEngine);
|
REGISTER_PLUGIN_DYNAMIC(SWORD25, PLUGIN_TYPE_ENGINE, Sword25MetaEngine);
|
||||||
|
|
|
@ -57,12 +57,17 @@ static const uint SLOT_COUNT = 18;
|
||||||
static const uint FILE_COPY_BUFFER_SIZE = 1024 * 10;
|
static const uint FILE_COPY_BUFFER_SIZE = 1024 * 10;
|
||||||
static const char *VERSIONID = "SCUMMVM1";
|
static const char *VERSIONID = "SCUMMVM1";
|
||||||
|
|
||||||
|
#define MAX_SAVEGAME_SIZE 100
|
||||||
|
|
||||||
|
char gameTarget[MAX_SAVEGAME_SIZE];
|
||||||
|
|
||||||
|
void setGameTarget(const char *target) {
|
||||||
|
strncpy(gameTarget, target, MAX_SAVEGAME_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
static Common::String generateSavegameFilename(uint slotID) {
|
static Common::String generateSavegameFilename(uint slotID) {
|
||||||
// FIXME: The savename names used here are not in accordance with
|
char buffer[MAX_SAVEGAME_SIZE];
|
||||||
// our conventions; they really should be something like
|
snprintf(buffer, MAX_SAVEGAME_SIZE, "%s.%.3d", gameTarget, slotID);
|
||||||
// "GAMEID.NUM" or "TARGET.NUM".
|
|
||||||
char buffer[10];
|
|
||||||
sprintf(buffer, "%d%s", slotID, SAVEGAME_EXTENSION);
|
|
||||||
return Common::String(buffer);
|
return Common::String(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,6 +71,8 @@ private:
|
||||||
Impl *_impl;
|
Impl *_impl;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void setGameTarget(const char *target);
|
||||||
|
|
||||||
} // End of namespace Sword25
|
} // End of namespace Sword25
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#include "sword25/sword25.h"
|
#include "sword25/sword25.h"
|
||||||
#include "sword25/kernel/filesystemutil.h"
|
#include "sword25/kernel/filesystemutil.h"
|
||||||
#include "sword25/kernel/kernel.h"
|
#include "sword25/kernel/kernel.h"
|
||||||
|
#include "sword25/kernel/persistenceservice.h"
|
||||||
#include "sword25/package/packagemanager.h"
|
#include "sword25/package/packagemanager.h"
|
||||||
#include "sword25/script/script.h"
|
#include "sword25/script/script.h"
|
||||||
|
|
||||||
|
@ -112,6 +113,9 @@ Common::Error Sword25Engine::appStart() {
|
||||||
return Common::kUnknownError;
|
return Common::kUnknownError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set the game target for use in savegames
|
||||||
|
setGameTarget(_targetName.c_str());
|
||||||
|
|
||||||
Common::StringArray commandParameters;
|
Common::StringArray commandParameters;
|
||||||
scriptPtr->setCommandLine(commandParameters);
|
scriptPtr->setCommandLine(commandParameters);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue