aboutsummaryrefslogtreecommitdiff
path: root/queen/talk.cpp
diff options
context:
space:
mode:
authorGregory Montoir2004-04-03 17:58:58 +0000
committerGregory Montoir2004-04-03 17:58:58 +0000
commit8f6ae7973e895e40ecbf84afa95a0aa81508113b (patch)
treea29329c8cddf2c6daf3f07845033fb4266b4137e /queen/talk.cpp
parent330cf4338327a7246f693192aa5c687d3eb5be79 (diff)
downloadscummvm-rg350-8f6ae7973e895e40ecbf84afa95a0aa81508113b.tar.gz
scummvm-rg350-8f6ae7973e895e40ecbf84afa95a0aa81508113b.tar.bz2
scummvm-rg350-8f6ae7973e895e40ecbf84afa95a0aa81508113b.zip
patch #910779 (with minor tweaks), fotaq hebrew support :
- reversed button captions in journal - reversed command text in pinnacle room - reverse order of lines in dialogue chooser thanks Ori Avtalion ! svn-id: r13447
Diffstat (limited to 'queen/talk.cpp')
-rw-r--r--queen/talk.cpp62
1 files changed, 58 insertions, 4 deletions
diff --git a/queen/talk.cpp b/queen/talk.cpp
index 8bc748ef25..17421e4e2d 100644
--- a/queen/talk.cpp
+++ b/queen/talk.cpp
@@ -1185,15 +1185,69 @@ TalkSelected *Talk::talkSelected() {
int Talk::splitOption(const char *str, char optionText[5][MAX_STRING_SIZE]) {
debug(6, "Talk::splitOption(%s)", str);
- // Check to see if option fits on one line, and exit early
+ int lines;
+ memset(optionText, 0, 5 * MAX_STRING_SIZE);
if (_vm->resource()->getLanguage() == ENGLISH ||
_vm->display()->textWidth(str) <= MAX_TEXT_WIDTH) {
strcpy(optionText[0], str);
- return 1;
+ lines = 1;
+ } else if (_vm->resource()->getLanguage() == HEBREW) {
+ lines = splitOptionHebrew(str, optionText);
+ } else {
+ lines = splitOptionDefault(str, optionText);
}
+ return lines;
+}
+int Talk::splitOptionHebrew(const char *str, char optionText[5][MAX_STRING_SIZE]) {
+ char tmpString[MAX_STRING_SIZE] = "";
+ uint16 len = 0;
+ uint16 spaceCharWidth = _vm->display()->textWidth(" ");
+ uint16 width = 0;
+ uint16 optionLines = 0;
+ uint16 maxTextLen = MAX_TEXT_WIDTH;
+ char *p = strchr(str, '\0');
+ while (p != str - 1) {
+ while (*p != ' ' && p != str - 1) {
+ --p;
+ ++len;
+ }
+ if (p != str - 1) {
+ uint16 wordWidth = _vm->display()->textWidth(p, len);
+ width += wordWidth;
+ if (width > maxTextLen) {
+ ++optionLines;
+ strncpy(optionText[optionLines], p, len);
+ optionText[optionLines][len] = '\0';
+ width = wordWidth;
+ maxTextLen = MAX_TEXT_WIDTH - OPTION_TEXT_MARGIN;
+ } else {
+ strcpy(tmpString, optionText[optionLines]);
+ strncpy(optionText[optionLines], p, len);
+ optionText[optionLines][len] = '\0';
+ strcat(optionText[optionLines], tmpString);
+ }
+ --p;
+ len = 1;
+ width += spaceCharWidth;
+ } else {
+ if (len > 1) {
+ if (width + _vm->display()->textWidth(p + 1, len) > maxTextLen) {
+ ++optionLines;
+ }
+ strcpy(tmpString, optionText[optionLines]);
+ strncpy(optionText[optionLines], p + 1, len);
+ optionText[optionLines][len] = '\0';
+ strcat(optionText[optionLines], tmpString);
+ }
+ ++optionLines;
+ }
+ }
+ return optionLines;
+}
+
+int Talk::splitOptionDefault(const char *str, char optionText[5][MAX_STRING_SIZE]) {
// Split up multiple line option at closest space character
- memset(optionText, 0, 5 * MAX_STRING_SIZE);
uint16 spaceCharWidth = _vm->display()->textWidth(" ");
uint16 width = 0;
uint16 optionLines = 0;
@@ -1205,7 +1259,7 @@ int Talk::splitOption(const char *str, char optionText[5][MAX_STRING_SIZE]) {
uint16 len = p - str;
uint16 wordWidth = _vm->display()->textWidth(str, len);
width += wordWidth;
- if (width> maxTextLen) {
+ if (width > maxTextLen) {
++optionLines;
strncpy(optionText[optionLines], str, len + 1);
width = wordWidth;