[Scummvm-cvs-logs] CVS: scummvm/scumm script_v8.cpp,2.43,2.44

Max Horn fingolfin at users.sourceforge.net
Wed Dec 25 12:17:02 CET 2002


Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1:/tmp/cvs-serv1666

Modified Files:
	script_v8.cpp 
Log Message:
text center mode hack

Index: script_v8.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v8.cpp,v
retrieving revision 2.43
retrieving revision 2.44
diff -u -d -r2.43 -r2.44
--- script_v8.cpp	25 Dec 2002 20:07:09 -0000	2.43
+++ script_v8.cpp	25 Dec 2002 20:15:54 -0000	2.44
@@ -527,7 +527,7 @@
 		break;
 	case 0xD1: {
 
-		byte buffer[1024];
+		char buffer[1024];
 		_messagePtr = _scriptPointer;
 
 		if (_messagePtr[0] == '/') {
@@ -552,10 +552,10 @@
 			// _sound->_talkChannel = _sound->playBundleSound(pointer);
 
 			_messagePtr = _transText;
-			_msgPtrToAdd = buffer;
+			_msgPtrToAdd = (byte *)buffer;
 			_messagePtr = addMessageToStack(_messagePtr);
 		} else {
-			_msgPtrToAdd = buffer;
+			_msgPtrToAdd = (byte *)buffer;
 			_scriptPointer = _messagePtr = addMessageToStack(_messagePtr);
 		}
 
@@ -563,7 +563,20 @@
 			loadCharset(_string[m].charset);
 
 		if (_fr[_string[m].charset] != NULL) {
-			_fr[_string[m].charset]->drawString((char *)buffer, (int)_string[m].xpos, (int)_string[m].ypos, (unsigned char)_string[m].color, 0);
+			int x = _string[m].xpos;
+			// HACK - center mode. I call this a hack because we really should
+			// not duplicate all the string code from string.cpp. Rather, maybe
+			// abstract away the code in string.cpp from using the 'charset'
+			// fonts, and allow it to work both with old and new fonts. To this
+			// end, we should seperate the parts of Charset/_charset which are
+			// for bookkeeping (like x_pos, center mode etc.) and those that are
+			// for rendering. Then let the old (think printCharOld), medium (printChar),
+			// new (NUT) style renderers be subclasses of a common base class (which
+			// defines the API). This will clean up the code, and allow us to reuse
+			// the string logic in string.cpp.
+			if (_string[m].center)
+				x -= _fr[_string[m].charset]->getStringWidth(buffer) / 2;
+			_fr[_string[m].charset]->drawString(buffer, x, _string[m].ypos, _string[m].color, 0);
 		}
 		break;
 	}





More information about the Scummvm-git-logs mailing list