[Scummvm-cvs-logs] SF.net SVN: scummvm:[54771] scummvm/trunk/engines/mohawk

fuzzie at users.sourceforge.net fuzzie at users.sourceforge.net
Sun Dec 5 00:48:31 CET 2010


Revision: 54771
          http://scummvm.svn.sourceforge.net/scummvm/?rev=54771&view=rev
Author:   fuzzie
Date:     2010-12-04 23:48:31 +0000 (Sat, 04 Dec 2010)

Log Message:
-----------
MOHAWK: implement setGlobalEnable and setGlobalVisible for LB

Modified Paths:
--------------
    scummvm/trunk/engines/mohawk/livingbooks.cpp
    scummvm/trunk/engines/mohawk/livingbooks.h

Modified: scummvm/trunk/engines/mohawk/livingbooks.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/livingbooks.cpp	2010-12-04 23:48:14 UTC (rev 54770)
+++ scummvm/trunk/engines/mohawk/livingbooks.cpp	2010-12-04 23:48:31 UTC (rev 54771)
@@ -1546,6 +1546,8 @@
 	_enabled = false;
 	_visible = true;
 	_playing = false;
+	_globalEnabled = true;
+	_globalVisible = true;
 	_nextTime = 0;
 	_startTime = 0;
 	_loops = 0;
@@ -1710,8 +1712,7 @@
 
 	case kLBGlobalSetNotVisible:
 		assert(size == 0);
-		// FIXME
-		_visible = false;
+		_globalVisible = false;
 		break;
 
 	case kLBSetAmbient:
@@ -1764,6 +1765,13 @@
 	_enabled = enabled;
 }
 
+void LBItem::setGlobalEnabled(bool enabled) {
+	bool wasEnabled = !_neverEnabled && _enabled && _globalEnabled;
+	_globalEnabled = enabled;
+	if (wasEnabled != (!_neverEnabled && _enabled && _globalEnabled))
+		setEnabled(enabled);
+}
+
 bool LBItem::contains(Common::Point point) {
 	if (_playing && _loopMode == 0xFFFF)
 		stop();
@@ -1771,11 +1779,11 @@
 	if (!_playing && _timingMode == 2)
 		setNextTime(_periodMin, _periodMax);
 
-	return _visible && _rect.contains(point);
+	return _visible && _globalVisible && _rect.contains(point);
 }
 
 void LBItem::update() {
-	if (_neverEnabled || !_enabled)
+	if (_neverEnabled || !_enabled || !_globalEnabled)
 		return;
 
 	if (_nextTime == 0 || _nextTime > (uint32)(_vm->_system->getMillis() / 16))
@@ -1790,7 +1798,7 @@
 }
 
 void LBItem::handleMouseDown(Common::Point pos) {
-	if (_neverEnabled || !_enabled)
+	if (_neverEnabled || !_enabled || !_globalEnabled)
 		return;
 
 	_vm->setFocus(this);
@@ -1811,7 +1819,7 @@
 		_vm->queueDelayedEvent(DelayedEvent(this, kLBEventDone));
 		return true;
 	}
-	if (!_neverEnabled && _enabled && !_playing) {
+	if (!_neverEnabled && _enabled && _globalEnabled && !_playing) {
 		_playing = togglePlaying(true, restart);
 		if (_playing) {
 			_nextTime = 0;
@@ -1888,6 +1896,13 @@
 	_vm->_needsRedraw = true;
 }
 
+void LBItem::setGlobalVisible(bool visible) {
+	bool wasEnabled = _visible && _globalVisible;
+	_globalVisible = visible;
+	if (wasEnabled != (_visible && _globalVisible))
+		_vm->_needsRedraw = true;
+}
+
 void LBItem::startPhase(uint phase) {
 	if (_phase == phase)
 		setEnabled(true);
@@ -2008,23 +2023,19 @@
 					break;
 
 				case 0xb:
-					// FIXME: 'showGlobal'
-					target->setVisible(false);
+					target->setGlobalVisible(false);
 					break;
 
 				case 0xc:
-					// FIXME: 'showGlobal'
-					target->setVisible(true);
+					target->setGlobalVisible(true);
 					break;
 
 				case 0xd:
-					// FIXME: 'enableGlobal'
-					target->setEnabled(false);
+					target->setGlobalEnabled(false);
 					break;
 
 				case 0xe:
-					// FIXME: 'enableGlobal'
-					target->setEnabled(true);
+					target->setGlobalEnabled(true);
 					break;
 
 				case 0xf:
@@ -2078,7 +2089,7 @@
 		_vm->_sound->stopSound(_resourceId);
 	}
 
-	if (_neverEnabled || !_enabled)
+	if (_neverEnabled || !_enabled || !_globalEnabled)
 		return false;
 
 	_running = true;
@@ -2140,6 +2151,14 @@
 	}
 }
 
+void LBGroupItem::setGlobalEnabled(bool enabled) {
+	for (uint i = 0; i < _groupEntries.size(); i++) {
+		LBItem *item = _vm->getItemById(_groupEntries[i].entryId);
+		if (item)
+			item->setGlobalEnabled(enabled);
+	}
+}
+
 bool LBGroupItem::contains(Common::Point point) {
 	return false;
 }
@@ -2170,6 +2189,14 @@
 	}
 }
 
