本文整理汇总了C++中common::InSaveFile::readLine方法的典型用法代码示例。如果您正苦于以下问题:C++ InSaveFile::readLine方法的具体用法?C++ InSaveFile::readLine怎么用?C++ InSaveFile::readLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common::InSaveFile
的用法示例。
在下文中一共展示了InSaveFile::readLine方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: getGamePartProgress
void SaveLoad_ns::getGamePartProgress(bool *complete, int size) {
assert(complete && size >= 3);
Common::InSaveFile *inFile = getInSaveFile(SPECIAL_SAVESLOT);
Common::String s = inFile->readLine();
delete inFile;
complete[0] = s.contains("dino");
complete[1] = s.contains("donna");
complete[2] = s.contains("dough");
}
示例3: readAndVerifyData
bool SaveGametests::readAndVerifyData(const char *fileName, const char *expected) {
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
Common::InSaveFile *loadFile = saveFileMan->openForLoading(fileName);
if (!loadFile) {
Testsuite::logDetailedPrintf("Can't open save File to load\n");
return false;
}
Common::String lineToRead = loadFile->readLine();
delete loadFile;
if (lineToRead.equals(expected)) {
return true;
}
return false;
}
示例4: setPartComplete
void SaveLoad_ns::setPartComplete(const char *part) {
Common::String s;
bool alreadyPresent = false;
Common::InSaveFile *inFile = getInSaveFile(SPECIAL_SAVESLOT);
if (inFile) {
s = inFile->readLine();
delete inFile;
if (s.contains(part)) {
alreadyPresent = true;
}
}
if (!alreadyPresent) {
Common::OutSaveFile *outFile = getOutSaveFile(SPECIAL_SAVESLOT);
outFile->writeString(s);
outFile->writeString(part);
outFile->finalize();
delete outFile;
}
}
示例5: doLoadGame
void SaveLoad_ns::doLoadGame(uint16 slot) {
_vm->cleanupGame();
Common::InSaveFile *f = getInSaveFile(slot);
if (!f) return;
Common::String s, character, location;
// scrap the line with the savefile name
f->readLine();
character = f->readLine();
location = f->readLine();
s = f->readLine();
_vm->_location._startPosition.x = atoi(s.c_str());
s = f->readLine();
_vm->_location._startPosition.y = atoi(s.c_str());
s = f->readLine();
_vm->_score = atoi(s.c_str());
s = f->readLine();
_globalFlags = atoi(s.c_str());
s = f->readLine();
_vm->_numLocations = atoi(s.c_str());
uint16 _si;
for (_si = 0; _si < _vm->_numLocations; _si++) {
s = f->readLine();
strcpy(_vm->_locationNames[_si], s.c_str());
s = f->readLine();
_vm->_localFlags[_si] = atoi(s.c_str());
}
_vm->cleanInventory(false);
ItemName name;
uint32 value;
for (_si = 0; _si < 30; _si++) {
s = f->readLine();
value = atoi(s.c_str());
s = f->readLine();
name = atoi(s.c_str());
_vm->addInventoryItem(name, value);
}
delete f;
// force reload of character to solve inventory
// bugs, but it's a good maneuver anyway
strcpy(_vm->_characterName1, "null");
char tmp[PATH_LEN];
sprintf(tmp, "%s.%s" , location.c_str(), character.c_str());
_vm->scheduleLocationSwitch(tmp);
}
示例6: saveLoadScreen
bool DrasculaEngine::saveLoadScreen() {
char names[10][23];
char file[50];
char fileEpa[50];
int n, n2, num_sav = 0, y = 27;
Common::InSaveFile *sav;
clearRoom();
snprintf(fileEpa, 50, "%s.epa", _targetName.c_str());
if (!(sav = _saveFileMan->openForLoading(fileEpa))) {
Common::OutSaveFile *epa;
if (!(epa = _saveFileMan->openForSaving(fileEpa)))
error("Can't open %s file", fileEpa);
for (n = 0; n < NUM_SAVES; n++)
epa->writeString("*\n");
epa->finalize();
delete epa;
if (!(sav = _saveFileMan->openForLoading(fileEpa))) {
error("Can't open %s file", fileEpa);
}
}
for (n = 0; n < NUM_SAVES; n++) {
strncpy(names[n], sav->readLine().c_str(), 23);
names[n][22] = '\0'; // make sure the savegame name is 0-terminated
}
delete sav;
loadPic("savescr.alg", bgSurface, HALF_PAL);
color_abc(kColorLightGreen);
select[0] = 0;
_system->setFeatureState(OSystem::kFeatureVirtualKeyboard, true);
setCursor(kCursorCrosshair);
while (!shouldQuit()) {
y = 27;
copyBackground();
for (n = 0; n < NUM_SAVES; n++) {
print_abc(names[n], 116, y);
y = y + 9;
}
print_abc(select, 117, 15);
updateScreen();
y = 27;
updateEvents();
if (leftMouseButton == 1) {
delay(50);
for (n = 0; n < NUM_SAVES; n++) {
if (mouseX > 115 && mouseY > y + (9 * n) && mouseX < 115 + 175 && mouseY < y + 10 + (9 * n)) {
strcpy(select, names[n]);
if (strcmp(select, "*"))
selectionMade = 1;
else {
enterName();
strcpy(names[n], select);
if (selectionMade == 1) {
snprintf(file, 50, "%s%02d", _targetName.c_str(), n + 1);
saveGame(file);
Common::OutSaveFile *tsav;
if (!(tsav = _saveFileMan->openForSaving(fileEpa))) {
error("Can't open %s file", fileEpa);
}
for (n = 0; n < NUM_SAVES; n++) {
tsav->writeString(names[n]);
tsav->writeString("\n");
}
tsav->finalize();
delete tsav;
}
}
print_abc(select, 117, 15);
y = 27;
for (n2 = 0; n2 < NUM_SAVES; n2++) {
print_abc(names[n2], 116, y);
y = y + 9;
}
if (selectionMade == 1) {
snprintf(file, 50, "%s%02d", _targetName.c_str(), n + 1);
}
num_sav = n;
}
}
if (mouseX > 117 && mouseY > 15 && mouseX < 295 && mouseY < 24 && selectionMade == 1) {
enterName();
strcpy(names[num_sav], select);
print_abc(select, 117, 15);
y = 27;
for (n2 = 0; n2 < NUM_SAVES; n2++) {
print_abc(names[n2], 116, y);
y = y + 9;
}
//.........这里部分代码省略.........