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

bgk at users.sourceforge.net bgk at users.sourceforge.net
Sat Jan 22 18:26:10 CET 2011


Revision: 55439
          http://scummvm.svn.sourceforge.net/scummvm/?rev=55439&view=rev
Author:   bgk
Date:     2011-01-22 17:26:09 +0000 (Sat, 22 Jan 2011)

Log Message:
-----------
MOHAWK: Dragging resources / levers code cleanup

Modified Paths:
--------------
    scummvm/trunk/engines/mohawk/myst.cpp
    scummvm/trunk/engines/mohawk/myst.h
    scummvm/trunk/engines/mohawk/myst_areas.cpp
    scummvm/trunk/engines/mohawk/myst_areas.h
    scummvm/trunk/engines/mohawk/myst_stacks/channelwood.cpp
    scummvm/trunk/engines/mohawk/myst_stacks/myst.cpp

Modified: scummvm/trunk/engines/mohawk/myst.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/myst.cpp	2011-01-22 17:19:58 UTC (rev 55438)
+++ scummvm/trunk/engines/mohawk/myst.cpp	2011-01-22 17:26:09 UTC (rev 55439)
@@ -302,7 +302,6 @@
 			switch (event.type) {
 			case Common::EVENT_MOUSEMOVE: {
 				_needsUpdate = true;
-				_mouse = event.mouse;
 				bool mouseClicked = _system->getEventManager()->getButtonState() & 1;
 
 				// Keep the same resource when dragging
@@ -311,23 +310,21 @@
 				}
 				if (_curResource >= 0 && _resources[_curResource]->isEnabled() && mouseClicked) {
 					debug(2, "Sending mouse move event to resource %d", _curResource);
-					_resources[_curResource]->handleMouseDrag(event.mouse);
+					_resources[_curResource]->handleMouseDrag();
 				}
 				break;
 			}
 			case Common::EVENT_LBUTTONUP:
-				_mouse = event.mouse;
 				if (_curResource >= 0 && _resources[_curResource]->isEnabled()) {
 					debug(2, "Sending mouse up event to resource %d", _curResource);
-					_resources[_curResource]->handleMouseUp(event.mouse);
+					_resources[_curResource]->handleMouseUp();
 				}
 				checkCurrentResource();
 				break;
 			case Common::EVENT_LBUTTONDOWN:
-				_mouse = event.mouse;
 				if (_curResource >= 0 && _resources[_curResource]->isEnabled()) {
 					debug(2, "Sending mouse up event to resource %d", _curResource);
-					_resources[_curResource]->handleMouseDown(event.mouse);
+					_resources[_curResource]->handleMouseDown();
 				}
 				break;
 			case Common::EVENT_KEYDOWN:

Modified: scummvm/trunk/engines/mohawk/myst.h
===================================================================
--- scummvm/trunk/engines/mohawk/myst.h	2011-01-22 17:19:58 UTC (rev 55438)
+++ scummvm/trunk/engines/mohawk/myst.h	2011-01-22 17:26:09 UTC (rev 55439)
@@ -180,7 +180,6 @@
 	MystScriptParser *_scriptParser;
 	Common::Array<MystResource*> _resources;
 	MystResource *_dragResource;
-	Common::Point _mouse;
 	Common::RandomSource *_rnd;
 
 	bool _showResourceRects;

Modified: scummvm/trunk/engines/mohawk/myst_areas.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/myst_areas.cpp	2011-01-22 17:19:58 UTC (rev 55438)
+++ scummvm/trunk/engines/mohawk/myst_areas.cpp	2011-01-22 17:26:09 UTC (rev 55439)
@@ -68,7 +68,7 @@
 MystResource::~MystResource() {
 }
 
-void MystResource::handleMouseUp(const Common::Point &mouse) {
+void MystResource::handleMouseUp() {
 	if (_dest != 0)
 		_vm->changeToCard(_dest, true);
 	else
@@ -122,7 +122,7 @@
 	_script = vm->_scriptParser->readScript(rlstStream, kMystScriptNormal);
 }
 
-void MystResourceType5::handleMouseUp(const Common::Point &mouse) {
+void MystResourceType5::handleMouseUp() {
 	_vm->_scriptParser->runScript(_script, this);
 }
 
@@ -285,40 +285,40 @@
 	}
 }
 
