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

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Sat Aug 16 15:10:55 CEST 2008


Revision: 33940
          http://scummvm.svn.sourceforge.net/scummvm/?rev=33940&view=rev
Author:   peres001
Date:     2008-08-16 13:10:54 +0000 (Sat, 16 Aug 2008)

Log Message:
-----------
Extended balloon manager to handle color constants and fixed color of text in balloons for BRA.

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/balloons.cpp
    scummvm/trunk/engines/parallaction/dialogue.cpp
    scummvm/trunk/engines/parallaction/exec_ns.cpp
    scummvm/trunk/engines/parallaction/graphics.h

Modified: scummvm/trunk/engines/parallaction/balloons.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/balloons.cpp	2008-08-16 12:49:27 UTC (rev 33939)
+++ scummvm/trunk/engines/parallaction/balloons.cpp	2008-08-16 13:10:54 UTC (rev 33940)
@@ -246,6 +246,8 @@
 
 	static int16 _dialogueBalloonX[5];
 
+	byte _textColors[2];
+
 	struct Balloon {
 		Common::Rect outerBox;
 		Common::Rect innerBox;
@@ -266,16 +268,18 @@
 
 	void freeBalloons();
 	int setLocationBalloon(char *text, bool endGame);
-	int setDialogueBalloon(char *text, uint16 winding, byte textColor);
-	int setSingleBalloon(char *text, uint16 x, uint16 y, uint16 winding, byte textColor);
-	void setBalloonText(uint id, char *text, byte textColor);
+	int setDialogueBalloon(char *text, uint16 winding, TextColor textColor);
+	int setSingleBalloon(char *text, uint16 x, uint16 y, uint16 winding, TextColor textColor);
+	void setBalloonText(uint id, char *text, TextColor textColor);
 	int hitTestDialogueBalloon(int x, int y);
 };
 
 int16 BalloonManager_ns::_dialogueBalloonX[5] = { 80, 120, 150, 150, 150 };
 
 BalloonManager_ns::BalloonManager_ns(Gfx *gfx) : _numBalloons(0), _gfx(gfx) {
-
+	_textColors[kSelectedColor] = 0;
+	_textColors[kUnselectedColor] = 3;
+	_textColors[kNormalColor] = 0;
 }
 
 BalloonManager_ns::~BalloonManager_ns() {
@@ -323,7 +327,7 @@
 }
 
 
