diff options
author | Torbjörn Andersson | 2009-07-25 13:07:50 +0000 |
---|---|---|
committer | Torbjörn Andersson | 2009-07-25 13:07:50 +0000 |
commit | 2e13d8923396b8549cb4d620a08ea386a1494ca8 (patch) | |
tree | 25a323154e7523a35f121ed4006f14257488de93 /engines | |
parent | ddd2b29beece3c03bfab11daa3530bc924388590 (diff) | |
download | scummvm-rg350-2e13d8923396b8549cb4d620a08ea386a1494ca8.tar.gz scummvm-rg350-2e13d8923396b8549cb4d620a08ea386a1494ca8.tar.bz2 scummvm-rg350-2e13d8923396b8549cb4d620a08ea386a1494ca8.zip |
Added word-wrapping to Drascula's conversation options. Fixes bug #2826607.
svn-id: r42755
Diffstat (limited to 'engines')
-rw-r--r-- | engines/drascula/converse.cpp | 23 | ||||
-rw-r--r-- | engines/drascula/drascula.h | 2 | ||||
-rw-r--r-- | engines/drascula/graphics.cpp | 21 |
3 files changed, 33 insertions, 13 deletions
diff --git a/engines/drascula/converse.cpp b/engines/drascula/converse.cpp index 4aa8ee0d9e..959e31456a 100644 --- a/engines/drascula/converse.cpp +++ b/engines/drascula/converse.cpp @@ -143,6 +143,7 @@ void DrasculaEngine::converse(int index) { game3 = kDialogOptionUnselected; char phrase1[78], phrase2[78], phrase3[78], phrase4[78]; char sound1[13], sound2[13], sound3[13], sound4[13]; + int phrase1_bottom, phrase2_bottom, phrase3_bottom, phrase4_bottom; int answer1, answer2, answer3; char buffer[256]; @@ -207,12 +208,12 @@ void DrasculaEngine::converse(int index) { updateEvents(); - print_abc_opc(phrase1, 2, game1); - print_abc_opc(phrase2, 10, game2); - print_abc_opc(phrase3, 18, game3); - print_abc_opc(phrase4, 26, kDialogOptionUnselected); + phrase1_bottom = 8 * print_abc_opc(phrase1, 2, game1); + phrase2_bottom = phrase1_bottom + 8 * print_abc_opc(phrase2, phrase1_bottom + 2, game2); + phrase3_bottom = phrase2_bottom + 8 * print_abc_opc(phrase3, phrase2_bottom + 2, game3); + phrase4_bottom = phrase3_bottom + 8 * print_abc_opc(phrase4, phrase3_bottom + 2, kDialogOptionUnselected); - if (mouseY > 0 && mouseY < 9) { + if (mouseY > 0 && mouseY < phrase1_bottom) { if (game1 == kDialogOptionClicked && _color != kColorWhite) color_abc(kColorWhite); else if (game1 != kDialogOptionClicked && _color != kColorLightGreen) @@ -226,13 +227,13 @@ void DrasculaEngine::converse(int index) { talk(phrase1, sound1); response(answer1); } - } else if (mouseY > 8 && mouseY < 17) { + } else if (mouseY > phrase1_bottom && mouseY < phrase2_bottom) { if (game2 == kDialogOptionClicked && _color != kColorWhite) color_abc(kColorWhite); else if (game2 != kDialogOptionClicked && _color != kColorLightGreen) color_abc(kColorLightGreen); - print_abc_opc(phrase2, 10, kDialogOptionSelected); + print_abc_opc(phrase2, phrase1_bottom + 2, kDialogOptionSelected); if (leftMouseButton == 1) { delay(100); @@ -240,13 +241,13 @@ void DrasculaEngine::converse(int index) { talk(phrase2, sound2); response(answer2); } - } else if (mouseY > 16 && mouseY < 25) { + } else if (mouseY > phrase2_bottom && mouseY < phrase3_bottom) { if (game3 == kDialogOptionClicked && _color != kColorWhite) color_abc(kColorWhite); else if (game3 != kDialogOptionClicked && _color != kColorLightGreen) color_abc(kColorLightGreen); - print_abc_opc(phrase3, 18, kDialogOptionSelected); + print_abc_opc(phrase3, phrase2_bottom + 2, kDialogOptionSelected); if (leftMouseButton == 1) { delay(100); @@ -254,8 +255,8 @@ void DrasculaEngine::converse(int index) { talk(phrase3, sound3); response(answer3); } - } else if (mouseY > 24 && mouseY < 33) { - print_abc_opc(phrase4, 26, kDialogOptionSelected); + } else if (mouseY > phrase3_bottom && mouseY < phrase4_bottom) { + print_abc_opc(phrase4, phrase3_bottom + 2, kDialogOptionSelected); if (leftMouseButton == 1) { delay(100); diff --git a/engines/drascula/drascula.h b/engines/drascula/drascula.h index b06a2c9d4b..1e87690bea 100644 --- a/engines/drascula/drascula.h +++ b/engines/drascula/drascula.h @@ -564,7 +564,7 @@ public: void playTalkSequence(int sequence); void doTalkSequenceCommand(TalkSequenceCommand cmd); void converse(int); - void print_abc_opc(const char *, int, int); + int print_abc_opc(const char *, int, int); void response(int); void activatePendulum(); diff --git a/engines/drascula/graphics.cpp b/engines/drascula/graphics.cpp index 76a551c980..7f1efa5d83 100644 --- a/engines/drascula/graphics.cpp +++ b/engines/drascula/graphics.cpp @@ -235,13 +235,30 @@ void DrasculaEngine::print_abc(const char *said, int screenX, int screenY) { } // for } -void DrasculaEngine::print_abc_opc(const char *said, int screenY, int game) { +int DrasculaEngine::print_abc_opc(const char *said, int screenY, int game) { int signY, letterY, letterX = 0; uint len = strlen(said); int screenX = 1; + int lines = 1; for (uint h = 0; h < len; h++) { + int wordLength; + + // Look ahead to the end of the word. + wordLength = 0; + int pos = h; + while (said[pos] && said[pos] != ' ') { + wordLength++; + pos++; + } + + if (screenX + wordLength * CHAR_WIDTH_OPC > 317) { + screenX = 0; + screenY += (CHAR_HEIGHT + 2); + lines++; + } + if (game == 1) { letterY = 6; signY = 15; @@ -281,6 +298,8 @@ void DrasculaEngine::print_abc_opc(const char *said, int screenY, int game) { screenX = screenX + CHAR_WIDTH_OPC; } + + return lines; } bool DrasculaEngine::textFitsCentered(char *text, int x) { |