[Scummvm-cvs-logs] CVS: scummvm/queen display.cpp,1.51,1.52 display.h,1.37,1.38 talk.cpp,1.76,1.77 talk.h,1.27,1.28
Gregory Montoir
cyx at users.sourceforge.net
Sat Jan 10 11:57:01 CET 2004
Update of /cvsroot/scummvm/scummvm/queen
In directory sc8-pr-cvs1:/tmp/cvs-serv26537/queen
Modified Files:
display.cpp display.h talk.cpp talk.h
Log Message:
enabled arrows in dialogue (non english versions)
Index: display.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/display.cpp,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -d -r1.51 -r1.52
--- display.cpp 10 Jan 2004 12:56:07 -0000 1.51
+++ display.cpp 10 Jan 2004 19:55:54 -0000 1.52
@@ -898,12 +898,17 @@
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;
}
Index: display.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/display.h,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- display.h 9 Jan 2004 15:14:15 -0000 1.37
+++ display.h 10 Jan 2004 19:55:54 -0000 1.38
@@ -98,6 +98,7 @@
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);
Index: talk.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/talk.cpp,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -d -r1.76 -r1.77
--- talk.cpp 10 Jan 2004 16:03:41 -0000 1.76
+++ talk.cpp 10 Jan 2004 19:55:54 -0000 1.77
@@ -1231,19 +1231,48 @@
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 @@
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);
@@ -1398,9 +1444,6 @@
}
}
-
- int mouseButton = _vm->input()->mouseButton();
- _vm->input()->clearMouseButton();
Verb v = _vm->input()->keyVerb();
if (v >= VERB_DIGIT_FIRST && v <= VERB_DIGIT_LAST) {
Index: talk.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/talk.h,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- talk.h 6 Jan 2004 12:45:29 -0000 1.27
+++ talk.h 10 Jan 2004 19:55:54 -0000 1.28
@@ -224,7 +224,7 @@
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]);
};
More information about the Scummvm-git-logs
mailing list