diff options
author | Nicola Mettifogo | 2007-03-18 08:58:41 +0000 |
---|---|---|
committer | Nicola Mettifogo | 2007-03-18 08:58:41 +0000 |
commit | 88ce9c83bde37aa7b40735f98ef0b80512bb0924 (patch) | |
tree | c81a72e7ca229fbe263c4c80afbd39fcb41c4669 | |
parent | ecf976b5ea3f91a476eb71766643fbf442a2e1f8 (diff) | |
download | scummvm-rg350-88ce9c83bde37aa7b40735f98ef0b80512bb0924.tar.gz scummvm-rg350-88ce9c83bde37aa7b40735f98ef0b80512bb0924.tar.bz2 scummvm-rg350-88ce9c83bde37aa7b40735f98ef0b80512bb0924.zip |
broke down huge runDialogue in more manageable chunks
svn-id: r26192
-rw-r--r-- | engines/parallaction/dialogue.cpp | 331 |
1 files changed, 178 insertions, 153 deletions
diff --git a/engines/parallaction/dialogue.cpp b/engines/parallaction/dialogue.cpp index 1d2e3f8c7d..5acafac4af 100644 --- a/engines/parallaction/dialogue.cpp +++ b/engines/parallaction/dialogue.cpp @@ -219,6 +219,178 @@ void freeDialogue(Dialogue *d) { } +uint16 askDialoguePassword(Dialogue *v60, StaticCnv *v48) { + debugC(1, kDebugDialogue, "checkDialoguePassword()"); + + char password[100]; + uint16 passwordLen = 0; + + while (true) { + strcpy(password, "......."); + _vm->_gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront); + + Common::Rect r(_answerBalloonW[0], _answerBalloonH[0]); + r.moveTo(_answerBalloonX[0], _answerBalloonY[0]); + + _vm->_gfx->drawBalloon(r, 1); + + _vm->_gfx->displayWrappedString( + v60->_answers[0], + _answerBalloonX[0], + _answerBalloonY[0], + MAX_BALLOON_WIDTH, + 3 + ); + + _vm->_gfx->flatBlitCnv( + v48, + ANSWER_CHARACTER_X, + ANSWER_CHARACTER_Y, + Gfx::kBitFront, + v48->_data1 + ); + + _vm->_gfx->displayBalloonString( + _answerBalloonX[0] + 5, + _answerBalloonY[0] + _answerBalloonH[0] - 15, + "> ", + 0 + ); + + Common::Event e; + + while (e.kbd.ascii != 0xD && passwordLen < MAX_PASSWORD_LENGTH) { + + // FIXME: see comment for updateInput() + if (!g_system->getEventManager()->pollEvent(e)) continue; + if (e.type != Common::EVENT_KEYDOWN) continue; + if (e.type != Common::EVENT_QUIT) g_system->quit(); + if (!isdigit(e.kbd.ascii)) continue; + + password[passwordLen] = e.kbd.ascii; + passwordLen++; + password[passwordLen] = '\0'; + + _vm->_gfx->displayBalloonString( + _answerBalloonX[0] + 5, + _answerBalloonY[0] + _answerBalloonH[0] - 15, + password, + 0 + ); + + g_system->delayMillis(20); + } + + if ((!scumm_stricmp(_vm->_characterName, _doughName) && !scumm_strnicmp(password, "1732461", 7)) || + (!scumm_stricmp(_vm->_characterName, _donnaName) && !scumm_strnicmp(password, "1622", 4)) || + (!scumm_stricmp(_vm->_characterName, _dinoName) && !scumm_strnicmp(password, "179", 3))) { + + break; + + } + + } + + return 0; + +} + +bool _askPassword; + +bool displayAnswer(Dialogue *v60, uint16 _si) { + + uint32 v28 = _localFlags[_vm->_currentLocationIndex]; + if (v60->_yesFlags[_si] & kFlagsGlobal) { + v28 = _commandFlags | kFlagsGlobal; + } + + // display suitable answers + if (((v60->_yesFlags[_si] & v28) == v60->_yesFlags[_si]) && ((v60->_noFlags[_si] & ~v28) == v60->_noFlags[_si])) { + + _vm->_gfx->getStringExtent( + v60->_answers[_si], + MAX_BALLOON_WIDTH, + &_answerBalloonW[_si], + &_answerBalloonH[_si] + ); + + debugC(1, kDebugDialogue, "runDialogue: showing answer #%i '%s'", + _si, + v60->_answers[_si] + ); + + Common::Rect r(_answerBalloonW[_si], _answerBalloonH[_si]); + r.moveTo(_answerBalloonX[_si], _answerBalloonY[_si]); + + _vm->_gfx->drawBalloon(r, 1); + + _answerBalloonY[_si+1] = 10 + _answerBalloonY[_si] + _answerBalloonH[_si]; + + _askPassword = _vm->_gfx->displayWrappedString( + v60->_answers[_si], + _answerBalloonX[_si], + _answerBalloonY[_si], + MAX_BALLOON_WIDTH, + 3 + ); + + debugC(1, kDebugDialogue, "runDialogue: answer #%i shown at (%i, %i)+(%i, %i)", + _si, + _answerBalloonX[_si], + _answerBalloonY[_si], + _answerBalloonW[_si], + _answerBalloonH[_si] + ); + + + return true; + } + + return false; + +} + +void displayQuestion(Dialogue *v60, StaticCnv *v5C) { + + int16 question_width = 0, question_height = 0; + + // display Question if any + if (scumm_stricmp(v60->_text, "NULL")) { + debugC(1, kDebugDialogue, "runDialogue: showing question '%s'", v60->_text); + + _vm->_gfx->flatBlitCnv( + v5C, + QUESTION_CHARACTER_X, + QUESTION_CHARACTER_Y, + Gfx::kBitFront, + v5C->_data1 + ); + + _vm->_gfx->getStringExtent( + v60->_text, + MAX_BALLOON_WIDTH, + &question_width, + &question_height + ); + + Common::Rect r(question_width, question_height); + r.moveTo(QUESTION_BALLOON_X, QUESTION_BALLOON_Y); + + _vm->_gfx->drawBalloon(r, v60->_mood & 0x10); + + _vm->_gfx->displayWrappedString( + v60->_text, + QUESTION_BALLOON_X, + QUESTION_BALLOON_Y, + MAX_BALLOON_WIDTH, + 0 + ); + + waitUntilLeftClick(); + _vm->_gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront); + } + +} void runDialogue(SpeakData *data) { debugC(1, kDebugDialogue, "runDialogue: starting dialogue '%s'", data->_name); @@ -253,8 +425,7 @@ void runDialogue(SpeakData *data) { v48._height = _vm->_char._talk._height; bool displayedAnswers = false; - int16 question_width = 0, question_height = 0; - bool askPassword = false; + _askPassword = false; uint16 _di = 0; Command *v34 = NULL; @@ -266,41 +437,7 @@ void runDialogue(SpeakData *data) { v48._data0 = _vm->_char._talk._array[0]; v48._data1 = NULL; // _talk.field_8[0]; - // display Question if any - if (scumm_stricmp(v60->_text, "NULL")) { - debugC(1, kDebugDialogue, "runDialogue: showing question '%s'", v60->_text); - - _vm->_gfx->flatBlitCnv( - &v5C, - QUESTION_CHARACTER_X, - QUESTION_CHARACTER_Y, - Gfx::kBitFront, - v5C._data1 - ); - - _vm->_gfx->getStringExtent( - v60->_text, - MAX_BALLOON_WIDTH, - &question_width, - &question_height - ); - - Common::Rect r(question_width, question_height); - r.moveTo(QUESTION_BALLOON_X, QUESTION_BALLOON_Y); - - _vm->_gfx->drawBalloon(r, v60->_mood & 0x10); - - _vm->_gfx->displayWrappedString( - v60->_text, - QUESTION_BALLOON_X, - QUESTION_BALLOON_Y, - MAX_BALLOON_WIDTH, - 0 - ); - - waitUntilLeftClick(); - _vm->_gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront); - } + displayQuestion(v60, &v5C); if (v60->_answers[0] == NULL) break; @@ -313,51 +450,10 @@ void runDialogue(SpeakData *data) { uint16 _si = 0; while (_si < 5 && v60->_answers[_si]) { - uint32 v28 = _localFlags[_vm->_currentLocationIndex]; - if (v60->_yesFlags[_si] & kFlagsGlobal) { - v28 = _commandFlags | kFlagsGlobal; - } - - // display suitable answers - if (((v60->_yesFlags[_si] & v28) == v60->_yesFlags[_si]) && ((v60->_noFlags[_si] & ~v28) == v60->_noFlags[_si])) { - - _vm->_gfx->getStringExtent( - v60->_answers[_si], - MAX_BALLOON_WIDTH, - &_answerBalloonW[_si], - &_answerBalloonH[_si] - ); - - debugC(1, kDebugDialogue, "runDialogue: showing answer #%i '%s'", - _si, - v60->_answers[_si] - ); - - Common::Rect r(_answerBalloonW[_si], _answerBalloonH[_si]); - r.moveTo(_answerBalloonX[_si], _answerBalloonY[_si]); - - _vm->_gfx->drawBalloon(r, 1); - - _answerBalloonY[_si+1] = 10 + _answerBalloonY[_si] + _answerBalloonH[_si]; - - askPassword = _vm->_gfx->displayWrappedString( - v60->_answers[_si], - _answerBalloonX[_si], - _answerBalloonY[_si], - MAX_BALLOON_WIDTH, - 3 - ); - - debugC(1, kDebugDialogue, "runDialogue: answer #%i shown at (%i, %i)+(%i, %i)", - _si, - _answerBalloonX[_si], - _answerBalloonY[_si], - _answerBalloonW[_si], - _answerBalloonH[_si] - ); - + if (displayAnswer(v60, _si)) { displayedAnswers = true; + } else { debugC(1, kDebugDialogue, "runDialogue: skipping answer #%i", _si); @@ -385,7 +481,7 @@ void runDialogue(SpeakData *data) { debugC(1, kDebugDialogue, "runDialogue: answering face shown"); - if (askPassword == false) { + if (_askPassword == false) { debugC(1, kDebugDialogue, "runDialogue: waiting for user to select answer"); _di = selectAnswer(v60, &v48); @@ -393,78 +489,7 @@ void runDialogue(SpeakData *data) { } else { - char password[100]; - uint16 passwordLen = 0; - - debugC(1, kDebugDialogue, "runDialogue: asking password"); - - while (askPassword == true) { - strcpy(password, "......."); - _vm->_gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront); - - Common::Rect r(_answerBalloonW[0], _answerBalloonH[0]); - r.moveTo(_answerBalloonX[0], _answerBalloonY[0]); - - _vm->_gfx->drawBalloon(r, 1); - - _vm->_gfx->displayWrappedString( - v60->_answers[0], - _answerBalloonX[0], - _answerBalloonY[0], - MAX_BALLOON_WIDTH, - 3 - ); - - _vm->_gfx->flatBlitCnv( - &v48, - ANSWER_CHARACTER_X, - ANSWER_CHARACTER_Y, - Gfx::kBitFront, - v48._data1 - ); - - _vm->_gfx->displayBalloonString( - _answerBalloonX[0] + 5, - _answerBalloonY[0] + _answerBalloonH[0] - 15, - "> ", - 0 - ); - - Common::Event e; - - while (e.kbd.ascii != 0xD && passwordLen < MAX_PASSWORD_LENGTH) { - - // FIXME: see comment for updateInput() - if (!g_system->getEventManager()->pollEvent(e)) continue; - if (e.type != Common::EVENT_KEYDOWN) continue; - if (e.type != Common::EVENT_QUIT) g_system->quit(); - if (!isdigit(e.kbd.ascii)) continue; - - password[passwordLen] = e.kbd.ascii; - passwordLen++; - password[passwordLen] = '\0'; - - _vm->_gfx->displayBalloonString( - _answerBalloonX[0] + 5, - _answerBalloonY[0] + _answerBalloonH[0] - 15, - password, - 0 - ); - - g_system->delayMillis(20); - } - - if ((!scumm_stricmp(_vm->_characterName, _doughName) && !scumm_strnicmp(password, "1732461", 7)) || - (!scumm_stricmp(_vm->_characterName, _donnaName) && !scumm_strnicmp(password, "1622", 4)) || - (!scumm_stricmp(_vm->_characterName, _dinoName) && !scumm_strnicmp(password, "179", 3))) { - - askPassword = false; - - } - - _di = 0; - - } + _di = askDialoguePassword(v60, &v48); } |