TINSEL: Enabled listSaves support

svn-id: r34263
This commit is contained in:
Max Horn 2008-09-01 21:13:11 +00:00
parent 4567cfc61c
commit 40e05acff3
4 changed files with 43 additions and 14 deletions

View File

@ -29,6 +29,7 @@
#include "common/file.h"
#include "tinsel/tinsel.h"
#include "tinsel/savescn.h" // needed by TinselMetaEngine::listSaves
namespace Tinsel {
@ -309,13 +310,42 @@ public:
}
virtual const char *getCopyright() const {
// FIXME: Bad copyright string.
// Should be something like "Tinsel (C) Psygnosis" or so... ???
return "Tinsel Engine";
}
virtual bool createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const;
virtual bool hasFeature(MetaEngineFeature f) const;
virtual SaveStateList listSaves(const char *target) const;
};
bool TinselMetaEngine::hasFeature(MetaEngineFeature f) const {
return
(f == kSupportsListSaves);
}
namespace Tinsel {
extern int getList(Common::SaveFileManager *saveFileMan, const Common::String &target);
}
SaveStateList TinselMetaEngine::listSaves(const char *target) const {
int numStates = Tinsel::getList(g_system->getSavefileManager(), target);
SaveStateList saveList;
for (int i = 0; i < numStates; i++) {
SaveStateDescriptor sd(i,
Tinsel::ListEntry(i, Tinsel::LE_DESC),
Tinsel::ListEntry(i, Tinsel::LE_NAME));
// TODO: Also add savedFiles[i].dateTime to the SaveStateDescriptor
saveList.push_back(sd);
}
return saveList;
}
bool TinselMetaEngine::createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const {
const Tinsel::TinselGameDescription *gd = (const Tinsel::TinselGameDescription *)desc;
if (gd) {

View File

@ -246,16 +246,11 @@ static char *NewName(void) {
* Store the file details, ordered by time, in savedFiles[] and return
* the number of files found).
*/
int getList(void) {
// No change since last call?
// TODO/FIXME: Just always reload this data? Be careful about slow downs!!!
if (!NeedLoad)
return numSfiles;
int getList(Common::SaveFileManager *saveFileMan, const Common::String &target) {
int i;
const Common::String pattern = _vm->getSavegamePattern();
Common::StringList files = _vm->getSaveFileMan()->listSavefiles(pattern.c_str());
const Common::String pattern = target + ".???";
Common::StringList files = saveFileMan->listSavefiles(pattern.c_str());
numSfiles = 0;
@ -264,7 +259,7 @@ int getList(void) {
break;
const Common::String &fname = *file;
Common::InSaveFile *f = _vm->getSaveFileMan()->openForLoading(fname.c_str());
Common::InSaveFile *f = saveFileMan->openForLoading(fname.c_str());
if (f == NULL) {
continue;
}
@ -304,6 +299,15 @@ int getList(void) {
return numSfiles;
}
int getList(void) {
// No change since last call?
// TODO/FIXME: Just always reload this data? Be careful about slow downs!!!
if (!NeedLoad)
return numSfiles;
return getList(_vm->getSaveFileMan(), _vm->getTargetName());
}
char *ListEntry(int i, letype which) {
if (i == -1)

View File

@ -710,10 +710,6 @@ int TinselEngine::init() {
return 0;
}
Common::String TinselEngine::getSavegamePattern() const {
return _targetName + ".???";
}
Common::String TinselEngine::getSavegameFilename(int16 saveNum) const {
char filename[256];
snprintf(filename, 256, "%s.%03d", getTargetName().c_str(), saveNum);

View File

@ -127,7 +127,6 @@ private:
public:
const Common::String getTargetName() const { return _targetName; }
Common::String getSavegamePattern() const;
Common::String getSavegameFilename(int16 saveNum) const;
Common::SaveFileManager *getSaveFileMan() { return _saveFileMan; }
Graphics::Surface &screen() { return _screenSurface; }