-void MystResourceType7::handleMouseUp(const Common::Point &mouse) {
+void MystResourceType7::handleMouseUp() {
 	if (_var7 == 0xFFFF) {
 		if (_numSubResources == 1)
-			_subResources[0]->handleMouseUp(mouse);
+			_subResources[0]->handleMouseUp();
 		else if (_numSubResources != 0)
 			warning("Type 7 Resource with _numSubResources of %d, but no control variable", _numSubResources);
 	} else {
 		uint16 varValue = _vm->_scriptParser->getVar(_var7);
 
 		if (_numSubResources == 1 && varValue != 0)
-			_subResources[0]->handleMouseUp(mouse);
+			_subResources[0]->handleMouseUp();
 		else if (_numSubResources != 0) {
 			if (varValue < _numSubResources)
-				_subResources[varValue]->handleMouseUp(mouse);
+				_subResources[varValue]->handleMouseUp();
 			else
 				warning("Type 7 Resource Var %d: %d exceeds number of sub resources %d", _var7, varValue, _numSubResources);
 		}
 	}
 }
 
-void MystResourceType7::handleMouseDown(const Common::Point &mouse) {
+void MystResourceType7::handleMouseDown() {
 	if (_var7 == 0xFFFF) {
 		if (_numSubResources == 1)
-			_subResources[0]->handleMouseDown(mouse);
+			_subResources[0]->handleMouseDown();
 		else if (_numSubResources != 0)
 			warning("Type 7 Resource with _numSubResources of %d, but no control variable", _numSubResources);
 	} else {
 		uint16 varValue = _vm->_scriptParser->getVar(_var7);
 
 		if (_numSubResources == 1 && varValue != 0)
-			_subResources[0]->handleMouseDown(mouse);
+			_subResources[0]->handleMouseDown();
 		else if (_numSubResources != 0) {
 			if (varValue < _numSubResources)
-				_subResources[varValue]->handleMouseDown(mouse);
+				_subResources[varValue]->handleMouseDown();
 			else
 				warning("Type 7 Resource Var %d: %d exceeds number of sub resources %d", _var7, varValue, _numSubResources);
 		}
@@ -515,13 +515,14 @@
 	_vm->_gfx->copyImageSectionToScreen(_vm->getCardBackgroundId(), src, dest);
 }
 
-void MystResourceType10::handleMouseDown(const Common::Point &mouse) {
+void MystResourceType10::handleMouseDown() {
 	// Tell the engine we are dragging a resource
 	_vm->_dragResource = this;
 
+	const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
 	updatePosition(mouse);
 
-	MystResourceType11::handleMouseDown(mouse);
+	MystResourceType11::handleMouseDown();
 
 	// Restore background
 	restoreBackground();
@@ -530,7 +531,8 @@
 	drawConditionalDataToScreen(2);
 }
 
-void MystResourceType10::handleMouseUp(const Common::Point &mouse) {
+void MystResourceType10::handleMouseUp() {
+	const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
 	updatePosition(mouse);
 
 	// Restore background
@@ -555,16 +557,17 @@
 
 	_vm->_scriptParser->setVarValue(_var8, value);
 
-	MystResourceType11::handleMouseUp(mouse);
+	MystResourceType11::handleMouseUp();
 
 	// No longer in drag mode
 	_vm->_dragResource = 0;
 }
 
-void MystResourceType10::handleMouseDrag(const Common::Point &mouse) {
+void MystResourceType10::handleMouseDrag() {
+	const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
 	updatePosition(mouse);
 
-	MystResourceType11::handleMouseDrag(mouse);
+	MystResourceType11::handleMouseDrag();
 
 	// Restore background
 	restoreBackground();
@@ -681,21 +684,24 @@
 		delete[] _lists[i].list;
 }
 
-void MystResourceType11::handleMouseDown(const Common::Point &mouse) {
+void MystResourceType11::handleMouseDown() {
+	const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
 	setPositionClipping(mouse, _pos);
 
 	_vm->_scriptParser->setInvokingResource(this);
 	_vm->_scriptParser->runOpcode(_mouseDownOpcode, _var8);
 }
 
-void MystResourceType11::handleMouseUp(const Common::Point &mouse) {
+void MystResourceType11::handleMouseUp() {
+	const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
 	setPositionClipping(mouse, _pos);
 
 	_vm->_scriptParser->setInvokingResource(this);
 	_vm->_scriptParser->runOpcode(_mouseUpOpcode, _var8);
 }
 
-void MystResourceType11::handleMouseDrag(const Common::Point &mouse) {
+void MystResourceType11::handleMouseDrag() {
+	const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
 	setPositionClipping(mouse, _pos);
 
 	_vm->_scriptParser->setInvokingResource(this);
@@ -760,6 +766,38 @@
 	_vm->_system->updateScreen();
 }
 
+bool MystResourceType12::pullLeverV() {
+	const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
+
+	// Make the handle follow the mouse
+	int16 maxStep = getStepsV() - 1;
+	Common::Rect rect = getRect();
+	int16 step = ((mouse.y - rect.top) * getStepsV()) / rect.height();
+	step = CLIP<int16>(step, 0, maxStep);
+
+	// Draw current frame
+	drawFrame(step);
+
+	// Return true if lever fully pulled
+	return step == maxStep;
+}
+
+void MystResourceType12::releaseLeverV() {
+	const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
+
+	// Get current lever frame
+	int16 maxStep = getStepsV() - 1;
+	Common::Rect rect = getRect();
+	int16 step = ((mouse.y - rect.top) * getStepsV()) / rect.height();
+	step = CLIP<int16>(step, 0, maxStep);
+
+	// Release lever
+	for (int i = step; i >= 0; i--) {
+		drawFrame(i);
+		_vm->_system->delayMillis(10);
+	}
+}
+
 MystResourceType13::MystResourceType13(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent) : MystResource(vm, rlstStream, parent) {
 	_enterOpcode = rlstStream->readUint16LE();
 	_leaveOpcode = rlstStream->readUint16LE();
@@ -780,7 +818,7 @@
 	_vm->_scriptParser->runOpcode(_leaveOpcode, _dest);
 }
 
-void MystResourceType13::handleMouseUp(const Common::Point &mouse) {
+void MystResourceType13::handleMouseUp() {
 	// Type 13 Resources do nothing on Mouse Clicks.
 	// This is required to override the inherited default
 	// i.e. MystResource::handleMouseUp

Modified: scummvm/trunk/engines/mohawk/myst_areas.h
===================================================================
--- scummvm/trunk/engines/mohawk/myst_areas.h	2011-01-22 17:19:58 UTC (rev 55438)
+++ scummvm/trunk/engines/mohawk/myst_areas.h	2011-01-22 17:26:09 UTC (rev 55439)
@@ -80,9 +80,9 @@
 	bool canBecomeActive();
 
 	// Mouse interface
-	virtual void handleMouseUp(const Common::Point &mouse);
-	virtual void handleMouseDown(const Common::Point &mouse) {}
-	virtual void handleMouseDrag(const Common::Point &mouse) {}
+	virtual void handleMouseUp();
+	virtual void handleMouseDown() {}
+	virtual void handleMouseDrag() {}
 
 protected:
 	MohawkEngine_Myst *_vm;
@@ -95,7 +95,7 @@
 class MystResourceType5 : public MystResource {
 public:
 	MystResourceType5(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent);
-	void handleMouseUp(const Common::Point &mouse);
+	void handleMouseUp();
 	const Common::String describe();
 
 protected:
@@ -130,8 +130,8 @@
 	virtual void drawDataToScreen();
 	virtual void handleCardChange();
 
-	virtual void handleMouseUp(const Common::Point &mouse);
-	virtual void handleMouseDown(const Common::Point &mouse);
+	virtual void handleMouseUp();
+	virtual void handleMouseDown();
 
 	MystResource *getSubResource(uint16 index) { return _subResources[index]; }
 protected:
@@ -168,9 +168,9 @@
 	virtual ~MystResourceType11();
 	const Common::String describe();
 
-	void handleMouseDown(const Common::Point &mouse);
-	void handleMouseUp(const Common::Point &mouse);
-	void handleMouseDrag(const Common::Point &mouse);
+	void handleMouseDown();
+	void handleMouseUp();
+	void handleMouseDrag();
 
 	uint16 getList1(uint16 index);
 	uint16 getList2(uint16 index);
@@ -207,9 +207,9 @@
 	MystResourceType10(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent);
 	virtual ~MystResourceType10();
 
-	void handleMouseDown(const Common::Point &mousee);
-	void handleMouseUp(const Common::Point &mouse);
-	void handleMouseDrag(const Common::Point &mouse);
+	void handleMouseDown();
+	void handleMouseUp();
+	void handleMouseDrag();
 	void setStep(uint16 step);
 	void setPosition(uint16 pos);
     void restoreBackground();
@@ -228,6 +228,8 @@
 	MystResourceType12(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent);
 	virtual ~MystResourceType12();
 	void drawFrame(uint16 frame);
+	bool pullLeverV();
+	void releaseLeverV();
 
 protected:
 	uint16 _numFrames;
@@ -243,7 +245,7 @@
 	MystResourceType13(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent);
 	const Common::String describe();
 
-	void handleMouseUp(const Common::Point &mouse);
+	void handleMouseUp();
 	void handleMouseEnter();
 	void handleMouseLeave();
 

Modified: scummvm/trunk/engines/mohawk/myst_stacks/channelwood.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/myst_stacks/channelwood.cpp	2011-01-22 17:19:58 UTC (rev 55438)
+++ scummvm/trunk/engines/mohawk/myst_stacks/channelwood.cpp	2011-01-22 17:26:09 UTC (rev 55439)
@@ -368,18 +368,10 @@
 
 	MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
 
-	// Make the handle follow the mouse
-	int16 maxStep = lever->getStepsV() - 1;
-	Common::Rect rect = lever->getRect();
-	int16 step = ((_vm->_mouse.y - rect.top) * lever->getStepsV()) / rect.height();
-	step = CLIP<int16>(step, 0, maxStep);
-
-	lever->drawFrame(step);
-
-	if (step == maxStep) {
+	if (lever->pullLeverV()) {
 		if (!_leverPulled) {
 			_leverPulled = true;
-			_leverAction->handleMouseUp(_vm->_system->getEventManager()->getMousePos());
+			_leverAction->handleMouseUp();
 		}
 	} else {
 		_leverPulled = false;
@@ -391,15 +383,7 @@
 
 	MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
 
-	// Make the handle follow the mouse
-	int16 maxStep = lever->getStepsV() - 1;
-	Common::Rect rect = lever->getRect();
-	int16 step = ((_vm->_mouse.y - rect.top) * lever->getStepsV()) / rect.height();
-	step = CLIP<int16>(step, 0, maxStep);
-
-	lever->drawFrame(step);
-
-	if (step == maxStep) {
+	if (lever->pullLeverV()) {
 		if (!_leverPulled) {
 			_leverPulled = true;
 			uint16 soundId = lever->getList2(0);
@@ -416,16 +400,9 @@
 
 	// Get current lever frame
 	MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
-	int16 maxStep = lever->getStepsV() - 1;
-	Common::Rect rect = lever->getRect();
-	int16 step = ((_vm->_mouse.y - rect.top) * lever->getStepsV()) / rect.height();
-	step = CLIP<int16>(step, 0, maxStep);
 
 	// Release lever
-	for (int i = step; i >= 0; i--) {
-		lever->drawFrame(i);
-		_vm->_system->delayMillis(10);
-	}
+	lever->releaseLeverV();
 
 	uint16 soundId = lever->getList3(0);
 	if (soundId)
@@ -466,15 +443,7 @@
 
 	MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
 
-	// Make the handle follow the mouse
-	int16 maxStep = lever->getStepsV() - 1;
-	Common::Rect rect = lever->getRect();
-	int16 step = ((_vm->_mouse.y - rect.top) * lever->getStepsV()) / rect.height();
-	step = CLIP<int16>(step, 0, maxStep);
-
-	lever->drawFrame(step);
-
-	if (step == maxStep) {
+	if (lever->pullLeverV()) {
 		uint16 soundId = lever->getList2(0);
 		_vm->_sound->replaceBackgroundMyst(soundId, 38400);
 	} else {
@@ -509,9 +478,11 @@
 	debugC(kDebugScript, "Opcode %d: Valve handle move", op);
 
 	MystResourceType12 *handle = static_cast<MystResourceType12 *>(_invokingResource);
-	if (handle->getRect().contains(_vm->_mouse)) {
+	const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
+
+	if (handle->getRect().contains(mouse)) {
 		// Compute frame to draw
-		_tempVar = (_vm->_mouse.x - 250) / 4;
+		_tempVar = (mouse.x - 250) / 4;
 		_tempVar = CLIP<int16>(_tempVar, 1, handle->getStepsH() - 2);
 
 		// Draw frame
@@ -558,9 +529,11 @@
 	debugC(kDebugScript, "Opcode %d: Valve handle move", op);
 
 	MystResourceType12 *handle = static_cast<MystResourceType12 *>(_invokingResource);
-	if (handle->getRect().contains(_vm->_mouse)) {
+	const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
+
+	if (handle->getRect().contains(mouse)) {
 		// Compute frame to draw
-		_tempVar = handle->getStepsH() - (_vm->_mouse.x - 234) / 4;
+		_tempVar = handle->getStepsH() - (mouse.x - 234) / 4;
 		_tempVar = CLIP<int16>(_tempVar, 1, handle->getStepsH() - 2);
 
 		// Draw frame
@@ -584,9 +557,11 @@
 	debugC(kDebugScript, "Opcode %d: Valve handle move", op);
 
 	MystResourceType12 *handle = static_cast<MystResourceType12 *>(_invokingResource);
-	if (handle->getRect().contains(_vm->_mouse)) {
+	const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
+
+	if (handle->getRect().contains(mouse)) {
 		// Compute frame to draw
-		_tempVar = handle->getStepsH() - (_vm->_mouse.x - 250) / 4;
+		_tempVar = handle->getStepsH() - (mouse.x - 250) / 4;
 		_tempVar = CLIP<int16>(_tempVar, 1, handle->getStepsH() - 2);
 
 		// Draw frame
@@ -677,7 +652,7 @@
 	debugC(kDebugScript, "Opcode %d: Execute mouse up", op);
 
 	MystResourceType5 *resource = static_cast<MystResourceType5 *>(_vm->_resources[argv[0]]);
-	resource->handleMouseUp(_vm->_system->getEventManager()->getMousePos());
+	resource->handleMouseUp();
 }
 
 void MystScriptParser_Channelwood::o_waterTankValveClose(uint16 op, uint16 var, uint16 argc, uint16 *argv) {

Modified: scummvm/trunk/engines/mohawk/myst_stacks/myst.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/myst_stacks/myst.cpp	2011-01-22 17:19:58 UTC (rev 55438)
+++ scummvm/trunk/engines/mohawk/myst_stacks/myst.cpp	2011-01-22 17:26:09 UTC (rev 55439)
@@ -1460,15 +1460,7 @@
 	// Used on Card 4100
 	MystResourceType12 *handle = static_cast<MystResourceType12 *>(_invokingResource);
 
-	// Make the handle follow the mouse
-	int16 maxStep = handle->getStepsV() - 1;
-    Common::Rect rect = handle->getRect();
-    int16 step = ((_vm->_mouse.y - rect.top) * handle->getStepsV()) / rect.height();
-	step = CLIP<uint16>(step, 0, maxStep);
-
-	handle->drawFrame(step);
-
-	if (step == maxStep) {
+	if (handle->pullLeverV()) {
 		// Sound not played yet
 		if (_tempVar == 0) {
 			uint16 soundId = handle->getList2(0);
@@ -1804,9 +1796,10 @@
 	debugC(kDebugScript, "Opcode %d: Circuit breaker move", op);
 
 	MystResourceType12 *breaker = static_cast<MystResourceType12 *>(_invokingResource);
+	const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
 
 	int16 maxStep = breaker->getStepsV() - 1;
-	int16 step = ((_vm->_mouse.y - 80) * breaker->getStepsV()) / 65;
+	int16 step = ((mouse.y - 80) * breaker->getStepsV()) / 65;
 	step = CLIP<uint16>(step, 0, maxStep);
 
 	breaker->drawFrame(step);
@@ -2329,11 +2322,12 @@
 	debugC(kDebugScript, "Opcode %d: Rocket lever move", op);
 
 	MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
+	const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
 
 	// Make the lever follow the mouse
 	int16 maxStep = lever->getStepsV() - 1;
     Common::Rect rect = lever->getRect();
-    int16 step = ((_vm->_mouse.y - rect.top) * lever->getStepsV()) / rect.height();
+    int16 step = ((mouse.y - rect.top) * lever->getStepsV()) / rect.height();
 	step = CLIP<uint16>(step, 0, maxStep);
 
 	lever->drawFrame(step);
@@ -2808,15 +2802,8 @@
 	if (!_clockLeverPulled) {
 		MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
 
-		// Make the handle follow the mouse
-		int16 maxStep = lever->getStepsV() - 1;
-		Common::Rect rect = lever->getRect();
-		int16 step = ((_vm->_mouse.y - rect.top) * lever->getStepsV()) / rect.height();
-		step = CLIP<int16>(step, 0, maxStep);
-
-		lever->drawFrame(step);
-
-		if (step == maxStep) {
+		// If lever pulled
+		if (lever->pullLeverV()) {
 			// Start videos for first step
 			if (_clockWeightPosition < 2214) {
 				_vm->_sound->replaceSoundMyst(5113);
@@ -2890,19 +2877,10 @@
 	if (_clockMiddleGearMovedAlone)
 		_vm->_sound->replaceSoundMyst(8113);
 
-	// Get current lever frame
+	// Release lever
 	MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
-	int16 maxStep = lever->getStepsV() - 1;
-	Common::Rect rect = lever->getRect();
-	int16 step = ((_vm->_mouse.y - rect.top) * lever->getStepsV()) / rect.height();
-	step = CLIP<int16>(step, 0, maxStep);
+	lever->releaseLeverV();
 
-	// Release lever
-	for (int i = step; i >= 0; i--) {
-		lever->drawFrame(i);
-		_vm->_system->delayMillis(10);
-	}
-
 	// Check if puzzle is solved
 	clockGearsCheckSolution();
 
@@ -2950,15 +2928,8 @@
 
 	MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
 
-	// Make the handle follow the mouse
-	int16 maxStep = lever->getStepsV() - 1;
-	Common::Rect rect = lever->getRect();
-	int16 step = ((_vm->_mouse.y - rect.top) * lever->getStepsV()) / rect.height();
-	step = CLIP<int16>(step, 0, maxStep);
-
-	lever->drawFrame(step);
-
-	if (step == maxStep && _clockWeightPosition != 0)
+	// If pulled
+	if (lever->pullLeverV() && _clockWeightPosition != 0)
 		clockReset();
 }
 
@@ -3040,16 +3011,8 @@
 
 	// Get current lever frame
 	MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
-	int16 maxStep = lever->getStepsV() - 1;
-	Common::Rect rect = lever->getRect();
-	int16 step = ((_vm->_mouse.y - rect.top) * lever->getStepsV()) / rect.height();
-	step = CLIP<int16>(step, 0, maxStep);
 
-	// Release lever
-	for (int i = step; i >= 0; i--) {
-		lever->drawFrame(i);
-		_vm->_system->delayMillis(10);
-	}
+	lever->releaseLeverV();
 
 	_vm->checkCursorHints();
 }


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