[Scummvm-cvs-logs] SF.net SVN: scummvm: [30345] scummvm/trunk/engines/parallaction

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Tue Jan 8 21:46:58 CET 2008


Revision: 30345
          http://scummvm.svn.sourceforge.net/scummvm/?rev=30345&view=rev
Author:   peres001
Date:     2008-01-08 12:46:58 -0800 (Tue, 08 Jan 2008)

Log Message:
-----------
Restructured label handling and moved all related code to Gfx.

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/graphics.cpp
    scummvm/trunk/engines/parallaction/graphics.h
    scummvm/trunk/engines/parallaction/objects.cpp
    scummvm/trunk/engines/parallaction/objects.h
    scummvm/trunk/engines/parallaction/parallaction.cpp
    scummvm/trunk/engines/parallaction/parallaction.h
    scummvm/trunk/engines/parallaction/parallaction_ns.cpp
    scummvm/trunk/engines/parallaction/parser_ns.cpp

Modified: scummvm/trunk/engines/parallaction/graphics.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.cpp	2008-01-08 20:37:31 UTC (rev 30344)
+++ scummvm/trunk/engines/parallaction/graphics.cpp	2008-01-08 20:46:58 UTC (rev 30345)
@@ -505,6 +505,43 @@
 
 }
 
+#define	LABEL_TRANSPARENT_COLOR 0xFF
+
+Label *Gfx::renderFloatingLabel(Font *font, char *text) {
+
+	Label *label = new Label;
+	Graphics::Surface *cnv = &label->_cnv;
+
+	uint w, h;
+
+	if (_vm->getPlatform() == Common::kPlatformAmiga) {
+		w = font->getStringWidth(text) + 16;
+		h = 10;
+
+		cnv->create(w, h, 1);
+		cnv->fillRect(Common::Rect(w,h), LABEL_TRANSPARENT_COLOR);
+
+		font->setColor(7);
+		font->drawString((byte*)cnv->pixels + 1, cnv->w, text);
+		font->drawString((byte*)cnv->pixels + 1 + cnv->w * 2, cnv->w, text);
+		font->drawString((byte*)cnv->pixels + cnv->w, cnv->w, text);
+		font->drawString((byte*)cnv->pixels + 2 + cnv->w, cnv->w, text);
+		font->setColor(1);
+		font->drawString((byte*)cnv->pixels + 1 + cnv->w, cnv->w, text);
+	} else {
+		w = font->getStringWidth(text);
+		h = font->height();
+
+		cnv->create(w, h, 1);
+		cnv->fillRect(Common::Rect(w,h), LABEL_TRANSPARENT_COLOR);
+
+		font->drawString((byte*)cnv->pixels, cnv->w, text);
+	}
+
+	return label;
+}
+
+
 void Gfx::setLabel(Label *label) {
 	_label = label;
 
@@ -544,7 +581,7 @@
 	r.moveTo(_label->_pos);
 
 	Graphics::Surface* surf = g_system->lockScreen();
-	flatBlit(r, (byte*)_label->_cnv.getBasePtr(0, 0), surf, 0);
+	flatBlit(r, (byte*)_label->_cnv.getBasePtr(0, 0), surf, LABEL_TRANSPARENT_COLOR);
 	g_system->unlockScreen();
 }
 

Modified: scummvm/trunk/engines/parallaction/graphics.h
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.h	2008-01-08 20:37:31 UTC (rev 30344)
+++ scummvm/trunk/engines/parallaction/graphics.h	2008-01-08 20:46:58 UTC (rev 30345)
@@ -251,6 +251,7 @@
 	// labels
 	Label	*_label;
 	void setLabel(Label *label);
+	Label *renderFloatingLabel(Font *font, char *text);
 
 	// cut/paste
 	void flatBlitCnv(Graphics::Surface *cnv, int16 x, int16 y, Gfx::Buffers buffer);

Modified: scummvm/trunk/engines/parallaction/objects.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/objects.cpp	2008-01-08 20:37:31 UTC (rev 30344)
+++ scummvm/trunk/engines/parallaction/objects.cpp	2008-01-08 20:46:58 UTC (rev 30345)
@@ -123,6 +123,8 @@
 	_type = 0;
 	_flags = 0;
 
+	_label = 0;
+
 	memset(_name, 0, ZONENAME_LENGTH);
 }
 
@@ -166,6 +168,8 @@
 	default:
 		break;
 	}
