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

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Thu Jul 3 12:31:26 CEST 2008


Revision: 32883
          http://scummvm.svn.sourceforge.net/scummvm/?rev=32883&view=rev
Author:   peres001
Date:     2008-07-03 03:31:25 -0700 (Thu, 03 Jul 2008)

Log Message:
-----------
Changed balloons to use GfxObj as well. Next step is to integrate balloons for BRA.

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/disk.h
    scummvm/trunk/engines/parallaction/disk_br.cpp
    scummvm/trunk/engines/parallaction/disk_ns.cpp
    scummvm/trunk/engines/parallaction/gfxbase.cpp
    scummvm/trunk/engines/parallaction/graphics.cpp
    scummvm/trunk/engines/parallaction/graphics.h

Modified: scummvm/trunk/engines/parallaction/disk.h
===================================================================
--- scummvm/trunk/engines/parallaction/disk.h	2008-07-03 10:26:55 UTC (rev 32882)
+++ scummvm/trunk/engines/parallaction/disk.h	2008-07-03 10:31:25 UTC (rev 32883)
@@ -61,7 +61,7 @@
 	virtual GfxObj* loadHead(const char* name) = 0;
 	virtual Font* loadFont(const char* name) = 0;
 	virtual GfxObj* loadStatic(const char* name) = 0;
-	virtual GfxObj* loadFrames(const char* name) = 0;
+	virtual Frames* loadFrames(const char* name) = 0;
 	virtual void loadSlide(BackgroundInfo& info, const char *filename) = 0;
 	virtual void loadScenery(BackgroundInfo& info, const char* background, const char* mask, const char* path) = 0;
 	virtual Table* loadTable(const char* name) = 0;
@@ -153,7 +153,7 @@
 	GfxObj* loadHead(const char* name);
 	Font* loadFont(const char* name);
 	GfxObj* loadStatic(const char* name);
-	GfxObj* loadFrames(const char* name);
+	Frames* loadFrames(const char* name);
 	void loadSlide(BackgroundInfo& info, const char *filename);
 	void loadScenery(BackgroundInfo& info, const char* background, const char* mask, const char* path);
 	Table* loadTable(const char* name);
@@ -187,7 +187,7 @@
 	GfxObj* loadHead(const char* name);
 	Font* loadFont(const char* name);
 	GfxObj* loadStatic(const char* name);
-	GfxObj* loadFrames(const char* name);
+	Frames* loadFrames(const char* name);
 	void loadSlide(BackgroundInfo& info, const char *filename);
 	void loadScenery(BackgroundInfo& info, const char* background, const char* mask, const char* path);
 	Table* loadTable(const char* name);
@@ -226,7 +226,7 @@
 	GfxObj* loadHead(const char* name);
 	Font* loadFont(const char* name);
 	GfxObj* loadStatic(const char* name);
-	GfxObj* loadFrames(const char* name);
+	Frames* loadFrames(const char* name);
 	void loadSlide(BackgroundInfo& info, const char *filename);
 	void loadScenery(BackgroundInfo& info, const char* name, const char* mask, const char* path);
 	Table* loadTable(const char* name);
@@ -251,7 +251,7 @@
 	GfxObj* loadTalk(const char *name);
 	Font* loadFont(const char* name);
 	GfxObj* loadStatic(const char* name);
-	GfxObj* loadFrames(const char* name);
+	Frames* loadFrames(const char* name);
 	void loadSlide(BackgroundInfo& info, const char *filename);
 	void loadScenery(BackgroundInfo& info, const char* name, const char* mask, const char* path);
 };

Modified: scummvm/trunk/engines/parallaction/disk_br.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/disk_br.cpp	2008-07-03 10:26:55 UTC (rev 32882)
+++ scummvm/trunk/engines/parallaction/disk_br.cpp	2008-07-03 10:31:25 UTC (rev 32883)
@@ -280,7 +280,7 @@
 	return sprites;
 }
 
-GfxObj* DosDisk_br::loadFrames(const char* name) {
+Frames* DosDisk_br::loadFrames(const char* name) {
 	debugC(5, kDebugDisk, "DosDisk_br::loadFrames");
 
 	char path[PATH_LEN];
@@ -291,7 +291,7 @@
 		errorFileNotFound(path);
 
 
-	return new GfxObj(0, createSprites(stream), name);
+	return createSprites(stream);
 }
 
 // Slides in Nippon Safes are basically screen-sized pictures with valid
@@ -600,13 +600,13 @@
 	return sprites;
 }
 
