- The GMM save dialog is now working for all engines which support the appropriate features

- Added a new method to the MetaEngine class, getMaximumSaveSlot(), and implemented it in all engines for which the listSavefiles() method is implemented (it goes together with the listSavefiles method). It is used to fill the unused save slots in the save/load dialogs of each engine, so that the user can create new save games in empty slots
- Unified the save/load dialog list numbering in the GMM load/save screens and in the load screen of the main menu (before a game is started)

svn-id: r34963
This commit is contained in:
Filippos Karapetis 2008-11-09 16:13:34 +00:00
parent 08eecfd3e5
commit f5729a4a8b
12 changed files with 46 additions and 12 deletions

View File

@ -2125,6 +2125,7 @@ public:
virtual bool hasFeature(MetaEngineFeature f) const;
virtual bool createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const;
virtual SaveStateList listSaves(const char *target) const;
virtual int getMaximumSaveSlot() const;
virtual void removeSaveState(const char *target, int slot) const;
const Common::ADGameDescription *fallbackDetect(const Common::FSList &fslist) const;
@ -2193,6 +2194,8 @@ SaveStateList AgiMetaEngine::listSaves(const char *target) const {
return saveList;
}
int AgiMetaEngine::getMaximumSaveSlot() const { return 999; }
void AgiMetaEngine::removeSaveState(const char *target, int slot) const {
char extension[6];
snprintf(extension, sizeof(extension), ".%03d", slot);

View File

@ -114,6 +114,7 @@ public:
virtual bool hasFeature(MetaEngineFeature f) const;
virtual bool createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const;
virtual SaveStateList listSaves(const char *target) const;
virtual int getMaximumSaveSlot() const;
};
bool AgosMetaEngine::hasFeature(MetaEngineFeature f) const {
@ -191,6 +192,8 @@ SaveStateList AgosMetaEngine::listSaves(const char *target) const {
return saveList;
}
int AgosMetaEngine::getMaximumSaveSlot() const { return 999; }
#if PLUGIN_ENABLED_DYNAMIC(AGOS)
REGISTER_PLUGIN_DYNAMIC(AGOS, PLUGIN_TYPE_ENGINE, AgosMetaEngine);
#else

View File

@ -536,6 +536,7 @@ public:
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;
virtual int getMaximumSaveSlot() const;
};
bool CineMetaEngine::hasFeature(MetaEngineFeature f) const {
@ -601,6 +602,8 @@ SaveStateList CineMetaEngine::listSaves(const char *target) const {
return saveList;
}
int CineMetaEngine::getMaximumSaveSlot() const { return 9; }
#if PLUGIN_ENABLED_DYNAMIC(CINE)
REGISTER_PLUGIN_DYNAMIC(CINE, PLUGIN_TYPE_ENGINE, CineMetaEngine);
#else

View File

@ -1067,6 +1067,7 @@ public:
bool hasFeature(MetaEngineFeature f) const;
bool createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const;
SaveStateList listSaves(const char *target) const;
virtual int getMaximumSaveSlot() const;
void removeSaveState(const char *target, int slot) const;
SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const;
};
@ -1162,6 +1163,8 @@ SaveStateList KyraMetaEngine::listSaves(const char *target) const {
return saveList;
}
int KyraMetaEngine::getMaximumSaveSlot() const { return 999; }
void KyraMetaEngine::removeSaveState(const char *target, int slot) const {
// Slot 0 can't be deleted, it's for restarting the game(s)
if (slot == 0)

View File

@ -188,6 +188,7 @@ public:
virtual bool hasFeature(MetaEngineFeature f) const;
virtual bool createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const;
virtual SaveStateList listSaves(const char *target) const;
virtual int getMaximumSaveSlot() const;
virtual void removeSaveState(const char *target, int slot) const;
};
@ -239,6 +240,8 @@ SaveStateList LureMetaEngine::listSaves(const char *target) const {
return saveList;
}
int LureMetaEngine::getMaximumSaveSlot() const { return 999; }
void LureMetaEngine::removeSaveState(const char *target, int slot) const {
char extension[6];
snprintf(extension, sizeof(extension), ".%03d", slot);

View File

@ -125,6 +125,13 @@ public:
return SaveStateDescriptor();
}
/**
* Gets the maximum save slot that the engine supports
*/
virtual int getMaximumSaveSlot() const {
return 0;
}
/** @name MetaEngineFeature flags */
//@{

View File