+void LBGroupItem::setGlobalVisible(bool visible) {
+	for (uint i = 0; i < _groupEntries.size(); i++) {
+		LBItem *item = _vm->getItemById(_groupEntries[i].entryId);
+		if (item)
+			item->setGlobalVisible(visible);
+	}
+}
+
 void LBGroupItem::startPhase(uint phase) {
 	_starting = true;
 	LBItem::startPhase(phase);
@@ -2207,7 +2234,7 @@
 }
 
 void LBPaletteItem::draw() {
-	if (!_visible)
+	if (!_visible || !_globalVisible)
 		return;
 
 	_vm->_system->setPalette(_palette + _drawStart * 4, _drawStart, _drawCount);
@@ -2370,7 +2397,7 @@
 }
 
 void LBLiveTextItem::handleMouseDown(Common::Point pos) {
-	if (_neverEnabled || !_enabled || _currentPhrase != 0xFFFF)
+	if (_neverEnabled || !_enabled || _globalEnabled || _currentPhrase != 0xFFFF)
 		return LBItem::handleMouseDown(pos);
 
 	pos.x -= _rect.left;
@@ -2401,7 +2428,7 @@
 bool LBLiveTextItem::togglePlaying(bool playing, bool restart) {
 	if (!playing)
 		return LBItem::togglePlaying(playing, restart);
-	if (_neverEnabled || !_enabled)
+	if (_neverEnabled || !_enabled || !_globalEnabled)
 		return (_currentPhrase != 0xFFFF);
 
 	// TODO: handle this properly
@@ -2423,7 +2450,7 @@
 }
 
 void LBLiveTextItem::notify(uint16 data, uint16 from) {
-	if (_neverEnabled || !_enabled || _currentPhrase == 0xFFFF)
+	if (_neverEnabled || !_enabled || !_globalEnabled || _currentPhrase == 0xFFFF)
 		return LBItem::notify(data, from);
 
 	if (_currentWord != 0xFFFF) {
@@ -2489,7 +2516,7 @@
 }
 
 void LBPictureItem::draw() {
-	if (!_visible)
+	if (!_visible || !_globalVisible)
 		return;
 
 	_vm->_gfx->copyAnimImageToScreen(_resourceId, _rect.left, _rect.top);
@@ -2513,7 +2540,7 @@
 	if (_running) {
 		if (enabled && _neverEnabled)
 			_anim->start();
-		else if (!_neverEnabled && !enabled && _enabled)
+		else if (!_neverEnabled && !enabled && _enabled && _globalEnabled)
 			if (_running) {
 				_anim->stop();
 
@@ -2530,7 +2557,7 @@
 }
 
 void LBAnimationItem::update() {
-	if (!_neverEnabled && _enabled && _running) {
+	if (!_neverEnabled && _enabled && _globalEnabled && _running) {
 		bool wasDone = _anim->update();
 		if (wasDone)
 			done(true);
@@ -2541,7 +2568,7 @@
 
 bool LBAnimationItem::togglePlaying(bool playing, bool restart) {
 	if (playing) {
-		if (!_neverEnabled && _enabled) {
+		if (!_neverEnabled && _enabled && _globalEnabled) {
 			if (restart)
 				seek(1);
 			_running = true;
@@ -2592,7 +2619,7 @@
 }
 
 void LBAnimationItem::draw() {
-	if (!_visible)
+	if (!_visible || !_globalVisible)
 		return;
 
 	_anim->draw();

Modified: scummvm/trunk/engines/mohawk/livingbooks.h
===================================================================
--- scummvm/trunk/engines/mohawk/livingbooks.h	2010-12-04 23:48:14 UTC (rev 54770)
+++ scummvm/trunk/engines/mohawk/livingbooks.h	2010-12-04 23:48:31 UTC (rev 54771)
@@ -234,6 +234,7 @@
 
 	virtual void destroySelf(); // 0x2
 	virtual void setEnabled(bool enabled); // 0x3
+	virtual void setGlobalEnabled(bool enabled);
 	virtual bool contains(Common::Point point); // 0x7
 	virtual void update(); // 0x8
 	virtual void draw() { } // 0x9
@@ -247,6 +248,7 @@
 	virtual void seek(uint16 pos) { } // 0x13
 	virtual void setFocused(bool focused) { } // 0x14
 	virtual void setVisible(bool visible); // 0x17
+	virtual void setGlobalVisible(bool enabled);
 	virtual void startPhase(uint phase); // 0x18
 	virtual void stop(); // 0x19
 	virtual void notify(uint16 data, uint16 from); // 0x1A
@@ -264,7 +266,7 @@
 	uint16 _resourceId;
 	uint16 _itemId;
 
-	bool _visible, _playing, _enabled, _neverEnabled;
+	bool _visible, _globalVisible, _playing, _enabled, _neverEnabled, _globalEnabled;
 
 	uint32 _nextTime, _startTime;
 	uint16 _loops;
@@ -305,11 +307,13 @@
 	void readData(uint16 type, uint16 size, Common::SeekableSubReadStreamEndian *stream);
 
 	void setEnabled(bool enabled);
+	void setGlobalEnabled(bool enabled);
 	bool contains(Common::Point point);
 	bool togglePlaying(bool playing, bool restart);
 	// 0x12
 	void seek(uint16 pos);
 	void setVisible(bool visible);
+	void setGlobalVisible(bool visible);
 	void startPhase(uint phase);
 	void stop();
 	


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