-int BalloonManager_ns::setSingleBalloon(char *text, uint16 x, uint16 y, uint16 winding, byte textColor) {
+int BalloonManager_ns::setSingleBalloon(char *text, uint16 x, uint16 y, uint16 winding, TextColor textColor) {
 
 	int16 w, h;
 
@@ -336,7 +340,7 @@
 	Balloon *balloon = &_intBalloons[id];
 
 	StringWriter_NS sw(_vm->_dialogueFont);
-	sw.write(text, MAX_BALLOON_WIDTH, textColor, balloon->surface);
+	sw.write(text, MAX_BALLOON_WIDTH, _textColors[textColor], balloon->surface);
 
 	// TODO: extract some text to make a name for obj
 	balloon->obj = _gfx->registerBalloon(new SurfaceToFrames(balloon->surface), 0);
@@ -347,7 +351,7 @@
 	return id;
 }
 
-int BalloonManager_ns::setDialogueBalloon(char *text, uint16 winding, byte textColor) {
+int BalloonManager_ns::setDialogueBalloon(char *text, uint16 winding, TextColor textColor) {
 
 	int16 w, h;
 
@@ -361,7 +365,7 @@
 	Balloon *balloon = &_intBalloons[id];
 
 	StringWriter_NS sw(_vm->_dialogueFont);
-	sw.write(text, MAX_BALLOON_WIDTH, textColor, balloon->surface);
+	sw.write(text, MAX_BALLOON_WIDTH, _textColors[textColor], balloon->surface);
 
 	// TODO: extract some text to make a name for obj
 	balloon->obj = _gfx->registerBalloon(new SurfaceToFrames(balloon->surface), 0);
@@ -377,12 +381,12 @@
 	return id;
 }
 
-void BalloonManager_ns::setBalloonText(uint id, char *text, byte textColor) {
+void BalloonManager_ns::setBalloonText(uint id, char *text, TextColor textColor) {
 	Balloon *balloon = getBalloon(id);
 	balloon->surface->fillRect(balloon->innerBox, 1);
 
 	StringWriter_NS sw(_vm->_dialogueFont);
-	sw.write(text, MAX_BALLOON_WIDTH, textColor, balloon->surface);
+	sw.write(text, MAX_BALLOON_WIDTH, _textColors[textColor], balloon->surface);
 }
 
 
@@ -398,7 +402,7 @@
 	int id = createBalloon(w+(endGame ? 5 : 10), h+5, -1, BALLOON_TRANSPARENT_COLOR_NS);
 	Balloon *balloon = &_intBalloons[id];
 	StringWriter_NS sw(_vm->_dialogueFont);
-	sw.write(text, MAX_BALLOON_WIDTH, 0, balloon->surface);
+	sw.write(text, MAX_BALLOON_WIDTH, _textColors[kNormalColor], balloon->surface);
 
 	// TODO: extract some text to make a name for obj
 	balloon->obj = _gfx->registerBalloon(new SurfaceToFrames(balloon->surface), 0);
@@ -534,6 +538,8 @@
 
 class BalloonManager_br : public BalloonManager {
 
+	byte _textColors[2];
+
 	struct Balloon {
 		Common::Rect box;
 		Graphics::Surface *surface;
@@ -562,9 +568,9 @@
 
 	void freeBalloons();
 	int setLocationBalloon(char *text, bool endGame);
-	int setDialogueBalloon(char *text, uint16 winding, byte textColor);
-	int setSingleBalloon(char *text, uint16 x, uint16 y, uint16 winding, byte textColor);
-	void setBalloonText(uint id, char *text, byte textColor);
+	int setDialogueBalloon(char *text, uint16 winding, TextColor textColor);
+	int setSingleBalloon(char *text, uint16 x, uint16 y, uint16 winding, TextColor textColor);
+	void setBalloonText(uint id, char *text, TextColor textColor);
 	int hitTestDialogueBalloon(int x, int y);
 };
 
@@ -590,7 +596,7 @@
 	return surf;
 }
 
-int BalloonManager_br::setSingleBalloon(char *text, uint16 x, uint16 y, uint16 winding, byte textColor) {
+int BalloonManager_br::setSingleBalloon(char *text, uint16 x, uint16 y, uint16 winding, TextColor textColor) {
 	cacheAnims();
 
 	int id = _numBalloons;
@@ -613,7 +619,7 @@
 	balloon->surface = expandBalloon(src, srcFrame);
 	src->getRect(srcFrame, balloon->box);
 
-	_writer.write(text, MAX_BALLOON_WIDTH, textColor, balloon->surface);
+	_writer.write(text, MAX_BALLOON_WIDTH, _textColors[textColor], balloon->surface);
 
 	// TODO: extract some text to make a name for obj
 	balloon->obj = _gfx->registerBalloon(new SurfaceToFrames(balloon->surface), 0);
@@ -626,7 +632,7 @@
 	return id;
 }
 
-int BalloonManager_br::setDialogueBalloon(char *text, uint16 winding, byte textColor) {
+int BalloonManager_br::setDialogueBalloon(char *text, uint16 winding, TextColor textColor) {
 	cacheAnims();
 
 	int id = _numBalloons;
@@ -649,7 +655,7 @@
 	balloon->surface = expandBalloon(src, srcFrame);
 	src->getRect(srcFrame, balloon->box);
 
-	_writer.write(text, MAX_BALLOON_WIDTH, textColor, balloon->surface);
+	_writer.write(text, MAX_BALLOON_WIDTH, _textColors[textColor], balloon->surface);
 
 	// TODO: extract some text to make a name for obj
 	balloon->obj = _gfx->registerBalloon(new SurfaceToFrames(balloon->surface), 0);
@@ -662,11 +668,11 @@
 	return id;
 }
 
-void BalloonManager_br::setBalloonText(uint id, char *text, byte textColor) {
+void BalloonManager_br::setBalloonText(uint id, char *text, TextColor textColor) {
 	Balloon *balloon = getBalloon(id);
 
 	StringWriter_BR sw(_vm->_dialogueFont);
-	sw.write(text, MAX_BALLOON_WIDTH, textColor, balloon->surface);
+	sw.write(text, MAX_BALLOON_WIDTH, _textColors[textColor], balloon->surface);
 }
 
 int BalloonManager_br::setLocationBalloon(char *text, bool endGame) {
@@ -722,6 +728,10 @@
 
 BalloonManager_br::BalloonManager_br(Disk *disk, Gfx *gfx) : _numBalloons(0), _disk(disk), _gfx(gfx),
 	_leftBalloon(0), _rightBalloon(0), _writer(_vm->_dialogueFont) {
+
+	_textColors[kSelectedColor] = 12;
+	_textColors[kUnselectedColor] = 0;
+	_textColors[kNormalColor] = 0;
 }
 
 BalloonManager_br::~BalloonManager_br() {

Modified: scummvm/trunk/engines/parallaction/dialogue.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/dialogue.cpp	2008-08-16 12:49:27 UTC (rev 33939)
+++ scummvm/trunk/engines/parallaction/dialogue.cpp	2008-08-16 13:10:54 UTC (rev 33940)
@@ -173,7 +173,7 @@
 	// display suitable answers
 	if (((a->_yesFlags & flags) == a->_yesFlags) && ((a->_noFlags & ~flags) == a->_noFlags)) {
 
-		int id = _vm->_balloonMan->setDialogueBalloon(a->_text, 1, 3);
+		int id = _vm->_balloonMan->setDialogueBalloon(a->_text, 1, BalloonManager::kUnselectedColor);
 		assert(id >= 0);
 		_visAnswers[id] = i;
 
@@ -203,7 +203,7 @@
 	if (_numVisAnswers == 1) {
 		int id = _vm->_gfx->setItem(_answerer, _ballonPos._answerChar.x, _ballonPos._answerChar.y);
 		_vm->_gfx->setItemFrame(id, _q->_answers[0]->_mood & 0xF);
-		_vm->_balloonMan->setBalloonText(0, _q->_answers[_visAnswers[0]]->_text, 0);
+		_vm->_balloonMan->setBalloonText(0, _q->_answers[_visAnswers[0]]->_text, BalloonManager::kNormalColor);
 	} else
 	if (_numVisAnswers > 1) {
 		int id = _vm->_gfx->setItem(_answerer, _ballonPos._answerChar.x, _ballonPos._answerChar.y);
@@ -218,7 +218,7 @@
 bool DialogueManager::displayQuestion() {
 	if (!scumm_stricmp(_q->_text, "NULL")) return false;
 
-	_vm->_balloonMan->setSingleBalloon(_q->_text, _ballonPos._questionBalloon.x, _ballonPos._questionBalloon.y, _q->_mood & 0x10, 0);
+	_vm->_balloonMan->setSingleBalloon(_q->_text, _ballonPos._questionBalloon.x, _ballonPos._questionBalloon.y, _q->_mood & 0x10, BalloonManager::kNormalColor);
 	int id = _vm->_gfx->setItem(_questioner, _ballonPos._questionChar.x, _ballonPos._questionChar.y);
 	_vm->_gfx->setItemFrame(id, _q->_mood & 0xF);
 
@@ -256,7 +256,7 @@
 	}
 
 	if (_passwordChanged) {
-		_vm->_balloonMan->setBalloonText(0, _q->_answers[0]->_text, 3);
+		_vm->_balloonMan->setBalloonText(0, _q->_answers[0]->_text, BalloonManager::kNormalColor);
 		_passwordChanged = false;
 	}
 
@@ -286,11 +286,11 @@
 
 	if (_selection != _oldSelection) {
 		if (_oldSelection != -1) {
-			_vm->_balloonMan->setBalloonText(_oldSelection, _q->_answers[_visAnswers[_oldSelection]]->_text, 3);
+			_vm->_balloonMan->setBalloonText(_oldSelection, _q->_answers[_visAnswers[_oldSelection]]->_text, BalloonManager::kUnselectedColor);
 		}
 
 		if (_selection != -1) {
-			_vm->_balloonMan->setBalloonText(_selection, _q->_answers[_visAnswers[_selection]]->_text, 0);
+			_vm->_balloonMan->setBalloonText(_selection, _q->_answers[_visAnswers[_selection]]->_text, BalloonManager::kSelectedColor);
 			_vm->_gfx->setItemFrame(0, _q->_answers[_visAnswers[_selection]]->_mood & 0xF);
 		}
 	}

Modified: scummvm/trunk/engines/parallaction/exec_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/exec_ns.cpp	2008-08-16 12:49:27 UTC (rev 33939)
+++ scummvm/trunk/engines/parallaction/exec_ns.cpp	2008-08-16 13:10:54 UTC (rev 33940)
@@ -558,7 +558,7 @@
 			}
 
 			_gfx->setHalfbriteMode(true);
-			_balloonMan->setSingleBalloon(data->_description, 0, 90, 0, 0);
+			_balloonMan->setSingleBalloon(data->_description, 0, 90, 0, BalloonManager::kNormalColor);
 			Common::Rect r;
 			data->_cnv->getRect(0, r);
 			id = _gfx->setItem(data->_cnv, 140, (_screenHeight - r.height())/2);
@@ -566,13 +566,13 @@
 			id = _gfx->setItem(_char._head, 100, 152);
 			_gfx->setItemFrame(id, 0);
 		} else {
-			_balloonMan->setSingleBalloon(data->_description, 140, 10, 0, 0);
+			_balloonMan->setSingleBalloon(data->_description, 140, 10, 0, BalloonManager::kNormalColor);
 			id = _gfx->setItem(_char._talk, 190, 80);
 			_gfx->setItemFrame(id, 0);
 		}
 	} else
 	if (getGameType() == GType_BRA) {
-		_balloonMan->setSingleBalloon(data->_description, 0, 0, 1, 0);
+		_balloonMan->setSingleBalloon(data->_description, 0, 0, 1, BalloonManager::kNormalColor);
 		int id = _gfx->setItem(_char._talk, 10, 80);
 		_gfx->setItemFrame(id, 0);
 	}

Modified: scummvm/trunk/engines/parallaction/graphics.h
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.h	2008-08-16 12:49:27 UTC (rev 33939)
+++ scummvm/trunk/engines/parallaction/graphics.h	2008-08-16 13:10:54 UTC (rev 33940)
@@ -495,13 +495,19 @@
 
 class BalloonManager {
 public:
+	enum TextColor {
+		kSelectedColor = 0,
+		kUnselectedColor = 1,
+		kNormalColor = 2
+	};
+
 	virtual ~BalloonManager() { }
 
 	virtual void freeBalloons() = 0;
 	virtual int setLocationBalloon(char *text, bool endGame) = 0;
-	virtual int setDialogueBalloon(char *text, uint16 winding, byte textColor) = 0;
-	virtual int setSingleBalloon(char *text, uint16 x, uint16 y, uint16 winding, byte textColor) = 0;
-	virtual void setBalloonText(uint id, char *text, byte textColor) = 0;
+	virtual int setDialogueBalloon(char *text, uint16 winding, TextColor textColor) = 0;
+	virtual int setSingleBalloon(char *text, uint16 x, uint16 y, uint16 winding, TextColor textColor) = 0;
+	virtual void setBalloonText(uint id, char *text, TextColor textColor) = 0;
 	virtual int hitTestDialogueBalloon(int x, int y) = 0;
 };
 


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