[Scummvm-cvs-logs] SF.net SVN: scummvm:[47838] scummvm/trunk/engines/sci

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Wed Feb 3 02:36:53 CET 2010


Revision: 47838
          http://scummvm.svn.sourceforge.net/scummvm/?rev=47838&view=rev
Author:   thebluegr
Date:     2010-02-03 01:36:53 +0000 (Wed, 03 Feb 2010)

Log Message:
-----------
Initial implementation of text drawing for SCI2 (it's a hack for now, done the "SCI0-SCI11" way, and text splitting is wrong...)

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/kernel32.cpp
    scummvm/trunk/engines/sci/engine/selector.cpp
    scummvm/trunk/engines/sci/engine/vm.h
    scummvm/trunk/engines/sci/graphics/frameout.cpp

Modified: scummvm/trunk/engines/sci/engine/kernel32.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel32.cpp	2010-02-03 01:34:39 UTC (rev 47837)
+++ scummvm/trunk/engines/sci/engine/kernel32.cpp	2010-02-03 01:36:53 UTC (rev 47838)
@@ -778,7 +778,7 @@
 	// TODO: argument 0 is usually 0, and arguments 1 and 2 are usually 1
 	reg_t object = argv[3];
 	Common::String text = s->_segMan->getString(GET_SEL32(s->_segMan, object, text));
-	debug("%s", text.c_str());
+	debug("kCreateTextBitmap: %s", text.c_str());
 
 	return NULL_REG;
 }

Modified: scummvm/trunk/engines/sci/engine/selector.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/selector.cpp	2010-02-03 01:34:39 UTC (rev 47837)
+++ scummvm/trunk/engines/sci/engine/selector.cpp	2010-02-03 01:36:53 UTC (rev 47838)
@@ -165,6 +165,8 @@
 	FIND_SELECTOR(plane);
 	FIND_SELECTOR(top);
 	FIND_SELECTOR(left);
+	FIND_SELECTOR(dimmed);
+	FIND_SELECTOR(fore);
 #endif
 }
 

Modified: scummvm/trunk/engines/sci/engine/vm.h
===================================================================
--- scummvm/trunk/engines/sci/engine/vm.h	2010-02-03 01:34:39 UTC (rev 47837)
+++ scummvm/trunk/engines/sci/engine/vm.h	2010-02-03 01:36:53 UTC (rev 47838)
@@ -204,6 +204,9 @@
 	Selector plane;
 	Selector top;
 	Selector left;
+
+	Selector fore;
+	Selector dimmed;
 #endif
 };
 

Modified: scummvm/trunk/engines/sci/graphics/frameout.cpp
===================================================================
--- scummvm/trunk/engines/sci/graphics/frameout.cpp	2010-02-03 01:34:39 UTC (rev 47837)
+++ scummvm/trunk/engines/sci/graphics/frameout.cpp	2010-02-03 01:36:53 UTC (rev 47838)
@@ -32,6 +32,7 @@
 #include "sci/engine/selector.h"
 #include "sci/engine/vm.h"
 #include "sci/graphics/cache.h"
+#include "sci/graphics/font.h"
 #include "sci/graphics/view.h"
 #include "sci/graphics/screen.h"
 #include "sci/graphics/picture.h"
@@ -149,6 +150,7 @@
 				itemEntry->priority = GET_SEL32V(_segMan, itemObject, priority);
 				itemEntry->scaleX = GET_SEL32V(_segMan, itemObject, scaleX);
 				itemEntry->scaleY = GET_SEL32V(_segMan, itemObject, scaleY);
+				itemEntry->object = itemObject;
 
 				itemEntry->x += planeLeft;
 				itemEntry->y += planeTop;
@@ -198,6 +200,31 @@
 					view->draw(itemEntry->celRect, itemEntry->celRect, itemEntry->celRect, itemEntry->loopNo, itemEntry->celNo, 255, 0, false);
 				else
 					view->drawScaled(itemEntry->celRect, itemEntry->celRect, itemEntry->celRect, itemEntry->loopNo, itemEntry->celNo, 255, itemEntry->scaleX, itemEntry->scaleY);
+			} else {
+				// Most likely a text entry
+				// This draws text the "SCI0-SCI11" way. In SCI2, text is prerendered in kCreateTextBitmap
+				// TODO: rewrite this the "SCI2" way (i.e. implement the text buffer to draw inside kCreateTextBitmap)
+				Kernel *kernel = ((SciEngine *)g_engine)->getKernel();
+				if (lookup_selector(_segMan, itemEntry->object, kernel->_selectorCache.text, NULL, NULL) == kSelectorVariable) {
+					Common::String text = _segMan->getString(GET_SEL32(_segMan, itemEntry->object, text));
+					int16 fontRes = GET_SEL32V(_segMan, itemEntry->object, font);
+					Font *font = new Font(_resMan, _screen, fontRes);
+					bool dimmed = GET_SEL32V(_segMan, itemEntry->object, dimmed);
+					uint16 foreColor = GET_SEL32V(_segMan, itemEntry->object, fore);
+					uint16 curX = itemEntry->x;
+					uint16 curY = itemEntry->y;
+					for (uint32 i = 0; i < text.size(); i++) {
+						// TODO: proper text splitting... this is a hack
+						if ((text[i] == ' ' && i > 0 && text[i - i] == ' ') || text[i] == '\n' || 
+							(curX + font->getCharWidth(text[i]) > _screen->getWidth())) {
+							curY += font->getCharHeight('A');
+							curX = itemEntry->x;
+						}
+						font->draw(text[i], curY, curX, foreColor, dimmed);
+						curX += font->getCharWidth(text[i]);
+					}
+					delete font;
+				}
 			}
 			listIterator++;
 		}


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