[Scummvm-cvs-logs] SF.net SVN: scummvm:[48828] scummvm/branches/branch-1-1-0/engines/ parallaction

wjpalenstijn at users.sourceforge.net wjpalenstijn at users.sourceforge.net
Wed Apr 28 20:55:50 CEST 2010


Revision: 48828
          http://scummvm.svn.sourceforge.net/scummvm/?rev=48828&view=rev
Author:   wjpalenstijn
Date:     2010-04-28 18:55:48 +0000 (Wed, 28 Apr 2010)

Log Message:
-----------
Backport r48811, r48827: fix for bug 2969257 (labels)

Modified Paths:
--------------
    scummvm/branches/branch-1-1-0/engines/parallaction/callables_ns.cpp
    scummvm/branches/branch-1-1-0/engines/parallaction/exec_br.cpp
    scummvm/branches/branch-1-1-0/engines/parallaction/graphics.cpp
    scummvm/branches/branch-1-1-0/engines/parallaction/graphics.h
    scummvm/branches/branch-1-1-0/engines/parallaction/gui_ns.cpp
    scummvm/branches/branch-1-1-0/engines/parallaction/objects.cpp
    scummvm/branches/branch-1-1-0/engines/parallaction/objects.h
    scummvm/branches/branch-1-1-0/engines/parallaction/parallaction.h
    scummvm/branches/branch-1-1-0/engines/parallaction/parallaction_br.cpp
    scummvm/branches/branch-1-1-0/engines/parallaction/parallaction_ns.cpp

Modified: scummvm/branches/branch-1-1-0/engines/parallaction/callables_ns.cpp
===================================================================
--- scummvm/branches/branch-1-1-0/engines/parallaction/callables_ns.cpp	2010-04-28 18:50:22 UTC (rev 48827)
+++ scummvm/branches/branch-1-1-0/engines/parallaction/callables_ns.cpp	2010-04-28 18:55:48 UTC (rev 48828)
@@ -409,13 +409,14 @@
 
 	parseLocation("common");
 
-	uint id[2];
-	id[0] = _gfx->createLabel(_menuFont, _location._slideText[0].c_str(), 1);
-	id[1] = _gfx->createLabel(_menuFont, _location._slideText[1].c_str(), 1);
+	GfxObj *labels[2];
+	labels[0] = _gfx->createLabel(_menuFont, _location._slideText[0].c_str(), 1);
+	labels[1] = _gfx->createLabel(_menuFont, _location._slideText[1].c_str(), 1);
 
-	_gfx->showLabel(id[0], CENTER_LABEL_HORIZONTAL, 38);
-	_gfx->showLabel(id[1], CENTER_LABEL_HORIZONTAL, 58);
+	_gfx->showLabel(labels[0], CENTER_LABEL_HORIZONTAL, 38);
+	_gfx->showLabel(labels[1], CENTER_LABEL_HORIZONTAL, 58);
 
+	// FIXME: this leaks two labels
 	return;
 }
 

Modified: scummvm/branches/branch-1-1-0/engines/parallaction/exec_br.cpp
===================================================================
--- scummvm/branches/branch-1-1-0/engines/parallaction/exec_br.cpp	2010-04-28 18:50:22 UTC (rev 48827)
+++ scummvm/branches/branch-1-1-0/engines/parallaction/exec_br.cpp	2010-04-28 18:55:48 UTC (rev 48828)
@@ -96,7 +96,7 @@
 		_subtitle[1] = _gfx->createLabel(_labelFont, s2, color);
 		_gfx->showLabel(_subtitle[1], CENTER_LABEL_HORIZONTAL, _subtitleY + 5 + _labelFont->height());
 	} else {
-		_subtitle[1] = -1;
+		_subtitle[1] = 0;
 	}
 #if 0	// disabled because no references to lip sync has been found in the scripts
 	_subtitleLipSync = 0;