+
+	delete _label;
 }
 
 void Zone::getRect(Common::Rect& r) const {

Modified: scummvm/trunk/engines/parallaction/objects.h
===================================================================
--- scummvm/trunk/engines/parallaction/objects.h	2008-01-08 20:37:31 UTC (rev 30344)
+++ scummvm/trunk/engines/parallaction/objects.h	2008-01-08 20:46:58 UTC (rev 30345)
@@ -280,7 +280,7 @@
 	int16			_bottom;
 	uint32			_type;
 	uint32			_flags;
-	Label			_label;
+	Label			*_label;
 	uint16			field_2C;		// unused
 	uint16			field_2E;		// unused
 	TypeData		u;

Modified: scummvm/trunk/engines/parallaction/parallaction.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.cpp	2008-01-08 20:37:31 UTC (rev 30344)
+++ scummvm/trunk/engines/parallaction/parallaction.cpp	2008-01-08 20:46:58 UTC (rev 30345)
@@ -504,7 +504,7 @@
 	if ((_hoverZone == NULL) && ((z->_flags & kFlagsNoName) == 0)) {
 		_hoverZone = z;
 		_input._event = kEvEnterZone;
-		_input._label = &z->_label;
+		_input._label = z->_label;
 		return true;
 	}
 
@@ -949,7 +949,6 @@
 	_ani._frame = 0;
 	_ani._flags = kFlagsActive | kFlagsNoName;
 	_ani._type = kZoneYou;
-	_ani._label._cnv.pixels = NULL;
 	strncpy(_ani._name, "yourself", ZONENAME_LENGTH);
 }
 

Modified: scummvm/trunk/engines/parallaction/parallaction.h
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.h	2008-01-08 20:37:31 UTC (rev 30344)
+++ scummvm/trunk/engines/parallaction/parallaction.h	2008-01-08 20:46:58 UTC (rev 30345)
@@ -570,7 +570,6 @@
 
 public:
 	virtual	void callFunction(uint index, void* parm) { }
-	virtual void renderLabel(Graphics::Surface *cnv, char *text) { }
 
 	virtual void setArrowCursor() = 0;
 	virtual void setInventoryCursor(int pos) = 0;
@@ -670,7 +669,6 @@
 	typedef void (Parallaction_ns::*Callable)(void*);
 
 	virtual	void callFunction(uint index, void* parm);
-	void renderLabel(Graphics::Surface *cnv, char *text);
 	void setMousePointer(uint32 value);
 
 	void	initJobs();

Modified: scummvm/trunk/engines/parallaction/parallaction_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction_ns.cpp	2008-01-08 20:37:31 UTC (rev 30344)
+++ scummvm/trunk/engines/parallaction/parallaction_ns.cpp	2008-01-08 20:46:58 UTC (rev 30345)
@@ -164,25 +164,6 @@
 
 }
 
-void Parallaction_ns::renderLabel(Graphics::Surface *cnv, char *text) {
-
-	if (getPlatform() == Common::kPlatformAmiga) {
-		cnv->create(_labelFont->getStringWidth(text) + 16, 10, 1);
-
-		_labelFont->setColor(7);
-		_labelFont->drawString((byte*)cnv->pixels + 1, cnv->w, text);
-		_labelFont->drawString((byte*)cnv->pixels + 1 + cnv->w * 2, cnv->w, text);
-		_labelFont->drawString((byte*)cnv->pixels + cnv->w, cnv->w, text);
-		_labelFont->drawString((byte*)cnv->pixels + 2 + cnv->w, cnv->w, text);
-		_labelFont->setColor(1);
-		_labelFont->drawString((byte*)cnv->pixels + 1 + cnv->w, cnv->w, text);
-	} else {
-		cnv->create(_labelFont->getStringWidth(text), _labelFont->height(), 1);
-		_labelFont->drawString((byte*)cnv->pixels, cnv->w, text);
-	}
-
-}
-
 void Parallaction_ns::initCursors() {
 
 	_mouseComposedArrow = _disk->loadPointer("pointer");

Modified: scummvm/trunk/engines/parallaction/parser_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parser_ns.cpp	2008-01-08 20:37:31 UTC (rev 30344)
+++ scummvm/trunk/engines/parallaction/parser_ns.cpp	2008-01-08 20:46:58 UTC (rev 30345)
@@ -119,7 +119,7 @@
 DECLARE_ANIM_PARSER(label)  {
 	debugC(7, kDebugParser, "ANIM_PARSER(label) ");
 
-	renderLabel(&_locParseCtxt.a->_label._cnv, _tokens[1]);
+	_locParseCtxt.a->_label = _gfx->renderFloatingLabel(_labelFont, _tokens[1]);
 }
 
 
@@ -1237,7 +1237,7 @@
 	debugC(7, kDebugParser, "ZONE_PARSER(label) ");
 
 //			printf("label: %s", _tokens[1]);
-	renderLabel(&_locParseCtxt.z->_label._cnv, _tokens[1]);
+	_locParseCtxt.z->_label = _gfx->renderFloatingLabel(_labelFont, _tokens[1]);
 }
 
 


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