diff options
author | lukaslw | 2014-06-18 02:32:20 +0200 |
---|---|---|
committer | lukaslw | 2014-06-22 20:09:15 +0200 |
commit | f00eeeda919bd636456b548c595e2062fcad37ef (patch) | |
tree | 9dc0cf35f97a4cecfa674609fa10e6fce365bbf4 | |
parent | 1e1d3044be4a230f8b62ebe4fbda934743bfe442 (diff) | |
download | scummvm-rg350-f00eeeda919bd636456b548c595e2062fcad37ef.tar.gz scummvm-rg350-f00eeeda919bd636456b548c595e2062fcad37ef.tar.bz2 scummvm-rg350-f00eeeda919bd636456b548c595e2062fcad37ef.zip |
PRINCE: Hero talking - dialog option choosing
-rw-r--r-- | engines/prince/hero.cpp | 179 | ||||
-rw-r--r-- | engines/prince/prince.cpp | 77 | ||||
-rw-r--r-- | engines/prince/prince.h | 4 |
3 files changed, 154 insertions, 106 deletions
diff --git a/engines/prince/hero.cpp b/engines/prince/hero.cpp index 3293c9c697..2194817fa9 100644 --- a/engines/prince/hero.cpp +++ b/engines/prince/hero.cpp @@ -621,105 +621,106 @@ void Hero::rotateHero() { void Hero::showHero() { if (_visible) { - // Is he talking? - if (_talkTime == 0) { //? - // Scale of hero - selectZoom(); - switch (_state) { - case STAY: - //if(OptionsFlag == false) { - //if(OpcodePC == null) { - _boredomTime++; - if (_boredomTime == 200) { // 140 for second hero - _boredomTime = 0; - _state = BORE; - } - switch (_lastDirection) { - case LEFT: - _moveSetType = Move_SL; - break; - case RIGHT: - _moveSetType = Move_SR; - break; - case UP: - _moveSetType = Move_SU; - break; - case DOWN: - _moveSetType = Move_SD; - break; - } + if (_talkTime != 0) { + _talkTime--; + if (_talkTime == 0) { + _state = STAY; // test this + } + } + // Scale of hero + selectZoom(); + switch (_state) { + case STAY: + //if(OptionsFlag == false) { + //if(OpcodePC == null) { + _boredomTime++; + if (_boredomTime == 200) { // 140 for second hero + _boredomTime = 0; + _state = BORE; + } + switch (_lastDirection) { + case LEFT: + _moveSetType = Move_SL; break; - case TURN: - /* - if(_lastDirection == _destDirection) { - _state = STAY; - } else { - _frame = 0; - rotateHero(); - _lastDirection = _destDirection; - } - */ + case RIGHT: + _moveSetType = Move_SR; break; - case MOVE: - switch (_lastDirection) { - case LEFT: - _moveSetType = Move_ML; - break; - case RIGHT: - _moveSetType = Move_MR; - break; - case UP: - _moveSetType = Move_MU; - break; - case DOWN: - _moveSetType = Move_MD; - break; - } + case UP: + _moveSetType = Move_SU; break; - case BORE: - //if (_direction == UP) { - switch (_boreNum) { - case 0: - _moveSetType = Move_BORED1; - break; - case 1: - _moveSetType = Move_BORED2; - break; - } - if (_phase == _moveSet[_moveSetType]->getFrameCount() - 1) { - _boreNum = _vm->_randomSource.getRandomNumber(1); // rand one of two 'bored' animation - _lastDirection = DOWN; - _state = STAY; - } + case DOWN: + _moveSetType = Move_SD; + break; + } + break; + case TURN: + /* + if(_lastDirection == _destDirection) { + _state = STAY; + } else { + _frame = 0; + rotateHero(); + _lastDirection = _destDirection; + } + */ + break; + case MOVE: + switch (_lastDirection) { + case LEFT: + _moveSetType = Move_ML; break; - case SPEC: - //specialAnim(); + case RIGHT: + _moveSetType = Move_MR; break; - case TALK: - switch (_lastDirection) { - case LEFT: - _moveSetType = Move_TL; - break; - case RIGHT: - _moveSetType = Move_TR; - break; - case UP: - _moveSetType = Move_TU; - break; - case DOWN: - _moveSetType = Move_TD; - break; - } + case UP: + _moveSetType = Move_MU; break; - case TRAN: + case DOWN: + _moveSetType = Move_MD; break; - case RUN: + } + break; + case BORE: + //if (_direction == UP) { + switch (_boreNum) { + case 0: + _moveSetType = Move_BORED1; break; - case DMOVE: + case 1: + _moveSetType = Move_BORED2; break; } - } else { - _talkTime--; // o ile? + if (_phase == _moveSet[_moveSetType]->getFrameCount() - 1) { + _boreNum = _vm->_randomSource.getRandomNumber(1); // rand one of two 'bored' animation + _lastDirection = DOWN; + _state = STAY; + } + break; + case SPEC: + //specialAnim(); + break; + case TALK: + switch (_lastDirection) { + case LEFT: + _moveSetType = Move_TL; + break; + case RIGHT: + _moveSetType = Move_TR; + break; + case UP: + _moveSetType = Move_TU; + break; + case DOWN: + _moveSetType = Move_TD; + break; + } + break; + case TRAN: + break; + case RUN: + break; + case DMOVE: + break; } showHeroAnimFrame(); } else { diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp index f75552d5d3..ab3c294cae 100644 --- a/engines/prince/prince.cpp +++ b/engines/prince/prince.cpp @@ -710,13 +710,13 @@ void PrinceEngine::keyHandler(Common::Event event) { break; case Common::KEYCODE_k: _mainHero->_middleY += 5; - addInvObj(); + //addInvObj(); break; case Common::KEYCODE_j: _mainHero->_middleX -= 5; - _flags->setFlagValue(Flags::CURSEBLINK, 1); - addInvObj(); - _flags->setFlagValue(Flags::CURSEBLINK, 0); + //_flags->setFlagValue(Flags::CURSEBLINK, 1); + //addInvObj(); + //_flags->setFlagValue(Flags::CURSEBLINK, 0); break; case Common::KEYCODE_l: _mainHero->_middleX += 5; @@ -843,6 +843,18 @@ void PrinceEngine::printAt(uint32 slot, uint8 color, const char *s, uint16 x, ui text._color = color; } +int PrinceEngine::calcText(const char *s) { + int lines = 1; + while (*s) { + if (*s == '\n') { + lines++; + } + s++; + } + return lines; + //time = lines * 30 +} + uint32 PrinceEngine::getTextWidth(const char *s) { uint16 textW = 0; while (*s) { @@ -855,21 +867,20 @@ uint32 PrinceEngine::getTextWidth(const char *s) { void PrinceEngine::showTexts(Graphics::Surface *screen) { for (uint32 slot = 0; slot < MAXTEXTS; ++slot) { Text& text = _textSlots[slot]; - if (!text._str && !text._time) + if (!text._str && !text._time) { continue; + } Common::Array<Common::String> lines; _font->wordWrapText(text._str, _graph->_frontScreen->w, lines); - for (uint8 i = 0; i < lines.size(); ++i) { - _font->drawString( - screen, - lines[i], - text._x - getTextWidth(lines[i].c_str())/2, - text._y - (lines.size() - i) * (_font->getFontHeight()), - screen->w, - text._color - ); + for (uint8 i = 0; i < lines.size(); i++) { + int x = text._x - getTextWidth(lines[i].c_str()) / 2; + int y = text._y - (lines.size() - i) * (_font->getFontHeight()); + if (y < 0) { + y = 0; + } + _font->drawString(screen, lines[i], x, y, screen->w, text._color); } text._time--; @@ -1974,6 +1985,7 @@ void PrinceEngine::runDialog(Common::Array<DialogLine> &dialogData) { Common::Point mousePos = _system->getEventManager()->getMousePos(); int dialogSelected = -1; + int dialogSelectedText = -1; for (uint i = 0; i < dialogData.size(); i++) { int actualColor = _dialogColor1; @@ -1985,6 +1997,7 @@ void PrinceEngine::runDialog(Common::Array<DialogLine> &dialogData) { if (dialogOption.contains(mousePos)) { actualColor = _dialogColor2; dialogSelected = dialogData[i]._nr; + dialogSelectedText = i; } for (uint j = 0; j < lines.size(); j++) { @@ -2006,7 +2019,7 @@ void PrinceEngine::runDialog(Common::Array<DialogLine> &dialogData) { case Common::EVENT_MOUSEMOVE: break; case Common::EVENT_LBUTTONDOWN: - dialogLeftMouseButton(dialogSelected); + dialogLeftMouseButton(dialogSelected, dialogData[dialogSelectedText]._line.c_str()); return; break; case Common::EVENT_RBUTTONDOWN: @@ -2033,12 +2046,44 @@ void PrinceEngine::runDialog(Common::Array<DialogLine> &dialogData) { delete _dialogImage; } -void PrinceEngine::dialogLeftMouseButton(int dialogSelected) { +void PrinceEngine::dialogLeftMouseButton(int dialogSelected, const char *s) { if (dialogSelected != -1) { //TODO @@showa_dialoga: + talkHero(0, s); } } +void PrinceEngine::talkHero(int slot, const char *s) { + // heroSlot = textSlot + + Text &text = _textSlots[slot]; + int lines = calcText(s); + int time = lines * 30; + int x, y; + //int textSkip = -2; // global? + + if (slot == 0) { + text._color = 0xFF00DC; // test this + _mainHero->_state = Hero::TALK; + _mainHero->_talkTime = time; + x = _mainHero->_middleX; + y = _mainHero->_middleY - _mainHero->_scaledFrameYSize - 10; + //y -= (_font->getFontHeight() + textSkip) * lines; // need this? + } else { + //text._color = _secondHero->color; + text._color = 0xFF00DC; // test this ! + _secondHero->_state = Hero::TALK; + _secondHero->_talkTime = time; + x = _secondHero->_middleX; + y = _secondHero->_middleY - _secondHero->_currHeight - 10; // set currHeight + //y -= (_font->getFontHeight() + textSkip) * lines; // need this? + } + text._time = time; // changed by SETSPECVOICE? + text._str = s; + text._x = x; + text._y = y; +} + // Test void PrinceEngine::testDialog() { Common::Array<DialogLine> tempDialogBox; diff --git a/engines/prince/prince.h b/engines/prince/prince.h index a9b074e859..5e04eecb1c 100644 --- a/engines/prince/prince.h +++ b/engines/prince/prince.h @@ -249,6 +249,7 @@ public: void changeCursor(uint16 curId); void printAt(uint32 slot, uint8 color, const char *s, uint16 x, uint16 y); + int calcText(const char *s); static const uint8 MAXTEXTS = 32; Text _textSlots[MAXTEXTS]; @@ -345,7 +346,7 @@ public: void rightMouseButton(); void inventoryLeftMouseButton(); void inventoryRightMouseButton(); - void dialogLeftMouseButton(int dialogSelected); + void dialogLeftMouseButton(int dialogSelected, const char *s); int _dialogWidth; int _dialogHeight; @@ -356,6 +357,7 @@ public: void createDialogBox(Common::Array<DialogLine> &dialogData); void runDialog(Common::Array<DialogLine> &dialogData); + void talkHero(int slot, const char *s); void testDialog(); int testAnimNr; |