diff options
author | Gregory Montoir | 2004-01-10 19:55:54 +0000 |
---|---|---|
committer | Gregory Montoir | 2004-01-10 19:55:54 +0000 |
commit | 615e0df8da215eebb85de1064e2d7a44a38ffb3e (patch) | |
tree | edfb256a76bcb79240cabc7e22a83d00b7693aba | |
parent | 3589c2f776a3b4716f6855403ed7ed6b7626ed65 (diff) | |
download | scummvm-rg350-615e0df8da215eebb85de1064e2d7a44a38ffb3e.tar.gz scummvm-rg350-615e0df8da215eebb85de1064e2d7a44a38ffb3e.tar.bz2 scummvm-rg350-615e0df8da215eebb85de1064e2d7a44a38ffb3e.zip |
enabled arrows in dialogue (non english versions)
svn-id: r12306
-rw-r--r-- | queen/display.cpp | 15 | ||||
-rw-r--r-- | queen/display.h | 1 | ||||
-rw-r--r-- | queen/talk.cpp | 69 | ||||
-rw-r--r-- | queen/talk.h | 2 |
4 files changed, 68 insertions, 19 deletions
diff --git a/queen/display.cpp b/queen/display.cpp index 0be40792fc..391db8def0 100644 --- a/queen/display.cpp +++ b/queen/display.cpp @@ -898,12 +898,17 @@ int Display::textCenterX(const char *text) const { uint16 Display::textWidth(const char *text) const { - uint16 len = 0; - while (*text) { - len += _charWidth[ (uint8)*text ]; - ++text; + return textWidth(text, strlen(text)); +} + + +uint16 Display::textWidth(const char *text, uint16 len) const { + assert(len <= strlen(text)); + uint16 width = 0; + for (uint16 i = 0; i < len; ++i) { + width += _charWidth[ (uint8)text[i] ]; } - return len; + return width; } diff --git a/queen/display.h b/queen/display.h index 30822cb361..46df760791 100644 --- a/queen/display.h +++ b/queen/display.h @@ -98,6 +98,7 @@ public: void textColor(uint16 y, uint8 color) { _texts[y].color = color; } int textCenterX(const char *text) const; uint16 textWidth(const char *text) const; + uint16 textWidth(const char *text, uint16 len) const; void drawChar(uint16 x, uint16 y, uint8 color, const uint8 *chr); void drawText(uint16 x, uint16 y, uint8 color, const char *text, bool outlined = true); void drawBox(int16 x1, int16 y1, int16 x2, int16 y2, uint8 col); diff --git a/queen/talk.cpp b/queen/talk.cpp index 3e448d97ef..b7852bc18a 100644 --- a/queen/talk.cpp +++ b/queen/talk.cpp @@ -1231,19 +1231,48 @@ TalkSelected *Talk::talkSelected() { int Talk::splitOption(const char *str, char optionText[5][MAX_STRING_SIZE]) { - //debug(6, "splitOption(\"%s\")", str); +// debug(0, "splitOption(\"%s\") width=%d", str, _vm->display()->textWidth(str)); // Check to see if option fits on one line, and exit early - /* XXX if (_vm->logic()->language() == ENGLISH || textWidth(str) <= MAX_TEXT_WIDTH)*/ { + if (_vm->resource()->getLanguage() == ENGLISH || + _vm->display()->textWidth(str) <= MAX_TEXT_WIDTH) { strcpy(optionText[0], str); return 1; } - abort(); - // Split up multiple line option at closest space character - // int optionLines = 0; + memset(optionText, 0, 5 * MAX_STRING_SIZE); + uint16 width = 0; + uint16 optionLines = 0; + uint16 maxTextLen = MAX_TEXT_WIDTH; + const char *p = str; + while (p) { + p = strchr(str, ' '); + if (p) { + uint16 len = p - str + 1; + width += _vm->display()->textWidth(str, len); + if (width > maxTextLen) { + strncat(optionText[optionLines], str, len - 1); +//debug(0, "1optionLines=%d optionText='%s'", optionLines, optionText[optionLines]); + ++optionLines; + width = 0; + maxTextLen = MAX_TEXT_WIDTH - 16; // compensate left margin + } else { + strncat(optionText[optionLines], str, len); +//debug(0,"2optionLines=%d optionText='%s' width=%d", optionLines, optionText[optionLines], width); + } +//debug(0, "3str=%s p+1=%s", str, p+1); + str = p + 1; + } + } +//debug(0, "str='%s'", str); + width += _vm->display()->textWidth(str); + if (width > maxTextLen) { + ++optionLines; + } + strcat(optionText[optionLines], str); + return optionLines + 1; } static char *removeStar(char *str) { @@ -1370,17 +1399,34 @@ int16 Talk::selectSentence() { zone = _vm->grid()->findZoneForPos(GS_PANEL, _vm->input()->mousePosX(), _vm->input()->mousePosY()); - if (5 == zone || 6 == zone) { - // XXX Arrow zones - debug(6, "Arrow zones"); + int mouseButton = _vm->input()->mouseButton(); + _vm->input()->clearMouseButton(); + + if (ARROW_ZONE_UP == zone || ARROW_ZONE_DOWN == zone) { + if (oldZone > 0) { + int16 y; + const Box *b = _vm->grid()->zone(GS_PANEL, oldZone); + for (y = b->y1; y < b->y2; y += 10) + _vm->display()->textColor(150 + y, INK_TALK_NORMAL); + oldZone = 0; + } + if (mouseButton != 0) { + if (zone == ARROW_ZONE_UP && arrowBobUp->active) { + startOption--; + } else if (zone == ARROW_ZONE_DOWN && arrowBobDown->active) { + startOption++; + } + } + rezone = true; + break; } else { if (oldZone != zone) { // Changed zone, change text colors int y; - /*debug(6, "Changed zone. oldZone = %i, zone = %i", - oldZone, zone);*/ + debug(0, "Changed zone. oldZone = %i, zone = %i", + oldZone, zone); if (zone > 0) { const Box *b = _vm->grid()->zone(GS_PANEL, zone); @@ -1399,9 +1445,6 @@ int16 Talk::selectSentence() { } - int mouseButton = _vm->input()->mouseButton(); - _vm->input()->clearMouseButton(); - Verb v = _vm->input()->keyVerb(); if (v >= VERB_DIGIT_FIRST && v <= VERB_DIGIT_LAST) { int n = v - VERB_DIGIT_FIRST + 1; diff --git a/queen/talk.h b/queen/talk.h index 2f0867c229..1036e99bc1 100644 --- a/queen/talk.h +++ b/queen/talk.h @@ -224,7 +224,7 @@ private: int state, int faceDirection); // FIND_SACTION - static int splitOption(const char *str, char optionText[5][MAX_STRING_SIZE]); + int splitOption(const char *str, char optionText[5][MAX_STRING_SIZE]); }; |