本文整理汇总了C++中common::SaveFileManager::listSavefiles方法的典型用法代码示例。如果您正苦于以下问题:C++ SaveFileManager::listSavefiles方法的具体用法?C++ SaveFileManager::listSavefiles怎么用?C++ SaveFileManager::listSavefiles使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common::SaveFileManager
的用法示例。
在下文中一共展示了SaveFileManager::listSavefiles方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: listSaves
SaveStateList SciMetaEngine::listSaves(const char *target) const {
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
Common::StringArray filenames;
Common::String pattern = target;
pattern += ".???";
filenames = saveFileMan->listSavefiles(pattern);
sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..)
SaveStateList saveList;
int slotNum = 0;
for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
// Obtain the last 3 digits of the filename, since they correspond to the save slot
slotNum = atoi(file->c_str() + file->size() - 3);
if (slotNum >= 0 && slotNum <= 99) {
Common::InSaveFile *in = saveFileMan->openForLoading(*file);
if (in) {
SavegameMetadata meta;
if (!get_savegame_metadata(in, &meta)) {
// invalid
delete in;
continue;
}
saveList.push_back(SaveStateDescriptor(slotNum, meta.name));
delete in;
}
}
}
return saveList;
}
示例2: listSaves
SaveStateList GrimMetaEngine::listSaves(const char *target) const {
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
Common::StringArray filenames;
Common::String targetString(target);
Common::String pattern = targetString.hasPrefix("monkey4") ? "efmi*.gsv" : "grim*.gsv";
filenames = saveFileMan->listSavefiles(pattern);
SaveStateList saveList;
char str[256];
int32 strSize;
for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
// Obtain the last digits of the filename, since they correspond to the save slot
int slotNum = atoi(file->c_str() + 4);
if (slotNum >= 0) {
SaveGame *savedState = SaveGame::openForLoading(*file);
if (savedState && savedState->isCompatible()) {
savedState->beginSection('SUBS');
strSize = savedState->readLESint32();
savedState->read(str, strSize);
savedState->endSection();
saveList.push_back(SaveStateDescriptor(slotNum, str));
}
delete savedState;
}
}
Common::sort(saveList.begin(), saveList.end(), cmpSave);
return saveList;
}
示例3: listSaves
SaveStateList SwordMetaEngine::listSaves(const char *target) const {
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
SaveStateList saveList;
char saveName[40];
Common::StringArray filenames = saveFileMan->listSavefiles("sword1.???");
sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..)
int slotNum = 0;
for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
// Obtain the last 3 digits of the filename, since they correspond to the save slot
slotNum = atoi(file->c_str() + file->size() - 3);
if (slotNum >= 0 && slotNum <= 999) {
Common::InSaveFile *in = saveFileMan->openForLoading(*file);
if (in) {
in->readUint32LE(); // header
in->read(saveName, 40);
saveList.push_back(SaveStateDescriptor(slotNum, saveName));
delete in;
}
}
}
return saveList;
}
示例4: listSaves
SaveStateList QueenMetaEngine::listSaves(const char *target) const {
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
Common::StringArray filenames;
char saveDesc[32];
Common::String pattern("queen.s??");
filenames = saveFileMan->listSavefiles(pattern);
sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..)
SaveStateList saveList;
for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
// Obtain the last 2 digits of the filename, since they correspond to the save slot
int slotNum = atoi(file->c_str() + file->size() - 2);
if (slotNum >= 0 && slotNum <= 99) {
Common::InSaveFile *in = saveFileMan->openForLoading(*file);
if (in) {
for (int i = 0; i < 4; i++)
in->readUint32BE();
in->read(saveDesc, 32);
saveList.push_back(SaveStateDescriptor(slotNum, saveDesc));
delete in;
}
}
}
return saveList;
}
示例5: getSavegameList
SaveStateList CProjectItem::getSavegameList(const Common::String &target) {
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
Common::StringArray filenames;
Common::String saveDesc;
Common::String pattern = Common::String::format("%s.0??", target.c_str());
TitanicSavegameHeader header;
filenames = saveFileMan->listSavefiles(pattern);
sort(filenames.begin(), filenames.end()); // Sort to get the files in numerical order
SaveStateList saveList;
for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
const char *ext = strrchr(file->c_str(), '.');
int slot = ext ? atoi(ext + 1) : -1;
if (slot >= 0 && slot < MAX_SAVEGAME_SLOTS) {
Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(*file);
if (in) {
SimpleFile f;
f.open(in);
if (!readSavegameHeader(&f, header))
continue;
saveList.push_back(SaveStateDescriptor(slot, header._saveName));
header._thumbnail->free();
delete header._thumbnail;
delete in;
}
}
}
return saveList;
}
示例6: listSaves
SaveStateList AgosMetaEngine::listSaves(const char *target) const {
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
Common::StringArray filenames;
Common::String saveDesc;
Common::String pattern = target;
pattern += ".###";
filenames = saveFileMan->listSavefiles(pattern);
SaveStateList saveList;
for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
// Obtain the last 3 digits of the filename, since they correspond to the save slot
int slotNum = atoi(file->c_str() + file->size() - 3);
if (slotNum >= 0 && slotNum <= 999) {
Common::InSaveFile *in = saveFileMan->openForLoading(*file);
if (in) {
saveDesc = file->c_str();
saveList.push_back(SaveStateDescriptor(slotNum, saveDesc));
delete in;
}
}
}
// Sort saves based on slot number.
Common::sort(saveList.begin(), saveList.end(), SaveStateDescriptorSlotComparator());
return saveList;
}
示例7: removeSaveState
void PictureMetaEngine::removeSaveState(const char *target, int slot) const {
// Slot 0 can't be deleted, it's for restarting the game(s)
if (slot == 0)
return;
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
Common::String filename = Picture::PictureEngine::getSavegameFilename(target, slot);
saveFileMan->removeSavefile(filename.c_str());
Common::StringArray filenames;
Common::String pattern = target;
pattern += ".???";
filenames = saveFileMan->listSavefiles(pattern.c_str());
Common::sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..)
for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
// Obtain the last 3 digits of the filename, since they correspond to the save slot
int slotNum = atoi(file->c_str() + file->size() - 3);
// Rename every slot greater than the deleted slot,
// Also do not rename quicksaves.
if (slotNum > slot && slotNum < 990) {
// FIXME: Our savefile renaming done here is inconsitent with what we do in
// GUI_v2::deleteMenu. While here we rename every slot with a greater equal
// number of the deleted slot to deleted slot, deleted slot + 1 etc.,
// we only rename the following slots in GUI_v2::deleteMenu until a slot
// is missing.
saveFileMan->renameSavefile(file->c_str(), filename.c_str());
filename = Picture::PictureEngine::getSavegameFilename(target, ++slot);
}
}
}
示例8: listSaves
SaveStateList PictureMetaEngine::listSaves(const char *target) const {
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
Picture::PictureEngine::SaveHeader header;
Common::String pattern = target;
pattern += ".???";
Common::StringArray filenames;
filenames = saveFileMan->listSavefiles(pattern.c_str());
Common::sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..)
SaveStateList saveList;
for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); file++) {
// Obtain the last 3 digits of the filename, since they correspond to the save slot
int slotNum = atoi(file->c_str() + file->size() - 3);
if (slotNum >= 0 && slotNum <= 999) {
Common::InSaveFile *in = saveFileMan->openForLoading(file->c_str());
if (in) {
if (Picture::PictureEngine::readSaveHeader(in, false, header) == Picture::PictureEngine::kRSHENoError) {
saveList.push_back(SaveStateDescriptor(slotNum, header.description));
}
delete in;
}
}
}
return saveList;
}
示例9: listSaves
SaveStateList AvalancheMetaEngine::listSaves(const char *target) const {
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
Common::StringArray filenames;
Common::String pattern = target;
pattern.toUppercase();
pattern += ".???";
filenames = saveFileMan->listSavefiles(pattern);
sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..)
SaveStateList saveList;
for (Common::StringArray::const_iterator filename = filenames.begin(); filename != filenames.end(); ++filename) {
const Common::String &fname = *filename;
int slotNum = atoi(fname.c_str() + fname.size() - 3);
if (slotNum >= 0 && slotNum <= getMaximumSaveSlot()) {
Common::InSaveFile *file = saveFileMan->openForLoading(fname);
if (file) {
// Check for our signature.
uint32 signature = file->readUint32LE();
if (signature != MKTAG('A', 'V', 'A', 'L')) {
warning("Savegame of incompatible type!");
delete file;
continue;
}
// Check version.
byte saveVersion = file->readByte();
if (saveVersion != kSavegameVersion) {
warning("Savegame of incompatible version!");
delete file;
continue;
}
// Read name.
uint32 nameSize = file->readUint32LE();
if (nameSize >= 255) {
delete file;
continue;
}
char *name = new char[nameSize + 1];
file->read(name, nameSize);
name[nameSize] = 0;
saveList.push_back(SaveStateDescriptor(slotNum, name));
delete[] name;
delete file;
}
}
}
return saveList;
}
示例10: listSaves
virtual SaveStateList listSaves(const char *target) const {
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
Common::String pattern = Common::String::format("%s??", target);
// Get list of savefiles for target game
Common::StringArray filenames = saveFileMan->listSavefiles(pattern);
Common::Array<int> slots;
for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
// Obtain the last 2 digits of the filename, since they correspond to the save slot
int slotNum = atoi(file->c_str() + file->size() - 2);
// Ensure save slot is within valid range
if (slotNum >= 1 && slotNum <= 10) {
slots.push_back(slotNum);
}
}
// Sort save slot ids
Common::sort<int>(slots.begin(), slots.end());
// Load save index
Common::String fileEpa = Common::String::format("%s.epa", target);
Common::InSaveFile *epa = saveFileMan->openForLoading(fileEpa);
// Get savegame names from index
Common::String saveDesc;
SaveStateList saveList;
int line = 1;
for (uint i = 0; i < slots.size(); i++) {
// ignore lines corresponding to unused saveslots
for (; line < slots[i]; line++)
epa->readLine();
// copy the name in the line corresponding to the save slot and truncate to 22 characters
saveDesc = Common::String(epa->readLine().c_str(), 22);
// handle cases where the save directory and save index are detectably out of sync
if (saveDesc == "*")
saveDesc = "No name specified.";
// increment line number to keep it in sync with slot number
line++;
// Insert savegame name into list
saveList.push_back(SaveStateDescriptor(slots[i], saveDesc));
}
delete epa;
return saveList;
}
示例11: listSaves
SaveStateList SkyMetaEngine::listSaves(const char *target) const {
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
SaveStateList saveList;
// Load the descriptions
Common::StringArray savenames;
savenames.resize(MAX_SAVE_GAMES+1);
Common::InSaveFile *inf;
inf = saveFileMan->openForLoading("SKY-VM.SAV");
if (inf != NULL) {
char *tmpBuf = new char[MAX_SAVE_GAMES * MAX_TEXT_LEN];
char *tmpPtr = tmpBuf;
inf->read(tmpBuf, MAX_SAVE_GAMES * MAX_TEXT_LEN);
for (int i = 0; i < MAX_SAVE_GAMES; ++i) {
savenames[i] = tmpPtr;
tmpPtr += savenames[i].size() + 1;
}
delete inf;
delete[] tmpBuf;
}
// Find all saves
Common::StringArray filenames;
filenames = saveFileMan->listSavefiles("SKY-VM.???");
sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..)
// Slot 0 is the autosave, if it exists.
// TODO: Check for the existence of the autosave -- but this require us
// to know which SKY variant we are looking at.
saveList.insert_at(0, SaveStateDescriptor(0, "*AUTOSAVE*"));
// Prepare the list of savestates by looping over all matching savefiles
for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
// Extract the extension
Common::String ext = file->c_str() + file->size() - 3;
ext.toUppercase();
if (Common::isDigit(ext[0]) && Common::isDigit(ext[1]) && Common::isDigit(ext[2])) {
int slotNum = atoi(ext.c_str());
Common::InSaveFile *in = saveFileMan->openForLoading(*file);
if (in) {
saveList.push_back(SaveStateDescriptor(slotNum+1, savenames[slotNum]));
delete in;
}
}
}
return saveList;
}
示例12: listSaves
SaveStateList CGEMetaEngine::listSaves(const char *target) const {
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
Common::StringArray filenames;
Common::String pattern = target;
pattern += ".???";
filenames = saveFileMan->listSavefiles(pattern);
sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..)
SaveStateList saveList;
int slotNum = 0;
for (Common::StringArray::const_iterator filename = filenames.begin(); filename != filenames.end(); ++filename) {
// Obtain the last 3 digits of the filename, since they correspond to the save slot
slotNum = atoi(filename->c_str() + filename->size() - 3);
if (slotNum >= 0 && slotNum <= 99) {
Common::InSaveFile *file = saveFileMan->openForLoading(*filename);
if (file) {
CGE::SavegameHeader header;
// Check to see if it's a ScummVM savegame or not
char buffer[kSavegameStrSize + 1];
file->read(buffer, kSavegameStrSize + 1);
if (!strncmp(buffer, CGE::savegameStr, kSavegameStrSize + 1)) {
// Valid savegame
if (CGE::CGEEngine::readSavegameHeader(file, header)) {
saveList.push_back(SaveStateDescriptor(slotNum, header.saveName));
if (header.thumbnail) {
header.thumbnail->free();
delete header.thumbnail;
}
}
} else {
// Must be an original format savegame
saveList.push_back(SaveStateDescriptor(slotNum, "Unknown"));
}
delete file;
}
}
}
return saveList;
}
示例13: listSaves
SaveStateList CineMetaEngine::listSaves(const char *target) const {
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
SaveStateList saveList;
Common::String pattern = target;
pattern += ".?";
Common::StringArray filenames = saveFileMan->listSavefiles(pattern);
sort(filenames.begin(), filenames.end());
Common::StringArray::const_iterator file;
Common::String filename = target;
filename += ".dir";
Common::InSaveFile *in = saveFileMan->openForLoading(filename);
if (in) {
typedef char CommandeType[20];
CommandeType saveNames[10];
// Initialize all savegames' descriptions to empty strings
// so that if the savegames' descriptions can only be partially read from file
// then the missing ones are correctly set to empty strings.
memset(saveNames, 0, sizeof(saveNames));
in->read(saveNames, 10 * 20);
CommandeType saveDesc;
for (file = filenames.begin(); file != filenames.end(); ++file) {
// Jump over savegame files that don't end with a digit (e.g. "fw.3" is ok, "fw.a" is not).
if (!isdigit(file->lastChar()))
continue;
// Obtain the last digit of the filename, since they correspond to the save slot
int slotNum = atoi(file->c_str() + file->size() - 1);
// Copy the savegame description making sure it ends with a trailing zero
strncpy(saveDesc, saveNames[slotNum], 20);
saveDesc[sizeof(CommandeType) - 1] = 0;
saveList.push_back(SaveStateDescriptor(slotNum, saveDesc));
}
}
delete in;
return saveList;
}
示例14: updateListing
void FileBrowserDialog::updateListing() {
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
ListWidget::StringArray list;
Common::StringArray filenames = saveFileMan->listSavefiles(_fileMask);
Common::sort(filenames.begin(), filenames.end());
for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
list.push_back(file->c_str());
}
_fileList->setList(list);
_fileList->scrollTo(0);
// Finally, redraw
draw();
}
示例15: L1_FileFindFirst
void L1_FileFindFirst() {
lua_Object extObj = lua_getparam(1);
if (!lua_isstring(extObj)) {
lua_pushnil();
return;
}
L1_FileFindDispose();
const char *extension = lua_getstring(extObj);
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
g_grim->_listFiles = saveFileMan->listSavefiles(extension);
g_grim->_listFilesIter = g_grim->_listFiles.begin();
if (g_grim->_listFilesIter == g_grim->_listFiles.end())
lua_pushnil();
else
L1_FileFindNext();
}