diff options
Diffstat (limited to 'engines/kyra')
-rw-r--r-- | engines/kyra/chargen.cpp | 412 | ||||
-rw-r--r-- | engines/kyra/eobcommon.cpp | 5 | ||||
-rw-r--r-- | engines/kyra/eobcommon.h | 3 | ||||
-rw-r--r-- | engines/kyra/gui_eob.cpp | 104 | ||||
-rw-r--r-- | engines/kyra/gui_eob.h | 3 | ||||
-rw-r--r-- | engines/kyra/items_eob.cpp | 2 | ||||
-rw-r--r-- | engines/kyra/resource.h | 6 | ||||
-rw-r--r-- | engines/kyra/saveload_eob.cpp | 68 | ||||
-rw-r--r-- | engines/kyra/staticres_eob.cpp | 11 |
9 files changed, 504 insertions, 110 deletions
diff --git a/engines/kyra/chargen.cpp b/engines/kyra/chargen.cpp index b326f92caf..16911a3ddd 100644 --- a/engines/kyra/chargen.cpp +++ b/engines/kyra/chargen.cpp @@ -69,7 +69,7 @@ private: void finish(); uint8 **_chargenMagicShapes; - uint8 **_chargenButtonLabels; + uint8 *_chargenButtonLabels[17]; int _activeBox; int _magicShapesBox; int _updateBoxShapesIndex; @@ -115,7 +115,7 @@ private: }; CharacterGenerator::CharacterGenerator(EoBCoreEngine *vm, Screen_EoB *screen) : _vm(vm), _screen(screen), - _characters(0), _faceShapes(0), _chargenMagicShapes(0), _chargenButtonLabels(0), _chargenMagicShapeTimer(0), + _characters(0), _faceShapes(0), _chargenMagicShapes(0), _chargenMagicShapeTimer(0), _updateBoxShapesIndex(0), _lastUpdateBoxShapesIndex(0), _magicShapesBox(6), _activeBox(0) { _chargenStatStrings = _vm->_chargenStatStrings; @@ -145,11 +145,8 @@ CharacterGenerator::~CharacterGenerator() { delete[] _chargenMagicShapes; } - if (_chargenButtonLabels) { - for (int i = 0; i < 17; i++) - delete[] _chargenButtonLabels[i]; - delete[] _chargenButtonLabels; - } + for (int i = 0; i < 17; i++) + delete[] _chargenButtonLabels[i]; } bool CharacterGenerator::start(EoBCharacter *characters, uint8 ***faceShapes) { @@ -261,7 +258,6 @@ void CharacterGenerator::init() { for (int i = 0; i < 10; i++) _chargenMagicShapes[i] = _screen->encodeShape(i << 2, 0, 4, 32, true); - _chargenButtonLabels = new uint8*[17]; for (int i = 0; i < 17; i++) { const CreatePartyModButton *c = &_chargenModButtons[i]; _chargenButtonLabels[i] = c->labelW? _screen->encodeShape(c->encodeLabelX, c->encodeLabelY, c->labelW, c->labelH, true) : 0; @@ -1322,12 +1318,8 @@ void CharacterGenerator::finish() { _chargenMagicShapes = 0; } - if (_chargenButtonLabels) { - for (int i = 0; i < 17; i++) - delete[] _chargenButtonLabels[i]; - delete[] _chargenButtonLabels; - _chargenButtonLabels = 0; - } + for (int i = 0; i < 17; i++) + delete[] _chargenButtonLabels[i]; } const EoBChargenButtonDef CharacterGenerator::_chargenButtonDefs[] = { @@ -1444,17 +1436,45 @@ private: bool selectAndLoadTransferFile(); Common::String transferFileDialogue(); + int selectCharactersMenu(); + void drawCharPortraitWithStats(int charIndex, bool enabled); + void updateHighlight(int index); + void convertStats(); + void convertInventory(); + Item convertItem(Item eob1Item); + void giveKhelbensCoin(); EoBCoreEngine *_vm; Screen_EoB *_screen; + + int _highlight; + EoBItem *_oldItems; + + const uint16 *_portraitFrames; + const uint8 *_convertTable; + const uint8 *_itemTable; + const uint32 *_expTable; + const char *const *_strings1; + const char *const *_strings2; + const char *const *_labels; }; TransferPartyWiz::TransferPartyWiz(EoBCoreEngine *vm, Screen_EoB *screen) : _vm(vm), _screen(screen) { + int temp; + _portraitFrames = _vm->staticres()->loadRawDataBe16(kEoB2TransferPortraitFrames, temp); + _convertTable = _vm->staticres()->loadRawData(kEoB2TransferConvertTable, temp); + _itemTable = _vm->staticres()->loadRawData(kEoB2TransferItemTable, temp); + _expTable = _vm->staticres()->loadRawDataBe32(kEoB2TransferExpTable, temp); + _strings1 = _vm->staticres()->loadStrings(kEoB2TransferStrings1, temp); + _strings2 = _vm->staticres()->loadStrings(kEoB2TransferStrings2, temp); + _labels = _vm->staticres()->loadStrings(kEoB2TransferLabels, temp); + _highlight = -1; + _oldItems = 0; } TransferPartyWiz::~TransferPartyWiz() { - + delete[] _oldItems; } bool TransferPartyWiz::start() { @@ -1465,11 +1485,39 @@ bool TransferPartyWiz::start() { convertStats(); + _oldItems = new EoBItem[600]; + memcpy(_oldItems, _vm->_items, sizeof(EoBItem) * 600); + _vm->loadItemDefs(); + + int selection = selectCharactersMenu(); + if (selection == 0) { + for (int i = 0; i < 6; i++) + delete[] _vm->_characters[i].faceShape; + memset(_vm->_characters, 0, sizeof(EoBCharacter) * 6); + return false; + } + + int ch = 0; + for (int i = 0; i < 6; i++) { + if (selection & (1 << i)) { + if (ch != i) { + delete[] _vm->_characters[ch].faceShape; + memcpy(&_vm->_characters[ch], &_vm->_characters[i], sizeof(EoBCharacter)); + _vm->_characters[i].faceShape = 0; + } + ch++; + } + } + memset(&_vm->_characters[4], 0, sizeof(EoBCharacter) * 2); + + convertInventory(); + giveKhelbensCoin(); + return true; } bool TransferPartyWiz::selectAndLoadTransferFile() { - for (int numLoops = 1; numLoops; numLoops--) { + for (int numLoops = 1; numLoops; numLoops--) { _screen->copyPage(12, 0); _vm->_savegameFilename = transferFileDialogue(); if (_vm->_savegameFilename.empty()) { @@ -1493,9 +1541,14 @@ Common::String TransferPartyWiz::transferFileDialogue() { Common::String tfile; KyraEngine_v1::SaveHeader header; + memset(&header, 0, sizeof(KyraEngine_v1::SaveHeader)); Common::InSaveFile *in; + _vm->_gui->transferWaitBox(); + for (Common::StringArray::iterator i = saveFileList.begin(); i != saveFileList.end(); ++i) { + _vm->updateInput(); + if (!(in = _vm->_saveFileMan->openForLoading(*i))) continue; @@ -1546,6 +1599,170 @@ Common::String TransferPartyWiz::transferFileDialogue() { return tfile; } +int TransferPartyWiz::selectCharactersMenu() { + _screen->setCurPage(2); + _screen->setFont(Screen::FID_6_FNT); + _screen->clearCurPage(); + + _vm->gui_drawBox(0, 0, 320, 163, _vm->_color1_1, _vm->_color2_1, _vm->_bkgColor_1); + _screen->printText(_strings2[0], 5, 3, 15, 0); + _screen->printText(_strings2[1], 5, 10, 15, 0); + + for (int i = 0; i < 6; i++) + drawCharPortraitWithStats(i, 0); + + _vm->gui_drawBox(4, 148, 43, 12, _vm->_color1_1, _vm->_color2_1, _vm->_bkgColor_1); + _vm->gui_drawBox(272, 148, 43, 12, _vm->_color1_1, _vm->_color2_1, _vm->_bkgColor_1); + + _screen->printShadedText(_labels[0], 9, 151, 15, 0); + _screen->printShadedText(_labels[1], 288, 151, 15, 0); + + _screen->setCurPage(0); + _screen->copyRegion(0, 0, 0, 0, 320, 200, 2, 0, Screen::CR_NO_P_CHECK); + _screen->updateScreen(); + + int selection = 0; + int highlight = 0; + bool update = false; + + for (bool loop = true; loop && (!_vm->shouldQuit()); ) { + int inputFlag = _vm->checkInput(0, false, 0) & 0x8ff; + _vm->removeInputTop(); + + if (inputFlag) { + if (inputFlag == _vm->_keyMap[Common::KEYCODE_LEFT] || inputFlag == _vm->_keyMap[Common::KEYCODE_RIGHT]) { + highlight ^= 1; + } else if (inputFlag == _vm->_keyMap[Common::KEYCODE_UP]) { + highlight -= 2; + if (highlight < 0) + highlight += 8; + } else if (inputFlag == _vm->_keyMap[Common::KEYCODE_DOWN]) { + highlight += 2; + if (highlight >= 8) + highlight -= 8; + } else if (inputFlag == _vm->_keyMap[Common::KEYCODE_RETURN] || inputFlag == _vm->_keyMap[Common::KEYCODE_SPACE]) { + update = true; + } else if (inputFlag == _vm->_keyMap[Common::KEYCODE_ESCAPE]) { + update = true; + highlight = 6; + } else if (inputFlag == 199) { + for (int i = 0; i < 8; i++) { + int t = i << 2; + if (_vm->posWithinRect(_vm->_mouseX, _vm->_mouseY, _portraitFrames[t], _portraitFrames[t + 1], _portraitFrames[t + 2], _portraitFrames[t + 3])) { + highlight = i; + update = true; + break; + } + } + } + } + + updateHighlight(highlight); + + if (!update) + continue; + + update = false; + + if (highlight < 6) { + if (_vm->_characters[highlight].flags & 1) { + selection ^= (1 << highlight); + drawCharPortraitWithStats(highlight, (selection & (1 << highlight)) ? true : false); + _screen->updateScreen(); + } + continue; + } + + int x = (highlight - 6) * 268 + 4; + _vm->gui_drawBox(x, 148, 43, 12, _vm->_bkgColor_1, _vm->_bkgColor_1, -1); + _screen->updateScreen(); + _vm->_system->delayMillis(80); + _vm->gui_drawBox(x, 148, 43, 12, _vm->_color1_1, _vm->_color2_1, -1); + _screen->updateScreen(); + + if (highlight == 6 || _vm->shouldQuit()) { + _screen->setFont(Screen::FID_8_FNT); + return 0; + } + + int count = 0; + for (int i = 0; i < 6; i++) { + if (selection & (1 << i)) + count++; + } + + if (count == 4 || _vm->shouldQuit()) + loop = false; + else + _vm->_gui->messageDialogue(16, count < 4 ? 69 : 70, 6); + + _screen->updateScreen(); + } + + _screen->setFont(Screen::FID_8_FNT); + if (_vm->shouldQuit()) + return 0; + else + _vm->_gui->messageDialogue(16, 71, 6); + + return selection; +} + +void TransferPartyWiz::drawCharPortraitWithStats(int charIndex, bool enabled) { + int16 x = (charIndex % 2) * 159; + int16 y = (charIndex / 2) * 40; + EoBCharacter *c = &_vm->_characters[charIndex]; + + _screen->fillRect(x + 4, y + 24, x + 36, y + 57, 12); + _vm->gui_drawBox(x + 40, y + 24, 118, 34, _vm->_color1_1, _vm->_color2_1, _vm->_bkgColor_1); + + if (!(c->flags & 1)) + return; + + _screen->drawShape(_screen->_curPage, c->faceShape, x + 4, y + 25, 0); + + int color1 = 15; + int color2 = 12; + + if (enabled) { + color1 = 6; + color2 = 15; + } else { + _screen->drawShape(_screen->_curPage, _vm->_disabledCharGrid, x + 4, y + 25, 0); + } + + _screen->printShadedText(c->name, x + 44, y + 27, color1, 0); + _screen->printText(_vm->_chargenRaceSexStrings[c->raceSex], x + 43, y + 36, color2, 0); + _screen->printText(_vm->_chargenClassStrings[c->cClass], x + 43, y + 43, color2, 0); + + Common::String tmp = Common::String::format(_strings1[0], c->level[0]); + for (int i = 1; i < _vm->_numLevelsPerClass[c->cClass]; i++) + tmp += Common::String::format(_strings1[1], c->level[i]); + _screen->printText(tmp.c_str(), x + 43, y + 50, color2, 0); +} + +void TransferPartyWiz::updateHighlight(int index) { + static const int16 xPos[] = { 9, 288 }; + if (_highlight > 5 && _highlight != index) + _screen->printText(_labels[_highlight - 6], xPos[_highlight - 6], 151, 15, 0); + + if (index < 6) { + _vm->_gui->updateBoxFrameHighLight(14 + index); + _highlight = index; + return; + } + + if (_highlight == index) + return; + + if (_highlight < 6) + _vm->_gui->updateBoxFrameHighLight(-1); + + _screen->printText(_labels[index - 6], xPos[index - 6], 151, 6, 0); + _screen->updateScreen(); + _highlight = index; +} + void TransferPartyWiz::convertStats() { for (int i = 0; i < 6; i++) { EoBCharacter *c = &_vm->_characters[i]; @@ -1553,25 +1770,182 @@ void TransferPartyWiz::convertStats() { for (int ii = 0; ii < 25; ii++) { if (c->mageSpellsAvailableFlags & (1 << ii)) { - int8 f = (int8)_vm->_transferConvertTable[i + 1] - 1; + int8 f = (int8)_convertTable[ii + 1] - 1; if (f != -1) aflags |= (1 << f); } } c->mageSpellsAvailableFlags = aflags; + c->armorClass = 0; + c->disabledSlots = 0; c->flags &= 1; c->hitPointsCur = c->hitPointsMax; c->food = 100; + c->effectFlags = 0; + c->damageTaken = 0; + memset(c->clericSpells, 0, sizeof(int8) * 80); + memset(c->mageSpells, 0, sizeof(int8) * 80); + memset(c->timers, 0, sizeof(uint32) * 10); + memset(c->events, 0, sizeof(int8) * 10); + memset(c->effectsRemainder, 0, sizeof(uint8) * 4); + memset(c->slotStatus, 0, sizeof(int8) * 5); + for (int ii = 0; ii < 3; ii++) { int t = _vm->getCharacterClassType(c->cClass, ii); if (t == -1) continue; - if (c->experience[ii] < _vm->_transferExpTable[t]) - c->experience[ii] = _vm->_transferExpTable[t]; + if (c->experience[ii] > _expTable[t]) + c->experience[ii] = _expTable[t]; + } + } +} + +void TransferPartyWiz::convertInventory() { + for (int i = 0; i < 4; i++) { + EoBCharacter *c = &_vm->_characters[i]; + + for (int slot = 0; slot < 27; slot++) { + Item itm = c->inventory[slot]; + if (slot == 16) { + Item first = itm; + c->inventory[slot] = 0; + + for (bool forceLoop = true; (itm && (itm != first)) || forceLoop; itm = _oldItems[itm].prev) { + forceLoop = false; + _vm->setItemPosition(&c->inventory[slot], -2, convertItem(itm), 0); + } + } else { + c->inventory[slot] = convertItem(itm); + } + } + } +} + +Item TransferPartyWiz::convertItem(Item eob1Item) { + if (!eob1Item) + return 0; + + EoBItem *itm1 = &_oldItems[eob1Item]; + + if (!_itemTable[itm1->type]) + return 0; + + Item newItem = _vm->duplicateItem(1); + EoBItem *itm2 = &_vm->_items[newItem]; + bool match = false; + + itm2->flags = itm1->flags | 0x40; + itm2->icon = itm1->icon; + itm2->type = itm1->type; + itm2->level = 0xff; + + switch(itm2->type) { + case 35: + itm1->value += 25; + // fall through + case 34: + itm2->value = _convertTable[itm1->value]; + if (!itm2->value) { + itm2->block = -1; + return 0; + } + break; + case 39: + itm2->value = itm1->value - 1; + break; + case 48: + if (itm1->value == 5) { + memset(itm2, 0, sizeof(EoBItem)); + itm2->block = -1; + return 0; + } + itm2->value = itm1->value; + itm2->flags = ((itm1->flags & 0x3f) + 3) | 0x40; + break; + case 18: + itm2->icon = 19; + // fall through + default: + itm2->value = itm1->value; + break; + } + + switch ((_vm->_itemTypes[itm2->type].extraProperties & 0x7f) - 1) { + case 0: + case 1: + case 2: + if (itm2->value) + itm2->flags |= 0x80; + break; + case 4: + case 5: + case 8: + case 9: + case 13: + case 15: + case 17: + itm2->flags |= 0x80; + break; + default: + break; + } + + for (int i = 1; i < 600; i++) { + if (i == 60 || i == 62 || i == 63 || i == 83) + continue; + EoBItem *tmp = &_vm->_items[i]; + if (tmp->level || tmp->block == -2 || tmp->type != itm2->type || tmp->icon != itm2->icon) + continue; + itm2->nameUnid = tmp->nameUnid; + itm2->nameId = tmp->nameId; + match = true; + break; + } + + if (!match) { + for (int i = 1; i < 600; i++) { + if (i == 60 || i == 62 || i == 63 || i == 83) + continue; + EoBItem *tmp = &_vm->_items[i]; + if (tmp->level || tmp->block == -2 || tmp->type != itm2->type) + continue; + itm2->nameUnid = tmp->nameUnid; + itm2->nameId = tmp->nameId; + match = true; + break; } } + + if (!match) { + memset(itm2, 0, sizeof(EoBItem)); + itm2->block = -1; + return 0; + } + + itm2->level = 0; + return newItem; +} + +void TransferPartyWiz::giveKhelbensCoin() { + bool success = false; + for (int i = 0; i < 4 && !success; i++) { + EoBCharacter *c = &_vm->_characters[i]; + + for (int slot = 2; slot < 16; slot++) { + if (c->inventory[slot]) + continue; + _vm->createInventoryItem(c, 93, -1, slot); + success = true; + break; + } + } + + if (!success) { + _vm->_characters[0].inventory[2] = 0; + _vm->createInventoryItem(&_vm->_characters[0], 93, -1, 2); + } } // Start functions diff --git a/engines/kyra/eobcommon.cpp b/engines/kyra/eobcommon.cpp index c64f60b3fd..f3e644b89d 100644 --- a/engines/kyra/eobcommon.cpp +++ b/engines/kyra/eobcommon.cpp @@ -64,9 +64,6 @@ EoBCoreEngine::EoBCoreEngine(OSystem *system, const GameFlags &flags) : KyraRpgE _beholderSpellList = 0; _beholderSfx = 0; - _transferConvertTable = 0; - _transferExpTable = 0; - _faceShapes = 0; _characters = 0; _items = 0; @@ -470,7 +467,7 @@ Common::Error EoBCoreEngine::go() { } } - if (!shouldQuit() && action > -3) { + if (!shouldQuit() && action >= -3) { runLoop(); if (_playFinale) { diff --git a/engines/kyra/eobcommon.h b/engines/kyra/eobcommon.h index f489f8742b..399eff7775 100644 --- a/engines/kyra/eobcommon.h +++ b/engines/kyra/eobcommon.h @@ -331,9 +331,6 @@ protected: const uint8 *_classModifierFlags; - const uint8 *_transferConvertTable; - const uint32 *_transferExpTable; - // timers void setupTimers(); void setCharEventTimer(int charIndex, uint32 countdown, int evnt, int updateExistingTimer); diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index ab92e08046..080af941df 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -2308,6 +2308,46 @@ bool GUI_EoB::confirmDialogue2(int dim, int id, int deflt) { return newHighlight ? false : true; } +void GUI_EoB::messageDialogue(int dim, int id, int buttonTextCol) { + int od = _screen->curDimIndex(); + _screen->setScreenDim(dim); + Screen::FontId of = _screen->setFont(Screen::FID_8_FNT); + + drawTextBox(dim, id); + const ScreenDim *dm = _screen->getScreenDim(dim); + + int bx = ((dm->sx + dm->w) << 3) - ((strlen(_vm->_menuOkString) << 3) + 16); + int by = dm->sy + dm->h - 19; + int bw = (strlen(_vm->_menuOkString) << 3) + 7; + + drawMenuButtonBox(bx, by, bw, 14, false, false); + _screen->printShadedText(_vm->_menuOkString, bx + 4, by + 3, buttonTextCol, 0); + _screen->updateScreen(); + + for (bool runLoop = true; runLoop && !_vm->shouldQuit(); ) { + int inputFlag = _vm->checkInput(0, false, 0) & 0x8ff; + _vm->removeInputTop(); + + if (inputFlag == 199 || inputFlag == 201) { + if (_vm->posWithinRect(_vm->_mouseX, _vm->_mouseY, bx, by, bx + bw, by + 14)) + runLoop = false; + } else if (inputFlag == _vm->_keyMap[Common::KEYCODE_SPACE] || inputFlag == _vm->_keyMap[Common::KEYCODE_RETURN] || inputFlag == _vm->_keyMap[Common::KEYCODE_o]) { + runLoop = false; + } + } + + drawMenuButtonBox(bx, by, bw, 14, true, true); + _screen->updateScreen(); + _vm->_system->delayMillis(80); + drawMenuButtonBox(bx, by, bw, 14, false, true); + _screen->updateScreen(); + + _screen->copyRegion(0, dm->h, dm->sx << 3, dm->sy, dm->w << 3, dm->h, 2, 0, Screen::CR_NO_P_CHECK); + _screen->setScreenDim(od); + _screen->setFont(of); + dm = _screen->getScreenDim(dim); +} + void GUI_EoB::messageDialogue2(int dim, int id, int buttonTextCol) { drawMenuButtonBox(_screen->_curDim->sx << 3, _screen->_curDim->sy, _screen->_curDim->w << 3, _screen->_curDim->h, false, false); @@ -2496,6 +2536,15 @@ int GUI_EoB::getTextInput(char *dest, int x, int y, int destMaxLen, int textColo return _keyPressed.keycode == Common::KEYCODE_ESCAPE ? -1 : len; } +void GUI_EoB::transferWaitBox() { + const ScreenDim *dm = _screen->getScreenDim(11); + int xo = dm->sx; + int yo = dm->sy; + _screen->modifyScreenDim(11, dm->sx + 9, dm->sy + 24, dm->w, dm->h); + displayTextBox(-4); + _screen->modifyScreenDim(11, xo, yo, dm->w, dm->h); +} + Common::String GUI_EoB::transferTargetMenu(Common::Array<Common::String> &targets) { _savegameListSize = targets.size(); if (_savegameList) { @@ -2542,13 +2591,14 @@ Common::String GUI_EoB::transferFileMenu(Common::String &target) { int slot = 0; do { slot = selectSaveSlotDialogue(72, 14, 4); - if (slot < 6) { - if (_saveSlotIdTemp[slot] == -1) - messageDialogue(11, 65, 6); - else { - _screen->modifyScreenDim(11, xo, yo, dm->w, dm->h); - return _vm->getSavegameFilename(target, _saveSlotIdTemp[slot]); - } + if (slot == 6) + break; + + if (_saveSlotIdTemp[slot] == -1) + messageDialogue(11, 65, 6); + else { + _screen->modifyScreenDim(11, xo, yo, dm->w, dm->h); + return _vm->getSavegameFilename(target, _saveSlotIdTemp[slot]); } } while (_saveSlotIdTemp[slot] == -1); @@ -3488,46 +3538,6 @@ bool GUI_EoB::confirmDialogue(int id) { return result; } -void GUI_EoB::messageDialogue(int dim, int id, int buttonTextCol) { - int od = _screen->curDimIndex(); - _screen->setScreenDim(dim); - Screen::FontId of = _screen->setFont(Screen::FID_8_FNT); - - drawTextBox(dim, id); - const ScreenDim *dm = _screen->getScreenDim(dim); - - int bx = ((dm->sx + dm->w) << 3) - ((strlen(_vm->_menuOkString) << 3) + 16); - int by = dm->sy + dm->h - 19; - int bw = (strlen(_vm->_menuOkString) << 3) + 7; - - drawMenuButtonBox(bx, by, bw, 14, false, false); - _screen->printShadedText(_vm->_menuOkString, bx + 4, by + 3, buttonTextCol, 0); - _screen->updateScreen(); - - for (bool runLoop = true; runLoop && !_vm->shouldQuit(); ) { - int inputFlag = _vm->checkInput(0, false, 0) & 0x8ff; - _vm->removeInputTop(); - - if (inputFlag == 199 || inputFlag == 201) { - if (_vm->posWithinRect(_vm->_mouseX, _vm->_mouseY, bx, by, bx + bw, by + 14)) - runLoop = false; - } else if (inputFlag == _vm->_keyMap[Common::KEYCODE_SPACE] || inputFlag == _vm->_keyMap[Common::KEYCODE_RETURN] || inputFlag == _vm->_keyMap[Common::KEYCODE_o]) { - runLoop = false; - } - } - - drawMenuButtonBox(bx, by, bw, 14, true, true); - _screen->updateScreen(); - _vm->_system->delayMillis(80); - drawMenuButtonBox(bx, by, bw, 14, false, true); - _screen->updateScreen(); - - _screen->copyRegion(0, dm->h, dm->sx << 3, dm->sy, dm->w << 3, dm->h, 2, 0, Screen::CR_NO_P_CHECK); - _screen->setScreenDim(od); - _screen->setFont(of); - dm = _screen->getScreenDim(dim); -} - int GUI_EoB::selectCharacterDialogue(int id) { uint8 flags = (id == 26) ? (_vm->game() == GI_EOB1 ? 0x04 : 0x14) : 0x02; _vm->removeInputTop(); diff --git a/engines/kyra/gui_eob.h b/engines/kyra/gui_eob.h index d8ce9bd234..ec4000e52a 100644 --- a/engines/kyra/gui_eob.h +++ b/engines/kyra/gui_eob.h @@ -63,6 +63,7 @@ public: bool runLoadMenu(int x, int y); bool confirmDialogue2(int dim, int id, int deflt); + void messageDialogue(int dim, int id, int buttonTextCol); void messageDialogue2(int dim, int id, int buttonTextCol); void updateBoxFrameHighLight(int box); @@ -70,6 +71,7 @@ public: int getTextInput(char *dest, int x, int y, int destMaxLen, int textColor1, int textColor2, int cursorColor); // Transfer party + void transferWaitBox(); Common::String transferTargetMenu(Common::Array<Common::String> &targets); Common::String transferFileMenu(Common::String &target); @@ -88,7 +90,6 @@ private: bool restParty(); bool confirmDialogue(int id); - void messageDialogue(int dim, int id, int buttonTextCol); int selectCharacterDialogue(int id); void displayTextBox(int id); diff --git a/engines/kyra/items_eob.cpp b/engines/kyra/items_eob.cpp index 28764dfe20..c58fd0835c 100644 --- a/engines/kyra/items_eob.cpp +++ b/engines/kyra/items_eob.cpp @@ -30,6 +30,7 @@ namespace Kyra { void EoBCoreEngine::loadItemDefs() { Common::SeekableReadStream *s = _res->createReadStream("item.dat"); + memset(_items, 0, sizeof(EoBItem) * 600); _numItems = s->readUint16LE(); for (int i = 0; i < 600; i++) @@ -58,6 +59,7 @@ void EoBCoreEngine::loadItemDefs() { s = _res->createReadStream("itemtype.dat"); uint16 numTypes = s->readUint16LE(); + delete[] _itemTypes; _itemTypes = new EoBItemType[65]; memset(_itemTypes, 0, sizeof(EoBItemType) * 65); diff --git a/engines/kyra/resource.h b/engines/kyra/resource.h index 45c18517a9..5b0af9840d 100644 --- a/engines/kyra/resource.h +++ b/engines/kyra/resource.h @@ -537,8 +537,14 @@ enum KyraResources { kEoB1Npc7Strings, kEoB2MainMenuStrings, + + kEoB2TransferPortraitFrames, kEoB2TransferConvertTable, + kEoB2TransferItemTable, kEoB2TransferExpTable, + kEoB2TransferStrings1, + kEoB2TransferStrings2, + kEoB2TransferLabels, kEoB2IntroStrings, kEoB2IntroCPSFiles, diff --git a/engines/kyra/saveload_eob.cpp b/engines/kyra/saveload_eob.cpp index 714033b569..1f982aa3ab 100644 --- a/engines/kyra/saveload_eob.cpp +++ b/engines/kyra/saveload_eob.cpp @@ -74,7 +74,7 @@ Common::Error EoBCoreEngine::loadGameState(int slot) { c->alignment = in.readByte(); c->portrait = in.readSByte(); if (slot == -1 && c->portrait < 0) - c->portrait += 43; + c->portrait = -c->portrait + 43; c->food = in.readByte(); in.read(c->level, 3); for (int ii = 0; ii < 3; ii++) @@ -118,35 +118,37 @@ Common::Error EoBCoreEngine::loadGameState(int slot) { } _screen->_curPage = 0; - // No more data required for party transfer - if (slot == -1) - return Common::kNoError; - - _currentLevel = in.readByte(); - _currentSub = in.readSByte(); - _currentBlock = in.readUint16BE(); - _currentDirection = in.readUint16BE(); - _itemInHand = in.readSint16BE(); - _hasTempDataFlags = in.readUint32BE(); - _partyEffectFlags = in.readUint32BE(); - - _updateFlags = in.readUint16BE(); - _compassDirection = in.readUint16BE(); - _currentControlMode = in.readUint16BE(); - _updateCharNum = in.readUint16BE(); - _openBookSpellLevel = in.readSByte(); - _openBookSpellSelectedItem = in.readSByte(); - _openBookSpellListOffset = in.readSByte(); - _openBookChar = in.readByte(); - _openBookType = in.readByte(); - _openBookCharBackup = in.readByte(); - _openBookTypeBackup = in.readByte(); - _activeSpellCharId = in.readByte(); - _activeSpellCharacterPos = in.readByte(); - _activeSpell = in.readByte(); - _returnAfterSpellCallback = in.readByte() ? true : false; - - _inf->loadState(in); + if (slot == -1) { + // Skip all settings which aren't necessary for party transfer. + // Jump directly to the items list. + in.skip(108); + } else { + _currentLevel = in.readByte(); + _currentSub = in.readSByte(); + _currentBlock = in.readUint16BE(); + _currentDirection = in.readUint16BE(); + _itemInHand = in.readSint16BE(); + _hasTempDataFlags = in.readUint32BE(); + _partyEffectFlags = in.readUint32BE(); + + _updateFlags = in.readUint16BE(); + _compassDirection = in.readUint16BE(); + _currentControlMode = in.readUint16BE(); + _updateCharNum = in.readUint16BE(); + _openBookSpellLevel = in.readSByte(); + _openBookSpellSelectedItem = in.readSByte(); + _openBookSpellListOffset = in.readSByte(); + _openBookChar = in.readByte(); + _openBookType = in.readByte(); + _openBookCharBackup = in.readByte(); + _openBookTypeBackup = in.readByte(); + _activeSpellCharId = in.readByte(); + _activeSpellCharacterPos = in.readByte(); + _activeSpell = in.readByte(); + _returnAfterSpellCallback = in.readByte() ? true : false; + + _inf->loadState(in); + } for (int i = 0; i < 600; i++) { EoBItem *t = &_items[i]; @@ -163,6 +165,12 @@ Common::Error EoBCoreEngine::loadGameState(int slot) { t->value = in.readSByte(); } + // No more data needed for party transfer + if (slot == -1) { + _loading = false; + return Common::kNoError; + } + for (int i = 51; i < 65; i++) { EoBItemType *t = &_itemTypes[i]; t->invFlags = in.readUint16BE(); diff --git a/engines/kyra/staticres_eob.cpp b/engines/kyra/staticres_eob.cpp index 8ab16f5da9..7bbe9f528f 100644 --- a/engines/kyra/staticres_eob.cpp +++ b/engines/kyra/staticres_eob.cpp @@ -1193,9 +1193,6 @@ void EoBEngine::initSpells() { void DarkMoonEngine::initStaticResource() { int temp; _mainMenuStrings = _staticres->loadStrings(kEoB2MainMenuStrings, temp); - _transferConvertTable = _staticres->loadRawData(kEoB2TransferConvertTable, temp); - _transferExpTable = _staticres->loadRawDataBe32(kEoB2TransferExpTable, temp); - _introStrings = _staticres->loadStrings(kEoB2IntroStrings, temp); _cpsFilesIntro = _staticres->loadStrings(kEoB2IntroCPSFiles, temp); @@ -1252,16 +1249,18 @@ void DarkMoonEngine::initStaticResource() { _errorSlotNoNameString = errorSlotNoNameString[(_flags.lang == Common::EN_ANY) ? 0 : ((_flags.lang == Common::DE_DEU) ? 1 : 2)]; // ScummVM specific - static const char *transferStringsScummVM[3][4] = { + static const char *transferStringsScummVM[3][5] = { { "\r We cannot find any EOB save game\r file. Please make sure that the\r save game file with the party\r you wish to transfer is located\r in your ScummVM save game\r directory. If you have set up\r multiple save directories you\r have to copy the EOB save file\r into your EOB II save directory.\r Do you wish to try again?", "Game ID", "\r It seems that you have already\r defeated Xanathar here. Do you\r wish to transfer the party that\r finished the game? If not, you\r will be able to select a save\r game from the save game\r dialogue.", - "Select File" + "Select File", + "\r\r Please wait..." }, { "\r Kein EOB-Spielstand zu finden.\r Bitte Spielstandsdatei mit der\r zu ]bernehmenden Gruppe in das\r ScummVM Spielstands-Verzeichnis\r kopieren. Bei mehreren Spiel-\r stands-Verzeichnissen bitte\r den EOB-Spielstand in das\r EOB II-Spielstands-Verzeichnis\r kopieren. Nochmal versuchen?", "Game ID", "\r Wie es scheint, wurde Xanathar\r hier bereits besiegt. Soll die\r Gruppe, mit der das Spiel be-\r endet wurde, ]bernommen werden?\r Falls nicht, kann ein Spielstand\r aus der Spielstandsliste gew[hlt\r werden.", - "Spiel W[hlen" + "Spiel W[hlen", + "\r\r Bitte warten..." }, { 0, 0, 0, 0 } |