From 540d081a6fd4daa31f746ddf30ccc91fb88ea04b Mon Sep 17 00:00:00 2001 From: athrxx Date: Sun, 11 Dec 2011 01:57:03 +0100 Subject: KYRA: (EOB) - initial code base commit --- engines/kyra/gui_eob.cpp | 2165 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 2165 insertions(+) create mode 100644 engines/kyra/gui_eob.cpp (limited to 'engines/kyra/gui_eob.cpp') diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp new file mode 100644 index 0000000000..9aafb76189 --- /dev/null +++ b/engines/kyra/gui_eob.cpp @@ -0,0 +1,2165 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#if defined(ENABLE_EOB) || defined(ENABLE_LOL) + +#include "kyra/eobcommon.h" +#include "kyra/gui_eob.h" +#include "kyra/timer.h" +#include "kyra/util.h" + +#include "common/system.h" + +namespace Kyra { + +void LolEobBaseEngine::removeInputTop() { + if (!_eventList.empty()) { + if (_eventList.begin()->event.type == Common::EVENT_LBUTTONDOWN) + _mouseClick = 1; + else if (_eventList.begin()->event.type == Common::EVENT_RBUTTONDOWN) + _mouseClick = 2; + else + _mouseClick = 0; + + _eventList.erase(_eventList.begin()); + } +} + +void LolEobBaseEngine::gui_drawBox(int x, int y, int w, int h, int frameColor1, int frameColor2, int fillColor) { + w--; h--; + if (fillColor != -1) + screen()->fillRect(x + 1, y + 1, x + w - 1, y + h - 1, fillColor); + + screen()->drawClippedLine(x + 1, y, x + w, y, frameColor2); + screen()->drawClippedLine(x + w, y, x + w, y + h - 1, frameColor2); + screen()->drawClippedLine(x, y, x, y + h, frameColor1); + screen()->drawClippedLine(x, y + h, x + w, y + h, frameColor1); +} + +void LolEobBaseEngine::gui_drawHorizontalBarGraph(int x, int y, int w, int h, int32 cur, int32 max, int col1, int col2) { + if (max < 1) + return; + if (cur < 0) + cur = 0; + + int32 e = MIN(cur, max); + + if (!--w) + return; + if (!--h) + return; + + int32 t = (e * w) / max; + + if (!t && e) + t++; + + if (t) + screen()->fillRect(x, y, x + t - 1, y + h, col1); + + if (t < w && col2) + screen()->fillRect(x + t, y, x + w, y + h, col2); +} + +void LolEobBaseEngine::gui_initButtonsFromList(const int16 *list) { + while (*list != -1) + gui_initButton(*list++); +} + +void LolEobBaseEngine::gui_resetButtonList() { + for (uint i = 0; i < ARRAYSIZE(_activeButtonData); ++i) + _activeButtonData[i].nextButton = 0; + + gui_notifyButtonListChanged(); + _activeButtons = 0; +} + +void LolEobBaseEngine::gui_notifyButtonListChanged() { + if (gui()) { + if (!_buttonListChanged && !_preserveEvents) + removeInputTop(); + _buttonListChanged = true; + } +} + +bool LolEobBaseEngine::clickedShape(int shapeIndex) { + if (_clickedSpecialFlag != 0x40) + return true; + + for (; shapeIndex; shapeIndex = _levelDecorationProperties[shapeIndex].next) { + if (_flags.gameID != GI_LOL) + shapeIndex--; + + uint16 s = _levelDecorationProperties[shapeIndex].shapeIndex[1]; + + if (s == 0xffff) + continue; + + int w = _flags.gameID == GI_LOL ? _levelDecorationShapes[s][3] : (_levelDecorationShapes[s][2] << 3); + int h = _levelDecorationShapes[s][_flags.gameID == GI_LOL ? 2 : 1]; + int x = _levelDecorationProperties[shapeIndex].shapeX[1] + _clickedShapeXOffs; + int y = _levelDecorationProperties[shapeIndex].shapeY[1] + _clickedShapeYOffs; + + if (_levelDecorationProperties[shapeIndex].flags & 1) { + if (_flags.gameID == GI_LOL) + w <<= 1; + else + x = 176 - x - w; + } + + if (posWithinRect(_mouseX, _mouseY, x - 4, y - 4, x + w + 8, y + h + 8)) + return true; + } + + return false; +} + +#ifdef ENABLE_EOB + +Button *EobCoreEngine::gui_getButton(Button *buttonList, int index) { + while (buttonList) { + if (buttonList->index == index) + return buttonList; + buttonList = buttonList->nextButton; + } + + return 0; +} + +void EobCoreEngine::gui_drawPlayField(int pageNum) { + _screen->loadEobCpsFileToPage("PLAYFLD", 0, 5, 3, 2); + int cp = _screen->setCurPage(2); + gui_drawCompass(true); + + if (pageNum && !_sceneDrawPage1) + drawScene(0); + + _screen->setCurPage(cp); + _screen->copyRegion(0, 0, 0, 0, 320, 200, 2, 0, Screen::CR_NO_P_CHECK); + _screen->updateScreen(); + + _screen->loadEobCpsFileToPage("INVENT", 0, 5, 3, 2); +} + +void EobCoreEngine::gui_restorePlayField() { + loadVcnData(0, 0); + _screen->_curPage = 0; + gui_drawPlayField(1); + gui_drawAllCharPortraitsWithStats(); +} + +void EobCoreEngine::gui_drawAllCharPortraitsWithStats() { + for (int i = 0; i < 6; i++) + gui_drawCharPortraitWithStats(i); +} + +void EobCoreEngine::gui_drawCharPortraitWithStats(int index) { + if (!testCharacter(index, 1)) + return; + + static const uint16 charPortraitPosX[] = { 8, 80, 184, 256 }; + static const uint16 charPortraitPosY[] = { 2, 54, 106 }; + + EobCharacter *c = &_characters[index]; + int txtCol1 = 12; + int txtCol2 = 15; + + if ((_flags.gameID == GI_EOB1 && c->flags & 6) || (_flags.gameID == GI_EOB2 && c->flags & 0x0e)) { + txtCol1 = 8; + txtCol2 = 6; + } + + char tmpStr[10]; + + if (_currentControlMode == 0) { + int x2 = charPortraitPosX[index & 1]; + int y2 = charPortraitPosY[index >> 1]; + Screen::FontId cf = _screen->setFont(Screen::FID_6_FNT); + + _screen->copyRegion(176, 168, x2 , y2, 64, 24, 2, 2, Screen::CR_NO_P_CHECK); + _screen->copyRegion(240, 168, x2, y2 + 24, 64, 26, 2, 2, Screen::CR_NO_P_CHECK); + int cp = _screen->setCurPage(2); + + if (index == _exchangeCharacterId) + _screen->printText(_characterGuiStringsSt[0], x2 + 2, y2 + 2, 8, _bkgColor_1); + else + _screen->printText(c->name, x2 + 2, y2 + 2, txtCol1, _bkgColor_1); + + gui_drawFaceShape(index); + gui_drawWeaponSlot(index, 0); + gui_drawWeaponSlot(index, 1); + gui_drawHitpoints(index); + + if (testCharacter(index, 2)) + gui_drawCharPortraitStatusFrame(index); + + if (c->damageTaken > 0) { + _screen->drawShape(2, _redSplatShape, x2 + 13, y2 + 30, 0); + sprintf(tmpStr, "%d", c->damageTaken); + _screen->printText(tmpStr, x2 + 34 - (strlen(tmpStr) * 3), y2 + 42, 15, 0); + } + + _screen->setCurPage(cp); + _screen->setFont(cf); + + if (!cp) { + _screen->copyRegion(x2, y2, charPortraitPosX[2 + (index & 1)], y2, 64, 50, 2, 0, Screen::CR_NO_P_CHECK); + _screen->updateScreen(); + } + } else if ((_currentControlMode == 1 || _currentControlMode == 2) && index == _updateCharNum) { + _screen->copyRegion(176, 0, 0, 0, 144, 168, 2, 2, Screen::CR_NO_P_CHECK); + _screen->_curPage = 2; + gui_drawFaceShape(index); + _screen->printShadedText(c->name, 219, 6, txtCol2, _bkgColor_1); + gui_drawHitpoints(index); + gui_drawFoodStatusGraph(index); + + if (_currentControlMode == 1) { + if (c->hitPointsCur == -10) + _screen->printShadedText(_characterGuiStringsSt[1], 247, 158, 6, _color6); + else if (c->hitPointsCur < 1) + _screen->printShadedText(_characterGuiStringsSt[2], 226, 158, 6, _color6); + else if (c->effectFlags & (_flags.gameID == GI_EOB1 ? 0x80 : 0x2000)) + _screen->printShadedText(_characterGuiStringsSt[3], 220, 158, 6, _color6); + else if (c->flags & 2) + _screen->printShadedText(_characterGuiStringsSt[4], 235, 158, 6, _color6); + else if (c->flags & 4) + _screen->printShadedText(_characterGuiStringsSt[5], 232, 158, 6, _color6); + else if (c->flags & 8) + _screen->printShadedText(_characterGuiStringsSt[6], 232, 158, 6, _color6); + + for (int i = 0; i < 27; i++) + gui_drawInventoryItem(i, 0, 2); + gui_drawInventoryItem(16, 1, 2); + + } else { + static const uint16 cm2X1[] = { 179, 272, 301 }; + static const uint16 cm2Y1[] = { 36, 51, 51 }; + static const uint16 cm2X2[] = { 271, 300, 318 }; + static const uint16 cm2Y2[] = { 165, 165, 147 }; + + for (int i = 0; i < 3; i++) + _screen->fillRect(cm2X1[i], cm2Y1[i], cm2X2[i], cm2Y2[i], _color6); + + _screen->printShadedText(_characterGuiStringsIn[0], 183, 42, 15, _color6); + _screen->printText(_chargenClassStrings[c->cClass], 183, 55, 12, _color6); + _screen->printText(_chargenAlignmentStrings[c->alignment], 183, 62, 12, _color6); + _screen->printText(_chargenRaceSexStrings[c->raceSex], 183, 69, 12, _color6); + + for (int i = 0; i < 6; i++) + _screen->printText(_chargenStatStrings[6 + i], 183, 82 + i * 7, 12, _color6); + + _screen->printText(_characterGuiStringsIn[1], 183, 124, 12, _color6); + _screen->printText(_characterGuiStringsIn[2], 239, 138, 12, _color6); + _screen->printText(_characterGuiStringsIn[3], 278, 138, 12, _color6); + + _screen->printText(getCharStrength(c->strengthCur, c->strengthExtCur), 275, 82, 15, _color6); + sprintf(tmpStr, "%d", c->intelligenceCur); + _screen->printText(tmpStr, 275, 89, 15, _color6); + sprintf(tmpStr, "%d", c->wisdomCur); + _screen->printText(tmpStr, 275, 96, 15, _color6); + sprintf(tmpStr, "%d", c->dexterityCur); + _screen->printText(tmpStr, 275, 103, 15, _color6); + sprintf(tmpStr, "%d", c->constitutionCur); + _screen->printText(tmpStr, 275, 110, 15, _color6); + sprintf(tmpStr, "%d", c->charismaCur); + _screen->printText(tmpStr, 275, 117, 15, _color6); + sprintf(tmpStr, "%d", c->armorClass); + _screen->printText(tmpStr, 275, 124, 15, _color6); + + for (int i = 0; i < 3; i++) { + int t = getClassHpIncreaseType(c->cClass, i); + if (t == -1) + continue; + + _screen->printText(_chargenClassStrings[t + 15], 180, 145 + 7 * i, 12, _color6); + sprintf(tmpStr, "%d", c->experience[i]); + _screen->printText(tmpStr, 251 - strlen(tmpStr) * 3, 145 + 7 * i, 15, _color6); + sprintf(tmpStr, "%d", c->level[i]); + _screen->printText(tmpStr, 286 - strlen(tmpStr) * 3, 145 + 7 * i, 15, _color6); + } + } + + _screen->_curPage = 0; + _screen->copyRegion(176, 0, 176, 0, 144, 168, 2, 0, Screen::CR_NO_P_CHECK); + _screen->copyRegion(0, 0, 176, 0, 144, 168, 2, 2, Screen::CR_NO_P_CHECK); + _screen->updateScreen(); + } +} + +void EobCoreEngine::gui_drawFaceShape(int index) { + if (!testCharacter(index, 1)) + return; + + static const uint8 xCoords[] = { 8, 80 }; + static const uint8 yCoords[] = { 11, 63, 115 }; + + int x = xCoords[index & 1]; + int y = yCoords[index >> 1]; + + if (!_screen->_curPage) + x += 176; + + if (_currentControlMode) { + if (_updateCharNum != index) + return; + + x = 181; + y = 3; + } + + EobCharacter *c = &_characters[index]; + + if (c->hitPointsCur == -10) { + _screen->drawShape(_screen->_curPage, _deadCharShape, x, y, 0); + return; + } + + if (_flags.gameID == GI_EOB1) { + if (c->effectFlags & 4) { + _screen->fillRect(x, y, x + 31, y + 31, 12); + return; + } + } else { + if (c->effectFlags & 0x140) { + _screen->setFadeTableIndex(1); + _screen->setShapeFadeMode(1, true); + } + + if (c->flags & 2) { + _screen->setFadeTableIndex(0); + _screen->setShapeFadeMode(1, true); + } + + if (c->flags & 8) { + _screen->setFadeTableIndex(2); + _screen->setShapeFadeMode(1, true); + } + } + + _screen->drawShape(_screen->_curPage, c->faceShape, x, y, 0); + + if (c->hitPointsCur < 1) + _screen->drawShape(_screen->_curPage, _disabledCharGrid, x, y, 0); + + //if ((c->flags & 2) || (c->flags & 8) || (c->effectFlags & 0x140)) { + _screen->setFadeTableIndex(4); + _screen->setShapeFadeMode(1, false); + //} +} + +void EobCoreEngine::gui_drawWeaponSlot(int charIndex, int slot) { + static const uint8 xCoords[] = { 40, 112 }; + static const uint8 yCoords[] = { 11, 27, 63, 79, 115, 131 }; + + int x = xCoords[charIndex & 1]; + int y = yCoords[(charIndex & 6) + slot]; + + if (!_screen->_curPage) + x += 176; + + int itm = _characters[charIndex].inventory[slot]; + gui_drawBox(x, y, 31, 16, _color1_1, _color2_1, _bkgColor_1); + + if (_characters[charIndex].slotStatus[slot]) { + gui_drawWeaponSlotStatus(x, y, _characters[charIndex].slotStatus[slot]); + return; + } + + if (itm) + drawItemIconShape(_screen->_curPage, itm, x + 8, y); + else if (!slot && checkScriptFlag(0x8000)) + _screen->drawShape(_screen->_curPage, _itemIconShapes[103], x + 8, y, 0); + else + _screen->drawShape(_screen->_curPage, _itemIconShapes[85], x + 8, y, 0); + + if ((_characters[charIndex].disabledSlots & (1 << slot)) || !validateWeaponSlotItem(charIndex, slot) || (_characters[charIndex].hitPointsCur <= 0) || (_characters[charIndex].flags & 0x0c)) + _screen->drawShape(_screen->_curPage, _weaponSlotGrid, x, y, 0); +} + +void EobCoreEngine::gui_drawWeaponSlotStatus(int x, int y, int status) { + char tmpStr[6]; + char tmpStr2[6]; + tmpStr2[0] = 0; + + if (status > -3 || status == -5) + _screen->drawShape(_screen->_curPage, _greenSplatShape, x - 1, y, 0); + else + gui_drawBox(x, y, 31, 16, _color9, _color10, _color11); + + switch (status + 5) { + case 0: + strcpy(tmpStr, _characterGuiStringsWp[2]); + break; + case 1: + strcpy(tmpStr, _characterGuiStringsWr[2]); + strcpy(tmpStr2, _characterGuiStringsWr[3]); + break; + case 2: + strcpy(tmpStr, _characterGuiStringsWr[0]); + strcpy(tmpStr2, _characterGuiStringsWr[1]); + break; + case 3: + strcpy(tmpStr, _characterGuiStringsWp[1]); + break; + case 4: + strcpy(tmpStr, _characterGuiStringsWp[0]); + break; + default: + snprintf(tmpStr, 6, "%d", status); + break; + } + + if (tmpStr2[0]) { + _screen->printText(tmpStr, x + (16 - strlen(tmpStr) * 3), y + 2, 15, 0); + _screen->printText(tmpStr2, x + (16 - strlen(tmpStr) * 3), y + 9, 15, 0); + } else { + _screen->printText(tmpStr, x + (16 - strlen(tmpStr) * 3), y + 5, 15, 0); + } +} + +void EobCoreEngine::gui_drawHitpoints(int index) { + if (!testCharacter(index, 1)) + return; + + if (_currentControlMode && (index != _updateCharNum)) + return; + + static const uint8 xCoords[] = { 23, 95 }; + static const uint8 yCoords[] = { 46, 98, 150 }; + static const uint8 barColor[] = { 3, 5, 8 }; + + int x = xCoords[index & 1]; + int y = yCoords[index >> 1]; + int w = 38; + int h = 3; + + if (!_screen->_curPage) + x += 176; + + if (_currentControlMode) { + x = 250; + y = 16; + w = 51; + h = 5; + } + + EobCharacter *c = &_characters[index]; + + if (_hpBarGraphs) { + int bgCur = c->hitPointsCur + 10; + int bgMax = c->hitPointsMax + 10; + int col = ((bgMax / 3) > bgCur) ? 1 : 0; + if (bgCur <= 10) + col = 2; + + if (!_currentControlMode) + _screen->printText(_characterGuiStringsHp[0], x - 13, y - 1, 12, 0); + + + gui_drawHorizontalBarGraph(x, y, w, h, bgCur, bgMax, barColor[col], _color5); + + } else { + char tmpString[12]; + snprintf(tmpString, 12, _characterGuiStringsHp[1], c->hitPointsCur, c->hitPointsMax); + + if (!_currentControlMode) { + x -= 13; + y -= 1; + } + + _screen->printText(tmpString, x, y, 12, _bkgColor_1); + } +} + +void EobCoreEngine::gui_drawFoodStatusGraph(int index) { + if (!_currentControlMode) + return; + + if (!testCharacter(index, 1)) + return; + + EobCharacter *c = &_characters[index]; + if (!(c->flags & 1)) + return; + + if (index != _updateCharNum) + return; + + uint8 col = c->food < 20 ? 8 : (c->food < 33 ? 5 : 3); + gui_drawHorizontalBarGraph(250, 25, 51, 5, c->food, 100, col, _color5); +} + +void EobCoreEngine::gui_drawHorizontalBarGraph(int x, int y, int w, int h, int32 curVal, int32 maxVal, int col1, int col2) { + gui_drawBox(x - 1, y - 1, w + 3, h + 2, _color2_1, _color1_1, -1); + LolEobBaseEngine::gui_drawHorizontalBarGraph(x, y, w + 2, h, curVal, maxVal, col1, col2); +} + +void EobCoreEngine::gui_drawCharPortraitStatusFrame(int index) { + uint8 boxColor = ((_partyEffectFlags & 0x20000) | (_partyEffectFlags & 0xffff)) ? 4 : 6; + + static const uint8 xCoords[] = { 8, 80 }; + static const uint8 yCoords[] = { 2, 54, 106 }; + int x = xCoords[index & 1]; + int y = yCoords[index >> 1]; + + if (!_screen->_curPage) + x += 176; + + EobCharacter *c = &_characters[index]; + + int v8 = (_flags.gameID == GI_EOB2 && ((c->effectFlags & 0x4818) || c->effectsRemainder[0] || c->effectsRemainder[1] || ((_partyEffectFlags & 0x20000) | (_partyEffectFlags & 0xffff)))) || + (_flags.gameID == GI_EOB1 && ((c->effectFlags & 0x302) || c->effectsRemainder[0] || c->effectsRemainder[1])) ? 1 : 0; + int vA = (_flags.gameID == GI_EOB2 && ((((c->effectFlags & 0x3000) | (c->effectFlags & 0x10000)) || (_partyEffectFlags & 0x8420)))) || + (_flags.gameID == GI_EOB1 && ((c->effectFlags & 0x4c8) || _partyEffectFlags & 300000))? 1 : 0; + + if (v8 || vA) { + if (v8 && !vA) { + _screen->drawBox(x, y, x + 63, y + 49, boxColor); + return; + } + + if (vA && !v8) { + _screen->drawBox(x, y, x + 63, y + 49, 5); + return; + } + + int iX= x; + int iY= y; + + for (int i = 0; i < 64; i += 16) { + x = iX + i; + if (v8) { + _screen->drawClippedLine(x, y, x + 7, y, boxColor); + _screen->drawClippedLine(x + 8, y + 49, x + 15, y + 49, boxColor); + } + if (vA) { + _screen->drawClippedLine(x + 8, y, x + 15, y, 5); + _screen->drawClippedLine(x, y + 49, x + 7, y + 49, 5); + } + } + + x = iX; + + for (int i = 1; i < 48; i += 12) { + y = iY + i - 1; + + if (vA) { + _screen->drawClippedLine(x, y + 1, x, y + 6, 5); + _screen->drawClippedLine(x + 63, y + 7, x + 63, y + 12, 5); + } + if (v8) { + _screen->drawClippedLine(x, y + 7, x, y + 12, boxColor); + _screen->drawClippedLine(x + 63, y + 1, x + 63, y + 6, boxColor); + } + } + + } else { + _screen->drawClippedLine(x, y, x + 62, y, _color1_1); + _screen->drawClippedLine(x, y + 49, x + 62, y + 49, _color2_1); + _screen->drawClippedLine(x - 1, y, x - 1, y + 50, 12); + _screen->drawClippedLine(x + 63, y, x + 63, y + 50, 12); + } +} + +void EobCoreEngine::gui_drawInventoryItem(int slot, int special, int pageNum) { + int x = _inventorySlotsX[slot]; + int y = _inventorySlotsY[slot]; + + int item = _characters[_updateCharNum].inventory[slot]; + int cp = _screen->setCurPage(pageNum); + + if (special) { + int wh = (slot == 25 || slot == 26) ? 10 : 18; + gui_drawBox(x - 1, y - 1, wh, wh, _color1_1, _color2_1, slot == 16 ? -1 : _bkgColor_1); + + if (slot == 16) { + _screen->fillRect(227, 65, 238, 69, 12); + int cnt = countQueuedItems(_characters[_updateCharNum].inventory[slot], -1, -1, 1, 1); + x = cnt >= 10 ? 227 : 233; + char str[3]; + snprintf(str, 3, "%d", cnt); + _screen->printText(str, x, 65, 15, 0); + } + } + + if (slot != 16 && item) { + if (slot == 25 || slot == 26) { + x -= 4; + y -= 4; + } + drawItemIconShape(pageNum, item, x, y); + } + _screen->_curPage = cp; + _screen->updateScreen(); +} + +void EobCoreEngine::gui_drawCompass(bool force) { + if (_currentDirection == _compassDirection && !force) + return; + + static const uint8 shpX[2][3] = { { 0x70, 0x4D, 0x95 }, { 0x72, 0x4F, 0x97 } }; + static const uint8 shpY[2][3] = { { 0x7F, 0x9A, 0x9A }, { 0x83, 0x9E, 0x9E } }; + int g = _flags.gameID == GI_EOB1 ? 0 : 1; + + for (int i = 0; i < 3; i++) + _screen->drawShape(_screen->_curPage, _compassShapes[(i << 2) + _currentDirection], shpX[g][i], shpY[g][i], 0); + + _compassDirection = _currentDirection; +} + +void EobCoreEngine::gui_drawDialogueBox() { + gui_drawBox(0, 121, 320, 79, _color1_1, _color2_1, _bkgColor_1); + txt()->clearCurDim(); +} + +void EobCoreEngine::gui_drawSpellbook() { + _screen->setCurPage(2); + int numTab = (_flags.gameID == GI_EOB1) ? 5 : 6; + _screen->copyRegion(64, 121, 64, 121, 112, 56, 0, 2, Screen::CR_NO_P_CHECK); + + for (int i = 0; i < numTab; i++) { + int col1 = _color14; + int col2 = _color13; + int col3 = _color12; + + if (i == _openBookSpellLevel) { + col1 = _color1_1; + col2 = _color2_1; + col3 = _bkgColor_1; + } + + if (_flags.gameID == GI_EOB1) { + gui_drawBox(i * 21 + 71, 122, 21, 9, col1, col2, col3); + _screen->printText(_magicStrings7[i], i * 21 + 73, 123, 12, 0); + } else { + gui_drawBox(i * 18 + 68, 121, 18, 9, col1, col2, col3); + char val[3]; + sprintf(val, "%d", i + 1); + _screen->printText(val, i * 18 + 75, 123, 12, 0); + } + } + + if (_flags.gameID == GI_EOB1) + gui_drawBox(71, 131, 105, 44, _color1_1, _color2_1, _bkgColor_1); + else { + gui_drawBox(68, 130, 108, 47, _color1_1, _color2_1, _bkgColor_1); + gui_drawBox(68, 168, 78, 9, _color8, _color7, _color6); + gui_drawBox(146, 168, 14, 9, _color8, _color7, _color6); + gui_drawBox(160, 168, 16, 9, _color8, _color7, _color6); + gui_drawSpellbookScrollArrow(150, 169, 0); + gui_drawSpellbookScrollArrow(165, 169, 1); + } + + int textCol1 = 15; + int textCol2 = 8; + int textXa = 74; + int textXs = 71; + int textY = 170; + int col3 = _bkgColor_1; + + if (_flags.gameID == GI_EOB1) { + textCol2 = 11; + textXa = textXs = 73; + textY = 168; + } + + for (int i = 0; i < 7; i++) { + int d = _openBookAvailableSpells[_openBookSpellLevel * 10 + _openBookSpellListOffset + i]; + if (_openBookSpellSelectedItem == i) { + if (d >= 0 && i < 6 && (i + _openBookSpellListOffset) < 9) { + _screen->printText(_openBookSpellList[d], textXs, 132 + 6 * i, textCol1, textCol2); + } else if (i == 6) { + if (_flags.gameID == GI_EOB2) + _screen->fillRect(69, 169, 144, 175, textCol2); + _screen->printText(_magicStrings1[0], textXa, textY, textCol1, textCol2); + } + } else { + if (d >= 0 && i < 6 && (i + _openBookSpellListOffset) < 9) + _screen->printText(_openBookSpellList[d], textXs, 132 + 6 * i, textCol1, col3); + else + _screen->printText(_magicStrings1[0], textXa, textY, 12, _color6); + } + } + + if (_characters[_openBookChar].disabledSlots & 4) { + static const uint8 xpos[] = { 0x44, 0x62, 0x80, 0x90 }; + static const uint8 ypos[] = { 0x82, 0x92, 0x98 }; + for (int yc = 0; yc < 3; yc++) { + for (int xc = 0; xc < 4; xc++) + _screen->drawShape(_screen->_curPage, _weaponSlotGrid, xpos[xc], ypos[yc], 0); + } + } + + if (_openBookAvailableSpells[_openBookSpellLevel * 10 + 6] <= 0) + _screen->drawShape(2, _blackBoxWideGrid, 146, 168, 0); + + _screen->setCurPage(0); + _screen->copyRegion(64, 121, 64, 121, 112, 56, 2, 0, Screen::CR_NO_P_CHECK); + _screen->updateScreen(); +} + +void EobCoreEngine::gui_drawSpellbookScrollArrow(int x, int y, int direction) { + static const uint8 x1[] = { 0, 2, 1, 0, 2, 2 }; + static const uint8 x2[] = { 2, 4, 5, 6, 4, 4 }; + if (direction) { + _screen->setPagePixel(_screen->_curPage, x + 3, y + 5, 12); + for (int i = 1; i < 6; i++) + _screen->drawClippedLine(x + x1[i], (5 - i) + y, x + x2[i], (5 - i) + y, 12); + } else { + _screen->setPagePixel(_screen->_curPage, x + 3, y, 12); + for (int i = 1; i < 6; i++) + _screen->drawClippedLine(x + x1[i], y + i, x + x2[i], y + i, 12); + } +} + +void EobCoreEngine::gui_updateSlotAfterScrollUse() { + _characters[_openBookChar].disabledSlots ^= (1 << (--_castScrollSlot)); + setCharEventTimer(_openBookChar, 18, _castScrollSlot + 2, 1); + gui_drawCharPortraitWithStats(_openBookChar); + _openBookChar = _openBookCharBackup; + _openBookType = _openBookTypeBackup; + _castScrollSlot = 0; + gui_toggleButtons(); +} + +void EobCoreEngine::gui_updateControls() { + Button b; + if (_currentControlMode) + clickedPortraitRestore(&b); + if (_updateFlags) + clickedSpellbookAbort(&b); +} + +void EobCoreEngine::gui_toggleButtons() { + if (_currentControlMode == 0) + gui_setPlayFieldButtons(); + else if (_currentControlMode == 1) + gui_setInventoryButtons(); + else if (_currentControlMode == 2) + gui_setStatsListButtons(); +} + +void EobCoreEngine::gui_setPlayFieldButtons() { + gui_resetButtonList(); + gui_initButtonsFromList(_updateFlags ? _buttonList2 : _buttonList1); +} + +void EobCoreEngine::gui_setInventoryButtons() { + gui_resetButtonList(); + gui_initButtonsFromList(_updateFlags ? _buttonList5 : _buttonList3); +} + +void EobCoreEngine::gui_setStatsListButtons() { + gui_resetButtonList(); + gui_initButtonsFromList(_updateFlags ? _buttonList6 : _buttonList4); +} + +void EobCoreEngine::gui_setSwapCharacterButtons() { + gui_resetButtonList(); + gui_initButtonsFromList(_buttonList7); +} + +void EobCoreEngine::gui_setCastOnWhomButtons() { + gui_resetButtonList(); + gui_initButtonsFromList(_buttonList8); +} + +void EobCoreEngine::gui_initButton(int index, int, int, int) { + Button *b = 0; + int cnt = 1; + + if (_flags.gameID == GI_EOB1 && index > 92) + return; + + if (_activeButtons) { + Button *n = _activeButtons; + while (n->nextButton) { + ++cnt; + n = n->nextButton; + } + + ++cnt; + b = n->nextButton = &_activeButtonData[cnt]; + } else { + b = &_activeButtonData[0]; + _activeButtons = b; + } + + *b = Button(); + b->data0Val2 = 12; + b->data1Val2 = b->data2Val2 = 15; + b->data3Val2 = 8; + + b->index = index + 1; + + const EobGuiButtonDef *d = &_buttonDefs[index]; + + if (_flags.gameID == GI_EOB1) { + // EOB1 spellbook modifications + if (index > 61 && index < 67) + d = &_buttonDefs[index + 33]; + if (index == 88) + d = &_buttonDefs[index + 12]; + } + + b->x = d->x; + b->y = d->y; + b->width = d->w; + b->height = d->h; + + // EOB1 spellbook modifications + if (_flags.gameID == GI_EOB1 && ((index > 66 && index < 73) || (index > 76 && index < 79))) + b->y++; + + b->flags = d->flags; + b->keyCode = d->keyCode; + b->keyCode2 = d->keyCode2; + b->arg = d->arg; + b->buttonCallback = d->buttonCallback; +} + +int EobCoreEngine::clickedCharPortraitDefault(Button *button) { + if (!testCharacter(button->arg, 1)) + return 1; + + gui_processCharPortraitClick(button->arg); + return 0; +} + +int EobCoreEngine::clickedCamp(Button *button) { + return button->arg; +} + +int EobCoreEngine::clickedSceneDropPickupItem(Button *button) { + uint16 block = _currentBlock; + if (button->arg > 1) { + block = calcNewBlockPosition(_currentBlock, _currentDirection); + int f = _wllWallFlags[_levelBlockProperties[block].walls[_sceneDrawVarDown]]; + if (!(f & 0x0b)) + return 1; + } + int d = _dropItemDirIndex[(_currentDirection << 2) + button->arg]; + + if (_itemInHand) { + setItemPosition((Item*)&_levelBlockProperties[block & 0x3ff].drawObjects, block, _itemInHand, d); + setHandItem(0); + runLevelScript(block, 4); + } else { + d = getQueuedItem((Item*)&_levelBlockProperties[block].drawObjects, d, -1); + if (!d) + return 1; + setHandItem(d); + runLevelScript(block, 8); + } + + _sceneUpdateRequired = true; + return 1; +} + +int EobCoreEngine::clickedCharPortrait2(Button *button) { + if (!_gui->_progress) { + if (!testCharacter(button->arg, 1)) + return button->index; + } + + _currentControlMode = 1; + if (!_gui->_progress) + _updateCharNum = button->arg; + + _screen->copyRegion(176, 0, 0, 0, 144, 168, 0, 5, Screen::CR_NO_P_CHECK); + gui_drawCharPortraitWithStats(_updateCharNum); + gui_setInventoryButtons(); + + return button->index; +} + +int EobCoreEngine::clickedWeaponSlot(Button *button) { + if (!testCharacter(button->arg, 1)) + return 1; + + static const uint8 sY[] = { 24, 24, 80, 80, 136, 136 }; + int slot = sY[button->arg] > _mouseY ? 0 : 1; + + if ((_gui->_flagsMouseLeft & 0x7f) == 1) + gui_processWeaponSlotClickLeft(button->arg, slot); + else + gui_processWeaponSlotClickRight(button->arg, slot); + + return 1; +} + +int EobCoreEngine::clickedCharNameLabelRight(Button *button) { + if (!testCharacter(button->arg, 1)) + return button->index; + + if (_updateFlags) { + Button b; + clickedSpellbookAbort(&b); + } + + if (_exchangeCharacterId == -1) { + _exchangeCharacterId = button->arg; + gui_setSwapCharacterButtons(); + gui_drawCharPortraitWithStats(_exchangeCharacterId); + enableTimer(0); + } else { + int d = _exchangeCharacterId; + _exchangeCharacterId = -1; + + EobCharacter temp; + memcpy(&temp, &_characters[d], sizeof(EobCharacter)); + memcpy(&_characters[d], &_characters[button->arg], sizeof(EobCharacter)); + memcpy(&_characters[button->arg], &temp, sizeof(EobCharacter)); + + _timer->disable(0); + gui_drawCharPortraitWithStats(d); + gui_processCharPortraitClick(button->arg); + gui_drawCharPortraitWithStats(button->arg); + gui_setPlayFieldButtons(); + setupCharacterTimers(); + } + + return button->index; +} + +int EobCoreEngine::clickedInventorySlot(Button *button) { + gui_processInventorySlotClick(button->arg); + return button->index; +} + +int EobCoreEngine::clickedEatItem(Button *button) { + eatItemInHand(_updateCharNum); + return button->index; +} + +int EobCoreEngine::clickedInventoryPrevChar(Button *button) { + if (_gui->_progress == 1) + _updateCharNum = 0; + else if (_gui->_progress == 2) + _updateCharNum = 1; + else + _updateCharNum = getNextValidCharIndex(_updateCharNum, -1); + + gui_drawCharPortraitWithStats(_updateCharNum); + return button->index; +} + +int EobCoreEngine::clickedInventoryNextChar(Button *button) { + int oldVal = _updateCharNum; + int v = button->arg == 2 ? 2 : 0; + + if (_gui->_progress == 1) + _updateCharNum = v + 2; + else if (_gui->_progress == 2) + _updateCharNum = v + 3; + else + _updateCharNum = getNextValidCharIndex(_updateCharNum, 1); + + if (!testCharacter(_updateCharNum, 1)) { + _updateCharNum = oldVal; + return 1; + } + + gui_drawCharPortraitWithStats(_updateCharNum); + return button->index; +} + +int EobCoreEngine::clickedSpellbookTab(Button *button) { + _openBookSpellLevel = button->arg; + _openBookSpellListOffset = 0; + + for (_openBookSpellSelectedItem = 0; _openBookSpellSelectedItem < 6; _openBookSpellSelectedItem++) { + if (_openBookAvailableSpells[_openBookSpellLevel * 10 + _openBookSpellSelectedItem] > 0) + break; + } + + gui_drawSpellbook(); + + _characters[_openBookChar].slotStatus[3] = _openBookSpellLevel; + _characters[_openBookChar].slotStatus[2] = _openBookSpellSelectedItem; + _characters[_openBookChar].slotStatus[4] = _openBookSpellListOffset; + + return button->index; +} + +int EobCoreEngine::clickedSpellbookList(Button *button) { + int listIndex = button->arg; + bool spellLevelAvailable = false; + + if (listIndex == 6) { + for (int i = 0; i < 10; i++) { + if (_openBookAvailableSpells[_openBookSpellLevel * 10 + i] > 0) { + spellLevelAvailable = true; + break; + } + } + if (!spellLevelAvailable) + return button->index; + + int v = (_gui->_progress == 1) ? -1 : ((_gui->_progress == 2) ? 1 : 0); + + _openBookSpellSelectedItem += _openBookSpellListOffset; + if (_openBookSpellSelectedItem == 12 || (_openBookSpellSelectedItem == 6 && _openBookSpellListOffset == 0)) + _openBookSpellSelectedItem = 9; + + do { + _openBookSpellSelectedItem += v; + int s = (_openBookSpellSelectedItem >= 0) ? _openBookSpellSelectedItem : 9; + _openBookSpellSelectedItem = (s <= 9) ? s : 0; + } while (_openBookAvailableSpells[_openBookSpellLevel * 10 + _openBookSpellSelectedItem] <= 0 && _openBookSpellSelectedItem != 9); + + if (_openBookSpellSelectedItem >= 6) { + _openBookSpellListOffset = 6; + if (_openBookSpellSelectedItem == 9) + _openBookSpellSelectedItem = 6; + else + _openBookSpellSelectedItem -= 6; + } else { + _openBookSpellListOffset = 0; + } + + if (_openBookSpellListOffset == 6 && _openBookAvailableSpells[_openBookSpellLevel * 10 + 6] <= 0) + _openBookSpellListOffset = 0; + + gui_drawSpellbook(); + + } else { + if (listIndex == 7 || _openBookAvailableSpells[_openBookSpellLevel * 10 + _openBookSpellListOffset + listIndex] > 0) { + if (listIndex < 6) { + if (_openBookSpellListOffset + listIndex < 9) + _openBookSpellSelectedItem= listIndex; + else if (listIndex != 7) + return button->index; + } else if (listIndex != 7) { + return button->index; + } + + if (_openBookSpellSelectedItem < 6 && ((_openBookSpellSelectedItem + _openBookSpellListOffset) < 9)) { + if (_characters[_openBookChar].disabledSlots & 4) + return button->index; + + gui_drawSpellbook(); + + int s = _openBookAvailableSpells[_openBookSpellLevel * 10 + _openBookSpellListOffset + _openBookSpellSelectedItem]; + if (_openBookType == 1) + s += _mageSpellListSize; + + castSpell(s, 0); + + } else if ((_openBookSpellSelectedItem == 6 && listIndex == 7) || (_openBookSpellSelectedItem != 6 && listIndex == 6) ) { + Button b; + clickedSpellbookAbort(&b); + } + } + } + + _characters[_openBookChar].slotStatus[2] = _openBookSpellSelectedItem; + _characters[_openBookChar].slotStatus[4] = _openBookSpellListOffset; + return button->index; +} + +int EobCoreEngine::clickedCastSpellOnCharacter(Button *button) { + _activeSpellCaster = button->arg; + + if (_activeSpellCaster == 255) { + _txt->printMessage(_magicStrings3[1]); + snd_playSoundEffect(79); + if (_castScrollSlot) { + gui_updateSlotAfterScrollUse(); + } else { + gui_toggleButtons(); + gui_drawSpellbook(); + } + } else { + if (_characters[_activeSpellCaster].flags & 1) + startSpell(_activeSpell); + } + + return button->index; +} + +int EobCoreEngine::clickedInventoryNextPage(Button *button) { + if (_currentControlMode == 2) { + gui_setInventoryButtons(); + _currentControlMode = 1; + } else { + gui_setStatsListButtons(); + _currentControlMode = 2; + } + + gui_drawCharPortraitWithStats(_updateCharNum); + return button->index; +} + +int EobCoreEngine::clickedPortraitRestore(Button *button) { + _currentControlMode = 0; + _screen->_curPage = 2; + _screen->copyRegion(0, 0, 0, 0, 144, 168, 5, _screen->_curPage, Screen::CR_NO_P_CHECK); + gui_drawAllCharPortraitsWithStats(); + _screen->_curPage = 0; + _screen->copyRegion(0, 0, 176, 0, 144, 168, 2, 0, Screen::CR_NO_P_CHECK); + _screen->updateScreen(); + gui_setPlayFieldButtons(); + return button->index; +} + +int EobCoreEngine::clickedUpArrow(Button *button) { + int b = calcNewBlockPositionAndTestPassability(_currentBlock, _currentDirection); + + if (b == -1) { + notifyBlockNotPassable(); + } else { + moveParty(b); + _sceneDefaultUpdate = 1; + } + + return button->index; +} + +int EobCoreEngine::clickedDownArrow(Button *button) { + int b = calcNewBlockPositionAndTestPassability(_currentBlock, (_currentDirection + 2) & 3); + + if (b == -1) { + notifyBlockNotPassable(); + } else { + moveParty(b); + _sceneDefaultUpdate = 1; + } + + return button->index; +} + +int EobCoreEngine::clickedLeftArrow(Button *button) { + int b = calcNewBlockPositionAndTestPassability(_currentBlock, (_currentDirection - 1) & 3); + + if (b == -1) { + notifyBlockNotPassable(); + } else { + moveParty(b); + _sceneDefaultUpdate = 1; + } + + return button->index; +} + +int EobCoreEngine::clickedRightArrow(Button *button) { + int b = calcNewBlockPositionAndTestPassability(_currentBlock, (_currentDirection + 1) & 3); + + if (b == -1) { + notifyBlockNotPassable(); + } else { + moveParty(b); + _sceneDefaultUpdate = 1; + } + + return button->index; +} + +int EobCoreEngine::clickedTurnLeftArrow(Button *button) { + _currentDirection = (_currentDirection - 1) & 3; + //_keybControlUnk = -1; + _sceneDefaultUpdate = 1; + _sceneUpdateRequired = true; + return button->index; +} + +int EobCoreEngine::clickedTurnRightArrow(Button *button) { + _currentDirection = (_currentDirection + 1) & 3; + //_keybControlUnk = -1; + _sceneDefaultUpdate = 1; + _sceneUpdateRequired = true; + return button->index; +} + +int EobCoreEngine::clickedAbortCharSwitch(Button *button) { + _timer->disable(0); + int c = _exchangeCharacterId; + _exchangeCharacterId = -1; + gui_drawCharPortraitWithStats(c); + gui_setPlayFieldButtons(); + return button->index; +} + +int EobCoreEngine::clickedSceneThrowItem(Button *button) { + if (!_itemInHand) + return button->index; + + if (launchObject(_updateCharNum, _itemInHand, _currentBlock, _dropItemDirIndex[(_currentDirection << 2) + button->arg], _currentDirection, _items[_itemInHand].type)) { + setHandItem(0); + _sceneUpdateRequired = true; + } + + return button->index; +} + +int EobCoreEngine::clickedSceneSpecial(Button *button) { + _clickedSpecialFlag = 0x40; + return specialWallAction(calcNewBlockPosition(_currentBlock, _currentDirection), _currentDirection); +} + +int EobCoreEngine::clickedSpellbookAbort(Button *button) { + _updateFlags = 0; + _screen->copyRegion(0, 0, 64, 121, 112, 56, 10, 0, Screen::CR_NO_P_CHECK); + _screen->updateScreen(); + gui_drawCompass(true); + gui_toggleButtons(); + return button->index; +} + +int EobCoreEngine::clickedSpellbookScroll(Button *button) { + if (_openBookAvailableSpells[_openBookSpellLevel * 10] > 0) { + _openBookSpellListOffset ^= 6; + _openBookSpellSelectedItem = 0; + } else { + _openBookSpellListOffset = 6; + } + + _characters[_openBookChar].slotStatus[2] = _openBookSpellSelectedItem; + _characters[_openBookChar].slotStatus[4] = _openBookSpellListOffset; + + gui_drawSpellbook(); + + return button->index; +} + +int EobCoreEngine::clickedUnk(Button *button) { + return button->index; +} + +void EobCoreEngine::gui_processCharPortraitClick(int index) { + if (index == _updateCharNum) + return; + + int a = _updateCharNum; + _updateCharNum = index; + + gui_drawCharPortraitWithStats(a); + gui_drawCharPortraitWithStats(index); +} + +void EobCoreEngine::gui_processWeaponSlotClickLeft(int charIndex, int slotIndex) { + int itm = _characters[charIndex].inventory[slotIndex]; + if (_items[itm].flags & 0x20) + return; + + int ih = _itemInHand; + int t = _items[ih].type; + uint16 v = (ih) ? _itemTypes[t].invFlags : 0xffff; + + if (v & _slotValidationFlags[slotIndex]) { + setHandItem(itm); + _characters[charIndex].inventory[slotIndex] = ih; + gui_drawCharPortraitWithStats(charIndex); + } + + recalcArmorClass(charIndex); +} + +void EobCoreEngine::gui_processWeaponSlotClickRight(int charIndex, int slotIndex) { + const char * const *strs = &_itemExtraStrings[_flags.gameID == GI_EOB1 ? 17 : (_flags.lang == Common::DE_DEU ? 26 : 22)]; + + if (!testCharacter(charIndex, 0x0d)) + return; + + uint16 itm = _characters[charIndex].inventory[slotIndex]; + int wslot = slotIndex < 2 ? slotIndex : -1; + + if (slotIndex < 2 && (!validateWeaponSlotItem(charIndex, slotIndex) || (!_currentControlMode && (_characters[charIndex].disabledSlots & (1 << slotIndex))))) + return; + + if (!itemUsableByCharacter(charIndex, itm)) + _txt->printMessage(strs[0], -1, _characters[charIndex].name); + + if (!itm && slotIndex > 1) + return; + + int8 tp = _items[itm].type; + int8 vl = _items[itm].value; + uint8 ep = _itemTypes[tp].extraProperties & 0x7f; + + switch (ep) { + case 0: + case 16: + // Item automatically used when worn + _txt->printMessage(strs[1]); + break; + + case 1: + case 2: + case 3: + // Weapons + if (!_currentControlMode) + useSlotWeapon(charIndex, slotIndex, itm); + break; + + case 4: + case 8: + case 12: + case 13: + case 15: + // Item not used that way + _txt->printMessage(strs[2]); + break; + + case 5: + case 6: + // Cleric holy symbol / mage spell book + if (!_currentControlMode) + useMagicBookOrSymbol(charIndex, ep == 6 ? 1 : 0); + break; + + case 7: + // Food ration + /* don't do anything if mouse control is enabled */ + //eatItemInHand(charIndex); + break; + + case 10: + if (_flags.gameID == GI_EOB1) + vl += _clericSpellOffset; + case 9: + // Mage/Cleric Scroll + if (!_currentControlMode) + useMagicScroll(charIndex, vl, wslot); + break; + + case 11: + // Letters, Notes, Maps + displayParchment(vl); + break; + + case 14: + // Potion + usePotion(charIndex, wslot); + break; + + case 18: + ep = ep; + break; + + case 19: + // eob2 horn + ep = ep; + break; + + case 20: + if (vl == 1) + inflictCharacterDamage(charIndex, 200); + else + useMagicScroll(charIndex, 55, wslot); + deleteInventoryItem(charIndex, wslot); + break; + + default: + break; + } + + if (ep == 1 && charIndex >= 2) + return; + + _lastUsedItem = itm; + runLevelScript(calcNewBlockPosition(_currentBlock, _currentDirection), 0x100); + _lastUsedItem = 0; +} + +void EobCoreEngine::gui_processInventorySlotClick(int slot) { + int itm = _characters[_updateCharNum].inventory[slot]; + int ih = _itemInHand; + if (!validateInventorySlotForItem(ih, _updateCharNum, slot)) + return; + + if (slot == 16) { + if (ih) { + setItemPosition(&_characters[_updateCharNum].inventory[16], -2, ih, 0); + gui_drawInventoryItem(slot, 1, 0); + setHandItem(0); + + } else { + itm = getQueuedItem(&_characters[_updateCharNum].inventory[16], 0, -1); + gui_drawInventoryItem(slot, 1, 0); + setHandItem(itm); + } + + } else { + setHandItem(itm); + _characters[_updateCharNum].inventory[slot] = ih; + gui_drawInventoryItem(slot, 1, 0); + recalcArmorClass(_updateCharNum); + } +} + +GUI_Eob::GUI_Eob(EobCoreEngine *vm) : GUI(vm), _vm(vm), _screen(vm->_screen) { + _scrollUpFunctor = _scrollDownFunctor = BUTTON_FUNCTOR(GUI_Eob, this, 0); + + _redrawButtonFunctor = BUTTON_FUNCTOR(GUI, this, &GUI::redrawButtonCallback); + _redrawShadedButtonFunctor = BUTTON_FUNCTOR(GUI, this, &GUI::redrawShadedButtonCallback); + + _specialProcessButton = _backupButtonList = 0; + _flagsMouseLeft = _flagsMouseRight = _flagsModifier = 0; + _backupButtonList = 0; + _progress = 0; + _prcButtonUnk3 = 1; + _cflag = 0xffff; + + _menuLineSpacing = 0; + _menuUnk1 = 0; + _menuLastInFlags = 0; + _menuCur = 0; + _menuNumItems = 0; +} + +void GUI_Eob::processButton(Button *button) { + if (!button->data0Val1 && !button->data2Val1 && !button->data1Val1) + return; + + if ((button->flags & 0x18) == 0x18) + return; + + int sd = button->dimTableIndex; + const ScreenDim *dm = _screen->getScreenDim(sd); + + int fx = button->x; + if (fx < 0) + fx += (dm->w << 3); + + int sx = fx + (dm->sx << 3); + + int fy = button->y; + if (fy < 0) + fy += dm->h; + + int sy = fy + dm->sy; + + uint16 fw = button->width; + uint16 fh = button->height; + + uint8 col1 = button->data1Val1; + uint8 col2 = button->data1Val3; + + int fx2 = sx + fw - 1; + int fy2 = sy + fh - 1; + + if (button->flags2 & 1) { + if (button->data1Val1 == 1) { + if (button->data0Val1 == 1) { + _screen->drawShape(_screen->_curPage, button->data1ShapePtr, fx, fy, sd); + } else if (button->data0Val1 == 2) { + if (!(button->flags2 & 4)) + _screen->printText((const char*) button->data1ShapePtr, sx, sy, col1, col2); + } else if (button->data0Val1 == 3) { + // nullsub (at least EOBII) + } else if (button->data0Val1 == 4) { + if (button->data1Callback) + (*button->data1Callback.get())(button); + } + } else if (button->data1Val1 == 2) { + if (!(button->flags2 & 4)) + _screen->drawBox(sx, sy, fx2, fy2, col1); + } else if (button->data1Val1 == 3) { + // nullsub (at least EOBII) + } else if (button->data1Val1 == 4) { + if (button->data1Callback) + (*button->data1Callback.get())(button); + } + } + + if (button->flags2 & 4) { + if (button->data2Val1 == 1) { + if (button->data0Val1 == 1) { + _screen->drawShape(_screen->_curPage, button->data2ShapePtr, fx, fy, sd); + } else if (button->data0Val1 == 2) { + if (button->flags2 & 1) + _screen->printText((const char*) button->data2ShapePtr, sx, sy, button->data3Val2, button->data3Val3); + else + _screen->printText((const char*) button->data2ShapePtr, sx, sy, button->data2Val2, button->data2Val3); + } else if (button->data0Val1 == 3) { + // nullsub (at least EOBII) + } else if (button->data0Val1 == 4) { + if (button->data2Callback) + (*button->data2Callback.get())(button); + } + } else if (button->data2Val1 == 2) { + _screen->drawBox(sx, sy, fx2, fy2, (button->flags2 & 1) ? button->data3Val2 : button->data2Val2); + } else if (button->data2Val1 == 3) { + // nullsub (at least EOBII) + } else if (button->data2Val1 == 4) { + if (button->data2Callback) + (*button->data2Callback.get())(button); + } + } + + if (!(button->flags2 & 5)) { + if (button->data0Val1 == 1) { + _screen->drawShape(_screen->_curPage, button->data0ShapePtr, fx, fy, sd); + } else if (button->data0Val1 == 2) { + _screen->printText((const char*) button->data0ShapePtr, sx, sy, button->data0Val2, button->data0Val3); + } else if (button->data0Val1 == 3) { + // nullsub (at least EOBII) + } else if (button->data0Val1 == 4) { + if (button->data0Callback) + (*button->data0Callback.get())(button); + } else if (button->data0Val1 == 5) { + _screen->drawBox(sx, sy, fx2, fy2, button->data0Val2); + } else { + if (!button->data0Val1) { + if(button->data1Val1 == 2 || button->data2Val1 == 2) { + _screen->drawBox(sx, sy, fx2, fy2, button->data0Val2); + } else { + // nullsub (at least EOBII) + } + } + } + } +} + +int GUI_Eob::processButtonList(Kyra::Button *buttonList, uint16 inputFlags, int8 mouseWheel) { + _progress = 0; + uint16 in = inputFlags & 0xff; + uint16 buttonReleaseFlag = 0; + bool clickEvt = false; + + _flagsMouseLeft = (_vm->_mouseClick == 1) ? 2 : 4; + _flagsMouseRight = (_vm->_mouseClick == 2) ? 2 : 4; + _vm->_mouseClick = 0; + + if (in >= 199 && in <= 202) { + buttonReleaseFlag = (inputFlags & 0x800) ? 3 : 1; + if (in < 201) + _flagsMouseLeft = buttonReleaseFlag; + else + _flagsMouseRight = buttonReleaseFlag; + + //////////////////////////// + if (!buttonList && !(inputFlags & 0x800)) + return inputFlags & 0xff; + //////////////////////////// + + inputFlags = 0; + clickEvt = true; + } else { + inputFlags &= 0xff; + } + + uint16 result = 0; + bool runLoop = true; + + if (!buttonList) + return inputFlags; + + if (_vm->_buttonListChanged || (buttonList != _backupButtonList)) { + _backupButtonList = buttonList; + _flagsModifier = 0; + + while (runLoop) { + processButton(buttonList); + _flagsModifier |= (buttonList->flags & 0xAA04); + + // UNUSED + //if (buttonList->flags2 & 0x20) { + // if (_processButtonListExtraCallback) + // this->*_processButtonListExtraCallback(buttonList); + //} + + if (buttonList->nextButton) + buttonList = buttonList->nextButton; + else + runLoop = false; + } + + _vm->_buttonListChanged = false; + + _specialProcessButton = 0; + _prcButtonUnk3 = 1; + _cflag = 0xffff; + } + + int sd = 0; + const ScreenDim *dm = _screen->getScreenDim(sd); + + int x1 = dm->sx << 3; + int y1 = dm->sy; + int w1 = dm->w << 3; + int h1 = dm->h; + + uint16 v8 = 0; + uint16 v18 = 0; + uint16 v16 = 0; + + if (_specialProcessButton) + buttonList = _specialProcessButton; + + while (runLoop) { + if (buttonList->flags & 8) { + buttonList = buttonList->nextButton; + runLoop = buttonList ? true : false; + continue; + } + + int vc = 0; + int v6 = 0; + uint16 iFlag = buttonList->index | 0x8000; + uint16 flgs2 = buttonList->flags2; + uint16 flgs = buttonList->flags; + + if (flgs2 & 1) + flgs2 |= 8; + else + flgs2 &= 0xfff7; + + if (flgs2 & 4) + flgs2 |= 0x10; + else + flgs2 &= 0xffef; + + uint16 vL = 0; + uint16 vR = 0; + + if (inputFlags) { + if (buttonList->keyCode == in) { + _progress = 1; + _flagsMouseLeft = 1; + flgs2 ^= 1; + result = iFlag; + v6 = 1; + } else if (buttonList->keyCode2 == in) { + _progress = 2; + _flagsMouseRight = 1; + result = iFlag; + v6 = 1; + } + } else if (_flagsModifier || clickEvt) { + vL = flgs & 0xf00; + vR = flgs & 0xf000; + + if (_prcButtonUnk3) { + if (sd != buttonList->dimTableIndex) { + sd = buttonList->dimTableIndex; + dm = _screen->getScreenDim(sd); + x1 = dm->sx << 3; + y1 = dm->sy; + w1 = dm->w << 3; + h1 = dm->h; + } + + int x2 = x1; + if (buttonList->x < 0) + x2 += w1; + x2 += buttonList->x; + + int y2 = y1; + if (buttonList->y < 0) + y2 += h1; + y2 += buttonList->y; + + if (_vm->_mouseX >= x2 && _vm->_mouseX <= (x2 + buttonList->width) && _vm->_mouseY >= y2 && _vm->_mouseY <= (y2 + buttonList->height)) { + flgs2 |= 2; + + if (vL) { + switch (_flagsMouseLeft - 1) { + case 0: + v18 = 1; + + if ((flgs & 4) && buttonList->data2Val1) { + flgs2 |= 4; + vc = 1; + } else { + flgs2 &= 0xfffb; + } + + if (flgs & 0x100) { + v6 = 1; + if (!(flgs & 1)) { + flgs2 ^= 1; + result = iFlag; + } + } + + if (flgs & 0x40) { + _specialProcessButton = buttonList; + v8 = 1; + } + + _cflag = flgs; + break; + + case 1: + if (flgs != _cflag) + break; + + if ((flgs & 4) && buttonList->data2Val1) { + flgs2 |= 4; + vc = 1; + } else { + flgs2 &= 0xfffb; + } + + if (!(flgs & 0x200)) + break; + + v6 = 1; + + if (flgs & 1) + break; + + flgs2 |= 1; + result = iFlag; + break; + + case 2: + if (_cflag != flgs) + break; + + if (flgs & 0x400) { + v6 = 1; + if (flgs & 1) { + flgs2 ^= 1; + result = iFlag; + } + } + + if ((flgs & 2) && (flgs2 & 1)) + flgs2 &= 0xfffe; + break; + + case 3: + if ((flgs & 4) || (!buttonList->data2Val1)) + flgs2 &= 0xfffb; + else + flgs2 |= 4; + + if (flgs & 0x800) { + v6 = 1; + break; + } + + if ((flgs & 2) && (flgs2 & 1)) + flgs2 &= 0xfffe; + break; + + default: + break; + } + } + + if (vR && !v6 && !vc) { + switch (_flagsMouseRight - 1) { + case 0: + v18 = 1; + + if ((flgs & 4) && buttonList->data2Val1) + flgs2 |= 4; + else + flgs2 &= 0xfffb; + + if (flgs & 0x1000) { + v6 = 1; + if (!(flgs & 1)) { + flgs2 ^= 1; + result = iFlag; + } + } + + if (flgs & 0x40) { + _specialProcessButton = buttonList; + v8 = 1; + } + + _cflag = flgs; + break; + + case 1: + if (flgs != _cflag) + break; + + if ((flgs & 4) && buttonList->data2Val1) + flgs2 |= 4; + else + flgs2 &= 0xfffb; + + if (!(flgs & 0x2000)) + break; + + v6 = 1; + + if (flgs & 1) + break; + + flgs2 |= 1; + result = iFlag; + break; + case 2: + if (_cflag != flgs) + break; + + if (flgs & 0x4000) { + v6 = 1; + if (flgs & 1) { + flgs2 ^= 1; + result = iFlag; + } + } + + if ((flgs & 2) && (flgs2 & 1)) + flgs2 &= 0xfffe; + break; + + case 3: + if ((flgs & 4) || (!buttonList->data2Val1)) + flgs2 &= 0xfffb; + else + flgs2 |= 4; + + if (flgs & 0x8000) { + v6 = 1; + break; + } + + if ((flgs & 2) && (flgs2 & 1)) + flgs2 &= 0xfffe; + break; + + default: + break; + } + } + } else { // if (_vm->_mouseX >= x2 && _vm->_mouseX <= (x2 + buttonList->width)....) + flgs2 &= 0xfff9; + + if ((flgs & 0x40) && (!(flgs & 0x80)) && _specialProcessButton && !v8) { + static const uint16 flagsTable[] = { 0x100, 0x200, 0x400, 0x800, 0x1000, 0x2000, 0x4000, 0x8000 }; + + if (vL) { + v16 = flagsTable[_flagsMouseLeft - 1]; + if (v16 & flgs) + v6 = 1; + } + + if (vR && !v6) { + v16 = flagsTable[_flagsMouseRight + 3]; + if (v16 & flgs) + v6 = 1; + } + + if (!v6) { + _specialProcessButton = 0; + _prcButtonUnk3 = 1; + } + } + + if ((flgs & 2) && (flgs2 & 1)) + flgs2 &= 0xfffe; + } // end if (_vm->_mouseX >= x2 && _vm->_mouseX <= (x2 + buttonList->width)....) + } // end if (_prcButtonUnk3) + } // end if (_flagsModifier || clickEvt) + + buttonList->flags = flgs; + buttonList->flags2 = flgs2; + + bool f21 = (flgs2 & 8) ? true : false; + bool f22 = (flgs2 & 1) ? true : false; + bool f23 = (flgs2 & 0x10) ? true : false; + bool f24 = (flgs2 & 4) ? true : false; + + if (f21 != f22 || f23 != f24) + processButton(buttonList); + + if (v6 && buttonList->buttonCallback) + runLoop = ((*buttonList->buttonCallback.get())(buttonList)) ? false : true; + + if ((flgs2 & 2) && (flgs & 0x20)) + runLoop = false; + + if (_specialProcessButton && ((vL && _flagsMouseLeft == 3) || (vR && _flagsMouseRight == 3))) { + _specialProcessButton = 0; + _prcButtonUnk3 = 1; + runLoop = false; + } + + if (_specialProcessButton && !v8) + runLoop = false; + + buttonList = buttonList->nextButton; + if (!buttonList) + runLoop = false; + }; + + if ((_flagsMouseLeft == 1 || _flagsMouseRight == 1) && !v18) + _cflag = 0xffff; + + if (!result) + result = inputFlags; + + return result; +} + +void GUI_Eob::setupMenu(int sd, int maxItem, const char *const *strings, int32 menuItemsMask, int unk, int lineSpacing) { + initMenuItemsMask(sd, maxItem, menuItemsMask, unk); + + const ScreenDim *dm = _screen->getScreenDim(19 + sd); + int x = (_screen->_curDim->sx + dm->sx) << 3; + int y = _screen->_curDim->sy + dm->sy; + + int v = getMenuItem(_menuCur, menuItemsMask, unk); + + for (int i = 0; i < _menuNumItems; i++) { + int item = getMenuItem(i, menuItemsMask, unk); + int ty = y + i * (lineSpacing + _screen->getFontHeight()); + _screen->printShadedText(strings[item], x, ty, dm->unkA, 0); + if (item == v) + _screen->printText(strings[item], x, ty, dm->unkC, 0); + } + + _screen->updateScreen(); + _menuLineSpacing = lineSpacing; + _menuUnk1 = 0; + _menuLastInFlags = 0; + _vm->removeInputTop(); +} + +int GUI_Eob::handleMenu(int sd, const char *const *strings, void *b, int32 menuItemsMask, int unk) { + const ScreenDim *dm = _screen->getScreenDim(19 + sd); + int h = _menuNumItems - 1; + int currentItem = _menuCur % _menuNumItems; + int newItem = currentItem; + int result = -1; + int lineH = (_menuLineSpacing + _screen->getFontHeight()); + int lineS1 = _menuLineSpacing >> 1; + int x = (_screen->_curDim->sx + dm->sx) << 3; + int y = _screen->_curDim->sy + dm->sy; + + int inFlag = _vm->checkInput(0, false, 0) & 0x8ff; + _vm->removeInputTop(); + Common::Point mousePos = _vm->getMousePos(); + + int x1 = (_screen->_curDim->sx << 3) + (dm->sx * _screen->getFontWidth()); + int y1 = _screen->_curDim->sy + dm->sy - lineS1; + int x2 = x1 + (dm->w * _screen->getFontWidth()) - 1; + int y2 = y1 + _menuNumItems * lineH - 1; + if (_vm->posWithinRect(mousePos.x, mousePos.y, x1, y1, x2, y2)) + newItem = (mousePos.y - y1) / lineH; + + if (inFlag == 199 || inFlag == 201) { + if (_vm->posWithinRect(_vm->_mouseX, _vm->_mouseY, x1, y1, x2, y2)) + result = newItem = (_vm->_mouseY - y1) / lineH; + } else if (inFlag == _vm->_keyMap[Common::KEYCODE_RETURN] || inFlag == _vm->_keyMap[Common::KEYCODE_SPACE] || inFlag == _vm->_keyMap[Common::KEYCODE_KP5]) { + result = newItem; + } else if (inFlag == _vm->_keyMap[Common::KEYCODE_HOME] || inFlag == _vm->_keyMap[Common::KEYCODE_KP7] || inFlag == _vm->_keyMap[Common::KEYCODE_PAGEUP] || inFlag == _vm->_keyMap[Common::KEYCODE_KP9]) { + newItem = 0; + } else if (inFlag == _vm->_keyMap[Common::KEYCODE_END] || inFlag == _vm->_keyMap[Common::KEYCODE_KP1] || inFlag == _vm->_keyMap[Common::KEYCODE_PAGEDOWN] || inFlag == _vm->_keyMap[Common::KEYCODE_KP3]) { + newItem = h; + } else if (inFlag == _vm->_keyMap[Common::KEYCODE_UP] || inFlag == _vm->_keyMap[Common::KEYCODE_KP8]) { + if (--newItem < 0) + newItem = h; + } else if (inFlag == _vm->_keyMap[Common::KEYCODE_DOWN] || inFlag == _vm->_keyMap[Common::KEYCODE_KP2]) { + if (++newItem > h) + newItem = 0; + } else { + _menuLastInFlags = inFlag; + } + + if (newItem != currentItem) { + _screen->printText(strings[getMenuItem(currentItem, menuItemsMask, unk)], x, y + currentItem * lineH , dm->unkA, 0); + _screen->printText(strings[getMenuItem(newItem, menuItemsMask, unk)], x, y + newItem * lineH , dm->unkC, 0); + _screen->updateScreen(); + } + + if (result != -1) { + result = getMenuItem(result, menuItemsMask, unk); + menuFlashSelection(strings[result], x, y + newItem * lineH, dm->unkA, dm->unkC, 0); + } + + _menuCur = newItem; + + return result; +} + +void GUI_Eob::initMenuItemsMask(int menuId, int maxItem, int32 menuItemsMask, int unk) { + if (menuItemsMask == -1) { + _menuNumItems = _screen->getScreenDim(19 + menuId)->h; + _menuCur = _screen->getScreenDim(19 + menuId)->unk8; + return; + } + + _menuNumItems = 0; + + for (int i = 0; i < maxItem; i++) { + if (menuItemsMask & (1 << (i + unk))) + _menuNumItems++; + } + + _menuCur = 0; +} + +int GUI_Eob::getMenuItem(int index, int32 menuItemsMask, int unk) { + if (menuItemsMask == -1) + return index; + + int res = 0; + int i = index; + + for (; i; res++) { + if (menuItemsMask & (1 << (res + unk))) + i--; + } + + while (!(menuItemsMask & (1 << (res + unk)))) + res++; + + return res; +} + +void GUI_Eob::menuFlashSelection(const char *str, int x, int y, int color1, int color2, int color3) { + for (int i = 0; i < 3; i++) { + _screen->printText(str, x, y, color2, color3); + _screen->updateScreen(); + _vm->_system->delayMillis(32); + _screen->printText(str, x, y, color1, color3); + _screen->updateScreen(); + _vm->_system->delayMillis(32); + } +} + +int GUI_Eob::getTextInput(char *dest, int x, int y, int destMaxLen, int textColor1, int textColor2, int cursorColor) { + uint8 cursorState = 1; + char sufx[] = " "; + + int len = strlen(dest); + if (len > destMaxLen) { + len = destMaxLen; + dest[destMaxLen] = 0; + } + + int pos = len; + if (len >= destMaxLen) + pos--; + + _screen->copyRegion((x - 1) << 3, y, 0, 191, (destMaxLen + 2) << 3, 9, 0, 2, Screen::CR_NO_P_CHECK); + _screen->printShadedText(dest, x << 3, y, textColor1, textColor2); + + uint32 next = _vm->_system->getMillis() + 2 * _vm->_tickLength; + sufx[0] = (pos < len) ? dest[pos] : 32; + _screen->printText(sufx, (x + pos) << 3, y, textColor1, cursorColor); + + int in = 0; + + do { + in = 0; + _keyPressed.reset(); + + while (!in) { + if (next <= _vm->_system->getMillis()) { + if (cursorState) { + _screen->copyRegion((pos + 1) << 3, 191, (x + pos) << 3, y, 8, 9, 2, 0, Screen::CR_NO_P_CHECK); + _screen->printShadedText(sufx, (x + pos) << 3, y, textColor1, textColor2); + } else { + _screen->printText(sufx, (x + pos) << 3, y, textColor1, cursorColor); + } + + _screen->updateScreen(); + cursorState ^= 1; + next = _vm->_system->getMillis() + 2 * _vm->_tickLength; + } + + _vm->updateInput(); + for (Common::List::const_iterator evt = _vm->_eventList.begin(); evt != _vm->_eventList.end(); ++evt) { + if (evt->event.type == Common::EVENT_KEYDOWN) { + _keyPressed = evt->event.kbd; + in = _keyPressed.ascii; + } + } + _vm->removeInputTop(); + } + + if (_keyPressed.keycode == Common::KEYCODE_BACKSPACE) { + if (pos >= len && len > 0) { + dest[--len] = 0; + pos--; + + } else if (pos > 0) { + for (int i = pos; i < destMaxLen; i++) + dest[i - 1] = dest[i]; + dest[--len] = 0; + pos--; + } + + } else if (_keyPressed.keycode == Common::KEYCODE_LEFT || _keyPressed.keycode == Common::KEYCODE_KP4) { + if (pos > 0) + pos--; + + } else if (_keyPressed.keycode == Common::KEYCODE_RIGHT || _keyPressed.keycode == Common::KEYCODE_KP6) { + if (pos < len && pos < (destMaxLen - 1)) + pos++; + + } else if (in > 31 && in < 126) { + if (!(in == 32 && pos == 0)) { + if (in >= 97 && in <= 122) + in -=32; + + if (pos < len) { + for (int i = destMaxLen - 1; i >= pos; i--) + dest[i + 1] = dest[i]; + + dest[pos++] = in; + + if (len == destMaxLen) + dest[len] = 0; + + } else { + if (pos == destMaxLen) { + pos--; + len--; + } + + dest[pos++] = in; + dest[pos] = 0; + } + + if (++len > destMaxLen) + len = destMaxLen; + + if (pos > (destMaxLen - 1)) + pos = (destMaxLen - 1); + } + } + + _screen->copyRegion(0, 191, (x - 1) << 3, y, (destMaxLen + 2) << 3, 9, 2, 0, Screen::CR_NO_P_CHECK); + _screen->printShadedText(dest, x << 3, y, textColor1, textColor2); + sufx[0] = (pos < len) ? dest[pos] : 32; + + if (cursorState) + _screen->printText(sufx, (x + pos) << 3, y, textColor1, cursorColor); + else + _screen->printShadedText(sufx, (x + pos) << 3, y, textColor1, textColor2); + _screen->updateScreen(); + + } while (_keyPressed.keycode != Common::KEYCODE_RETURN && _keyPressed.keycode != Common::KEYCODE_ESCAPE); + + return _keyPressed.keycode == Common::KEYCODE_ESCAPE ? -1 : len; +} + +#endif // ENABLE_EOB + +} // End of namespace Kyra + +#endif // defined(ENABLE_EOB) || defined(ENABLE_LOL) + -- cgit v1.2.3 From 80ece6caaef652e4d0f618ab793c11b00fcf9441 Mon Sep 17 00:00:00 2001 From: athrxx Date: Thu, 9 Jun 2011 23:59:11 +0200 Subject: KYRA: (EOB) - replace snprintf/sprintf --- engines/kyra/gui_eob.cpp | 79 ++++++++++++++++++++---------------------------- 1 file changed, 33 insertions(+), 46 deletions(-) (limited to 'engines/kyra/gui_eob.cpp') diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index 9aafb76189..34ab19034d 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -188,8 +188,6 @@ void EobCoreEngine::gui_drawCharPortraitWithStats(int index) { txtCol2 = 6; } - char tmpStr[10]; - if (_currentControlMode == 0) { int x2 = charPortraitPosX[index & 1]; int y2 = charPortraitPosY[index >> 1]; @@ -214,8 +212,8 @@ void EobCoreEngine::gui_drawCharPortraitWithStats(int index) { if (c->damageTaken > 0) { _screen->drawShape(2, _redSplatShape, x2 + 13, y2 + 30, 0); - sprintf(tmpStr, "%d", c->damageTaken); - _screen->printText(tmpStr, x2 + 34 - (strlen(tmpStr) * 3), y2 + 42, 15, 0); + Common::String tmpStr = Common::String::format("%d", c->damageTaken); + _screen->printText(tmpStr.c_str(), x2 + 34 - tmpStr.size() * 3, y2 + 42, 15, 0); } _screen->setCurPage(cp); @@ -272,19 +270,13 @@ void EobCoreEngine::gui_drawCharPortraitWithStats(int index) { _screen->printText(_characterGuiStringsIn[2], 239, 138, 12, _color6); _screen->printText(_characterGuiStringsIn[3], 278, 138, 12, _color6); - _screen->printText(getCharStrength(c->strengthCur, c->strengthExtCur), 275, 82, 15, _color6); - sprintf(tmpStr, "%d", c->intelligenceCur); - _screen->printText(tmpStr, 275, 89, 15, _color6); - sprintf(tmpStr, "%d", c->wisdomCur); - _screen->printText(tmpStr, 275, 96, 15, _color6); - sprintf(tmpStr, "%d", c->dexterityCur); - _screen->printText(tmpStr, 275, 103, 15, _color6); - sprintf(tmpStr, "%d", c->constitutionCur); - _screen->printText(tmpStr, 275, 110, 15, _color6); - sprintf(tmpStr, "%d", c->charismaCur); - _screen->printText(tmpStr, 275, 117, 15, _color6); - sprintf(tmpStr, "%d", c->armorClass); - _screen->printText(tmpStr, 275, 124, 15, _color6); + _screen->printText(getCharStrength(c->strengthCur, c->strengthExtCur).c_str(), 275, 82, 15, _color6); + _screen->printText(Common::String::format("%d", c->intelligenceCur).c_str(), 275, 89, 15, _color6); + _screen->printText(Common::String::format("%d", c->wisdomCur).c_str(), 275, 96, 15, _color6); + _screen->printText(Common::String::format("%d", c->dexterityCur).c_str(), 275, 103, 15, _color6); + _screen->printText(Common::String::format("%d", c->constitutionCur).c_str(), 275, 110, 15, _color6); + _screen->printText(Common::String::format("%d", c->charismaCur).c_str(), 275, 117, 15, _color6); + _screen->printText(Common::String::format("%d", c->armorClass).c_str(), 275, 124, 15, _color6); for (int i = 0; i < 3; i++) { int t = getClassHpIncreaseType(c->cClass, i); @@ -292,10 +284,10 @@ void EobCoreEngine::gui_drawCharPortraitWithStats(int index) { continue; _screen->printText(_chargenClassStrings[t + 15], 180, 145 + 7 * i, 12, _color6); - sprintf(tmpStr, "%d", c->experience[i]); - _screen->printText(tmpStr, 251 - strlen(tmpStr) * 3, 145 + 7 * i, 15, _color6); - sprintf(tmpStr, "%d", c->level[i]); - _screen->printText(tmpStr, 286 - strlen(tmpStr) * 3, 145 + 7 * i, 15, _color6); + Common::String tmpStr = Common::String::format("%d", c->experience[i]); + _screen->printText(tmpStr.c_str(), 251 - tmpStr.size() * 3, 145 + 7 * i, 15, _color6); + tmpStr = Common::String::format("%d", c->level[i]); + _screen->printText(tmpStr.c_str(), 286 - tmpStr.size() * 3, 145 + 7 * i, 15, _color6); } } @@ -397,10 +389,9 @@ void EobCoreEngine::gui_drawWeaponSlot(int charIndex, int slot) { } void EobCoreEngine::gui_drawWeaponSlotStatus(int x, int y, int status) { - char tmpStr[6]; - char tmpStr2[6]; - tmpStr2[0] = 0; - + Common::String tmpStr; + Common::String tmpStr2; + if (status > -3 || status == -5) _screen->drawShape(_screen->_curPage, _greenSplatShape, x - 1, y, 0); else @@ -408,32 +399,32 @@ void EobCoreEngine::gui_drawWeaponSlotStatus(int x, int y, int status) { switch (status + 5) { case 0: - strcpy(tmpStr, _characterGuiStringsWp[2]); + tmpStr = _characterGuiStringsWp[2]; break; case 1: - strcpy(tmpStr, _characterGuiStringsWr[2]); - strcpy(tmpStr2, _characterGuiStringsWr[3]); + tmpStr = _characterGuiStringsWr[2]; + tmpStr2 = _characterGuiStringsWr[3]; break; case 2: - strcpy(tmpStr, _characterGuiStringsWr[0]); - strcpy(tmpStr2, _characterGuiStringsWr[1]); + tmpStr = _characterGuiStringsWr[0]; + tmpStr2 = _characterGuiStringsWr[1]; break; case 3: - strcpy(tmpStr, _characterGuiStringsWp[1]); + tmpStr = _characterGuiStringsWp[1]; break; case 4: - strcpy(tmpStr, _characterGuiStringsWp[0]); + tmpStr = _characterGuiStringsWp[0]; break; default: - snprintf(tmpStr, 6, "%d", status); + tmpStr = Common::String::format("%d", status); break; } - if (tmpStr2[0]) { - _screen->printText(tmpStr, x + (16 - strlen(tmpStr) * 3), y + 2, 15, 0); - _screen->printText(tmpStr2, x + (16 - strlen(tmpStr) * 3), y + 9, 15, 0); + if (!tmpStr2.empty()) { + _screen->printText(tmpStr.c_str(), x + (16 - tmpStr.size() * 3), y + 2, 15, 0); + _screen->printText(tmpStr2.c_str(), x + (16 - tmpStr.size() * 3), y + 9, 15, 0); } else { - _screen->printText(tmpStr, x + (16 - strlen(tmpStr) * 3), y + 5, 15, 0); + _screen->printText(tmpStr.c_str(), x + (16 - tmpStr.size() * 3), y + 5, 15, 0); } } @@ -479,15 +470,14 @@ void EobCoreEngine::gui_drawHitpoints(int index) { gui_drawHorizontalBarGraph(x, y, w, h, bgCur, bgMax, barColor[col], _color5); } else { - char tmpString[12]; - snprintf(tmpString, 12, _characterGuiStringsHp[1], c->hitPointsCur, c->hitPointsMax); + Common::String tmpString = Common::String::format(_characterGuiStringsHp[1], c->hitPointsCur, c->hitPointsMax); if (!_currentControlMode) { x -= 13; y -= 1; } - _screen->printText(tmpString, x, y, 12, _bkgColor_1); + _screen->printText(tmpString.c_str(), x, y, 12, _bkgColor_1); } } @@ -596,9 +586,8 @@ void EobCoreEngine::gui_drawInventoryItem(int slot, int special, int pageNum) { _screen->fillRect(227, 65, 238, 69, 12); int cnt = countQueuedItems(_characters[_updateCharNum].inventory[slot], -1, -1, 1, 1); x = cnt >= 10 ? 227 : 233; - char str[3]; - snprintf(str, 3, "%d", cnt); - _screen->printText(str, x, 65, 15, 0); + Common::String str = Common::String::format("%d", cnt); + _screen->printText(str.c_str(), x, 65, 15, 0); } } @@ -653,9 +642,7 @@ void EobCoreEngine::gui_drawSpellbook() { _screen->printText(_magicStrings7[i], i * 21 + 73, 123, 12, 0); } else { gui_drawBox(i * 18 + 68, 121, 18, 9, col1, col2, col3); - char val[3]; - sprintf(val, "%d", i + 1); - _screen->printText(val, i * 18 + 75, 123, 12, 0); + _screen->printText(Common::String::format("%d", i + 1).c_str(), i * 18 + 75, 123, 12, 0); } } -- cgit v1.2.3 From adbf14c3c480890dfb155b896d1805e102311aa9 Mon Sep 17 00:00:00 2001 From: athrxx Date: Mon, 13 Jun 2011 17:38:28 +0200 Subject: KYRA: (EOB) - update static resources (menu strings) --- engines/kyra/gui_eob.cpp | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'engines/kyra/gui_eob.cpp') diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index 34ab19034d..02af458d65 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -834,6 +834,29 @@ int EobCoreEngine::clickedCharPortraitDefault(Button *button) { } int EobCoreEngine::clickedCamp(Button *button) { + gui_updateControls(); + disableSysTimer(2); + int cd = _screen->curDimIndex(); + + for (int i = 0; i < 6; i++) { + if (!testCharacter(i, 1)) + continue; + _characters[i].damageTaken = 0; + _characters[i].slotStatus[0] = _characters[i].slotStatus[1] = 0; + gui_drawCharPortraitWithStats(i); + } + + _screen->copyRegion(0, 120, 0, 0, 176, 24, 0, 14, Screen::CR_NO_P_CHECK); + Screen::FontId of = _screen->setFont(Screen::FID_8_FNT); + + + _screen->setFont(of); + _screen->setCurPage(0); + _screen->setScreenDim(cd); + + enableSysTimer(2); + updateCharacterEvents(true); + return button->arg; } @@ -1317,13 +1340,14 @@ void EobCoreEngine::gui_processWeaponSlotClickRight(int charIndex, int slotIndex case 7: // Food ration - /* don't do anything if mouse control is enabled */ - //eatItemInHand(charIndex); + // Don't do anything if mouse control is enabled (we don't support anything else) + // eatItemInHand(charIndex); break; case 10: if (_flags.gameID == GI_EOB1) vl += _clericSpellOffset; + // drop through case 9: // Mage/Cleric Scroll if (!_currentControlMode) -- cgit v1.2.3 From c8665d06bc59b695cb6c444b1e3c24104b69dec4 Mon Sep 17 00:00:00 2001 From: athrxx Date: Thu, 16 Jun 2011 18:51:47 +0200 Subject: KYRA: (EOB) - fix some warnings and add some menu code --- engines/kyra/gui_eob.cpp | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'engines/kyra/gui_eob.cpp') diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index 02af458d65..56c5acd3df 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -456,7 +456,7 @@ void EobCoreEngine::gui_drawHitpoints(int index) { EobCharacter *c = &_characters[index]; - if (_hpBarGraphs) { + if (_configHpBarGraphs) { int bgCur = c->hitPointsCur + 10; int bgMax = c->hitPointsMax + 10; int col = ((bgMax / 3) > bgCur) ? 1 : 0; @@ -849,10 +849,32 @@ int EobCoreEngine::clickedCamp(Button *button) { _screen->copyRegion(0, 120, 0, 0, 176, 24, 0, 14, Screen::CR_NO_P_CHECK); Screen::FontId of = _screen->setFont(Screen::FID_8_FNT); + for (int i = 0; i < 4; i++) { + delete _menuStringsPrefsTemp[i]; + _menuStringsPrefsTemp[i] = new char[strlen(_menuStringsPrefs[i]) + 8]; + } + Common::strlcpy(_menuStringsPrefsTemp[0], Common::String::format(_menuStringsPrefs[0], _menuStringsOnOff[_configMusic ? 0 : 1]).c_str(), strlen(_menuStringsPrefs[0]) + 8); + Common::strlcpy(_menuStringsPrefsTemp[1], Common::String::format(_menuStringsPrefs[1], _menuStringsOnOff[_configSounds ? 0 : 1]).c_str(), strlen(_menuStringsPrefs[1]) + 8); + Common::strlcpy(_menuStringsPrefsTemp[2], Common::String::format(_menuStringsPrefs[2], _menuStringsOnOff[_configHpBarGraphs ? 0 : 1]).c_str(), strlen(_menuStringsPrefs[2]) + 8); + Common::strlcpy(_menuStringsPrefsTemp[3], Common::String::format(_menuStringsPrefs[3], _menuStringsOnOff[_configMouse ? 0 : 1]).c_str(), strlen(_menuStringsPrefs[3]) + 8); + _screen->setFont(of); - _screen->setCurPage(0); + _screen->copyRegion(0, 0, 0, 120, 176, 24, 14, 2, Screen::CR_NO_P_CHECK); _screen->setScreenDim(cd); + drawScene(0); + + //for (int i = 0; i < 6; i++) + // cleanupCharacterSpellList(i); + + _screen->setCurPage(0); + const ScreenDim *dm = _screen->getScreenDim(10); + _screen->copyRegion(dm->sx << 3, dm->sy, dm->sx << 3, dm->sy, dm->w << 3, dm->h, 2, 0, Screen::CR_NO_P_CHECK); + + //if (displayInv) + // _screen->loadEobCpsFileToPage("INVENT", 0, 5, 3, 2); + + _screen->updateScreen(); enableSysTimer(2); updateCharacterEvents(true); @@ -1548,7 +1570,7 @@ int GUI_Eob::processButtonList(Kyra::Button *buttonList, uint16 inputFlags, int8 uint16 in = inputFlags & 0xff; uint16 buttonReleaseFlag = 0; bool clickEvt = false; - + _vm->TTTTT = true; _flagsMouseLeft = (_vm->_mouseClick == 1) ? 2 : 4; _flagsMouseRight = (_vm->_mouseClick == 2) ? 2 : 4; _vm->_mouseClick = 0; @@ -1919,7 +1941,7 @@ int GUI_Eob::processButtonList(Kyra::Button *buttonList, uint16 inputFlags, int8 if (!result) result = inputFlags; - +_vm-> TTTTT=false; return result; } -- cgit v1.2.3 From 6853452bcbed083aa84638f11e4ce04ca189f0a1 Mon Sep 17 00:00:00 2001 From: athrxx Date: Fri, 17 Jun 2011 17:35:00 +0200 Subject: KYRA: (EOB) - fix shift key input --- engines/kyra/gui_eob.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'engines/kyra/gui_eob.cpp') diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index 56c5acd3df..10eabe937f 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -1570,7 +1570,7 @@ int GUI_Eob::processButtonList(Kyra::Button *buttonList, uint16 inputFlags, int8 uint16 in = inputFlags & 0xff; uint16 buttonReleaseFlag = 0; bool clickEvt = false; - _vm->TTTTT = true; + //_vm->_processingButtons = true; _flagsMouseLeft = (_vm->_mouseClick == 1) ? 2 : 4; _flagsMouseRight = (_vm->_mouseClick == 2) ? 2 : 4; _vm->_mouseClick = 0; @@ -1589,7 +1589,7 @@ int GUI_Eob::processButtonList(Kyra::Button *buttonList, uint16 inputFlags, int8 inputFlags = 0; clickEvt = true; - } else { + } else if (inputFlags & 0x8000) { inputFlags &= 0xff; } @@ -1668,13 +1668,13 @@ int GUI_Eob::processButtonList(Kyra::Button *buttonList, uint16 inputFlags, int8 uint16 vR = 0; if (inputFlags) { - if (buttonList->keyCode == in) { + if (buttonList->keyCode == inputFlags) { _progress = 1; _flagsMouseLeft = 1; flgs2 ^= 1; result = iFlag; v6 = 1; - } else if (buttonList->keyCode2 == in) { + } else if (buttonList->keyCode2 == inputFlags) { _progress = 2; _flagsMouseRight = 1; result = iFlag; @@ -1941,7 +1941,9 @@ int GUI_Eob::processButtonList(Kyra::Button *buttonList, uint16 inputFlags, int8 if (!result) result = inputFlags; -_vm-> TTTTT=false; + + //_vm->_processingButtons=false; + return result; } -- cgit v1.2.3 From 045d08986d3accc3fc7d55d76eb550db01ad7fc7 Mon Sep 17 00:00:00 2001 From: athrxx Date: Wed, 22 Jun 2011 01:08:28 +0200 Subject: KYRA: (EOB) - start implementing camp menu --- engines/kyra/gui_eob.cpp | 393 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 362 insertions(+), 31 deletions(-) (limited to 'engines/kyra/gui_eob.cpp') diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index 10eabe937f..9baed752a3 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -24,6 +24,7 @@ #include "kyra/eobcommon.h" #include "kyra/gui_eob.h" +#include "kyra/text_eob.h" #include "kyra/timer.h" #include "kyra/util.h" @@ -847,25 +848,15 @@ int EobCoreEngine::clickedCamp(Button *button) { } _screen->copyRegion(0, 120, 0, 0, 176, 24, 0, 14, Screen::CR_NO_P_CHECK); - Screen::FontId of = _screen->setFont(Screen::FID_8_FNT); - for (int i = 0; i < 4; i++) { - delete _menuStringsPrefsTemp[i]; - _menuStringsPrefsTemp[i] = new char[strlen(_menuStringsPrefs[i]) + 8]; - } - - Common::strlcpy(_menuStringsPrefsTemp[0], Common::String::format(_menuStringsPrefs[0], _menuStringsOnOff[_configMusic ? 0 : 1]).c_str(), strlen(_menuStringsPrefs[0]) + 8); - Common::strlcpy(_menuStringsPrefsTemp[1], Common::String::format(_menuStringsPrefs[1], _menuStringsOnOff[_configSounds ? 0 : 1]).c_str(), strlen(_menuStringsPrefs[1]) + 8); - Common::strlcpy(_menuStringsPrefsTemp[2], Common::String::format(_menuStringsPrefs[2], _menuStringsOnOff[_configHpBarGraphs ? 0 : 1]).c_str(), strlen(_menuStringsPrefs[2]) + 8); - Common::strlcpy(_menuStringsPrefsTemp[3], Common::String::format(_menuStringsPrefs[3], _menuStringsOnOff[_configMouse ? 0 : 1]).c_str(), strlen(_menuStringsPrefs[3]) + 8); + _gui->runCampMenu(); - _screen->setFont(of); _screen->copyRegion(0, 0, 0, 120, 176, 24, 14, 2, Screen::CR_NO_P_CHECK); _screen->setScreenDim(cd); drawScene(0); - //for (int i = 0; i < 6; i++) - // cleanupCharacterSpellList(i); + for (int i = 0; i < 6; i++) + cleanupCharacterSpellList(i); _screen->setCurPage(0); const ScreenDim *dm = _screen->getScreenDim(10); @@ -1447,18 +1438,30 @@ GUI_Eob::GUI_Eob(EobCoreEngine *vm) : GUI(vm), _vm(vm), _screen(vm->_screen) { _redrawButtonFunctor = BUTTON_FUNCTOR(GUI, this, &GUI::redrawButtonCallback); _redrawShadedButtonFunctor = BUTTON_FUNCTOR(GUI, this, &GUI::redrawShadedButtonCallback); + _menuStringsPrefsTemp = new char*[4]; + memset(_menuStringsPrefsTemp, 0, 4 * sizeof(char*)); + _specialProcessButton = _backupButtonList = 0; _flagsMouseLeft = _flagsMouseRight = _flagsModifier = 0; _backupButtonList = 0; _progress = 0; _prcButtonUnk3 = 1; _cflag = 0xffff; - + _menuLineSpacing = 0; _menuUnk1 = 0; _menuLastInFlags = 0; _menuCur = 0; _menuNumItems = 0; + _menuButtons = 0; +} + +GUI_Eob::~GUI_Eob() { + if (_menuStringsPrefsTemp) { + for (int i = 0; i < 4; i++) + delete _menuStringsPrefsTemp[i]; + delete[] _menuStringsPrefsTemp; + } } void GUI_Eob::processButton(Button *button) { @@ -2028,23 +2031,6 @@ int GUI_Eob::handleMenu(int sd, const char *const *strings, void *b, int32 menuI return result; } -void GUI_Eob::initMenuItemsMask(int menuId, int maxItem, int32 menuItemsMask, int unk) { - if (menuItemsMask == -1) { - _menuNumItems = _screen->getScreenDim(19 + menuId)->h; - _menuCur = _screen->getScreenDim(19 + menuId)->unk8; - return; - } - - _menuNumItems = 0; - - for (int i = 0; i < maxItem; i++) { - if (menuItemsMask & (1 << (i + unk))) - _menuNumItems++; - } - - _menuCur = 0; -} - int GUI_Eob::getMenuItem(int index, int32 menuItemsMask, int unk) { if (menuItemsMask == -1) return index; @@ -2074,6 +2060,172 @@ void GUI_Eob::menuFlashSelection(const char *str, int x, int y, int color1, int } } +int GUI_Eob::runCampMenu() { + Screen::FontId of = _screen->setFont(Screen::FID_8_FNT); + + Button *highlightButton = 0; + Button *prevHighlightButton = 0; + + int newMenu = 0; + int lastMenu = -1; + int e = 0; + int menuG = 0; + int menuH = 0; + _menuButtons = 0; + + for (bool runLoop = true; runLoop && !_vm->shouldQuit(); ) { + if (newMenu == 2) + updateOptionsStrings(); + + if (newMenu != -1) { + releaseButtons(_menuButtons); + + _vm->_menuDefs[0].titleStrId = newMenu ? 1 : 56; + if (newMenu == 2) + _vm->_menuDefs[2].titleStrId = 57; + else if (newMenu == 1) + _vm->_menuDefs[1].titleStrId = 58; + + _menuButtons = initMenu(newMenu); + + if (newMenu != lastMenu) { + highlightButton = _menuButtons; + prevHighlightButton = 0; + } + + lastMenu = newMenu; + newMenu = -1; + } + + int inputFlag = _vm->checkInput(_menuButtons, false, 0) & 0x80ff; + _vm->removeInputTop(); + + if (inputFlag == _vm->_keyMap[Common::KEYCODE_ESCAPE]) + inputFlag = 0x8007; + else if (inputFlag == _vm->_keyMap[Common::KEYCODE_KP5] || inputFlag == _vm->_keyMap[Common::KEYCODE_SPACE] || inputFlag == _vm->_keyMap[Common::KEYCODE_RETURN]) { + inputFlag = 0x8000 + prevHighlightButton->index; + } + + Button *clickedButton = _vm->gui_getButton(_menuButtons, inputFlag & 0x7fff); + + if (clickedButton) { + drawMenuButton(prevHighlightButton, false, false, true); + drawMenuButton(clickedButton, true, true, true); + _screen->updateScreen(); + _vm->_system->delayMillis(80); + drawMenuButton(clickedButton, false, true, true); + _screen->updateScreen(); + highlightButton = clickedButton; + prevHighlightButton = 0; + } + + if (inputFlag == _vm->_keyMap[Common::KEYCODE_KP3] || inputFlag == _vm->_keyMap[Common::KEYCODE_PAGEDOWN] || inputFlag == _vm->_keyMap[Common::KEYCODE_KP1] || inputFlag == _vm->_keyMap[Common::KEYCODE_END]) { + highlightButton = _vm->gui_getButton(_menuButtons, _vm->_menuDefs[lastMenu].firstButtonStrId + _vm->_menuDefs[lastMenu].numButtons); + inputFlag = _vm->_keyMap[Common::KEYCODE_UP]; + } else if (inputFlag == _vm->_keyMap[Common::KEYCODE_KP7] || inputFlag == _vm->_keyMap[Common::KEYCODE_HOME] || inputFlag == _vm->_keyMap[Common::KEYCODE_KP9] || inputFlag == _vm->_keyMap[Common::KEYCODE_PAGEUP]) { + highlightButton = _vm->gui_getButton(_menuButtons, _vm->_menuDefs[lastMenu].firstButtonStrId + 1); + } else if (inputFlag == _vm->_keyMap[Common::KEYCODE_KP8] || inputFlag == _vm->_keyMap[Common::KEYCODE_UP] || inputFlag == _vm->_keyMap[Common::KEYCODE_KP2] || inputFlag == _vm->_keyMap[Common::KEYCODE_DOWN]) { + if (prevHighlightButton) { + int dir = (inputFlag == _vm->_keyMap[Common::KEYCODE_UP]) ? -1 : 1; + int s = prevHighlightButton->index + dir; + int a = _vm->_menuDefs[lastMenu].firstButtonStrId + 1; + int b = a + _vm->_menuDefs[lastMenu].numButtons - 1; + + do { + if (s < a) + s = b; + if (s > b) + s = a; + if (_vm->_menuButtonDefs[s - 1].flags & 2) + break; + s += dir; + } while(!_vm->shouldQuit()); + + highlightButton = _vm->gui_getButton(_menuButtons, s); + } + + } else if (inputFlag > 0x8001 && inputFlag < 0x8010) { + switch (inputFlag) { + case 0x8001: + break; + case 0x8002: + break; + case 0x8003: + break; + case 0x8004: + break; + case 0x8005: + newMenu = 2; + break; + case 0x8006: + newMenu = 1; + break; + case 0x8007: + if (menuH) + displayTextBox(44); + // fall through + case 0x800c: + case 0x800f: + if (lastMenu == 1 || lastMenu == 2) + newMenu = 0; + else if (inputFlag == _vm->_keyMap[Common::KEYCODE_ESCAPE]) + newMenu = 0; + else + runLoop = false; + break; + case 0x8008: + break; + case 0x8009: + break; + case 0x800a: + break; + case 0x800b: + break; + case 0x800d: + break; + case 0x800e: + break; + default: + break; + } + + } else { + Common::Point p = _vm->getMousePos(); + for (Button *b = _menuButtons; b; b = b->nextButton) { + if ((b->arg & 2) && _vm->posWithinRect(p.x, p.y, b->x, b->y, b->x + b->width, b->y + b->height)) + highlightButton = b; + } + } + + if (menuG || e) { + for (int i = 0; i < 6; i++) { + _vm->gui_drawCharPortraitWithStats(i); + _vm->cleanupCharacterSpellList(i); + } + } + + menuG = e = 0; + + if (prevHighlightButton != highlightButton && newMenu == -1 && runLoop) { + drawMenuButton(prevHighlightButton, false, false, true); + drawMenuButton(highlightButton, false, true, true); + _screen->updateScreen(); + prevHighlightButton = highlightButton; + } + } + + releaseButtons(_menuButtons); + _menuButtons = 0; + + _screen->setFont(of); + + return 0; +} + +int GUI_Eob::runLoadMenu(int x, int y) { + return 0; +} + int GUI_Eob::getTextInput(char *dest, int x, int y, int destMaxLen, int textColor1, int textColor2, int cursorColor) { uint8 cursorState = 1; char sufx[] = " "; @@ -2192,6 +2344,185 @@ 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::initMenuItemsMask(int menuId, int maxItem, int32 menuItemsMask, int unk) { + if (menuItemsMask == -1) { + _menuNumItems = _screen->getScreenDim(19 + menuId)->h; + _menuCur = _screen->getScreenDim(19 + menuId)->unk8; + return; + } + + _menuNumItems = 0; + + for (int i = 0; i < maxItem; i++) { + if (menuItemsMask & (1 << (i + unk))) + _menuNumItems++; + } + + _menuCur = 0; +} + +Button *GUI_Eob::initMenu(int id) { + _screen->setCurPage(2); + + EobMenuDef *m = &_vm->_menuDefs[id]; + + if (m->dim) { + const ScreenDim *dm = _screen->getScreenDim(m->dim); + _screen->fillRect(dm->sx << 3, dm->sy, ((dm->sx + dm->w) << 3) - 1, (dm->sy + dm->h) - 1, _vm->_bkgColor_1); + _screen->setScreenDim(m->dim); + drawMenuButtonBox(dm->sx << 3, dm->sy, dm->w << 3, dm->h, false, false); + } + + _screen->printShadedText(getMenuString(m->titleStrId), 5, 5, m->titleCol, 0); + + Button *buttons = 0; + 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->data0Val2 = 12; + b->data1Val2 = b->data2Val2 = 15; + b->data3Val2 = 8; + b->flags = 0x1100; + b->keyCode = df->keyCode; + b->keyCode2 = df->keyCode | 0x100; + b->x = df->x; + b->y = df->y; + b->width = df->width; + b->height = df->height; + b->extButtonDef = df; + b->arg = df->flags; + + drawMenuButton(b, false, false, false); + buttons = linkButton(buttons, b); + } + + _screen->copyRegion(_screen->_curDim->sx << 3, _screen->_curDim->sy, _screen->_curDim->sx << 3, _screen->_curDim->sy, _screen->_curDim->w << 3, _screen->_curDim->h, 2, 0, Screen::CR_NO_P_CHECK); + _vm->gui_notifyButtonListChanged(); + _screen->setCurPage(0); + _screen->updateScreen(); + + return buttons; +} + +void GUI_Eob::drawMenuButton(Button *b, bool clicked, bool highlight, bool noFill) { + if (!b) + return; + + EobMenuButtonDef *d = (EobMenuButtonDef*)b->extButtonDef; + + if (d->flags & 1) + drawMenuButtonBox(b->x, b->y, b->width, b->height, clicked, noFill); + + if (d->labelId) { + const char *s = getMenuString(d->labelId); + + int xOffs = 4; + int yOffs = 3; + + if (d->flags & 4) { + xOffs = ((b->width - (strlen(s) << 3)) >> 1) + 1; + yOffs = (b->height - 7) >> 1; + } + + if (noFill || clicked) + _screen->printText(s, b->x + xOffs, b->y + yOffs, highlight ? 6 : 15, 0); + else + _screen->printShadedText(s, b->x + xOffs, b->y + yOffs, highlight ? 6 : 15, 0); + } +} + +void GUI_Eob::drawMenuButtonBox(int x, int y, int w, int h, bool clicked, bool noFill) { + uint8 col1 = _vm->_color1_1; + uint8 col2 = _vm->_color2_1; + + if (clicked) + col1 = col2 = _vm->_bkgColor_1; + + _vm->gui_drawBox(x, y, w, h, col1, col2, -1); + _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::displayTextBox(int id) { + +} + +void GUI_Eob::updateOptionsStrings() { + for (int i = 0; i < 4; i++) { + delete _menuStringsPrefsTemp[i]; + _menuStringsPrefsTemp[i] = new char[strlen(_vm->_menuStringsPrefs[i]) + 8]; + } + + Common::strlcpy(_menuStringsPrefsTemp[0], Common::String::format(_vm->_menuStringsPrefs[0], _vm->_menuStringsOnOff[_vm->_configMusic ? 0 : 1]).c_str(), strlen(_vm->_menuStringsPrefs[0]) + 8); + Common::strlcpy(_menuStringsPrefsTemp[1], Common::String::format(_vm->_menuStringsPrefs[1], _vm->_menuStringsOnOff[_vm->_configSounds ? 0 : 1]).c_str(), strlen(_vm->_menuStringsPrefs[1]) + 8); + Common::strlcpy(_menuStringsPrefsTemp[2], Common::String::format(_vm->_menuStringsPrefs[2], _vm->_menuStringsOnOff[_vm->_configHpBarGraphs ? 0 : 1]).c_str(), strlen(_vm->_menuStringsPrefs[2]) + 8); + Common::strlcpy(_menuStringsPrefsTemp[3], Common::String::format(_vm->_menuStringsPrefs[3], _vm->_menuStringsOnOff[_vm->_configMouse ? 0 : 1]).c_str(), strlen(_vm->_menuStringsPrefs[3]) + 8); +} + +const char *GUI_Eob::getMenuString(int id) { + if (id >= 69) + return _vm->_menuStringsTransfer[id - 69]; + else if (id >= 67) + return _vm->_menuStringsDefeat[id - 67]; + else if (id >= 63) + return _vm->_menuStringsSpec[id - 63]; + else if (id >= 60) + return _vm->_menuStringsSpellNo[id - 60]; + else if (id == 59) + return _vm->_menuStringsPoison[0]; + else if (id >= 56) + return _vm->_menuStringsHead[id - 56]; + else if (id >= 53) + return _vm->_menuStringsDrop2[id - 53]; + else if (id >= 48) + return _vm->_menuStringsScribe[id - 48]; + else if (id == 47) + _vm->_menuStringsStarve[0]; + else if (id == 46) + _vm->_menuStringsExit[0]; + else if (id == 45) + _vm->_menuStringsDrop[0]; + else if (id >= 40) + return _vm->_menuStringsRest[id - 40]; + else if (id >= 23) + return _vm->_menuStringsSpells[id - 23]; + else if (id >= 21) + return _vm->_menuStringsOnOff[id - 21]; + else if (id >= 17) + return _menuStringsPrefsTemp[id - 17]; + else if (id >= 9) + return _vm->_menuStringsSaveLoad[id - 9]; + else if (id >= 1) + return _vm->_menuStringsMain[id - 1]; + return 0; +} + +Button *GUI_Eob::linkButton(Button *list, Button *newbt) { + if (!list) { + list = newbt; + return list; + } + + if (!newbt) + return list; + + Button *resList = list; + while (list->nextButton) + list = list->nextButton; + list->nextButton = newbt; + newbt->nextButton = 0; + + return resList; +} + +void GUI_Eob::releaseButtons(Button *list) { + while (list) { + Button *n = list->nextButton; + delete list; + list = n; + } +} + #endif // ENABLE_EOB } // End of namespace Kyra -- cgit v1.2.3 From 97e5036bf0022f1b5e2ce5a9fe3a11d5f3216b50 Mon Sep 17 00:00:00 2001 From: athrxx Date: Thu, 23 Jun 2011 22:42:12 +0200 Subject: KYRA: (EOB) - more work on ingame menus --- engines/kyra/gui_eob.cpp | 447 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 392 insertions(+), 55 deletions(-) (limited to 'engines/kyra/gui_eob.cpp') diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index 9baed752a3..4d5a1bf438 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -151,7 +151,7 @@ void EobCoreEngine::gui_drawPlayField(int pageNum) { int cp = _screen->setCurPage(2); gui_drawCompass(true); - if (pageNum && !_sceneDrawPage1) + if (pageNum && !_sceneDrawPage2) drawScene(0); _screen->setCurPage(cp); @@ -280,7 +280,7 @@ void EobCoreEngine::gui_drawCharPortraitWithStats(int index) { _screen->printText(Common::String::format("%d", c->armorClass).c_str(), 275, 124, 15, _color6); for (int i = 0; i < 3; i++) { - int t = getClassHpIncreaseType(c->cClass, i); + int t = getCharacterClassType(c->cClass, i); if (t == -1) continue; @@ -862,8 +862,8 @@ int EobCoreEngine::clickedCamp(Button *button) { const ScreenDim *dm = _screen->getScreenDim(10); _screen->copyRegion(dm->sx << 3, dm->sy, dm->sx << 3, dm->sy, dm->w << 3, dm->h, 2, 0, Screen::CR_NO_P_CHECK); - //if (displayInv) - // _screen->loadEobCpsFileToPage("INVENT", 0, 5, 3, 2); + /*if (reloadInv) + _screen->loadEobCpsFileToPage("INVENT", 0, 5, 3, 2);*/ _screen->updateScreen(); @@ -948,11 +948,7 @@ int EobCoreEngine::clickedCharNameLabelRight(Button *button) { } else { int d = _exchangeCharacterId; _exchangeCharacterId = -1; - - EobCharacter temp; - memcpy(&temp, &_characters[d], sizeof(EobCharacter)); - memcpy(&_characters[d], &_characters[button->arg], sizeof(EobCharacter)); - memcpy(&_characters[button->arg], &temp, sizeof(EobCharacter)); + exchangeCharacters(d, button->arg); _timer->disable(0); gui_drawCharPortraitWithStats(d); @@ -1432,11 +1428,11 @@ void EobCoreEngine::gui_processInventorySlotClick(int slot) { } } -GUI_Eob::GUI_Eob(EobCoreEngine *vm) : GUI(vm), _vm(vm), _screen(vm->_screen) { +GUI_Eob::GUI_Eob(EobCoreEngine *vm) : GUI_v1(vm), _vm(vm), _screen(vm->_screen) { _scrollUpFunctor = _scrollDownFunctor = BUTTON_FUNCTOR(GUI_Eob, this, 0); - _redrawButtonFunctor = BUTTON_FUNCTOR(GUI, this, &GUI::redrawButtonCallback); - _redrawShadedButtonFunctor = BUTTON_FUNCTOR(GUI, this, &GUI::redrawShadedButtonCallback); + _redrawButtonFunctor = BUTTON_FUNCTOR(GUI_v1, this, &GUI_v1::redrawButtonCallback); + _redrawShadedButtonFunctor = BUTTON_FUNCTOR(GUI_v1, this, &GUI_v1::redrawShadedButtonCallback); _menuStringsPrefsTemp = new char*[4]; memset(_menuStringsPrefsTemp, 0, 4 * sizeof(char*)); @@ -1453,7 +1449,12 @@ GUI_Eob::GUI_Eob(EobCoreEngine *vm) : GUI(vm), _vm(vm), _screen(vm->_screen) { _menuLastInFlags = 0; _menuCur = 0; _menuNumItems = 0; - _menuButtons = 0; + + _charSelectRedraw = false; + + _updateBoxIndex = -1; + _highLightBoxTimer = 0; + _updateBoxColorIndex = 0; } GUI_Eob::~GUI_Eob() { @@ -1950,17 +1951,17 @@ int GUI_Eob::processButtonList(Kyra::Button *buttonList, uint16 inputFlags, int8 return result; } -void GUI_Eob::setupMenu(int sd, int maxItem, const char *const *strings, int32 menuItemsMask, int unk, int lineSpacing) { - initMenuItemsMask(sd, maxItem, menuItemsMask, unk); +void GUI_Eob::simpleMenu_setup(int sd, int maxItem, const char *const *strings, int32 menuItemsMask, int unk, int lineSpacing) { + simpleMenu_initMenuItemsMask(sd, maxItem, menuItemsMask, unk); const ScreenDim *dm = _screen->getScreenDim(19 + sd); int x = (_screen->_curDim->sx + dm->sx) << 3; int y = _screen->_curDim->sy + dm->sy; - int v = getMenuItem(_menuCur, menuItemsMask, unk); + int v = simpleMenu_getMenuItem(_menuCur, menuItemsMask, unk); for (int i = 0; i < _menuNumItems; i++) { - int item = getMenuItem(i, menuItemsMask, unk); + int item = simpleMenu_getMenuItem(i, menuItemsMask, unk); int ty = y + i * (lineSpacing + _screen->getFontHeight()); _screen->printShadedText(strings[item], x, ty, dm->unkA, 0); if (item == v) @@ -1974,7 +1975,7 @@ void GUI_Eob::setupMenu(int sd, int maxItem, const char *const *strings, int32 m _vm->removeInputTop(); } -int GUI_Eob::handleMenu(int sd, const char *const *strings, void *b, int32 menuItemsMask, int unk) { +int GUI_Eob::simpleMenu_process(int sd, const char *const *strings, void *b, int32 menuItemsMask, int unk) { const ScreenDim *dm = _screen->getScreenDim(19 + sd); int h = _menuNumItems - 1; int currentItem = _menuCur % _menuNumItems; @@ -2016,14 +2017,14 @@ int GUI_Eob::handleMenu(int sd, const char *const *strings, void *b, int32 menuI } if (newItem != currentItem) { - _screen->printText(strings[getMenuItem(currentItem, menuItemsMask, unk)], x, y + currentItem * lineH , dm->unkA, 0); - _screen->printText(strings[getMenuItem(newItem, menuItemsMask, unk)], x, y + newItem * lineH , dm->unkC, 0); + _screen->printText(strings[simpleMenu_getMenuItem(currentItem, menuItemsMask, unk)], x, y + currentItem * lineH , dm->unkA, 0); + _screen->printText(strings[simpleMenu_getMenuItem(newItem, menuItemsMask, unk)], x, y + newItem * lineH , dm->unkC, 0); _screen->updateScreen(); } if (result != -1) { - result = getMenuItem(result, menuItemsMask, unk); - menuFlashSelection(strings[result], x, y + newItem * lineH, dm->unkA, dm->unkC, 0); + result = simpleMenu_getMenuItem(result, menuItemsMask, unk); + simpleMenu_flashSelection(strings[result], x, y + newItem * lineH, dm->unkA, dm->unkC, 0); } _menuCur = newItem; @@ -2031,7 +2032,7 @@ int GUI_Eob::handleMenu(int sd, const char *const *strings, void *b, int32 menuI return result; } -int GUI_Eob::getMenuItem(int index, int32 menuItemsMask, int unk) { +int GUI_Eob::simpleMenu_getMenuItem(int index, int32 menuItemsMask, int unk) { if (menuItemsMask == -1) return index; @@ -2049,7 +2050,7 @@ int GUI_Eob::getMenuItem(int index, int32 menuItemsMask, int unk) { return res; } -void GUI_Eob::menuFlashSelection(const char *str, int x, int y, int color1, int color2, int color3) { +void GUI_Eob::simpleMenu_flashSelection(const char *str, int x, int y, int color1, int color2, int color3) { for (int i = 0; i < 3; i++) { _screen->printText(str, x, y, color2, color3); _screen->updateScreen(); @@ -2060,7 +2061,7 @@ void GUI_Eob::menuFlashSelection(const char *str, int x, int y, int color1, int } } -int GUI_Eob::runCampMenu() { +void GUI_Eob::runCampMenu() { Screen::FontId of = _screen->setFont(Screen::FID_8_FNT); Button *highlightButton = 0; @@ -2068,17 +2069,18 @@ int GUI_Eob::runCampMenu() { int newMenu = 0; int lastMenu = -1; - int e = 0; - int menuG = 0; - int menuH = 0; - _menuButtons = 0; + bool redrawPortraits = false; + bool res = false; + _charSelectRedraw = false; + _vm->_resting = false; + Button *buttonList = 0; for (bool runLoop = true; runLoop && !_vm->shouldQuit(); ) { if (newMenu == 2) updateOptionsStrings(); if (newMenu != -1) { - releaseButtons(_menuButtons); + releaseButtons(buttonList); _vm->_menuDefs[0].titleStrId = newMenu ? 1 : 56; if (newMenu == 2) @@ -2086,10 +2088,10 @@ int GUI_Eob::runCampMenu() { else if (newMenu == 1) _vm->_menuDefs[1].titleStrId = 58; - _menuButtons = initMenu(newMenu); + buttonList = initMenu(newMenu); if (newMenu != lastMenu) { - highlightButton = _menuButtons; + highlightButton = buttonList; prevHighlightButton = 0; } @@ -2097,7 +2099,7 @@ int GUI_Eob::runCampMenu() { newMenu = -1; } - int inputFlag = _vm->checkInput(_menuButtons, false, 0) & 0x80ff; + int inputFlag = _vm->checkInput(buttonList, false, 0) & 0x80ff; _vm->removeInputTop(); if (inputFlag == _vm->_keyMap[Common::KEYCODE_ESCAPE]) @@ -2106,7 +2108,7 @@ int GUI_Eob::runCampMenu() { inputFlag = 0x8000 + prevHighlightButton->index; } - Button *clickedButton = _vm->gui_getButton(_menuButtons, inputFlag & 0x7fff); + Button *clickedButton = _vm->gui_getButton(buttonList, inputFlag & 0x7fff); if (clickedButton) { drawMenuButton(prevHighlightButton, false, false, true); @@ -2120,10 +2122,10 @@ int GUI_Eob::runCampMenu() { } if (inputFlag == _vm->_keyMap[Common::KEYCODE_KP3] || inputFlag == _vm->_keyMap[Common::KEYCODE_PAGEDOWN] || inputFlag == _vm->_keyMap[Common::KEYCODE_KP1] || inputFlag == _vm->_keyMap[Common::KEYCODE_END]) { - highlightButton = _vm->gui_getButton(_menuButtons, _vm->_menuDefs[lastMenu].firstButtonStrId + _vm->_menuDefs[lastMenu].numButtons); + highlightButton = _vm->gui_getButton(buttonList, _vm->_menuDefs[lastMenu].firstButtonStrId + _vm->_menuDefs[lastMenu].numButtons); inputFlag = _vm->_keyMap[Common::KEYCODE_UP]; } else if (inputFlag == _vm->_keyMap[Common::KEYCODE_KP7] || inputFlag == _vm->_keyMap[Common::KEYCODE_HOME] || inputFlag == _vm->_keyMap[Common::KEYCODE_KP9] || inputFlag == _vm->_keyMap[Common::KEYCODE_PAGEUP]) { - highlightButton = _vm->gui_getButton(_menuButtons, _vm->_menuDefs[lastMenu].firstButtonStrId + 1); + highlightButton = _vm->gui_getButton(buttonList, _vm->_menuDefs[lastMenu].firstButtonStrId + 1); } else if (inputFlag == _vm->_keyMap[Common::KEYCODE_KP8] || inputFlag == _vm->_keyMap[Common::KEYCODE_UP] || inputFlag == _vm->_keyMap[Common::KEYCODE_KP2] || inputFlag == _vm->_keyMap[Common::KEYCODE_DOWN]) { if (prevHighlightButton) { int dir = (inputFlag == _vm->_keyMap[Common::KEYCODE_UP]) ? -1 : 1; @@ -2141,29 +2143,50 @@ int GUI_Eob::runCampMenu() { s += dir; } while(!_vm->shouldQuit()); - highlightButton = _vm->gui_getButton(_menuButtons, s); + highlightButton = _vm->gui_getButton(buttonList, s); } - } else if (inputFlag > 0x8001 && inputFlag < 0x8010) { + } else if (inputFlag > 0x8000 && inputFlag < 0x8010) { + int i = 0; + int cnt = 0; + switch (inputFlag) { case 0x8001: + if (_vm->restParty()) + runLoop = false; + else + _vm->_resting = false; + redrawPortraits = true; break; + case 0x8002: + runMemorizePrayMenu(selectCharacterDialogue(23), 0); + newMenu = 0; break; + case 0x8003: + runMemorizePrayMenu(selectCharacterDialogue(26), 1); + newMenu = 0; break; + case 0x8004: + scribeScrollDialogue(); + newMenu = 0; break; + case 0x8005: newMenu = 2; break; + case 0x8006: newMenu = 1; break; + case 0x8007: - if (menuH) + if (_vm->_resting) displayTextBox(44); // fall through + case 0x800c: case 0x800f: if (lastMenu == 1 || lastMenu == 2) @@ -2173,38 +2196,74 @@ int GUI_Eob::runCampMenu() { else runLoop = false; break; + case 0x8008: + // load break; + case 0x8009: + // save break; + case 0x800a: + for (; i < 6; i++) { + if (_vm->testCharacter(i, 1)) + cnt++; + } + + if (cnt > 4) { + _vm->dropCharacter(selectCharacterDialogue(53)); + _vm->gui_drawPlayField(0); + res = true; + _screen->copyRegion(0, 120, 0, 0, 176, 24, 0, 14, Screen::CR_NO_P_CHECK); + _screen->setFont(Screen::FID_6_FNT); + _vm->gui_drawAllCharPortraitsWithStats(); + _screen->setFont(Screen::FID_8_FNT); + } else { + displayTextBox(45); + } + + newMenu = 0; break; + case 0x800b: + if (confirmDialogue(46)) + _vm->quitGame(); + newMenu = 0; break; + case 0x800d: + _vm->_configSounds ^= true; + _vm->_configMusic = _vm->_configSounds ? 1 : 0; + newMenu = 2; break; + case 0x800e: + _vm->_configHpBarGraphs ^= true; + newMenu = 2; + redrawPortraits = true; break; + default: break; } } else { Common::Point p = _vm->getMousePos(); - for (Button *b = _menuButtons; b; b = b->nextButton) { + for (Button *b = buttonList; b; b = b->nextButton) { if ((b->arg & 2) && _vm->posWithinRect(p.x, p.y, b->x, b->y, b->x + b->width, b->y + b->height)) highlightButton = b; } } - if (menuG || e) { + if (_charSelectRedraw || redrawPortraits) { for (int i = 0; i < 6; i++) { _vm->gui_drawCharPortraitWithStats(i); _vm->cleanupCharacterSpellList(i); } } - menuG = e = 0; + _charSelectRedraw = redrawPortraits = false; if (prevHighlightButton != highlightButton && newMenu == -1 && runLoop) { drawMenuButton(prevHighlightButton, false, false, true); @@ -2214,18 +2273,51 @@ int GUI_Eob::runCampMenu() { } } - releaseButtons(_menuButtons); - _menuButtons = 0; + releaseButtons(buttonList); + + _vm->writeSettings(); _screen->setFont(of); - - return 0; } int GUI_Eob::runLoadMenu(int x, int y) { return 0; } +void GUI_Eob::highLightBoxFrame(int box) { + static const uint8 colorTable[] = { 0x0F, 0xB0, 0xB2, 0xB4, 0xB6, + 0xB8, 0xBA, 0xBC, 0x0C, 0xBC, 0xBA, 0xB8, 0xB6, 0xB4, 0xB2, 0xB0, 0x00 + }; + + if (_updateBoxIndex == box) { + if (_updateBoxIndex == -1) + return; + + if (_vm->_system->getMillis() <= _highLightBoxTimer) + return; + + if (!colorTable[_updateBoxColorIndex]) + _updateBoxColorIndex = 0; + + const EobRect16 *r = &_highLightBoxFrames[_updateBoxIndex]; + _screen->drawBox(r->x1, r->y1, r->x2, r->y2, colorTable[_updateBoxColorIndex++]); + _screen->updateScreen(); + + _highLightBoxTimer = _vm->_system->getMillis() + _vm->_tickLength; + + } else { + if (_updateBoxIndex != -1) { + const EobRect16 *r = &_highLightBoxFrames[_updateBoxIndex]; + _screen->drawBox(r->x1, r->y1, r->x2, r->y2, 12); + _screen->updateScreen(); + } + + _updateBoxColorIndex = 0; + _updateBoxIndex = box; + _highLightBoxTimer = _vm->_system->getMillis(); + } +} + int GUI_Eob::getTextInput(char *dest, int x, int y, int destMaxLen, int textColor1, int textColor2, int cursorColor) { uint8 cursorState = 1; char sufx[] = " "; @@ -2344,7 +2436,7 @@ 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::initMenuItemsMask(int menuId, int maxItem, int32 menuItemsMask, int unk) { +void GUI_Eob::simpleMenu_initMenuItemsMask(int menuId, int maxItem, int32 menuItemsMask, int unk) { if (menuItemsMask == -1) { _menuNumItems = _screen->getScreenDim(19 + menuId)->h; _menuCur = _screen->getScreenDim(19 + menuId)->unk8; @@ -2361,6 +2453,253 @@ void GUI_Eob::initMenuItemsMask(int menuId, int maxItem, int32 menuItemsMask, in _menuCur = 0; } +void GUI_Eob::runSaveMenu() { + +} + +void GUI_Eob::runMemorizePrayMenu(int charIndex, int spellType) { + +} + +void GUI_Eob::scribeScrollDialogue() { + +} + +bool GUI_Eob::confirmDialogue(int id) { + int od = _screen->curDimIndex(); + Screen::FontId of = _screen->setFont(Screen::FID_8_FNT); + + Button *buttonList = initMenu(5); + + _screen->printShadedText(getMenuString(id), (_screen->_curDim->sx + 1) << 3, _screen->_curDim->sy + 4, 15, 0); + + int newHighlight = 0; + int lastHighlight = -1; + bool result = false; + + for (bool runLoop = true; runLoop && !_vm->shouldQuit(); ) { + if (newHighlight != lastHighlight) { + if (lastHighlight != -1) + drawMenuButton(_vm->gui_getButton(buttonList, lastHighlight + 33), false, false, true); + drawMenuButton(_vm->gui_getButton(buttonList, newHighlight + 33), false, true, true); + _screen->updateScreen(); + lastHighlight = newHighlight; + } + + int inputFlag = _vm->checkInput(buttonList, false, 0) & 0x80ff; + _vm->removeInputTop(); + + if (inputFlag == _vm->_keyMap[Common::KEYCODE_KP5] || inputFlag == _vm->_keyMap[Common::KEYCODE_SPACE] || inputFlag == _vm->_keyMap[Common::KEYCODE_RETURN]) { + result = lastHighlight ? false : true; + inputFlag = 0x8021 + lastHighlight; + runLoop = false; + } else if (inputFlag == _vm->_keyMap[Common::KEYCODE_KP4] || inputFlag == _vm->_keyMap[Common::KEYCODE_LEFT] || inputFlag == _vm->_keyMap[Common::KEYCODE_KP6] || inputFlag == _vm->_keyMap[Common::KEYCODE_RIGHT]) { + newHighlight ^= 1; + } else if (inputFlag == 0x8021) { + result = true; + runLoop = false; + } else if (inputFlag == 0x8022) { + result = false; + runLoop = false; + } else { + Common::Point p = _vm->getMousePos(); + for (Button *b = buttonList; b; b = b->nextButton) { + if ((b->arg & 2) && _vm->posWithinRect(p.x, p.y, b->x, b->y, b->x + b->width, b->y + b->height)) + newHighlight = b->index - 33; + } + } + + if (!runLoop) { + Button *b = _vm->gui_getButton(buttonList, lastHighlight + 33); + drawMenuButton(b, true, true, true); + _screen->updateScreen(); + _vm->_system->delayMillis(80); + drawMenuButton(b, false, true, true); + _screen->updateScreen(); + } + } + + releaseButtons(buttonList); + + _screen->setFont(of); + _screen->setScreenDim(od); + + return result; +} + +int GUI_Eob::selectCharacterDialogue(int id) { + uint8 flags = (id == 26) ? 0x14 : 0x02; + _vm->removeInputTop(); + + _charSelectRedraw = false; + bool abort = false; + int count = 0; + int result = -1; + int found[6]; + + for (int i = 0; i < 6; i++) { + found[i] = -1; + + if (!_vm->testCharacter(i, 1)) + continue; + + if (!(_vm->_classModifierFlags[_vm->_characters[i].cClass] & flags) && (id != 53)) + continue; + + if (id != 53 && (!_vm->_characters[i].food || !_vm->testCharacter(i, 4))) { + abort = true; + } else { + found[i] = 0; + result = i; + count++; + } + } + + if (!count) { + int eid = 0; + if (id == 23) + eid = abort ? 28 : 72; + else if (id == 26) + eid = abort ? 27 : 73; + else if (id == 49) + eid = 52; + + displayTextBox(eid); + return -1; + } + + static const uint16 selX[] = { 184, 256, 184, 256, 184, 256 }; + static const uint8 selY[] = { 2, 2, 54, 54, 106, 106}; + + for (int i = 0; i < 6; i++) { + if (found[i] != -1 || !_vm->testCharacter(i, 1)) + continue; + + _screen->drawShape(0, _vm->_blackBoxSmallGrid, selX[i], selY[i], 0); + _screen->drawShape(0, _vm->_blackBoxSmallGrid, selX[i] + 16, selY[i], 0); + _screen->drawShape(0, _vm->_blackBoxSmallGrid, selX[i] + 32, selY[i], 0); + _screen->drawShape(0, _vm->_blackBoxSmallGrid, selX[i] + 48, selY[i], 0); + _charSelectRedraw = true; + } + + if (count == 1) { + int l = _vm->getCharacterLevelIndex(4, _vm->_characters[result].cClass); + + if (l == -1) + return result; + + if (_vm->_characters[result].level[l] > 8) + return result; + + displayTextBox(24); + return -1; + } + + _vm->_menuDefs[3].titleStrId = id; + Button *buttonList = initMenu(3); + + result = -2; + int hlCur = -1; + Screen::FontId of = _screen->setFont(Screen::FID_6_FNT); + + while (result == -2 && !_vm->shouldQuit()) { + int inputFlag = _vm->checkInput(buttonList, false, 0); + _vm->removeInputTop(); + + highLightBoxFrame(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); + _vm->gui_drawCharPortraitWithStats(hlCur--); + if (hlCur < 0) + hlCur = 5; + while (found[hlCur]) { + if (--hlCur < 0) + hlCur = 5; + } + + } 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); + _vm->gui_drawCharPortraitWithStats(hlCur++); + if (hlCur == 6) + hlCur = 0; + while (found[hlCur]) { + if (++hlCur == 6) + hlCur = 0; + } + + } else if (inputFlag == _vm->_keyMap[Common::KEYCODE_KP5] || inputFlag == _vm->_keyMap[Common::KEYCODE_RETURN]) { + if (found >= 0) + result = hlCur; + + } else if (inputFlag == _vm->_keyMap[Common::KEYCODE_ESCAPE] || inputFlag == 0x8010) { + _screen->setFont(Screen::FID_8_FNT); + drawMenuButton(buttonList, true, true, true); + _screen->updateScreen(); + _vm->_system->delayMillis(80); + drawMenuButton(buttonList, false, false, true); + _screen->updateScreen(); + _screen->setFont(Screen::FID_6_FNT); + result = -1; + + } else if (inputFlag > 0x8010 && inputFlag < 0x8017) { + result = inputFlag - 0x8011; + if (found[result]) + result = -2; + } + } + + highLightBoxFrame(-1); + if (hlCur >= 0) + _vm->gui_drawCharPortraitWithStats(hlCur); + + _screen->setFont(Screen::FID_8_FNT); + + if (result != -1 && id != 53) { + if (flags == 0x14) { + if (_vm->_classModifierFlags[_vm->_characters[result].cClass] & 0x10 && _vm->_characters[result].level[0] < 9) { + displayTextBox(24); + result = -1; + } + } else { + if (_vm->checkCharacterInventoryForItem(result, 29, -1) == -1) { + displayTextBox(25); + result = -1; + } + } + } + + releaseButtons(buttonList); + _screen->setFont(of); + + return result; +} + +void GUI_Eob::displayTextBox(int id) { + int op = _screen->setCurPage(2); + int od = _screen->curDimIndex(); + Screen::FontId of = _screen->setFont(Screen::FID_8_FNT); + _screen->setClearScreenDim(11); + const ScreenDim *dm = _screen->getScreenDim(11); + + drawMenuButtonBox(dm->sx << 3, dm->sy, dm->w << 3, dm->h, false, false); + _screen->printShadedText(getMenuString(id), (dm->sx << 3) + 5, dm->sy + 5, 15, 0); + _screen->copyRegion(dm->sx << 3, dm->sy, dm->sx << 3, dm->sy, dm->w << 3, dm->h, 2, 0, Screen::CR_NO_P_CHECK); + _screen->updateScreen(); + + for (uint32 timeOut = _vm->_system->getMillis() + 1440; _vm->_system->getMillis() < timeOut && !_vm->shouldQuit(); ) { + int in = _vm->checkInput(0, false, 0); + _vm->removeInputTop(); + if (in && !(in & 0x800)) + break; + _vm->_system->delayMillis(4); + } + + _screen->setCurPage(op); + _screen->setFont(of); + _screen->setScreenDim(od); +} + Button *GUI_Eob::initMenu(int id) { _screen->setCurPage(2); @@ -2443,10 +2782,6 @@ 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::displayTextBox(int id) { - -} - void GUI_Eob::updateOptionsStrings() { for (int i = 0; i < 4; i++) { delete _menuStringsPrefsTemp[i]; @@ -2460,6 +2795,8 @@ void GUI_Eob::updateOptionsStrings() { } const char *GUI_Eob::getMenuString(int id) { + static const char empty[] = ""; + if (id >= 69) return _vm->_menuStringsTransfer[id - 69]; else if (id >= 67) @@ -2477,11 +2814,11 @@ const char *GUI_Eob::getMenuString(int id) { else if (id >= 48) return _vm->_menuStringsScribe[id - 48]; else if (id == 47) - _vm->_menuStringsStarve[0]; + return _vm->_menuStringsStarve[0]; else if (id == 46) - _vm->_menuStringsExit[0]; + return _vm->_menuStringsExit[0]; else if (id == 45) - _vm->_menuStringsDrop[0]; + return _vm->_menuStringsDrop[0]; else if (id >= 40) return _vm->_menuStringsRest[id - 40]; else if (id >= 23) @@ -2494,7 +2831,7 @@ const char *GUI_Eob::getMenuString(int id) { return _vm->_menuStringsSaveLoad[id - 9]; else if (id >= 1) return _vm->_menuStringsMain[id - 1]; - return 0; + return empty; } Button *GUI_Eob::linkButton(Button *list, Button *newbt) { -- cgit v1.2.3 From d7f2720b5709b1b4a93f81163752d2da148d2fd9 Mon Sep 17 00:00:00 2001 From: athrxx Date: Sat, 25 Jun 2011 17:21:09 +0200 Subject: KYRA: (EOB) - match eob code with 3f2b5b9e8b9196c9d0e573abf8f8350ec4034b1d --- engines/kyra/gui_eob.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'engines/kyra/gui_eob.cpp') diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index 4d5a1bf438..4fe5b6bed9 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -1951,17 +1951,17 @@ int GUI_Eob::processButtonList(Kyra::Button *buttonList, uint16 inputFlags, int8 return result; } -void GUI_Eob::simpleMenu_setup(int sd, int maxItem, const char *const *strings, int32 menuItemsMask, int unk, int lineSpacing) { - simpleMenu_initMenuItemsMask(sd, maxItem, menuItemsMask, unk); +void GUI_Eob::simpleMenu_setup(int sd, int maxItem, const char *const *strings, int32 menuItemsMask, int itemOffset, int lineSpacing) { + simpleMenu_initMenuItemsMask(sd, maxItem, menuItemsMask, itemOffset); const ScreenDim *dm = _screen->getScreenDim(19 + sd); int x = (_screen->_curDim->sx + dm->sx) << 3; int y = _screen->_curDim->sy + dm->sy; - int v = simpleMenu_getMenuItem(_menuCur, menuItemsMask, unk); + int v = simpleMenu_getMenuItem(_menuCur, menuItemsMask, itemOffset); for (int i = 0; i < _menuNumItems; i++) { - int item = simpleMenu_getMenuItem(i, menuItemsMask, unk); + int item = simpleMenu_getMenuItem(i, menuItemsMask, itemOffset); int ty = y + i * (lineSpacing + _screen->getFontHeight()); _screen->printShadedText(strings[item], x, ty, dm->unkA, 0); if (item == v) @@ -1975,7 +1975,7 @@ void GUI_Eob::simpleMenu_setup(int sd, int maxItem, const char *const *strings, _vm->removeInputTop(); } -int GUI_Eob::simpleMenu_process(int sd, const char *const *strings, void *b, int32 menuItemsMask, int unk) { +int GUI_Eob::simpleMenu_process(int sd, const char *const *strings, void *b, int32 menuItemsMask, int itemOffset) { const ScreenDim *dm = _screen->getScreenDim(19 + sd); int h = _menuNumItems - 1; int currentItem = _menuCur % _menuNumItems; @@ -2017,13 +2017,13 @@ int GUI_Eob::simpleMenu_process(int sd, const char *const *strings, void *b, int } if (newItem != currentItem) { - _screen->printText(strings[simpleMenu_getMenuItem(currentItem, menuItemsMask, unk)], x, y + currentItem * lineH , dm->unkA, 0); - _screen->printText(strings[simpleMenu_getMenuItem(newItem, menuItemsMask, unk)], x, y + newItem * lineH , dm->unkC, 0); + _screen->printText(strings[simpleMenu_getMenuItem(currentItem, menuItemsMask, itemOffset)], x, y + currentItem * lineH , dm->unkA, 0); + _screen->printText(strings[simpleMenu_getMenuItem(newItem, menuItemsMask, itemOffset)], x, y + newItem * lineH , dm->unkC, 0); _screen->updateScreen(); } if (result != -1) { - result = simpleMenu_getMenuItem(result, menuItemsMask, unk); + result = simpleMenu_getMenuItem(result, menuItemsMask, itemOffset); simpleMenu_flashSelection(strings[result], x, y + newItem * lineH, dm->unkA, dm->unkC, 0); } @@ -2032,7 +2032,7 @@ int GUI_Eob::simpleMenu_process(int sd, const char *const *strings, void *b, int return result; } -int GUI_Eob::simpleMenu_getMenuItem(int index, int32 menuItemsMask, int unk) { +int GUI_Eob::simpleMenu_getMenuItem(int index, int32 menuItemsMask, int itemOffset) { if (menuItemsMask == -1) return index; @@ -2040,11 +2040,11 @@ int GUI_Eob::simpleMenu_getMenuItem(int index, int32 menuItemsMask, int unk) { int i = index; for (; i; res++) { - if (menuItemsMask & (1 << (res + unk))) + if (menuItemsMask & (1 << (res + itemOffset))) i--; } - while (!(menuItemsMask & (1 << (res + unk)))) + while (!(menuItemsMask & (1 << (res + itemOffset)))) res++; return res; @@ -2436,7 +2436,7 @@ 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::simpleMenu_initMenuItemsMask(int menuId, int maxItem, int32 menuItemsMask, int unk) { +void GUI_Eob::simpleMenu_initMenuItemsMask(int menuId, int maxItem, int32 menuItemsMask, int itemOffset) { if (menuItemsMask == -1) { _menuNumItems = _screen->getScreenDim(19 + menuId)->h; _menuCur = _screen->getScreenDim(19 + menuId)->unk8; @@ -2446,7 +2446,7 @@ void GUI_Eob::simpleMenu_initMenuItemsMask(int menuId, int maxItem, int32 menuIt _menuNumItems = 0; for (int i = 0; i < maxItem; i++) { - if (menuItemsMask & (1 << (i + unk))) + if (menuItemsMask & (1 << (i + itemOffset))) _menuNumItems++; } @@ -2462,7 +2462,7 @@ void GUI_Eob::runMemorizePrayMenu(int charIndex, int spellType) { } void GUI_Eob::scribeScrollDialogue() { - + } bool GUI_Eob::confirmDialogue(int id) { -- cgit v1.2.3 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/gui_eob.cpp | 324 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 314 insertions(+), 10 deletions(-) (limited to 'engines/kyra/gui_eob.cpp') 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]; -- cgit v1.2.3 From 76bfcf834d73a9578164842ed5ab8e1eff2814e8 Mon Sep 17 00:00:00 2001 From: athrxx Date: Wed, 16 Nov 2011 19:16:19 +0100 Subject: KYRA: (EOB) - some refactoring --- engines/kyra/gui_eob.cpp | 54 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 17 deletions(-) (limited to 'engines/kyra/gui_eob.cpp') diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index 5d86b9c589..6eab4a0083 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -29,6 +29,7 @@ #include "kyra/util.h" #include "common/system.h" +#include "common/savefile.h" namespace Kyra { @@ -1428,12 +1429,9 @@ void EobCoreEngine::gui_processInventorySlotClick(int slot) { } } -GUI_Eob::GUI_Eob(EobCoreEngine *vm) : GUI_v1(vm), _vm(vm), _screen(vm->_screen) { +GUI_Eob::GUI_Eob(EobCoreEngine *vm) : GUI(vm), _vm(vm), _screen(vm->_screen) { _scrollUpFunctor = _scrollDownFunctor = BUTTON_FUNCTOR(GUI_Eob, this, 0); - _redrawButtonFunctor = BUTTON_FUNCTOR(GUI_v1, this, &GUI_v1::redrawButtonCallback); - _redrawShadedButtonFunctor = BUTTON_FUNCTOR(GUI_v1, this, &GUI_v1::redrawShadedButtonCallback); - _menuStringsPrefsTemp = new char*[4]; memset(_menuStringsPrefsTemp, 0, 4 * sizeof(char*)); @@ -1445,7 +1443,6 @@ GUI_Eob::GUI_Eob(EobCoreEngine *vm) : GUI_v1(vm), _vm(vm), _screen(vm->_screen) _cflag = 0xffff; _menuLineSpacing = 0; - //_menuUnk1 = 0; _menuLastInFlags = 0; _menuCur = 0; _menuNumItems = 0; @@ -1462,6 +1459,7 @@ GUI_Eob::GUI_Eob(EobCoreEngine *vm) : GUI_v1(vm), _vm(vm), _screen(vm->_screen) _updateBoxIndex = -1; _highLightBoxTimer = 0; _updateBoxColorIndex = 0; + _needRest = false; } GUI_Eob::~GUI_Eob() { @@ -1979,7 +1977,6 @@ void GUI_Eob::simpleMenu_setup(int sd, int maxItem, const char *const *strings, _screen->updateScreen(); _menuLineSpacing = lineSpacing; - //_menuUnk1 = 0; _menuLastInFlags = 0; _vm->removeInputTop(); } @@ -2081,7 +2078,7 @@ void GUI_Eob::runCampMenu() { bool redrawPortraits = false; bool res = false; _charSelectRedraw = false; - _vm->_resting = false; + _needRest = false; Button *buttonList = 0; for (bool runLoop = true; runLoop && !_vm->shouldQuit(); ) { @@ -2164,7 +2161,7 @@ void GUI_Eob::runCampMenu() { if (_vm->restParty()) runLoop = false; else - _vm->_resting = false; + _needRest = false; redrawPortraits = true; break; @@ -2192,7 +2189,7 @@ void GUI_Eob::runCampMenu() { break; case 0x8007: - if (_vm->_resting) + if (_needRest) displayTextBox(44); // fall through @@ -2207,11 +2204,17 @@ void GUI_Eob::runCampMenu() { break; case 0x8008: - // load + if (runLoadMenu(0, 0)) + runLoop = false; + else + newMenu = 1; break; case 0x8009: - // save + if (runSaveMenu(0, 0)) + displayTextBox(14); + else + newMenu = 1; break; case 0x800a: @@ -2289,8 +2292,21 @@ void GUI_Eob::runCampMenu() { _screen->setFont(of); } -int GUI_Eob::runLoadMenu(int x, int y) { - return 0; +bool GUI_Eob::runLoadMenu(int x, int y) { + const ScreenDim *dm = _screen->getScreenDim(11); + int xo = dm->sx; + int yo = dm->sy; + bool result = false; + _savegameListUpdateNeeded = true; + + _screen->modifyScreenDim(11, dm->sx + (x >> 8), dm->sy + y, dm->w, dm->sy); + + updateSavegameList(); + setupSaveMenuSlots(); + + _screen->modifyScreenDim(11, xo, yo, dm->w, dm->sy); + + return result; } void GUI_Eob::updateBoxFrameHighLight(int box) { @@ -2462,8 +2478,8 @@ void GUI_Eob::simpleMenu_initMenuItemsMask(int menuId, int maxItem, int32 menuIt _menuCur = 0; } -void GUI_Eob::runSaveMenu() { - +bool GUI_Eob::runSaveMenu(int x, int y) { + return true; } void GUI_Eob::runMemorizePrayMenu(int charIndex, int spellType) { @@ -2642,7 +2658,7 @@ void GUI_Eob::runMemorizePrayMenu(int charIndex, int spellType) { } if (inputFlag & 0x8000) { - Button *b = _vm->gui_getButton(buttonList, inputFlag & 0x7fff); + b = _vm->gui_getButton(buttonList, inputFlag & 0x7fff); drawMenuButton(b, true, true, true); _screen->updateScreen(); _vm->_system->delayMillis(80); @@ -2726,7 +2742,7 @@ void GUI_Eob::runMemorizePrayMenu(int charIndex, int spellType) { } else if (_numAssignedSpellsOfType[i * 2]) { _numAssignedSpellsOfType[i * 2]--; - _vm->_resting = true; + _needRest = true; int pg = lh[i] - 1; for (int ii = 0; ii < 10; ii++) { if (!charSpellList[pg * 10 + ii]) { @@ -3164,6 +3180,10 @@ void GUI_Eob::releaseButtons(Button *list) { } } +void GUI_Eob::setupSaveMenuSlots() { + +} + #endif // ENABLE_EOB } // End of namespace Kyra -- cgit v1.2.3 From c53589bcda2875154b2590f264838b1be728d1f3 Mon Sep 17 00:00:00 2001 From: athrxx Date: Fri, 1 Jul 2011 00:43:37 +0200 Subject: KYRA: (EOB) - implement load menu (only 6 slots supported for now) --- engines/kyra/gui_eob.cpp | 248 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 240 insertions(+), 8 deletions(-) (limited to 'engines/kyra/gui_eob.cpp') diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index 6eab4a0083..4eb2497539 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -1435,6 +1435,15 @@ GUI_Eob::GUI_Eob(EobCoreEngine *vm) : GUI(vm), _vm(vm), _screen(vm->_screen) { _menuStringsPrefsTemp = new char*[4]; memset(_menuStringsPrefsTemp, 0, 4 * sizeof(char*)); + _saveSlotStringsTemp = new char*[6]; + for (int i = 0; i < 6; i++) { + _saveSlotStringsTemp[i] = new char[20]; + memset(_saveSlotStringsTemp[i], 0, 20); + } + _saveSlotIdTemp = new int16[6]; + _savegameOffset = 0; + _saveSlotX = _saveSlotY = 0; + _specialProcessButton = _backupButtonList = 0; _flagsMouseLeft = _flagsMouseRight = _flagsModifier = 0; _backupButtonList = 0; @@ -1469,6 +1478,14 @@ GUI_Eob::~GUI_Eob() { delete[] _menuStringsPrefsTemp; } + if (_saveSlotStringsTemp) { + for (int i = 0; i < 6; i++) + delete[] _saveSlotStringsTemp[i]; + delete[] _saveSlotStringsTemp; + } + + delete[] _saveSlotIdTemp; + delete[] _numAssignedSpellsOfType; } @@ -2285,11 +2302,9 @@ void GUI_Eob::runCampMenu() { } } + _screen->setFont(of); releaseButtons(buttonList); - _vm->writeSettings(); - - _screen->setFont(of); } bool GUI_Eob::runLoadMenu(int x, int y) { @@ -2299,13 +2314,27 @@ bool GUI_Eob::runLoadMenu(int x, int y) { bool result = false; _savegameListUpdateNeeded = true; - _screen->modifyScreenDim(11, dm->sx + (x >> 8), dm->sy + y, dm->w, dm->sy); + _screen->modifyScreenDim(11, dm->sx + (x >> 3), dm->sy + y, dm->w, dm->h); updateSavegameList(); - setupSaveMenuSlots(); - _screen->modifyScreenDim(11, xo, yo, dm->w, dm->sy); + for (bool runLoop = true; runLoop; ) { + int slot = selectSaveSlotDialogue(x, y, 1); + if (slot > 5) { + runLoop = result = false; + } else if (slot >= 0) { + if (_saveSlotIdTemp[slot] == -1) { + messageDialogue(11, 65, 6); + } else { + if (_vm->loadGameState(_saveSlotIdTemp[slot]).getCode() != Common::kNoError) + messageDialogue(11, 16, 6); + runLoop = false; + result = true; + } + } + } + _screen->modifyScreenDim(11, xo, yo, dm->w, dm->h); return result; } @@ -2479,7 +2508,95 @@ void GUI_Eob::simpleMenu_initMenuItemsMask(int menuId, int maxItem, int32 menuIt } bool GUI_Eob::runSaveMenu(int x, int y) { - return true; + const ScreenDim *dm = _screen->getScreenDim(11); + int xo = dm->sx; + int yo = dm->sy; + bool result = false; + _savegameListUpdateNeeded = true; + + _screen->modifyScreenDim(11, dm->sx + (x >> 3), dm->sy + y, dm->w, dm->h); + + updateSavegameList(); + + /*for (bool runLoop = true; runLoop; ) { + int slot = selectSaveSlotDialogue(x, y, 1); + if (slot > 5) { + runLoop = result = false; + } else if (slot >= 0) { + if (_saveSlotIdTemp[slot] == -1) { + messageDialogue(11, 65, 6); + } else { + if (_vm->loadGameState(_saveSlotIdTemp[slot]).getCode() != Common::kNoError) + messageDialogue(11, 16, 6); + runLoop = false; + result = true; + } + } + }*/ + + _screen->modifyScreenDim(11, xo, yo, dm->w, dm->h); + return result; +} + +int GUI_Eob::selectSaveSlotDialogue(int x, int y, int id) { + assert (id < 2); + + _saveSlotX = _saveSlotY = 0; + _screen->setCurPage(2); + + setupSaveMenuSlots(); + drawMenuButtonBox(0, 0, 176, 144, false, false); + _screen->printShadedText(_vm->_saveLoadStrings[2 + id], 52, 5, 15, 0); + + for (int i = 0; i < 7; i++) + drawSaveSlotButton(i, 1, 15); + + _screen->copyRegion(0, 0, x, y, 176, 144, 2, 0, Screen::CR_NO_P_CHECK); + _screen->setCurPage(0); + _screen->updateScreen(); + + _saveSlotX = x; + _saveSlotY = y; + int lastHighlight = -1; + int newHighlight = 0; + int slot = -1; + + for (bool runLoop = true; runLoop && !_vm->shouldQuit(); ) { + int inputFlag = _vm->checkInput(0, false, 0) & 0x8ff; + _vm->removeInputTop(); + + if (inputFlag == _vm->_keyMap[Common::KEYCODE_SPACE] || inputFlag == _vm->_keyMap[Common::KEYCODE_RETURN]) { + runLoop = false; + } else if (inputFlag == _vm->_keyMap[Common::KEYCODE_DOWN] || inputFlag == _vm->_keyMap[Common::KEYCODE_KP2]) { + if (++newHighlight > 6) + newHighlight = 0; + } else if (inputFlag == _vm->_keyMap[Common::KEYCODE_UP] || inputFlag == _vm->_keyMap[Common::KEYCODE_KP8]) { + if (--newHighlight < 0) + newHighlight = 6; + } else { + slot = getHighlightSlot(); + if (slot != -1) { + newHighlight = slot; + if (inputFlag == 199) + runLoop = false; + } + } + + if (lastHighlight != newHighlight) { + drawSaveSlotButton(lastHighlight, 0, 15); + drawSaveSlotButton(newHighlight, 0, 6); + _screen->updateScreen(); + lastHighlight = newHighlight; + } + } + + drawSaveSlotButton(newHighlight, 2, 6); + _screen->updateScreen(); + _vm->_system->delayMillis(80); + drawSaveSlotButton(newHighlight, 1, 6); + _screen->updateScreen(); + + return newHighlight; } void GUI_Eob::runMemorizePrayMenu(int charIndex, int spellType) { @@ -2674,7 +2791,7 @@ void GUI_Eob::runMemorizePrayMenu(int charIndex, int spellType) { updateDesc = true; } - } else if (inputFlag == _vm->_keyMap[Common::KEYCODE_KP_MINUS] || inputFlag == _vm->_keyMap[Common::KEYCODE_MINUS] /*|| inputFlag == _vm->_keyMap[Common::KEYCODE_*/) { + } else if (inputFlag == _vm->_keyMap[Common::KEYCODE_KP_MINUS] || inputFlag == _vm->_keyMap[Common::KEYCODE_MINUS]) { if (np[lastHighLightButton] && _numAssignedSpellsOfType[menuSpellMap[lastHighLightButton * 11 + lastHighLightText + 1] * 2 - 2]) { _numAssignedSpellsOfType[menuSpellMap[lastHighLightButton * 11 + lastHighLightText + 1] * 2 - 2]--; numAssignedSpellsPerBookPage[lastHighLightButton]--; @@ -2826,6 +2943,47 @@ bool GUI_Eob::confirmDialogue(int id) { return result; } +void GUI_Eob::messageDialogue(int dim, int id, int buttonTextCol) { + static const char buttonText[] = "OK"; + + 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(buttonText) << 3) + 16); + int by = dm->sy + dm->h - 19; + int bw = (strlen(buttonText) << 3) + 7; + + drawMenuButtonBox(bx, by, bw, 14, false, false); + _screen->printShadedText(buttonText, 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) { + Common::Point p = _vm->getMousePos(); + if (_vm->posWithinRect(p.x, p.y, 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->setScreenDim(od); + _screen->setFont(of); +} + int GUI_Eob::selectCharacterDialogue(int id) { uint8 flags = (id == 26) ? 0x14 : 0x02; _vm->removeInputTop(); @@ -3084,6 +3242,48 @@ 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::drawTextBox(int dim, int id) { + int od = _screen->curDimIndex(); + _screen->setScreenDim(dim); + const ScreenDim *dm = _screen->getScreenDim(dim); + Screen::FontId of = _screen->setFont(Screen::FID_8_FNT); + + if (dm->w <= 22 && dm->h <= 84) + _screen->copyRegion(dm->sx << 3, dm->sy, 0, dm->h, dm->w << 3, dm->h, 0, 2, Screen::CR_NO_P_CHECK); + + _screen->setCurPage(2); + + drawMenuButtonBox(0, 0, dm->w << 3, dm->h, false, false); + _screen->printShadedText(getMenuString(id), 5, 5, 15, 0); + + _screen->setCurPage(0); + _screen->copyRegion(0, 0, dm->sx << 3, dm->sy, dm->w << 3, dm->h, 2, 0, Screen::CR_NO_P_CHECK); + _screen->updateScreen(); + _screen->setScreenDim(od); + _screen->setFont(of); +} + +void GUI_Eob::drawSaveSlotButton(int slot, int redrawBox, int textCol) { + if (slot < 0) + return; + + int x = _saveSlotX + 4; + int y = _saveSlotY + slot * 17 + 20; + int w = 167; + const char *s = (slot < 6) ?_saveSlotStringsTemp[slot] : _vm->_saveLoadStrings[0]; + + if (slot >= 6 ) { + x = _saveSlotX + 118; + y = _saveSlotY + 126; + w = 53; + } + + if (redrawBox) + drawMenuButtonBox(x, y, w, 14, (redrawBox - 1) ? true : false, false); + + _screen->printShadedText(s, x + 4, y + 3, textCol, 0); +} + void GUI_Eob::memorizePrayMenuPrintString(int spellId, int bookPageIndex, int spellType, bool noFill, bool highLight) { if (bookPageIndex < 0) return; @@ -3121,6 +3321,10 @@ const char *GUI_Eob::getMenuString(int id) { return _vm->_menuStringsTransfer[id - 69]; else if (id >= 67) return _vm->_menuStringsDefeat[id - 67]; + else if (id == 66) + return _vm->_errorSlotEmptyString; + else if (id == 65) + return _vm->_errorSlotEmptyString; else if (id >= 63) return _vm->_menuStringsSpec[id - 63]; else if (id >= 60) @@ -3181,7 +3385,35 @@ void GUI_Eob::releaseButtons(Button *list) { } void GUI_Eob::setupSaveMenuSlots() { + for (int i = 0; i < 6; ++i) { + if (_savegameOffset + i < _savegameListSize) { + if (_savegameList[i + _savegameOffset]) { + Common::strlcpy(_saveSlotStringsTemp[i], _savegameList[i + _savegameOffset], 20); + _saveSlotIdTemp[i] = i + _savegameOffset; + continue; + } + } + Common::strlcpy(_saveSlotStringsTemp[i], _vm->_saveLoadStrings[1], 20); + _saveSlotIdTemp[i] = -1; + } +} + +int GUI_Eob::getHighlightSlot() { + int res = -1; + Common::Point p = _vm->getMousePos(); + + for (int i = 0; i < 6; i++) { + int y = _saveSlotY + i * 17 + 20; + if (_vm->posWithinRect(p.x, p.y, _saveSlotX + 4, y, _saveSlotX + 167, y + 14)) { + res = i; + break; + } + } + + if (_vm->posWithinRect(p.x, p.y, _saveSlotX + 118, _saveSlotY + 126, _saveSlotX + 171, _saveSlotY + 140)) + res = 6; + return res; } #endif // ENABLE_EOB -- cgit v1.2.3 From 5baabf037df661e4730500ecebca6347031aa295 Mon Sep 17 00:00:00 2001 From: athrxx Date: Sat, 2 Jul 2011 03:19:46 +0200 Subject: KYRA: (EOB) - implement save menu --- engines/kyra/gui_eob.cpp | 149 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 125 insertions(+), 24 deletions(-) (limited to 'engines/kyra/gui_eob.cpp') diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index 4eb2497539..1d69a901e5 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -30,6 +30,7 @@ #include "common/system.h" #include "common/savefile.h" +#include "graphics/scaler.h" namespace Kyra { @@ -849,9 +850,10 @@ int EobCoreEngine::clickedCamp(Button *button) { } _screen->copyRegion(0, 120, 0, 0, 176, 24, 0, 14, Screen::CR_NO_P_CHECK); + _screen->copyPage(0, 7); - _gui->runCampMenu(); - + _gui->runCampMenu(); + _screen->copyRegion(0, 0, 0, 120, 176, 24, 14, 2, Screen::CR_NO_P_CHECK); _screen->setScreenDim(cd); drawScene(0); @@ -862,10 +864,7 @@ int EobCoreEngine::clickedCamp(Button *button) { _screen->setCurPage(0); const ScreenDim *dm = _screen->getScreenDim(10); _screen->copyRegion(dm->sx << 3, dm->sy, dm->sx << 3, dm->sy, dm->w << 3, dm->h, 2, 0, Screen::CR_NO_P_CHECK); - - /*if (reloadInv) - _screen->loadEobCpsFileToPage("INVENT", 0, 5, 3, 2);*/ - + _screen->updateScreen(); enableSysTimer(2); @@ -1430,7 +1429,7 @@ void EobCoreEngine::gui_processInventorySlotClick(int slot) { } GUI_Eob::GUI_Eob(EobCoreEngine *vm) : GUI(vm), _vm(vm), _screen(vm->_screen) { - _scrollUpFunctor = _scrollDownFunctor = BUTTON_FUNCTOR(GUI_Eob, this, 0); + //_scrollUpFunctor = _scrollDownFunctor = BUTTON_FUNCTOR(GUI_Eob, this, 0); _menuStringsPrefsTemp = new char*[4]; memset(_menuStringsPrefsTemp, 0, 4 * sizeof(char*)); @@ -2230,8 +2229,7 @@ void GUI_Eob::runCampMenu() { case 0x8009: if (runSaveMenu(0, 0)) displayTextBox(14); - else - newMenu = 1; + newMenu = 1; break; case 0x800a: @@ -2316,9 +2314,7 @@ bool GUI_Eob::runLoadMenu(int x, int y) { _screen->modifyScreenDim(11, dm->sx + (x >> 3), dm->sy + y, dm->w, dm->h); - updateSavegameList(); - - for (bool runLoop = true; runLoop; ) { + for (bool runLoop = true; runLoop && !_vm->shouldQuit(); ) { int slot = selectSaveSlotDialogue(x, y, 1); if (slot > 5) { runLoop = result = false; @@ -2490,6 +2486,13 @@ 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::createScreenThumbnail(Graphics::Surface &dst) { + uint8 *screenPal = new uint8[768]; + _screen->getRealPalette(0, screenPal); + ::createThumbnail(&dst, _screen->getCPagePtr(7), Screen::SCREEN_W, Screen::SCREEN_H, screenPal); + delete[] screenPal; +} + void GUI_Eob::simpleMenu_initMenuItemsMask(int menuId, int maxItem, int32 menuItemsMask, int itemOffset) { if (menuItemsMask == -1) { _menuNumItems = _screen->getScreenDim(19 + menuId)->h; @@ -2516,23 +2519,49 @@ bool GUI_Eob::runSaveMenu(int x, int y) { _screen->modifyScreenDim(11, dm->sx + (x >> 3), dm->sy + y, dm->w, dm->h); - updateSavegameList(); - - /*for (bool runLoop = true; runLoop; ) { - int slot = selectSaveSlotDialogue(x, y, 1); + for (bool runLoop = true; runLoop && !_vm->shouldQuit(); ) { + int slot = selectSaveSlotDialogue(x, y, 0); if (slot > 5) { runLoop = result = false; } else if (slot >= 0) { - if (_saveSlotIdTemp[slot] == -1) { - messageDialogue(11, 65, 6); - } else { - if (_vm->loadGameState(_saveSlotIdTemp[slot]).getCode() != Common::kNoError) - messageDialogue(11, 16, 6); - runLoop = false; + bool useSlot = (_saveSlotIdTemp[slot] == -1); + if (useSlot) + _saveSlotStringsTemp[slot][0] = 0; + else + useSlot = confirmDialogue2(11, 55, 1); + + if (!useSlot) + continue; + + int fx = (x + 1) << 3; + int fy = y + slot * 17 + 23; + + for (int in = -1; in == -1 && !_vm->shouldQuit(); ) { + _screen->fillRect(fx - 2, fy, fx + 160, fy + 8, _vm->_bkgColor_1); + in = getTextInput(_saveSlotStringsTemp[slot], x + 1, fy, 19, 2, 0, 8); + if (!strlen(_saveSlotStringsTemp[slot])) { + messageDialogue(11, 54, 6); + in = -1; + } + }; + + _screen->fillRect(fx - 2, fy, fx + 160, fy + 8, _vm->_bkgColor_1); + _screen->printShadedText(_saveSlotStringsTemp[slot], (x + 1) << 3, fy, 15, 0); + + Graphics::Surface thumb; + createScreenThumbnail(thumb); + Common::Error err = _vm->saveGameStateIntern(_savegameOffset + slot, _saveSlotStringsTemp[slot], &thumb); + thumb.free(); + + if (err.getCode() == Common::kNoError) { + _savegameListUpdateNeeded = true; result = true; + } else { + messageDialogue(11, 15, 6); } + runLoop = false; } - }*/ + } _screen->modifyScreenDim(11, xo, yo, dm->w, dm->h); return result; @@ -2544,7 +2573,9 @@ int GUI_Eob::selectSaveSlotDialogue(int x, int y, int id) { _saveSlotX = _saveSlotY = 0; _screen->setCurPage(2); + updateSavegameList(); setupSaveMenuSlots(); + drawMenuButtonBox(0, 0, 176, 144, false, false); _screen->printShadedText(_vm->_saveLoadStrings[2 + id], 52, 5, 15, 0); @@ -2943,6 +2974,74 @@ bool GUI_Eob::confirmDialogue(int id) { return result; } +bool GUI_Eob::confirmDialogue2(int dim, int id, int deflt) { + int od = _screen->curDimIndex(); + Screen::FontId of = _screen->setFont(Screen::FID_8_FNT); + _screen->setScreenDim(dim); + + drawTextBox(dim, id); + + int16 x[2]; + x[0] = (_screen->_curDim->sx << 3) + 8; + x[1] = (_screen->_curDim->sx + _screen->_curDim->w - 5) << 3; + int16 y = _screen->_curDim->sy + _screen->_curDim->h - 21; + int newHighlight = deflt ^ 1; + int lastHighlight = -1; + + for (int i = 0; i < 2; i++) + drawMenuButtonBox(x[i], y, 32, 14, false, false); + + for (bool runLoop = true; runLoop && !_vm->shouldQuit(); ) { + Common::Point p = _vm->getMousePos(); + if (_vm->posWithinRect(p.x, p.y, x[0], y, x[0] + 32, y + 14)) + newHighlight = 0; + else if (_vm->posWithinRect(p.x, p.y, x[1], y, x[1] + 32, y + 14)) + newHighlight = 1; + + int inputFlag = _vm->checkInput(0, false, 0) & 0x8ff; + _vm->removeInputTop(); + + if (inputFlag == _vm->_keyMap[Common::KEYCODE_SPACE] || inputFlag == _vm->_keyMap[Common::KEYCODE_RETURN]) { + runLoop = false; + } else if (inputFlag == _vm->_keyMap[Common::KEYCODE_LEFT] || inputFlag == _vm->_keyMap[Common::KEYCODE_KP4] || inputFlag == _vm->_keyMap[Common::KEYCODE_RIGHT] || inputFlag == _vm->_keyMap[Common::KEYCODE_KP6]) { + newHighlight ^= 1; + } else if (inputFlag == _vm->_keyMap[Common::KEYCODE_n]) { + newHighlight = 1; + runLoop = false; + } else if (inputFlag == _vm->_keyMap[Common::KEYCODE_y]) { + newHighlight = 0; + runLoop = false; + } else if (inputFlag == 199 || inputFlag == 201) { + if (_vm->posWithinRect(p.x, p.y, x[0], y, x[0] + 32, y + 14)) { + newHighlight = 0; + runLoop = false; + } else if (_vm->posWithinRect(p.x, p.y, x[1], y, x[1] + 32, y + 14)) { + newHighlight = 1; + runLoop = false; + } + } + + if (newHighlight != lastHighlight) { + for (int i = 0; i < 2; i++) + _screen->printShadedText(_vm->_menuYesNoStrings[i], x[i] + 16 - (strlen(_vm->_menuYesNoStrings[i]) << 2) + 1, y + 3, i == newHighlight ? 6 : 15, 0); + _screen->updateScreen(); + lastHighlight = newHighlight; + } + } + + drawMenuButtonBox(x[newHighlight], y, 32, 14, true, true); + _screen->updateScreen(); + _vm->_system->delayMillis(80); + drawMenuButtonBox(x[newHighlight], y, 32, 14, false, true); + _screen->updateScreen(); + + _screen->copyRegion(0, _screen->_curDim->h, _screen->_curDim->sx << 3, _screen->_curDim->sy, _screen->_curDim->w << 3, _screen->_curDim->h, 2, 0, Screen::CR_NO_P_CHECK); + _screen->setFont(of); + _screen->setScreenDim(od); + + return newHighlight ? false : true; +} + void GUI_Eob::messageDialogue(int dim, int id, int buttonTextCol) { static const char buttonText[] = "OK"; @@ -2979,9 +3078,11 @@ void GUI_Eob::messageDialogue(int dim, int id, int buttonTextCol) { _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) { -- cgit v1.2.3 From db83458330310072c743d5acc7e1a470c888ec3b Mon Sep 17 00:00:00 2001 From: athrxx Date: Tue, 5 Jul 2011 17:28:02 +0200 Subject: KYRA: (EOB) - implement scribe scroll menu --- engines/kyra/gui_eob.cpp | 120 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 119 insertions(+), 1 deletion(-) (limited to 'engines/kyra/gui_eob.cpp') diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index 1d69a901e5..936567b5bf 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -2909,7 +2909,125 @@ void GUI_Eob::runMemorizePrayMenu(int charIndex, int spellType) { void GUI_Eob::scribeScrollDialogue() { - + int16 *scrollInvSlot = new int16[32]; + int16 *scrollCharacter = new int16[32]; + int16 *menuItems = new int16[6]; + int numScrolls = 0; + + for (int i = 0; i < 32; i++) { + for (int ii = 0; ii < 6; ii++) { + scrollInvSlot[i] = _vm->checkCharacterInventoryForItem(ii, 34, i + 1) + 1; + if (scrollInvSlot[i] > 0) { + numScrolls++; + scrollCharacter[i] = ii; + break; + } + } + } + + if (numScrolls) { + int csel = selectCharacterDialogue(49); + if (csel != -1) { + + EobCharacter *c = &_vm->_characters[csel]; + int s = 0; + + for (int i = 0; i < 32 && s < 6; i++) { + if (!scrollInvSlot[i]) + continue; + + if (c->mageSpellsAvailabilityFlags & (1 << i)) + scrollInvSlot[i] = 0; + else + menuItems[s++] = i + 1; + } + + if (s) { + Button *buttonList = 0; + bool redraw = true; + int lastHighLight = -1; + int newHighLight = 0; + + while (s && !_vm->shouldQuit()) { + if (redraw) { + s = 0; + for (int i = 0; i < 32 && s < 6; i++) { + if (!scrollInvSlot[i]) + continue; + menuItems[s++] = i + 1; + } + + if (!s) + break; + + releaseButtons(buttonList); + buttonList = initMenu(6); + + for (int i = 0; i < s; i++) + _screen->printShadedText(_vm->_mageSpellList[menuItems[i]], 8, 9 * i + 50, 15, 0); + + redraw = false; + lastHighLight = -1; + newHighLight = 0; + } + + if (lastHighLight != newHighLight) { + if (lastHighLight >= 0) + _screen->printText(_vm->_mageSpellList[menuItems[lastHighLight]], 8, 9 * lastHighLight + 50, 15, 0); + lastHighLight = newHighLight; + _screen->printText(_vm->_mageSpellList[menuItems[lastHighLight]], 8, 9 * lastHighLight + 50, 6, 0); + _screen->updateScreen(); + } + + int inputFlag = _vm->checkInput(buttonList, false, 0); + _vm->removeInputTop(); + + if (inputFlag == 0) { + Common::Point p = _vm->getMousePos(); + if (_vm->posWithinRect(p.x, p.y, 8, 50, 176, s * 9 + 49)) + newHighLight = (p.y - 50) / 9; + } else if (inputFlag == _vm->_keyMap[Common::KEYCODE_KP2] || inputFlag == _vm->_keyMap[Common::KEYCODE_DOWN]) { + newHighLight = (newHighLight + 1) % s; + } else if (inputFlag == _vm->_keyMap[Common::KEYCODE_KP8] || inputFlag == _vm->_keyMap[Common::KEYCODE_UP]) { + newHighLight = (newHighLight + s - 1) % s; + } else if (inputFlag == 0x8023 || inputFlag == _vm->_keyMap[Common::KEYCODE_ESCAPE]) { + s = 0; + } else if (inputFlag == 0x8024) { + newHighLight = (_vm->_mouseY - 50) / 9; + if (newHighLight >= 0 && newHighLight < s) { + inputFlag = _vm->_keyMap[Common::KEYCODE_SPACE]; + } else { + inputFlag = 0; + newHighLight = lastHighLight; + } + } + + if (inputFlag == _vm->_keyMap[Common::KEYCODE_SPACE] || inputFlag == _vm->_keyMap[Common::KEYCODE_RETURN] || inputFlag == _vm->_keyMap[Common::KEYCODE_KP5]) { + int t = menuItems[newHighLight] - 1; + Item scItem = _vm->_characters[scrollCharacter[t]].inventory[scrollInvSlot[t] - 1]; + c->mageSpellsAvailabilityFlags |= (1 << t); + _vm->_characters[scrollCharacter[t]].inventory[scrollInvSlot[t] - 1] = 0; + _vm->gui_drawCharPortraitWithStats(_vm->_characters[scrollCharacter[t]].id); + scrollInvSlot[t] = 0; + _vm->_items[scItem].block = -1; + redraw = true; + s--; + } + } + + releaseButtons(buttonList); + + } else { + displayTextBox(51); + } + } + } else { + displayTextBox(50); + } + + delete[] menuItems; + delete[] scrollCharacter; + delete[] scrollInvSlot; } bool GUI_Eob::confirmDialogue(int id) { -- cgit v1.2.3 From 9140fd8e91882250e23e2e4b44bf3088f3da827a Mon Sep 17 00:00:00 2001 From: athrxx Date: Mon, 18 Jul 2011 01:22:58 +0200 Subject: KYRA: (EOB) - implement party resting --- engines/kyra/gui_eob.cpp | 496 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 401 insertions(+), 95 deletions(-) (limited to 'engines/kyra/gui_eob.cpp') diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index 936567b5bf..3a71642f9b 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -24,6 +24,7 @@ #include "kyra/eobcommon.h" #include "kyra/gui_eob.h" +#include "kyra/script_eob.h" #include "kyra/text_eob.h" #include "kyra/timer.h" #include "kyra/util.h" @@ -508,7 +509,7 @@ void EobCoreEngine::gui_drawHorizontalBarGraph(int x, int y, int w, int h, int32 } void EobCoreEngine::gui_drawCharPortraitStatusFrame(int index) { - uint8 boxColor = ((_partyEffectFlags & 0x20000) | (_partyEffectFlags & 0xffff)) ? 4 : 6; + uint8 redGreenColor = (_partyEffectFlags & 0x20000) ? 4 : 6; static const uint8 xCoords[] = { 8, 80 }; static const uint8 yCoords[] = { 2, 54, 106 }; @@ -520,18 +521,16 @@ void EobCoreEngine::gui_drawCharPortraitStatusFrame(int index) { EobCharacter *c = &_characters[index]; - int v8 = (_flags.gameID == GI_EOB2 && ((c->effectFlags & 0x4818) || c->effectsRemainder[0] || c->effectsRemainder[1] || ((_partyEffectFlags & 0x20000) | (_partyEffectFlags & 0xffff)))) || - (_flags.gameID == GI_EOB1 && ((c->effectFlags & 0x302) || c->effectsRemainder[0] || c->effectsRemainder[1])) ? 1 : 0; - int vA = (_flags.gameID == GI_EOB2 && ((((c->effectFlags & 0x3000) | (c->effectFlags & 0x10000)) || (_partyEffectFlags & 0x8420)))) || - (_flags.gameID == GI_EOB1 && ((c->effectFlags & 0x4c8) || _partyEffectFlags & 300000))? 1 : 0; + bool redGreen = ((c->effectFlags & 0x4818) || (_partyEffectFlags & 0x20000) || c->effectsRemainder[0] || c->effectsRemainder[1]) ? true : false; + bool yellow = ((c->effectFlags & 0x13000) || (_partyEffectFlags & 0x8420) || c->effectsRemainder[0] || c->effectsRemainder[1]) ? true : false; - if (v8 || vA) { - if (v8 && !vA) { - _screen->drawBox(x, y, x + 63, y + 49, boxColor); + if (redGreen || yellow) { + if (redGreen && !yellow) { + _screen->drawBox(x, y, x + 63, y + 49, redGreenColor); return; } - if (vA && !v8) { + if (yellow && !redGreen) { _screen->drawBox(x, y, x + 63, y + 49, 5); return; } @@ -541,11 +540,11 @@ void EobCoreEngine::gui_drawCharPortraitStatusFrame(int index) { for (int i = 0; i < 64; i += 16) { x = iX + i; - if (v8) { - _screen->drawClippedLine(x, y, x + 7, y, boxColor); - _screen->drawClippedLine(x + 8, y + 49, x + 15, y + 49, boxColor); + if (redGreen) { + _screen->drawClippedLine(x, y, x + 7, y, redGreenColor); + _screen->drawClippedLine(x + 8, y + 49, x + 15, y + 49, redGreenColor); } - if (vA) { + if (yellow) { _screen->drawClippedLine(x + 8, y, x + 15, y, 5); _screen->drawClippedLine(x, y + 49, x + 7, y + 49, 5); } @@ -556,13 +555,13 @@ void EobCoreEngine::gui_drawCharPortraitStatusFrame(int index) { for (int i = 1; i < 48; i += 12) { y = iY + i - 1; - if (vA) { + if (yellow) { _screen->drawClippedLine(x, y + 1, x, y + 6, 5); _screen->drawClippedLine(x + 63, y + 7, x + 63, y + 12, 5); } - if (v8) { - _screen->drawClippedLine(x, y + 7, x, y + 12, boxColor); - _screen->drawClippedLine(x + 63, y + 1, x + 63, y + 6, boxColor); + if (redGreen) { + _screen->drawClippedLine(x, y + 7, x, y + 12, redGreenColor); + _screen->drawClippedLine(x + 63, y + 1, x + 63, y + 6, redGreenColor); } } @@ -859,7 +858,7 @@ int EobCoreEngine::clickedCamp(Button *button) { drawScene(0); for (int i = 0; i < 6; i++) - cleanupCharacterSpellList(i); + sortCharacterSpellList(i); _screen->setCurPage(0); const ScreenDim *dm = _screen->getScreenDim(10); @@ -867,8 +866,11 @@ int EobCoreEngine::clickedCamp(Button *button) { _screen->updateScreen(); - enableSysTimer(2); - updateCharacterEvents(true); + enableSysTimer(2); + manualAdvanceTimer(2, _restPartyElapsedTime); + _restPartyElapsedTime = 0; + + checkPartyStatus(true); return button->arg; } @@ -2174,11 +2176,12 @@ void GUI_Eob::runCampMenu() { switch (inputFlag) { case 0x8001: - if (_vm->restParty()) + if (restParty()) runLoop = false; else _needRest = false; redrawPortraits = true; + newMenu = 0; break; case 0x8002: @@ -2286,7 +2289,7 @@ void GUI_Eob::runCampMenu() { if (_charSelectRedraw || redrawPortraits) { for (int i = 0; i < 6; i++) { _vm->gui_drawCharPortraitWithStats(i); - _vm->cleanupCharacterSpellList(i); + _vm->sortCharacterSpellList(i); } } @@ -2334,6 +2337,74 @@ bool GUI_Eob::runLoadMenu(int x, int y) { return result; } +bool GUI_Eob::confirmDialogue2(int dim, int id, int deflt) { + int od = _screen->curDimIndex(); + Screen::FontId of = _screen->setFont(Screen::FID_8_FNT); + _screen->setScreenDim(dim); + + drawTextBox(dim, id); + + int16 x[2]; + x[0] = (_screen->_curDim->sx << 3) + 8; + x[1] = (_screen->_curDim->sx + _screen->_curDim->w - 5) << 3; + int16 y = _screen->_curDim->sy + _screen->_curDim->h - 21; + int newHighlight = deflt ^ 1; + int lastHighlight = -1; + + for (int i = 0; i < 2; i++) + drawMenuButtonBox(x[i], y, 32, 14, false, false); + + for (bool runLoop = true; runLoop && !_vm->shouldQuit(); ) { + Common::Point p = _vm->getMousePos(); + if (_vm->posWithinRect(p.x, p.y, x[0], y, x[0] + 32, y + 14)) + newHighlight = 0; + else if (_vm->posWithinRect(p.x, p.y, x[1], y, x[1] + 32, y + 14)) + newHighlight = 1; + + int inputFlag = _vm->checkInput(0, false, 0) & 0x8ff; + _vm->removeInputTop(); + + if (inputFlag == _vm->_keyMap[Common::KEYCODE_SPACE] || inputFlag == _vm->_keyMap[Common::KEYCODE_RETURN]) { + runLoop = false; + } else if (inputFlag == _vm->_keyMap[Common::KEYCODE_LEFT] || inputFlag == _vm->_keyMap[Common::KEYCODE_KP4] || inputFlag == _vm->_keyMap[Common::KEYCODE_RIGHT] || inputFlag == _vm->_keyMap[Common::KEYCODE_KP6]) { + newHighlight ^= 1; + } else if (inputFlag == _vm->_keyMap[Common::KEYCODE_n]) { + newHighlight = 1; + runLoop = false; + } else if (inputFlag == _vm->_keyMap[Common::KEYCODE_y]) { + newHighlight = 0; + runLoop = false; + } else if (inputFlag == 199 || inputFlag == 201) { + if (_vm->posWithinRect(p.x, p.y, x[0], y, x[0] + 32, y + 14)) { + newHighlight = 0; + runLoop = false; + } else if (_vm->posWithinRect(p.x, p.y, x[1], y, x[1] + 32, y + 14)) { + newHighlight = 1; + runLoop = false; + } + } + + if (newHighlight != lastHighlight) { + for (int i = 0; i < 2; i++) + _screen->printShadedText(_vm->_menuYesNoStrings[i], x[i] + 16 - (strlen(_vm->_menuYesNoStrings[i]) << 2) + 1, y + 3, i == newHighlight ? 6 : 15, 0); + _screen->updateScreen(); + lastHighlight = newHighlight; + } + } + + drawMenuButtonBox(x[newHighlight], y, 32, 14, true, true); + _screen->updateScreen(); + _vm->_system->delayMillis(80); + drawMenuButtonBox(x[newHighlight], y, 32, 14, false, true); + _screen->updateScreen(); + + _screen->copyRegion(0, _screen->_curDim->h, _screen->_curDim->sx << 3, _screen->_curDim->sy, _screen->_curDim->w << 3, _screen->_curDim->h, 2, 0, Screen::CR_NO_P_CHECK); + _screen->setFont(of); + _screen->setScreenDim(od); + + return newHighlight ? false : true; +} + 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 @@ -2686,7 +2757,7 @@ void GUI_Eob::runMemorizePrayMenu(int charIndex, int spellType) { for (int i = 0; i < _numPages; i++) np[i] = _vm->_numSpellsMage[lv * _numPages + i]; - avltyFlags = c->mageSpellsAvailabilityFlags; + avltyFlags = c->mageSpellsAvailableFlags; } } @@ -2916,7 +2987,7 @@ void GUI_Eob::scribeScrollDialogue() { for (int i = 0; i < 32; i++) { for (int ii = 0; ii < 6; ii++) { - scrollInvSlot[i] = _vm->checkCharacterInventoryForItem(ii, 34, i + 1) + 1; + scrollInvSlot[i] = _vm->checkInventoryForItem(ii, 34, i + 1) + 1; if (scrollInvSlot[i] > 0) { numScrolls++; scrollCharacter[i] = ii; @@ -2936,7 +3007,7 @@ void GUI_Eob::scribeScrollDialogue() { if (!scrollInvSlot[i]) continue; - if (c->mageSpellsAvailabilityFlags & (1 << i)) + if (c->mageSpellsAvailableFlags & (1 << i)) scrollInvSlot[i] = 0; else menuItems[s++] = i + 1; @@ -3005,7 +3076,7 @@ void GUI_Eob::scribeScrollDialogue() { if (inputFlag == _vm->_keyMap[Common::KEYCODE_SPACE] || inputFlag == _vm->_keyMap[Common::KEYCODE_RETURN] || inputFlag == _vm->_keyMap[Common::KEYCODE_KP5]) { int t = menuItems[newHighLight] - 1; Item scItem = _vm->_characters[scrollCharacter[t]].inventory[scrollInvSlot[t] - 1]; - c->mageSpellsAvailabilityFlags |= (1 << t); + c->mageSpellsAvailableFlags |= (1 << t); _vm->_characters[scrollCharacter[t]].inventory[scrollInvSlot[t] - 1] = 0; _vm->gui_drawCharPortraitWithStats(_vm->_characters[scrollCharacter[t]].id); scrollInvSlot[t] = 0; @@ -3030,6 +3101,284 @@ void GUI_Eob::scribeScrollDialogue() { delete[] scrollInvSlot; } +bool GUI_Eob::restParty() { + static const int8 eob1healSpells[] = { 2, 15, 20, 24 }; + static const int8 eob2healSpells[] = { 3, 16, 20, 28 }; + const int8 *spells = _vm->game() == GI_EOB1 ? eob1healSpells : eob2healSpells; + + uint8 crs[6]; + memset(crs, 0, 6); + int hours = 0; + + if (_vm->_inf->preventRest()) { + assert(_vm->_menuStringsRest3[0]); + _vm->restParty_displayWarning(_vm->_menuStringsRest3[0]); + return true; + } + + if (_vm->restParty_updateMonsters()) + return true; + + if (_vm->restParty_extraAbortCondition()) + return true; + + drawMenuButtonBox(_screen->_curDim->sx << 3, _screen->_curDim->sy, _screen->_curDim->w << 3, _screen->_curDim->h, false, false); + + int nonPoisoned = 0; + for (int i = 0; i < 6; i++) { + if (!_vm->testCharacter(i, 1)) + continue; + nonPoisoned |= _vm->testCharacter(i, 0x10); + } + + if (!nonPoisoned) { + if (!confirmDialogue(59)) + return false; + } + + int8 *list = 0; + bool useHealers = false; + bool res = false; + bool restLoop = true; + bool restContinue = false; + int injured = _vm->restParty_getCharacterWithLowestHp(); + + if (injured > 0) { + for (int i = 0; i < 6; i++) { + if (!_vm->testCharacter(i, 13)) + continue; + if (_vm->getCharacterLevelIndex(2, _vm->_characters[i].cClass) == -1 && _vm->getCharacterLevelIndex(4, _vm->_characters[i].cClass) == -1) + continue; + if (_vm->checkInventoryForItem(i, 30, -1) == -1) + continue; + if (_vm->restParty_checkHealSpells(i)) + useHealers = confirmDialogue(40); + } + } + + _screen->setClearScreenDim(7); + _screen->setFont(Screen::FID_6_FNT); + + restParty_updateRestTime(hours, true); + + for (int l = 0; !res && restLoop && !_vm->shouldQuit(); ) { + l++; + + // Regenerate spells + for (int i = 0; i < 6; i++) { + crs[i]++; + + if (!_vm->_characters[i].food) + continue; + if (!_vm->testCharacter(i, 5)) + continue; + + if (_vm->checkInventoryForItem(i, 30, -1) != -1) { + list = _vm->_characters[i].clericSpells; + + for (int ii = 0; ii < 80; ii++) { + if ((ii / 10 + 48) >= crs[i]) + break; + + if (*list >= 0) { + list++; + continue; + } + + *list *= -1; + crs[i] = 48; + _vm->_txt->printMessage(Common::String::format(_vm->_menuStringsRest2[0], _vm->_characters[i].name, _vm->_spells[_vm->_mageSpellListSize + *list].name).c_str()); + _vm->delay(80); + break; + } + } + + if (_vm->checkInventoryForItem(i, 29, -1) != -1) { + list = _vm->_characters[i].mageSpells; + + for (int ii = 0; ii < 80; ii++) { + if ((ii / 6 + 48) >= crs[i]) + break; + + if (*list >= 0) { + list++; + continue; + } + + *list *= -1; + crs[i] = 48; + _vm->_txt->printMessage(Common::String::format(_vm->_menuStringsRest2[1], _vm->_characters[i].name, _vm->_spells[*list].name).c_str()); + _vm->delay(80); + break; + } + } + } + + // Heal party members + if (useHealers) { + for (int i = 0; i < 6 && injured; i++) { + if (_vm->getCharacterLevelIndex(2, _vm->_characters[i].cClass) == -1 && _vm->getCharacterLevelIndex(4, _vm->_characters[i].cClass) == -1) + continue; + if (_vm->checkInventoryForItem(i, 30, -1) == -1) + continue; + + list = 0; + if (crs[i] >= 48) { + for (int ii = 0; !list && ii < 3; ii++) + list = (int8*)memchr(_vm->_characters[i].clericSpells, -spells[ii], 80); + } + + if (list) + break; + + list = _vm->_characters[i].clericSpells; + for (int ii = 0; ii < 80 && injured; ii++) { + int healHp = 0; + if (*list == spells[0]) + healHp = _vm->rollDice(1, 8, 0); + else if (*list == spells[1]) + healHp = _vm->rollDice(2, 8, 1); + else if (*list == spells[2]) + healHp = _vm->rollDice(3, 8, 3); + + if (!healHp) { + list++; + continue; + } + + *list *= -1; + list++; + + crs[i] = 0; + injured--; + + _vm->_txt->printMessage(Common::String::format(_vm->_menuStringsRest2[2], _vm->_characters[i].name, _vm->_characters[injured].name).c_str()); + _vm->delay(80); + + _vm->_characters[injured].hitPointsCur += healHp; + if (_vm->_characters[injured].hitPointsCur > _vm->_characters[injured].hitPointsMax) + _vm->_characters[injured].hitPointsCur = _vm->_characters[injured].hitPointsMax; + + _vm->gui_drawCharPortraitWithStats(injured++); + } + } + } + + if (l == 6) { + l = 0; + restParty_updateRestTime(++hours, false); + _vm->_restPartyElapsedTime += (32760 * _vm->_tickLength); + + // Update poisoning + for (int i = 0; i < 6; i++) { + if (!_vm->testCharacter(i, 1)) + continue; + if (_vm->testCharacter(i, 16)) + continue; + _vm->inflictCharacterDamage(i, 10); + _vm->delayWithTicks(5); + } + + if (!(hours % 8)) { + bool starving = false; + for (int i = 0; i < 6; i++) { + // Add Lay On Hands spell + if (_vm->_characters[i].cClass == 2) { + list = (int8*)memchr(_vm->_characters[i].clericSpells, spells[3], 10); + if (list) { + *list = spells[3]; + } else { + list = (int8*)memchr(_vm->_characters[i].clericSpells, -spells[3], 10); + if (list) { + *list = spells[3]; + } else if (!memchr(_vm->_characters[i].clericSpells, spells[3], 10)) { + list = (int8*)memchr(_vm->_characters[i].clericSpells, 0, 10); + *list = spells[3]; + } + } + } + + if (!_vm->testCharacter(i, 3)) + continue; + + // Update hitpoints and food status + if (_vm->_characters[i].food) { + if (_vm->_characters[i].hitPointsCur < _vm->_characters[i].hitPointsMax) { + _vm->_characters[i].hitPointsCur++; + _screen->setFont(Screen::FID_6_FNT); + _vm->gui_drawCharPortraitWithStats(i); + } + + if (!_vm->checkInventoryForRings(i, 2)) { + if (_vm->_characters[i].food <= 5) { + _vm->_characters[i].food = 0; + starving = true; + } else { + _vm->_characters[i].food -= 5; + } + } + } else { + if ((hours % 24) || (_vm->_characters[i].hitPointsCur <= -10)) + continue; + _vm->inflictCharacterDamage(i, 1); + starving = true; + _screen->setFont(Screen::FID_6_FNT); + _vm->gui_drawCharPortraitWithStats(i); + } + } + + if (starving) { + if (!confirmDialogue(47)) { + restContinue = false; + restLoop = false; + } + restParty_updateRestTime(hours, true); + } + injured = restLoop ? _vm->restParty_getCharacterWithLowestHp() : 0; + } + } + + if (!_vm->restParty_checkSpellsToLearn() && restLoop && !restContinue && injured) { + restContinue = confirmDialogue(41); + restParty_updateRestTime(hours, true); + if (!restContinue) + restLoop = false; + } + + int in = _vm->checkInput(0, false, 0); + _vm->removeInputTop(); + if (in) + restLoop = false; + + if (restLoop) { + res = _vm->restParty_updateMonsters(); + if (!res) + res = _vm->checkPartyStatus(false); + } + + if (!_vm->restParty_checkSpellsToLearn()) { + if (!restContinue) { + if (!useHealers) + restLoop = false; + } + if (!injured) + restLoop = false; + } + } + + _vm->removeInputTop(); + _screen->setScreenDim(4); + _screen->setFont(Screen::FID_8_FNT); + + if (!injured && !res) + displayTextBox(43); + + if (res && hours > 4) + _vm->restParty_npc(); + + return res; +} + bool GUI_Eob::confirmDialogue(int id) { int od = _screen->curDimIndex(); Screen::FontId of = _screen->setFont(Screen::FID_8_FNT); @@ -3092,74 +3441,6 @@ bool GUI_Eob::confirmDialogue(int id) { return result; } -bool GUI_Eob::confirmDialogue2(int dim, int id, int deflt) { - int od = _screen->curDimIndex(); - Screen::FontId of = _screen->setFont(Screen::FID_8_FNT); - _screen->setScreenDim(dim); - - drawTextBox(dim, id); - - int16 x[2]; - x[0] = (_screen->_curDim->sx << 3) + 8; - x[1] = (_screen->_curDim->sx + _screen->_curDim->w - 5) << 3; - int16 y = _screen->_curDim->sy + _screen->_curDim->h - 21; - int newHighlight = deflt ^ 1; - int lastHighlight = -1; - - for (int i = 0; i < 2; i++) - drawMenuButtonBox(x[i], y, 32, 14, false, false); - - for (bool runLoop = true; runLoop && !_vm->shouldQuit(); ) { - Common::Point p = _vm->getMousePos(); - if (_vm->posWithinRect(p.x, p.y, x[0], y, x[0] + 32, y + 14)) - newHighlight = 0; - else if (_vm->posWithinRect(p.x, p.y, x[1], y, x[1] + 32, y + 14)) - newHighlight = 1; - - int inputFlag = _vm->checkInput(0, false, 0) & 0x8ff; - _vm->removeInputTop(); - - if (inputFlag == _vm->_keyMap[Common::KEYCODE_SPACE] || inputFlag == _vm->_keyMap[Common::KEYCODE_RETURN]) { - runLoop = false; - } else if (inputFlag == _vm->_keyMap[Common::KEYCODE_LEFT] || inputFlag == _vm->_keyMap[Common::KEYCODE_KP4] || inputFlag == _vm->_keyMap[Common::KEYCODE_RIGHT] || inputFlag == _vm->_keyMap[Common::KEYCODE_KP6]) { - newHighlight ^= 1; - } else if (inputFlag == _vm->_keyMap[Common::KEYCODE_n]) { - newHighlight = 1; - runLoop = false; - } else if (inputFlag == _vm->_keyMap[Common::KEYCODE_y]) { - newHighlight = 0; - runLoop = false; - } else if (inputFlag == 199 || inputFlag == 201) { - if (_vm->posWithinRect(p.x, p.y, x[0], y, x[0] + 32, y + 14)) { - newHighlight = 0; - runLoop = false; - } else if (_vm->posWithinRect(p.x, p.y, x[1], y, x[1] + 32, y + 14)) { - newHighlight = 1; - runLoop = false; - } - } - - if (newHighlight != lastHighlight) { - for (int i = 0; i < 2; i++) - _screen->printShadedText(_vm->_menuYesNoStrings[i], x[i] + 16 - (strlen(_vm->_menuYesNoStrings[i]) << 2) + 1, y + 3, i == newHighlight ? 6 : 15, 0); - _screen->updateScreen(); - lastHighlight = newHighlight; - } - } - - drawMenuButtonBox(x[newHighlight], y, 32, 14, true, true); - _screen->updateScreen(); - _vm->_system->delayMillis(80); - drawMenuButtonBox(x[newHighlight], y, 32, 14, false, true); - _screen->updateScreen(); - - _screen->copyRegion(0, _screen->_curDim->h, _screen->_curDim->sx << 3, _screen->_curDim->sy, _screen->_curDim->w << 3, _screen->_curDim->h, 2, 0, Screen::CR_NO_P_CHECK); - _screen->setFont(of); - _screen->setScreenDim(od); - - return newHighlight ? false : true; -} - void GUI_Eob::messageDialogue(int dim, int id, int buttonTextCol) { static const char buttonText[] = "OK"; @@ -3338,7 +3619,7 @@ int GUI_Eob::selectCharacterDialogue(int id) { result = -1; } } else { - if (_vm->checkCharacterInventoryForItem(result, 29, -1) == -1) { + if (_vm->checkInventoryForItem(result, 29, -1) == -1) { displayTextBox(25); result = -1; } @@ -3635,6 +3916,31 @@ int GUI_Eob::getHighlightSlot() { return res; } +void GUI_Eob::restParty_updateRestTime(int hours, bool init) { + Screen::FontId of = _screen->setFont(Screen::FID_8_FNT); + int od = _screen->curDimIndex(); + _screen->setScreenDim(10); + + if (init) { + _screen->setCurPage(0); + _vm->_txt->clearCurDim(); + drawMenuButtonBox(_screen->_curDim->sx << 3, _screen->_curDim->sy, _screen->_curDim->w << 3, _screen->_curDim->h, false, false); + _screen->copyRegion(_screen->_curDim->sx << 3, _screen->_curDim->sy, _screen->_curDim->sx << 3, _screen->_curDim->sy, _screen->_curDim->w << 3, _screen->_curDim->h, 0, 2, Screen::CR_NO_P_CHECK); + _screen->printShadedText(getMenuString(42), (_screen->_curDim->sx + 1) << 3, _screen->_curDim->sy + 5, 9, 0); + } + + _screen->setCurPage(2); + _screen->printShadedText(Common::String::format(_vm->_menuStringsRest2[3], hours).c_str(), (_screen->_curDim->sx + 1) << 3, _screen->_curDim->sy + 20, 15, _vm->_bkgColor_1); + _screen->setCurPage(0); + _screen->copyRegion(((_screen->_curDim->sx + 1) << 3) - 1, _screen->_curDim->sy + 20, ((_screen->_curDim->sx + 1) << 3) - 1, _screen->_curDim->sy + 20, 144, 8, 2, 0, Screen::CR_NO_P_CHECK); + _screen->updateScreen(); + + _vm->delay(160); + + _screen->setScreenDim(od); + _screen->setFont(of); +} + #endif // ENABLE_EOB } // End of namespace Kyra -- cgit v1.2.3 From c302b3e43b1d8cfe1eae669e01d3a0775d1f7b51 Mon Sep 17 00:00:00 2001 From: athrxx Date: Thu, 21 Jul 2011 00:28:57 +0200 Subject: KYRA: (EOB) - fix various bugs and implement some spells --- engines/kyra/gui_eob.cpp | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) (limited to 'engines/kyra/gui_eob.cpp') diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index 3a71642f9b..c13b4da7e9 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -665,11 +665,13 @@ void EobCoreEngine::gui_drawSpellbook() { int textXs = 71; int textY = 170; int col3 = _bkgColor_1; + int col4 = _color6; if (_flags.gameID == GI_EOB1) { textCol2 = 11; textXa = textXs = 73; textY = 168; + col4 = _bkgColor_1; } for (int i = 0; i < 7; i++) { @@ -686,7 +688,7 @@ void EobCoreEngine::gui_drawSpellbook() { if (d >= 0 && i < 6 && (i + _openBookSpellListOffset) < 9) _screen->printText(_openBookSpellList[d], textXs, 132 + 6 * i, textCol1, col3); else - _screen->printText(_magicStrings1[0], textXa, textY, 12, _color6); + _screen->printText(_magicStrings1[0], textXa, textY, 12, col4); } } @@ -805,7 +807,7 @@ void EobCoreEngine::gui_initButton(int index, int, int, int) { if (_flags.gameID == GI_EOB1) { // EOB1 spellbook modifications - if (index > 61 && index < 67) + if (index > 60 && index < 66) d = &_buttonDefs[index + 33]; if (index == 88) d = &_buttonDefs[index + 12]; @@ -867,7 +869,7 @@ int EobCoreEngine::clickedCamp(Button *button) { _screen->updateScreen(); enableSysTimer(2); - manualAdvanceTimer(2, _restPartyElapsedTime); + advanceTimers(_restPartyElapsedTime); _restPartyElapsedTime = 0; checkPartyStatus(true); @@ -1083,7 +1085,7 @@ int EobCoreEngine::clickedSpellbookList(Button *button) { int s = _openBookAvailableSpells[_openBookSpellLevel * 10 + _openBookSpellListOffset + _openBookSpellSelectedItem]; if (_openBookType == 1) - s += _mageSpellListSize; + s += _clericSpellOffset; castSpell(s, 0); @@ -1100,11 +1102,10 @@ int EobCoreEngine::clickedSpellbookList(Button *button) { } int EobCoreEngine::clickedCastSpellOnCharacter(Button *button) { - _activeSpellCaster = button->arg; + _activeSpellCaster = button->arg & 0xff; - if (_activeSpellCaster == 255) { - _txt->printMessage(_magicStrings3[1]); - snd_playSoundEffect(79); + if (_activeSpellCaster == 0xff) { + printWarning(_magicStrings3[_flags.gameID == GI_EOB1 ? 2 : 1]); if (_castScrollSlot) { gui_updateSlotAfterScrollUse(); } else { @@ -2774,7 +2775,7 @@ void GUI_Eob::runMemorizePrayMenu(int charIndex, int spellType) { for (int i = 0; i < 80; i++) { int8 s = charSpellList[i]; - if (s == 0 || s == _vm->_spellLevelsClericSize) + if (s == 0 || (_vm->game() == GI_EOB2 && s == 29)) continue; if (s < 0) @@ -2938,8 +2939,8 @@ void GUI_Eob::runMemorizePrayMenu(int charIndex, int spellType) { _screen->setFont(Screen::FID_8_FNT); memset(charSpellList, 0, 80); - if (spellType) - charSpellList[0] = _vm->_spellLevelsClericSize; + if (spellType && _vm->game() == GI_EOB2) + charSpellList[0] = 29; for (int i = 0; i < 32; i++) { if (_numAssignedSpellsOfType[i * 2] < _numAssignedSpellsOfType[i * 2 + 1]) @@ -3187,7 +3188,7 @@ bool GUI_Eob::restParty() { *list *= -1; crs[i] = 48; - _vm->_txt->printMessage(Common::String::format(_vm->_menuStringsRest2[0], _vm->_characters[i].name, _vm->_spells[_vm->_mageSpellListSize + *list].name).c_str()); + _vm->_txt->printMessage(Common::String::format(_vm->_menuStringsRest2[0], _vm->_characters[i].name, _vm->_spells[_vm->_clericSpellOffset + *list].name).c_str()); _vm->delay(80); break; } @@ -3485,7 +3486,7 @@ void GUI_Eob::messageDialogue(int dim, int id, int buttonTextCol) { } int GUI_Eob::selectCharacterDialogue(int id) { - uint8 flags = (id == 26) ? 0x14 : 0x02; + uint8 flags = (id == 26) ? (_vm->game() == GI_EOB1 ? 0x04 : 0x14) : 0x02; _vm->removeInputTop(); _charSelectRedraw = false; @@ -3613,10 +3614,13 @@ int GUI_Eob::selectCharacterDialogue(int id) { _screen->setFont(Screen::FID_8_FNT); if (result != -1 && id != 53) { - if (flags == 0x14) { - if (_vm->_classModifierFlags[_vm->_characters[result].cClass] & 0x10 && _vm->_characters[result].level[0] < 9) { - displayTextBox(24); - result = -1; + if (flags & 4) { + int lv = _vm->getCharacterLevelIndex(4, _vm->_characters[result].cClass); + if (lv != -1) { + if (_vm->_characters[result].level[lv] < 9) { + displayTextBox(24); + result = -1; + } } } else { if (_vm->checkInventoryForItem(result, 29, -1) == -1) { -- cgit v1.2.3 From 0e4c184e285c9b20b90536eb485a7f8a50833da3 Mon Sep 17 00:00:00 2001 From: athrxx Date: Thu, 28 Jul 2011 17:56:59 +0200 Subject: KYRA: (EOB) - implement some gui functionality, some bug fixes, etc. --- engines/kyra/gui_eob.cpp | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'engines/kyra/gui_eob.cpp') diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index c13b4da7e9..c7972299d1 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -924,7 +924,10 @@ int EobCoreEngine::clickedWeaponSlot(Button *button) { if (!testCharacter(button->arg, 1)) return 1; - static const uint8 sY[] = { 24, 24, 80, 80, 136, 136 }; + // Fix this using the coordinates from gui_drawWeaponSlot(). + // The coordinates used in the original are slightly wrong + // (most noticeable for characters 5 and 6). + static const uint8 sY[] = { 27, 27, 79, 79, 131, 131 }; int slot = sY[button->arg] > _mouseY ? 0 : 1; if ((_gui->_flagsMouseLeft & 0x7f) == 1) @@ -1298,19 +1301,17 @@ void EobCoreEngine::gui_processWeaponSlotClickLeft(int charIndex, int slotIndex) } void EobCoreEngine::gui_processWeaponSlotClickRight(int charIndex, int slotIndex) { - const char * const *strs = &_itemExtraStrings[_flags.gameID == GI_EOB1 ? 17 : (_flags.lang == Common::DE_DEU ? 26 : 22)]; - if (!testCharacter(charIndex, 0x0d)) return; - uint16 itm = _characters[charIndex].inventory[slotIndex]; + Item itm = _characters[charIndex].inventory[slotIndex]; int wslot = slotIndex < 2 ? slotIndex : -1; if (slotIndex < 2 && (!validateWeaponSlotItem(charIndex, slotIndex) || (!_currentControlMode && (_characters[charIndex].disabledSlots & (1 << slotIndex))))) return; if (!itemUsableByCharacter(charIndex, itm)) - _txt->printMessage(strs[0], -1, _characters[charIndex].name); + _txt->printMessage(_itemMisuseStrings[0], -1, _characters[charIndex].name); if (!itm && slotIndex > 1) return; @@ -1323,7 +1324,7 @@ void EobCoreEngine::gui_processWeaponSlotClickRight(int charIndex, int slotIndex case 0: case 16: // Item automatically used when worn - _txt->printMessage(strs[1]); + _txt->printMessage(_itemMisuseStrings[1]); break; case 1: @@ -1340,7 +1341,7 @@ void EobCoreEngine::gui_processWeaponSlotClickRight(int charIndex, int slotIndex case 13: case 15: // Item not used that way - _txt->printMessage(strs[2]); + _txt->printMessage(_itemMisuseStrings[2]); break; case 5: @@ -1377,12 +1378,12 @@ void EobCoreEngine::gui_processWeaponSlotClickRight(int charIndex, int slotIndex break; case 18: - ep = ep; + useWand(charIndex, wslot); break; case 19: // eob2 horn - ep = ep; + useHorn(charIndex, wslot); break; case 20: @@ -1397,7 +1398,7 @@ void EobCoreEngine::gui_processWeaponSlotClickRight(int charIndex, int slotIndex break; } - if (ep == 1 && charIndex >= 2) + if (_flags.gameID == GI_EOB1 || (ep == 1 && charIndex >= 2)) return; _lastUsedItem = itm; @@ -3837,8 +3838,12 @@ const char *GUI_Eob::getMenuString(int id) { return _vm->_menuStringsPoison[0]; else if (id >= 56) return _vm->_menuStringsHead[id - 56]; - else if (id >= 53) - return _vm->_menuStringsDrop2[id - 53]; + else if (id == 55) + return _vm->_menuStringsDrop2[_vm->game() == GI_EOB1 ? 1 : 2]; + else if (id == 54) + return _vm->_errorSlotNoNameString; + else if (id == 53) + return _vm->_menuStringsDrop2[0]; else if (id >= 48) return _vm->_menuStringsScribe[id - 48]; else if (id == 47) -- cgit v1.2.3 From 84900e8e50df8490fbdebc3acb25a338949f2de9 Mon Sep 17 00:00:00 2001 From: athrxx Date: Fri, 29 Jul 2011 15:57:02 +0200 Subject: KYRA: (EOB) - add turn undead spell, add some screen fades, fix some bugs --- engines/kyra/gui_eob.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'engines/kyra/gui_eob.cpp') diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index c7972299d1..ce5f3ea53f 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -149,17 +149,19 @@ Button *EobCoreEngine::gui_getButton(Button *buttonList, int index) { return 0; } -void EobCoreEngine::gui_drawPlayField(int pageNum) { +void EobCoreEngine::gui_drawPlayField(bool refresh) { _screen->loadEobCpsFileToPage("PLAYFLD", 0, 5, 3, 2); int cp = _screen->setCurPage(2); gui_drawCompass(true); - if (pageNum && !_sceneDrawPage2) + if (refresh && !_sceneDrawPage2) drawScene(0); _screen->setCurPage(cp); _screen->copyRegion(0, 0, 0, 0, 320, 200, 2, 0, Screen::CR_NO_P_CHECK); - _screen->updateScreen(); + + if (!_loading) + _screen->updateScreen(); _screen->loadEobCpsFileToPage("INVENT", 0, 5, 3, 2); } @@ -167,7 +169,7 @@ void EobCoreEngine::gui_drawPlayField(int pageNum) { void EobCoreEngine::gui_restorePlayField() { loadVcnData(0, 0); _screen->_curPage = 0; - gui_drawPlayField(1); + gui_drawPlayField(true); gui_drawAllCharPortraitsWithStats(); } @@ -706,7 +708,8 @@ void EobCoreEngine::gui_drawSpellbook() { _screen->setCurPage(0); _screen->copyRegion(64, 121, 64, 121, 112, 56, 2, 0, Screen::CR_NO_P_CHECK); - _screen->updateScreen(); + if (!_loading) + _screen->updateScreen(); } void EobCoreEngine::gui_drawSpellbookScrollArrow(int x, int y, int direction) { @@ -2245,7 +2248,7 @@ void GUI_Eob::runCampMenu() { if (cnt > 4) { _vm->dropCharacter(selectCharacterDialogue(53)); - _vm->gui_drawPlayField(0); + _vm->gui_drawPlayField(false); res = true; _screen->copyRegion(0, 120, 0, 0, 176, 24, 0, 14, Screen::CR_NO_P_CHECK); _screen->setFont(Screen::FID_6_FNT); -- cgit v1.2.3 From 48f83b7bb48a1625f6c195e396f8d40047f50915 Mon Sep 17 00:00:00 2001 From: athrxx Date: Mon, 1 Aug 2011 22:50:51 +0200 Subject: KYRA: (EOB) - implement npc sequences and fix some bugs --- engines/kyra/gui_eob.cpp | 64 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 50 insertions(+), 14 deletions(-) (limited to 'engines/kyra/gui_eob.cpp') diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index ce5f3ea53f..c495eb541f 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -385,7 +385,7 @@ void EobCoreEngine::gui_drawWeaponSlot(int charIndex, int slot) { if (itm) drawItemIconShape(_screen->_curPage, itm, x + 8, y); - else if (!slot && checkScriptFlag(0x8000)) + else if (!slot && _flags.gameID == GI_EOB2 && checkScriptFlag(0x80000000)) _screen->drawShape(_screen->_curPage, _itemIconShapes[103], x + 8, y, 0); else _screen->drawShape(_screen->_curPage, _itemIconShapes[85], x + 8, y, 0); @@ -2410,6 +2410,44 @@ bool GUI_Eob::confirmDialogue2(int dim, int id, int deflt) { return newHighlight ? false : true; } +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); + + _screen->_curPage = 2; + _screen->setClearScreenDim(dim); + drawMenuButtonBox(_screen->_curDim->sx << 3, _screen->_curDim->sy, _screen->_curDim->w << 3, _screen->_curDim->h, false, false); + _screen->printShadedText(getMenuString(id), (_screen->_curDim->sx << 3) + 5, _screen->_curDim->sy + 5, 15, 0); + _screen->_curPage = 0; + _screen->copyRegion(_screen->_curDim->sx << 3, _screen->_curDim->sy, _screen->_curDim->sx << 3, _screen->_curDim->sy, _screen->_curDim->w << 3, _screen->_curDim->h, 2, 0, Screen::CR_NO_P_CHECK); + + int x = (_screen->_curDim->sx << 3) + (_screen->_curDim->w << 2) - (strlen(_vm->_menuOkString) << 2); + int y = _screen->_curDim->sy + _screen->_curDim->h - 21; + int w = (strlen(_vm->_menuOkString) << 3) + 8; + drawMenuButtonBox(x, y, w, 14, false, false); + _screen->printShadedText(_vm->_menuOkString, x + 4, y + 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, x, y, x + w, y + 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; + } + } + + _vm->gui_drawBox(x, y, w, 14, _vm->_color2_1, _vm->_bkgColor_1, -1); + _screen->updateScreen(); + _vm->_system->delayMillis(80); + drawMenuButtonBox(x, y, w, 14, false, false); + _screen->printShadedText(_vm->_menuOkString, x + 4, y + 3, buttonTextCol, 0); + _screen->updateScreen(); + +} + 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 @@ -3375,11 +3413,12 @@ bool GUI_Eob::restParty() { _screen->setScreenDim(4); _screen->setFont(Screen::FID_8_FNT); - if (!injured && !res) - displayTextBox(43); - - if (res && hours > 4) - _vm->restParty_npc(); + if (!res) { + if (!injured) + displayTextBox(43); + if (hours > 4) + _vm->restParty_npc(); + } return res; } @@ -3447,8 +3486,6 @@ bool GUI_Eob::confirmDialogue(int id) { } void GUI_Eob::messageDialogue(int dim, int id, int buttonTextCol) { - static const char buttonText[] = "OK"; - int od = _screen->curDimIndex(); _screen->setScreenDim(dim); Screen::FontId of = _screen->setFont(Screen::FID_8_FNT); @@ -3456,12 +3493,12 @@ void GUI_Eob::messageDialogue(int dim, int id, int buttonTextCol) { drawTextBox(dim, id); const ScreenDim *dm = _screen->getScreenDim(dim); - int bx = ((dm->sx + dm->w) << 3) - ((strlen(buttonText) << 3) + 16); + int bx = ((dm->sx + dm->w) << 3) - ((strlen(_vm->_menuOkString) << 3) + 16); int by = dm->sy + dm->h - 19; - int bw = (strlen(buttonText) << 3) + 7; + int bw = (strlen(_vm->_menuOkString) << 3) + 7; drawMenuButtonBox(bx, by, bw, 14, false, false); - _screen->printShadedText(buttonText, bx + 4, by + 3, buttonTextCol, 0); + _screen->printShadedText(_vm->_menuOkString, bx + 4, by + 3, buttonTextCol, 0); _screen->updateScreen(); for (bool runLoop = true; runLoop && !_vm->shouldQuit(); ) { @@ -3469,9 +3506,8 @@ void GUI_Eob::messageDialogue(int dim, int id, int buttonTextCol) { _vm->removeInputTop(); if (inputFlag == 199 || inputFlag == 201) { - Common::Point p = _vm->getMousePos(); - if (_vm->posWithinRect(p.x, p.y, bx, by, bx + bw, by + 14)) - runLoop = false; + 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; } -- cgit v1.2.3 From aab9e62247af1c22772bb79821675fbab06c047d Mon Sep 17 00:00:00 2001 From: athrxx Date: Wed, 3 Aug 2011 00:40:21 +0200 Subject: KYRA: (EOB) - some more sequence code and bug fixes --- engines/kyra/gui_eob.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'engines/kyra/gui_eob.cpp') diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index c495eb541f..9dec1584c5 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -2509,7 +2509,7 @@ int GUI_Eob::getTextInput(char *dest, int x, int y, int destMaxLen, int textColo in = 0; _keyPressed.reset(); - while (!in) { + while (!in && !_vm->shouldQuit()) { if (next <= _vm->_system->getMillis()) { if (cursorState) { _screen->copyRegion((pos + 1) << 3, 191, (x + pos) << 3, y, 8, 9, 2, 0, Screen::CR_NO_P_CHECK); @@ -2595,7 +2595,7 @@ int GUI_Eob::getTextInput(char *dest, int x, int y, int destMaxLen, int textColo _screen->printShadedText(sufx, (x + pos) << 3, y, textColor1, textColor2); _screen->updateScreen(); - } while (_keyPressed.keycode != Common::KEYCODE_RETURN && _keyPressed.keycode != Common::KEYCODE_ESCAPE); + } while (_keyPressed.keycode != Common::KEYCODE_RETURN && _keyPressed.keycode != Common::KEYCODE_ESCAPE && !_vm->shouldQuit()); return _keyPressed.keycode == Common::KEYCODE_ESCAPE ? -1 : len; } @@ -3194,8 +3194,10 @@ bool GUI_Eob::restParty() { continue; if (_vm->checkInventoryForItem(i, 30, -1) == -1) continue; - if (_vm->restParty_checkHealSpells(i)) + if (_vm->restParty_checkHealSpells(i)) { useHealers = confirmDialogue(40); + break; + } } } -- cgit v1.2.3 From bac0caeb0ff712fe9002985c44c1ea651b86e018 Mon Sep 17 00:00:00 2001 From: athrxx Date: Sat, 6 Aug 2011 00:40:53 +0200 Subject: KYRA: (EOB) - lots of fixes towards EOB1 playability also implement some new code (EOB1 portals, burning hands spell, etc.) --- engines/kyra/gui_eob.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/kyra/gui_eob.cpp') diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index 9dec1584c5..04b863c325 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -150,7 +150,7 @@ Button *EobCoreEngine::gui_getButton(Button *buttonList, int index) { } void EobCoreEngine::gui_drawPlayField(bool refresh) { - _screen->loadEobCpsFileToPage("PLAYFLD", 0, 5, 3, 2); + _screen->loadEobBitmap("PLAYFLD", 0, 5, 3, 2); int cp = _screen->setCurPage(2); gui_drawCompass(true); @@ -163,7 +163,7 @@ void EobCoreEngine::gui_drawPlayField(bool refresh) { if (!_loading) _screen->updateScreen(); - _screen->loadEobCpsFileToPage("INVENT", 0, 5, 3, 2); + _screen->loadEobBitmap("INVENT", 0, 5, 3, 2); } void EobCoreEngine::gui_restorePlayField() { -- cgit v1.2.3 From fc5b29fdbcf4170436a32da2c1f4b078b1f1f90f Mon Sep 17 00:00:00 2001 From: athrxx Date: Sun, 7 Aug 2011 03:31:15 +0200 Subject: KYRA: (EOB) - implemented some spells and fixed more bugs --- engines/kyra/gui_eob.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/kyra/gui_eob.cpp') diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index 04b863c325..393bbab4a8 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -524,7 +524,7 @@ void EobCoreEngine::gui_drawCharPortraitStatusFrame(int index) { EobCharacter *c = &_characters[index]; bool redGreen = ((c->effectFlags & 0x4818) || (_partyEffectFlags & 0x20000) || c->effectsRemainder[0] || c->effectsRemainder[1]) ? true : false; - bool yellow = ((c->effectFlags & 0x13000) || (_partyEffectFlags & 0x8420) || c->effectsRemainder[0] || c->effectsRemainder[1]) ? true : false; + bool yellow = ((c->effectFlags & 0x13000) || (_partyEffectFlags & 0x8420)) ? true : false; if (redGreen || yellow) { if (redGreen && !yellow) { @@ -1108,9 +1108,9 @@ int EobCoreEngine::clickedSpellbookList(Button *button) { } int EobCoreEngine::clickedCastSpellOnCharacter(Button *button) { - _activeSpellCaster = button->arg & 0xff; + _activeSpellCharId = button->arg & 0xff; - if (_activeSpellCaster == 0xff) { + if (_activeSpellCharId == 0xff) { printWarning(_magicStrings3[_flags.gameID == GI_EOB1 ? 2 : 1]); if (_castScrollSlot) { gui_updateSlotAfterScrollUse(); @@ -1119,7 +1119,7 @@ int EobCoreEngine::clickedCastSpellOnCharacter(Button *button) { gui_drawSpellbook(); } } else { - if (_characters[_activeSpellCaster].flags & 1) + if (_characters[_activeSpellCharId].flags & 1) startSpell(_activeSpell); } -- cgit v1.2.3 From 0d54aff6324b1f6c739df89ab072328cc5402873 Mon Sep 17 00:00:00 2001 From: athrxx Date: Sun, 14 Aug 2011 18:29:45 +0200 Subject: KYRA: (EOB) - add EOB 1 intro (also add and fix several other things, like cone of cold vortex, drawShape issues, etc.) --- engines/kyra/gui_eob.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/kyra/gui_eob.cpp') diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index 393bbab4a8..fcd66c923b 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -385,7 +385,7 @@ void EobCoreEngine::gui_drawWeaponSlot(int charIndex, int slot) { if (itm) drawItemIconShape(_screen->_curPage, itm, x + 8, y); - else if (!slot && _flags.gameID == GI_EOB2 && checkScriptFlag(0x80000000)) + else if (!slot && _flags.gameID == GI_EOB2 && checkScriptFlags(0x80000000)) _screen->drawShape(_screen->_curPage, _itemIconShapes[103], x + 8, y, 0); else _screen->drawShape(_screen->_curPage, _itemIconShapes[85], x + 8, y, 0); -- cgit v1.2.3 From b3c8173bd46ddc831344848723598846bd5c41e8 Mon Sep 17 00:00:00 2001 From: athrxx Date: Mon, 14 Nov 2011 19:57:23 +0100 Subject: KYRA: (EOB) - extend save/load dialogue to support 990 slots --- engines/kyra/gui_eob.cpp | 84 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 68 insertions(+), 16 deletions(-) (limited to 'engines/kyra/gui_eob.cpp') diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index fcd66c923b..7778feba8e 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -1609,7 +1609,9 @@ int GUI_Eob::processButtonList(Kyra::Button *buttonList, uint16 inputFlags, int8 _flagsMouseRight = (_vm->_mouseClick == 2) ? 2 : 4; _vm->_mouseClick = 0; - if (in >= 199 && in <= 202) { + if (mouseWheel) { + return 204 + mouseWheel; + } else if (in >= 199 && in <= 202) { buttonReleaseFlag = (inputFlags & 0x800) ? 3 : 1; if (in < 201) _flagsMouseLeft = buttonReleaseFlag; @@ -2318,7 +2320,6 @@ bool GUI_Eob::runLoadMenu(int x, int y) { int xo = dm->sx; int yo = dm->sy; bool result = false; - _savegameListUpdateNeeded = true; _screen->modifyScreenDim(11, dm->sx + (x >> 3), dm->sy + y, dm->w, dm->h); @@ -2629,7 +2630,6 @@ bool GUI_Eob::runSaveMenu(int x, int y) { int xo = dm->sx; int yo = dm->sy; bool result = false; - _savegameListUpdateNeeded = true; _screen->modifyScreenDim(11, dm->sx + (x >> 3), dm->sy + y, dm->w, dm->h); @@ -2667,12 +2667,11 @@ bool GUI_Eob::runSaveMenu(int x, int y) { Common::Error err = _vm->saveGameStateIntern(_savegameOffset + slot, _saveSlotStringsTemp[slot], &thumb); thumb.free(); - if (err.getCode() == Common::kNoError) { - _savegameListUpdateNeeded = true; + if (err.getCode() == Common::kNoError) result = true; - } else { + else messageDialogue(11, 15, 6); - } + runLoop = false; } } @@ -2687,14 +2686,11 @@ int GUI_Eob::selectSaveSlotDialogue(int x, int y, int id) { _saveSlotX = _saveSlotY = 0; _screen->setCurPage(2); - updateSavegameList(); - setupSaveMenuSlots(); + updateSaveSlotsList(); + _savegameOffset = 0; drawMenuButtonBox(0, 0, 176, 144, false, false); _screen->printShadedText(_vm->_saveLoadStrings[2 + id], 52, 5, 15, 0); - - for (int i = 0; i < 7; i++) - drawSaveSlotButton(i, 1, 15); _screen->copyRegion(0, 0, x, y, 176, 144, 2, 0, Screen::CR_NO_P_CHECK); _screen->setCurPage(0); @@ -2703,6 +2699,7 @@ int GUI_Eob::selectSaveSlotDialogue(int x, int y, int id) { _saveSlotX = x; _saveSlotY = y; int lastHighlight = -1; + int lastOffset = -1; int newHighlight = 0; int slot = -1; @@ -2712,12 +2709,47 @@ int GUI_Eob::selectSaveSlotDialogue(int x, int y, int id) { if (inputFlag == _vm->_keyMap[Common::KEYCODE_SPACE] || inputFlag == _vm->_keyMap[Common::KEYCODE_RETURN]) { runLoop = false; + } else if (inputFlag == _vm->_keyMap[Common::KEYCODE_ESCAPE]) { + newHighlight = 6; + runLoop = false; } else if (inputFlag == _vm->_keyMap[Common::KEYCODE_DOWN] || inputFlag == _vm->_keyMap[Common::KEYCODE_KP2]) { - if (++newHighlight > 6) - newHighlight = 0; + if (++newHighlight > 5) { + newHighlight = 5; + if (++_savegameOffset > 984) + _savegameOffset = 984; + else + lastOffset = -1; + } } else if (inputFlag == _vm->_keyMap[Common::KEYCODE_UP] || inputFlag == _vm->_keyMap[Common::KEYCODE_KP8]) { - if (--newHighlight < 0) - newHighlight = 6; + if (--newHighlight < 0) { + newHighlight = 0; + if (--_savegameOffset < 0) + _savegameOffset = 0; + else + lastOffset = -1; + } + } else if (inputFlag == _vm->_keyMap[Common::KEYCODE_PAGEDOWN] || inputFlag == _vm->_keyMap[Common::KEYCODE_KP1]) { + _savegameOffset += 6; + if (_savegameOffset > 984) + _savegameOffset = 984; + else + lastOffset = -1; + } else if (inputFlag == _vm->_keyMap[Common::KEYCODE_PAGEUP] || inputFlag == _vm->_keyMap[Common::KEYCODE_KP7]) { + _savegameOffset -= 6; + if (_savegameOffset < 0) + _savegameOffset = 0; + else + lastOffset = -1; + } else if (inputFlag == 205) { + if (++_savegameOffset > 984) + _savegameOffset = 984; + else + lastOffset = -1; + } else if (inputFlag == 203) { + if (--_savegameOffset < 0) + _savegameOffset = 0; + else + lastOffset = -1; } else { slot = getHighlightSlot(); if (slot != -1) { @@ -2727,9 +2759,25 @@ int GUI_Eob::selectSaveSlotDialogue(int x, int y, int id) { } } + if (lastOffset != _savegameOffset) { + lastHighlight = -1; + setupSaveMenuSlots(); + for (int i = 0; i < 7; i++) + drawSaveSlotButton(i, 1, 15); + lastOffset = _savegameOffset; + } + if (lastHighlight != newHighlight) { drawSaveSlotButton(lastHighlight, 0, 15); drawSaveSlotButton(newHighlight, 0, 6); + + // Display highlighted slot index in the bottom left corner to avoid people getting lost with the 990 save slots + _screen->setFont(Screen::FID_6_FNT); + _screen->fillRect(_saveSlotX + 5, _saveSlotY + 135, _saveSlotX + 46, _saveSlotY + 140, _vm->_bkgColor_1); + int sli = (newHighlight == 6) ? _savegameOffset : (_savegameOffset + newHighlight); + _screen->printText(Common::String::format("%03d/989", sli).c_str(), _saveSlotX + 5, _saveSlotY + 135, _vm->_color2_1, _vm->_bkgColor_1); + _screen->setFont(Screen::FID_8_FNT); + _screen->updateScreen(); lastHighlight = newHighlight; } @@ -3966,6 +4014,10 @@ int GUI_Eob::getHighlightSlot() { return res; } +void GUI_Eob::sortSaveSlots() { + Common::sort(_saveSlots.begin(), _saveSlots.end(), Common::Less()); +} + void GUI_Eob::restParty_updateRestTime(int hours, bool init) { Screen::FontId of = _screen->setFont(Screen::FID_8_FNT); int od = _screen->curDimIndex(); -- cgit v1.2.3 From f7032c126dd097e8083e0fc740c7c856e0f2dd58 Mon Sep 17 00:00:00 2001 From: athrxx Date: Wed, 17 Aug 2011 18:46:29 +0200 Subject: KYRA: (EOB) - fix some bugs - fix monster movement - fix character level gain - add some static res for party transfer --- engines/kyra/gui_eob.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'engines/kyra/gui_eob.cpp') diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index 7778feba8e..a5f06c551e 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -1978,8 +1978,6 @@ int GUI_Eob::processButtonList(Kyra::Button *buttonList, uint16 inputFlags, int8 if (!result) result = inputFlags; - //_vm->_processingButtons=false; - return result; } @@ -2773,7 +2771,6 @@ int GUI_Eob::selectSaveSlotDialogue(int x, int y, int id) { // Display highlighted slot index in the bottom left corner to avoid people getting lost with the 990 save slots _screen->setFont(Screen::FID_6_FNT); - _screen->fillRect(_saveSlotX + 5, _saveSlotY + 135, _saveSlotX + 46, _saveSlotY + 140, _vm->_bkgColor_1); int sli = (newHighlight == 6) ? _savegameOffset : (_savegameOffset + newHighlight); _screen->printText(Common::String::format("%03d/989", sli).c_str(), _saveSlotX + 5, _saveSlotY + 135, _vm->_color2_1, _vm->_bkgColor_1); _screen->setFont(Screen::FID_8_FNT); @@ -3980,6 +3977,7 @@ void GUI_Eob::releaseButtons(Button *list) { delete list; list = n; } + _vm->gui_notifyButtonListChanged(); } void GUI_Eob::setupSaveMenuSlots() { -- cgit v1.2.3 From 2448d885e4e331a22e1e468277142155a5ddda87 Mon Sep 17 00:00:00 2001 From: athrxx Date: Sun, 21 Aug 2011 20:26:07 +0200 Subject: KYRA: (EOB) - complete EOBII playability - fixed temp data generation, block data loading, some spell issues, etc. - both EOB I and II should now be completable - one big issue remaining (AdLib driver gets swamped with monster sounds which causes heavy lags in some levels) --- engines/kyra/gui_eob.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'engines/kyra/gui_eob.cpp') diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index a5f06c551e..d333528ab2 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -853,12 +853,12 @@ int EobCoreEngine::clickedCamp(Button *button) { gui_drawCharPortraitWithStats(i); } - _screen->copyRegion(0, 120, 0, 0, 176, 24, 0, 14, Screen::CR_NO_P_CHECK); _screen->copyPage(0, 7); + _screen->copyRegion(0, 120, 0, 0, 176, 24, 0, 12, Screen::CR_NO_P_CHECK); _gui->runCampMenu(); - _screen->copyRegion(0, 0, 0, 120, 176, 24, 14, 2, Screen::CR_NO_P_CHECK); + _screen->copyRegion(0, 0, 0, 120, 176, 24, 12, 2, Screen::CR_NO_P_CHECK); _screen->setScreenDim(cd); drawScene(0); @@ -2250,7 +2250,7 @@ void GUI_Eob::runCampMenu() { _vm->dropCharacter(selectCharacterDialogue(53)); _vm->gui_drawPlayField(false); res = true; - _screen->copyRegion(0, 120, 0, 0, 176, 24, 0, 14, Screen::CR_NO_P_CHECK); + _screen->copyRegion(0, 120, 0, 0, 176, 24, 0, 12, Screen::CR_NO_P_CHECK); _screen->setFont(Screen::FID_6_FNT); _vm->gui_drawAllCharPortraitsWithStats(); _screen->setFont(Screen::FID_8_FNT); @@ -2282,6 +2282,8 @@ void GUI_Eob::runCampMenu() { default: break; } + + lastMenu = -1; } else { Common::Point p = _vm->getMousePos(); -- cgit v1.2.3 From 1cbd56693086afa8ce93092c3638e1052e31a5d9 Mon Sep 17 00:00:00 2001 From: athrxx Date: Thu, 29 Sep 2011 22:51:36 +0200 Subject: KYRA: (EOB) - fix invalid string access (also fix several cpp-check warnings) --- engines/kyra/gui_eob.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'engines/kyra/gui_eob.cpp') diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index d333528ab2..af97d487cb 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -85,6 +85,7 @@ void LolEobBaseEngine::gui_drawHorizontalBarGraph(int x, int y, int w, int h, in } void LolEobBaseEngine::gui_initButtonsFromList(const int16 *list) { + return; while (*list != -1) gui_initButton(*list++); } @@ -1480,7 +1481,7 @@ GUI_Eob::GUI_Eob(EobCoreEngine *vm) : GUI(vm), _vm(vm), _screen(vm->_screen) { GUI_Eob::~GUI_Eob() { if (_menuStringsPrefsTemp) { for (int i = 0; i < 4; i++) - delete _menuStringsPrefsTemp[i]; + delete[] _menuStringsPrefsTemp[i]; delete[] _menuStringsPrefsTemp; } @@ -1600,6 +1601,7 @@ void GUI_Eob::processButton(Button *button) { } int GUI_Eob::processButtonList(Kyra::Button *buttonList, uint16 inputFlags, int8 mouseWheel) { + return 0; _progress = 0; uint16 in = inputFlags & 0xff; uint16 buttonReleaseFlag = 0; @@ -3897,7 +3899,7 @@ void GUI_Eob::memorizePrayMenuPrintString(int spellId, int bookPageIndex, int sp void GUI_Eob::updateOptionsStrings() { for (int i = 0; i < 4; i++) { - delete _menuStringsPrefsTemp[i]; + delete[] _menuStringsPrefsTemp[i]; _menuStringsPrefsTemp[i] = new char[strlen(_vm->_menuStringsPrefs[i]) + 8]; } -- cgit v1.2.3 From 532f8f33f2dad8c0292c41301926becc5198a83e Mon Sep 17 00:00:00 2001 From: athrxx Date: Fri, 30 Sep 2011 19:34:42 +0200 Subject: KYRA: (EOB) - fix mem leak --- engines/kyra/gui_eob.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'engines/kyra/gui_eob.cpp') diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index af97d487cb..4ced205d91 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -85,7 +85,6 @@ void LolEobBaseEngine::gui_drawHorizontalBarGraph(int x, int y, int w, int h, in } void LolEobBaseEngine::gui_initButtonsFromList(const int16 *list) { - return; while (*list != -1) gui_initButton(*list++); } @@ -808,13 +807,17 @@ void EobCoreEngine::gui_initButton(int index, int, int, int) { b->index = index + 1; const EobGuiButtonDef *d = &_buttonDefs[index]; + b->buttonCallback = _buttonCallbacks[index]; if (_flags.gameID == GI_EOB1) { // EOB1 spellbook modifications - if (index > 60 && index < 66) + if (index > 60 && index < 66) { d = &_buttonDefs[index + 33]; - if (index == 88) + b->buttonCallback = _buttonCallbacks[index + 33]; + } else if (index == 88) { d = &_buttonDefs[index + 12]; + b->buttonCallback = _buttonCallbacks[index + 12]; + } } b->x = d->x; @@ -830,7 +833,6 @@ void EobCoreEngine::gui_initButton(int index, int, int, int) { b->keyCode = d->keyCode; b->keyCode2 = d->keyCode2; b->arg = d->arg; - b->buttonCallback = d->buttonCallback; } int EobCoreEngine::clickedCharPortraitDefault(Button *button) { @@ -1437,8 +1439,6 @@ void EobCoreEngine::gui_processInventorySlotClick(int slot) { } GUI_Eob::GUI_Eob(EobCoreEngine *vm) : GUI(vm), _vm(vm), _screen(vm->_screen) { - //_scrollUpFunctor = _scrollDownFunctor = BUTTON_FUNCTOR(GUI_Eob, this, 0); - _menuStringsPrefsTemp = new char*[4]; memset(_menuStringsPrefsTemp, 0, 4 * sizeof(char*)); @@ -1601,7 +1601,6 @@ void GUI_Eob::processButton(Button *button) { } int GUI_Eob::processButtonList(Kyra::Button *buttonList, uint16 inputFlags, int8 mouseWheel) { - return 0; _progress = 0; uint16 in = inputFlags & 0xff; uint16 buttonReleaseFlag = 0; -- cgit v1.2.3 From 5837e0f94ea7abf67ecd618fb641eec98231ebcb Mon Sep 17 00:00:00 2001 From: athrxx Date: Sat, 12 Nov 2011 14:35:16 +0100 Subject: KYRA: (EOB) - make sure that the music stops after character generation in Eob 1 (also more cleanup) --- engines/kyra/gui_eob.cpp | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'engines/kyra/gui_eob.cpp') diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index 4ced205d91..f084bc9978 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -2451,9 +2451,7 @@ void GUI_Eob::messageDialogue2(int dim, int id, int buttonTextCol) { } 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 - }; + static const uint8 colorTable[] = { 0x0F, 0xB0, 0xB2, 0xB4, 0xB6, 0xB8, 0xBA, 0xBC, 0x0C, 0xBC, 0xBA, 0xB8, 0xB6, 0xB4, 0xB2, 0xB0, 0x00 }; if (_updateBoxIndex == box) { if (_updateBoxIndex == -1) @@ -4044,6 +4042,29 @@ void GUI_Eob::restParty_updateRestTime(int hours, bool init) { _screen->setFont(of); } +const EobRect16 GUI_Eob::_updateBoxFrameHighLights[] = { + { 0x00B7, 0x0001, 0x00F7, 0x0034 }, + { 0x00FF, 0x0001, 0x013F, 0x0034 }, + { 0x00B7, 0x0035, 0x00F7, 0x0068 }, + { 0x00FF, 0x0035, 0x013F, 0x0068 }, + { 0x00B7, 0x0069, 0x00F7, 0x009C }, + { 0x00FF, 0x0069, 0x013F, 0x009C }, + { 0x0010, 0x003F, 0x0030, 0x0060 }, + { 0x0050, 0x003F, 0x0070, 0x0060 }, + { 0x0010, 0x007F, 0x0030, 0x00A0 }, + { 0x0050, 0x007F, 0x0070, 0x00A0 }, + { 0x00B0, 0x0042, 0x00D0, 0x0061 }, + { 0x00D0, 0x0042, 0x00F0, 0x0061 }, + { 0x00F0, 0x0042, 0x0110, 0x0061 }, + { 0x0110, 0x0042, 0x0130, 0x0061 }, + { 0x0004, 0x0018, 0x0024, 0x0039 }, + { 0x00A3, 0x0018, 0x00C3, 0x0039 }, + { 0x0004, 0x0040, 0x0024, 0x0061 }, + { 0x00A3, 0x0040, 0x00C3, 0x0061 }, + { 0x0004, 0x0068, 0x0024, 0x0089 }, + { 0x00A3, 0x0068, 0x00C3, 0x0089 } +}; + #endif // ENABLE_EOB } // End of namespace Kyra -- cgit v1.2.3 From aac7e16afa8546232a27754c6928cd43cd6ba876 Mon Sep 17 00:00:00 2001 From: athrxx Date: Mon, 28 Nov 2011 18:44:40 +0100 Subject: KYRA: (EOB) - fix some more bugs - wrong usage of static array which caused issues when restarting after RTL - portability issue with dialog labels - (original code) bug in hold person spell --- engines/kyra/gui_eob.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'engines/kyra/gui_eob.cpp') diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index f084bc9978..7d8e9250cd 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -2100,7 +2100,7 @@ void GUI_Eob::runCampMenu() { int newMenu = 0; int lastMenu = -1; bool redrawPortraits = false; - bool res = false; + _charSelectRedraw = false; _needRest = false; Button *buttonList = 0; @@ -2250,7 +2250,6 @@ void GUI_Eob::runCampMenu() { if (cnt > 4) { _vm->dropCharacter(selectCharacterDialogue(53)); _vm->gui_drawPlayField(false); - res = true; _screen->copyRegion(0, 120, 0, 0, 176, 24, 0, 12, Screen::CR_NO_P_CHECK); _screen->setFont(Screen::FID_6_FNT); _vm->gui_drawAllCharPortraitsWithStats(); -- cgit v1.2.3 From 8b618e46df21d90a1a5ad62633a2b9d3c1da0317 Mon Sep 17 00:00:00 2001 From: athrxx Date: Sun, 11 Dec 2011 12:29:09 +0100 Subject: KYRA: (EOB/LOL) - cleanup common code (rename some stuff and move EOB/LOL common code to separate files) --- engines/kyra/gui_eob.cpp | 262 ++++++++++++++--------------------------------- 1 file changed, 78 insertions(+), 184 deletions(-) (limited to 'engines/kyra/gui_eob.cpp') diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index 7d8e9250cd..6d13b17a5f 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -20,12 +20,12 @@ * */ -#if defined(ENABLE_EOB) || defined(ENABLE_LOL) +#ifdef ENABLE_EOB #include "kyra/eobcommon.h" #include "kyra/gui_eob.h" #include "kyra/script_eob.h" -#include "kyra/text_eob.h" +#include "kyra/text_rpg.h" #include "kyra/timer.h" #include "kyra/util.h" @@ -35,110 +35,6 @@ namespace Kyra { -void LolEobBaseEngine::removeInputTop() { - if (!_eventList.empty()) { - if (_eventList.begin()->event.type == Common::EVENT_LBUTTONDOWN) - _mouseClick = 1; - else if (_eventList.begin()->event.type == Common::EVENT_RBUTTONDOWN) - _mouseClick = 2; - else - _mouseClick = 0; - - _eventList.erase(_eventList.begin()); - } -} - -void LolEobBaseEngine::gui_drawBox(int x, int y, int w, int h, int frameColor1, int frameColor2, int fillColor) { - w--; h--; - if (fillColor != -1) - screen()->fillRect(x + 1, y + 1, x + w - 1, y + h - 1, fillColor); - - screen()->drawClippedLine(x + 1, y, x + w, y, frameColor2); - screen()->drawClippedLine(x + w, y, x + w, y + h - 1, frameColor2); - screen()->drawClippedLine(x, y, x, y + h, frameColor1); - screen()->drawClippedLine(x, y + h, x + w, y + h, frameColor1); -} - -void LolEobBaseEngine::gui_drawHorizontalBarGraph(int x, int y, int w, int h, int32 cur, int32 max, int col1, int col2) { - if (max < 1) - return; - if (cur < 0) - cur = 0; - - int32 e = MIN(cur, max); - - if (!--w) - return; - if (!--h) - return; - - int32 t = (e * w) / max; - - if (!t && e) - t++; - - if (t) - screen()->fillRect(x, y, x + t - 1, y + h, col1); - - if (t < w && col2) - screen()->fillRect(x + t, y, x + w, y + h, col2); -} - -void LolEobBaseEngine::gui_initButtonsFromList(const int16 *list) { - while (*list != -1) - gui_initButton(*list++); -} - -void LolEobBaseEngine::gui_resetButtonList() { - for (uint i = 0; i < ARRAYSIZE(_activeButtonData); ++i) - _activeButtonData[i].nextButton = 0; - - gui_notifyButtonListChanged(); - _activeButtons = 0; -} - -void LolEobBaseEngine::gui_notifyButtonListChanged() { - if (gui()) { - if (!_buttonListChanged && !_preserveEvents) - removeInputTop(); - _buttonListChanged = true; - } -} - -bool LolEobBaseEngine::clickedShape(int shapeIndex) { - if (_clickedSpecialFlag != 0x40) - return true; - - for (; shapeIndex; shapeIndex = _levelDecorationProperties[shapeIndex].next) { - if (_flags.gameID != GI_LOL) - shapeIndex--; - - uint16 s = _levelDecorationProperties[shapeIndex].shapeIndex[1]; - - if (s == 0xffff) - continue; - - int w = _flags.gameID == GI_LOL ? _levelDecorationShapes[s][3] : (_levelDecorationShapes[s][2] << 3); - int h = _levelDecorationShapes[s][_flags.gameID == GI_LOL ? 2 : 1]; - int x = _levelDecorationProperties[shapeIndex].shapeX[1] + _clickedShapeXOffs; - int y = _levelDecorationProperties[shapeIndex].shapeY[1] + _clickedShapeYOffs; - - if (_levelDecorationProperties[shapeIndex].flags & 1) { - if (_flags.gameID == GI_LOL) - w <<= 1; - else - x = 176 - x - w; - } - - if (posWithinRect(_mouseX, _mouseY, x - 4, y - 4, x + w + 8, y + h + 8)) - return true; - } - - return false; -} - -#ifdef ENABLE_EOB - Button *EobCoreEngine::gui_getButton(Button *buttonList, int index) { while (buttonList) { if (buttonList->index == index) @@ -159,7 +55,7 @@ void EobCoreEngine::gui_drawPlayField(bool refresh) { _screen->setCurPage(cp); _screen->copyRegion(0, 0, 0, 0, 320, 200, 2, 0, Screen::CR_NO_P_CHECK); - + if (!_loading) _screen->updateScreen(); @@ -397,7 +293,7 @@ void EobCoreEngine::gui_drawWeaponSlot(int charIndex, int slot) { void EobCoreEngine::gui_drawWeaponSlotStatus(int x, int y, int status) { Common::String tmpStr; Common::String tmpStr2; - + if (status > -3 || status == -5) _screen->drawShape(_screen->_curPage, _greenSplatShape, x - 1, y, 0); else @@ -507,7 +403,7 @@ void EobCoreEngine::gui_drawFoodStatusGraph(int index) { void EobCoreEngine::gui_drawHorizontalBarGraph(int x, int y, int w, int h, int32 curVal, int32 maxVal, int col1, int col2) { gui_drawBox(x - 1, y - 1, w + 3, h + 2, _color2_1, _color1_1, -1); - LolEobBaseEngine::gui_drawHorizontalBarGraph(x, y, w + 2, h, curVal, maxVal, col1, col2); + KyraRpgEngine::gui_drawHorizontalBarGraph(x, y, w + 2, h, curVal, maxVal, col1, col2); } void EobCoreEngine::gui_drawCharPortraitStatusFrame(int index) { @@ -858,7 +754,7 @@ int EobCoreEngine::clickedCamp(Button *button) { _screen->copyPage(0, 7); _screen->copyRegion(0, 120, 0, 0, 176, 24, 0, 12, Screen::CR_NO_P_CHECK); - + _gui->runCampMenu(); _screen->copyRegion(0, 0, 0, 120, 176, 24, 12, 2, Screen::CR_NO_P_CHECK); @@ -870,7 +766,7 @@ int EobCoreEngine::clickedCamp(Button *button) { _screen->setCurPage(0); const ScreenDim *dm = _screen->getScreenDim(10); - _screen->copyRegion(dm->sx << 3, dm->sy, dm->sx << 3, dm->sy, dm->w << 3, dm->h, 2, 0, Screen::CR_NO_P_CHECK); + _screen->copyRegion(dm->sx << 3, dm->sy, dm->sx << 3, dm->sy, dm->w << 3, dm->h, 2, 0, Screen::CR_NO_P_CHECK); _screen->updateScreen(); @@ -1457,7 +1353,7 @@ GUI_Eob::GUI_Eob(EobCoreEngine *vm) : GUI(vm), _vm(vm), _screen(vm->_screen) { _progress = 0; _prcButtonUnk3 = 1; _cflag = 0xffff; - + _menuLineSpacing = 0; _menuLastInFlags = 0; _menuCur = 0; @@ -1471,7 +1367,7 @@ GUI_Eob::GUI_Eob(EobCoreEngine *vm) : GUI(vm), _vm(vm), _screen(vm->_screen) { memset(_numAssignedSpellsOfType, 0, 72); _charSelectRedraw = false; - + _updateBoxIndex = -1; _highLightBoxTimer = 0; _updateBoxColorIndex = 0; @@ -1978,7 +1874,7 @@ int GUI_Eob::processButtonList(Kyra::Button *buttonList, uint16 inputFlags, int8 if (!result) result = inputFlags; - + return result; } @@ -2093,10 +1989,10 @@ void GUI_Eob::simpleMenu_flashSelection(const char *str, int x, int y, int color void GUI_Eob::runCampMenu() { Screen::FontId of = _screen->setFont(Screen::FID_8_FNT); - + Button *highlightButton = 0; Button *prevHighlightButton = 0; - + int newMenu = 0; int lastMenu = -1; bool redrawPortraits = false; @@ -2108,7 +2004,7 @@ void GUI_Eob::runCampMenu() { for (bool runLoop = true; runLoop && !_vm->shouldQuit(); ) { if (newMenu == 2) updateOptionsStrings(); - + if (newMenu != -1) { releaseButtons(buttonList); @@ -2117,7 +2013,7 @@ void GUI_Eob::runCampMenu() { _vm->_menuDefs[2].titleStrId = 57; else if (newMenu == 1) _vm->_menuDefs[1].titleStrId = 58; - + buttonList = initMenu(newMenu); if (newMenu != lastMenu) { @@ -2128,10 +2024,10 @@ void GUI_Eob::runCampMenu() { lastMenu = newMenu; newMenu = -1; } - + int inputFlag = _vm->checkInput(buttonList, false, 0) & 0x80ff; _vm->removeInputTop(); - + if (inputFlag == _vm->_keyMap[Common::KEYCODE_ESCAPE]) inputFlag = 0x8007; else if (inputFlag == _vm->_keyMap[Common::KEYCODE_KP5] || inputFlag == _vm->_keyMap[Common::KEYCODE_SPACE] || inputFlag == _vm->_keyMap[Common::KEYCODE_RETURN]) { @@ -2175,7 +2071,7 @@ void GUI_Eob::runCampMenu() { highlightButton = _vm->gui_getButton(buttonList, s); } - + } else if (inputFlag > 0x8000 && inputFlag < 0x8010) { int i = 0; int cnt = 0; @@ -2284,7 +2180,7 @@ void GUI_Eob::runCampMenu() { } lastMenu = -1; - + } else { Common::Point p = _vm->getMousePos(); for (Button *b = buttonList; b; b = b->nextButton) { @@ -2292,7 +2188,7 @@ void GUI_Eob::runCampMenu() { highlightButton = b; } } - + if (_charSelectRedraw || redrawPortraits) { for (int i = 0; i < 6; i++) { _vm->gui_drawCharPortraitWithStats(i); @@ -2320,10 +2216,10 @@ bool GUI_Eob::runLoadMenu(int x, int y) { int xo = dm->sx; int yo = dm->sy; bool result = false; - + _screen->modifyScreenDim(11, dm->sx + (x >> 3), dm->sy + y, dm->w, dm->h); - - for (bool runLoop = true; runLoop && !_vm->shouldQuit(); ) { + + for (bool runLoop = true; runLoop && !_vm->shouldQuit(); ) { int slot = selectSaveSlotDialogue(x, y, 1); if (slot > 5) { runLoop = result = false; @@ -2356,7 +2252,7 @@ bool GUI_Eob::confirmDialogue2(int dim, int id, int deflt) { int16 y = _screen->_curDim->sy + _screen->_curDim->h - 21; int newHighlight = deflt ^ 1; int lastHighlight = -1; - + for (int i = 0; i < 2; i++) drawMenuButtonBox(x[i], y, 32, 14, false, false); @@ -2391,7 +2287,7 @@ bool GUI_Eob::confirmDialogue2(int dim, int id, int deflt) { } if (newHighlight != lastHighlight) { - for (int i = 0; i < 2; i++) + for (int i = 0; i < 2; i++) _screen->printShadedText(_vm->_menuYesNoStrings[i], x[i] + 16 - (strlen(_vm->_menuYesNoStrings[i]) << 2) + 1, y + 3, i == newHighlight ? 6 : 15, 0); _screen->updateScreen(); lastHighlight = newHighlight; @@ -2407,7 +2303,7 @@ bool GUI_Eob::confirmDialogue2(int dim, int id, int deflt) { _screen->copyRegion(0, _screen->_curDim->h, _screen->_curDim->sx << 3, _screen->_curDim->sy, _screen->_curDim->w << 3, _screen->_curDim->h, 2, 0, Screen::CR_NO_P_CHECK); _screen->setFont(of); _screen->setScreenDim(od); - + return newHighlight ? false : true; } @@ -2417,7 +2313,7 @@ void GUI_Eob::messageDialogue2(int dim, int id, int buttonTextCol) { _screen->_curPage = 2; _screen->setClearScreenDim(dim); drawMenuButtonBox(_screen->_curDim->sx << 3, _screen->_curDim->sy, _screen->_curDim->w << 3, _screen->_curDim->h, false, false); - _screen->printShadedText(getMenuString(id), (_screen->_curDim->sx << 3) + 5, _screen->_curDim->sy + 5, 15, 0); + _screen->printShadedText(getMenuString(id), (_screen->_curDim->sx << 3) + 5, _screen->_curDim->sy + 5, 15, 0); _screen->_curPage = 0; _screen->copyRegion(_screen->_curDim->sx << 3, _screen->_curDim->sy, _screen->_curDim->sx << 3, _screen->_curDim->sy, _screen->_curDim->w << 3, _screen->_curDim->h, 2, 0, Screen::CR_NO_P_CHECK); @@ -2628,10 +2524,10 @@ bool GUI_Eob::runSaveMenu(int x, int y) { int xo = dm->sx; int yo = dm->sy; bool result = false; - + _screen->modifyScreenDim(11, dm->sx + (x >> 3), dm->sy + y, dm->w, dm->h); - - for (bool runLoop = true; runLoop && !_vm->shouldQuit(); ) { + + for (bool runLoop = true; runLoop && !_vm->shouldQuit(); ) { int slot = selectSaveSlotDialogue(x, y, 0); if (slot > 5) { runLoop = result = false; @@ -2641,13 +2537,13 @@ bool GUI_Eob::runSaveMenu(int x, int y) { _saveSlotStringsTemp[slot][0] = 0; else useSlot = confirmDialogue2(11, 55, 1); - + if (!useSlot) continue; int fx = (x + 1) << 3; int fy = y + slot * 17 + 23; - + for (int in = -1; in == -1 && !_vm->shouldQuit(); ) { _screen->fillRect(fx - 2, fy, fx + 160, fy + 8, _vm->_bkgColor_1); in = getTextInput(_saveSlotStringsTemp[slot], x + 1, fy, 19, 2, 0, 8); @@ -2665,12 +2561,12 @@ bool GUI_Eob::runSaveMenu(int x, int y) { Common::Error err = _vm->saveGameStateIntern(_savegameOffset + slot, _saveSlotStringsTemp[slot], &thumb); thumb.free(); - if (err.getCode() == Common::kNoError) + if (err.getCode() == Common::kNoError) result = true; else messageDialogue(11, 15, 6); - runLoop = false; + runLoop = false; } } @@ -2683,7 +2579,7 @@ int GUI_Eob::selectSaveSlotDialogue(int x, int y, int id) { _saveSlotX = _saveSlotY = 0; _screen->setCurPage(2); - + updateSaveSlotsList(); _savegameOffset = 0; @@ -2701,7 +2597,7 @@ int GUI_Eob::selectSaveSlotDialogue(int x, int y, int id) { int newHighlight = 0; int slot = -1; - for (bool runLoop = true; runLoop && !_vm->shouldQuit(); ) { + for (bool runLoop = true; runLoop && !_vm->shouldQuit(); ) { int inputFlag = _vm->checkInput(0, false, 0) & 0x8ff; _vm->removeInputTop(); @@ -2768,7 +2664,7 @@ int GUI_Eob::selectSaveSlotDialogue(int x, int y, int id) { if (lastHighlight != newHighlight) { drawSaveSlotButton(lastHighlight, 0, 15); drawSaveSlotButton(newHighlight, 0, 6); - + // Display highlighted slot index in the bottom left corner to avoid people getting lost with the 990 save slots _screen->setFont(Screen::FID_6_FNT); int sli = (newHighlight == 6) ? _savegameOffset : (_savegameOffset + newHighlight); @@ -2798,7 +2694,7 @@ void GUI_Eob::runMemorizePrayMenu(int charIndex, int spellType) { uint32 avltyFlags = 0; int li = 0; int lv = 0; - + EobCharacter *c = &_vm->_characters[charIndex]; int8 wm = c->wisdomCur - 12; if (wm < 0) @@ -2806,10 +2702,10 @@ void GUI_Eob::runMemorizePrayMenu(int charIndex, int spellType) { 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) @@ -2817,7 +2713,7 @@ void GUI_Eob::runMemorizePrayMenu(int charIndex, int spellType) { for (int i = 0; i < _numPages; i++) np[i] = _vm->_numSpellsPal[lv * _numPages + i]; - + avltyFlags = _paladinSpellAvltyFlags; } @@ -2878,7 +2774,7 @@ void GUI_Eob::runMemorizePrayMenu(int charIndex, int spellType) { for (int i = 0; i < 32; i++) { if (!(avltyFlags & (1 << i))) continue; - + int d = lh[i] - 1; if (d < 0) continue; @@ -2931,7 +2827,7 @@ void GUI_Eob::runMemorizePrayMenu(int charIndex, int spellType) { 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); + _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) @@ -2939,13 +2835,13 @@ void GUI_Eob::runMemorizePrayMenu(int charIndex, int spellType) { 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(); @@ -2961,7 +2857,7 @@ void GUI_Eob::runMemorizePrayMenu(int charIndex, int spellType) { newHighLightText = (p.y - 50 ) / 9; if (menuSpellMap[lastHighLightButton * 11] - 1 < newHighLightText) newHighLightText = menuSpellMap[lastHighLightButton * 11] - 1; - } + } } if (inputFlag & 0x8000) { @@ -2999,7 +2895,7 @@ void GUI_Eob::runMemorizePrayMenu(int charIndex, int spellType) { newHighLightText = 0; } else if (inputFlag == 0x8017) { if (numAssignedSpellsPerBookPage[lastHighLightButton]) { - for (int i = 1; i <= menuSpellMap[lastHighLightButton * 11]; i++) { + 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; } @@ -3087,7 +2983,7 @@ void GUI_Eob::scribeScrollDialogue() { if (numScrolls) { int csel = selectCharacterDialogue(49); if (csel != -1) { - + EobCharacter *c = &_vm->_characters[csel]; int s = 0; @@ -3128,7 +3024,7 @@ void GUI_Eob::scribeScrollDialogue() { redraw = false; lastHighLight = -1; newHighLight = 0; - } + } if (lastHighLight != newHighLight) { if (lastHighLight >= 0) @@ -3152,7 +3048,7 @@ void GUI_Eob::scribeScrollDialogue() { } else if (inputFlag == 0x8023 || inputFlag == _vm->_keyMap[Common::KEYCODE_ESCAPE]) { s = 0; } else if (inputFlag == 0x8024) { - newHighLight = (_vm->_mouseY - 50) / 9; + newHighLight = (_vm->_mouseY - 50) / 9; if (newHighLight >= 0 && newHighLight < s) { inputFlag = _vm->_keyMap[Common::KEYCODE_SPACE]; } else { @@ -3193,7 +3089,7 @@ bool GUI_Eob::restParty() { static const int8 eob1healSpells[] = { 2, 15, 20, 24 }; static const int8 eob2healSpells[] = { 3, 16, 20, 28 }; const int8 *spells = _vm->game() == GI_EOB1 ? eob1healSpells : eob2healSpells; - + uint8 crs[6]; memset(crs, 0, 6); int hours = 0; @@ -3243,7 +3139,7 @@ bool GUI_Eob::restParty() { useHealers = confirmDialogue(40); break; } - } + } } _screen->setClearScreenDim(7); @@ -3269,14 +3165,14 @@ bool GUI_Eob::restParty() { for (int ii = 0; ii < 80; ii++) { if ((ii / 10 + 48) >= crs[i]) break; - + if (*list >= 0) { list++; continue; } *list *= -1; - crs[i] = 48; + crs[i] = 48; _vm->_txt->printMessage(Common::String::format(_vm->_menuStringsRest2[0], _vm->_characters[i].name, _vm->_spells[_vm->_clericSpellOffset + *list].name).c_str()); _vm->delay(80); break; @@ -3289,14 +3185,14 @@ bool GUI_Eob::restParty() { for (int ii = 0; ii < 80; ii++) { if ((ii / 6 + 48) >= crs[i]) break; - + if (*list >= 0) { list++; continue; } *list *= -1; - crs[i] = 48; + crs[i] = 48; _vm->_txt->printMessage(Common::String::format(_vm->_menuStringsRest2[1], _vm->_characters[i].name, _vm->_spells[*list].name).c_str()); _vm->delay(80); break; @@ -3311,7 +3207,7 @@ bool GUI_Eob::restParty() { continue; if (_vm->checkInventoryForItem(i, 30, -1) == -1) continue; - + list = 0; if (crs[i] >= 48) { for (int ii = 0; !list && ii < 3; ii++) @@ -3416,7 +3312,7 @@ bool GUI_Eob::restParty() { _vm->gui_drawCharPortraitWithStats(i); } } - + if (starving) { if (!confirmDialogue(47)) { restContinue = false; @@ -3475,7 +3371,7 @@ bool GUI_Eob::confirmDialogue(int id) { Screen::FontId of = _screen->setFont(Screen::FID_8_FNT); Button *buttonList = initMenu(5); - + _screen->printShadedText(getMenuString(id), (_screen->_curDim->sx + 1) << 3, _screen->_curDim->sy + 4, 15, 0); int newHighlight = 0; @@ -3490,7 +3386,7 @@ bool GUI_Eob::confirmDialogue(int id) { _screen->updateScreen(); lastHighlight = newHighlight; } - + int inputFlag = _vm->checkInput(buttonList, false, 0) & 0x80ff; _vm->removeInputTop(); @@ -3539,7 +3435,7 @@ void GUI_Eob::messageDialogue(int dim, int id, int buttonTextCol) { 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; @@ -3565,7 +3461,7 @@ void GUI_Eob::messageDialogue(int dim, int id, int buttonTextCol) { _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); @@ -3576,7 +3472,7 @@ int GUI_Eob::selectCharacterDialogue(int id) { uint8 flags = (id == 26) ? (_vm->game() == GI_EOB1 ? 0x04 : 0x14) : 0x02; _vm->removeInputTop(); - _charSelectRedraw = false; + _charSelectRedraw = false; bool abort = false; int count = 0; int result = -1; @@ -3584,20 +3480,20 @@ int GUI_Eob::selectCharacterDialogue(int id) { for (int i = 0; i < 6; i++) { found[i] = -1; - + if (!_vm->testCharacter(i, 1)) continue; - + if (!(_vm->_classModifierFlags[_vm->_characters[i].cClass] & flags) && (id != 53)) continue; - + if (id != 53 && (!_vm->_characters[i].food || !_vm->testCharacter(i, 4))) { abort = true; } else { found[i] = 0; result = i; count++; - } + } } if (!count) { @@ -3627,7 +3523,7 @@ int GUI_Eob::selectCharacterDialogue(int id) { _charSelectRedraw = true; } - if (count == 1) { + if (count == 1) { int l = _vm->getCharacterLevelIndex(4, _vm->_characters[result].cClass); if (l == -1) @@ -3650,7 +3546,7 @@ int GUI_Eob::selectCharacterDialogue(int id) { while (result == -2 && !_vm->shouldQuit()) { int inputFlag = _vm->checkInput(buttonList, false, 0); _vm->removeInputTop(); - + 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]) { @@ -3757,7 +3653,7 @@ Button *GUI_Eob::initMenu(int id) { const ScreenDim *dm = _screen->getScreenDim(m->dim); _screen->fillRect(dm->sx << 3, dm->sy, ((dm->sx + dm->w) << 3) - 1, (dm->sy + dm->h) - 1, _vm->_bkgColor_1); _screen->setScreenDim(m->dim); - drawMenuButtonBox(dm->sx << 3, dm->sy, dm->w << 3, dm->h, false, false); + drawMenuButtonBox(dm->sx << 3, dm->sy, dm->w << 3, dm->h, false, false); } _screen->printShadedText(getMenuString(m->titleStrId), 5, 5, m->titleCol, 0); @@ -3798,7 +3694,7 @@ Button *GUI_Eob::initMenu(int id) { void GUI_Eob::drawMenuButton(Button *b, bool clicked, bool highlight, bool noFill) { if (!b) return; - + EobMenuButtonDef *d = (EobMenuButtonDef*)b->extButtonDef; if (d->flags & 1) @@ -3806,7 +3702,7 @@ void GUI_Eob::drawMenuButton(Button *b, bool clicked, bool highlight, bool noFil if (d->labelId) { const char *s = getMenuString(d->labelId); - + int xOffs = 4; int yOffs = 3; @@ -3825,7 +3721,7 @@ void GUI_Eob::drawMenuButton(Button *b, bool clicked, bool highlight, bool noFil void GUI_Eob::drawMenuButtonBox(int x, int y, int w, int h, bool clicked, bool noFill) { uint8 col1 = _vm->_color1_1; uint8 col2 = _vm->_color2_1; - + if (clicked) col1 = col2 = _vm->_bkgColor_1; @@ -3859,7 +3755,7 @@ void GUI_Eob::drawSaveSlotButton(int slot, int redrawBox, int textCol) { return; int x = _saveSlotX + 4; - int y = _saveSlotY + slot * 17 + 20; + int y = _saveSlotY + slot * 17 + 20; int w = 167; const char *s = (slot < 6) ?_saveSlotStringsTemp[slot] : _vm->_saveLoadStrings[0]; @@ -3867,8 +3763,8 @@ void GUI_Eob::drawSaveSlotButton(int slot, int redrawBox, int textCol) { x = _saveSlotX + 118; y = _saveSlotY + 126; w = 53; - } - + } + if (redrawBox) drawMenuButtonBox(x, y, w, 14, (redrawBox - 1) ? true : false, false); @@ -3997,7 +3893,7 @@ void GUI_Eob::setupSaveMenuSlots() { int GUI_Eob::getHighlightSlot() { int res = -1; Common::Point p = _vm->getMousePos(); - + for (int i = 0; i < 6; i++) { int y = _saveSlotY + i * 17 + 20; if (_vm->posWithinRect(p.x, p.y, _saveSlotX + 4, y, _saveSlotX + 167, y + 14)) { @@ -4034,7 +3930,7 @@ void GUI_Eob::restParty_updateRestTime(int hours, bool init) { _screen->setCurPage(0); _screen->copyRegion(((_screen->_curDim->sx + 1) << 3) - 1, _screen->_curDim->sy + 20, ((_screen->_curDim->sx + 1) << 3) - 1, _screen->_curDim->sy + 20, 144, 8, 2, 0, Screen::CR_NO_P_CHECK); _screen->updateScreen(); - + _vm->delay(160); _screen->setScreenDim(od); @@ -4064,9 +3960,7 @@ const EobRect16 GUI_Eob::_updateBoxFrameHighLights[] = { { 0x00A3, 0x0068, 0x00C3, 0x0089 } }; -#endif // ENABLE_EOB - } // End of namespace Kyra -#endif // defined(ENABLE_EOB) || defined(ENABLE_LOL) +#endif // ENABLE_EOB -- cgit v1.2.3 From 0aa32385230dbe1ab62bb2d02d04ca5cc46d928c Mon Sep 17 00:00:00 2001 From: athrxx Date: Mon, 12 Dec 2011 16:23:01 +0100 Subject: KYRA: (EOB/LOL) - rename some vars (all cases of Eob to EoB, all cases of Lol to LoL, all cases of LolEobCommon to RpgCommon) --- engines/kyra/gui_eob.cpp | 224 +++++++++++++++++++++++------------------------ 1 file changed, 112 insertions(+), 112 deletions(-) (limited to 'engines/kyra/gui_eob.cpp') diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index 6d13b17a5f..76b4b35b08 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -35,7 +35,7 @@ namespace Kyra { -Button *EobCoreEngine::gui_getButton(Button *buttonList, int index) { +Button *EoBCoreEngine::gui_getButton(Button *buttonList, int index) { while (buttonList) { if (buttonList->index == index) return buttonList; @@ -45,8 +45,8 @@ Button *EobCoreEngine::gui_getButton(Button *buttonList, int index) { return 0; } -void EobCoreEngine::gui_drawPlayField(bool refresh) { - _screen->loadEobBitmap("PLAYFLD", 0, 5, 3, 2); +void EoBCoreEngine::gui_drawPlayField(bool refresh) { + _screen->loadEoBBitmap("PLAYFLD", 0, 5, 3, 2); int cp = _screen->setCurPage(2); gui_drawCompass(true); @@ -59,29 +59,29 @@ void EobCoreEngine::gui_drawPlayField(bool refresh) { if (!_loading) _screen->updateScreen(); - _screen->loadEobBitmap("INVENT", 0, 5, 3, 2); + _screen->loadEoBBitmap("INVENT", 0, 5, 3, 2); } -void EobCoreEngine::gui_restorePlayField() { +void EoBCoreEngine::gui_restorePlayField() { loadVcnData(0, 0); _screen->_curPage = 0; gui_drawPlayField(true); gui_drawAllCharPortraitsWithStats(); } -void EobCoreEngine::gui_drawAllCharPortraitsWithStats() { +void EoBCoreEngine::gui_drawAllCharPortraitsWithStats() { for (int i = 0; i < 6; i++) gui_drawCharPortraitWithStats(i); } -void EobCoreEngine::gui_drawCharPortraitWithStats(int index) { +void EoBCoreEngine::gui_drawCharPortraitWithStats(int index) { if (!testCharacter(index, 1)) return; static const uint16 charPortraitPosX[] = { 8, 80, 184, 256 }; static const uint16 charPortraitPosY[] = { 2, 54, 106 }; - EobCharacter *c = &_characters[index]; + EoBCharacter *c = &_characters[index]; int txtCol1 = 12; int txtCol2 = 15; @@ -200,7 +200,7 @@ void EobCoreEngine::gui_drawCharPortraitWithStats(int index) { } } -void EobCoreEngine::gui_drawFaceShape(int index) { +void EoBCoreEngine::gui_drawFaceShape(int index) { if (!testCharacter(index, 1)) return; @@ -221,7 +221,7 @@ void EobCoreEngine::gui_drawFaceShape(int index) { y = 3; } - EobCharacter *c = &_characters[index]; + EoBCharacter *c = &_characters[index]; if (c->hitPointsCur == -10) { _screen->drawShape(_screen->_curPage, _deadCharShape, x, y, 0); @@ -261,7 +261,7 @@ void EobCoreEngine::gui_drawFaceShape(int index) { //} } -void EobCoreEngine::gui_drawWeaponSlot(int charIndex, int slot) { +void EoBCoreEngine::gui_drawWeaponSlot(int charIndex, int slot) { static const uint8 xCoords[] = { 40, 112 }; static const uint8 yCoords[] = { 11, 27, 63, 79, 115, 131 }; @@ -290,7 +290,7 @@ void EobCoreEngine::gui_drawWeaponSlot(int charIndex, int slot) { _screen->drawShape(_screen->_curPage, _weaponSlotGrid, x, y, 0); } -void EobCoreEngine::gui_drawWeaponSlotStatus(int x, int y, int status) { +void EoBCoreEngine::gui_drawWeaponSlotStatus(int x, int y, int status) { Common::String tmpStr; Common::String tmpStr2; @@ -330,7 +330,7 @@ void EobCoreEngine::gui_drawWeaponSlotStatus(int x, int y, int status) { } } -void EobCoreEngine::gui_drawHitpoints(int index) { +void EoBCoreEngine::gui_drawHitpoints(int index) { if (!testCharacter(index, 1)) return; @@ -356,7 +356,7 @@ void EobCoreEngine::gui_drawHitpoints(int index) { h = 5; } - EobCharacter *c = &_characters[index]; + EoBCharacter *c = &_characters[index]; if (_configHpBarGraphs) { int bgCur = c->hitPointsCur + 10; @@ -383,14 +383,14 @@ void EobCoreEngine::gui_drawHitpoints(int index) { } } -void EobCoreEngine::gui_drawFoodStatusGraph(int index) { +void EoBCoreEngine::gui_drawFoodStatusGraph(int index) { if (!_currentControlMode) return; if (!testCharacter(index, 1)) return; - EobCharacter *c = &_characters[index]; + EoBCharacter *c = &_characters[index]; if (!(c->flags & 1)) return; @@ -401,12 +401,12 @@ void EobCoreEngine::gui_drawFoodStatusGraph(int index) { gui_drawHorizontalBarGraph(250, 25, 51, 5, c->food, 100, col, _color5); } -void EobCoreEngine::gui_drawHorizontalBarGraph(int x, int y, int w, int h, int32 curVal, int32 maxVal, int col1, int col2) { +void EoBCoreEngine::gui_drawHorizontalBarGraph(int x, int y, int w, int h, int32 curVal, int32 maxVal, int col1, int col2) { gui_drawBox(x - 1, y - 1, w + 3, h + 2, _color2_1, _color1_1, -1); KyraRpgEngine::gui_drawHorizontalBarGraph(x, y, w + 2, h, curVal, maxVal, col1, col2); } -void EobCoreEngine::gui_drawCharPortraitStatusFrame(int index) { +void EoBCoreEngine::gui_drawCharPortraitStatusFrame(int index) { uint8 redGreenColor = (_partyEffectFlags & 0x20000) ? 4 : 6; static const uint8 xCoords[] = { 8, 80 }; @@ -417,7 +417,7 @@ void EobCoreEngine::gui_drawCharPortraitStatusFrame(int index) { if (!_screen->_curPage) x += 176; - EobCharacter *c = &_characters[index]; + EoBCharacter *c = &_characters[index]; bool redGreen = ((c->effectFlags & 0x4818) || (_partyEffectFlags & 0x20000) || c->effectsRemainder[0] || c->effectsRemainder[1]) ? true : false; bool yellow = ((c->effectFlags & 0x13000) || (_partyEffectFlags & 0x8420)) ? true : false; @@ -471,7 +471,7 @@ void EobCoreEngine::gui_drawCharPortraitStatusFrame(int index) { } } -void EobCoreEngine::gui_drawInventoryItem(int slot, int special, int pageNum) { +void EoBCoreEngine::gui_drawInventoryItem(int slot, int special, int pageNum) { int x = _inventorySlotsX[slot]; int y = _inventorySlotsY[slot]; @@ -502,7 +502,7 @@ void EobCoreEngine::gui_drawInventoryItem(int slot, int special, int pageNum) { _screen->updateScreen(); } -void EobCoreEngine::gui_drawCompass(bool force) { +void EoBCoreEngine::gui_drawCompass(bool force) { if (_currentDirection == _compassDirection && !force) return; @@ -516,12 +516,12 @@ void EobCoreEngine::gui_drawCompass(bool force) { _compassDirection = _currentDirection; } -void EobCoreEngine::gui_drawDialogueBox() { +void EoBCoreEngine::gui_drawDialogueBox() { gui_drawBox(0, 121, 320, 79, _color1_1, _color2_1, _bkgColor_1); txt()->clearCurDim(); } -void EobCoreEngine::gui_drawSpellbook() { +void EoBCoreEngine::gui_drawSpellbook() { _screen->setCurPage(2); int numTab = (_flags.gameID == GI_EOB1) ? 5 : 6; _screen->copyRegion(64, 121, 64, 121, 112, 56, 0, 2, Screen::CR_NO_P_CHECK); @@ -608,7 +608,7 @@ void EobCoreEngine::gui_drawSpellbook() { _screen->updateScreen(); } -void EobCoreEngine::gui_drawSpellbookScrollArrow(int x, int y, int direction) { +void EoBCoreEngine::gui_drawSpellbookScrollArrow(int x, int y, int direction) { static const uint8 x1[] = { 0, 2, 1, 0, 2, 2 }; static const uint8 x2[] = { 2, 4, 5, 6, 4, 4 }; if (direction) { @@ -622,7 +622,7 @@ void EobCoreEngine::gui_drawSpellbookScrollArrow(int x, int y, int direction) { } } -void EobCoreEngine::gui_updateSlotAfterScrollUse() { +void EoBCoreEngine::gui_updateSlotAfterScrollUse() { _characters[_openBookChar].disabledSlots ^= (1 << (--_castScrollSlot)); setCharEventTimer(_openBookChar, 18, _castScrollSlot + 2, 1); gui_drawCharPortraitWithStats(_openBookChar); @@ -632,7 +632,7 @@ void EobCoreEngine::gui_updateSlotAfterScrollUse() { gui_toggleButtons(); } -void EobCoreEngine::gui_updateControls() { +void EoBCoreEngine::gui_updateControls() { Button b; if (_currentControlMode) clickedPortraitRestore(&b); @@ -640,7 +640,7 @@ void EobCoreEngine::gui_updateControls() { clickedSpellbookAbort(&b); } -void EobCoreEngine::gui_toggleButtons() { +void EoBCoreEngine::gui_toggleButtons() { if (_currentControlMode == 0) gui_setPlayFieldButtons(); else if (_currentControlMode == 1) @@ -649,32 +649,32 @@ void EobCoreEngine::gui_toggleButtons() { gui_setStatsListButtons(); } -void EobCoreEngine::gui_setPlayFieldButtons() { +void EoBCoreEngine::gui_setPlayFieldButtons() { gui_resetButtonList(); gui_initButtonsFromList(_updateFlags ? _buttonList2 : _buttonList1); } -void EobCoreEngine::gui_setInventoryButtons() { +void EoBCoreEngine::gui_setInventoryButtons() { gui_resetButtonList(); gui_initButtonsFromList(_updateFlags ? _buttonList5 : _buttonList3); } -void EobCoreEngine::gui_setStatsListButtons() { +void EoBCoreEngine::gui_setStatsListButtons() { gui_resetButtonList(); gui_initButtonsFromList(_updateFlags ? _buttonList6 : _buttonList4); } -void EobCoreEngine::gui_setSwapCharacterButtons() { +void EoBCoreEngine::gui_setSwapCharacterButtons() { gui_resetButtonList(); gui_initButtonsFromList(_buttonList7); } -void EobCoreEngine::gui_setCastOnWhomButtons() { +void EoBCoreEngine::gui_setCastOnWhomButtons() { gui_resetButtonList(); gui_initButtonsFromList(_buttonList8); } -void EobCoreEngine::gui_initButton(int index, int, int, int) { +void EoBCoreEngine::gui_initButton(int index, int, int, int) { Button *b = 0; int cnt = 1; @@ -702,7 +702,7 @@ void EobCoreEngine::gui_initButton(int index, int, int, int) { b->index = index + 1; - const EobGuiButtonDef *d = &_buttonDefs[index]; + const EoBGuiButtonDef *d = &_buttonDefs[index]; b->buttonCallback = _buttonCallbacks[index]; if (_flags.gameID == GI_EOB1) { @@ -731,7 +731,7 @@ void EobCoreEngine::gui_initButton(int index, int, int, int) { b->arg = d->arg; } -int EobCoreEngine::clickedCharPortraitDefault(Button *button) { +int EoBCoreEngine::clickedCharPortraitDefault(Button *button) { if (!testCharacter(button->arg, 1)) return 1; @@ -739,7 +739,7 @@ int EobCoreEngine::clickedCharPortraitDefault(Button *button) { return 0; } -int EobCoreEngine::clickedCamp(Button *button) { +int EoBCoreEngine::clickedCamp(Button *button) { gui_updateControls(); disableSysTimer(2); int cd = _screen->curDimIndex(); @@ -779,7 +779,7 @@ int EobCoreEngine::clickedCamp(Button *button) { return button->arg; } -int EobCoreEngine::clickedSceneDropPickupItem(Button *button) { +int EoBCoreEngine::clickedSceneDropPickupItem(Button *button) { uint16 block = _currentBlock; if (button->arg > 1) { block = calcNewBlockPosition(_currentBlock, _currentDirection); @@ -805,7 +805,7 @@ int EobCoreEngine::clickedSceneDropPickupItem(Button *button) { return 1; } -int EobCoreEngine::clickedCharPortrait2(Button *button) { +int EoBCoreEngine::clickedCharPortrait2(Button *button) { if (!_gui->_progress) { if (!testCharacter(button->arg, 1)) return button->index; @@ -822,7 +822,7 @@ int EobCoreEngine::clickedCharPortrait2(Button *button) { return button->index; } -int EobCoreEngine::clickedWeaponSlot(Button *button) { +int EoBCoreEngine::clickedWeaponSlot(Button *button) { if (!testCharacter(button->arg, 1)) return 1; @@ -840,7 +840,7 @@ int EobCoreEngine::clickedWeaponSlot(Button *button) { return 1; } -int EobCoreEngine::clickedCharNameLabelRight(Button *button) { +int EoBCoreEngine::clickedCharNameLabelRight(Button *button) { if (!testCharacter(button->arg, 1)) return button->index; @@ -870,17 +870,17 @@ int EobCoreEngine::clickedCharNameLabelRight(Button *button) { return button->index; } -int EobCoreEngine::clickedInventorySlot(Button *button) { +int EoBCoreEngine::clickedInventorySlot(Button *button) { gui_processInventorySlotClick(button->arg); return button->index; } -int EobCoreEngine::clickedEatItem(Button *button) { +int EoBCoreEngine::clickedEatItem(Button *button) { eatItemInHand(_updateCharNum); return button->index; } -int EobCoreEngine::clickedInventoryPrevChar(Button *button) { +int EoBCoreEngine::clickedInventoryPrevChar(Button *button) { if (_gui->_progress == 1) _updateCharNum = 0; else if (_gui->_progress == 2) @@ -892,7 +892,7 @@ int EobCoreEngine::clickedInventoryPrevChar(Button *button) { return button->index; } -int EobCoreEngine::clickedInventoryNextChar(Button *button) { +int EoBCoreEngine::clickedInventoryNextChar(Button *button) { int oldVal = _updateCharNum; int v = button->arg == 2 ? 2 : 0; @@ -912,7 +912,7 @@ int EobCoreEngine::clickedInventoryNextChar(Button *button) { return button->index; } -int EobCoreEngine::clickedSpellbookTab(Button *button) { +int EoBCoreEngine::clickedSpellbookTab(Button *button) { _openBookSpellLevel = button->arg; _openBookSpellListOffset = 0; @@ -930,7 +930,7 @@ int EobCoreEngine::clickedSpellbookTab(Button *button) { return button->index; } -int EobCoreEngine::clickedSpellbookList(Button *button) { +int EoBCoreEngine::clickedSpellbookList(Button *button) { int listIndex = button->arg; bool spellLevelAvailable = false; @@ -1006,7 +1006,7 @@ int EobCoreEngine::clickedSpellbookList(Button *button) { return button->index; } -int EobCoreEngine::clickedCastSpellOnCharacter(Button *button) { +int EoBCoreEngine::clickedCastSpellOnCharacter(Button *button) { _activeSpellCharId = button->arg & 0xff; if (_activeSpellCharId == 0xff) { @@ -1025,7 +1025,7 @@ int EobCoreEngine::clickedCastSpellOnCharacter(Button *button) { return button->index; } -int EobCoreEngine::clickedInventoryNextPage(Button *button) { +int EoBCoreEngine::clickedInventoryNextPage(Button *button) { if (_currentControlMode == 2) { gui_setInventoryButtons(); _currentControlMode = 1; @@ -1038,7 +1038,7 @@ int EobCoreEngine::clickedInventoryNextPage(Button *button) { return button->index; } -int EobCoreEngine::clickedPortraitRestore(Button *button) { +int EoBCoreEngine::clickedPortraitRestore(Button *button) { _currentControlMode = 0; _screen->_curPage = 2; _screen->copyRegion(0, 0, 0, 0, 144, 168, 5, _screen->_curPage, Screen::CR_NO_P_CHECK); @@ -1050,7 +1050,7 @@ int EobCoreEngine::clickedPortraitRestore(Button *button) { return button->index; } -int EobCoreEngine::clickedUpArrow(Button *button) { +int EoBCoreEngine::clickedUpArrow(Button *button) { int b = calcNewBlockPositionAndTestPassability(_currentBlock, _currentDirection); if (b == -1) { @@ -1063,7 +1063,7 @@ int EobCoreEngine::clickedUpArrow(Button *button) { return button->index; } -int EobCoreEngine::clickedDownArrow(Button *button) { +int EoBCoreEngine::clickedDownArrow(Button *button) { int b = calcNewBlockPositionAndTestPassability(_currentBlock, (_currentDirection + 2) & 3); if (b == -1) { @@ -1076,7 +1076,7 @@ int EobCoreEngine::clickedDownArrow(Button *button) { return button->index; } -int EobCoreEngine::clickedLeftArrow(Button *button) { +int EoBCoreEngine::clickedLeftArrow(Button *button) { int b = calcNewBlockPositionAndTestPassability(_currentBlock, (_currentDirection - 1) & 3); if (b == -1) { @@ -1089,7 +1089,7 @@ int EobCoreEngine::clickedLeftArrow(Button *button) { return button->index; } -int EobCoreEngine::clickedRightArrow(Button *button) { +int EoBCoreEngine::clickedRightArrow(Button *button) { int b = calcNewBlockPositionAndTestPassability(_currentBlock, (_currentDirection + 1) & 3); if (b == -1) { @@ -1102,7 +1102,7 @@ int EobCoreEngine::clickedRightArrow(Button *button) { return button->index; } -int EobCoreEngine::clickedTurnLeftArrow(Button *button) { +int EoBCoreEngine::clickedTurnLeftArrow(Button *button) { _currentDirection = (_currentDirection - 1) & 3; //_keybControlUnk = -1; _sceneDefaultUpdate = 1; @@ -1110,7 +1110,7 @@ int EobCoreEngine::clickedTurnLeftArrow(Button *button) { return button->index; } -int EobCoreEngine::clickedTurnRightArrow(Button *button) { +int EoBCoreEngine::clickedTurnRightArrow(Button *button) { _currentDirection = (_currentDirection + 1) & 3; //_keybControlUnk = -1; _sceneDefaultUpdate = 1; @@ -1118,7 +1118,7 @@ int EobCoreEngine::clickedTurnRightArrow(Button *button) { return button->index; } -int EobCoreEngine::clickedAbortCharSwitch(Button *button) { +int EoBCoreEngine::clickedAbortCharSwitch(Button *button) { _timer->disable(0); int c = _exchangeCharacterId; _exchangeCharacterId = -1; @@ -1127,7 +1127,7 @@ int EobCoreEngine::clickedAbortCharSwitch(Button *button) { return button->index; } -int EobCoreEngine::clickedSceneThrowItem(Button *button) { +int EoBCoreEngine::clickedSceneThrowItem(Button *button) { if (!_itemInHand) return button->index; @@ -1139,12 +1139,12 @@ int EobCoreEngine::clickedSceneThrowItem(Button *button) { return button->index; } -int EobCoreEngine::clickedSceneSpecial(Button *button) { +int EoBCoreEngine::clickedSceneSpecial(Button *button) { _clickedSpecialFlag = 0x40; return specialWallAction(calcNewBlockPosition(_currentBlock, _currentDirection), _currentDirection); } -int EobCoreEngine::clickedSpellbookAbort(Button *button) { +int EoBCoreEngine::clickedSpellbookAbort(Button *button) { _updateFlags = 0; _screen->copyRegion(0, 0, 64, 121, 112, 56, 10, 0, Screen::CR_NO_P_CHECK); _screen->updateScreen(); @@ -1153,7 +1153,7 @@ int EobCoreEngine::clickedSpellbookAbort(Button *button) { return button->index; } -int EobCoreEngine::clickedSpellbookScroll(Button *button) { +int EoBCoreEngine::clickedSpellbookScroll(Button *button) { if (_openBookAvailableSpells[_openBookSpellLevel * 10] > 0) { _openBookSpellListOffset ^= 6; _openBookSpellSelectedItem = 0; @@ -1169,11 +1169,11 @@ int EobCoreEngine::clickedSpellbookScroll(Button *button) { return button->index; } -int EobCoreEngine::clickedUnk(Button *button) { +int EoBCoreEngine::clickedUnk(Button *button) { return button->index; } -void EobCoreEngine::gui_processCharPortraitClick(int index) { +void EoBCoreEngine::gui_processCharPortraitClick(int index) { if (index == _updateCharNum) return; @@ -1184,7 +1184,7 @@ void EobCoreEngine::gui_processCharPortraitClick(int index) { gui_drawCharPortraitWithStats(index); } -void EobCoreEngine::gui_processWeaponSlotClickLeft(int charIndex, int slotIndex) { +void EoBCoreEngine::gui_processWeaponSlotClickLeft(int charIndex, int slotIndex) { int itm = _characters[charIndex].inventory[slotIndex]; if (_items[itm].flags & 0x20) return; @@ -1202,7 +1202,7 @@ void EobCoreEngine::gui_processWeaponSlotClickLeft(int charIndex, int slotIndex) recalcArmorClass(charIndex); } -void EobCoreEngine::gui_processWeaponSlotClickRight(int charIndex, int slotIndex) { +void EoBCoreEngine::gui_processWeaponSlotClickRight(int charIndex, int slotIndex) { if (!testCharacter(charIndex, 0x0d)) return; @@ -1308,7 +1308,7 @@ void EobCoreEngine::gui_processWeaponSlotClickRight(int charIndex, int slotIndex _lastUsedItem = 0; } -void EobCoreEngine::gui_processInventorySlotClick(int slot) { +void EoBCoreEngine::gui_processInventorySlotClick(int slot) { int itm = _characters[_updateCharNum].inventory[slot]; int ih = _itemInHand; if (!validateInventorySlotForItem(ih, _updateCharNum, slot)) @@ -1334,7 +1334,7 @@ void EobCoreEngine::gui_processInventorySlotClick(int slot) { } } -GUI_Eob::GUI_Eob(EobCoreEngine *vm) : GUI(vm), _vm(vm), _screen(vm->_screen) { +GUI_EoB::GUI_EoB(EoBCoreEngine *vm) : GUI(vm), _vm(vm), _screen(vm->_screen) { _menuStringsPrefsTemp = new char*[4]; memset(_menuStringsPrefsTemp, 0, 4 * sizeof(char*)); @@ -1374,7 +1374,7 @@ GUI_Eob::GUI_Eob(EobCoreEngine *vm) : GUI(vm), _vm(vm), _screen(vm->_screen) { _needRest = false; } -GUI_Eob::~GUI_Eob() { +GUI_EoB::~GUI_EoB() { if (_menuStringsPrefsTemp) { for (int i = 0; i < 4; i++) delete[] _menuStringsPrefsTemp[i]; @@ -1392,7 +1392,7 @@ GUI_Eob::~GUI_Eob() { delete[] _numAssignedSpellsOfType; } -void GUI_Eob::processButton(Button *button) { +void GUI_EoB::processButton(Button *button) { if (!button->data0Val1 && !button->data2Val1 && !button->data1Val1) return; @@ -1496,7 +1496,7 @@ void GUI_Eob::processButton(Button *button) { } } -int GUI_Eob::processButtonList(Kyra::Button *buttonList, uint16 inputFlags, int8 mouseWheel) { +int GUI_EoB::processButtonList(Kyra::Button *buttonList, uint16 inputFlags, int8 mouseWheel) { _progress = 0; uint16 in = inputFlags & 0xff; uint16 buttonReleaseFlag = 0; @@ -1878,7 +1878,7 @@ int GUI_Eob::processButtonList(Kyra::Button *buttonList, uint16 inputFlags, int8 return result; } -void GUI_Eob::simpleMenu_setup(int sd, int maxItem, const char *const *strings, int32 menuItemsMask, int itemOffset, int lineSpacing) { +void GUI_EoB::simpleMenu_setup(int sd, int maxItem, const char *const *strings, int32 menuItemsMask, int itemOffset, int lineSpacing) { simpleMenu_initMenuItemsMask(sd, maxItem, menuItemsMask, itemOffset); const ScreenDim *dm = _screen->getScreenDim(19 + sd); @@ -1901,7 +1901,7 @@ void GUI_Eob::simpleMenu_setup(int sd, int maxItem, const char *const *strings, _vm->removeInputTop(); } -int GUI_Eob::simpleMenu_process(int sd, const char *const *strings, void *b, int32 menuItemsMask, int itemOffset) { +int GUI_EoB::simpleMenu_process(int sd, const char *const *strings, void *b, int32 menuItemsMask, int itemOffset) { const ScreenDim *dm = _screen->getScreenDim(19 + sd); int h = _menuNumItems - 1; int currentItem = _menuCur % _menuNumItems; @@ -1958,7 +1958,7 @@ int GUI_Eob::simpleMenu_process(int sd, const char *const *strings, void *b, int return result; } -int GUI_Eob::simpleMenu_getMenuItem(int index, int32 menuItemsMask, int itemOffset) { +int GUI_EoB::simpleMenu_getMenuItem(int index, int32 menuItemsMask, int itemOffset) { if (menuItemsMask == -1) return index; @@ -1976,7 +1976,7 @@ int GUI_Eob::simpleMenu_getMenuItem(int index, int32 menuItemsMask, int itemOffs return res; } -void GUI_Eob::simpleMenu_flashSelection(const char *str, int x, int y, int color1, int color2, int color3) { +void GUI_EoB::simpleMenu_flashSelection(const char *str, int x, int y, int color1, int color2, int color3) { for (int i = 0; i < 3; i++) { _screen->printText(str, x, y, color2, color3); _screen->updateScreen(); @@ -1987,7 +1987,7 @@ void GUI_Eob::simpleMenu_flashSelection(const char *str, int x, int y, int color } } -void GUI_Eob::runCampMenu() { +void GUI_EoB::runCampMenu() { Screen::FontId of = _screen->setFont(Screen::FID_8_FNT); Button *highlightButton = 0; @@ -2211,7 +2211,7 @@ void GUI_Eob::runCampMenu() { _vm->writeSettings(); } -bool GUI_Eob::runLoadMenu(int x, int y) { +bool GUI_EoB::runLoadMenu(int x, int y) { const ScreenDim *dm = _screen->getScreenDim(11); int xo = dm->sx; int yo = dm->sy; @@ -2239,7 +2239,7 @@ bool GUI_Eob::runLoadMenu(int x, int y) { return result; } -bool GUI_Eob::confirmDialogue2(int dim, int id, int deflt) { +bool GUI_EoB::confirmDialogue2(int dim, int id, int deflt) { int od = _screen->curDimIndex(); Screen::FontId of = _screen->setFont(Screen::FID_8_FNT); _screen->setScreenDim(dim); @@ -2307,7 +2307,7 @@ bool GUI_Eob::confirmDialogue2(int dim, int id, int deflt) { return newHighlight ? false : true; } -void GUI_Eob::messageDialogue2(int dim, int id, int buttonTextCol) { +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); _screen->_curPage = 2; @@ -2345,7 +2345,7 @@ void GUI_Eob::messageDialogue2(int dim, int id, int buttonTextCol) { } -void GUI_Eob::updateBoxFrameHighLight(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 }; if (_updateBoxIndex == box) { @@ -2358,7 +2358,7 @@ void GUI_Eob::updateBoxFrameHighLight(int box) { if (!colorTable[_updateBoxColorIndex]) _updateBoxColorIndex = 0; - const EobRect16 *r = &_updateBoxFrameHighLights[_updateBoxIndex]; + const EoBRect16 *r = &_updateBoxFrameHighLights[_updateBoxIndex]; _screen->drawBox(r->x1, r->y1, r->x2, r->y2, colorTable[_updateBoxColorIndex++]); _screen->updateScreen(); @@ -2366,7 +2366,7 @@ void GUI_Eob::updateBoxFrameHighLight(int box) { } else { if (_updateBoxIndex != -1) { - const EobRect16 *r = &_updateBoxFrameHighLights[_updateBoxIndex]; + const EoBRect16 *r = &_updateBoxFrameHighLights[_updateBoxIndex]; _screen->drawBox(r->x1, r->y1, r->x2, r->y2, 12); _screen->updateScreen(); } @@ -2377,7 +2377,7 @@ void GUI_Eob::updateBoxFrameHighLight(int box) { } } -int GUI_Eob::getTextInput(char *dest, int x, int y, int destMaxLen, int textColor1, int textColor2, int cursorColor) { +int GUI_EoB::getTextInput(char *dest, int x, int y, int destMaxLen, int textColor1, int textColor2, int cursorColor) { uint8 cursorState = 1; char sufx[] = " "; @@ -2495,14 +2495,14 @@ 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::createScreenThumbnail(Graphics::Surface &dst) { +void GUI_EoB::createScreenThumbnail(Graphics::Surface &dst) { uint8 *screenPal = new uint8[768]; _screen->getRealPalette(0, screenPal); ::createThumbnail(&dst, _screen->getCPagePtr(7), Screen::SCREEN_W, Screen::SCREEN_H, screenPal); delete[] screenPal; } -void GUI_Eob::simpleMenu_initMenuItemsMask(int menuId, int maxItem, int32 menuItemsMask, int itemOffset) { +void GUI_EoB::simpleMenu_initMenuItemsMask(int menuId, int maxItem, int32 menuItemsMask, int itemOffset) { if (menuItemsMask == -1) { _menuNumItems = _screen->getScreenDim(19 + menuId)->h; _menuCur = _screen->getScreenDim(19 + menuId)->unk8; @@ -2519,7 +2519,7 @@ void GUI_Eob::simpleMenu_initMenuItemsMask(int menuId, int maxItem, int32 menuIt _menuCur = 0; } -bool GUI_Eob::runSaveMenu(int x, int y) { +bool GUI_EoB::runSaveMenu(int x, int y) { const ScreenDim *dm = _screen->getScreenDim(11); int xo = dm->sx; int yo = dm->sy; @@ -2574,7 +2574,7 @@ bool GUI_Eob::runSaveMenu(int x, int y) { return result; } -int GUI_Eob::selectSaveSlotDialogue(int x, int y, int id) { +int GUI_EoB::selectSaveSlotDialogue(int x, int y, int id) { assert (id < 2); _saveSlotX = _saveSlotY = 0; @@ -2685,7 +2685,7 @@ int GUI_Eob::selectSaveSlotDialogue(int x, int y, int id) { return newHighlight; } -void GUI_Eob::runMemorizePrayMenu(int charIndex, int spellType) { +void GUI_EoB::runMemorizePrayMenu(int charIndex, int spellType) { if (charIndex == -1) return; @@ -2695,7 +2695,7 @@ void GUI_Eob::runMemorizePrayMenu(int charIndex, int spellType) { int li = 0; int lv = 0; - EobCharacter *c = &_vm->_characters[charIndex]; + EoBCharacter *c = &_vm->_characters[charIndex]; int8 wm = c->wisdomCur - 12; if (wm < 0) wm = 0; @@ -2963,7 +2963,7 @@ void GUI_Eob::runMemorizePrayMenu(int charIndex, int spellType) { } -void GUI_Eob::scribeScrollDialogue() { +void GUI_EoB::scribeScrollDialogue() { int16 *scrollInvSlot = new int16[32]; int16 *scrollCharacter = new int16[32]; int16 *menuItems = new int16[6]; @@ -2984,7 +2984,7 @@ void GUI_Eob::scribeScrollDialogue() { int csel = selectCharacterDialogue(49); if (csel != -1) { - EobCharacter *c = &_vm->_characters[csel]; + EoBCharacter *c = &_vm->_characters[csel]; int s = 0; for (int i = 0; i < 32 && s < 6; i++) { @@ -3085,7 +3085,7 @@ void GUI_Eob::scribeScrollDialogue() { delete[] scrollInvSlot; } -bool GUI_Eob::restParty() { +bool GUI_EoB::restParty() { static const int8 eob1healSpells[] = { 2, 15, 20, 24 }; static const int8 eob2healSpells[] = { 3, 16, 20, 28 }; const int8 *spells = _vm->game() == GI_EOB1 ? eob1healSpells : eob2healSpells; @@ -3366,7 +3366,7 @@ bool GUI_Eob::restParty() { return res; } -bool GUI_Eob::confirmDialogue(int id) { +bool GUI_EoB::confirmDialogue(int id) { int od = _screen->curDimIndex(); Screen::FontId of = _screen->setFont(Screen::FID_8_FNT); @@ -3428,7 +3428,7 @@ bool GUI_Eob::confirmDialogue(int id) { return result; } -void GUI_Eob::messageDialogue(int dim, int id, int buttonTextCol) { +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); @@ -3468,7 +3468,7 @@ void GUI_Eob::messageDialogue(int dim, int id, int buttonTextCol) { dm = _screen->getScreenDim(dim); } -int GUI_Eob::selectCharacterDialogue(int id) { +int GUI_EoB::selectCharacterDialogue(int id) { uint8 flags = (id == 26) ? (_vm->game() == GI_EOB1 ? 0x04 : 0x14) : 0x02; _vm->removeInputTop(); @@ -3619,7 +3619,7 @@ int GUI_Eob::selectCharacterDialogue(int id) { return result; } -void GUI_Eob::displayTextBox(int id) { +void GUI_EoB::displayTextBox(int id) { int op = _screen->setCurPage(2); int od = _screen->curDimIndex(); Screen::FontId of = _screen->setFont(Screen::FID_8_FNT); @@ -3644,10 +3644,10 @@ void GUI_Eob::displayTextBox(int id) { _screen->setScreenDim(od); } -Button *GUI_Eob::initMenu(int id) { +Button *GUI_EoB::initMenu(int id) { _screen->setCurPage(2); - EobMenuDef *m = &_vm->_menuDefs[id]; + EoBMenuDef *m = &_vm->_menuDefs[id]; if (m->dim) { const ScreenDim *dm = _screen->getScreenDim(m->dim); @@ -3660,7 +3660,7 @@ Button *GUI_Eob::initMenu(int id) { Button *buttons = 0; for (int i = 0; i < m->numButtons; i++) { - const EobMenuButtonDef *df = &_vm->_menuButtonDefs[m->firstButtonStrId + i]; + const EoBMenuButtonDef *df = &_vm->_menuButtonDefs[m->firstButtonStrId + i]; Button *b = new Button; b->index = m->firstButtonStrId + i + 1; if (id == 4 && _vm->game() == GI_EOB1) @@ -3691,11 +3691,11 @@ Button *GUI_Eob::initMenu(int id) { return buttons; } -void GUI_Eob::drawMenuButton(Button *b, bool clicked, bool highlight, bool noFill) { +void GUI_EoB::drawMenuButton(Button *b, bool clicked, bool highlight, bool noFill) { if (!b) return; - EobMenuButtonDef *d = (EobMenuButtonDef*)b->extButtonDef; + EoBMenuButtonDef *d = (EoBMenuButtonDef*)b->extButtonDef; if (d->flags & 1) drawMenuButtonBox(b->x, b->y, b->width, b->height, clicked, noFill); @@ -3718,7 +3718,7 @@ void GUI_Eob::drawMenuButton(Button *b, bool clicked, bool highlight, bool noFil } } -void GUI_Eob::drawMenuButtonBox(int x, int y, int w, int h, bool clicked, bool noFill) { +void GUI_EoB::drawMenuButtonBox(int x, int y, int w, int h, bool clicked, bool noFill) { uint8 col1 = _vm->_color1_1; uint8 col2 = _vm->_color2_1; @@ -3729,7 +3729,7 @@ 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::drawTextBox(int dim, int id) { +void GUI_EoB::drawTextBox(int dim, int id) { int od = _screen->curDimIndex(); _screen->setScreenDim(dim); const ScreenDim *dm = _screen->getScreenDim(dim); @@ -3750,7 +3750,7 @@ void GUI_Eob::drawTextBox(int dim, int id) { _screen->setFont(of); } -void GUI_Eob::drawSaveSlotButton(int slot, int redrawBox, int textCol) { +void GUI_EoB::drawSaveSlotButton(int slot, int redrawBox, int textCol) { if (slot < 0) return; @@ -3771,7 +3771,7 @@ void GUI_Eob::drawSaveSlotButton(int slot, int redrawBox, int textCol) { _screen->printShadedText(s, x + 4, y + 3, textCol, 0); } -void GUI_Eob::memorizePrayMenuPrintString(int spellId, int bookPageIndex, int spellType, bool noFill, bool highLight) { +void GUI_EoB::memorizePrayMenuPrintString(int spellId, int bookPageIndex, int spellType, bool noFill, bool highLight) { if (bookPageIndex < 0) return; @@ -3789,7 +3789,7 @@ void GUI_Eob::memorizePrayMenuPrintString(int spellId, int bookPageIndex, int sp } } -void GUI_Eob::updateOptionsStrings() { +void GUI_EoB::updateOptionsStrings() { for (int i = 0; i < 4; i++) { delete[] _menuStringsPrefsTemp[i]; _menuStringsPrefsTemp[i] = new char[strlen(_vm->_menuStringsPrefs[i]) + 8]; @@ -3801,7 +3801,7 @@ void GUI_Eob::updateOptionsStrings() { Common::strlcpy(_menuStringsPrefsTemp[3], Common::String::format(_vm->_menuStringsPrefs[3], _vm->_menuStringsOnOff[_vm->_configMouse ? 0 : 1]).c_str(), strlen(_vm->_menuStringsPrefs[3]) + 8); } -const char *GUI_Eob::getMenuString(int id) { +const char *GUI_EoB::getMenuString(int id) { static const char empty[] = ""; if (id >= 69) @@ -3849,7 +3849,7 @@ const char *GUI_Eob::getMenuString(int id) { return empty; } -Button *GUI_Eob::linkButton(Button *list, Button *newbt) { +Button *GUI_EoB::linkButton(Button *list, Button *newbt) { if (!list) { list = newbt; return list; @@ -3867,7 +3867,7 @@ Button *GUI_Eob::linkButton(Button *list, Button *newbt) { return resList; } -void GUI_Eob::releaseButtons(Button *list) { +void GUI_EoB::releaseButtons(Button *list) { while (list) { Button *n = list->nextButton; delete list; @@ -3876,7 +3876,7 @@ void GUI_Eob::releaseButtons(Button *list) { _vm->gui_notifyButtonListChanged(); } -void GUI_Eob::setupSaveMenuSlots() { +void GUI_EoB::setupSaveMenuSlots() { for (int i = 0; i < 6; ++i) { if (_savegameOffset + i < _savegameListSize) { if (_savegameList[i + _savegameOffset]) { @@ -3890,7 +3890,7 @@ void GUI_Eob::setupSaveMenuSlots() { } } -int GUI_Eob::getHighlightSlot() { +int GUI_EoB::getHighlightSlot() { int res = -1; Common::Point p = _vm->getMousePos(); @@ -3908,11 +3908,11 @@ int GUI_Eob::getHighlightSlot() { return res; } -void GUI_Eob::sortSaveSlots() { +void GUI_EoB::sortSaveSlots() { Common::sort(_saveSlots.begin(), _saveSlots.end(), Common::Less()); } -void GUI_Eob::restParty_updateRestTime(int hours, bool init) { +void GUI_EoB::restParty_updateRestTime(int hours, bool init) { Screen::FontId of = _screen->setFont(Screen::FID_8_FNT); int od = _screen->curDimIndex(); _screen->setScreenDim(10); @@ -3937,7 +3937,7 @@ void GUI_Eob::restParty_updateRestTime(int hours, bool init) { _screen->setFont(of); } -const EobRect16 GUI_Eob::_updateBoxFrameHighLights[] = { +const EoBRect16 GUI_EoB::_updateBoxFrameHighLights[] = { { 0x00B7, 0x0001, 0x00F7, 0x0034 }, { 0x00FF, 0x0001, 0x013F, 0x0034 }, { 0x00B7, 0x0035, 0x00F7, 0x0068 }, -- cgit v1.2.3 From 692f9ee6d524752bf1b1d169f81f68309901187a Mon Sep 17 00:00:00 2001 From: athrxx Date: Mon, 12 Dec 2011 19:05:29 +0100 Subject: KYRA: whitespace cleanup --- engines/kyra/gui_eob.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'engines/kyra/gui_eob.cpp') diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index 76b4b35b08..1930ab1e59 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -3632,7 +3632,7 @@ void GUI_EoB::displayTextBox(int id) { _screen->updateScreen(); for (uint32 timeOut = _vm->_system->getMillis() + 1440; _vm->_system->getMillis() < timeOut && !_vm->shouldQuit(); ) { - int in = _vm->checkInput(0, false, 0); + int in = _vm->checkInput(0, false, 0); _vm->removeInputTop(); if (in && !(in & 0x800)) break; @@ -3963,4 +3963,3 @@ const EoBRect16 GUI_EoB::_updateBoxFrameHighLights[] = { } // End of namespace Kyra #endif // ENABLE_EOB - -- cgit v1.2.3 From c0e782fd0b2ba9de69563e8bcb4fb43e2f311b35 Mon Sep 17 00:00:00 2001 From: athrxx Date: Tue, 13 Dec 2011 22:04:06 +0100 Subject: KYRA: (EOB) - Start implementing EOB1 party transfer (not working yet) (ScummVM specific solution which allows the selection of save files of all configured EOB1 targets) --- engines/kyra/gui_eob.cpp | 76 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 70 insertions(+), 6 deletions(-) (limited to 'engines/kyra/gui_eob.cpp') diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index 1930ab1e59..ab92e08046 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -2220,6 +2220,7 @@ bool GUI_EoB::runLoadMenu(int x, int y) { _screen->modifyScreenDim(11, dm->sx + (x >> 3), dm->sy + y, dm->w, dm->h); for (bool runLoop = true; runLoop && !_vm->shouldQuit(); ) { + updateSaveSlotsList(_vm->_targetName); int slot = selectSaveSlotDialogue(x, y, 1); if (slot > 5) { runLoop = result = false; @@ -2495,6 +2496,66 @@ int GUI_EoB::getTextInput(char *dest, int x, int y, int destMaxLen, int textColo return _keyPressed.keycode == Common::KEYCODE_ESCAPE ? -1 : len; } +Common::String GUI_EoB::transferTargetMenu(Common::Array &targets) { + _savegameListSize = targets.size(); + if (_savegameList) { + for (int i = 0; i < _savegameListSize; i++) + delete[] _savegameList[i]; + delete[] _savegameList; + } + _savegameList = new char*[_savegameListSize]; + memset(_savegameList, 0, _savegameListSize * sizeof(char*)); + + Common::StringArray::iterator ii = targets.begin(); + for (int i = 0; i < _savegameListSize; ++i) { + _savegameList[i] = new char[(*ii).size() + 1]; + strcpy(_savegameList[i], (*ii++).c_str()); + } + + const ScreenDim *dm = _screen->getScreenDim(11); + int xo = dm->sx; + int yo = dm->sy; + _screen->modifyScreenDim(11, dm->sx + 9, dm->sy + 14, dm->w, dm->h); + + int slot = 0; + do { + slot = selectSaveSlotDialogue(72, 14, 2); + if (slot == 6) + break; + } while (_saveSlotIdTemp[slot] == -1); + + _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]; +} + +Common::String GUI_EoB::transferFileMenu(Common::String &target) { + updateSaveSlotsList(target, true); + _saveSlotsListUpdateNeeded = true; + + const ScreenDim *dm = _screen->getScreenDim(11); + int xo = dm->sx; + int yo = dm->sy; + _screen->modifyScreenDim(11, dm->sx + 9, dm->sy + 14, dm->w, dm->h); + + 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]); + } + } + } while (_saveSlotIdTemp[slot] == -1); + + _screen->modifyScreenDim(11, xo, yo, dm->w, dm->h); + return _vm->_saveLoadStrings[1]; +} + void GUI_EoB::createScreenThumbnail(Graphics::Surface &dst) { uint8 *screenPal = new uint8[768]; _screen->getRealPalette(0, screenPal); @@ -2528,6 +2589,7 @@ bool GUI_EoB::runSaveMenu(int x, int y) { _screen->modifyScreenDim(11, dm->sx + (x >> 3), dm->sy + y, dm->w, dm->h); for (bool runLoop = true; runLoop && !_vm->shouldQuit(); ) { + updateSaveSlotsList(_vm->_targetName); int slot = selectSaveSlotDialogue(x, y, 0); if (slot > 5) { runLoop = result = false; @@ -2575,16 +2637,14 @@ bool GUI_EoB::runSaveMenu(int x, int y) { } int GUI_EoB::selectSaveSlotDialogue(int x, int y, int id) { - assert (id < 2); - _saveSlotX = _saveSlotY = 0; _screen->setCurPage(2); - updateSaveSlotsList(); _savegameOffset = 0; drawMenuButtonBox(0, 0, 176, 144, false, false); - _screen->printShadedText(_vm->_saveLoadStrings[2 + id], 52, 5, 15, 0); + const char *title = (id < 2) ? _vm->_saveLoadStrings[2 + id] : _vm->_transferStringsScummVM[id - 1]; + _screen->printShadedText(title, 52, 5, 15, 0); _screen->copyRegion(0, 0, x, y, 176, 144, 2, 0, Screen::CR_NO_P_CHECK); _screen->setCurPage(0); @@ -3806,8 +3866,10 @@ const char *GUI_EoB::getMenuString(int id) { if (id >= 69) return _vm->_menuStringsTransfer[id - 69]; - else if (id >= 67) - return _vm->_menuStringsDefeat[id - 67]; + else if (id == 68) + return _vm->_transferStringsScummVM[0]; + else if (id == 67) + return _vm->_menuStringsDefeat[0]; else if (id == 66) return _vm->_errorSlotEmptyString; else if (id == 65) @@ -3846,6 +3908,8 @@ const char *GUI_EoB::getMenuString(int id) { return _vm->_menuStringsSaveLoad[id - 9]; else if (id >= 1) return _vm->_menuStringsMain[id - 1]; + else if (id < 0) + return _vm->_transferStringsScummVM[-id]; return empty; } -- cgit v1.2.3 From d807b3d42b4a49dfe8262f496f9b341aef3c8bdd Mon Sep 17 00:00:00 2001 From: athrxx Date: Sat, 17 Dec 2011 22:55:19 +0100 Subject: KYRA: (EOB) - implement EOB1 party transfer --- engines/kyra/gui_eob.cpp | 104 ++++++++++++++++++++++++++--------------------- 1 file changed, 57 insertions(+), 47 deletions(-) (limited to 'engines/kyra/gui_eob.cpp') 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 &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(); -- cgit v1.2.3 From a95f34bc64ada8f1d35466a0e4cb10c96ba95580 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 27 Dec 2011 02:02:19 +0100 Subject: KYRA: Some formatting fixes. --- engines/kyra/gui_eob.cpp | 264 +++++++++++++++++++++++------------------------ 1 file changed, 132 insertions(+), 132 deletions(-) (limited to 'engines/kyra/gui_eob.cpp') diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index 080af941df..51a9e52266 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -300,26 +300,26 @@ void EoBCoreEngine::gui_drawWeaponSlotStatus(int x, int y, int status) { gui_drawBox(x, y, 31, 16, _color9, _color10, _color11); switch (status + 5) { - case 0: - tmpStr = _characterGuiStringsWp[2]; - break; - case 1: - tmpStr = _characterGuiStringsWr[2]; - tmpStr2 = _characterGuiStringsWr[3]; - break; - case 2: - tmpStr = _characterGuiStringsWr[0]; - tmpStr2 = _characterGuiStringsWr[1]; - break; - case 3: - tmpStr = _characterGuiStringsWp[1]; - break; - case 4: - tmpStr = _characterGuiStringsWp[0]; - break; - default: - tmpStr = Common::String::format("%d", status); - break; + case 0: + tmpStr = _characterGuiStringsWp[2]; + break; + case 1: + tmpStr = _characterGuiStringsWr[2]; + tmpStr2 = _characterGuiStringsWr[3]; + break; + case 2: + tmpStr = _characterGuiStringsWr[0]; + tmpStr2 = _characterGuiStringsWr[1]; + break; + case 3: + tmpStr = _characterGuiStringsWp[1]; + break; + case 4: + tmpStr = _characterGuiStringsWp[0]; + break; + default: + tmpStr = Common::String::format("%d", status); + break; } if (!tmpStr2.empty()) { @@ -433,8 +433,8 @@ void EoBCoreEngine::gui_drawCharPortraitStatusFrame(int index) { return; } - int iX= x; - int iY= y; + int iX = x; + int iY = y; for (int i = 0; i < 64; i += 16) { x = iX + i; @@ -790,11 +790,11 @@ int EoBCoreEngine::clickedSceneDropPickupItem(Button *button) { int d = _dropItemDirIndex[(_currentDirection << 2) + button->arg]; if (_itemInHand) { - setItemPosition((Item*)&_levelBlockProperties[block & 0x3ff].drawObjects, block, _itemInHand, d); + setItemPosition((Item *)&_levelBlockProperties[block & 0x3ff].drawObjects, block, _itemInHand, d); setHandItem(0); runLevelScript(block, 4); } else { - d = getQueuedItem((Item*)&_levelBlockProperties[block].drawObjects, d, -1); + d = getQueuedItem((Item *)&_levelBlockProperties[block].drawObjects, d, -1); if (!d) return 1; setHandItem(d); @@ -975,7 +975,7 @@ int EoBCoreEngine::clickedSpellbookList(Button *button) { if (listIndex == 7 || _openBookAvailableSpells[_openBookSpellLevel * 10 + _openBookSpellListOffset + listIndex] > 0) { if (listIndex < 6) { if (_openBookSpellListOffset + listIndex < 9) - _openBookSpellSelectedItem= listIndex; + _openBookSpellSelectedItem = listIndex; else if (listIndex != 7) return button->index; } else if (listIndex != 7) { @@ -994,7 +994,7 @@ int EoBCoreEngine::clickedSpellbookList(Button *button) { castSpell(s, 0); - } else if ((_openBookSpellSelectedItem == 6 && listIndex == 7) || (_openBookSpellSelectedItem != 6 && listIndex == 6) ) { + } else if ((_openBookSpellSelectedItem == 6 && listIndex == 7) || (_openBookSpellSelectedItem != 6 && listIndex == 6)) { Button b; clickedSpellbookAbort(&b); } @@ -1223,81 +1223,81 @@ void EoBCoreEngine::gui_processWeaponSlotClickRight(int charIndex, int slotIndex uint8 ep = _itemTypes[tp].extraProperties & 0x7f; switch (ep) { - case 0: - case 16: - // Item automatically used when worn - _txt->printMessage(_itemMisuseStrings[1]); - break; - - case 1: - case 2: - case 3: - // Weapons - if (!_currentControlMode) - useSlotWeapon(charIndex, slotIndex, itm); - break; - - case 4: - case 8: - case 12: - case 13: - case 15: - // Item not used that way - _txt->printMessage(_itemMisuseStrings[2]); - break; - - case 5: - case 6: - // Cleric holy symbol / mage spell book - if (!_currentControlMode) - useMagicBookOrSymbol(charIndex, ep == 6 ? 1 : 0); - break; - - case 7: - // Food ration - // Don't do anything if mouse control is enabled (we don't support anything else) - // eatItemInHand(charIndex); - break; - - case 10: - if (_flags.gameID == GI_EOB1) - vl += _clericSpellOffset; - // drop through - case 9: - // Mage/Cleric Scroll - if (!_currentControlMode) - useMagicScroll(charIndex, vl, wslot); - break; - - case 11: - // Letters, Notes, Maps - displayParchment(vl); - break; - - case 14: - // Potion - usePotion(charIndex, wslot); - break; - - case 18: - useWand(charIndex, wslot); - break; - - case 19: - // eob2 horn - useHorn(charIndex, wslot); - break; - - case 20: - if (vl == 1) - inflictCharacterDamage(charIndex, 200); - else - useMagicScroll(charIndex, 55, wslot); - deleteInventoryItem(charIndex, wslot); - break; + case 0: + case 16: + // Item automatically used when worn + _txt->printMessage(_itemMisuseStrings[1]); + break; + + case 1: + case 2: + case 3: + // Weapons + if (!_currentControlMode) + useSlotWeapon(charIndex, slotIndex, itm); + break; + + case 4: + case 8: + case 12: + case 13: + case 15: + // Item not used that way + _txt->printMessage(_itemMisuseStrings[2]); + break; + + case 5: + case 6: + // Cleric holy symbol / mage spell book + if (!_currentControlMode) + useMagicBookOrSymbol(charIndex, ep == 6 ? 1 : 0); + break; + + case 7: + // Food ration + // Don't do anything if mouse control is enabled (we don't support anything else) + // eatItemInHand(charIndex); + break; + + case 10: + if (_flags.gameID == GI_EOB1) + vl += _clericSpellOffset; + // drop through + case 9: + // Mage/Cleric Scroll + if (!_currentControlMode) + useMagicScroll(charIndex, vl, wslot); + break; + + case 11: + // Letters, Notes, Maps + displayParchment(vl); + break; + + case 14: + // Potion + usePotion(charIndex, wslot); + break; + + case 18: + useWand(charIndex, wslot); + break; + + case 19: + // eob2 horn + useHorn(charIndex, wslot); + break; + + case 20: + if (vl == 1) + inflictCharacterDamage(charIndex, 200); + else + useMagicScroll(charIndex, 55, wslot); + deleteInventoryItem(charIndex, wslot); + break; - default: - break; + default: + break; } if (_flags.gameID == GI_EOB1 || (ep == 1 && charIndex >= 2)) @@ -1336,7 +1336,7 @@ void EoBCoreEngine::gui_processInventorySlotClick(int slot) { GUI_EoB::GUI_EoB(EoBCoreEngine *vm) : GUI(vm), _vm(vm), _screen(vm->_screen) { _menuStringsPrefsTemp = new char*[4]; - memset(_menuStringsPrefsTemp, 0, 4 * sizeof(char*)); + memset(_menuStringsPrefsTemp, 0, 4 * sizeof(char *)); _saveSlotStringsTemp = new char*[6]; for (int i = 0; i < 6; i++) { @@ -1429,7 +1429,7 @@ void GUI_EoB::processButton(Button *button) { _screen->drawShape(_screen->_curPage, button->data1ShapePtr, fx, fy, sd); } else if (button->data0Val1 == 2) { if (!(button->flags2 & 4)) - _screen->printText((const char*) button->data1ShapePtr, sx, sy, col1, col2); + _screen->printText((const char *)button->data1ShapePtr, sx, sy, col1, col2); } else if (button->data0Val1 == 3) { // nullsub (at least EOBII) } else if (button->data0Val1 == 4) { @@ -1453,9 +1453,9 @@ void GUI_EoB::processButton(Button *button) { _screen->drawShape(_screen->_curPage, button->data2ShapePtr, fx, fy, sd); } else if (button->data0Val1 == 2) { if (button->flags2 & 1) - _screen->printText((const char*) button->data2ShapePtr, sx, sy, button->data3Val2, button->data3Val3); + _screen->printText((const char *)button->data2ShapePtr, sx, sy, button->data3Val2, button->data3Val3); else - _screen->printText((const char*) button->data2ShapePtr, sx, sy, button->data2Val2, button->data2Val3); + _screen->printText((const char *)button->data2ShapePtr, sx, sy, button->data2Val2, button->data2Val3); } else if (button->data0Val1 == 3) { // nullsub (at least EOBII) } else if (button->data0Val1 == 4) { @@ -1476,7 +1476,7 @@ void GUI_EoB::processButton(Button *button) { if (button->data0Val1 == 1) { _screen->drawShape(_screen->_curPage, button->data0ShapePtr, fx, fy, sd); } else if (button->data0Val1 == 2) { - _screen->printText((const char*) button->data0ShapePtr, sx, sy, button->data0Val2, button->data0Val3); + _screen->printText((const char *)button->data0ShapePtr, sx, sy, button->data0Val2, button->data0Val3); } else if (button->data0Val1 == 3) { // nullsub (at least EOBII) } else if (button->data0Val1 == 4) { @@ -1486,7 +1486,7 @@ void GUI_EoB::processButton(Button *button) { _screen->drawBox(sx, sy, fx2, fy2, button->data0Val2); } else { if (!button->data0Val1) { - if(button->data1Val1 == 2 || button->data2Val1 == 2) { + if (button->data1Val1 == 2 || button->data2Val1 == 2) { _screen->drawBox(sx, sy, fx2, fy2, button->data0Val2); } else { // nullsub (at least EOBII) @@ -1542,7 +1542,7 @@ int GUI_EoB::processButtonList(Kyra::Button *buttonList, uint16 inputFlags, int8 // UNUSED //if (buttonList->flags2 & 0x20) { - // if (_processButtonListExtraCallback) + //if (_processButtonListExtraCallback) // this->*_processButtonListExtraCallback(buttonList); //} @@ -2001,7 +2001,7 @@ void GUI_EoB::runCampMenu() { _needRest = false; Button *buttonList = 0; - for (bool runLoop = true; runLoop && !_vm->shouldQuit(); ) { + for (bool runLoop = true; runLoop && !_vm->shouldQuit();) { if (newMenu == 2) updateOptionsStrings(); @@ -2067,7 +2067,7 @@ void GUI_EoB::runCampMenu() { if (_vm->_menuButtonDefs[s - 1].flags & 2) break; s += dir; - } while(!_vm->shouldQuit()); + } while (!_vm->shouldQuit()); highlightButton = _vm->gui_getButton(buttonList, s); } @@ -2219,7 +2219,7 @@ bool GUI_EoB::runLoadMenu(int x, int y) { _screen->modifyScreenDim(11, dm->sx + (x >> 3), dm->sy + y, dm->w, dm->h); - for (bool runLoop = true; runLoop && !_vm->shouldQuit(); ) { + for (bool runLoop = true; runLoop && !_vm->shouldQuit();) { updateSaveSlotsList(_vm->_targetName); int slot = selectSaveSlotDialogue(x, y, 1); if (slot > 5) { @@ -2257,7 +2257,7 @@ bool GUI_EoB::confirmDialogue2(int dim, int id, int deflt) { for (int i = 0; i < 2; i++) drawMenuButtonBox(x[i], y, 32, 14, false, false); - for (bool runLoop = true; runLoop && !_vm->shouldQuit(); ) { + for (bool runLoop = true; runLoop && !_vm->shouldQuit();) { Common::Point p = _vm->getMousePos(); if (_vm->posWithinRect(p.x, p.y, x[0], y, x[0] + 32, y + 14)) newHighlight = 0; @@ -2324,7 +2324,7 @@ void GUI_EoB::messageDialogue(int dim, int id, int buttonTextCol) { _screen->printShadedText(_vm->_menuOkString, bx + 4, by + 3, buttonTextCol, 0); _screen->updateScreen(); - for (bool runLoop = true; runLoop && !_vm->shouldQuit(); ) { + for (bool runLoop = true; runLoop && !_vm->shouldQuit();) { int inputFlag = _vm->checkInput(0, false, 0) & 0x8ff; _vm->removeInputTop(); @@ -2365,7 +2365,7 @@ void GUI_EoB::messageDialogue2(int dim, int id, int buttonTextCol) { _screen->printShadedText(_vm->_menuOkString, x + 4, y + 3, buttonTextCol, 0); _screen->updateScreen(); - for (bool runLoop = true; runLoop && !_vm->shouldQuit(); ) { + for (bool runLoop = true; runLoop && !_vm->shouldQuit();) { int inputFlag = _vm->checkInput(0, false, 0) & 0x8ff; _vm->removeInputTop(); @@ -2492,7 +2492,7 @@ int GUI_EoB::getTextInput(char *dest, int x, int y, int destMaxLen, int textColo } else if (in > 31 && in < 126) { if (!(in == 32 && pos == 0)) { if (in >= 97 && in <= 122) - in -=32; + in -= 32; if (pos < len) { for (int i = destMaxLen - 1; i >= pos; i--) @@ -2553,7 +2553,7 @@ Common::String GUI_EoB::transferTargetMenu(Common::Array &target delete[] _savegameList; } _savegameList = new char*[_savegameListSize]; - memset(_savegameList, 0, _savegameListSize * sizeof(char*)); + memset(_savegameList, 0, _savegameListSize * sizeof(char *)); Common::StringArray::iterator ii = targets.begin(); for (int i = 0; i < _savegameListSize; ++i) { @@ -2593,7 +2593,7 @@ Common::String GUI_EoB::transferFileMenu(Common::String &target) { slot = selectSaveSlotDialogue(72, 14, 4); if (slot == 6) break; - + if (_saveSlotIdTemp[slot] == -1) messageDialogue(11, 65, 6); else { @@ -2638,7 +2638,7 @@ bool GUI_EoB::runSaveMenu(int x, int y) { _screen->modifyScreenDim(11, dm->sx + (x >> 3), dm->sy + y, dm->w, dm->h); - for (bool runLoop = true; runLoop && !_vm->shouldQuit(); ) { + for (bool runLoop = true; runLoop && !_vm->shouldQuit();) { updateSaveSlotsList(_vm->_targetName); int slot = selectSaveSlotDialogue(x, y, 0); if (slot > 5) { @@ -2656,7 +2656,7 @@ bool GUI_EoB::runSaveMenu(int x, int y) { int fx = (x + 1) << 3; int fy = y + slot * 17 + 23; - for (int in = -1; in == -1 && !_vm->shouldQuit(); ) { + for (int in = -1; in == -1 && !_vm->shouldQuit();) { _screen->fillRect(fx - 2, fy, fx + 160, fy + 8, _vm->_bkgColor_1); in = getTextInput(_saveSlotStringsTemp[slot], x + 1, fy, 19, 2, 0, 8); if (!strlen(_saveSlotStringsTemp[slot])) { @@ -2707,7 +2707,7 @@ int GUI_EoB::selectSaveSlotDialogue(int x, int y, int id) { int newHighlight = 0; int slot = -1; - for (bool runLoop = true; runLoop && !_vm->shouldQuit(); ) { + for (bool runLoop = true; runLoop && !_vm->shouldQuit();) { int inputFlag = _vm->checkInput(0, false, 0) & 0x8ff; _vm->removeInputTop(); @@ -2904,7 +2904,7 @@ void GUI_EoB::runMemorizePrayMenu(int charIndex, int spellType) { bool updateDesc = true; bool updateList = true; - for (bool runLoop = true; runLoop && !_vm->shouldQuit(); ) { + for (bool runLoop = true; runLoop && !_vm->shouldQuit();) { updateBoxFrameHighLight(charIndex); if (newHighLightButton < 0) @@ -2964,7 +2964,7 @@ void GUI_EoB::runMemorizePrayMenu(int charIndex, int spellType) { } else { Common::Point p = _vm->getMousePos(); if (_vm->posWithinRect(p.x, p.y, 8, 50, 168, 122)) { - newHighLightText = (p.y - 50 ) / 9; + newHighLightText = (p.y - 50) / 9; if (menuSpellMap[lastHighLightButton * 11] - 1 < newHighLightText) newHighLightText = menuSpellMap[lastHighLightButton * 11] - 1; } @@ -3257,7 +3257,7 @@ bool GUI_EoB::restParty() { restParty_updateRestTime(hours, true); - for (int l = 0; !res && restLoop && !_vm->shouldQuit(); ) { + for (int l = 0; !res && restLoop && !_vm->shouldQuit();) { l++; // Regenerate spells @@ -3321,7 +3321,7 @@ bool GUI_EoB::restParty() { list = 0; if (crs[i] >= 48) { for (int ii = 0; !list && ii < 3; ii++) - list = (int8*)memchr(_vm->_characters[i].clericSpells, -spells[ii], 80); + list = (int8 *)memchr(_vm->_characters[i].clericSpells, -spells[ii], 80); } if (list) @@ -3380,15 +3380,15 @@ bool GUI_EoB::restParty() { for (int i = 0; i < 6; i++) { // Add Lay On Hands spell if (_vm->_characters[i].cClass == 2) { - list = (int8*)memchr(_vm->_characters[i].clericSpells, spells[3], 10); + list = (int8 *)memchr(_vm->_characters[i].clericSpells, spells[3], 10); if (list) { *list = spells[3]; } else { - list = (int8*)memchr(_vm->_characters[i].clericSpells, -spells[3], 10); + list = (int8 *)memchr(_vm->_characters[i].clericSpells, -spells[3], 10); if (list) { *list = spells[3]; } else if (!memchr(_vm->_characters[i].clericSpells, spells[3], 10)) { - list = (int8*)memchr(_vm->_characters[i].clericSpells, 0, 10); + list = (int8 *)memchr(_vm->_characters[i].clericSpells, 0, 10); *list = spells[3]; } } @@ -3488,7 +3488,7 @@ bool GUI_EoB::confirmDialogue(int id) { int lastHighlight = -1; bool result = false; - for (bool runLoop = true; runLoop && !_vm->shouldQuit(); ) { + for (bool runLoop = true; runLoop && !_vm->shouldQuit();) { if (newHighlight != lastHighlight) { if (lastHighlight != -1) drawMenuButton(_vm->gui_getButton(buttonList, lastHighlight + 33), false, false, true); @@ -3701,7 +3701,7 @@ void GUI_EoB::displayTextBox(int id) { _screen->copyRegion(dm->sx << 3, dm->sy, dm->sx << 3, dm->sy, dm->w << 3, dm->h, 2, 0, Screen::CR_NO_P_CHECK); _screen->updateScreen(); - for (uint32 timeOut = _vm->_system->getMillis() + 1440; _vm->_system->getMillis() < timeOut && !_vm->shouldQuit(); ) { + for (uint32 timeOut = _vm->_system->getMillis() + 1440; _vm->_system->getMillis() < timeOut && !_vm->shouldQuit();) { int in = _vm->checkInput(0, false, 0); _vm->removeInputTop(); if (in && !(in & 0x800)) @@ -3765,7 +3765,7 @@ void GUI_EoB::drawMenuButton(Button *b, bool clicked, bool highlight, bool noFil if (!b) return; - EoBMenuButtonDef *d = (EoBMenuButtonDef*)b->extButtonDef; + EoBMenuButtonDef *d = (EoBMenuButtonDef *)b->extButtonDef; if (d->flags & 1) drawMenuButtonBox(b->x, b->y, b->width, b->height, clicked, noFill); @@ -3827,9 +3827,9 @@ void GUI_EoB::drawSaveSlotButton(int slot, int redrawBox, int textCol) { int x = _saveSlotX + 4; int y = _saveSlotY + slot * 17 + 20; int w = 167; - const char *s = (slot < 6) ?_saveSlotStringsTemp[slot] : _vm->_saveLoadStrings[0]; + const char *s = (slot < 6) ? _saveSlotStringsTemp[slot] : _vm->_saveLoadStrings[0]; - if (slot >= 6 ) { + if (slot >= 6) { x = _saveSlotX + 118; y = _saveSlotY + 126; w = 53; @@ -4034,6 +4034,6 @@ const EoBRect16 GUI_EoB::_updateBoxFrameHighLights[] = { { 0x00A3, 0x0068, 0x00C3, 0x0089 } }; -} // End of namespace Kyra +} // End of namespace Kyra #endif // ENABLE_EOB -- cgit v1.2.3 From 37c046339dfc70f29c163457c72158e02a6c1cdb Mon Sep 17 00:00:00 2001 From: athrxx Date: Tue, 27 Dec 2011 16:42:05 +0100 Subject: KYRA: (EOB) - cleanup dialog settings a bit --- engines/kyra/gui_eob.cpp | 130 +++++++++++++++++++++++------------------------ 1 file changed, 65 insertions(+), 65 deletions(-) (limited to 'engines/kyra/gui_eob.cpp') diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index 51a9e52266..1ccb60ada1 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -100,9 +100,9 @@ void EoBCoreEngine::gui_drawCharPortraitWithStats(int index) { int cp = _screen->setCurPage(2); if (index == _exchangeCharacterId) - _screen->printText(_characterGuiStringsSt[0], x2 + 2, y2 + 2, 8, _bkgColor_1); + _screen->printText(_characterGuiStringsSt[0], x2 + 2, y2 + 2, 8, guiSettings()->colors.fill); else - _screen->printText(c->name, x2 + 2, y2 + 2, txtCol1, _bkgColor_1); + _screen->printText(c->name, x2 + 2, y2 + 2, txtCol1, guiSettings()->colors.fill); gui_drawFaceShape(index); gui_drawWeaponSlot(index, 0); @@ -129,23 +129,23 @@ void EoBCoreEngine::gui_drawCharPortraitWithStats(int index) { _screen->copyRegion(176, 0, 0, 0, 144, 168, 2, 2, Screen::CR_NO_P_CHECK); _screen->_curPage = 2; gui_drawFaceShape(index); - _screen->printShadedText(c->name, 219, 6, txtCol2, _bkgColor_1); + _screen->printShadedText(c->name, 219, 6, txtCol2, guiSettings()->colors.fill); gui_drawHitpoints(index); gui_drawFoodStatusGraph(index); if (_currentControlMode == 1) { if (c->hitPointsCur == -10) - _screen->printShadedText(_characterGuiStringsSt[1], 247, 158, 6, _color6); + _screen->printShadedText(_characterGuiStringsSt[1], 247, 158, 6, guiSettings()->colors.extraFill); else if (c->hitPointsCur < 1) - _screen->printShadedText(_characterGuiStringsSt[2], 226, 158, 6, _color6); + _screen->printShadedText(_characterGuiStringsSt[2], 226, 158, 6, guiSettings()->colors.extraFill); else if (c->effectFlags & (_flags.gameID == GI_EOB1 ? 0x80 : 0x2000)) - _screen->printShadedText(_characterGuiStringsSt[3], 220, 158, 6, _color6); + _screen->printShadedText(_characterGuiStringsSt[3], 220, 158, 6, guiSettings()->colors.extraFill); else if (c->flags & 2) - _screen->printShadedText(_characterGuiStringsSt[4], 235, 158, 6, _color6); + _screen->printShadedText(_characterGuiStringsSt[4], 235, 158, 6, guiSettings()->colors.extraFill); else if (c->flags & 4) - _screen->printShadedText(_characterGuiStringsSt[5], 232, 158, 6, _color6); + _screen->printShadedText(_characterGuiStringsSt[5], 232, 158, 6, guiSettings()->colors.extraFill); else if (c->flags & 8) - _screen->printShadedText(_characterGuiStringsSt[6], 232, 158, 6, _color6); + _screen->printShadedText(_characterGuiStringsSt[6], 232, 158, 6, guiSettings()->colors.extraFill); for (int i = 0; i < 27; i++) gui_drawInventoryItem(i, 0, 2); @@ -158,38 +158,38 @@ void EoBCoreEngine::gui_drawCharPortraitWithStats(int index) { static const uint16 cm2Y2[] = { 165, 165, 147 }; for (int i = 0; i < 3; i++) - _screen->fillRect(cm2X1[i], cm2Y1[i], cm2X2[i], cm2Y2[i], _color6); + _screen->fillRect(cm2X1[i], cm2Y1[i], cm2X2[i], cm2Y2[i], guiSettings()->colors.extraFill); - _screen->printShadedText(_characterGuiStringsIn[0], 183, 42, 15, _color6); - _screen->printText(_chargenClassStrings[c->cClass], 183, 55, 12, _color6); - _screen->printText(_chargenAlignmentStrings[c->alignment], 183, 62, 12, _color6); - _screen->printText(_chargenRaceSexStrings[c->raceSex], 183, 69, 12, _color6); + _screen->printShadedText(_characterGuiStringsIn[0], 183, 42, 15, guiSettings()->colors.extraFill); + _screen->printText(_chargenClassStrings[c->cClass], 183, 55, 12, guiSettings()->colors.extraFill); + _screen->printText(_chargenAlignmentStrings[c->alignment], 183, 62, 12, guiSettings()->colors.extraFill); + _screen->printText(_chargenRaceSexStrings[c->raceSex], 183, 69, 12, guiSettings()->colors.extraFill); for (int i = 0; i < 6; i++) - _screen->printText(_chargenStatStrings[6 + i], 183, 82 + i * 7, 12, _color6); + _screen->printText(_chargenStatStrings[6 + i], 183, 82 + i * 7, 12, guiSettings()->colors.extraFill); - _screen->printText(_characterGuiStringsIn[1], 183, 124, 12, _color6); - _screen->printText(_characterGuiStringsIn[2], 239, 138, 12, _color6); - _screen->printText(_characterGuiStringsIn[3], 278, 138, 12, _color6); + _screen->printText(_characterGuiStringsIn[1], 183, 124, 12, guiSettings()->colors.extraFill); + _screen->printText(_characterGuiStringsIn[2], 239, 138, 12, guiSettings()->colors.extraFill); + _screen->printText(_characterGuiStringsIn[3], 278, 138, 12, guiSettings()->colors.extraFill); - _screen->printText(getCharStrength(c->strengthCur, c->strengthExtCur).c_str(), 275, 82, 15, _color6); - _screen->printText(Common::String::format("%d", c->intelligenceCur).c_str(), 275, 89, 15, _color6); - _screen->printText(Common::String::format("%d", c->wisdomCur).c_str(), 275, 96, 15, _color6); - _screen->printText(Common::String::format("%d", c->dexterityCur).c_str(), 275, 103, 15, _color6); - _screen->printText(Common::String::format("%d", c->constitutionCur).c_str(), 275, 110, 15, _color6); - _screen->printText(Common::String::format("%d", c->charismaCur).c_str(), 275, 117, 15, _color6); - _screen->printText(Common::String::format("%d", c->armorClass).c_str(), 275, 124, 15, _color6); + _screen->printText(getCharStrength(c->strengthCur, c->strengthExtCur).c_str(), 275, 82, 15, guiSettings()->colors.extraFill); + _screen->printText(Common::String::format("%d", c->intelligenceCur).c_str(), 275, 89, 15, guiSettings()->colors.extraFill); + _screen->printText(Common::String::format("%d", c->wisdomCur).c_str(), 275, 96, 15, guiSettings()->colors.extraFill); + _screen->printText(Common::String::format("%d", c->dexterityCur).c_str(), 275, 103, 15, guiSettings()->colors.extraFill); + _screen->printText(Common::String::format("%d", c->constitutionCur).c_str(), 275, 110, 15, guiSettings()->colors.extraFill); + _screen->printText(Common::String::format("%d", c->charismaCur).c_str(), 275, 117, 15, guiSettings()->colors.extraFill); + _screen->printText(Common::String::format("%d", c->armorClass).c_str(), 275, 124, 15, guiSettings()->colors.extraFill); for (int i = 0; i < 3; i++) { int t = getCharacterClassType(c->cClass, i); if (t == -1) continue; - _screen->printText(_chargenClassStrings[t + 15], 180, 145 + 7 * i, 12, _color6); + _screen->printText(_chargenClassStrings[t + 15], 180, 145 + 7 * i, 12, guiSettings()->colors.extraFill); Common::String tmpStr = Common::String::format("%d", c->experience[i]); - _screen->printText(tmpStr.c_str(), 251 - tmpStr.size() * 3, 145 + 7 * i, 15, _color6); + _screen->printText(tmpStr.c_str(), 251 - tmpStr.size() * 3, 145 + 7 * i, 15, guiSettings()->colors.extraFill); tmpStr = Common::String::format("%d", c->level[i]); - _screen->printText(tmpStr.c_str(), 286 - tmpStr.size() * 3, 145 + 7 * i, 15, _color6); + _screen->printText(tmpStr.c_str(), 286 - tmpStr.size() * 3, 145 + 7 * i, 15, guiSettings()->colors.extraFill); } } @@ -272,7 +272,7 @@ void EoBCoreEngine::gui_drawWeaponSlot(int charIndex, int slot) { x += 176; int itm = _characters[charIndex].inventory[slot]; - gui_drawBox(x, y, 31, 16, _color1_1, _color2_1, _bkgColor_1); + gui_drawBox(x, y, 31, 16, guiSettings()->colors.frame1, guiSettings()->colors.frame2, guiSettings()->colors.fill); if (_characters[charIndex].slotStatus[slot]) { gui_drawWeaponSlotStatus(x, y, _characters[charIndex].slotStatus[slot]); @@ -297,7 +297,7 @@ void EoBCoreEngine::gui_drawWeaponSlotStatus(int x, int y, int status) { if (status > -3 || status == -5) _screen->drawShape(_screen->_curPage, _greenSplatShape, x - 1, y, 0); else - gui_drawBox(x, y, 31, 16, _color9, _color10, _color11); + gui_drawBox(x, y, 31, 16, guiSettings()->colors.warningFrame1, guiSettings()->colors.warningFrame2, guiSettings()->colors.warningFill); switch (status + 5) { case 0: @@ -369,7 +369,7 @@ void EoBCoreEngine::gui_drawHitpoints(int index) { _screen->printText(_characterGuiStringsHp[0], x - 13, y - 1, 12, 0); - gui_drawHorizontalBarGraph(x, y, w, h, bgCur, bgMax, barColor[col], _color5); + gui_drawHorizontalBarGraph(x, y, w, h, bgCur, bgMax, barColor[col], guiSettings()->colors.barGraph); } else { Common::String tmpString = Common::String::format(_characterGuiStringsHp[1], c->hitPointsCur, c->hitPointsMax); @@ -379,7 +379,7 @@ void EoBCoreEngine::gui_drawHitpoints(int index) { y -= 1; } - _screen->printText(tmpString.c_str(), x, y, 12, _bkgColor_1); + _screen->printText(tmpString.c_str(), x, y, 12, guiSettings()->colors.fill); } } @@ -398,11 +398,11 @@ void EoBCoreEngine::gui_drawFoodStatusGraph(int index) { return; uint8 col = c->food < 20 ? 8 : (c->food < 33 ? 5 : 3); - gui_drawHorizontalBarGraph(250, 25, 51, 5, c->food, 100, col, _color5); + gui_drawHorizontalBarGraph(250, 25, 51, 5, c->food, 100, col, guiSettings()->colors.barGraph); } void EoBCoreEngine::gui_drawHorizontalBarGraph(int x, int y, int w, int h, int32 curVal, int32 maxVal, int col1, int col2) { - gui_drawBox(x - 1, y - 1, w + 3, h + 2, _color2_1, _color1_1, -1); + gui_drawBox(x - 1, y - 1, w + 3, h + 2, guiSettings()->colors.frame2, guiSettings()->colors.frame1, -1); KyraRpgEngine::gui_drawHorizontalBarGraph(x, y, w + 2, h, curVal, maxVal, col1, col2); } @@ -464,8 +464,8 @@ void EoBCoreEngine::gui_drawCharPortraitStatusFrame(int index) { } } else { - _screen->drawClippedLine(x, y, x + 62, y, _color1_1); - _screen->drawClippedLine(x, y + 49, x + 62, y + 49, _color2_1); + _screen->drawClippedLine(x, y, x + 62, y, guiSettings()->colors.frame1); + _screen->drawClippedLine(x, y + 49, x + 62, y + 49, guiSettings()->colors.frame2); _screen->drawClippedLine(x - 1, y, x - 1, y + 50, 12); _screen->drawClippedLine(x + 63, y, x + 63, y + 50, 12); } @@ -480,7 +480,7 @@ void EoBCoreEngine::gui_drawInventoryItem(int slot, int special, int pageNum) { if (special) { int wh = (slot == 25 || slot == 26) ? 10 : 18; - gui_drawBox(x - 1, y - 1, wh, wh, _color1_1, _color2_1, slot == 16 ? -1 : _bkgColor_1); + gui_drawBox(x - 1, y - 1, wh, wh, guiSettings()->colors.frame1, guiSettings()->colors.frame2, slot == 16 ? -1 : guiSettings()->colors.fill); if (slot == 16) { _screen->fillRect(227, 65, 238, 69, 12); @@ -517,7 +517,7 @@ void EoBCoreEngine::gui_drawCompass(bool force) { } void EoBCoreEngine::gui_drawDialogueBox() { - gui_drawBox(0, 121, 320, 79, _color1_1, _color2_1, _bkgColor_1); + gui_drawBox(0, 121, 320, 79, guiSettings()->colors.frame1, guiSettings()->colors.frame2, guiSettings()->colors.fill); txt()->clearCurDim(); } @@ -527,14 +527,14 @@ void EoBCoreEngine::gui_drawSpellbook() { _screen->copyRegion(64, 121, 64, 121, 112, 56, 0, 2, Screen::CR_NO_P_CHECK); for (int i = 0; i < numTab; i++) { - int col1 = _color14; - int col2 = _color13; - int col3 = _color12; + int col1 = guiSettings()->colors.inactiveTabFrame1; + int col2 = guiSettings()->colors.inactiveTabFrame2; + int col3 = guiSettings()->colors.inactiveTabFill; if (i == _openBookSpellLevel) { - col1 = _color1_1; - col2 = _color2_1; - col3 = _bkgColor_1; + col1 = guiSettings()->colors.frame1; + col2 = guiSettings()->colors.frame2; + col3 = guiSettings()->colors.fill; } if (_flags.gameID == GI_EOB1) { @@ -547,12 +547,12 @@ void EoBCoreEngine::gui_drawSpellbook() { } if (_flags.gameID == GI_EOB1) - gui_drawBox(71, 131, 105, 44, _color1_1, _color2_1, _bkgColor_1); + gui_drawBox(71, 131, 105, 44, guiSettings()->colors.frame1, guiSettings()->colors.frame2, guiSettings()->colors.fill); else { - gui_drawBox(68, 130, 108, 47, _color1_1, _color2_1, _bkgColor_1); - gui_drawBox(68, 168, 78, 9, _color8, _color7, _color6); - gui_drawBox(146, 168, 14, 9, _color8, _color7, _color6); - gui_drawBox(160, 168, 16, 9, _color8, _color7, _color6); + gui_drawBox(68, 130, 108, 47, guiSettings()->colors.frame1, guiSettings()->colors.frame2, guiSettings()->colors.fill); + gui_drawBox(68, 168, 78, 9, guiSettings()->colors.extraFrame1, guiSettings()->colors.extraFrame2, guiSettings()->colors.extraFill); + gui_drawBox(146, 168, 14, 9, guiSettings()->colors.extraFrame1, guiSettings()->colors.extraFrame2, guiSettings()->colors.extraFill); + gui_drawBox(160, 168, 16, 9, guiSettings()->colors.extraFrame1, guiSettings()->colors.extraFrame2, guiSettings()->colors.extraFill); gui_drawSpellbookScrollArrow(150, 169, 0); gui_drawSpellbookScrollArrow(165, 169, 1); } @@ -562,14 +562,14 @@ void EoBCoreEngine::gui_drawSpellbook() { int textXa = 74; int textXs = 71; int textY = 170; - int col3 = _bkgColor_1; - int col4 = _color6; + int col3 = guiSettings()->colors.fill; + int col4 = guiSettings()->colors.extraFill; if (_flags.gameID == GI_EOB1) { textCol2 = 11; textXa = textXs = 73; textY = 168; - col4 = _bkgColor_1; + col4 = guiSettings()->colors.fill; } for (int i = 0; i < 7; i++) { @@ -2377,7 +2377,7 @@ void GUI_EoB::messageDialogue2(int dim, int id, int buttonTextCol) { } } - _vm->gui_drawBox(x, y, w, 14, _vm->_color2_1, _vm->_bkgColor_1, -1); + _vm->gui_drawBox(x, y, w, 14, _vm->guiSettings()->colors.frame2, _vm->guiSettings()->colors.fill, -1); _screen->updateScreen(); _vm->_system->delayMillis(80); drawMenuButtonBox(x, y, w, 14, false, false); @@ -2657,7 +2657,7 @@ bool GUI_EoB::runSaveMenu(int x, int y) { int fy = y + slot * 17 + 23; for (int in = -1; in == -1 && !_vm->shouldQuit();) { - _screen->fillRect(fx - 2, fy, fx + 160, fy + 8, _vm->_bkgColor_1); + _screen->fillRect(fx - 2, fy, fx + 160, fy + 8, _vm->guiSettings()->colors.fill); in = getTextInput(_saveSlotStringsTemp[slot], x + 1, fy, 19, 2, 0, 8); if (!strlen(_saveSlotStringsTemp[slot])) { messageDialogue(11, 54, 6); @@ -2665,7 +2665,7 @@ bool GUI_EoB::runSaveMenu(int x, int y) { } }; - _screen->fillRect(fx - 2, fy, fx + 160, fy + 8, _vm->_bkgColor_1); + _screen->fillRect(fx - 2, fy, fx + 160, fy + 8, _vm->guiSettings()->colors.fill); _screen->printShadedText(_saveSlotStringsTemp[slot], (x + 1) << 3, fy, 15, 0); Graphics::Surface thumb; @@ -2778,7 +2778,7 @@ int GUI_EoB::selectSaveSlotDialogue(int x, int y, int id) { // Display highlighted slot index in the bottom left corner to avoid people getting lost with the 990 save slots _screen->setFont(Screen::FID_6_FNT); int sli = (newHighlight == 6) ? _savegameOffset : (_savegameOffset + newHighlight); - _screen->printText(Common::String::format("%03d/989", sli).c_str(), _saveSlotX + 5, _saveSlotY + 135, _vm->_color2_1, _vm->_bkgColor_1); + _screen->printText(Common::String::format("%03d/989", sli).c_str(), _saveSlotX + 5, _saveSlotY + 135, _vm->guiSettings()->colors.frame2, _vm->guiSettings()->colors.fill); _screen->setFont(Screen::FID_8_FNT); _screen->updateScreen(); @@ -2937,7 +2937,7 @@ void GUI_EoB::runMemorizePrayMenu(int charIndex, int spellType) { 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); + _screen->printShadedText(Common::String::format(_vm->_menuStringsMgc[1], np[lastHighLightButton] - numAssignedSpellsPerBookPage[lastHighLightButton], np[lastHighLightButton]).c_str(), 8, 38, 9, _vm->guiSettings()->colors.fill); } if (newHighLightText < 0) @@ -3721,7 +3721,7 @@ Button *GUI_EoB::initMenu(int id) { if (m->dim) { const ScreenDim *dm = _screen->getScreenDim(m->dim); - _screen->fillRect(dm->sx << 3, dm->sy, ((dm->sx + dm->w) << 3) - 1, (dm->sy + dm->h) - 1, _vm->_bkgColor_1); + _screen->fillRect(dm->sx << 3, dm->sy, ((dm->sx + dm->w) << 3) - 1, (dm->sy + dm->h) - 1, _vm->guiSettings()->colors.fill); _screen->setScreenDim(m->dim); drawMenuButtonBox(dm->sx << 3, dm->sy, dm->w << 3, dm->h, false, false); } @@ -3789,14 +3789,14 @@ void GUI_EoB::drawMenuButton(Button *b, bool clicked, bool highlight, bool noFil } void GUI_EoB::drawMenuButtonBox(int x, int y, int w, int h, bool clicked, bool noFill) { - uint8 col1 = _vm->_color1_1; - uint8 col2 = _vm->_color2_1; + uint8 col1 = _vm->guiSettings()->colors.frame1; + uint8 col2 = _vm->guiSettings()->colors.frame2; if (clicked) - col1 = col2 = _vm->_bkgColor_1; + col1 = col2 = _vm->guiSettings()->colors.fill; _vm->gui_drawBox(x, y, w, h, col1, col2, -1); - _vm->gui_drawBox(x + 1, y + 1, w - 2, h - 2, _vm->_color1_1, _vm->_color2_1, noFill ? -1 : _vm->_bkgColor_1); + _vm->gui_drawBox(x + 1, y + 1, w - 2, h - 2, _vm->guiSettings()->colors.frame1, _vm->guiSettings()->colors.frame2, noFill ? -1 : _vm->guiSettings()->colors.fill); } void GUI_EoB::drawTextBox(int dim, int id) { @@ -3852,10 +3852,10 @@ void GUI_EoB::memorizePrayMenuPrintString(int spellId, int bookPageIndex, int sp 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); + _screen->printShadedText(s.c_str(), 8, y, highLight ? 6 : 15, _vm->guiSettings()->colors.fill); } else { - _screen->fillRect(6, y, 168, y + 8, _vm->_bkgColor_1); + _screen->fillRect(6, y, 168, y + 8, _vm->guiSettings()->colors.fill); } } @@ -4000,7 +4000,7 @@ void GUI_EoB::restParty_updateRestTime(int hours, bool init) { } _screen->setCurPage(2); - _screen->printShadedText(Common::String::format(_vm->_menuStringsRest2[3], hours).c_str(), (_screen->_curDim->sx + 1) << 3, _screen->_curDim->sy + 20, 15, _vm->_bkgColor_1); + _screen->printShadedText(Common::String::format(_vm->_menuStringsRest2[3], hours).c_str(), (_screen->_curDim->sx + 1) << 3, _screen->_curDim->sy + 20, 15, _vm->guiSettings()->colors.fill); _screen->setCurPage(0); _screen->copyRegion(((_screen->_curDim->sx + 1) << 3) - 1, _screen->_curDim->sy + 20, ((_screen->_curDim->sx + 1) << 3) - 1, _screen->_curDim->sy + 20, 144, 8, 2, 0, Screen::CR_NO_P_CHECK); _screen->updateScreen(); -- cgit v1.2.3 From e6b6099d54c05a95530125e95da69a90aff4863d Mon Sep 17 00:00:00 2001 From: athrxx Date: Tue, 27 Dec 2011 20:57:58 +0100 Subject: KYRA: (EOB) - fix minor color glitch --- engines/kyra/gui_eob.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/kyra/gui_eob.cpp') diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index 1ccb60ada1..a80ef03201 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -464,8 +464,8 @@ void EoBCoreEngine::gui_drawCharPortraitStatusFrame(int index) { } } else { - _screen->drawClippedLine(x, y, x + 62, y, guiSettings()->colors.frame1); - _screen->drawClippedLine(x, y + 49, x + 62, y + 49, guiSettings()->colors.frame2); + _screen->drawClippedLine(x, y, x + 62, y, guiSettings()->colors.frame2); + _screen->drawClippedLine(x, y + 49, x + 62, y + 49, guiSettings()->colors.frame1); _screen->drawClippedLine(x - 1, y, x - 1, y + 50, 12); _screen->drawClippedLine(x + 63, y, x + 63, y + 50, 12); } -- cgit v1.2.3 From a35550d200a9e19894571758afe992185c6c6176 Mon Sep 17 00:00:00 2001 From: athrxx Date: Tue, 27 Dec 2011 21:50:07 +0100 Subject: KYRA: (EOB) - fix invalid string access in EOB 1 (when entering the memorize/pray menu without having a mage/cleric) --- engines/kyra/gui_eob.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/kyra/gui_eob.cpp') diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index a80ef03201..512c13a977 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -3543,7 +3543,7 @@ int GUI_EoB::selectCharacterDialogue(int id) { _vm->removeInputTop(); _charSelectRedraw = false; - bool abort = false; + bool starvedUnconscious = false; int count = 0; int result = -1; int found[6]; @@ -3558,7 +3558,7 @@ int GUI_EoB::selectCharacterDialogue(int id) { continue; if (id != 53 && (!_vm->_characters[i].food || !_vm->testCharacter(i, 4))) { - abort = true; + starvedUnconscious = true; } else { found[i] = 0; result = i; @@ -3569,9 +3569,9 @@ int GUI_EoB::selectCharacterDialogue(int id) { if (!count) { int eid = 0; if (id == 23) - eid = abort ? 28 : 72; + eid = (starvedUnconscious || _vm->game() == GI_EOB1) ? 28 : 72; else if (id == 26) - eid = abort ? 27 : 73; + eid = (starvedUnconscious || _vm->game() == GI_EOB1) ? 27 : 73; else if (id == 49) eid = 52; -- cgit v1.2.3 From 99b14c5dbc9414b46afffabafb4be9c9c4c51fd1 Mon Sep 17 00:00:00 2001 From: athrxx Date: Tue, 27 Dec 2011 23:59:16 +0100 Subject: KYRA: (EOB) - fix spell book tab 5 in EOB1 --- engines/kyra/gui_eob.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/kyra/gui_eob.cpp') diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index 512c13a977..a378fe1ea5 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -708,8 +708,8 @@ void EoBCoreEngine::gui_initButton(int index, int, int, int) { if (_flags.gameID == GI_EOB1) { // EOB1 spellbook modifications if (index > 60 && index < 66) { - d = &_buttonDefs[index + 33]; - b->buttonCallback = _buttonCallbacks[index + 33]; + d = &_buttonDefs[index + 34]; + b->buttonCallback = _buttonCallbacks[index + 34]; } else if (index == 88) { d = &_buttonDefs[index + 12]; b->buttonCallback = _buttonCallbacks[index + 12]; -- cgit v1.2.3 From 76dec424696eacf2e9c1576d0580babb1a58e3f1 Mon Sep 17 00:00:00 2001 From: athrxx Date: Tue, 3 Jan 2012 17:25:10 +0100 Subject: KYRA: (EOB) - improved eob target detection in transfer party dialog (parse domains instead of save files) --- engines/kyra/gui_eob.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'engines/kyra/gui_eob.cpp') 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 &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 &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) { -- cgit v1.2.3 From 12d1a9d37f716d8aae4e373705d7f8beec1b8842 Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Sat, 7 Jan 2012 22:17:39 -0600 Subject: KYRA: Fix LoL/EoB savegame typing issue with keymapper If you bind letters (e.g. WSAD) using the keymapper and then try to save using the in-engine dialog, the letters would get captured and make it impossible to name a save using those letters. Thanks LordHoto --- engines/kyra/gui_eob.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'engines/kyra/gui_eob.cpp') diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index d60fa47571..611eab1bff 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -29,6 +29,7 @@ #include "kyra/timer.h" #include "kyra/util.h" +#include "backends/keymapper/keymapper.h" #include "common/system.h" #include "common/savefile.h" #include "graphics/scaler.h" @@ -2419,6 +2420,11 @@ void GUI_EoB::updateBoxFrameHighLight(int box) { } int GUI_EoB::getTextInput(char *dest, int x, int y, int destMaxLen, int textColor1, int textColor2, int cursorColor) { +#ifdef ENABLE_KEYMAPPER + Common::Keymapper *const keymapper = _vm->getEventManager()->getKeymapper(); + keymapper->pushKeymap(Common::kGlobalKeymapName); +#endif + uint8 cursorState = 1; char sufx[] = " "; @@ -2533,6 +2539,10 @@ int GUI_EoB::getTextInput(char *dest, int x, int y, int destMaxLen, int textColo } while (_keyPressed.keycode != Common::KEYCODE_RETURN && _keyPressed.keycode != Common::KEYCODE_ESCAPE && !_vm->shouldQuit()); +#ifdef ENABLE_KEYMAPPER + keymapper->popKeymap(Common::kGlobalKeymapName); +#endif + return _keyPressed.keycode == Common::KEYCODE_ESCAPE ? -1 : len; } -- cgit v1.2.3 From f11b52a097912cfc24728259150c00227167df38 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 29 Jan 2012 16:15:27 +0100 Subject: KYRA: Prevent unnecessary removal of const in some casts. --- engines/kyra/gui_eob.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/kyra/gui_eob.cpp') diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index 611eab1bff..5c2c3e5f33 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -3781,7 +3781,7 @@ void GUI_EoB::drawMenuButton(Button *b, bool clicked, bool highlight, bool noFil if (!b) return; - EoBMenuButtonDef *d = (EoBMenuButtonDef *)b->extButtonDef; + const EoBMenuButtonDef *d = (const EoBMenuButtonDef *)b->extButtonDef; if (d->flags & 1) drawMenuButtonBox(b->x, b->y, b->width, b->height, clicked, noFill); -- cgit v1.2.3 From cf8a6dcd835d3db85648c07e3f254505ea7a7945 Mon Sep 17 00:00:00 2001 From: athrxx Date: Sun, 29 Jan 2012 17:14:47 +0100 Subject: KYRA: (EOB) - fix typo --- engines/kyra/gui_eob.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/kyra/gui_eob.cpp') diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index 5c2c3e5f33..3df19f3690 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -3656,7 +3656,7 @@ int GUI_EoB::selectCharacterDialogue(int id) { } } else if (inputFlag == _vm->_keyMap[Common::KEYCODE_KP5] || inputFlag == _vm->_keyMap[Common::KEYCODE_RETURN]) { - if (found >= 0) + if (hlCur >= 0) result = hlCur; } else if (inputFlag == _vm->_keyMap[Common::KEYCODE_ESCAPE] || inputFlag == 0x8010) { -- cgit v1.2.3 From d192fed3b52ec36abaf0f2d85158ddb28ee69fb1 Mon Sep 17 00:00:00 2001 From: athrxx Date: Mon, 6 Feb 2012 01:31:38 +0100 Subject: KYRA: (EOB) - fix character hand icons (upper thumbs should point to the right, lower thumb to the left) --- engines/kyra/gui_eob.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/kyra/gui_eob.cpp') diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index 3df19f3690..b89a6d7293 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -285,7 +285,7 @@ void EoBCoreEngine::gui_drawWeaponSlot(int charIndex, int slot) { else if (!slot && _flags.gameID == GI_EOB2 && checkScriptFlags(0x80000000)) _screen->drawShape(_screen->_curPage, _itemIconShapes[103], x + 8, y, 0); else - _screen->drawShape(_screen->_curPage, _itemIconShapes[85], x + 8, y, 0); + _screen->drawShape(_screen->_curPage, _itemIconShapes[85 + slot], x + 8, y, 0); if ((_characters[charIndex].disabledSlots & (1 << slot)) || !validateWeaponSlotItem(charIndex, slot) || (_characters[charIndex].hitPointsCur <= 0) || (_characters[charIndex].flags & 0x0c)) _screen->drawShape(_screen->_curPage, _weaponSlotGrid, x, y, 0); -- cgit v1.2.3 From 86a817beb5eef248c5f5e28f18133db802a59c2e Mon Sep 17 00:00:00 2001 From: athrxx Date: Mon, 13 Feb 2012 18:39:50 +0100 Subject: KYRA: (EOB) - start work on CGA and EGA graphics modes --- engines/kyra/gui_eob.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'engines/kyra/gui_eob.cpp') diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index b89a6d7293..2fdfb0c011 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -47,7 +47,7 @@ Button *EoBCoreEngine::gui_getButton(Button *buttonList, int index) { } void EoBCoreEngine::gui_drawPlayField(bool refresh) { - _screen->loadEoBBitmap("PLAYFLD", 0, 5, 3, 2); + _screen->loadEoBBitmap("PLAYFLD", _cgaMappingDeco, 5, 3, 2); int cp = _screen->setCurPage(2); gui_drawCompass(true); @@ -60,11 +60,11 @@ void EoBCoreEngine::gui_drawPlayField(bool refresh) { if (!_loading) _screen->updateScreen(); - _screen->loadEoBBitmap("INVENT", 0, 5, 3, 2); + _screen->loadEoBBitmap("INVENT", _cgaMappingInv, 5, 3, 2); } void EoBCoreEngine::gui_restorePlayField() { - loadVcnData(0, 0); + loadVcnData(0, (_flags.gameID == GI_EOB1) ? _cgaMappingLevel[_cgaLevelMappingIndex[_currentLevel - 1]] : 0); _screen->_curPage = 0; gui_drawPlayField(true); gui_drawAllCharPortraitsWithStats(); @@ -1891,7 +1891,7 @@ void GUI_EoB::simpleMenu_setup(int sd, int maxItem, const char *const *strings, for (int i = 0; i < _menuNumItems; i++) { int item = simpleMenu_getMenuItem(i, menuItemsMask, itemOffset); int ty = y + i * (lineSpacing + _screen->getFontHeight()); - _screen->printShadedText(strings[item], x, ty, dm->unkA, 0); + _screen->printShadedText(strings[item], x, ty, (_vm->_configRenderMode == Common::kRenderCGA) ? 1 : dm->unkA, 0); if (item == v) _screen->printText(strings[item], x, ty, dm->unkC, 0); } @@ -1944,7 +1944,7 @@ int GUI_EoB::simpleMenu_process(int sd, const char *const *strings, void *b, int } if (newItem != currentItem) { - _screen->printText(strings[simpleMenu_getMenuItem(currentItem, menuItemsMask, itemOffset)], x, y + currentItem * lineH , dm->unkA, 0); + _screen->printText(strings[simpleMenu_getMenuItem(currentItem, menuItemsMask, itemOffset)], x, y + currentItem * lineH, (_vm->_configRenderMode == Common::kRenderCGA) ? 1 : dm->unkA, 0); _screen->printText(strings[simpleMenu_getMenuItem(newItem, menuItemsMask, itemOffset)], x, y + newItem * lineH , dm->unkC, 0); _screen->updateScreen(); } -- cgit v1.2.3 From 151d314912b08d7d598a3995524d89c8b4ab0371 Mon Sep 17 00:00:00 2001 From: athrxx Date: Mon, 13 Feb 2012 17:04:05 +0100 Subject: KYRA: (EOB) - complete CGA graphics mode implementation --- engines/kyra/gui_eob.cpp | 89 +++++++++++++++++++++++++++++++----------------- 1 file changed, 58 insertions(+), 31 deletions(-) (limited to 'engines/kyra/gui_eob.cpp') diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index 2fdfb0c011..39cc4692c4 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -116,7 +116,7 @@ void EoBCoreEngine::gui_drawCharPortraitWithStats(int index) { if (c->damageTaken > 0) { _screen->drawShape(2, _redSplatShape, x2 + 13, y2 + 30, 0); Common::String tmpStr = Common::String::format("%d", c->damageTaken); - _screen->printText(tmpStr.c_str(), x2 + 34 - tmpStr.size() * 3, y2 + 42, 15, 0); + _screen->printText(tmpStr.c_str(), x2 + 34 - tmpStr.size() * 3, y2 + 42, (_configRenderMode == Common::kRenderCGA) ? 12 : 15, 0); } _screen->setCurPage(cp); @@ -256,10 +256,8 @@ void EoBCoreEngine::gui_drawFaceShape(int index) { if (c->hitPointsCur < 1) _screen->drawShape(_screen->_curPage, _disabledCharGrid, x, y, 0); - //if ((c->flags & 2) || (c->flags & 8) || (c->effectFlags & 0x140)) { - _screen->setFadeTableIndex(4); - _screen->setShapeFadeMode(1, false); - //} + _screen->setFadeTableIndex(4); + _screen->setShapeFadeMode(1, false); } void EoBCoreEngine::gui_drawWeaponSlot(int charIndex, int slot) { @@ -323,11 +321,13 @@ void EoBCoreEngine::gui_drawWeaponSlotStatus(int x, int y, int status) { break; } + int textColor= (_configRenderMode == Common::kRenderCGA) ? 2 : 15; + if (!tmpStr2.empty()) { - _screen->printText(tmpStr.c_str(), x + (16 - tmpStr.size() * 3), y + 2, 15, 0); - _screen->printText(tmpStr2.c_str(), x + (16 - tmpStr.size() * 3), y + 9, 15, 0); + _screen->printText(tmpStr.c_str(), x + (16 - tmpStr.size() * 3), y + 2, textColor, 0); + _screen->printText(tmpStr2.c_str(), x + (16 - tmpStr.size() * 3), y + 9, textColor, 0); } else { - _screen->printText(tmpStr.c_str(), x + (16 - tmpStr.size() * 3), y + 5, 15, 0); + _screen->printText(tmpStr.c_str(), x + (16 - tmpStr.size() * 3), y + 5, textColor, 0); } } @@ -408,12 +408,13 @@ void EoBCoreEngine::gui_drawHorizontalBarGraph(int x, int y, int w, int h, int32 } void EoBCoreEngine::gui_drawCharPortraitStatusFrame(int index) { - uint8 redGreenColor = (_partyEffectFlags & 0x20000) ? 4 : 6; + uint8 redGreenColor = (_partyEffectFlags & 0x20000) ? 4 : ((_configRenderMode == Common::kRenderCGA) ? 3 : 6); static const uint8 xCoords[] = { 8, 80 }; static const uint8 yCoords[] = { 2, 54, 106 }; int x = xCoords[index & 1]; int y = yCoords[index >> 1]; + int xOffset = (_configRenderMode == Common::kRenderCGA) ? 0 : 1; if (!_screen->_curPage) x += 176; @@ -467,7 +468,7 @@ void EoBCoreEngine::gui_drawCharPortraitStatusFrame(int index) { } else { _screen->drawClippedLine(x, y, x + 62, y, guiSettings()->colors.frame2); _screen->drawClippedLine(x, y + 49, x + 62, y + 49, guiSettings()->colors.frame1); - _screen->drawClippedLine(x - 1, y, x - 1, y + 50, 12); + _screen->drawClippedLine(x - xOffset, y, x - xOffset, y + 50, 12); _screen->drawClippedLine(x + 63, y, x + 63, y + 50, 12); } } @@ -481,7 +482,15 @@ void EoBCoreEngine::gui_drawInventoryItem(int slot, int special, int pageNum) { if (special) { int wh = (slot == 25 || slot == 26) ? 10 : 18; - gui_drawBox(x - 1, y - 1, wh, wh, guiSettings()->colors.frame1, guiSettings()->colors.frame2, slot == 16 ? -1 : guiSettings()->colors.fill); + + uint8 col1 = guiSettings()->colors.frame1; + uint8 col2 = guiSettings()->colors.frame2; + if (_configRenderMode == Common::kRenderCGA ) { + col1 = 1; + col2 = 3; + } + + gui_drawBox(x - 1, y - 1, wh, wh, col1, col2, slot == 16 ? -1 : guiSettings()->colors.fill); if (slot == 16) { _screen->fillRect(227, 65, 238, 69, 12); @@ -528,14 +537,26 @@ void EoBCoreEngine::gui_drawSpellbook() { _screen->copyRegion(64, 121, 64, 121, 112, 56, 0, 2, Screen::CR_NO_P_CHECK); for (int i = 0; i < numTab; i++) { - int col1 = guiSettings()->colors.inactiveTabFrame1; - int col2 = guiSettings()->colors.inactiveTabFrame2; - int col3 = guiSettings()->colors.inactiveTabFill; - - if (i == _openBookSpellLevel) { - col1 = guiSettings()->colors.frame1; - col2 = guiSettings()->colors.frame2; - col3 = guiSettings()->colors.fill; + int col1 = 0; + int col2 = 1; + int col3 = 2; + + if (_configRenderMode == Common::kRenderCGA) { + if (i == _openBookSpellLevel) { + col1 = 1; + col2 = 2; + col3 = 3; + } + } else { + col1 = guiSettings()->colors.inactiveTabFrame1; + col2 = guiSettings()->colors.inactiveTabFrame2; + col3 = guiSettings()->colors.inactiveTabFill; + + if (i == _openBookSpellLevel) { + col1 = guiSettings()->colors.frame1; + col2 = guiSettings()->colors.frame2; + col3 = guiSettings()->colors.fill; + } } if (_flags.gameID == GI_EOB1) { @@ -558,19 +579,21 @@ void EoBCoreEngine::gui_drawSpellbook() { gui_drawSpellbookScrollArrow(165, 169, 1); } - int textCol1 = 15; + int textCol1 = (_configRenderMode == Common::kRenderCGA) ? 3 : 15; int textCol2 = 8; int textXa = 74; int textXs = 71; int textY = 170; - int col3 = guiSettings()->colors.fill; + int col3 = (_configRenderMode == Common::kRenderCGA) ? 2 : guiSettings()->colors.fill; int col4 = guiSettings()->colors.extraFill; + int col5 = 12; if (_flags.gameID == GI_EOB1) { - textCol2 = 11; + textCol2 = (_configRenderMode == Common::kRenderCGA) ? 12 : 11; textXa = textXs = 73; textY = 168; - col4 = guiSettings()->colors.fill; + col4 = col3; + col5 = textCol1; } for (int i = 0; i < 7; i++) { @@ -587,7 +610,7 @@ void EoBCoreEngine::gui_drawSpellbook() { if (d >= 0 && i < 6 && (i + _openBookSpellListOffset) < 9) _screen->printText(_openBookSpellList[d], textXs, 132 + 6 * i, textCol1, col3); else - _screen->printText(_magicStrings1[0], textXa, textY, 12, col4); + _screen->printText(_magicStrings1[0], textXa, textY, col5, col4); } } @@ -2704,13 +2727,14 @@ bool GUI_EoB::runSaveMenu(int x, int y) { int GUI_EoB::selectSaveSlotDialogue(int x, int y, int id) { _saveSlotX = _saveSlotY = 0; + int col1 = (_vm->_configRenderMode == Common::kRenderCGA) ? 1 : 15; _screen->setCurPage(2); _savegameOffset = 0; drawMenuButtonBox(0, 0, 176, 144, false, false); const char *title = (id < 2) ? _vm->_saveLoadStrings[2 + id] : _vm->_transferStringsScummVM[id - 1]; - _screen->printShadedText(title, 52, 5, 15, 0); + _screen->printShadedText(title, 52, 5, col1, 0); _screen->copyRegion(0, 0, x, y, 176, 144, 2, 0, Screen::CR_NO_P_CHECK); _screen->setCurPage(0); @@ -2783,12 +2807,12 @@ int GUI_EoB::selectSaveSlotDialogue(int x, int y, int id) { lastHighlight = -1; setupSaveMenuSlots(); for (int i = 0; i < 7; i++) - drawSaveSlotButton(i, 1, 15); + drawSaveSlotButton(i, 1, col1); lastOffset = _savegameOffset; } if (lastHighlight != newHighlight) { - drawSaveSlotButton(lastHighlight, 0, 15); + drawSaveSlotButton(lastHighlight, 0, col1); drawSaveSlotButton(newHighlight, 0, 6); // Display highlighted slot index in the bottom left corner to avoid people getting lost with the 990 save slots @@ -3797,10 +3821,12 @@ void GUI_EoB::drawMenuButton(Button *b, bool clicked, bool highlight, bool noFil yOffs = (b->height - 7) >> 1; } + int col1 = (_vm->_configRenderMode == Common::kRenderCGA) ? 1 : 15; + if (noFill || clicked) - _screen->printText(s, b->x + xOffs, b->y + yOffs, highlight ? 6 : 15, 0); + _screen->printText(s, b->x + xOffs, b->y + yOffs, highlight ? 6 : col1, 0); else - _screen->printShadedText(s, b->x + xOffs, b->y + yOffs, highlight ? 6 : 15, 0); + _screen->printShadedText(s, b->x + xOffs, b->y + yOffs, highlight ? 6 : col1, 0); } } @@ -3862,13 +3888,14 @@ void GUI_EoB::memorizePrayMenuPrintString(int spellId, int bookPageIndex, int sp return; int y = bookPageIndex * 9 + 50; + int col1 = (_vm->_configRenderMode == Common::kRenderCGA) ? 1 : 15; 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); + _screen->printText(s.c_str(), 8, y, highLight ? 6 : col1, 0); else - _screen->printShadedText(s.c_str(), 8, y, highLight ? 6 : 15, _vm->guiSettings()->colors.fill); + _screen->printShadedText(s.c_str(), 8, y, highLight ? 6 : col1, _vm->guiSettings()->colors.fill); } else { _screen->fillRect(6, y, 168, y + 8, _vm->guiSettings()->colors.fill); -- cgit v1.2.3 From 66da4777d476c6a9fc2a13351e3b30afc748fd94 Mon Sep 17 00:00:00 2001 From: athrxx Date: Tue, 21 Feb 2012 21:14:28 +0100 Subject: KYRA: (EOB) - implement EGA mode (hi res dithering) for EOB II (also fix various thing connected to CGA/EGA modes) --- engines/kyra/gui_eob.cpp | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'engines/kyra/gui_eob.cpp') diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index 39cc4692c4..eadfd10d1e 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -777,11 +777,11 @@ int EoBCoreEngine::clickedCamp(Button *button) { } _screen->copyPage(0, 7); - _screen->copyRegion(0, 120, 0, 0, 176, 24, 0, 12, Screen::CR_NO_P_CHECK); + _screen->copyRegion(0, 120, 0, 0, 176, 24, 0, (_screen->getPageScaleFactor(0) == 2) ? 1 : 12, Screen::CR_NO_P_CHECK); _gui->runCampMenu(); - _screen->copyRegion(0, 0, 0, 120, 176, 24, 12, 2, Screen::CR_NO_P_CHECK); + _screen->copyRegion(0, 0, 0, 120, 176, 24, (_screen->getPageScaleFactor(0) == 2) ? 1 : 12, 2, Screen::CR_NO_P_CHECK); _screen->setScreenDim(cd); drawScene(0); @@ -1170,7 +1170,7 @@ int EoBCoreEngine::clickedSceneSpecial(Button *button) { int EoBCoreEngine::clickedSpellbookAbort(Button *button) { _updateFlags = 0; - _screen->copyRegion(0, 0, 64, 121, 112, 56, 10, 0, Screen::CR_NO_P_CHECK); + _screen->copyRegion(0, 0, 64, 121, 112, 56, (_screen->getPageScaleFactor(0) == 2) ? 4 : 10, 0, Screen::CR_NO_P_CHECK); _screen->updateScreen(); gui_drawCompass(true); gui_toggleButtons(); @@ -1392,9 +1392,11 @@ GUI_EoB::GUI_EoB(EoBCoreEngine *vm) : GUI(vm), _vm(vm), _screen(vm->_screen) { _charSelectRedraw = false; + _highLightColorTable = (_vm->game() == GI_EOB1 && (_vm->_configRenderMode == Common::kRenderCGA || _vm->_configRenderMode == Common::kRenderEGA)) ? _highlightColorTableEGA : _highlightColorTableVGA; _updateBoxIndex = -1; _highLightBoxTimer = 0; _updateBoxColorIndex = 0; + _needRest = false; } @@ -2170,7 +2172,7 @@ void GUI_EoB::runCampMenu() { if (cnt > 4) { _vm->dropCharacter(selectCharacterDialogue(53)); _vm->gui_drawPlayField(false); - _screen->copyRegion(0, 120, 0, 0, 176, 24, 0, 12, Screen::CR_NO_P_CHECK); + _screen->copyRegion(0, 120, 0, 0, 176, 24, 0, (_screen->getPageScaleFactor(0) == 2) ? 1 : 12, Screen::CR_NO_P_CHECK); _screen->setFont(Screen::FID_6_FNT); _vm->gui_drawAllCharPortraitsWithStats(); _screen->setFont(Screen::FID_8_FNT); @@ -2411,8 +2413,6 @@ void GUI_EoB::messageDialogue2(int dim, int id, int buttonTextCol) { } 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 }; - if (_updateBoxIndex == box) { if (_updateBoxIndex == -1) return; @@ -2420,18 +2420,18 @@ void GUI_EoB::updateBoxFrameHighLight(int box) { if (_vm->_system->getMillis() <= _highLightBoxTimer) return; - if (!colorTable[_updateBoxColorIndex]) + if (!_highLightColorTable[_updateBoxColorIndex]) _updateBoxColorIndex = 0; - const EoBRect16 *r = &_updateBoxFrameHighLights[_updateBoxIndex]; - _screen->drawBox(r->x1, r->y1, r->x2, r->y2, colorTable[_updateBoxColorIndex++]); + const EoBRect16 *r = &_highlightFrames[_updateBoxIndex]; + _screen->drawBox(r->x1, r->y1, r->x2, r->y2, _highLightColorTable[_updateBoxColorIndex++]); _screen->updateScreen(); _highLightBoxTimer = _vm->_system->getMillis() + _vm->_tickLength; } else { if (_updateBoxIndex != -1) { - const EoBRect16 *r = &_updateBoxFrameHighLights[_updateBoxIndex]; + const EoBRect16 *r = &_highlightFrames[_updateBoxIndex]; _screen->drawBox(r->x1, r->y1, r->x2, r->y2, 12); _screen->updateScreen(); } @@ -2607,7 +2607,7 @@ Common::String GUI_EoB::transferTargetMenu(Common::Array &target break; } while (_saveSlotIdTemp[slot] == -1); - _screen->copyRegion(72, 14, 72, 14, 176, 144, 12, 0, Screen::CR_NO_P_CHECK); + _screen->copyRegion(72, 14, 72, 14, 176, 144, (_screen->getPageScaleFactor(0) == 2) ? 7 : 12, 0, Screen::CR_NO_P_CHECK); _screen->modifyScreenDim(11, xo, yo, dm->w, dm->h); return (slot < 6) ? _savegameList[_savegameOffset + slot] : Common::String(); @@ -4054,7 +4054,7 @@ void GUI_EoB::restParty_updateRestTime(int hours, bool init) { _screen->setFont(of); } -const EoBRect16 GUI_EoB::_updateBoxFrameHighLights[] = { +const EoBRect16 GUI_EoB::_highlightFrames[] = { { 0x00B7, 0x0001, 0x00F7, 0x0034 }, { 0x00FF, 0x0001, 0x013F, 0x0034 }, { 0x00B7, 0x0035, 0x00F7, 0x0068 }, @@ -4077,6 +4077,10 @@ const EoBRect16 GUI_EoB::_updateBoxFrameHighLights[] = { { 0x00A3, 0x0068, 0x00C3, 0x0089 } }; +const uint8 GUI_EoB::_highlightColorTableVGA[] = { 0x0F, 0xB0, 0xB2, 0xB4, 0xB6, 0xB8, 0xBA, 0xBC, 0x0C, 0xBC, 0xBA, 0xB8, 0xB6, 0xB4, 0xB2, 0xB0, 0x00 }; + +const uint8 GUI_EoB::_highlightColorTableEGA[] = { 0x0C, 0x0D, 0x0E, 0x0F, 0x0E, 0x0D, 0x00 }; + } // End of namespace Kyra #endif // ENABLE_EOB -- cgit v1.2.3 From ecd1a9f9435c5fc5d502d75dd256394b5f3283f3 Mon Sep 17 00:00:00 2001 From: athrxx Date: Thu, 23 Feb 2012 21:36:14 +0100 Subject: KYRA: (EOB) - cleanup CGA/EGA code a bit --- engines/kyra/gui_eob.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'engines/kyra/gui_eob.cpp') diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index eadfd10d1e..ec9b674885 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -777,11 +777,11 @@ int EoBCoreEngine::clickedCamp(Button *button) { } _screen->copyPage(0, 7); - _screen->copyRegion(0, 120, 0, 0, 176, 24, 0, (_screen->getPageScaleFactor(0) == 2) ? 1 : 12, Screen::CR_NO_P_CHECK); + _screen->copyRegion(0, 120, 0, 0, 176, 24, 0, _useHiResDithering ? 1 : 12, Screen::CR_NO_P_CHECK); _gui->runCampMenu(); - _screen->copyRegion(0, 0, 0, 120, 176, 24, (_screen->getPageScaleFactor(0) == 2) ? 1 : 12, 2, Screen::CR_NO_P_CHECK); + _screen->copyRegion(0, 0, 0, 120, 176, 24, _useHiResDithering ? 1 : 12, 2, Screen::CR_NO_P_CHECK); _screen->setScreenDim(cd); drawScene(0); @@ -1170,7 +1170,7 @@ int EoBCoreEngine::clickedSceneSpecial(Button *button) { int EoBCoreEngine::clickedSpellbookAbort(Button *button) { _updateFlags = 0; - _screen->copyRegion(0, 0, 64, 121, 112, 56, (_screen->getPageScaleFactor(0) == 2) ? 4 : 10, 0, Screen::CR_NO_P_CHECK); + _screen->copyRegion(0, 0, 64, 121, 112, 56, _useHiResDithering ? 4 : 10, 0, Screen::CR_NO_P_CHECK); _screen->updateScreen(); gui_drawCompass(true); gui_toggleButtons(); @@ -2172,7 +2172,7 @@ void GUI_EoB::runCampMenu() { if (cnt > 4) { _vm->dropCharacter(selectCharacterDialogue(53)); _vm->gui_drawPlayField(false); - _screen->copyRegion(0, 120, 0, 0, 176, 24, 0, (_screen->getPageScaleFactor(0) == 2) ? 1 : 12, Screen::CR_NO_P_CHECK); + _screen->copyRegion(0, 120, 0, 0, 176, 24, 0, _vm->_useHiResDithering ? 1 : 12, Screen::CR_NO_P_CHECK); _screen->setFont(Screen::FID_6_FNT); _vm->gui_drawAllCharPortraitsWithStats(); _screen->setFont(Screen::FID_8_FNT); @@ -2607,7 +2607,7 @@ Common::String GUI_EoB::transferTargetMenu(Common::Array &target break; } while (_saveSlotIdTemp[slot] == -1); - _screen->copyRegion(72, 14, 72, 14, 176, 144, (_screen->getPageScaleFactor(0) == 2) ? 7 : 12, 0, Screen::CR_NO_P_CHECK); + _screen->copyRegion(72, 14, 72, 14, 176, 144, _vm->_useHiResDithering ? 7 : 12, 0, Screen::CR_NO_P_CHECK); _screen->modifyScreenDim(11, xo, yo, dm->w, dm->h); return (slot < 6) ? _savegameList[_savegameOffset + slot] : Common::String(); -- cgit v1.2.3 From 30fa5e166379b9e0764b437c6925c22d908d7122 Mon Sep 17 00:00:00 2001 From: athrxx Date: Fri, 24 Feb 2012 15:48:06 +0100 Subject: KYRA: (EOB) - fix save file thumbnail generation in CGA/EGA mode --- engines/kyra/gui_eob.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'engines/kyra/gui_eob.cpp') diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index ec9b674885..e8e69d5b1f 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -2648,7 +2648,14 @@ bool GUI_EoB::transferFileMenu(Common::String &targetName, Common::String &selec void GUI_EoB::createScreenThumbnail(Graphics::Surface &dst) { uint8 *screenPal = new uint8[768]; _screen->getRealPalette(0, screenPal); - ::createThumbnail(&dst, _screen->getCPagePtr(7), Screen::SCREEN_W, Screen::SCREEN_H, screenPal); + uint16 width = Screen::SCREEN_W; + uint16 height = Screen::SCREEN_H; + if (_vm->_useHiResDithering) { + width <<= 1; + height <<= 1; + } + + ::createThumbnail(&dst, _screen->getCPagePtr(7), width, height, screenPal); delete[] screenPal; } -- cgit v1.2.3 From 75efdd2d84e21f5d3d01afcc89d61289ae87e4a2 Mon Sep 17 00:00:00 2001 From: Christoph Mallon Date: Tue, 13 Mar 2012 10:40:41 +0100 Subject: JANITORIAL: Replace (x ? false : true) by !(x). --- engines/kyra/gui_eob.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/kyra/gui_eob.cpp') diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index e8e69d5b1f..76e4f0dba9 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -1876,7 +1876,7 @@ int GUI_EoB::processButtonList(Kyra::Button *buttonList, uint16 inputFlags, int8 processButton(buttonList); if (v6 && buttonList->buttonCallback) - runLoop = ((*buttonList->buttonCallback.get())(buttonList)) ? false : true; + runLoop = !(*buttonList->buttonCallback.get())(buttonList); if ((flgs2 & 2) && (flgs & 0x20)) runLoop = false; @@ -2331,7 +2331,7 @@ bool GUI_EoB::confirmDialogue2(int dim, int id, int deflt) { _screen->setFont(of); _screen->setScreenDim(od); - return newHighlight ? false : true; + return newHighlight == 0; } void GUI_EoB::messageDialogue(int dim, int id, int buttonTextCol) { @@ -3548,7 +3548,7 @@ bool GUI_EoB::confirmDialogue(int id) { _vm->removeInputTop(); if (inputFlag == _vm->_keyMap[Common::KEYCODE_KP5] || inputFlag == _vm->_keyMap[Common::KEYCODE_SPACE] || inputFlag == _vm->_keyMap[Common::KEYCODE_RETURN]) { - result = lastHighlight ? false : true; + result = lastHighlight == 0; inputFlag = 0x8021 + lastHighlight; runLoop = false; } else if (inputFlag == _vm->_keyMap[Common::KEYCODE_KP4] || inputFlag == _vm->_keyMap[Common::KEYCODE_LEFT] || inputFlag == _vm->_keyMap[Common::KEYCODE_KP6] || inputFlag == _vm->_keyMap[Common::KEYCODE_RIGHT]) { -- cgit v1.2.3 From e40ba4c1354fabc0d1bd81a6ab80cd5f349d88fa Mon Sep 17 00:00:00 2001 From: Christoph Mallon Date: Tue, 13 Mar 2012 14:53:40 +0100 Subject: JANITORIAL: Simply use *x instead of *x.get() on smart pointers. --- engines/kyra/gui_eob.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'engines/kyra/gui_eob.cpp') diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index 76e4f0dba9..e3c0743e5c 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -1460,7 +1460,7 @@ void GUI_EoB::processButton(Button *button) { // nullsub (at least EOBII) } else if (button->data0Val1 == 4) { if (button->data1Callback) - (*button->data1Callback.get())(button); + (*button->data1Callback)(button); } } else if (button->data1Val1 == 2) { if (!(button->flags2 & 4)) @@ -1469,7 +1469,7 @@ void GUI_EoB::processButton(Button *button) { // nullsub (at least EOBII) } else if (button->data1Val1 == 4) { if (button->data1Callback) - (*button->data1Callback.get())(button); + (*button->data1Callback)(button); } } @@ -1486,7 +1486,7 @@ void GUI_EoB::processButton(Button *button) { // nullsub (at least EOBII) } else if (button->data0Val1 == 4) { if (button->data2Callback) - (*button->data2Callback.get())(button); + (*button->data2Callback)(button); } } else if (button->data2Val1 == 2) { _screen->drawBox(sx, sy, fx2, fy2, (button->flags2 & 1) ? button->data3Val2 : button->data2Val2); @@ -1494,7 +1494,7 @@ void GUI_EoB::processButton(Button *button) { // nullsub (at least EOBII) } else if (button->data2Val1 == 4) { if (button->data2Callback) - (*button->data2Callback.get())(button); + (*button->data2Callback)(button); } } @@ -1507,7 +1507,7 @@ void GUI_EoB::processButton(Button *button) { // nullsub (at least EOBII) } else if (button->data0Val1 == 4) { if (button->data0Callback) - (*button->data0Callback.get())(button); + (*button->data0Callback)(button); } else if (button->data0Val1 == 5) { _screen->drawBox(sx, sy, fx2, fy2, button->data0Val2); } else { @@ -1876,7 +1876,7 @@ int GUI_EoB::processButtonList(Kyra::Button *buttonList, uint16 inputFlags, int8 processButton(buttonList); if (v6 && buttonList->buttonCallback) - runLoop = !(*buttonList->buttonCallback.get())(buttonList); + runLoop = !(*buttonList->buttonCallback)(buttonList); if ((flgs2 & 2) && (flgs & 0x20)) runLoop = false; -- cgit v1.2.3