[Scummvm-cvs-logs] CVS: scummvm newgui.cpp,1.27,1.28 newgui.h,1.20,1.21

Max Horn fingolfin at users.sourceforge.net
Fri Jul 26 17:37:02 CEST 2002


Update of /cvsroot/scummvm/scummvm
In directory usw-pr-cvs1:/tmp/cvs-serv6843

Modified Files:
	newgui.cpp newgui.h 
Log Message:
added support for right aligned text; made use of that in the sound dialog; less redrawing in the sound dialog

Index: newgui.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/newgui.cpp,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- newgui.cpp	26 Jul 2002 20:38:55 -0000	1.27
+++ newgui.cpp	27 Jul 2002 00:36:09 -0000	1.28
@@ -29,7 +29,6 @@
  * TODO list
  * - implement the missing / incomplete dialogs
  * - add more widgets
- * - add support for right/center aligned text
  * - allow multi line (l/c/r aligned) text via StaticTextWidget ?
  * - add "close" widget to all dialogs (with a flag to turn it off) ?
  * - make dialogs "moveable" ?
@@ -438,22 +437,30 @@
 
 }
 
-void NewGui::drawString(const char *str, int x, int y, int w, byte color, bool center)
+void NewGui::drawString(const char *str, int x, int y, int w, byte color, int align)
 {
 	if (_s->_gameId) {						/* If a game is active.. */
 		StringTab *st = &_s->string[5];
 		st->charset = 1;
-		st->center = center;
+		st->center = (align == kTextAlignCenter);
 		st->color = color;
-		st->xpos = center ? x+w/2 : x;
+
+		if (align == kTextAlignLeft)
+			st->xpos = x;
+		else if (align == kTextAlignCenter)
+			st->xpos = x + w/2;
+		else if (align == kTextAlignRight)
+			st->xpos = x + w - _s->charset.getStringWidth(0, (byte *)str, 0);
+
 		st->ypos = y;
 		st->right = x + w;
 	
 		_s->_messagePtr = (byte *)str;
 		_s->drawString(5);
 	} else {
-		// FIXME - support center, use nicer custom font. Ultimately, we might
-		// want to *always* draw our messages this way.
+		// FIXME - support center/right align, use nicer custom font.
+		// Ultimately, we might want to *always* draw our messages this way,
+		// but only if we have a nice font.
 		uint len = strlen(str);
 		for (uint letter = 0; letter < len; letter++)
 			drawChar(str[letter], x + (letter * 8), y);

Index: newgui.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/newgui.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- newgui.h	26 Jul 2002 00:41:06 -0000	1.20
+++ newgui.h	27 Jul 2002 00:36:09 -0000	1.21
@@ -31,6 +31,12 @@
 #define hline(x, y, x2, color) line(x, y, x2, y, color);
 #define vline(x, y, y2, color) line(x, y, x, y2, color);
 
+enum {
+	kTextAlignLeft,
+	kTextAlignCenter,
+	kTextAlignRight,
+};
+
 // Extremly simple stack class, doesn't even do any error checking (for now)
 class DialogStack {
 protected:
@@ -124,7 +130,7 @@
 	void frameRect(int x, int y, int w, int h, byte color);
 	void addDirtyRect(int x, int y, int w, int h);
 	void drawChar(const char c, int x, int y);
-	void drawString(const char *str, int x, int y, int w, byte color, bool center = false);
+	void drawString(const char *str, int x, int y, int w, byte color, int align = kTextAlignLeft);
 
 	void drawBitmap(uint32 bitmap[8], int x, int y, byte color);
 	void blitTo(byte buffer[320*200], int x, int y, int w, int h);





More information about the Scummvm-git-logs mailing list