[Scummvm-cvs-logs] SF.net SVN: scummvm: [30615] scummvm/trunk/engines/parallaction
peres001 at users.sourceforge.net
peres001 at users.sourceforge.net
Tue Jan 22 21:53:29 CET 2008
Revision: 30615
http://scummvm.svn.sourceforge.net/scummvm/?rev=30615&view=rev
Author: peres001
Date: 2008-01-22 12:53:29 -0800 (Tue, 22 Jan 2008)
Log Message:
-----------
Some refactoring of text drawing routines.
Modified Paths:
--------------
scummvm/trunk/engines/parallaction/graphics.cpp
scummvm/trunk/engines/parallaction/graphics.h
Modified: scummvm/trunk/engines/parallaction/graphics.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.cpp 2008-01-22 19:45:06 UTC (rev 30614)
+++ scummvm/trunk/engines/parallaction/graphics.cpp 2008-01-22 20:53:29 UTC (rev 30615)
@@ -795,38 +795,38 @@
}
-
-uint16 Gfx::getStringWidth(const char *text) {
- return _font->getStringWidth(text);
-}
-
void Gfx::getStringExtent(char *text, uint16 maxwidth, int16* width, int16* height) {
uint16 lines = 0;
uint16 w = 0;
*width = 0;
+ uint16 blankWidth = _font->getStringWidth(" ");
+ uint16 tokenWidth = 0;
+
char token[40];
while (strlen(text) != 0) {
text = parseNextToken(text, token, 40, " ", true);
- w += getStringWidth(token);
+ tokenWidth = _font->getStringWidth(token);
+ w += tokenWidth;
+
if (!scumm_stricmp(token, "%p")) {
lines++;
} else {
if (w > maxwidth) {
- w -= getStringWidth(token);
+ w -= tokenWidth;
lines++;
if (w > *width)
*width = w;
- w = getStringWidth(token);
+ w = tokenWidth;
}
}
- w += getStringWidth(" ");
+ w += blankWidth;
text = Common::ltrim(text);
}
@@ -1170,6 +1170,9 @@
uint16 rx = 10;
uint16 ry = 4;
+ uint16 blankWidth = _font->getStringWidth(" ");
+ uint16 tokenWidth = 0;
+
char token[40];
if (wrapwidth == -1)
@@ -1186,17 +1189,20 @@
strcpy(token, "> .......");
strncpy(token+2, _password, strlen(_password));
+ tokenWidth = _font->getStringWidth(token);
+
rv = true;
} else {
+ tokenWidth = _font->getStringWidth(token);
- linewidth += getStringWidth(token);
+ linewidth += tokenWidth;
if (linewidth > wrapwidth) {
// wrap line
lines++;
rx = 10; // x
ry = 4 + lines*10; // y
- linewidth = getStringWidth(token);
+ linewidth = tokenWidth;
}
if (!scumm_stricmp(token, "%s")) {
@@ -1207,8 +1213,8 @@
drawText(surf, rx, ry, token, color);
- rx += getStringWidth(token) + getStringWidth(" ");
- linewidth += getStringWidth(" ");
+ rx += tokenWidth + blankWidth;
+ linewidth += blankWidth;
text = Common::ltrim(text);
}
Modified: scummvm/trunk/engines/parallaction/graphics.h
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.h 2008-01-22 19:45:06 UTC (rev 30614)
+++ scummvm/trunk/engines/parallaction/graphics.h 2008-01-22 20:53:29 UTC (rev 30615)
@@ -262,7 +262,6 @@
public:
// balloons and text
- uint16 getStringWidth(const char *text);
void getStringExtent(char *text, uint16 maxwidth, int16* width, int16* height);
// labels
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list