diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/kyra/chargen.cpp | 102 | ||||
-rw-r--r-- | engines/kyra/eobcommon.cpp | 100 | ||||
-rw-r--r-- | engines/kyra/eobcommon.h | 31 | ||||
-rw-r--r-- | engines/kyra/gui.cpp | 40 | ||||
-rw-r--r-- | engines/kyra/gui.h | 6 | ||||
-rw-r--r-- | engines/kyra/gui_eob.cpp | 447 | ||||
-rw-r--r-- | engines/kyra/gui_eob.h | 92 | ||||
-rw-r--r-- | engines/kyra/gui_lok.cpp | 2 | ||||
-rw-r--r-- | engines/kyra/gui_lok.h | 2 | ||||
-rw-r--r-- | engines/kyra/gui_lol.cpp | 6 | ||||
-rw-r--r-- | engines/kyra/gui_lol.h | 2 | ||||
-rw-r--r-- | engines/kyra/gui_v2.cpp | 4 | ||||
-rw-r--r-- | engines/kyra/gui_v2.h | 2 | ||||
-rw-r--r-- | engines/kyra/kyra_hof.h | 2 | ||||
-rw-r--r-- | engines/kyra/kyra_lok.h | 2 | ||||
-rw-r--r-- | engines/kyra/kyra_mr.h | 2 | ||||
-rw-r--r-- | engines/kyra/kyra_v1.cpp | 2 | ||||
-rw-r--r-- | engines/kyra/kyra_v1.h | 6 | ||||
-rw-r--r-- | engines/kyra/lol.cpp | 2 | ||||
-rw-r--r-- | engines/kyra/lol.h | 2 | ||||
-rw-r--r-- | engines/kyra/loleobbase.h | 2 | ||||
-rw-r--r-- | engines/kyra/resource.h | 2 | ||||
-rw-r--r-- | engines/kyra/script_eob.cpp | 10 | ||||
-rw-r--r-- | engines/kyra/script_eob.h | 5 | ||||
-rw-r--r-- | engines/kyra/sequences_eob1.cpp | 4 | ||||
-rw-r--r-- | engines/kyra/sequences_eob2.cpp | 4 | ||||
-rw-r--r-- | engines/kyra/staticres_eob.cpp | 4 |
27 files changed, 637 insertions, 248 deletions
diff --git a/engines/kyra/chargen.cpp b/engines/kyra/chargen.cpp index 03ab45363f..380cc12a62 100644 --- a/engines/kyra/chargen.cpp +++ b/engines/kyra/chargen.cpp @@ -42,7 +42,6 @@ private: void checkForCompleteParty(); void toggleSpecialButton(int index, int bodyCustom, int pageNum); void processSpecialButton(int index); - void highlightBoxFrame(int index); int viewDeleteCharacter(); void createPartyMember(); int raceSexMenu(); @@ -67,11 +66,8 @@ private: uint8 **_chargenButtonLabels; int _activeBox; int _magicShapesBox; - int _updateBoxIndex; - int _updateBoxColorIndex; int _updateBoxShapesIndex; int _lastUpdateBoxShapesIndex; - uint32 _chargenBoxTimer; uint32 _chargenMagicShapeTimer; int8 _chargenSelectedPortraits[4]; int8 _chargenSelectedPortraits2[4]; @@ -95,7 +91,6 @@ private: static const EobChargenButtonDef _chargenButtonDefs[]; static const CreatePartyModButton _chargenModButtons[]; static const EobRect8 _chargenButtonBodyCoords[]; - static const EobRect16 _chargenPortraitBoxFrames[]; static const int16 _chargenBoxX[]; static const int16 _chargenBoxY[]; static const int16 _chargenNameFieldX[]; @@ -118,9 +113,8 @@ bool EobCoreEngine::startCharacterGeneration() { } CharacterGenerator::CharacterGenerator(EobCoreEngine *vm, Screen_Eob *screen) : _vm(vm), _screen(screen), - _characters(0), _faceShapes(0), _chargenMagicShapes(0), _chargenButtonLabels(0), _updateBoxIndex(-1), - _chargenBoxTimer(0), _chargenMagicShapeTimer(0), _updateBoxColorIndex(0), _updateBoxShapesIndex(0), - _lastUpdateBoxShapesIndex(0), _magicShapesBox(6), _activeBox(0) { + _characters(0), _faceShapes(0), _chargenMagicShapes(0), _chargenButtonLabels(0), _chargenMagicShapeTimer(0), + _updateBoxShapesIndex(0), _lastUpdateBoxShapesIndex(0), _magicShapesBox(6), _activeBox(0) { _chargenStatStrings = _vm->_chargenStatStrings; _chargenRaceSexStrings = _vm->_chargenRaceSexStrings; @@ -178,7 +172,7 @@ bool CharacterGenerator::start(EobCharacter *characters, uint8 ***faceShapes) { _activeBox = 0; for (bool loop = true; loop && (!_vm->shouldQuit()); ) { - highlightBoxFrame(_activeBox + 6); + _vm->_gui->highLightBoxFrame(_activeBox + 6); _vm->sound()->process(); int inputFlag = _vm->checkInput(_vm->_activeButtons, false, 0); _vm->removeInputTop(); @@ -193,7 +187,7 @@ bool CharacterGenerator::start(EobCharacter *characters, uint8 ***faceShapes) { _vm->sound()->haltTrack(); return false; } - highlightBoxFrame(-1); + _vm->_gui->highLightBoxFrame(-1); } if (inputFlag & 0x8000) { @@ -207,7 +201,7 @@ bool CharacterGenerator::start(EobCharacter *characters, uint8 ***faceShapes) { } if (inputFlag == _vm->_keyMap[Common::KEYCODE_RETURN] || inputFlag == _vm->_keyMap[Common::KEYCODE_SPACE] || inputFlag == _vm->_keyMap[Common::KEYCODE_KP5]) { - highlightBoxFrame(-1); + _vm->_gui->highLightBoxFrame(-1); if (_characters[_activeBox].name[0]) { int b = _activeBox; if (viewDeleteCharacter()) @@ -381,50 +375,16 @@ void CharacterGenerator::processSpecialButton(int index) { toggleSpecialButton(index, 0, 0); } -void CharacterGenerator::highlightBoxFrame(int index) { - static const uint8 colorTable[] = { 0x0F, 0xB0, 0xB2, 0xB4, 0xB6, - 0xB8, 0xBA, 0xBC, 0x0C, 0xBC, 0xBA, 0xB8, 0xB6, 0xB4, 0xB2, 0xB0, 0x00 - }; - - if (_updateBoxIndex == index) { - if (_updateBoxIndex == -1) - return; - - if (_vm->_system->getMillis() <= _chargenBoxTimer) - return; - - if (!colorTable[_updateBoxColorIndex]) - _updateBoxColorIndex = 0; - - const EobRect16 *r = &_chargenPortraitBoxFrames[_updateBoxIndex]; - _screen->drawBox(r->x1, r->y1, r->x2, r->y2, colorTable[_updateBoxColorIndex++]); - _screen->updateScreen(); - - _chargenBoxTimer = _vm->_system->getMillis() + _vm->_tickLength; - - } else { - if (_updateBoxIndex != -1) { - const EobRect16 *r = &_chargenPortraitBoxFrames[_updateBoxIndex]; - _screen->drawBox(r->x1, r->y1, r->x2, r->y2, 12); - _screen->updateScreen(); - } - - _updateBoxColorIndex = 0; - _updateBoxIndex = index; - _chargenBoxTimer = _vm->_system->getMillis(); - } -} - int CharacterGenerator::viewDeleteCharacter() { initButtonsFromList(0, 7); _vm->removeInputTop(); - highlightBoxFrame(-1); + _vm->_gui->highLightBoxFrame(-1); printStats(_activeBox, 2); int res = 0; for (bool loop = true; loop && _characters[_activeBox].name[0] && !_vm->shouldQuit(); ) { - highlightBoxFrame(_activeBox + 6); + _vm->_gui->highLightBoxFrame(_activeBox + 6); _vm->sound()->process(); int inputFlag = _vm->checkInput(_vm->_activeButtons, false, 0); @@ -463,14 +423,14 @@ int CharacterGenerator::viewDeleteCharacter() { } if (loop == false) - highlightBoxFrame(-1); + _vm->_gui->highLightBoxFrame(-1); if (!_characters[cbx].name[0]) loop = false; if (cbx != _activeBox) { _activeBox = cbx; - highlightBoxFrame(-1); + _vm->_gui->highLightBoxFrame(-1); if (loop) printStats(_activeBox, 2); } @@ -480,8 +440,8 @@ int CharacterGenerator::viewDeleteCharacter() { } void CharacterGenerator::createPartyMember() { - _screen->setScreenDim(2); - _chargenBoxTimer = 0; + _screen->setScreenDim(2); + assert(_vm->_gui); for (int i = 0; i != 3 && !_vm->shouldQuit(); i++) { bool bck = false; @@ -528,11 +488,11 @@ int CharacterGenerator::raceSexMenu() { _screen->printShadedText(_chargenStrings2[8], 147, 67, 9, 0); _vm->removeInputTop(); - _vm->_gui->setupMenu(1, 0, _chargenRaceSexStrings, -1, 0, 0); + _vm->_gui->simpleMenu_setup(1, 0, _chargenRaceSexStrings, -1, 0, 0); int16 res = -1; while (res == -1 && !_vm->shouldQuit()) { - res = _vm->_gui->handleMenu(1, _chargenRaceSexStrings, 0, -1, 0); + res = _vm->_gui->simpleMenu_process(1, _chargenRaceSexStrings, 0, -1, 0); updateMagicShapes(); } @@ -557,7 +517,7 @@ int CharacterGenerator::classMenu(int raceSex) { toggleSpecialButton(5, 0, 0); itemsMask &=_classMenuMasks[raceSex / 2]; - _vm->_gui->setupMenu(2, 15, _chargenClassStrings, itemsMask, 0, 0); + _vm->_gui->simpleMenu_setup(2, 15, _chargenClassStrings, itemsMask, 0, 0); _vm->_mouseX = _vm->_mouseY = 0; int16 res = -1; @@ -576,7 +536,7 @@ int CharacterGenerator::classMenu(int raceSex) { else _vm->removeInputTop(); } else { - res = _vm->_gui->handleMenu(2, _chargenClassStrings, 0, itemsMask, 0); + res = _vm->_gui->simpleMenu_process(2, _chargenClassStrings, 0, itemsMask, 0); } } @@ -606,7 +566,7 @@ int CharacterGenerator::alignmentMenu(int cClass) { toggleSpecialButton(5, 0, 0); itemsMask &=_alignmentMenuMasks[cClass]; - _vm->_gui->setupMenu(3, 9, _chargenAlignmentStrings, itemsMask, 0, 0); + _vm->_gui->simpleMenu_setup(3, 9, _chargenAlignmentStrings, itemsMask, 0, 0); _vm->_mouseX = _vm->_mouseY = 0; int16 res = -1; @@ -625,7 +585,7 @@ int CharacterGenerator::alignmentMenu(int cClass) { else _vm->removeInputTop(); } else { - res = _vm->_gui->handleMenu(3, _chargenAlignmentStrings, 0, itemsMask, 0); + res = _vm->_gui->simpleMenu_process(3, _chargenAlignmentStrings, 0, itemsMask, 0); } } @@ -793,8 +753,8 @@ void CharacterGenerator::statsAndFacesMenu() { } } - highlightBoxFrame(6 + _activeBox); - highlightBoxFrame(-1); + _vm->_gui->highLightBoxFrame(6 + _activeBox); + _vm->_gui->highLightBoxFrame(-1); } void CharacterGenerator::faceSelectMenu() { @@ -809,7 +769,7 @@ void CharacterGenerator::faceSelectMenu() { printStats(_activeBox, 4); toggleSpecialButton(12, 0, 0); toggleSpecialButton(13, 0, 0); - highlightBoxFrame(-1); + _vm->_gui->highLightBoxFrame(-1); shp = getNextFreeFaceShape(shp, charSex, 1, _chargenSelectedPortraits); @@ -833,7 +793,7 @@ void CharacterGenerator::faceSelectMenu() { in = _vm->checkInput(_vm->_activeButtons, false, 0); _vm->removeInputTop(); - highlightBoxFrame(box + 10); + _vm->_gui->highLightBoxFrame(box + 10); if (in == 0x8002 || in == _vm->_keyMap[Common::KEYCODE_RIGHT]) { processSpecialButton(13); @@ -853,7 +813,7 @@ void CharacterGenerator::faceSelectMenu() { } } - highlightBoxFrame(-1); + _vm->_gui->highLightBoxFrame(-1); if (in == 1) shp = getNextFreeFaceShape(shp - 1, charSex, -1, _chargenSelectedPortraits); @@ -864,7 +824,7 @@ void CharacterGenerator::faceSelectMenu() { } if (!_vm->shouldQuit()) { - highlightBoxFrame(-1); + _vm->_gui->highLightBoxFrame(-1); updateMagicShapes(); _chargenSelectedPortraits[_activeBox] = sp[res]; @@ -899,7 +859,7 @@ int CharacterGenerator::getNextFreeFaceShape(int shpIndex, int charSex, int step } void CharacterGenerator::processFaceMenuSelection(int index) { - highlightBoxFrame(-1); + _vm->_gui->highLightBoxFrame(-1); if (index <= 48) _screen->drawShape(0, _characters[_activeBox].faceShape, _chargenBoxX[_activeBox], _chargenBoxY[_activeBox] + 1, 0); else @@ -1127,15 +1087,15 @@ int CharacterGenerator::getMaxHp(int cclass, int constitution, int level1, int l int res = 0; constitution = _vm->getClassAndConstHitpointsModifier(cclass, constitution); - int m = _vm->getClassHpIncreaseType(cclass, 0); + int m = _vm->getCharacterClassType(cclass, 0); if (m != -1) res = _vm->getModifiedHpLimits(m, constitution, level1, false); - m = _vm->getClassHpIncreaseType(cclass, 1); + m = _vm->getCharacterClassType(cclass, 1); if (m != -1) res += _vm->getModifiedHpLimits(m, constitution, level2, false); - m = _vm->getClassHpIncreaseType(cclass, 2); + m = _vm->getCharacterClassType(cclass, 2); if (m != -1) res += _vm->getModifiedHpLimits(m, constitution, level3, false); @@ -1148,15 +1108,15 @@ int CharacterGenerator::getMinHp(int cclass, int constitution, int level1, int l int res = 0; constitution = _vm->getClassAndConstHitpointsModifier(cclass, constitution); - int m = _vm->getClassHpIncreaseType(cclass, 0); + int m = _vm->getCharacterClassType(cclass, 0); if (m != -1) res = _vm->getModifiedHpLimits(m, constitution, level1, true); - m = _vm->getClassHpIncreaseType(cclass, 1); + m = _vm->getCharacterClassType(cclass, 1); if (m != -1) res += _vm->getModifiedHpLimits(m, constitution, level2, true); - m = _vm->getClassHpIncreaseType(cclass, 2); + m = _vm->getCharacterClassType(cclass, 2); if (m != -1) res += _vm->getModifiedHpLimits(m, constitution, level3, true); @@ -1443,7 +1403,7 @@ const EobRect8 CharacterGenerator::_chargenButtonBodyCoords[] = { { 0x14, 0x90, 0x0B, 0x10 } }; -const EobRect16 CharacterGenerator::_chargenPortraitBoxFrames[] = { +const EobRect16 GUI_Eob::_highLightBoxFrames[] = { { 0x00B7, 0x0001, 0x00F7, 0x0034 }, { 0x00FF, 0x0001, 0x013F, 0x0034 }, { 0x00B7, 0x0035, 0x00F7, 0x0068 }, diff --git a/engines/kyra/eobcommon.cpp b/engines/kyra/eobcommon.cpp index d193bc0842..83a57cd66f 100644 --- a/engines/kyra/eobcommon.cpp +++ b/engines/kyra/eobcommon.cpp @@ -48,6 +48,7 @@ EobCoreEngine::EobCoreEngine(OSystem *system, const GameFlags &flags) : LolEobBa _saveLoadMode = 0; _updateHandItemCursor = false; _configMouse = true; + _resting = false; _largeItemShapes = _smallItemShapes = _thrownItemShapes = _spellShapes = _firebeamShapes = _itemIconShapes = _wallOfForceShapes = _teleporterShapes = _sparkShapes = _compassShapes = 0; @@ -257,6 +258,8 @@ Common::Error EobCoreEngine::init() { _screen->loadFont(Screen::FID_6_FNT, "FONT6.FNT"); _screen->loadFont(Screen::FID_8_FNT, "FONT8.FNT"); + readSettings(); + Common::Error err = LolEobBaseEngine::init(); if (err.getCode() != Common::kNoError) return err; @@ -365,7 +368,7 @@ Common::Error EobCoreEngine::go() { } else if (action == -2) { // new game repeatLoop = startCharacterGeneration(); - if (repeatLoop) + if (repeatLoop && !shouldQuit()) startupNew(); } else if (action == -3) { // transfer party @@ -382,6 +385,34 @@ Common::Error EobCoreEngine::go() { return Common::kNoError; } +void EobCoreEngine::registerDefaultSettings() { + KyraEngine_v1::registerDefaultSettings(); + ConfMan.registerDefault("hpbargraphs", true); +} + +void EobCoreEngine::readSettings() { + _configHpBarGraphs = ConfMan.getBool("hpbargraphs"); + _configSounds = ConfMan.getBool("sfx_mute") ? 0 : 1; + _configMusic = _configSounds ? 1 : 0; + + if (_sound) + _sound->enableSFX(_configSounds); +} + +void EobCoreEngine::writeSettings() { + ConfMan.setBool("hpbargraphs", _configHpBarGraphs); + ConfMan.setBool("sfx_mute", _configSounds == 0); + + if (_sound) { + if (!_configSounds) + _sound->beginFadeOut(); + _sound->enableMusic(_configSounds ? 1 : 0); + _sound->enableSFX(_configSounds); + } + + ConfMan.flushToDisk(); +} + void EobCoreEngine::startupNew() { gui_setPlayFieldButtons(); _screen->_curPage = 0; @@ -659,7 +690,7 @@ int EobCoreEngine::generateCharacterHitpointsByLevel(int charIndex, int levelInd if (!(levelIndex & (1 << i))) continue; - int d = getClassHpIncreaseType(c->cClass, i); + int d = getCharacterClassType(c->cClass, i); if (c->level[i] <= _hpIncrPerLevel[6 + i]) h += rollDice(1, (d >= 0) ? _hpIncrPerLevel[d] : 0); @@ -686,8 +717,8 @@ int EobCoreEngine::getClassAndConstHitpointsModifier(int cclass, int constitutio return 2; } -int EobCoreEngine::getClassHpIncreaseType(int cclass, int levelIndex) { - return _classHpIncreaseType[cclass * 3 + levelIndex]; +int EobCoreEngine::getCharacterClassType(int cclass, int levelIndex) { + return _characterClassType[cclass * 3 + levelIndex]; } int EobCoreEngine::getModifiedHpLimits(int hpModifier, int constModifier, int level, bool mode) { @@ -867,11 +898,11 @@ int EobCoreEngine::getCharacterClericPaladinLevel(int index) { if (index == -1) return (_currentLevel < 7) ? 5 : 9; - int l = getLevelIndexForHpIncType(2, _characters[index].cClass); + int l = getCharacterLevelIndex(2, _characters[index].cClass); if (l > -1) return _characters[index].level[l]; - l = getLevelIndexForHpIncType(4, _characters[index].cClass); + l = getCharacterLevelIndex(4, _characters[index].cClass); if (l > -1) { if (_characters[index].level[l] > 8) return _characters[index].level[l] - 8; @@ -887,18 +918,18 @@ int EobCoreEngine::getCharacterMageLevel(int index) { if (index == -1) return (_currentLevel < 7) ? 5 : 9; - int l = getLevelIndexForHpIncType(1, _characters[index].cClass); + int l = getCharacterLevelIndex(1, _characters[index].cClass); return (l > -1) ? _characters[index].level[l] : 1; } -int EobCoreEngine::getLevelIndexForHpIncType(int hpIncType, int cClass) { - if (getClassHpIncreaseType(cClass, 0) == hpIncType) +int EobCoreEngine::getCharacterLevelIndex(int type, int cClass) { + if (getCharacterClassType(cClass, 0) == type) return 0; - if (getClassHpIncreaseType(cClass, 1) == hpIncType) + if (getCharacterClassType(cClass, 1) == type) return 1; - if (getClassHpIncreaseType(cClass, 2) == hpIncType) + if (getCharacterClassType(cClass, 2) == type) return 2; return -1; @@ -1020,6 +1051,20 @@ int EobCoreEngine::prepareForNewPartyMember(int16 itemType, int16 itemValue) { return 1; } +void EobCoreEngine::dropCharacter(int charIndex) { + if (!testCharacter(charIndex, 1)) + return; + + removeCharacterFromParty(charIndex); + + if (charIndex < 5) + exchangeCharacters(charIndex, testCharacter(5, 1) ? 5 : 4); + + gui_processCharPortraitClick(0); + gui_setPlayFieldButtons(); + setupCharacterTimers(); +} + void EobCoreEngine::removeCharacterFromParty(int charIndex) { EobCharacter *c = &_characters[charIndex]; c->flags = 0; @@ -1043,6 +1088,13 @@ void EobCoreEngine::removeCharacterFromParty(int charIndex) { setupCharacterTimers(); } +void EobCoreEngine::exchangeCharacters(int charIndex1, int charIndex2) { + EobCharacter temp; + memcpy(&temp, &_characters[charIndex1], sizeof(EobCharacter)); + memcpy(&_characters[charIndex1], &_characters[charIndex2], sizeof(EobCharacter)); + memcpy(&_characters[charIndex2], &temp, sizeof(EobCharacter)); +} + void EobCoreEngine::increasePartyExperience(int16 points) { int cnt = 0; for (int i = 0; i < 6; i++) { @@ -1067,7 +1119,7 @@ void EobCoreEngine::increaseCharacterExperience(int charIndex, int32 points) { points /= _numLevelsPerClass[cl]; for (int i = 0; i < 3; i++) { - if (getClassHpIncreaseType(cl, i) == -1) + if (getCharacterClassType(cl, i) == -1) continue; _characters[charIndex].experience[i] += points; @@ -1081,7 +1133,7 @@ void EobCoreEngine::increaseCharacterExperience(int charIndex, int32 points) { } uint32 EobCoreEngine::getRequiredExperience(int cClass, int levelIndex, int level) { - cClass = getClassHpIncreaseType(cClass, levelIndex); + cClass = getCharacterClassType(cClass, levelIndex); if (cClass == -1) return 0xffffffff; @@ -1275,6 +1327,28 @@ void EobCoreEngine::displayParchment(int id) { restoreAfterDialogueSequence(); } +bool EobCoreEngine::restParty() { + if (_inf->preventRest()) { + assert(_menuStringsRest3[0]); + displayRestWarning(_menuStringsRest3[0]); + return true; + } + + return true; +} + +void EobCoreEngine::displayRestWarning(const char *str) { + int od = _screen->curDimIndex(); + _screen->setScreenDim(7); + Screen::FontId of = _screen->setFont(Screen::FID_6_FNT); + _screen->setCurPage(0); + + _txt->printMessage(Common::String::format("\r%s\r", str).c_str()); + + _screen->setFont(of); + _screen->setScreenDim(od); +} + void EobCoreEngine::useSlotWeapon(int charIndex, int slotIndex, int item) { EobCharacter *c = &_characters[charIndex]; int tp = item ? _items[item].type : 0; diff --git a/engines/kyra/eobcommon.h b/engines/kyra/eobcommon.h index a4fb0d7735..ede25dd140 100644 --- a/engines/kyra/eobcommon.h +++ b/engines/kyra/eobcommon.h @@ -55,13 +55,6 @@ struct EobRect8 { uint8 h; }; -struct EobRect16 { - int16 x1; - int16 y1; - uint16 x2; - uint16 y2; -}; - struct EobChargenButtonDef { uint8 x; uint8 y; @@ -258,7 +251,7 @@ public: virtual ~EobCoreEngine(); Screen *screen() { return _screen; } - GUI *gui() const { return _gui; } + GUI_v1 *gui() const { return _gui; } protected: // Startup @@ -270,14 +263,18 @@ protected: virtual void seq_playFinale() = 0; bool _playFinale; - //Init + //Init, config void loadItemsAndDecorationsShapes(); void releaseItemsAndDecorationsShapes(); void initButtonData(); void initMenus(); void initStaticResource(); - virtual void initSpells(); + virtual void initSpells(); + + void registerDefaultSettings(); + void readSettings(); + void writeSettings(); const uint8 **_largeItemShapes; const uint8 **_smallItemShapes; @@ -324,7 +321,7 @@ protected: uint8 **_faceShapes; - static const int8 _classHpIncreaseType[]; + static const int8 _characterClassType[]; static const uint8 _hpIncrPerLevel[]; static const uint8 _numLevelsPerClass[]; static const int16 _hpConstModifiers[]; @@ -361,7 +358,7 @@ protected: int getDexterityArmorClassModifier(int dexterity); int generateCharacterHitpointsByLevel(int charIndex, int levelIndex); int getClassAndConstHitpointsModifier(int cclass, int constitution); - int getClassHpIncreaseType(int cclass, int levelIndex); + int getCharacterClassType(int cclass, int levelIndex); int getModifiedHpLimits(int hpModifier, int constModifier, int level, bool mode); Common::String getCharStrength(int str, int strExt); int testCharacter(int index, int flags); @@ -371,7 +368,7 @@ protected: int validateWeaponSlotItem(int index, int slot); int getCharacterClericPaladinLevel(int index); int getCharacterMageLevel(int index); - int getLevelIndexForHpIncType(int unk, int cClass); + int getCharacterLevelIndex(int type, int cClass); int countCharactersWithSpecificItems(int16 itemType, int16 itemValue); int checkCharacterInventoryForItem(int character, int16 itemType, int16 itemValue); @@ -382,7 +379,9 @@ protected: void initNpc(int npcIndex); int npcJoinDialogue(int npcIndex, int queryJoinTextId, int confirmJoinTextId, int noJoinTextId); int prepareForNewPartyMember(int16 itemType, int16 itemValue); + void dropCharacter(int charIndex); void removeCharacterFromParty(int charIndex); + void exchangeCharacters(int charIndex1, int charIndex2); void increasePartyExperience(int16 points); void increaseCharacterExperience(int charIndex, int32 points); @@ -773,6 +772,9 @@ protected: void delay(uint32 millis, bool doUpdate = false, bool isMainLoop = false); void displayParchment(int id); + bool restParty(); + void displayRestWarning(const char *str); + virtual void drawLightningColumn() {} virtual int resurrectionSelectDialogue() { return -1; } virtual int charSelectDialogue() { return -1; } @@ -786,6 +788,7 @@ protected: void releaseMonsterTempData(LevelTempData *tmp); int _saveLoadMode; + bool _resting; Screen_Eob *_screen; GUI_Eob *_gui; @@ -996,6 +999,8 @@ protected: const char *const *_menuStringsMgc; const char *const *_menuStringsPrefs; const char *const *_menuStringsRest2; + const char *const *_menuStringsRest3; + const char *const *_menuStringsRest4; const char *const *_menuStringsDefeat; const char *const *_menuStringsTransfer; diff --git a/engines/kyra/gui.cpp b/engines/kyra/gui.cpp index 27f09b645e..3a5d79817e 100644 --- a/engines/kyra/gui.cpp +++ b/engines/kyra/gui.cpp @@ -30,15 +30,15 @@ namespace Kyra { -GUI::GUI(KyraEngine_v1 *kyra) +GUI_v1::GUI_v1(KyraEngine_v1 *kyra) : _vm(kyra), _screen(kyra->screen()), _text(kyra->text()) { _menuButtonList = 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); } -Button *GUI::addButtonToList(Button *list, Button *newButton) { +Button *GUI_v1::addButtonToList(Button *list, Button *newButton) { if (!newButton) return list; @@ -56,7 +56,7 @@ Button *GUI::addButtonToList(Button *list, Button *newButton) { return list; } -void GUI::initMenuLayout(Menu &menu) { +void GUI_v1::initMenuLayout(Menu &menu) { if (menu.x == -1) menu.x = (320 - menu.width) >> 1; if (menu.y == -1) @@ -68,7 +68,7 @@ void GUI::initMenuLayout(Menu &menu) { } } -void GUI::initMenu(Menu &menu) { +void GUI_v1::initMenu(Menu &menu) { _menuButtonList = 0; _screen->hideMouse(); @@ -197,7 +197,7 @@ void GUI::initMenu(Menu &menu) { _screen->updateScreen(); } -void GUI::processHighlights(Menu &menu) { +void GUI_v1::processHighlights(Menu &menu) { int x1, y1, x2, y2; Common::Point p = _vm->getMousePos(); int mouseX = p.x; @@ -242,7 +242,7 @@ void GUI::processHighlights(Menu &menu) { _screen->updateScreen(); } -void GUI::redrawText(const Menu &menu) { +void GUI_v1::redrawText(const Menu &menu) { int textX; int i = menu.highlightedItem; @@ -271,7 +271,7 @@ void GUI::redrawText(const Menu &menu) { } } -void GUI::redrawHighlight(const Menu &menu) { +void GUI_v1::redrawHighlight(const Menu &menu) { int textX; int i = menu.highlightedItem; @@ -301,12 +301,12 @@ void GUI::redrawHighlight(const Menu &menu) { } } -void GUI::updateAllMenuButtons() { +void GUI_v1::updateAllMenuButtons() { for (Button *cur = _menuButtonList; cur; cur = cur->nextButton) updateMenuButton(cur); } -void GUI::updateMenuButton(Button *button) { +void GUI_v1::updateMenuButton(Button *button) { if (!_displayMenu) return; @@ -316,7 +316,7 @@ void GUI::updateMenuButton(Button *button) { _screen->showMouse(); } -void GUI::updateButton(Button *button) { +void GUI_v1::updateButton(Button *button) { if (!button || (button->flags & 8)) return; @@ -337,7 +337,7 @@ void GUI::updateButton(Button *button) { processButton(button); } -int GUI::redrawButtonCallback(Button *button) { +int GUI_v1::redrawButtonCallback(Button *button) { if (!_displayMenu) return 0; @@ -351,7 +351,7 @@ int GUI::redrawButtonCallback(Button *button) { return 0; } -int GUI::redrawShadedButtonCallback(Button *button) { +int GUI_v1::redrawShadedButtonCallback(Button *button) { if (!_displayMenu) return 0; @@ -365,7 +365,7 @@ int GUI::redrawShadedButtonCallback(Button *button) { return 0; } -void GUI::updateSaveList(bool excludeQuickSaves) { +void GUI_v1::updateSaveList(bool excludeQuickSaves) { Common::String pattern = _vm->_targetName + ".???"; Common::StringArray saveFileList = _vm->_saveFileMan->listSavefiles(pattern); _saveSlots.clear(); @@ -391,13 +391,13 @@ void GUI::updateSaveList(bool excludeQuickSaves) { sortSaveSlots(); } -void GUI::sortSaveSlots() { +void GUI_v1::sortSaveSlots() { Common::sort(_saveSlots.begin(), _saveSlots.end(), Common::Less<int>()); if (_saveSlots.size() > 2) Common::sort(_saveSlots.begin()+1, _saveSlots.end(), Common::Greater<int>()); } -int GUI::getNextSavegameSlot() { +int GUI_v1::getNextSavegameSlot() { Common::InSaveFile *in; int start = _vm->game() == GI_LOL ? 0 : 1; @@ -412,7 +412,7 @@ int GUI::getNextSavegameSlot() { return 0; } -void GUI::checkTextfieldInput() { +void GUI_v1::checkTextfieldInput() { Common::Event event; uint32 now = _vm->_system->getMillis(); @@ -461,11 +461,11 @@ void GUI::checkTextfieldInput() { _vm->_system->delayMillis(3); } -void GUI::printMenuText(const char *str, int x, int y, uint8 c0, uint8 c1, uint8 c2) { +void GUI_v1::printMenuText(const char *str, int x, int y, uint8 c0, uint8 c1, uint8 c2) { _text->printText(str, x, y, c0, c1, c2); } -int GUI::getMenuCenterStringX(const char *str, int x1, int x2) { +int GUI_v1::getMenuCenterStringX(const char *str, int x1, int x2) { return _text->getCenterStringX(str, x1, x2); } diff --git a/engines/kyra/gui.h b/engines/kyra/gui.h index ad0e0d630f..597f088c0d 100644 --- a/engines/kyra/gui.h +++ b/engines/kyra/gui.h @@ -146,10 +146,10 @@ struct Menu { class Screen; class TextDisplayer; -class GUI { +class GUI_v1 { public: - GUI(KyraEngine_v1 *vm); - virtual ~GUI() {} + GUI_v1(KyraEngine_v1 *vm); + virtual ~GUI_v1() {} // button specific virtual Button *addButtonToList(Button *list, Button *newButton); 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) { diff --git a/engines/kyra/gui_eob.h b/engines/kyra/gui_eob.h index 3eddee553b..64f1c1979a 100644 --- a/engines/kyra/gui_eob.h +++ b/engines/kyra/gui_eob.h @@ -31,10 +31,17 @@ namespace Kyra { +struct EobRect16 { + int16 x1; + int16 y1; + uint16 x2; + uint16 y2; +}; + class DarkMoonEngine; class Screen_Eob; -class GUI_Eob : public GUI { +class GUI_Eob : public GUI_v1 { friend class EobCoreEngine; friend class CharacterGenerator; public: @@ -47,69 +54,49 @@ public: void processButton(Button *button); int processButtonList(Button *buttonList, uint16 inputFlags, int8 mouseWheel); - int redrawShadedButtonCallback(Button *button) { return 0; } - int redrawButtonCallback(Button *button) { return 0; } - // Non button based menu handling (main menu, character generation) - void setupMenu(int sd, int maxItem, const char *const *strings, int32 menuItemsMask, int unk, int lineSpacing); - int handleMenu(int sd, const char *const *strings, void *b, int32 menuItemsMask, int unk); - int getMenuItem(int index, int32 menuItemsMask, int unk); - void menuFlashSelection(const char *str, int x, int y, int color1, int color2, int color3); + void simpleMenu_setup(int sd, int maxItem, const char *const *strings, int32 menuItemsMask, int unk, int lineSpacing); + int simpleMenu_process(int sd, const char *const *strings, void *b, int32 menuItemsMask, int unk); // Button based menus (camp menu, options, save/load) - int runCampMenu(); + void runCampMenu(); int runLoadMenu(int x, int y); + void highLightBoxFrame(int box); + int getTextInput(char *dest, int x, int y, int destMaxLen, int textColor1, int textColor2, int cursorColor); // utilities for thumbnail creation void createScreenThumbnail(Graphics::Surface &dst) {} -private: - void initMenuItemsMask(int menuId, int maxItem, int32 menuItemsMask, int unk); - - //void backupPage0(); - //void restorePage0(); + // unused + int redrawShadedButtonCallback(Button *button) { return 0; } + int redrawButtonCallback(Button *button) { return 0; } - //void setupSavegameNames(Menu &menu, int num); - //void printMenuText(const char *str, int x, int y, uint8 c0, uint8 c1, uint8 flags); +private: + int simpleMenu_getMenuItem(int index, int32 menuItemsMask, int unk); + void simpleMenu_flashSelection(const char *str, int x, int y, int color1, int color2, int color3); + void simpleMenu_initMenuItemsMask(int menuId, int maxItem, int32 menuItemsMask, int unk); - //int getMenuCenterStringX(const char *str, int x1, int x2); + void runSaveMenu(); + void runMemorizePrayMenu(int charIndex, int spellType); + void scribeScrollDialogue(); - //int getInput(); - Button *initMenu(int id); + bool confirmDialogue(int id); + int selectCharacterDialogue(int id); + void displayTextBox(int id); + Button *initMenu(int id); void drawMenuButton(Button *b, bool clicked, bool highlight, bool noFill); void drawMenuButtonBox(int x, int y, int w, int h, bool clicked, bool noFill); - void displayTextBox(int id); void updateOptionsStrings(); const char *getMenuString(int id); Button *linkButton(Button *list, Button *newbt); void releaseButtons(Button *list); - Button *getButtonListData() { return _menuButtons; } - Button *getScrollUpButton() { return &_scrollUpButton; } - Button *getScrollDownButton() { return &_scrollDownButton; } - - Button::Callback getScrollUpButtonHandler() const { return _scrollUpFunctor; } - Button::Callback getScrollDownButtonHandler() const { return _scrollDownFunctor; } - - uint8 defaultColor1() const { return 0xFE; } - uint8 defaultColor2() const { return 0x00; } - - const char *getMenuTitle(const Menu &menu) { return 0; } - const char *getMenuItemTitle(const MenuItem &menuItem) { return 0; } - const char *getMenuItemLabel(const MenuItem &menuItem) { return 0; } - - //Button _menuButtons[10]; - Button *_menuButtons; - Button _scrollUpButton; + Button _scrollUpButton;//////////////////77 Button _scrollDownButton; - //Menu _mainMenu, _gameOptions, _audioOptions, _choiceMenu, _loadMenu, _saveMenu, _deleteMenu, _savenameMenu, _deathMenu; - //Menu *_currentMenu, *_lastMenu, *_newMenu; - //int _menuResult; - //char *_saveDescription; char **_menuStringsPrefsTemp; @@ -124,7 +111,7 @@ private: uint16 _flagsMouseRight; uint16 _flagsModifier; uint16 _progress; - uint16 _prcButtonUnk3; /// ALWAYS 1?? REMOVE ?? + uint16 _prcButtonUnk3; uint16 _cflag; Button::Callback _scrollUpFunctor; @@ -136,6 +123,27 @@ private: int _menuCur; int _menuNumItems; + bool _charSelectRedraw; + + int _updateBoxIndex; + int _updateBoxColorIndex; + uint32 _highLightBoxTimer; + static const EobRect16 _highLightBoxFrames[]; + + // unused + Button *getButtonListData() { return 0; } + Button *getScrollUpButton() { return &_scrollUpButton; } + Button *getScrollDownButton() { return &_scrollDownButton; } + + Button::Callback getScrollUpButtonHandler() const { return _scrollUpFunctor; } + Button::Callback getScrollDownButtonHandler() const { return _scrollDownFunctor; } + + uint8 defaultColor1() const { return 0xFE; } + uint8 defaultColor2() const { return 0x00; } + + const char *getMenuTitle(const Menu &menu) { return 0; } + const char *getMenuItemTitle(const MenuItem &menuItem) { return 0; } + const char *getMenuItemLabel(const MenuItem &menuItem) { return 0; } }; } // End of namespace Kyra diff --git a/engines/kyra/gui_lok.cpp b/engines/kyra/gui_lok.cpp index 4a2d51faa3..6e0d108435 100644 --- a/engines/kyra/gui_lok.cpp +++ b/engines/kyra/gui_lok.cpp @@ -184,7 +184,7 @@ int KyraEngine_LoK::buttonAmuletCallback(Button *caller) { #pragma mark - -GUI_LoK::GUI_LoK(KyraEngine_LoK *vm, Screen_LoK *screen) : GUI(vm), _vm(vm), _screen(screen) { +GUI_LoK::GUI_LoK(KyraEngine_LoK *vm, Screen_LoK *screen) : GUI_v1(vm), _vm(vm), _screen(screen) { _lastScreenUpdate = 0; _menu = 0; _pressFlag = false; diff --git a/engines/kyra/gui_lok.h b/engines/kyra/gui_lok.h index 5a8d6ab532..1d1060312d 100644 --- a/engines/kyra/gui_lok.h +++ b/engines/kyra/gui_lok.h @@ -92,7 +92,7 @@ namespace Kyra { class KyraEngine_LoK; -class GUI_LoK : public GUI { +class GUI_LoK : public GUI_v1 { friend class KyraEngine_LoK; public: GUI_LoK(KyraEngine_LoK *vm, Screen_LoK *screen); diff --git a/engines/kyra/gui_lol.cpp b/engines/kyra/gui_lol.cpp index 08ce0bdadd..681caf93b1 100644 --- a/engines/kyra/gui_lol.cpp +++ b/engines/kyra/gui_lol.cpp @@ -1838,12 +1838,12 @@ int LoLEngine::clickedStatusIcon(Button *button) { return 1; } -GUI_LoL::GUI_LoL(LoLEngine *vm) : GUI(vm), _vm(vm), _screen(vm->_screen) { +GUI_LoL::GUI_LoL(LoLEngine *vm) : GUI_v1(vm), _vm(vm), _screen(vm->_screen) { _scrollUpFunctor = BUTTON_FUNCTOR(GUI_LoL, this, &GUI_LoL::scrollUp); _scrollDownFunctor = BUTTON_FUNCTOR(GUI_LoL, this, &GUI_LoL::scrollDown); - _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); _specialProcessButton = _backUpButtonList = 0; _flagsModifier = 0; diff --git a/engines/kyra/gui_lol.h b/engines/kyra/gui_lol.h index 9c0c4e2bfe..3a8135a1b9 100644 --- a/engines/kyra/gui_lol.h +++ b/engines/kyra/gui_lol.h @@ -88,7 +88,7 @@ namespace Kyra { class LoLEngine; class Screen_LoL; -class GUI_LoL : public GUI { +class GUI_LoL : public GUI_v1 { friend class LoLEngine; public: GUI_LoL(LoLEngine *vm); diff --git a/engines/kyra/gui_v2.cpp b/engines/kyra/gui_v2.cpp index c0477f29f1..a1d74fded9 100644 --- a/engines/kyra/gui_v2.cpp +++ b/engines/kyra/gui_v2.cpp @@ -30,7 +30,7 @@ namespace Kyra { -GUI_v2::GUI_v2(KyraEngine_v2 *vm) : GUI(vm), _vm(vm), _screen(vm->screen_v2()) { +GUI_v2::GUI_v2(KyraEngine_v2 *vm) : GUI_v1(vm), _vm(vm), _screen(vm->screen_v2()) { _backUpButtonList = _specialProcessButton = 0; _buttonListChanged = false; _lastScreenUpdate = 0; @@ -48,7 +48,7 @@ GUI_v2::GUI_v2(KyraEngine_v2 *vm) : GUI(vm), _vm(vm), _screen(vm->screen_v2()) { } Button *GUI_v2::addButtonToList(Button *list, Button *newButton) { - list = GUI::addButtonToList(list, newButton); + list = GUI_v1::addButtonToList(list, newButton); _buttonListChanged = true; return list; } diff --git a/engines/kyra/gui_v2.h b/engines/kyra/gui_v2.h index ef95c0301a..402766b1ca 100644 --- a/engines/kyra/gui_v2.h +++ b/engines/kyra/gui_v2.h @@ -99,7 +99,7 @@ namespace Kyra { class KyraEngine_v2; class Screen_v2; -class GUI_v2 : public GUI { +class GUI_v2 : public GUI_v1 { public: GUI_v2(KyraEngine_v2 *vm); diff --git a/engines/kyra/kyra_hof.h b/engines/kyra/kyra_hof.h index a6add505cb..3acefdde8e 100644 --- a/engines/kyra/kyra_hof.h +++ b/engines/kyra/kyra_hof.h @@ -199,7 +199,7 @@ public: Screen *screen() { return _screen; } Screen_v2 *screen_v2() const { return _screen; } - GUI *gui() const { return _gui; } + GUI_v1 *gui() const { return _gui; } virtual TextDisplayer *text() { return _text; } int language() const { return _lang; } protected: diff --git a/engines/kyra/kyra_lok.h b/engines/kyra/kyra_lok.h index e5fb3cddca..3ecefbac5d 100644 --- a/engines/kyra/kyra_lok.h +++ b/engines/kyra/kyra_lok.h @@ -109,7 +109,7 @@ public: Screen *screen() { return _screen; } Animator_LoK *animator() { return _animator; } - GUI *gui() const { return _gui; } + GUI_v1 *gui() const { return _gui; } virtual Movie *createWSAMovie(); uint8 **shapes() { return _shapes; } diff --git a/engines/kyra/kyra_mr.h b/engines/kyra/kyra_mr.h index 38ff271037..4b3e8b3fc7 100644 --- a/engines/kyra/kyra_mr.h +++ b/engines/kyra/kyra_mr.h @@ -54,7 +54,7 @@ public: Screen *screen() { return _screen; } Screen_v2 *screen_v2() const { return _screen; } - GUI *gui() const { return _gui; } + GUI_v1 *gui() const { return _gui; } SoundDigital *soundDigital() { return _soundDigital; } int language() const { return _lang; } bool heliumMode() const { return _configHelium; } diff --git a/engines/kyra/kyra_v1.cpp b/engines/kyra/kyra_v1.cpp index c1b9f2a453..72cc5bc396 100644 --- a/engines/kyra/kyra_v1.cpp +++ b/engines/kyra/kyra_v1.cpp @@ -345,7 +345,7 @@ int KyraEngine_v1::checkInput(Button *buttonList, bool mainLoop, int eventFlag) _eventList.erase(_eventList.begin()); } - GUI *guiInstance = gui(); + GUI_v1 *guiInstance = gui(); if (guiInstance) { if (keys) return guiInstance->processButtonList(buttonList, keys | eventFlag, mouseWheel); diff --git a/engines/kyra/kyra_v1.h b/engines/kyra/kyra_v1.h index 40f9074106..3a4be467ac 100644 --- a/engines/kyra/kyra_v1.h +++ b/engines/kyra/kyra_v1.h @@ -176,14 +176,14 @@ class TextDisplayer; class StaticResource; class TimerManager; class Debugger; -class GUI; +class GUI_v1; struct Button; class KyraEngine_v1 : public Engine { friend class Debugger; friend class ::KyraMetaEngine; -friend class GUI; +friend class GUI_v1; friend class SoundMidiPC; // For _eventMan public: KyraEngine_v1(OSystem *system, const GameFlags &flags); @@ -196,7 +196,7 @@ public: Resource *resource() { return _res; } virtual Screen *screen() = 0; virtual TextDisplayer *text() { return _text; } - virtual GUI *gui() const { return 0; } + virtual GUI_v1 *gui() const { return 0; } Sound *sound() { return _sound; } StaticResource *staticres() { return _staticres; } TimerManager *timer() { return _timer; } diff --git a/engines/kyra/lol.cpp b/engines/kyra/lol.cpp index 7a4a3ec3e2..8e978c1b34 100644 --- a/engines/kyra/lol.cpp +++ b/engines/kyra/lol.cpp @@ -357,7 +357,7 @@ Screen *LoLEngine::screen() { return _screen; } -GUI *LoLEngine::gui() const { +GUI_v1 *LoLEngine::gui() const { return _gui; } diff --git a/engines/kyra/lol.h b/engines/kyra/lol.h index 8ddba8607c..a33263fc96 100644 --- a/engines/kyra/lol.h +++ b/engines/kyra/lol.h @@ -279,7 +279,7 @@ public: virtual void initKeymap(); Screen *screen(); - GUI *gui() const; + GUI_v1 *gui() const; private: Screen_LoL *_screen; diff --git a/engines/kyra/loleobbase.h b/engines/kyra/loleobbase.h index a2c13827fc..8bebfe4306 100644 --- a/engines/kyra/loleobbase.h +++ b/engines/kyra/loleobbase.h @@ -86,7 +86,7 @@ public: virtual ~LolEobBaseEngine(); virtual Screen *screen() = 0; - virtual GUI *gui() const = 0; + virtual GUI_v1 *gui() const = 0; protected: // Startup diff --git a/engines/kyra/resource.h b/engines/kyra/resource.h index 90a3e74b19..fa4dd10893 100644 --- a/engines/kyra/resource.h +++ b/engines/kyra/resource.h @@ -314,6 +314,8 @@ enum KyraResources { kEobBaseMenuStringsMgc, kEobBaseMenuStringsPrefs, kEobBaseMenuStringsRest2, + kEobBaseMenuStringsRest3, + kEobBaseMenuStringsRest4, kEobBaseMenuStringsDefeat, kEobBaseMenuStringsTransfer, kEobBaseMenuStringsSpec, diff --git a/engines/kyra/script_eob.cpp b/engines/kyra/script_eob.cpp index ef3a623e83..c514c8d239 100644 --- a/engines/kyra/script_eob.cpp +++ b/engines/kyra/script_eob.cpp @@ -122,7 +122,7 @@ EobInfProcessor::EobInfProcessor(EobCoreEngine *engine, Screen_Eob *screen) : _v _abortScript = 0; _abortAfterSubroutine = 0; _dlgResult = 0; - _script2 = 0; + _preventRest = 0; _lastScriptFunc = 0; _lastScriptSub = 0; @@ -192,13 +192,13 @@ void EobInfProcessor::run(int func, int sub) { } void EobInfProcessor::loadState(Common::SeekableSubReadStreamEndian &in) { - _script2 = in.readByte(); + _preventRest = in.readByte(); for (int i = 0; i < 18; i++) _flagTable[i] = in.readUint16BE(); } void EobInfProcessor::saveState(Common::OutSaveFile *out) { - out->writeByte(_script2); + out->writeByte(_preventRest); for (int i = 0; i < 18; i++) out->writeUint16BE(_flagTable[i]); } @@ -521,7 +521,7 @@ int EobInfProcessor::oeob_setFlags(int8 *data) { switch (*pos++) { case -47: - _script2 = 0; + _preventRest = 0; break; case -28: @@ -570,7 +570,7 @@ int EobInfProcessor::oeob_removeFlags(int8 *data) { switch (a) { case -47: - _script2 = 1; + _preventRest = 1; break; case -28: diff --git a/engines/kyra/script_eob.h b/engines/kyra/script_eob.h index 2b02807531..322322ae1f 100644 --- a/engines/kyra/script_eob.h +++ b/engines/kyra/script_eob.h @@ -43,7 +43,8 @@ public: void run(int func, int sub); void setFlag(int flag) { _flagTable[17] |= flag; } - bool checkFlag(int flag) { return (_flagTable[17] & flag) ? true : false; } + bool checkFlag(int flag) const { return (_flagTable[17] & flag) ? true : false; } + bool preventRest() const { return _preventRest ? true : false; } void loadState(Common::SeekableSubReadStreamEndian &in); void saveState(Common::OutSaveFile *out); @@ -96,7 +97,7 @@ private: uint8 _abortScript; uint16 _abortAfterSubroutine; int _dlgResult; - uint8 _script2; + uint8 _preventRest; uint16 _lastScriptFunc; uint16 _lastScriptSub; diff --git a/engines/kyra/sequences_eob1.cpp b/engines/kyra/sequences_eob1.cpp index e835c12f0f..dcfabfeddd 100644 --- a/engines/kyra/sequences_eob1.cpp +++ b/engines/kyra/sequences_eob1.cpp @@ -94,10 +94,10 @@ int EobEngine::mainMenuLoop() { int sel = -1; do { _screen->setScreenDim(28); - _gui->setupMenu(8, 0, _mainMenuStrings, -1, 0, 0); + _gui->simpleMenu_setup(8, 0, _mainMenuStrings, -1, 0, 0); while (sel == -1 && !shouldQuit()) - sel = _gui->handleMenu(8, _mainMenuStrings, 0, -1, 0); + sel = _gui->simpleMenu_process(8, _mainMenuStrings, 0, -1, 0); } while ((sel < 0 || sel > 5) && !shouldQuit()); return sel + 1; diff --git a/engines/kyra/sequences_eob2.cpp b/engines/kyra/sequences_eob2.cpp index c926eb6934..3765ee3d92 100644 --- a/engines/kyra/sequences_eob2.cpp +++ b/engines/kyra/sequences_eob2.cpp @@ -155,10 +155,10 @@ int DarkMoonEngine::mainMenuLoop() { int sel = -1; do { _screen->setScreenDim(6); - _gui->setupMenu(6, 0, _mainMenuStrings, -1, 0, 0); + _gui->simpleMenu_setup(6, 0, _mainMenuStrings, -1, 0, 0); while (sel == -1 && !shouldQuit()) - sel = _gui->handleMenu(6, _mainMenuStrings, 0, -1, 0); + sel = _gui->simpleMenu_process(6, _mainMenuStrings, 0, -1, 0); } while ((sel < 0 || sel > 5) && !shouldQuit()); return sel + 1; diff --git a/engines/kyra/staticres_eob.cpp b/engines/kyra/staticres_eob.cpp index bf06ba66bd..a9746004bd 100644 --- a/engines/kyra/staticres_eob.cpp +++ b/engines/kyra/staticres_eob.cpp @@ -266,7 +266,7 @@ const uint8 EobCoreEngine::_hpIncrPerLevel[] = { 10, 4, 8, 6, 10, 10, 9, 10, 9, const uint8 EobCoreEngine::_numLevelsPerClass[] = { 1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 2, 2, 3, 2, 2 }; -const int8 EobCoreEngine::_classHpIncreaseType[] = { +const int8 EobCoreEngine::_characterClassType[] = { 0, -1, -1, 5, -1, -1, 4, -1, -1, 1, -1, -1, 2, -1, -1, 3, -1, -1, 0, 2, -1, 0, 3, -1, 0, 1, -1, 0, 1, 3, 3, 1, -1, 2, 3, -1, 0, 2, 1, 5, 2, -1, 2, 1, -1 @@ -381,6 +381,8 @@ void EobCoreEngine::initStaticResource() { _menuStringsMgc = _staticres->loadStrings(kEobBaseMenuStringsMgc, temp); _menuStringsPrefs = _staticres->loadStrings(kEobBaseMenuStringsPrefs, temp); _menuStringsRest2 = _staticres->loadStrings(kEobBaseMenuStringsRest2, temp); + _menuStringsRest3 = _staticres->loadStrings(kEobBaseMenuStringsRest3, temp); + _menuStringsRest4 = _staticres->loadStrings(kEobBaseMenuStringsRest4, temp); _menuStringsDefeat = _staticres->loadStrings(kEobBaseMenuStringsDefeat, temp); _menuStringsTransfer = _staticres->loadStrings(kEobBaseMenuStringsTransfer, temp); _menuStringsSpec = _staticres->loadStrings(kEobBaseMenuStringsSpec, temp); |