From b7f7635876d3621b11d66cddca9babc1b5f1a1c6 Mon Sep 17 00:00:00 2001 From: athrxx Date: Sun, 6 Nov 2011 17:35:27 +0100 Subject: KYRA: (EOB) - implement memorize/pray spells menu --- engines/kyra/chargen.cpp | 30 ++-- engines/kyra/eobcommon.cpp | 2 - engines/kyra/eobcommon.h | 10 +- engines/kyra/gui_eob.cpp | 324 +++++++++++++++++++++++++++++++++++++++-- engines/kyra/gui_eob.h | 13 +- engines/kyra/magic_eob.cpp | 1 + engines/kyra/resource.h | 8 +- engines/kyra/saveload_eob.cpp | 6 +- engines/kyra/scene_eob.cpp | 3 +- engines/kyra/staticres_eob.cpp | 30 +++- engines/kyra/timer_eob.cpp | 2 +- 11 files changed, 379 insertions(+), 50 deletions(-) (limited to 'engines') diff --git a/engines/kyra/chargen.cpp b/engines/kyra/chargen.cpp index 380cc12a62..3147fbb850 100644 --- a/engines/kyra/chargen.cpp +++ b/engines/kyra/chargen.cpp @@ -172,7 +172,7 @@ bool CharacterGenerator::start(EobCharacter *characters, uint8 ***faceShapes) { _activeBox = 0; for (bool loop = true; loop && (!_vm->shouldQuit()); ) { - _vm->_gui->highLightBoxFrame(_activeBox + 6); + _vm->_gui->updateBoxFrameHighLight(_activeBox + 6); _vm->sound()->process(); int inputFlag = _vm->checkInput(_vm->_activeButtons, false, 0); _vm->removeInputTop(); @@ -187,7 +187,7 @@ bool CharacterGenerator::start(EobCharacter *characters, uint8 ***faceShapes) { _vm->sound()->haltTrack(); return false; } - _vm->_gui->highLightBoxFrame(-1); + _vm->_gui->updateBoxFrameHighLight(-1); } if (inputFlag & 0x8000) { @@ -201,7 +201,7 @@ bool CharacterGenerator::start(EobCharacter *characters, uint8 ***faceShapes) { } if (inputFlag == _vm->_keyMap[Common::KEYCODE_RETURN] || inputFlag == _vm->_keyMap[Common::KEYCODE_SPACE] || inputFlag == _vm->_keyMap[Common::KEYCODE_KP5]) { - _vm->_gui->highLightBoxFrame(-1); + _vm->_gui->updateBoxFrameHighLight(-1); if (_characters[_activeBox].name[0]) { int b = _activeBox; if (viewDeleteCharacter()) @@ -379,12 +379,12 @@ int CharacterGenerator::viewDeleteCharacter() { initButtonsFromList(0, 7); _vm->removeInputTop(); - _vm->_gui->highLightBoxFrame(-1); + _vm->_gui->updateBoxFrameHighLight(-1); printStats(_activeBox, 2); int res = 0; for (bool loop = true; loop && _characters[_activeBox].name[0] && !_vm->shouldQuit(); ) { - _vm->_gui->highLightBoxFrame(_activeBox + 6); + _vm->_gui->updateBoxFrameHighLight(_activeBox + 6); _vm->sound()->process(); int inputFlag = _vm->checkInput(_vm->_activeButtons, false, 0); @@ -423,14 +423,14 @@ int CharacterGenerator::viewDeleteCharacter() { } if (loop == false) - _vm->_gui->highLightBoxFrame(-1); + _vm->_gui->updateBoxFrameHighLight(-1); if (!_characters[cbx].name[0]) loop = false; if (cbx != _activeBox) { _activeBox = cbx; - _vm->_gui->highLightBoxFrame(-1); + _vm->_gui->updateBoxFrameHighLight(-1); if (loop) printStats(_activeBox, 2); } @@ -753,8 +753,8 @@ void CharacterGenerator::statsAndFacesMenu() { } } - _vm->_gui->highLightBoxFrame(6 + _activeBox); - _vm->_gui->highLightBoxFrame(-1); + _vm->_gui->updateBoxFrameHighLight(6 + _activeBox); + _vm->_gui->updateBoxFrameHighLight(-1); } void CharacterGenerator::faceSelectMenu() { @@ -769,7 +769,7 @@ void CharacterGenerator::faceSelectMenu() { printStats(_activeBox, 4); toggleSpecialButton(12, 0, 0); toggleSpecialButton(13, 0, 0); - _vm->_gui->highLightBoxFrame(-1); + _vm->_gui->updateBoxFrameHighLight(-1); shp = getNextFreeFaceShape(shp, charSex, 1, _chargenSelectedPortraits); @@ -793,7 +793,7 @@ void CharacterGenerator::faceSelectMenu() { in = _vm->checkInput(_vm->_activeButtons, false, 0); _vm->removeInputTop(); - _vm->_gui->highLightBoxFrame(box + 10); + _vm->_gui->updateBoxFrameHighLight(box + 10); if (in == 0x8002 || in == _vm->_keyMap[Common::KEYCODE_RIGHT]) { processSpecialButton(13); @@ -813,7 +813,7 @@ void CharacterGenerator::faceSelectMenu() { } } - _vm->_gui->highLightBoxFrame(-1); + _vm->_gui->updateBoxFrameHighLight(-1); if (in == 1) shp = getNextFreeFaceShape(shp - 1, charSex, -1, _chargenSelectedPortraits); @@ -824,7 +824,7 @@ void CharacterGenerator::faceSelectMenu() { } if (!_vm->shouldQuit()) { - _vm->_gui->highLightBoxFrame(-1); + _vm->_gui->updateBoxFrameHighLight(-1); updateMagicShapes(); _chargenSelectedPortraits[_activeBox] = sp[res]; @@ -859,7 +859,7 @@ int CharacterGenerator::getNextFreeFaceShape(int shpIndex, int charSex, int step } void CharacterGenerator::processFaceMenuSelection(int index) { - _vm->_gui->highLightBoxFrame(-1); + _vm->_gui->updateBoxFrameHighLight(-1); if (index <= 48) _screen->drawShape(0, _characters[_activeBox].faceShape, _chargenBoxX[_activeBox], _chargenBoxY[_activeBox] + 1, 0); else @@ -1403,7 +1403,7 @@ const EobRect8 CharacterGenerator::_chargenButtonBodyCoords[] = { { 0x14, 0x90, 0x0B, 0x10 } }; -const EobRect16 GUI_Eob::_highLightBoxFrames[] = { +const EobRect16 GUI_Eob::_updateBoxFrameHighLights[] = { { 0x00B7, 0x0001, 0x00F7, 0x0034 }, { 0x00FF, 0x0001, 0x013F, 0x0034 }, { 0x00B7, 0x0035, 0x00F7, 0x0068 }, diff --git a/engines/kyra/eobcommon.cpp b/engines/kyra/eobcommon.cpp index 7ec988ef1e..04739c2735 100644 --- a/engines/kyra/eobcommon.cpp +++ b/engines/kyra/eobcommon.cpp @@ -344,8 +344,6 @@ Common::Error EobCoreEngine::go() { _screen->setMouseCursor(0, 0, _itemIconShapes[0]); _screen->showMouse(); - //initPlayBuffers - loadItemDefs(); int action = 0; diff --git a/engines/kyra/eobcommon.h b/engines/kyra/eobcommon.h index 8b97ab361d..27e0dc9545 100644 --- a/engines/kyra/eobcommon.h +++ b/engines/kyra/eobcommon.h @@ -1006,11 +1006,13 @@ protected: const char *const *_menuStringsSpellNo; const uint8 *_spellLevelsMage; + int _spellLevelsMageSize; const uint8 *_spellLevelsCleric; - const uint8 *_spellLevelsMps1; - const uint8 *_spellLevelsMps2; - const uint8 *_spellLevelsMps3; - const uint8 *_spellLevelsMps4; + int _spellLevelsClericSize; + const uint8 *_numSpellsCleric; + const uint8 *_numSpellsWisAdj; + const uint8 *_numSpellsPal; + const uint8 *_numSpellsMage; // sound void snd_playSoundEffect(int id, int volume=0xFF); diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index 4fe5b6bed9..5d86b9c589 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -1445,11 +1445,18 @@ GUI_Eob::GUI_Eob(EobCoreEngine *vm) : GUI_v1(vm), _vm(vm), _screen(vm->_screen) _cflag = 0xffff; _menuLineSpacing = 0; - _menuUnk1 = 0; + //_menuUnk1 = 0; _menuLastInFlags = 0; _menuCur = 0; _menuNumItems = 0; + _numPages = (_vm->game() == GI_EOB2) ? 8 : 5; + _numVisPages = (_vm->game() == GI_EOB2) ? 6 : 5; + _clericSpellAvltyFlags = (_vm->game() == GI_EOB2) ? 0xf7ffffff : 0x7bffff; + _paladinSpellAvltyFlags = (_vm->game() == GI_EOB2) ? 0xa9bbd1d : 0x800ff2; + _numAssignedSpellsOfType = new int8[72]; + memset(_numAssignedSpellsOfType, 0, 72); + _charSelectRedraw = false; _updateBoxIndex = -1; @@ -1463,6 +1470,8 @@ GUI_Eob::~GUI_Eob() { delete _menuStringsPrefsTemp[i]; delete[] _menuStringsPrefsTemp; } + + delete[] _numAssignedSpellsOfType; } void GUI_Eob::processButton(Button *button) { @@ -1970,7 +1979,7 @@ void GUI_Eob::simpleMenu_setup(int sd, int maxItem, const char *const *strings, _screen->updateScreen(); _menuLineSpacing = lineSpacing; - _menuUnk1 = 0; + //_menuUnk1 = 0; _menuLastInFlags = 0; _vm->removeInputTop(); } @@ -2284,7 +2293,7 @@ int GUI_Eob::runLoadMenu(int x, int y) { return 0; } -void GUI_Eob::highLightBoxFrame(int box) { +void GUI_Eob::updateBoxFrameHighLight(int box) { static const uint8 colorTable[] = { 0x0F, 0xB0, 0xB2, 0xB4, 0xB6, 0xB8, 0xBA, 0xBC, 0x0C, 0xBC, 0xBA, 0xB8, 0xB6, 0xB4, 0xB2, 0xB0, 0x00 }; @@ -2299,7 +2308,7 @@ void GUI_Eob::highLightBoxFrame(int box) { if (!colorTable[_updateBoxColorIndex]) _updateBoxColorIndex = 0; - const EobRect16 *r = &_highLightBoxFrames[_updateBoxIndex]; + const EobRect16 *r = &_updateBoxFrameHighLights[_updateBoxIndex]; _screen->drawBox(r->x1, r->y1, r->x2, r->y2, colorTable[_updateBoxColorIndex++]); _screen->updateScreen(); @@ -2307,7 +2316,7 @@ void GUI_Eob::highLightBoxFrame(int box) { } else { if (_updateBoxIndex != -1) { - const EobRect16 *r = &_highLightBoxFrames[_updateBoxIndex]; + const EobRect16 *r = &_updateBoxFrameHighLights[_updateBoxIndex]; _screen->drawBox(r->x1, r->y1, r->x2, r->y2, 12); _screen->updateScreen(); } @@ -2458,9 +2467,283 @@ void GUI_Eob::runSaveMenu() { } void GUI_Eob::runMemorizePrayMenu(int charIndex, int spellType) { + if (charIndex == -1) + return; + + uint8 np[8]; + memset(np, 0, sizeof(np)); + uint32 avltyFlags = 0; + int li = 0; + int lv = 0; + + EobCharacter *c = &_vm->_characters[charIndex]; + int8 wm = c->wisdomCur - 12; + if (wm < 0) + wm = 0; + + if (spellType) { + li = _vm->getCharacterLevelIndex(2, c->cClass); + + if (li == -1) { + li = _vm->getCharacterLevelIndex(4, c->cClass); + + if (li != -1) { + lv = c->level[li] - 1; + if (lv < 0) + lv = 0; + + for (int i = 0; i < _numPages; i++) + np[i] = _vm->_numSpellsPal[lv * _numPages + i]; + + avltyFlags = _paladinSpellAvltyFlags; + } + + } else { + lv = c->level[li] - 1; + for (int i = 0; i < _numPages; i++) { + np[i] = _vm->_numSpellsCleric[lv * _numPages + i]; + if (np[i]) + np[i] += _vm->_numSpellsWisAdj[wm * _numPages + i]; + } + avltyFlags = _clericSpellAvltyFlags; + } + + } else { + li = _vm->getCharacterLevelIndex(1, c->cClass); + + if (li == -1) { + if (_vm->checkInventoryForRings(charIndex, 1)) { + np[3] <<= 1; + np[4] <<= 1; + } + + } else { + lv = c->level[li] - 1; + for (int i = 0; i < _numPages; i++) + np[i] = _vm->_numSpellsMage[lv * _numPages + i]; + + avltyFlags = c->mageSpellsAvailabilityFlags; + } + } + + int8 *menuSpellMap = new int8[88]; + memset(menuSpellMap, 0, 88); + int8 *numAssignedSpellsPerBookPage = new int8[8]; + memset(numAssignedSpellsPerBookPage, 0, 8); + memset(_numAssignedSpellsOfType, 0, 72); + int8 *lh = new int8[40]; + memset(lh, 0, 40); + + memcpy(lh, spellType ? _vm->_spellLevelsCleric : _vm->_spellLevelsMage, spellType ? _vm->_spellLevelsClericSize : _vm->_spellLevelsMageSize); + int8 *charSpellList = spellType ? c->clericSpells : c->mageSpells; + + for (int i = 0; i < 80; i++) { + int8 s = charSpellList[i]; + if (s == 0 || s == _vm->_spellLevelsClericSize) + continue; + + if (s < 0) + s = -s; + else + _numAssignedSpellsOfType[s * 2 - 1]++; + + s--; + _numAssignedSpellsOfType[s * 2]++; + numAssignedSpellsPerBookPage[lh[s] - 1]++; + } + + for (int i = 0; i < 32; i++) { + if (!(avltyFlags & (1 << i))) + continue; + + int d = lh[i] - 1; + if (d < 0) + continue; + + if (!spellType || (spellType && np[d])) { + menuSpellMap[d * 11]++; + menuSpellMap[d * 11 + menuSpellMap[d * 11]] = i + 1; + } + } + + Button *buttonList = initMenu(4); + + int lastHighLightText = -1; + int lastHighLightButton = -1; + int newHighLightButton = 0; + int newHighLightText = 0; + bool updateDesc = true; + bool updateList = true; + + for (bool runLoop = true; runLoop && !_vm->shouldQuit(); ) { + updateBoxFrameHighLight(charIndex); + + if (newHighLightButton < 0) + newHighLightButton = 7; + if (newHighLightButton > 7) + newHighLightButton = 0; + + Button *b = 0; + + if (lastHighLightButton != newHighLightButton) { + if (lastHighLightButton >= 0) + drawMenuButton(_vm->gui_getButton(buttonList, lastHighLightButton + 26), false, false, true); + drawMenuButton(_vm->gui_getButton(buttonList, newHighLightButton + 26), false, true, true); + newHighLightText = 0; + lastHighLightText = -1; + lastHighLightButton = newHighLightButton; + updateDesc = updateList = true; + } + + if (updateList) { + updateList = false; + _screen->setCurPage(2); + for (int ii = 1; ii < 9; ii++) + memorizePrayMenuPrintString(menuSpellMap[lastHighLightButton * 11 + ii], ii - 1, spellType, false, false); + + _screen->setCurPage(0); + _screen->copyRegion(0, 50, 0, 50, 176, 72, 2, 0, Screen::CR_NO_P_CHECK); + lastHighLightText = -1; + } + + if (updateDesc) { + updateDesc = false; + _screen->printShadedText(Common::String::format(_vm->_menuStringsMgc[1], np[lastHighLightButton] - numAssignedSpellsPerBookPage[lastHighLightButton], np[lastHighLightButton]).c_str(), 8, 38, 9, _vm->_bkgColor_1); + } + + if (newHighLightText < 0) + newHighLightText = menuSpellMap[lastHighLightButton * 11] - 1; + + if (menuSpellMap[lastHighLightButton * 11] <= newHighLightText) + newHighLightText = 0; + + if (newHighLightText != lastHighLightText) { + memorizePrayMenuPrintString(menuSpellMap[lastHighLightButton * 11 + lastHighLightText + 1], lastHighLightText, spellType, true, false); + memorizePrayMenuPrintString(menuSpellMap[lastHighLightButton * 11 + newHighLightText + 1], newHighLightText, spellType, true, true); + lastHighLightText = newHighLightText; + } + + int inputFlag = _vm->checkInput(buttonList, false, 0) & 0x80ff; + _vm->removeInputTop(); + + if (inputFlag == _vm->_keyMap[Common::KEYCODE_KP6] || inputFlag == _vm->_keyMap[Common::KEYCODE_RIGHT]) { + inputFlag = 0x801a + ((lastHighLightButton + 1) % _numVisPages); + } else if (inputFlag == _vm->_keyMap[Common::KEYCODE_KP4] || inputFlag == _vm->_keyMap[Common::KEYCODE_LEFT]) { + inputFlag = lastHighLightButton ? 0x8019 + lastHighLightButton : 0x8019 + _numVisPages; + } else if (inputFlag == _vm->_keyMap[Common::KEYCODE_ESCAPE]) { + inputFlag = 0x8018; + } else { + Common::Point p = _vm->getMousePos(); + if (_vm->posWithinRect(p.x, p.y, 8, 50, 168, 122)) { + newHighLightText = (p.y - 50 ) / 9; + if (menuSpellMap[lastHighLightButton * 11] - 1 < newHighLightText) + newHighLightText = menuSpellMap[lastHighLightButton * 11] - 1; + } + } + + if (inputFlag & 0x8000) { + Button *b = _vm->gui_getButton(buttonList, inputFlag & 0x7fff); + drawMenuButton(b, true, true, true); + _screen->updateScreen(); + _vm->_system->delayMillis(80); + drawMenuButton(b, false, false, true); + _screen->updateScreen(); + } + if (inputFlag == 0x8019 || inputFlag == _vm->_keyMap[Common::KEYCODE_KP_PLUS] || inputFlag == _vm->_keyMap[Common::KEYCODE_PLUS] || inputFlag == _vm->_keyMap[Common::KEYCODE_KP5] || inputFlag == _vm->_keyMap[Common::KEYCODE_SPACE] || inputFlag == _vm->_keyMap[Common::KEYCODE_RETURN]) { + if (np[lastHighLightButton] > numAssignedSpellsPerBookPage[lastHighLightButton] && lastHighLightText != -1) { + _numAssignedSpellsOfType[menuSpellMap[lastHighLightButton * 11 + lastHighLightText + 1] * 2 - 2]++; + numAssignedSpellsPerBookPage[lastHighLightButton]++; + memorizePrayMenuPrintString(menuSpellMap[lastHighLightButton * 11 + lastHighLightText + 1], lastHighLightText, spellType, false, true); + updateDesc = true; + } + + } else if (inputFlag == _vm->_keyMap[Common::KEYCODE_KP_MINUS] || inputFlag == _vm->_keyMap[Common::KEYCODE_MINUS] /*|| inputFlag == _vm->_keyMap[Common::KEYCODE_*/) { + if (np[lastHighLightButton] && _numAssignedSpellsOfType[menuSpellMap[lastHighLightButton * 11 + lastHighLightText + 1] * 2 - 2]) { + _numAssignedSpellsOfType[menuSpellMap[lastHighLightButton * 11 + lastHighLightText + 1] * 2 - 2]--; + numAssignedSpellsPerBookPage[lastHighLightButton]--; + memorizePrayMenuPrintString(menuSpellMap[lastHighLightButton * 11 + lastHighLightText + 1], lastHighLightText, spellType, false, true); + updateDesc = true; + } + + } else if (inputFlag == _vm->_keyMap[Common::KEYCODE_UP] || inputFlag == _vm->_keyMap[Common::KEYCODE_KP8]) { + newHighLightText = lastHighLightText - 1; + } else if (inputFlag == _vm->_keyMap[Common::KEYCODE_DOWN] || inputFlag == _vm->_keyMap[Common::KEYCODE_KP2]) { + newHighLightText = lastHighLightText + 1; + } else if (inputFlag == _vm->_keyMap[Common::KEYCODE_END] || inputFlag == _vm->_keyMap[Common::KEYCODE_KP1]) { + newHighLightText = menuSpellMap[lastHighLightButton * 11] - 1; + } else if (inputFlag == _vm->_keyMap[Common::KEYCODE_HOME] || inputFlag == _vm->_keyMap[Common::KEYCODE_KP7]) { + newHighLightText = 0; + } else if (inputFlag == 0x8017) { + if (numAssignedSpellsPerBookPage[lastHighLightButton]) { + for (int i = 1; i <= menuSpellMap[lastHighLightButton * 11]; i++) { + numAssignedSpellsPerBookPage[lastHighLightButton] -= _numAssignedSpellsOfType[menuSpellMap[lastHighLightButton * 11 + i] * 2 - 2]; + _numAssignedSpellsOfType[menuSpellMap[lastHighLightButton * 11 + i] * 2 - 2] = 0; + } + + updateDesc = updateList = true; + } + + } else if (inputFlag == 0x8018) { + _vm->gui_drawAllCharPortraitsWithStats(); + runLoop = false; + + } else if (inputFlag & 0x8000) { + newHighLightButton = inputFlag - 0x801a; + if (newHighLightButton == lastHighLightButton) + drawMenuButton(_vm->gui_getButton(buttonList, inputFlag & 0x7fff), false, true, true); + } + } + + releaseButtons(buttonList); + updateBoxFrameHighLight(-1); + + _screen->setFont(Screen::FID_6_FNT); + _vm->gui_drawCharPortraitWithStats(charIndex); + _screen->setFont(Screen::FID_8_FNT); + + memset(charSpellList, 0, 80); + if (spellType) + charSpellList[0] = _vm->_spellLevelsClericSize; + + for (int i = 0; i < 32; i++) { + if (_numAssignedSpellsOfType[i * 2] < _numAssignedSpellsOfType[i * 2 + 1]) + _numAssignedSpellsOfType[i * 2 + 1] = _numAssignedSpellsOfType[i * 2]; + + if (_numAssignedSpellsOfType[i * 2 + 1]) { + _numAssignedSpellsOfType[i * 2]--; + _numAssignedSpellsOfType[i * 2 + 1]--; + + int pg = lh[i] - 1; + for (int ii = 0; ii < 10; ii++) { + if (!charSpellList[pg * 10 + ii]) { + charSpellList[pg * 10 + ii] = i + 1; + break; + } + } + i--; + + } else if (_numAssignedSpellsOfType[i * 2]) { + _numAssignedSpellsOfType[i * 2]--; + + _vm->_resting = true; + int pg = lh[i] - 1; + for (int ii = 0; ii < 10; ii++) { + if (!charSpellList[pg * 10 + ii]) { + charSpellList[pg * 10 + ii] = -(i + 1); + break; + } + } + i--; + } + } + + delete[] menuSpellMap; + delete[] numAssignedSpellsPerBookPage; + delete[] lh; } + void GUI_Eob::scribeScrollDialogue() { } @@ -2606,10 +2889,10 @@ int GUI_Eob::selectCharacterDialogue(int id) { int inputFlag = _vm->checkInput(buttonList, false, 0); _vm->removeInputTop(); - highLightBoxFrame(hlCur); + updateBoxFrameHighLight(hlCur); if (inputFlag == _vm->_keyMap[Common::KEYCODE_KP4] || inputFlag == _vm->_keyMap[Common::KEYCODE_LEFT] || inputFlag == _vm->_keyMap[Common::KEYCODE_KP8] || inputFlag == _vm->_keyMap[Common::KEYCODE_UP] || inputFlag == _vm->_keyMap[Common::KEYCODE_a] || inputFlag == _vm->_keyMap[Common::KEYCODE_w]) { - highLightBoxFrame(-1); + updateBoxFrameHighLight(-1); _vm->gui_drawCharPortraitWithStats(hlCur--); if (hlCur < 0) hlCur = 5; @@ -2619,7 +2902,7 @@ int GUI_Eob::selectCharacterDialogue(int id) { } } else if (inputFlag == _vm->_keyMap[Common::KEYCODE_KP6] || inputFlag == _vm->_keyMap[Common::KEYCODE_RIGHT] || inputFlag == _vm->_keyMap[Common::KEYCODE_KP2] || inputFlag == _vm->_keyMap[Common::KEYCODE_DOWN] || inputFlag == _vm->_keyMap[Common::KEYCODE_z] || inputFlag == _vm->_keyMap[Common::KEYCODE_s]) { - highLightBoxFrame(-1); + updateBoxFrameHighLight(-1); _vm->gui_drawCharPortraitWithStats(hlCur++); if (hlCur == 6) hlCur = 0; @@ -2649,7 +2932,7 @@ int GUI_Eob::selectCharacterDialogue(int id) { } } - highLightBoxFrame(-1); + updateBoxFrameHighLight(-1); if (hlCur >= 0) _vm->gui_drawCharPortraitWithStats(hlCur); @@ -2718,7 +3001,10 @@ Button *GUI_Eob::initMenu(int id) { for (int i = 0; i < m->numButtons; i++) { const EobMenuButtonDef *df = &_vm->_menuButtonDefs[m->firstButtonStrId + i]; Button *b = new Button; - b->index = m->firstButtonStrId + i + 1; + b->index = m->firstButtonStrId + i + 1; + if (id == 4 && _vm->game() == GI_EOB1) + b->index -= 14; + b->data0Val2 = 12; b->data1Val2 = b->data2Val2 = 15; b->data3Val2 = 8; @@ -2782,6 +3068,24 @@ void GUI_Eob::drawMenuButtonBox(int x, int y, int w, int h, bool clicked, bool n _vm->gui_drawBox(x + 1, y + 1, w - 2, h - 2, _vm->_color1_1, _vm->_color2_1, noFill ? -1 : _vm->_bkgColor_1); } +void GUI_Eob::memorizePrayMenuPrintString(int spellId, int bookPageIndex, int spellType, bool noFill, bool highLight) { + if (bookPageIndex < 0) + return; + + int y = bookPageIndex * 9 + 50; + + if (spellId) { + Common::String s(Common::String::format(_vm->_menuStringsMgc[0], spellType ? _vm->_clericSpellList[spellId] : _vm->_mageSpellList[spellId], _numAssignedSpellsOfType[spellId * 2 - 2])); + if (noFill) + _screen->printText(s.c_str(), 8, y, highLight ? 6 : 15, 0); + else + _screen->printShadedText(s.c_str(), 8, y, highLight ? 6 : 15, _vm->_bkgColor_1); + + } else { + _screen->fillRect(6, y, 168, y + 8, _vm->_bkgColor_1); + } +} + void GUI_Eob::updateOptionsStrings() { for (int i = 0; i < 4; i++) { delete _menuStringsPrefsTemp[i]; diff --git a/engines/kyra/gui_eob.h b/engines/kyra/gui_eob.h index bb446f75a0..6d4edfde24 100644 --- a/engines/kyra/gui_eob.h +++ b/engines/kyra/gui_eob.h @@ -62,7 +62,7 @@ public: void runCampMenu(); int runLoadMenu(int x, int y); - void highLightBoxFrame(int box); + void updateBoxFrameHighLight(int box); int getTextInput(char *dest, int x, int y, int destMaxLen, int textColor1, int textColor2, int cursorColor); @@ -89,6 +89,7 @@ private: Button *initMenu(int id); void drawMenuButton(Button *b, bool clicked, bool highlight, bool noFill); void drawMenuButtonBox(int x, int y, int w, int h, bool clicked, bool noFill); + void memorizePrayMenuPrintString(int spellId, int bookPageIndex, int spellType, bool noFill, bool highLight); void updateOptionsStrings(); const char *getMenuString(int id); @@ -118,9 +119,15 @@ private: Button::Callback _scrollDownFunctor; int _menuLineSpacing; - int _menuUnk1; + //int _menuUnk1; int _menuLastInFlags; + uint8 _numPages; + uint8 _numVisPages; + int8 *_numAssignedSpellsOfType; + uint32 _clericSpellAvltyFlags; + uint32 _paladinSpellAvltyFlags; + int _menuCur; int _menuNumItems; bool _charSelectRedraw; @@ -128,7 +135,7 @@ private: int _updateBoxIndex; int _updateBoxColorIndex; uint32 _highLightBoxTimer; - static const EobRect16 _highLightBoxFrames[]; + static const EobRect16 _updateBoxFrameHighLights[]; // unused Button *getButtonListData() { return 0; } diff --git a/engines/kyra/magic_eob.cpp b/engines/kyra/magic_eob.cpp index 8b6de927bf..77971da441 100644 --- a/engines/kyra/magic_eob.cpp +++ b/engines/kyra/magic_eob.cpp @@ -201,6 +201,7 @@ void EobCoreEngine::castSpell(int spell, int weaponSlot) { } void EobCoreEngine::removeCharacterEffect(int spell, int charIndex, int showWarning) { + assert(spell >= 0); EobCharacter *c = &_characters[charIndex]; EobSpell *s = &_spells[spell]; diff --git a/engines/kyra/resource.h b/engines/kyra/resource.h index 5d9554c31f..441199ce6b 100644 --- a/engines/kyra/resource.h +++ b/engines/kyra/resource.h @@ -323,10 +323,10 @@ enum KyraResources { kEobBaseSpellLevelsMage, kEobBaseSpellLevelsCleric, - kEobBaseSpellMps1, - kEobBaseSpellMps2, - kEobBaseSpellMps3, - kEobBaseSpellMps4, + kEobBaseNumSpellsCleric, + kEobBaseNumSpellsWisAdj, + kEobBaseNumSpellsPal, + kEobBaseNumSpellsMage, kEobBaseCharGuiStringsHp, kEobBaseCharGuiStringsWp1, diff --git a/engines/kyra/saveload_eob.cpp b/engines/kyra/saveload_eob.cpp index 85b94cd3d4..497be6fdce 100644 --- a/engines/kyra/saveload_eob.cpp +++ b/engines/kyra/saveload_eob.cpp @@ -352,6 +352,8 @@ Common::Error EobCoreEngine::loadGameState(int slot) { } if (_saveLoadMode != -1) { + if (_flags.gameID == GI_EOB1) + _screen->loadPalette("EOBPAL.COL", _screen->getPalette(0)); loadLevel(_currentLevel, _currentSub); _sceneUpdateRequired = true; _screen->setFont(Screen::FID_6_FNT); @@ -395,7 +397,6 @@ Common::Error EobCoreEngine::saveGameStateIntern(int slot, const char *saveName, for (int i = 0; i < 6; i++) { timerSpecialCharacterUpdate(0x30 + i); - uint32 ct = _system->getMillis(); EobCharacter *c = &_characters[i]; out->writeByte(c->id); @@ -432,8 +433,9 @@ Common::Error EobCoreEngine::saveGameStateIntern(int slot, const char *saveName, out->writeUint32BE(c->mageSpellsAvailabilityFlags); for (int ii = 0; ii < 27; ii++) out->writeSint16BE(c->inventory[ii]); + uint32 ct = _system->getMillis(); for (int ii = 0; ii < 10; ii++) - out->writeUint32BE(c->timers[ii] ? c->timers[ii] - ct : 0); + out->writeUint32BE((c->timers[ii] && c->timers[ii] > ct) ? c->timers[ii] - ct : 0); out->write(c->events, 10); out->write(c->effectsRemainder, 4); diff --git a/engines/kyra/scene_eob.cpp b/engines/kyra/scene_eob.cpp index 56bf352b98..e92d813af9 100644 --- a/engines/kyra/scene_eob.cpp +++ b/engines/kyra/scene_eob.cpp @@ -740,10 +740,9 @@ Common::String EobCoreEngine::initLevelData(int sub){ pos += 11; _screen->setShapeFadeMode(0, false); _screen->setShapeFadeMode(1, false); - } //////////////////// + } else _screen->loadPalette(tmpStr.c_str(), _screen->getPalette(0)); - ////////////////////7 Palette backupPal(256); backupPal.copy(_screen->getPalette(0), 224, 32, 224); diff --git a/engines/kyra/staticres_eob.cpp b/engines/kyra/staticres_eob.cpp index 7908bc28ee..e348ef2616 100644 --- a/engines/kyra/staticres_eob.cpp +++ b/engines/kyra/staticres_eob.cpp @@ -388,12 +388,12 @@ void EobCoreEngine::initStaticResource() { _menuStringsSpec = _staticres->loadStrings(kEobBaseMenuStringsSpec, temp); _menuStringsSpellNo = _staticres->loadStrings(kEobBaseMenuStringsSpellNo, temp); - _spellLevelsMage = _staticres->loadRawData(kEobBaseSpellLevelsMage, temp); - _spellLevelsCleric = _staticres->loadRawData(kEobBaseSpellLevelsCleric, temp); - _spellLevelsMps1 = _staticres->loadRawData(kEobBaseSpellMps1, temp); - _spellLevelsMps2 = _staticres->loadRawData(kEobBaseSpellMps2, temp); - _spellLevelsMps3 = _staticres->loadRawData(kEobBaseSpellMps3, temp); - _spellLevelsMps4 = _staticres->loadRawData(kEobBaseSpellMps4, temp); + _spellLevelsMage = _staticres->loadRawData(kEobBaseSpellLevelsMage, _spellLevelsMageSize); + _spellLevelsCleric = _staticres->loadRawData(kEobBaseSpellLevelsCleric, _spellLevelsClericSize); + _numSpellsCleric = _staticres->loadRawData(kEobBaseNumSpellsCleric, temp); + _numSpellsWisAdj = _staticres->loadRawData(kEobBaseNumSpellsWisAdj, temp); + _numSpellsPal = _staticres->loadRawData(kEobBaseNumSpellsPal, temp); + _numSpellsMage = _staticres->loadRawData(kEobBaseNumSpellsMage, temp); _characterGuiStringsHp = _staticres->loadStrings(kEobBaseCharGuiStringsHp, temp); _characterGuiStringsWp = _staticres->loadStrings(_flags.gameID == GI_EOB2 ? kEobBaseCharGuiStringsWp2 : kEobBaseCharGuiStringsWp1, temp); @@ -656,7 +656,17 @@ void EobCoreEngine::initMenus() { { 38, 16, 57, 32, 14, 22, 7 }, { 39, 128, 57, 32, 14, 51, 7 }, { 8, 128, 126, 40, 14, 19, 7 }, - { 0, 0, 50, 168, 72, 61, 0 } + { 0, 0, 50, 168, 72, 61, 0 }, + // EOB 1 memorize/pray menu: + { 36, 8, 126, 48, 14, 48, 5 }, + { 8, 128, 126, 40, 14, 19, 5 }, + { 0, 0, 50, 168, 72, 61, 0 }, + { 31, 8, 16, 24, 20, 2, 5 }, + { 32, 40, 16, 24, 20, 3, 5 }, + { 33, 72, 16, 24, 20, 4, 5 }, + { 34, 104, 16, 24, 20, 5, 5 }, + { 35, 136, 16, 24, 20, 6, 5 }, + { 31, 8, 16, 24, 20, 2, 5 } }; _menuButtonDefs = buttonDefs; @@ -674,6 +684,12 @@ void EobCoreEngine::initMenus() { delete[] _menuDefs; _menuDefs = new EobMenuDef[ARRAYSIZE(menuDefs)]; memcpy(_menuDefs, menuDefs, sizeof(menuDefs)); + + if (_flags.gameID == GI_EOB1) { + // assign EOB 1 style memorize/pray menu + _menuDefs[4].numButtons = 8; + _menuDefs[4].firstButtonStrId = 36; + } } diff --git a/engines/kyra/timer_eob.cpp b/engines/kyra/timer_eob.cpp index 70b89bee9c..f6e8b63dc1 100644 --- a/engines/kyra/timer_eob.cpp +++ b/engines/kyra/timer_eob.cpp @@ -264,7 +264,7 @@ void EobCoreEngine::timerSpecialCharacterUpdate(int timerNum) { int evt = c->events[i]; if (evt < 0) { - removeCharacterEffect(evt, charIndex, 1); + removeCharacterEffect(-evt, charIndex, 1); continue; } -- cgit v1.2.3