diff options
Diffstat (limited to 'engines/parallaction/saveload.cpp')
| -rw-r--r-- | engines/parallaction/saveload.cpp | 171 |
1 files changed, 102 insertions, 69 deletions
diff --git a/engines/parallaction/saveload.cpp b/engines/parallaction/saveload.cpp index 44613c970c..9a787d7f00 100644 --- a/engines/parallaction/saveload.cpp +++ b/engines/parallaction/saveload.cpp @@ -31,6 +31,7 @@ #include "gui/message.h" #include "parallaction/parallaction.h" +#include "parallaction/saveload.h" #include "parallaction/sound.h" @@ -57,12 +58,11 @@ protected: GUI::StaticTextWidget *_time; GUI::StaticTextWidget *_playtime; GUI::ContainerWidget *_container; - Parallaction_ns *_vm; uint8 _fillR, _fillG, _fillB; public: - SaveLoadChooser(const String &title, const String &buttonLabel, Parallaction_ns *engine); + SaveLoadChooser(const String &title, const String &buttonLabel); ~SaveLoadChooser(); virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data); @@ -73,34 +73,39 @@ public: virtual void reflowLayout(); }; -Common::String Parallaction_ns::genSaveFileName(uint slot, bool oldStyle) { +Common::String SaveLoad_ns::genOldSaveFileName(uint slot) { assert(slot < NUM_SAVESLOTS || slot == SPECIAL_SAVESLOT); char s[20]; - sprintf(s, (oldStyle ? "game.%i" : "nippon.%.3d"), slot ); + sprintf(s, "game.%i", slot); return Common::String(s); } -Common::InSaveFile *Parallaction_ns::getInSaveFile(uint slot) { + +Common::String SaveLoad::genSaveFileName(uint slot) { + assert(slot < NUM_SAVESLOTS || slot == SPECIAL_SAVESLOT); + + char s[20]; + sprintf(s, "%s.%.3d", _saveFilePrefix.c_str(), slot); + + return Common::String(s); +} + +Common::InSaveFile *SaveLoad::getInSaveFile(uint slot) { Common::String name = genSaveFileName(slot); return _saveFileMan->openForLoading(name.c_str()); } -Common::OutSaveFile *Parallaction_ns::getOutSaveFile(uint slot) { +Common::OutSaveFile *SaveLoad::getOutSaveFile(uint slot) { Common::String name = genSaveFileName(slot); return _saveFileMan->openForSaving(name.c_str()); } -void Parallaction_ns::doLoadGame(uint16 slot) { - - _soundMan->stopMusic(); +void SaveLoad_ns::doLoadGame(uint16 slot) { - cleanupGame(); - - _introSarcData3 = 200; - _introSarcData2 = 1; + _vm->cleanupGame(); Common::InSaveFile *f = getInSaveFile(slot); if (!f) return; @@ -109,77 +114,77 @@ void Parallaction_ns::doLoadGame(uint16 slot) { char n[16]; char l[16]; - f->readLine(s, 199); + f->readLine_OLD(s, 199); - f->readLine(n, 15); + f->readLine_OLD(n, 15); - f->readLine(l, 15); + f->readLine_OLD(l, 15); - f->readLine(s, 15); - _location._startPosition.x = atoi(s); + f->readLine_OLD(s, 15); + _vm->_location._startPosition.x = atoi(s); - f->readLine(s, 15); - _location._startPosition.y = atoi(s); + f->readLine_OLD(s, 15); + _vm->_location._startPosition.y = atoi(s); - f->readLine(s, 15); + f->readLine_OLD(s, 15); _score = atoi(s); - f->readLine(s, 15); + f->readLine_OLD(s, 15); _globalFlags = atoi(s); - f->readLine(s, 15); + f->readLine_OLD(s, 15); // TODO (LIST): unify (and parametrize) calls to freeZones. // We aren't calling freeAnimations because it is not needed, since // kChangeLocation will trigger a complete deletion. Anyway, we still - // need to invoke freeZones here with kEngineQuit set, because the + // need to invoke freeZones here with _quit set, because the // call in changeLocation preserve certain zones. - _engineFlags |= kEngineQuit; - freeZones(); - _engineFlags &= ~kEngineQuit; + _vm->_quit = true; + _vm->freeZones(); + _vm->_quit = false; - _numLocations = atoi(s); + _vm->_numLocations = atoi(s); uint16 _si; - for (_si = 0; _si < _numLocations; _si++) { - f->readLine(s, 20); + for (_si = 0; _si < _vm->_numLocations; _si++) { + f->readLine_OLD(s, 20); s[strlen(s)] = '\0'; - strcpy(_locationNames[_si], s); + strcpy(_vm->_locationNames[_si], s); - f->readLine(s, 15); - _localFlags[_si] = atoi(s); + f->readLine_OLD(s, 15); + _vm->_localFlags[_si] = atoi(s); } - cleanInventory(false); + _vm->cleanInventory(false); ItemName name; uint32 value; for (_si = 0; _si < 30; _si++) { - f->readLine(s, 15); + f->readLine_OLD(s, 15); value = atoi(s); - f->readLine(s, 15); + f->readLine_OLD(s, 15); name = atoi(s); - addInventoryItem(name, value); + _vm->addInventoryItem(name, value); } delete f; // force reload of character to solve inventory // bugs, but it's a good maneuver anyway - strcpy(_characterName1, "null"); + strcpy(_vm->_characterName1, "null"); char tmp[PATH_LEN]; sprintf(tmp, "%s.%s" , l, n); - scheduleLocationSwitch(tmp); + _vm->scheduleLocationSwitch(tmp); return; } -void Parallaction_ns::doSaveGame(uint16 slot, const char* name) { +void SaveLoad_ns::doSaveGame(uint16 slot, const char* name) { Common::OutSaveFile *f = getOutSaveFile(slot); if (f == 0) { @@ -202,30 +207,30 @@ void Parallaction_ns::doSaveGame(uint16 slot, const char* name) { f->writeString(s); f->writeString("\n"); - sprintf(s, "%s\n", _char.getFullName()); + sprintf(s, "%s\n", _vm->_char.getFullName()); f->writeString(s); sprintf(s, "%s\n", _saveData1); f->writeString(s); - sprintf(s, "%d\n", _char._ani->getX()); + sprintf(s, "%d\n", _vm->_char._ani->getX()); f->writeString(s); - sprintf(s, "%d\n", _char._ani->getY()); + sprintf(s, "%d\n", _vm->_char._ani->getY()); f->writeString(s); sprintf(s, "%d\n", _score); f->writeString(s); sprintf(s, "%u\n", _globalFlags); f->writeString(s); - sprintf(s, "%d\n", _numLocations); + sprintf(s, "%d\n", _vm->_numLocations); f->writeString(s); - for (uint16 _si = 0; _si < _numLocations; _si++) { - sprintf(s, "%s\n%u\n", _locationNames[_si], _localFlags[_si]); + for (uint16 _si = 0; _si < _vm->_numLocations; _si++) { + sprintf(s, "%s\n%u\n", _vm->_locationNames[_si], _vm->_localFlags[_si]); f->writeString(s); } const InventoryItem *item; for (uint16 _si = 0; _si < 30; _si++) { - item = getInventoryItem(_si); + item = _vm->getInventoryItem(_si); sprintf(s, "%u\n%d\n", item->_id, item->_index); f->writeString(s); } @@ -247,8 +252,9 @@ enum { }; -SaveLoadChooser::SaveLoadChooser(const String &title, const String &buttonLabel, Parallaction_ns *engine) - : Dialog("ScummSaveLoad"), _list(0), _chooseButton(0), _gfxWidget(0), _vm(engine) { + +SaveLoadChooser::SaveLoadChooser(const String &title, const String &buttonLabel) + : Dialog("ScummSaveLoad"), _list(0), _chooseButton(0), _gfxWidget(0) { // _drawingHints |= GUI::THEME_HINT_SPECIAL_COLOR; _backgroundType = GUI::Theme::kDialogBackgroundSpecial; @@ -335,7 +341,7 @@ void SaveLoadChooser::reflowLayout() { Dialog::reflowLayout(); } -int Parallaction_ns::buildSaveFileList(Common::StringList& l) { +int SaveLoad_ns::buildSaveFileList(Common::StringList& l) { char buf[200]; @@ -346,7 +352,7 @@ int Parallaction_ns::buildSaveFileList(Common::StringList& l) { Common::InSaveFile *f = getInSaveFile(i); if (f) { - f->readLine(buf, 199); + f->readLine_OLD(buf, 199); delete f; count++; @@ -359,9 +365,9 @@ int Parallaction_ns::buildSaveFileList(Common::StringList& l) { } -int Parallaction_ns::selectSaveFile(uint16 arg_0, const char* caption, const char* button) { +int SaveLoad_ns::selectSaveFile(uint16 arg_0, const char* caption, const char* button) { - SaveLoadChooser* slc = new SaveLoadChooser(caption, button, this); + SaveLoadChooser* slc = new SaveLoadChooser(caption, button); Common::StringList l; @@ -380,7 +386,7 @@ int Parallaction_ns::selectSaveFile(uint16 arg_0, const char* caption, const cha -bool Parallaction_ns::loadGame() { +bool SaveLoad_ns::loadGame() { int _di = selectSaveFile( 0, "Load file", "Load" ); if (_di == -1) { @@ -392,15 +398,15 @@ bool Parallaction_ns::loadGame() { GUI::TimedMessageDialog dialog("Loading game...", 1500); dialog.runModal(); - setArrowCursor(); + _vm->_input->setArrowCursor(); return true; } -bool Parallaction_ns::saveGame() { +bool SaveLoad_ns::saveGame() { - if (!scumm_stricmp(_location._name, "caveau")) { + if (!scumm_stricmp(_vm->_location._name, "caveau")) { return false; } @@ -418,7 +424,7 @@ bool Parallaction_ns::saveGame() { } -void Parallaction_ns::setPartComplete(const Character& character) { +void SaveLoad_ns::setPartComplete(const char *part) { char buf[30]; bool alreadyPresent = false; @@ -426,10 +432,10 @@ void Parallaction_ns::setPartComplete(const Character& character) { Common::InSaveFile *inFile = getInSaveFile(SPECIAL_SAVESLOT); if (inFile) { - inFile->readLine(buf, 29); + inFile->readLine_OLD(buf, 29); delete inFile; - if (strstr(buf, character.getBaseName())) { + if (strstr(buf, part)) { alreadyPresent = true; } } @@ -437,7 +443,7 @@ void Parallaction_ns::setPartComplete(const Character& character) { if (!alreadyPresent) { Common::OutSaveFile *outFile = getOutSaveFile(SPECIAL_SAVESLOT); outFile->writeString(buf); - outFile->writeString(character.getBaseName()); + outFile->writeString(part); outFile->finalize(); delete outFile; } @@ -445,17 +451,20 @@ void Parallaction_ns::setPartComplete(const Character& character) { return; } -bool Parallaction_ns::allPartsComplete() { - char buf[30]; +void SaveLoad_ns::getGamePartProgress(bool *complete, int size) { + assert(complete && size >= 3); + char buf[30]; Common::InSaveFile *inFile = getInSaveFile(SPECIAL_SAVESLOT); - inFile->readLine(buf, 29); + inFile->readLine_OLD(buf, 29); delete inFile; - return strstr(buf, "dino") && strstr(buf, "donna") && strstr(buf, "dough"); + complete[0] = strstr(buf, "dino"); + complete[1] = strstr(buf, "donna"); + complete[2] = strstr(buf, "dough"); } -void Parallaction_ns::renameOldSavefiles() { +void SaveLoad_ns::renameOldSavefiles() { bool exists[NUM_SAVESLOTS]; uint num = 0; @@ -463,7 +472,7 @@ void Parallaction_ns::renameOldSavefiles() { for (i = 0; i < NUM_SAVESLOTS; i++) { exists[i] = false; - Common::String name = genSaveFileName(i, true); + Common::String name = genOldSaveFileName(i); Common::InSaveFile *f = _saveFileMan->openForLoading(name.c_str()); if (f) { exists[i] = true; @@ -491,8 +500,8 @@ void Parallaction_ns::renameOldSavefiles() { uint success = 0; for (i = 0; i < NUM_SAVESLOTS; i++) { if (exists[i]) { - Common::String oldName = genSaveFileName(i, true); - Common::String newName = genSaveFileName(i, false); + Common::String oldName = genOldSaveFileName(i); + Common::String newName = genSaveFileName(i); if (_saveFileMan->renameSavefile(oldName.c_str(), newName.c_str())) { success++; } else { @@ -518,4 +527,28 @@ void Parallaction_ns::renameOldSavefiles() { } +bool SaveLoad_br::loadGame() { + // TODO: implement loadgame + return false; +} + +bool SaveLoad_br::saveGame() { + // TODO: implement savegame + return false; +} + +void SaveLoad_br::getGamePartProgress(bool *complete, int size) { + assert(complete && size >= 3); + + // TODO: implement progress loading + + complete[0] = true; + complete[1] = true; + complete[2] = true; +} + +void SaveLoad_br::setPartComplete(const char *part) { + // TODO: implement progress saving +} + } // namespace Parallaction |
