aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver Kiehl2004-07-30 20:05:24 +0000
committerOliver Kiehl2004-07-30 20:05:24 +0000
commit1e54e2471f3ef249f9328693b543526c4e7459ed (patch)
treeea283b33ad8ec711032dff377140b8f8468a8373
parent9ae69f7590e5dad52f7a2ff5e4c4c13a2f52f044 (diff)
downloadscummvm-rg350-1e54e2471f3ef249f9328693b543526c4e7459ed.tar.gz
scummvm-rg350-1e54e2471f3ef249f9328693b543526c4e7459ed.tar.bz2
scummvm-rg350-1e54e2471f3ef249f9328693b543526c4e7459ed.zip
fix subtitle alignment
svn-id: r14371
-rw-r--r--simon/simon.cpp22
1 files changed, 17 insertions, 5 deletions
diff --git a/simon/simon.cpp b/simon/simon.cpp
index 8424996d1a..5548b5714c 100644
--- a/simon/simon.cpp
+++ b/simon/simon.cpp
@@ -4183,11 +4183,12 @@ void SimonEngine::talk_with_text(uint vga_sprite_id, uint color, const char *str
char *convertedString2 = convertedString;
int16 height, len_div_3;
int stringLength = strlen(string);
- int pos, padding, lettersPerRow;
+ int pos, padding, lettersPerRow, lettersPerRowJustified;
const int textHeight = 10;
height = textHeight;
lettersPerRow = width / 6;
+ lettersPerRowJustified = stringLength / (stringLength / lettersPerRow + 1) + 1;
len_div_3 = (stringLength + 3) / 3;
if (!(_game & GF_SIMON2) && (_game & GF_TALKIE)) {
@@ -4205,14 +4206,25 @@ void SimonEngine::talk_with_text(uint vga_sprite_id, uint color, const char *str
assert(stringLength > 0);
while (stringLength > 0) {
if (stringLength > lettersPerRow) {
- pos = lettersPerRow;
- while (string[pos] != ' ' && pos > 0)
- pos--;
+ int removeLastWord = 0;
+ if (lettersPerRow > lettersPerRowJustified) {
+ pos = lettersPerRowJustified;
+ while (string[pos] != ' ')
+ pos++;
+ if (pos > lettersPerRow)
+ removeLastWord = 1;
+ }
+ if (lettersPerRow <= lettersPerRowJustified || removeLastWord) {
+ pos = lettersPerRow;
+ while (string[pos] != ' ' && pos > 0)
+ pos--;
+ }
height += textHeight;
y -= textHeight;
} else
pos = stringLength;
- padding = (lettersPerRow - pos) / 2;
+ padding = (lettersPerRow - pos) % 2 ?
+ (lettersPerRow - pos) / 2 + 1 : (lettersPerRow - pos) / 2;
while (padding--)
*convertedString2++ = ' ';
stringLength -= pos;