diff options
author | athrxx | 2012-01-03 17:25:10 +0100 |
---|---|---|
committer | unknown | 2012-01-03 17:37:47 +0100 |
commit | 76dec424696eacf2e9c1576d0580babb1a58e3f1 (patch) | |
tree | e35333d3a764ade97205e3abedef1c4fa1a9c746 | |
parent | 4fd0e9e94ba5a4e4b11a9e993f69350f70564227 (diff) | |
download | scummvm-rg350-76dec424696eacf2e9c1576d0580babb1a58e3f1.tar.gz scummvm-rg350-76dec424696eacf2e9c1576d0580babb1a58e3f1.tar.bz2 scummvm-rg350-76dec424696eacf2e9c1576d0580babb1a58e3f1.zip |
KYRA: (EOB) - improved eob target detection in transfer party dialog
(parse domains instead of save files)
-rw-r--r-- | engines/kyra/chargen.cpp | 77 | ||||
-rw-r--r-- | engines/kyra/gui_eob.cpp | 18 | ||||
-rw-r--r-- | engines/kyra/gui_eob.h | 2 |
3 files changed, 40 insertions, 57 deletions
diff --git a/engines/kyra/chargen.cpp b/engines/kyra/chargen.cpp index 1093bec079..91a90407b1 100644 --- a/engines/kyra/chargen.cpp +++ b/engines/kyra/chargen.cpp @@ -29,6 +29,11 @@ #include "common/savefile.h" #include "common/str-array.h" +#include "common/config-manager.h" +#include "base/plugins.h" +#include "engines/metaengine.h" +#include "engines/game.h" + namespace Kyra { // Character Generator @@ -1446,7 +1451,8 @@ public: private: bool selectAndLoadTransferFile(); - Common::String transferFileDialogue(); + bool transferFileDialogue(Common::String &dest); + int selectCharactersMenu(); void drawCharPortraitWithStats(int charIndex, bool enabled); @@ -1531,83 +1537,54 @@ bool TransferPartyWiz::start() { bool TransferPartyWiz::selectAndLoadTransferFile() { do { _screen->copyPage(12, 0); - _vm->_savegameFilename = transferFileDialogue(); - } while (_vm->_savegameFilename.empty() && _vm->_gui->confirmDialogue2(15, 68, 1)); + if (transferFileDialogue(_vm->_savegameFilename)) + break; + } while (_vm->_gui->confirmDialogue2(15, 68, 1)); if (_vm->_savegameFilename.empty()) return false; - if (_vm->_savegameFilename.equals(_vm->_saveLoadStrings[1])) - return false; - if (_vm->loadGameState(-1).getCode() != Common::kNoError) return false; return true; } -Common::String TransferPartyWiz::transferFileDialogue() { - Common::StringArray saveFileList = _vm->_saveFileMan->listSavefiles("*.*"); - Common::StringArray targets; - Common::String tfile; - - KyraEngine_v1::SaveHeader header; - memset(&header, 0, sizeof(KyraEngine_v1::SaveHeader)); - Common::InSaveFile *in; - + bool TransferPartyWiz::transferFileDialogue(Common::String &dest) { _vm->_gui->transferWaitBox(); - for (Common::StringArray::iterator i = saveFileList.begin(); i != saveFileList.end(); ++i) { - _vm->updateInput(); - - if (!(in = _vm->_saveFileMan->openForLoading(*i))) - continue; - - if (KyraEngine_v1::readSaveHeader(in, false, header)) { - delete in; - continue; - } - - delete in; - - if (header.gameID != GI_EOB1) - continue; - - i->insertChar('\0', i->size() - 4); + Common::Array<Common::String> eobTargets; + const Common::ConfigManager::DomainMap dom = ConfMan.getGameDomains(); - Common::StringArray::iterator ii = targets.begin(); - for (; ii != targets.end(); ++ii) { - if (!i->compareToIgnoreCase(*ii)) - break; - } - - if (ii == targets.end()) - targets.push_back(*i); + for (Common::ConfigManager::DomainMap::const_iterator i = dom.begin(); i != dom.end(); ++i) { + if (ConfMan.get("gameid", i->_key).equals("eob")) + eobTargets.push_back(i->_key); + _vm->updateInput(); } - if (targets.empty()) - return tfile; + if (eobTargets.empty()) + return false; - Common::String target = _vm->_gui->transferTargetMenu(targets); + Common::String target = _vm->_gui->transferTargetMenu(eobTargets); _screen->copyPage(12, 0); - if (target.equals(_vm->_saveLoadStrings[1])) - return target; + if (target.empty()) + return true; - tfile = target + ".fin"; - in = _vm->_saveFileMan->openForLoading(tfile); + dest = target + ".fin"; + Common::InSaveFile *in = _vm->_saveFileMan->openForLoading(dest); if (in) { delete in; if (_vm->_gui->confirmDialogue2(15, -2, 1)) - return tfile; + return true; } _screen->copyPage(12, 0); - tfile = _vm->_gui->transferFileMenu(target); + bool result = _vm->_gui->transferFileMenu(target, dest); _screen->copyPage(12, 0); - return tfile; + return result; } int TransferPartyWiz::selectCharactersMenu() { diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index a378fe1ea5..d60fa47571 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -2546,12 +2546,13 @@ void GUI_EoB::transferWaitBox() { } Common::String GUI_EoB::transferTargetMenu(Common::Array<Common::String> &targets) { - _savegameListSize = targets.size(); if (_savegameList) { for (int i = 0; i < _savegameListSize; i++) delete[] _savegameList[i]; delete[] _savegameList; } + + _savegameListSize = targets.size(); _savegameList = new char*[_savegameListSize]; memset(_savegameList, 0, _savegameListSize * sizeof(char *)); @@ -2576,12 +2577,16 @@ Common::String GUI_EoB::transferTargetMenu(Common::Array<Common::String> &target _screen->copyRegion(72, 14, 72, 14, 176, 144, 12, 0, Screen::CR_NO_P_CHECK); _screen->modifyScreenDim(11, xo, yo, dm->w, dm->h); - return (slot < 6) ? _savegameList[_savegameOffset + slot] : _vm->_saveLoadStrings[1]; + return (slot < 6) ? _savegameList[_savegameOffset + slot] : Common::String(); } -Common::String GUI_EoB::transferFileMenu(Common::String &target) { - updateSaveSlotsList(target, true); +bool GUI_EoB::transferFileMenu(Common::String &targetName, Common::String &selection) { + updateSaveSlotsList(targetName, true); _saveSlotsListUpdateNeeded = true; + selection.clear(); + + if (!_savegameListSize) + return false; const ScreenDim *dm = _screen->getScreenDim(11); int xo = dm->sx; @@ -2598,12 +2603,13 @@ Common::String GUI_EoB::transferFileMenu(Common::String &target) { messageDialogue(11, 65, 6); else { _screen->modifyScreenDim(11, xo, yo, dm->w, dm->h); - return _vm->getSavegameFilename(target, _saveSlotIdTemp[slot]); + selection = _vm->getSavegameFilename(targetName, _saveSlotIdTemp[slot]); + return true; } } while (_saveSlotIdTemp[slot] == -1); _screen->modifyScreenDim(11, xo, yo, dm->w, dm->h); - return _vm->_saveLoadStrings[1]; + return true; } void GUI_EoB::createScreenThumbnail(Graphics::Surface &dst) { diff --git a/engines/kyra/gui_eob.h b/engines/kyra/gui_eob.h index ec4000e52a..759ed641ce 100644 --- a/engines/kyra/gui_eob.h +++ b/engines/kyra/gui_eob.h @@ -73,7 +73,7 @@ public: // Transfer party void transferWaitBox(); Common::String transferTargetMenu(Common::Array<Common::String> &targets); - Common::String transferFileMenu(Common::String &target); + bool transferFileMenu(Common::String &targetName, Common::String &selection); // utilities for thumbnail creation void createScreenThumbnail(Graphics::Surface &dst); |