From 1e54e2471f3ef249f9328693b543526c4e7459ed Mon Sep 17 00:00:00 2001 From: Oliver Kiehl Date: Fri, 30 Jul 2004 20:05:24 +0000 Subject: fix subtitle alignment svn-id: r14371 --- simon/simon.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'simon') 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; -- cgit v1.2.3