@@ -104,11 +104,11 @@
 }
 
 void Parallaction_br::clearSubtitles() {
-	if (_subtitle[0] != -1) {
+	if (_subtitle[0]) {
 		_gfx->hideLabel(_subtitle[0]);
 	}
 
-	if (_subtitle[1] != -1) {
+	if (_subtitle[1]) {
 		_gfx->hideLabel(_subtitle[1]);
 	}
 }

Modified: scummvm/branches/branch-1-1-0/engines/parallaction/graphics.cpp
===================================================================
--- scummvm/branches/branch-1-1-0/engines/parallaction/graphics.cpp	2010-04-28 18:50:22 UTC (rev 48827)
+++ scummvm/branches/branch-1-1-0/engines/parallaction/graphics.cpp	2010-04-28 18:55:48 UTC (rev 48828)
@@ -524,7 +524,7 @@
 	surf.fillRect(Common::Rect(w,h), LABEL_TRANSPARENT_COLOR);
 }
 
-uint Gfx::renderFloatingLabel(Font *font, char *text) {
+GfxObj *Gfx::renderFloatingLabel(Font *font, char *text) {
 
 	Graphics::Surface *cnv = new Graphics::Surface;
 
@@ -555,34 +555,32 @@
 	obj->transparentKey = LABEL_TRANSPARENT_COLOR;
 	obj->layer = LAYER_FOREGROUND;
 
-	uint id = _labels.size();
-	_labels.insert_at(id, obj);
-
-	return id;
+	return obj;
 }
 
-void Gfx::showFloatingLabel(uint label) {
-	assert(label < _labels.size());
-
+void Gfx::showFloatingLabel(GfxObj *label) {
 	hideFloatingLabel();
 
-	_labels[label]->x = -1000;
-	_labels[label]->y = -1000;
-	_labels[label]->setFlags(kGfxObjVisible);
-
-	_floatingLabel = label;
+	if (label) {
+		label->x = -1000;
+		label->y = -1000;
+		label->setFlags(kGfxObjVisible);
+	
+		_floatingLabel = label;
+		_labels.push_back(label);
+	}
 }
 
 void Gfx::hideFloatingLabel() {
-	if (_floatingLabel != NO_FLOATING_LABEL) {
-		_labels[_floatingLabel]->clearFlags(kGfxObjVisible);
+	if (_floatingLabel != 0) {
+		_floatingLabel->clearFlags(kGfxObjVisible);
 	}
-	_floatingLabel = NO_FLOATING_LABEL;
+	_floatingLabel = 0;
 }
 
 
 void Gfx::updateFloatingLabel() {
-	if (_floatingLabel == NO_FLOATING_LABEL) {
+	if (_floatingLabel == 0) {
 		return;
 	}
 
@@ -596,7 +594,7 @@
 	} *traits;
 
 	Common::Rect r;
-	_labels[_floatingLabel]->getRect(0, r);
+	_floatingLabel->getRect(0, r);
 
 	if (_gameType == GType_Nippon) {
 		FloatingLabelTraits traits_NS = {
@@ -619,14 +617,14 @@
 	_vm->_input->getCursorPos(cursor);
 	Common::Point offset = (_vm->_input->_activeItem._id) ? traits->_offsetWithItem : traits->_offsetWithoutItem;
 
-	_labels[_floatingLabel]->x = CLIP(cursor.x + offset.x, traits->_minX, traits->_maxX);
-	_labels[_floatingLabel]->y = CLIP(cursor.y + offset.y, traits->_minY, traits->_maxY);
+	_floatingLabel->x = CLIP(cursor.x + offset.x, traits->_minX, traits->_maxX);
+	_floatingLabel->y = CLIP(cursor.y + offset.y, traits->_minY, traits->_maxY);
 }
 
 
 
 
-uint Gfx::createLabel(Font *font, const char *text, byte color) {
+GfxObj *Gfx::createLabel(Font *font, const char *text, byte color) {
 	Graphics::Surface *cnv = new Graphics::Surface;
 
 	uint w, h;
@@ -652,19 +650,18 @@
 	obj->transparentKey = LABEL_TRANSPARENT_COLOR;
 	obj->layer = LAYER_FOREGROUND;
 
-	int id = _labels.size();
+	return obj;
+}
 
-	_labels.insert_at(id, obj);
+void Gfx::showLabel(GfxObj *label, int16 x, int16 y) {
+	if (!label) {
+		return;
+	}
 
-	return id;
-}
+	label->setFlags(kGfxObjVisible);
 
-void Gfx::showLabel(uint id, int16 x, int16 y) {
-	assert(id < _labels.size());
-	_labels[id]->setFlags(kGfxObjVisible);
-
 	Common::Rect r;
-	_labels[id]->getRect(0, r);
+	label->getRect(0, r);
 
 	if (x == CENTER_LABEL_HORIZONTAL) {
 		x = CLIP<int16>((_backgroundInfo->width - r.width()) / 2, 0, _backgroundInfo->width/2);
@@ -674,23 +671,32 @@
 		y = CLIP<int16>((_vm->_screenHeight - r.height()) / 2, 0, _vm->_screenHeight/2);
 	}
 
-	_labels[id]->x = x;
-	_labels[id]->y = y;
+	label->x = x;
+	label->y = y;
+	
+	_labels.push_back(label);
 }
 
-void Gfx::hideLabel(uint id) {
-	assert(id < _labels.size());
-	_labels[id]->clearFlags(kGfxObjVisible);
+void Gfx::hideLabel(GfxObj *label) {
+	if (label) {
+		label->clearFlags(kGfxObjVisible);
+		unregisterLabel(label);
+	}
 }
 
 void Gfx::freeLabels() {
-	for (uint i = 0; i < _labels.size(); i++) {
-		delete _labels[i];
-	}
 	_labels.clear();
-	_floatingLabel = NO_FLOATING_LABEL;
+	_floatingLabel = 0;
 }
 
+void Gfx::unregisterLabel(GfxObj *label) {
+	for (uint i = 0; i < _labels.size(); i++) {
+		if (_labels[i] == label) {
+			_labels.remove_at(i);
+			break;
+		}
+	}	
+}
 
 
 void Gfx::copyRect(const Common::Rect &r, Graphics::Surface &src, Graphics::Surface &dst) {
@@ -724,7 +730,7 @@
 
 	setPalette(_palette);
 
-	_floatingLabel = NO_FLOATING_LABEL;
+	_floatingLabel = 0;
 
 	_backgroundInfo = 0;
 

Modified: scummvm/branches/branch-1-1-0/engines/parallaction/graphics.h
===================================================================
--- scummvm/branches/branch-1-1-0/engines/parallaction/graphics.h	2010-04-28 18:50:22 UTC (rev 48827)
+++ scummvm/branches/branch-1-1-0/engines/parallaction/graphics.h	2010-04-28 18:55:48 UTC (rev 48828)
@@ -444,14 +444,15 @@
 	void unpackBlt(const Common::Rect& r, byte *data, uint size, Graphics::Surface *surf, uint16 z, uint scale, byte transparentColor);
 
 	// labels
-	void showFloatingLabel(uint label);
+	void showFloatingLabel(GfxObj *label);
 	void hideFloatingLabel();
 
-	uint renderFloatingLabel(Font *font, char *text);
-	uint createLabel(Font *font, const char *text, byte color);
-	void showLabel(uint id, int16 x, int16 y);
-	void hideLabel(uint id);
+	GfxObj *renderFloatingLabel(Font *font, char *text);
+	GfxObj *createLabel(Font *font, const char *text, byte color);
+	void showLabel(GfxObj *label, int16 x, int16 y);
+	void hideLabel(GfxObj *label);
 	void freeLabels();
+	void unregisterLabel(GfxObj *label);
 
 	// dialogue handling
 	GfxObj* registerBalloon(Frames *frames, const char *text);
@@ -528,11 +529,18 @@
 	void				scroll();
 	#define NO_FLOATING_LABEL	1000
 
+	struct Label {
+		Common::String _text;
+		int  _x, _y;
+		int color;
+		bool _floating;
+	};
+
 	GfxObjArray	_labels;
 	GfxObjArray _balloons;
 	GfxObjArray	_items;
 
-	uint _floatingLabel;
+	GfxObj *_floatingLabel;
 
 	// overlay mode enables drawing of graphics with automatic screen-to-game coordinate translation
 	bool				_overlayMode;

Modified: scummvm/branches/branch-1-1-0/engines/parallaction/gui_ns.cpp
===================================================================
--- scummvm/branches/branch-1-1-0/engines/parallaction/gui_ns.cpp	2010-04-28 18:50:22 UTC (rev 48827)
+++ scummvm/branches/branch-1-1-0/engines/parallaction/gui_ns.cpp	2010-04-28 18:55:48 UTC (rev 48828)
@@ -107,6 +107,7 @@
 	bool	_allowChoice;
 	Common::String _nextState;
 
+	GfxObj *_label;
 	static const Common::Rect _dosLanguageSelectBlocks[4];
 	static const Common::Rect _amigaLanguageSelectBlocks[4];
 	const Common::Rect *_blocks;
@@ -135,10 +136,21 @@
 			_blocks = _dosLanguageSelectBlocks;
 		}
 
+		_label = 0;
 		_language = -1;
 		_allowChoice = true;
 	}
+	
+	~ChooseLanguageInputState_NS() {
+		destroyLabels();
+	}
 
+	void destroyLabels() {
+		_vm->_gfx->unregisterLabel(_label);
+		delete _label;
+		_label = 0;
+	}
+
 	virtual MenuInputState* run() {
 		if (!_allowChoice) {
 			_vm->setInternLanguage(_language);
@@ -157,7 +169,7 @@
 			if (_blocks[i].contains(p)) {
 				_vm->setInternLanguage(i);
 				_vm->beep();
-				_vm->_gfx->freeLabels();
+				destroyLabels();
 				return _helper->getState(_nextState);
 			}
 		}
@@ -175,8 +187,8 @@
 		// user can choose language in this version
 		_vm->showSlide("lingua");
 
-		uint id = _vm->_gfx->createLabel(_vm->_introFont, "SELECT LANGUAGE", 1);
-		_vm->_gfx->showLabel(id, 60, 30);
+		_label = _vm->_gfx->createLabel(_vm->_introFont, "SELECT LANGUAGE", 1);
+		_vm->_gfx->showLabel(_label, 60, 30);
 
 		_vm->_input->setArrowCursor();
 	}
@@ -201,7 +213,7 @@
 	int _choice, _oldChoice;
 	Common::String _nextState[2];
 
-	uint	_labels[2];
+	GfxObj	*_labels[2];
 
 	Parallaction *_vm;
 
@@ -215,14 +227,30 @@
 
 		_nextState[0] = "newgame";
 		_nextState[1] = "loadgame";
+		
+		_labels[0] = 0;
+		_labels[1] = 0;
 	}
+	
+	~SelectGameInputState_NS() {
+		destroyLabels();
+	}
+	
+	void destroyLabels() {
+		_vm->_gfx->unregisterLabel(_labels[0]);
+		_vm->_gfx->unregisterLabel(_labels[1]);
+		delete _labels[0];
+		delete _labels[1];
+		_labels[0] = 0;
+		_labels[1] = 0;
+	}
 
 
 	virtual MenuInputState *run() {
 		int event = _vm->_input->getLastButtonEvent();
 
 		if (event == kMouseLeftUp) {
-			_vm->_gfx->freeLabels();
+			destroyLabels();
 			return _helper->getState(_nextState[_choice]);
 		}
 
@@ -293,18 +321,27 @@
 class NewGameInputState_NS : public MenuInputState {
 	Parallaction_ns *_vm;
 
+	GfxObj *_labels[4];
 	static const char *introMsg3[4];
 
 public:
 	NewGameInputState_NS(Parallaction_ns *vm, MenuInputHelper *helper) : MenuInputState("newgame", helper), _vm(vm) {
+		_labels[0] = 0;
+		_labels[1] = 0;
+		_labels[2] = 0;
+		_labels[3] = 0;
 	}
+	
+	~NewGameInputState_NS() {
+		destroyLabels();
+	}
 
 	virtual MenuInputState* run() {
 		int event = _vm->_input->getLastButtonEvent();
 
 		if (event == kMouseLeftUp || event == kMouseRightUp) {
 			_vm->_input->setMouseState(MOUSE_ENABLED_SHOW);
-			_vm->_gfx->freeLabels();
+			destroyLabels();
 
 			if (event == kMouseLeftUp) {
 				_vm->scheduleLocationSwitch("fogne.dough");
@@ -317,19 +354,33 @@
 		return this;
 	}
 
+	void destroyLabels() {
+		_vm->_gfx->unregisterLabel(_labels[0]);
+		_vm->_gfx->unregisterLabel(_labels[1]);
+		_vm->_gfx->unregisterLabel(_labels[2]);
+		_vm->_gfx->unregisterLabel(_labels[3]);
+		delete _labels[0];
+		delete _labels[1];
+		delete _labels[2];
+		delete _labels[3];
+		_labels[0] = 0;
+		_labels[1] = 0;
+		_labels[2] = 0;
+		_labels[3] = 0;
+	}
+
 	virtual void enter() {
 		_vm->changeBackground("test");
 		_vm->_input->setMouseState(MOUSE_ENABLED_HIDE);
 
-		uint id[4];
-		id[0] = _vm->_gfx->createLabel(_vm->_menuFont, introMsg3[0], 1);
-		id[1] = _vm->_gfx->createLabel(_vm->_menuFont, introMsg3[1], 1);
-		id[2] = _vm->_gfx->createLabel(_vm->_menuFont, introMsg3[2], 1);
-		id[3] = _vm->_gfx->createLabel(_vm->_menuFont, introMsg3[3], 1);
-		_vm->_gfx->showLabel(id[0], CENTER_LABEL_HORIZONTAL, 50);
-		_vm->_gfx->showLabel(id[1], CENTER_LABEL_HORIZONTAL, 70);
-		_vm->_gfx->showLabel(id[2], CENTER_LABEL_HORIZONTAL, 100);
-		_vm->_gfx->showLabel(id[3], CENTER_LABEL_HORIZONTAL, 120);
+		_labels[0] = _vm->_gfx->createLabel(_vm->_menuFont, introMsg3[0], 1);
+		_labels[1] = _vm->_gfx->createLabel(_vm->_menuFont, introMsg3[1], 1);
+		_labels[2] = _vm->_gfx->createLabel(_vm->_menuFont, introMsg3[2], 1);
+		_labels[3] = _vm->_gfx->createLabel(_vm->_menuFont, introMsg3[3], 1);
+		_vm->_gfx->showLabel(_labels[0], CENTER_LABEL_HORIZONTAL, 50);
+		_vm->_gfx->showLabel(_labels[1], CENTER_LABEL_HORIZONTAL, 70);
+		_vm->_gfx->showLabel(_labels[2], CENTER_LABEL_HORIZONTAL, 100);
+		_vm->_gfx->showLabel(_labels[3], CENTER_LABEL_HORIZONTAL, 120);
 	}
 };
 
@@ -402,7 +453,7 @@
 	Graphics::Surface _block;
 	Graphics::Surface _emptySlots;
 
-	uint	_labels[2];
+	GfxObj	*_labels[2];
 	uint	_len;
 	uint32	_startTime;
 
@@ -427,13 +478,26 @@
 	SelectCharacterInputState_NS(Parallaction_ns *vm, MenuInputHelper *helper) : MenuInputState("selectcharacter", helper), _vm(vm) {
 		_keys = (_vm->getPlatform() == Common::kPlatformAmiga && (_vm->getFeatures() & GF_LANG_MULT)) ? _amigaKeys : _pcKeys;
 		_block.create(BLOCK_WIDTH, BLOCK_HEIGHT, 1);
+		_labels[0] = 0;
+		_labels[1] = 0;
 	}
 
 	~SelectCharacterInputState_NS() {
 		_block.free();
 		_emptySlots.free();
+
+		destroyLabels();
 	}
 
+	void destroyLabels() {
+		_vm->_gfx->unregisterLabel(_labels[0]);
+		_vm->_gfx->unregisterLabel(_labels[1]);
+		delete _labels[0];
+		delete _labels[1];
+		_labels[0] = 0;
+		_labels[1] = 0;
+	}
+
 	void cleanup() {
 		_points[0] = _points[1] = _points[2] = 0;
 		_vm->_gfx->hideLabel(_labels[1]);
@@ -490,7 +554,7 @@
 	}
 
 	void success() {
-		_vm->_gfx->freeLabels();
+		destroyLabels();
 		_vm->_gfx->setBlackPalette();
 		_emptySlots.free();
 
@@ -628,17 +692,34 @@
 	};
 
 	static const Credit _credits[6];
+	GfxObj *_labels[2];
 
 public:
 	ShowCreditsInputState_NS(Parallaction *vm, MenuInputHelper *helper) : MenuInputState("showcredits", helper), _vm(vm) {
+		_labels[0] = 0;
+		_labels[1] = 0;
 	}
 
+	~ShowCreditsInputState_NS() {
+		destroyLabels();
+	}
+
+	void destroyLabels() {
+		_vm->_gfx->unregisterLabel(_labels[0]);
+		_vm->_gfx->unregisterLabel(_labels[1]);
+		delete _labels[0];
+		delete _labels[1];	
+		_labels[0] = 0;
+		_labels[1] = 0;
+	}
+
 	void drawCurrentLabel() {
-		uint id[2];
-		id[0] = _vm->_gfx->createLabel(_vm->_menuFont, _credits[_current]._role, 1);
-		id[1] = _vm->_gfx->createLabel(_vm->_menuFont, _credits[_current]._name, 1);
-		_vm->_gfx->showLabel(id[0], CENTER_LABEL_HORIZONTAL, 80);
-		_vm->_gfx->showLabel(id[1], CENTER_LABEL_HORIZONTAL, 100);
+		destroyLabels();
+
+		_labels[0] = _vm->_gfx->createLabel(_vm->_menuFont, _credits[_current]._role, 1);
+		_labels[1] = _vm->_gfx->createLabel(_vm->_menuFont, _credits[_current]._name, 1);
+		_vm->_gfx->showLabel(_labels[0], CENTER_LABEL_HORIZONTAL, 80);
+		_vm->_gfx->showLabel(_labels[1], CENTER_LABEL_HORIZONTAL, 100);
 	}
 
 
@@ -655,7 +736,7 @@
 		if ((event == kMouseLeftUp) || (curTime - _startTime > 5500)) {
 			_current++;
 			_startTime = curTime;
-			_vm->_gfx->freeLabels();
+			destroyLabels();
 
 			if (_current == 6) {
 				return _helper->getState("endintro");
@@ -685,12 +766,24 @@
 class EndIntroInputState_NS : public MenuInputState {
 	Parallaction_ns *_vm;
 	bool _isDemo;
+	GfxObj *_label;
 
 public:
 	EndIntroInputState_NS(Parallaction_ns *vm, MenuInputHelper *helper) : MenuInputState("endintro", helper), _vm(vm) {
 		_isDemo = (_vm->getFeatures() & GF_DEMO) != 0;
+		_label = 0;
 	}
 
+	~EndIntroInputState_NS() {
+		destroyLabels();
+	}
+
+	void destroyLabels() {
+		_vm->_gfx->unregisterLabel(_label);
+		delete _label;
+		_label = 0;
+	}
+
 	virtual MenuInputState* run() {
 
 		int event = _vm->_input->getLastButtonEvent();
@@ -703,7 +796,7 @@
 			return 0;
 		}
 
-		_vm->_gfx->freeLabels();
+		destroyLabels();
 		_engineFlags &= ~kEngineBlockInput;
 		return _helper->getState("selectcharacter");
 	}
@@ -713,8 +806,8 @@
 
 		if (!_isDemo) {
 			_vm->_soundManI->stopMusic();
-			int label = _vm->_gfx->createLabel(_vm->_menuFont, "CLICK MOUSE BUTTON TO START", 1);
-			_vm->_gfx->showLabel(label, CENTER_LABEL_HORIZONTAL, 80);
+			_label = _vm->_gfx->createLabel(_vm->_menuFont, "CLICK MOUSE BUTTON TO START", 1);
+			_vm->_gfx->showLabel(_label, CENTER_LABEL_HORIZONTAL, 80);
 		}
 	}
 };
@@ -735,10 +828,32 @@
 	static const char *endMsg6[4];
 	static const char *endMsg7[4];
 
+	GfxObj *_labels[4];
 
 public:
 	EndPartInputState_NS(Parallaction *vm, MenuInputHelper *helper) : MenuInputState("endpart", helper), _vm(vm) {
+		_labels[0] = 0;
+		_labels[1] = 0;
+		_labels[2] = 0;
+		_labels[3] = 0;
 	}
+	
+	void destroyLabels() {
+		_vm->_gfx->unregisterLabel(_labels[0]);
+		_vm->_gfx->unregisterLabel(_labels[1]);
+		_vm->_gfx->unregisterLabel(_labels[2]);
+		_vm->_gfx->unregisterLabel(_labels[3]);
+		
+		delete _labels[0];
+		delete _labels[1];
+		delete _labels[2];
+		delete _labels[3];
+		
+		_labels[0] = 0;
+		_labels[1] = 0;
+		_labels[2] = 0;
+		_labels[3] = 0;
+	}
 
 	virtual MenuInputState* run() {
 		int event = _vm->_input->getLastButtonEvent();
@@ -746,7 +861,7 @@
 			return this;
 		}
 
-		_vm->_gfx->freeLabels();
+		destroyLabels();
 
 		if (_allPartsComplete) {
 			_vm->scheduleLocationSwitch("estgrotta.drki");
@@ -763,23 +878,22 @@
 		_vm->_input->setMouseState(MOUSE_DISABLED);
 
 		uint16 language = _vm->getInternLanguage();
-		uint id[4];
 		if (_allPartsComplete) {
-			id[0] = _vm->_gfx->createLabel(_vm->_menuFont, endMsg4[language], 1);
-			id[1] = _vm->_gfx->createLabel(_vm->_menuFont, endMsg5[language], 1);
-			id[2] = _vm->_gfx->createLabel(_vm->_menuFont, endMsg6[language], 1);
-			id[3] = _vm->_gfx->createLabel(_vm->_menuFont, endMsg7[language], 1);
+			_labels[0] = _vm->_gfx->createLabel(_vm->_menuFont, endMsg4[language], 1);
+			_labels[1] = _vm->_gfx->createLabel(_vm->_menuFont, endMsg5[language], 1);
+			_labels[2] = _vm->_gfx->createLabel(_vm->_menuFont, endMsg6[language], 1);
+			_labels[3] = _vm->_gfx->createLabel(_vm->_menuFont, endMsg7[language], 1);
 		} else {
-			id[0] = _vm->_gfx->createLabel(_vm->_menuFont, endMsg0[language], 1);
-			id[1] = _vm->_gfx->createLabel(_vm->_menuFont, endMsg1[language], 1);
-			id[2] = _vm->_gfx->createLabel(_vm->_menuFont, endMsg2[language], 1);
-			id[3] = _vm->_gfx->createLabel(_vm->_menuFont, endMsg3[language], 1);
+			_labels[0] = _vm->_gfx->createLabel(_vm->_menuFont, endMsg0[language], 1);
+			_labels[1] = _vm->_gfx->createLabel(_vm->_menuFont, endMsg1[language], 1);
+			_labels[2] = _vm->_gfx->createLabel(_vm->_menuFont, endMsg2[language], 1);
+			_labels[3] = _vm->_gfx->createLabel(_vm->_menuFont, endMsg3[language], 1);
 		}
 
-		_vm->_gfx->showLabel(id[0], CENTER_LABEL_HORIZONTAL, 70);
-		_vm->_gfx->showLabel(id[1], CENTER_LABEL_HORIZONTAL, 100);
-		_vm->_gfx->showLabel(id[2], CENTER_LABEL_HORIZONTAL, 130);
-		_vm->_gfx->showLabel(id[3], CENTER_LABEL_HORIZONTAL, 160);
+		_vm->_gfx->showLabel(_labels[0], CENTER_LABEL_HORIZONTAL, 70);
+		_vm->_gfx->showLabel(_labels[1], CENTER_LABEL_HORIZONTAL, 100);
+		_vm->_gfx->showLabel(_labels[2], CENTER_LABEL_HORIZONTAL, 130);
+		_vm->_gfx->showLabel(_labels[3], CENTER_LABEL_HORIZONTAL, 160);
 	}
 };
 

Modified: scummvm/branches/branch-1-1-0/engines/parallaction/objects.cpp
===================================================================
--- scummvm/branches/branch-1-1-0/engines/parallaction/objects.cpp	2010-04-28 18:50:22 UTC (rev 48827)
+++ scummvm/branches/branch-1-1-0/engines/parallaction/objects.cpp	2010-04-28 18:55:48 UTC (rev 48828)
@@ -204,6 +204,8 @@
 }
 
 Zone::~Zone() {
+	_vm->_gfx->unregisterLabel(_label);
+	delete _label;
 }
 
 void Zone::translate(int16 x, int16 y) {

Modified: scummvm/branches/branch-1-1-0/engines/parallaction/objects.h
===================================================================
--- scummvm/branches/branch-1-1-0/engines/parallaction/objects.h	2010-04-28 18:50:22 UTC (rev 48827)
+++ scummvm/branches/branch-1-1-0/engines/parallaction/objects.h	2010-04-28 18:55:48 UTC (rev 48828)
@@ -272,7 +272,7 @@
 
 	uint32			_type;
 	uint32			_flags;
-	uint			_label;
+	GfxObj			*_label;
 
 	TypeData		u;
 	CommandList		_commands;

Modified: scummvm/branches/branch-1-1-0/engines/parallaction/parallaction.h
===================================================================
--- scummvm/branches/branch-1-1-0/engines/parallaction/parallaction.h	2010-04-28 18:50:22 UTC (rev 48827)
+++ scummvm/branches/branch-1-1-0/engines/parallaction/parallaction.h	2010-04-28 18:55:48 UTC (rev 48828)
@@ -546,7 +546,7 @@
 	uint		_subtitleLipSync;
 #endif
 	int			_subtitleY;
-	int			_subtitle[2];
+	GfxObj		*_subtitle[2];
 	ZonePtr		_activeZone2;
 	uint32		_zoneFlags[NUM_LOCATIONS][NUM_ZONES];
 

Modified: scummvm/branches/branch-1-1-0/engines/parallaction/parallaction_br.cpp
===================================================================
--- scummvm/branches/branch-1-1-0/engines/parallaction/parallaction_br.cpp	2010-04-28 18:50:22 UTC (rev 48827)
+++ scummvm/branches/branch-1-1-0/engines/parallaction/parallaction_br.cpp	2010-04-28 18:55:48 UTC (rev 48828)
@@ -87,8 +87,8 @@
 
 	_part = -1;
 
-	_subtitle[0] = -1;
-	_subtitle[1] = -1;
+	_subtitle[0] = 0;
+	_subtitle[1] = 0;
 
 	memset(_zoneFlags, 0, sizeof(_zoneFlags));
 
@@ -226,7 +226,7 @@
 void Parallaction_br::freeLocation(bool removeAll) {
 	// free open location stuff
 	clearSubtitles();
-	_subtitle[0] = _subtitle[1] = -1;
+	_subtitle[0] = _subtitle[1] = 0;
 
 	_localFlagNames->clear();
 

Modified: scummvm/branches/branch-1-1-0/engines/parallaction/parallaction_ns.cpp
===================================================================
--- scummvm/branches/branch-1-1-0/engines/parallaction/parallaction_ns.cpp	2010-04-28 18:50:22 UTC (rev 48827)
+++ scummvm/branches/branch-1-1-0/engines/parallaction/parallaction_ns.cpp	2010-04-28 18:55:48 UTC (rev 48828)
@@ -214,7 +214,10 @@
 
 Parallaction_ns::~Parallaction_ns() {
 	freeFonts();
+
+	// TODO: we may want to add a ~Character instead
 	freeCharacter();
+	_char._ani.reset();
 
 	destroyInventory();
 
@@ -340,6 +343,7 @@
 	_soundManI->playLocationMusic(location);
 
 	_input->stopHovering();
+	// this is still needed to remove the floatingLabel
 	_gfx->freeLabels();
 
 	_zoneTrap.reset();
@@ -355,12 +359,13 @@
 
 	if (locname.hasSlide()) {
 		showSlide(locname.slide());
-		uint id = _gfx->createLabel(_menuFont, _location._slideText[0].c_str(), 1);
-		_gfx->showLabel(id, CENTER_LABEL_HORIZONTAL, 14);
+		GfxObj *label = _gfx->createLabel(_menuFont, _location._slideText[0].c_str(), 1);
+		_gfx->showLabel(label, CENTER_LABEL_HORIZONTAL, 14);
 		_gfx->updateScreen();
 
 		_input->waitForButtonEvent(kMouseLeftUp);
-		_gfx->freeLabels();
+		_gfx->unregisterLabel(label);
+		delete label;
 	}
 
 	if (locname.hasCharacter()) {


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