KYRA: (EOB) - improved eob target detection in transfer party dialog

(parse domains instead of save files)
This commit is contained in:
athrxx 2012-01-03 17:25:10 +01:00 committed by unknown
parent 4fd0e9e94b
commit 76dec42469
3 changed files with 40 additions and 57 deletions

View File

@ -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) {
Common::Array<Common::String> eobTargets;
const Common::ConfigManager::DomainMap dom = ConfMan.getGameDomains();
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 (!(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::StringArray::iterator ii = targets.begin();
for (; ii != targets.end(); ++ii) {
if (!i->compareToIgnoreCase(*ii))
break;
}
if (ii == targets.end())
targets.push_back(*i);
}
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() {

View File

@ -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) {

View File

@ -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);