[Scummvm-cvs-logs] CVS: scummvm/scumm/smush frenderer.cpp,1.8,1.9 frenderer.h,1.6,1.7 player.cpp,1.21,1.22
Pawe? Ko?odziejski
aquadran at users.sourceforge.net
Sat Nov 16 01:09:02 CET 2002
Update of /cvsroot/scummvm/scummvm/scumm/smush
In directory usw-pr-cvs1:/tmp/cvs-serv13863
Modified Files:
frenderer.cpp frenderer.h player.cpp
Log Message:
DIG: fixed subtitles in Space Time Six smush movie
Index: frenderer.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/smush/frenderer.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- frenderer.cpp 22 Sep 2002 00:20:23 -0000 1.8
+++ frenderer.cpp 16 Nov 2002 09:08:48 -0000 1.9
@@ -295,7 +295,6 @@
left_x = size.getX() - max_width;
for(i = 0; i < nb_subs; i++) {
-// int32 substr_width = substr_widths[i];
drawSubstring((const byte *)substrings[i], buffer, size, left_x, y);
y += stringHeight(substrings[i]);
delete []substrings[i];
@@ -306,3 +305,64 @@
return true;
}
+bool FontRenderer::drawStringWrapCentered(const char * str, char * buffer, const Point & size, int32 x, int32 y, int32 width) const {
+ debug(9, "FontRenderer::drawStringWrapCentered(%s, %d, %d)", str, x, y);
+ assert(strchr(str, '\n') == 0);
+ char * * words = split(str, ' ');
+ int32 nb_sub = 0;
+
+ while(words[nb_sub]) nb_sub++;
+
+ int32 * sizes = new int32[nb_sub];
+ int32 i = 0, max_width = 0, height = 0, nb_subs = 0;
+
+ for(i = 0; i < nb_sub; i++)
+ sizes[i] = stringWidth(words[i]);
+
+ char * * substrings = new char *[nb_sub];
+ int32 * substr_widths = new int32[nb_sub];
+ int32 space_width = charWidth(' ');
+
+ i = 0;
+ 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()) {
+ substr_width += sizes[j++] + space_width;
+ }
+
+ for(int32 k = i + 1; k < j; k++) {
+ strcat(substr, " ");
+ strcat(substr, words[k]);
+ }
+
+ substrings[nb_subs] = substr;
+ substr_widths[nb_subs++] = substr_width;
+ i = j;
+ height += stringHeight(substr);
+ }
+
+ delete []sizes;
+ for(i = 0; i < nb_sub; i++) {
+ delete []words[i];
+ }
+ delete []words;
+
+ if(y + height > size.getY()) {
+ y = size.getY() - height;
+ }
+
+ 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);
+ y += stringHeight(substrings[i]);
+ delete []substrings[i];
+ }
+
+ delete []substr_widths;
+ delete []substrings;
+ return true;
+}
Index: frenderer.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/smush/frenderer.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- frenderer.h 20 Sep 2002 05:46:03 -0000 1.6
+++ frenderer.h 16 Nov 2002 09:08:48 -0000 1.7
@@ -149,6 +149,7 @@
*/
bool drawStringCentered(const char * str, char * buffer, const Point & size, int32 y, int32 xmin, int32 width, int32 offset) const;
bool drawStringWrap(const char * str, char * buffer, const Point & size, int32 x, int32 y, int32 width) const;
+ bool drawStringWrapCentered(const char * str, char * buffer, const Point & size, int32 x, int32 y, int32 width) const;
/*! @brief draw a string at an absolute position.
@param str the string to draw.
Index: player.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/smush/player.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- player.cpp 15 Nov 2002 19:31:44 -0000 1.21
+++ player.cpp 16 Nov 2002 09:08:48 -0000 1.22
@@ -411,7 +411,7 @@
fr->drawStringWrap(str, _curBuffer, _frameSize, pos_x, MAX(pos_y, top), width);
}
else if(flags == 13) {
- fr->drawStringCentered(str, _curBuffer, _frameSize, MAX(pos_y, top), left, width, pos_x);
+ fr->drawStringWrapCentered(str, _curBuffer, _frameSize, pos_x, MAX(pos_y, top), width);
}
else
warning("SmushPlayer::handleTextResource. Not handled flags: %d\n", flags);
More information about the Scummvm-git-logs
mailing list