[Scummvm-cvs-logs] CVS: scummvm/gui newgui.cpp,1.25,1.26
Max Horn
fingolfin at users.sourceforge.net
Tue Nov 5 05:34:05 CET 2002
Update of /cvsroot/scummvm/scummvm/gui
In directory usw-pr-cvs1:/tmp/cvs-serv25532/gui
Modified Files:
newgui.cpp
Log Message:
clip text drawing
Index: newgui.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/newgui.cpp,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- newgui.cpp 26 Oct 2002 09:31:14 -0000 1.25
+++ newgui.cpp 5 Nov 2002 13:33:33 -0000 1.26
@@ -432,6 +432,7 @@
void NewGui::drawString(const String &str, int x, int y, int w, int16 color, int align)
{
+ const int leftX = x, rightX = x + w;
int width = getStringWidth(str);
if (align == kTextAlignCenter)
x = x + (w - width - 1)/2;
@@ -439,8 +440,12 @@
x = x + w - width;
for (int i = 0; i < str.size(); ++i) {
- drawChar(str[i], x, y, color);
- x += getCharWidth(str[i]);
+ w = getCharWidth(str[i]);
+ if (x+w > rightX)
+ break;
+ if (x >= leftX)
+ drawChar(str[i], x, y, color);
+ x += w;
}
}
More information about the Scummvm-git-logs
mailing list