-GfxObj* AmigaDisk_br::loadFrames(const char* name) {
+Frames* AmigaDisk_br::loadFrames(const char* name) {
 	debugC(1, kDebugDisk, "AmigaDisk_br::loadFrames '%s'", name);
 
 	char path[PATH_LEN];
 	sprintf(path, "%s/anims/%s", _partPath, name);
 
-	return new GfxObj(0, createSprites(path));
+	return createSprites(path);
 }
 
 GfxObj* AmigaDisk_br::loadTalk(const char *name) {

Modified: scummvm/trunk/engines/parallaction/disk_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/disk_ns.cpp	2008-07-03 10:26:55 UTC (rev 32882)
+++ scummvm/trunk/engines/parallaction/disk_ns.cpp	2008-07-03 10:31:25 UTC (rev 32883)
@@ -490,8 +490,8 @@
 	return new GfxObj(0, new SurfaceToFrames(cnv), name);
 }
 
-GfxObj* DosDisk_ns::loadFrames(const char* name) {
-	return new GfxObj(0, loadCnv(name), name);
+Frames* DosDisk_ns::loadFrames(const char* name) {
+	return loadCnv(name);
 }
 
 //
@@ -1258,7 +1258,7 @@
 	return;
 }
 
-GfxObj* AmigaDisk_ns::loadFrames(const char* name) {
+Frames* AmigaDisk_ns::loadFrames(const char* name) {
 	debugC(1, kDebugDisk, "AmigaDisk_ns::loadFrames '%s'", name);
 
 	Common::SeekableReadStream *s;
@@ -1273,7 +1273,7 @@
 	Cnv *cnv = makeCnv(*s);
 	delete s;
 
-	return new GfxObj(0, cnv, name);
+	return cnv;
 }
 
 GfxObj* AmigaDisk_ns::loadHead(const char* name) {

Modified: scummvm/trunk/engines/parallaction/gfxbase.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/gfxbase.cpp	2008-07-03 10:26:55 UTC (rev 32882)
+++ scummvm/trunk/engines/parallaction/gfxbase.cpp	2008-07-03 10:31:25 UTC (rev 32883)
@@ -86,12 +86,14 @@
 }
 
 GfxObj* Gfx::loadAnim(const char *name) {
-	GfxObj *obj = _disk->loadFrames(name);
+	Frames* frames = _disk->loadFrames(name);
+	assert(frames);
+
+	GfxObj *obj = new GfxObj(kGfxObjTypeAnim, frames, name);
 	assert(obj);
 
 	// animation Z is not set here, but controlled by game scripts and user interaction.
 	// it is always >=0 and <screen height
-	obj->type = kGfxObjTypeAnim;
 	obj->transparentKey = 0;
 	_gfxobjList.push_back(obj);
 	return obj;
@@ -110,11 +112,13 @@
 }
 
 GfxObj* Gfx::loadDoor(const char *name) {
-	GfxObj *obj = _disk->loadFrames(name);
+	Frames *frames = _disk->loadFrames(name);
+	assert(frames);
+
+	GfxObj *obj = new GfxObj(kGfxObjTypeDoor, frames, name);
 	assert(obj);
 
 	obj->z = kGfxObjDoorZ;	// this preset Z value ensures that doors are drawn first
-	obj->type = kGfxObjTypeDoor;
 	obj->transparentKey = 0;
 	_gfxobjList.push_back(obj);
 	return obj;

Modified: scummvm/trunk/engines/parallaction/graphics.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.cpp	2008-07-03 10:26:55 UTC (rev 32882)
+++ scummvm/trunk/engines/parallaction/graphics.cpp	2008-07-03 10:31:25 UTC (rev 32883)
@@ -362,15 +362,13 @@
 }
 
 void Gfx::drawBalloons() {
-	if (_numBalloons == 0) {
+	if (_balloons.size() == 0) {
 		return;
 	}
 
 	Graphics::Surface *surf = g_system->lockScreen();
-	for (uint i = 0; i < _numBalloons; i++) {
-		Common::Rect r(_balloons[i].surface.w, _balloons[i].surface.h);
-		r.moveTo(_balloons[i].x, _balloons[i].y);
-		blt(r, (byte*)_balloons[i].surface.getBasePtr(0, 0), surf, LAYER_FOREGROUND, BALLOON_TRANSPARENT_COLOR);
+	for (uint i = 0; i < _balloons.size(); i++) {
+		drawGfxObject(_balloons[i], *surf, false);
 	}
 	g_system->unlockScreen();
 }
@@ -832,7 +830,7 @@
 
 Gfx::Balloon* Gfx::getBalloon(uint id) {
 	assert(id < _numBalloons);
-	return &_balloons[id];
+	return &_intBalloons[id];
 }
 
 int Gfx::createBalloon(int16 w, int16 h, int16 winding, uint16 borderThickness) {
@@ -840,18 +838,19 @@
 
 	int id = _numBalloons;
 
-	Gfx::Balloon *balloon = &_balloons[id];
+	Gfx::Balloon *balloon = &_intBalloons[id];
 
 	int16 real_h = (winding == -1) ? h : h + 9;
-	balloon->surface.create(w, real_h, 1);
-	balloon->surface.fillRect(Common::Rect(w, real_h), BALLOON_TRANSPARENT_COLOR);
+	balloon->surface = new Graphics::Surface;
+	balloon->surface->create(w, real_h, 1);
+	balloon->surface->fillRect(Common::Rect(w, real_h), BALLOON_TRANSPARENT_COLOR);
 
 	Common::Rect r(w, h);
-	balloon->surface.fillRect(r, 0);
+	balloon->surface->fillRect(r, 0);
 	balloon->outerBox = r;
 
 	r.grow(-borderThickness);
-	balloon->surface.fillRect(r, 1);
+	balloon->surface->fillRect(r, 1);
 	balloon->innerBox = r;
 
 	if (winding != -1) {
@@ -860,7 +859,7 @@
 		winding = (winding == 0 ? 1 : 0);
 		Common::Rect s(BALLOON_TAIL_WIDTH, BALLOON_TAIL_HEIGHT);
 		s.moveTo(r.width()/2 - 5, r.bottom - 1);
-		blt(s, _resBalloonTail[winding], &balloon->surface, LAYER_FOREGROUND, BALLOON_TRANSPARENT_COLOR);
+		blt(s, _resBalloonTail[winding], balloon->surface, LAYER_FOREGROUND, BALLOON_TRANSPARENT_COLOR);
 	}
 
 	_numBalloons++;
@@ -868,6 +867,20 @@
 	return id;
 }
 
+GfxObj* Gfx::registerBalloon(Frames *frames, const char *text) {
+
+	GfxObj *obj = new GfxObj(kGfxObjTypeBalloon, frames, text);
+
+	obj->layer = LAYER_FOREGROUND;
+	obj->frame = 0;
+	obj->transparentKey = BALLOON_TRANSPARENT_COLOR;
+	obj->setFlags(kGfxObjVisible);
+
+	_balloons.push_back(obj);
+
+	return obj;
+}
+
 int Gfx::setSingleBalloon(char *text, uint16 x, uint16 y, uint16 winding, byte textColor) {
 
 	int16 w, h;
@@ -875,12 +888,14 @@
 	getStringExtent(_vm->_dialogueFont, text, MAX_BALLOON_WIDTH, &w, &h);
 
 	int id = createBalloon(w+5, h, winding, 1);
-	Gfx::Balloon *balloon = &_balloons[id];
+	Gfx::Balloon *balloon = &_intBalloons[id];
 
-	drawWrappedText(_vm->_dialogueFont, &balloon->surface, text, textColor, MAX_BALLOON_WIDTH);
+	drawWrappedText(_vm->_dialogueFont, balloon->surface, text, textColor, MAX_BALLOON_WIDTH);
 
-	balloon->x = x;
-	balloon->y = y;
+	// TODO: extract some text to make a name for obj
+	balloon->obj = registerBalloon(new SurfaceToFrames(balloon->surface), 0);
+	balloon->obj->x = x;
+	balloon->obj->y = y;
 
 	return id;
 }
@@ -892,15 +907,17 @@
 	getStringExtent(_vm->_dialogueFont, text, MAX_BALLOON_WIDTH, &w, &h);
 
 	int id = createBalloon(w+5, h, winding, 1);
-	Gfx::Balloon *balloon = &_balloons[id];
+	Gfx::Balloon *balloon = &_intBalloons[id];
 
-	drawWrappedText(_vm->_dialogueFont, &balloon->surface, text, textColor, MAX_BALLOON_WIDTH);
+	drawWrappedText(_vm->_dialogueFont, balloon->surface, text, textColor, MAX_BALLOON_WIDTH);
 
-	balloon->x = _dialogueBalloonX[id];
-	balloon->y = 10;
+	// TODO: extract some text to make a name for obj
+	balloon->obj = registerBalloon(new SurfaceToFrames(balloon->surface), 0);
+	balloon->obj->x = _dialogueBalloonX[id];
+	balloon->obj->y = 10;
 
 	if (id > 0) {
-		balloon->y += _balloons[id - 1].y + _balloons[id - 1].outerBox.height();
+		balloon->obj->y += _intBalloons[id - 1].obj->y + _intBalloons[id - 1].outerBox.height();
 	}
 
 
@@ -909,8 +926,8 @@
 
 void Gfx::setBalloonText(uint id, char *text, byte textColor) {
 	Gfx::Balloon *balloon = getBalloon(id);
-	balloon->surface.fillRect(balloon->innerBox, 1);
-	drawWrappedText(_vm->_dialogueFont, &balloon->surface, text, textColor, MAX_BALLOON_WIDTH);
+	balloon->surface->fillRect(balloon->innerBox, 1);
+	drawWrappedText(_vm->_dialogueFont, balloon->surface, text, textColor, MAX_BALLOON_WIDTH);
 }
 
 
@@ -921,11 +938,13 @@
 	getStringExtent(_vm->_dialogueFont, text, MAX_BALLOON_WIDTH, &w, &h);
 
 	int id = createBalloon(w+(endGame ? 5 : 10), h+5, -1, BALLOON_TRANSPARENT_COLOR);
-	Gfx::Balloon *balloon = &_balloons[id];
-	drawWrappedText(_vm->_dialogueFont, &balloon->surface, text, 0, MAX_BALLOON_WIDTH);
+	Gfx::Balloon *balloon = &_intBalloons[id];
+	drawWrappedText(_vm->_dialogueFont, balloon->surface, text, 0, MAX_BALLOON_WIDTH);
 
-	balloon->x = 5;
-	balloon->y = 5;
+	// TODO: extract some text to make a name for obj
+	balloon->obj = registerBalloon(new SurfaceToFrames(balloon->surface), 0);
+	balloon->obj->x = 5;
+	balloon->obj->y = 5;
 
 	return id;
 }
@@ -935,10 +954,10 @@
 	Common::Point p;
 
 	for (uint i = 0; i < _numBalloons; i++) {
-		p.x = x - _balloons[i].x;
-		p.y = y - _balloons[i].y;
+		p.x = x - _intBalloons[i].obj->x;
+		p.y = y - _intBalloons[i].obj->y;
 
-		if (_balloons[i].innerBox.contains(p))
+		if (_intBalloons[i].innerBox.contains(p))
 			return i;
 	}
 
@@ -947,8 +966,12 @@
 
 
 void Gfx::freeBalloons() {
+	_balloons.clear();
+
 	for (uint i = 0; i < _numBalloons; i++) {
-		_balloons[i].surface.free();
+		delete _intBalloons[i].obj;
+		_intBalloons[i].obj = 0;
+		_intBalloons[i].surface = 0;	// no need to delete surface, since it is done by obj (GfxObj)
 	}
 	_numBalloons = 0;
 }

Modified: scummvm/trunk/engines/parallaction/graphics.h
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.h	2008-07-03 10:26:55 UTC (rev 32882)
+++ scummvm/trunk/engines/parallaction/graphics.h	2008-07-03 10:31:25 UTC (rev 32883)
@@ -344,7 +344,8 @@
 	kGfxObjTypeDoor = 0,
 	kGfxObjTypeGet = 1,
 	kGfxObjTypeAnim = 2,
-	kGfxObjTypeLabel = 3
+	kGfxObjTypeLabel = 3,
+	kGfxObjTypeBalloon = 4
 };
 
 enum {
@@ -484,6 +485,7 @@
 	void setBalloonText(uint id, char *text, byte textColor);
 	int hitTestDialogueBalloon(int x, int y);
 	void getStringExtent(Font *font, char *text, uint16 maxwidth, int16* width, int16* height);
+	GfxObj* registerBalloon(Frames *frames, const char *text);
 
 	// other items
 	int setItem(GfxObj* obj, uint16 x, uint16 y, byte transparentColor = 0);
@@ -552,13 +554,11 @@
 	static int16 _dialogueBalloonX[5];
 
 	struct Balloon {
-		uint16 x;
-		uint16 y;
 		Common::Rect outerBox;
 		Common::Rect innerBox;
-		uint16 winding;
-		Graphics::Surface surface;
-	} _balloons[5];
+		Graphics::Surface *surface;
+		GfxObj	*obj;
+	} _intBalloons[5];
 
 	uint	_numBalloons;
 
@@ -573,6 +573,7 @@
 
 	typedef Common::Array<GfxObj*> GfxObjArray;
 	GfxObjArray	_labels;
+	GfxObjArray _balloons;
 
 	uint _floatingLabel;
 


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