@ -247,6 +247,7 @@ public:
virtual bool hasFeature(MetaEngineFeature f) const;
virtual bool createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const;
virtual SaveStateList listSaves(const char *target) const;
virtual int getMaximumSaveSlot() const;
virtual void removeSaveState(const char *target, int slot) const;
};
@ -308,6 +309,8 @@ SaveStateList ParallactionMetaEngine::listSaves(const char *target) const {
return saveList;
}
int ParallactionMetaEngine::getMaximumSaveSlot() const { return 99; }
void ParallactionMetaEngine::removeSaveState(const char *target, int slot) const {
char extension[6];
snprintf(extension, sizeof(extension), ".0%02d", slot);

View File

@ -151,6 +151,7 @@ public:
virtual bool hasFeature(MetaEngineFeature f) const;
virtual bool createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const;
virtual SaveStateList listSaves(const char *target) const;
virtual int getMaximumSaveSlot() const;
virtual void removeSaveState(const char *target, int slot) const;
};
@ -200,23 +201,15 @@ SaveStateList SagaMetaEngine::listSaves(const char *target) const {
in->read(saveDesc, SAVE_TITLE_SIZE);
saveList.push_back(SaveStateDescriptor(slotNum, saveDesc));
delete in;
} else {
// handle gaps
*saveDesc = 0;
saveList.push_back(SaveStateDescriptor(slotNum, saveDesc));
}
}
}
// Fill the rest of the list with empty slots
*saveDesc = 0;
for (int i = slotNum + 1; i <= 99; i++) {
saveList.push_back(SaveStateDescriptor(i, saveDesc));
}
return saveList;
}
int SagaMetaEngine::getMaximumSaveSlot() const { return 99; }
void SagaMetaEngine::removeSaveState(const char *target, int slot) const {
char extension[6];
snprintf(extension, sizeof(extension), ".s%02d", slot);

View File

@ -685,6 +685,7 @@ public:
virtual Common::Error createInstance(OSystem *syst, Engine **engine) const;
virtual SaveStateList listSaves(const char *target) const;
virtual int getMaximumSaveSlot() const;
virtual void removeSaveState(const char *target, int slot) const;
virtual SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const;
};
@ -961,6 +962,8 @@ namespace Scumm {
extern bool getSavegameName(Common::InSaveFile *in, Common::String &desc, int heversion);
}
int ScummMetaEngine::getMaximumSaveSlot() const { return 99; }
SaveStateList ScummMetaEngine::listSaves(const char *target) const {
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
Common::StringList filenames;

View File

@ -343,6 +343,7 @@ public:
virtual bool hasFeature(MetaEngineFeature f) const;
virtual SaveStateList listSaves(const char *target) const;
virtual int getMaximumSaveSlot() const;
};
bool TinselMetaEngine::hasFeature(MetaEngineFeature f) const {
@ -367,6 +368,7 @@ SaveStateList TinselMetaEngine::listSaves(const char *target) const {
return saveList;
}
int TinselMetaEngine::getMaximumSaveSlot() const { return 999; }
bool TinselMetaEngine::createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const {
const Tinsel::TinselGameDescription *gd = (const Tinsel::TinselGameDescription *)desc;

View File

@ -140,6 +140,7 @@ public:
virtual bool hasFeature(MetaEngineFeature f) const;
virtual bool createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const;
virtual SaveStateList listSaves(const char *target) const;
virtual int getMaximumSaveSlot() const;
virtual void removeSaveState(const char *target, int slot) const;
};
@ -214,6 +215,8 @@ SaveStateList ToucheMetaEngine::listSaves(const char *target) const {
return saveList;
}
int ToucheMetaEngine::getMaximumSaveSlot() const { return 99; }
void ToucheMetaEngine::removeSaveState(const char *target, int slot) const {
char extension[5];
snprintf(extension, sizeof(extension), ".%d", slot);

View File

@ -483,7 +483,7 @@ SaveLoadChooser::SaveLoadChooser(const String &title, const String &buttonLabel)
// Add choice list
_list = new GUI::ListWidget(this, "ScummSaveLoad.List");
_list->setNumberingMode(GUI::kListNumberingOff);
setSaveMode(false);
_gfxWidget = new GUI::GraphicsWidget(this, 0, 0, 10, 10);
@ -541,7 +541,7 @@ const Common::String &SaveLoadChooser::getResultString() const {
void SaveLoadChooser::setSaveMode(bool saveMode) {
_list->setEditable(saveMode);
_list->setNumberingMode(saveMode ? GUI::kListNumberingOne : GUI::kListNumberingZero);
_list->setNumberingMode(GUI::kListNumberingOne);
}
void SaveLoadChooser::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
@ -738,10 +738,18 @@ void SaveLoadChooser::close() {
void SaveLoadChooser::updateSaveList() {
_saveList = (*_plugin)->listSaves(_target.c_str());
int curSlot = 0;
StringList saveNames;
for (SaveStateList::const_iterator x = _saveList.begin(); x != _saveList.end(); ++x) {
saveNames.push_back(x->description());
curSlot++;
}
// Fill the rest of the save slots with empty saves
Common::String emptyDesc;
for (int i = curSlot + 1; i <= (*_plugin)->getMaximumSaveSlot(); i++)
saveNames.push_back(emptyDesc);
_list->setList(saveNames);
}