[Scummvm-cvs-logs] CVS: scummvm/gui newgui.cpp,1.10,1.11

Max Horn fingolfin at users.sourceforge.net
Thu Sep 19 15:38:02 CEST 2002


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

Modified Files:
	newgui.cpp 
Log Message:
found out that guifont actually contains a char width table -> make use of it now

Index: newgui.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/newgui.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- newgui.cpp	19 Sep 2002 21:45:55 -0000	1.10
+++ newgui.cpp	19 Sep 2002 22:37:00 -0000	1.11
@@ -38,7 +38,8 @@
  */
 
 // Built-in font
-static byte guifont[] = {0,0,99,1,226,8,4,8,6,8,6,0,0,0,0,0,0,0,0,0,0,0,8,2,1,8,0,0,0,0,0,0,0,0,0,0,0,0,4,3,7,8,7,7,8,4,5,5,8,7,4,7,3,8,7,7,7,7,8,7,7,7,7,7,3,4,7,5,7,7,8,7,7,7,7,7,7,7,7,5,7,7,
+static byte guifont[] = {
+0,0,99,1,226,8,4,8,6,8,6,0,0,0,0,0,0,0,0,0,0,0,8,2,1,8,0,0,0,0,0,0,0,0,0,0,0,0,4,3,7,8,7,7,8,4,5,5,8,7,4,7,3,8,7,7,7,7,8,7,7,7,7,7,3,4,7,5,7,7,8,7,7,7,7,7,7,7,7,5,7,7,
 7,8,7,7,7,7,7,7,7,7,7,8,7,7,7,5,8,5,8,8,7,7,7,6,7,7,7,7,7,5,6,7,5,8,7,7,7,7,7,7,7,7,7,8,7,7,7,5,3,5,0,8,7,7,7,7,7,7,0,6,7,7,7,5,5,5,7,0,6,8,8,7,7,7,7,7,0,7,7,0,0,
 0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,0,0,0,0,0,0,0,0,1,3,6,12,
 24,62,3,0,128,192,96,48,24,124,192,0,0,3,62,24,12,6,3,1,0,192,124,24,48,96,192,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
@@ -63,7 +64,8 @@
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,28,54,54,124,102,102,124,64,0,0,0};
+0,0,0,0,0,0,28,54,54,124,102,102,124,64,0,0,0
+};
 
 // Constructor
 NewGui::NewGui(Scumm *s) : _s(s), _system(s->_system), _screen(0),
@@ -384,13 +386,12 @@
 	_system->copy_rect_overlay(buf, _screen_pitch, x, y, w, h);
 }
 
-void NewGui::drawChar(const char str, int xx, int yy, int16 color)
+void NewGui::drawChar(const char chr, int xx, int yy, int16 color)
 {
 	unsigned int buffer = 0, mask = 0, x, y;
 	byte *tmp;
 
-	tmp = &guifont[0];
-	tmp += 224 + (str + 1) * 8;
+	tmp = guifont + 224 + (chr + 1) * 8;
 
 	int16 *ptr = getBasePtr(xx, yy);
 	if (ptr == NULL)
@@ -421,43 +422,7 @@
 
 int NewGui::getCharWidth(char c)
 {
-	int space;
-
-	switch (c) {
-	case '.':
-	case ':':
-	case '\'':
-	case '!':
-		space = 3;
-		break;
-	case 'I':
-	case 'i':
-	case 'l':
-		space = 5;
-		break;
-	case ';':
-	case ' ':
-		space = 4;
-		break;
-	case '(':
-	case ')':
-		space = 5;
-		break;
-	case 'c':
-		space = 6;
-		break;
-	case '4':
-	case '/':
-	case 'W':
-	case 'w':
-	case 'M':
-	case 'm':
-		space = 8;
-		break;
-	default:
-		space = 7;
-	}
-	return space;
+	return guifont[c+6];
 }
 
 void NewGui::drawString(const char *str, int x, int y, int w, int16 color, int align)





More information about the Scummvm-git-logs mailing list