mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-22 18:02:05 +00:00
DIG: fixed subtitles in Space Time Six smush movie
svn-id: r5580
This commit is contained in:
parent
cec1a5a2cd
commit
34782f17ab
@ -295,7 +295,6 @@ bool FontRenderer::drawStringWrap(const char * str, char * buffer, const Point &
|
||||
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 @@ bool FontRenderer::drawStringWrap(const char * str, char * buffer, const Point &
|
||||
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;
|
||||
}
|
||||
|
@ -149,6 +149,7 @@ public:
|
||||
*/
|
||||
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.
|
||||
|
@ -411,7 +411,7 @@ void SmushPlayer::handleTextResource(Chunk & b) {
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user