aboutsummaryrefslogtreecommitdiff
path: root/scumm
diff options
context:
space:
mode:
authorPaweł Kołodziejski2002-11-21 17:50:14 +0000
committerPaweł Kołodziejski2002-11-21 17:50:14 +0000
commit897f1bb479a5b5c73ebf9ef28012bc7624009ef9 (patch)
treeb542fdeaa91d0e164c05e82f10936e4a2be3fd41 /scumm
parent4165e1ceb4bcb80c907b9f135d8803eedf6ab47b (diff)
downloadscummvm-rg350-897f1bb479a5b5c73ebf9ef28012bc7624009ef9.tar.gz
scummvm-rg350-897f1bb479a5b5c73ebf9ef28012bc7624009ef9.tar.bz2
scummvm-rg350-897f1bb479a5b5c73ebf9ef28012bc7624009ef9.zip
applied patch: #641704
svn-id: r5675
Diffstat (limited to 'scumm')
-rw-r--r--scumm/smush/frenderer.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/scumm/smush/frenderer.cpp b/scumm/smush/frenderer.cpp
index 25d5b35afa..ea754472ab 100644
--- a/scumm/smush/frenderer.cpp
+++ b/scumm/smush/frenderer.cpp
@@ -306,6 +306,7 @@ bool FontRenderer::drawStringWrap(const char * str, char * buffer, const Point &
}
bool FontRenderer::drawStringWrapCentered(const char * str, char * buffer, const Point & size, int32 x, int32 y, int32 width) const {
+ int32 max_substr_width = 0;
debug(9, "FontRenderer::drawStringWrapCentered(%s, %d, %d)", str, x, y);
assert(strchr(str, '\n') == 0);
char * * words = split(str, ' ');
@@ -324,13 +325,14 @@ bool FontRenderer::drawStringWrapCentered(const char * str, char * buffer, const
int32 space_width = charWidth(' ');
i = 0;
+ width = MIN(width, size.getX());
while(i < nb_sub) {
int32 substr_width = sizes[i];
char * substr = new char[1000];
strcpy(substr, words[i]);
int32 j = i + 1;
- while(j < nb_sub && (substr_width + space_width + sizes[j]) < size.getX()) {
+ while(j < nb_sub && (substr_width + space_width + sizes[j]) < width) {
substr_width += sizes[j++] + space_width;
}
@@ -341,6 +343,7 @@ bool FontRenderer::drawStringWrapCentered(const char * str, char * buffer, const
substrings[nb_subs] = substr;
substr_widths[nb_subs++] = substr_width;
+ max_substr_width = MAX(substr_width, max_substr_width);
i = j;
height += stringHeight(substr);
}
@@ -355,6 +358,12 @@ bool FontRenderer::drawStringWrapCentered(const char * str, char * buffer, const
y = size.getY() - height;
}
+ if(x - max_substr_width / 2 < 0) {
+ x = max_substr_width / 2;
+ } else if (x + max_substr_width / 2 >= size.getX()) {
+ x = size.getX() - 1 - max_substr_width / 2;
+ }
+
for(i = 0; i < nb_subs; i++) {
int32 substr_width = substr_widths[i];
drawSubstring((const byte *)substrings[i], buffer, size, x - substr_width / 2, y);