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

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Tue Jul 22 14:35:47 CEST 2008


Revision: 33198
          http://scummvm.svn.sourceforge.net/scummvm/?rev=33198&view=rev
Author:   peres001
Date:     2008-07-22 12:35:46 +0000 (Tue, 22 Jul 2008)

Log Message:
-----------
Merged inventory input code from different files.

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/input.cpp
    scummvm/trunk/engines/parallaction/input.h
    scummvm/trunk/engines/parallaction/parallaction.cpp

Modified: scummvm/trunk/engines/parallaction/input.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/input.cpp	2008-07-22 12:18:24 UTC (rev 33197)
+++ scummvm/trunk/engines/parallaction/input.cpp	2008-07-22 12:35:46 UTC (rev 33198)
@@ -235,14 +235,7 @@
 
 	if (_mouseButtons == kMouseRightDown) {
 		// right button down shows inventory
-
-		if (_vm->hitZone(kZoneYou, _mousePos.x, _mousePos.y) && (_activeItem._id != 0)) {
-			_activeItem._index = (_activeItem._id >> 16) & 0xFFFF;
-			_engineFlags |= kEngineDragging;
-		}
-
-		_inputData._event = kEvOpenInventory;
-		_transCurrentHoverItem = -1;
+		enterInventoryMode();
 		return true;
 	}
 
@@ -282,31 +275,38 @@
 	}
 
 	return true;
-
 }
 
-bool Input::translateInventoryInput() {
 
-	if ((_engineFlags & kEngineInventory) == 0) {
-		return false;
+void Input::enterInventoryMode() {
+	bool hitCharacter = _vm->hitZone(kZoneYou, _mousePos.x, _mousePos.y);
+
+	if (hitCharacter) {
+		if (_activeItem._id != 0) {
+			_activeItem._index = (_activeItem._id >> 16) & 0xFFFF;
+			_engineFlags |= kEngineDragging;
+		} else {
+			_vm->setArrowCursor();
+		}
 	}
 
-	// in inventory
-	int16 _si = _vm->getHoverInventoryItem(_mousePos.x, _mousePos.y);
+	stopHovering();
+	_vm->pauseJobs();
+	_vm->openInventory();
 
-	if (_mouseButtons == kMouseRightUp) {
-		// right up hides inventory
+	_transCurrentHoverItem = -1;
+}
 
-		_inputData._event = kEvCloseInventory;
-		_inputData._inventoryIndex = _vm->getHoverInventoryItem(_mousePos.x, _mousePos.y);
-		_vm->highlightInventoryItem(-1);			// disable
+void Input::exitInventoryMode() {
+	// right up hides inventory
 
-		if ((_engineFlags & kEngineDragging) == 0) {
-			return true;
-		}
+	int item = _vm->getHoverInventoryItem(_mousePos.x, _mousePos.y);
+	_vm->highlightInventoryItem(-1);			// disable
 
+	if ((_engineFlags & kEngineDragging)) {
+
 		_engineFlags &= ~kEngineDragging;
-		ZonePtr z = _vm->hitZone(kZoneMerge, _activeItem._index, _vm->getInventoryItemIndex(_inputData._inventoryIndex));
+		ZonePtr z = _vm->hitZone(kZoneMerge, _activeItem._index, _vm->getInventoryItemIndex(item));
 
 		if (z) {
 			_vm->dropItem(z->u.merge->_obj1);
@@ -315,17 +315,32 @@
 			_vm->_cmdExec->run(z->_commands);
 		}
 
-		return true;
 	}
 
-	if (_si == _transCurrentHoverItem) {
-		_inputData._event = kEvNone;
+	_vm->closeInventory();
+	_vm->setInventoryCursor(item);
+	_vm->resumeJobs();
+}
+
+bool Input::translateInventoryInput() {
+
+	if ((_engineFlags & kEngineInventory) == 0) {
+		return false;
+	}
+
+	// in inventory
+	int16 _si = _vm->getHoverInventoryItem(_mousePos.x, _mousePos.y);
+
+	if (_mouseButtons == kMouseRightUp) {
+		exitInventoryMode();
 		return true;
 	}
 
-	_transCurrentHoverItem = _si;
-	_inputData._event = kEvHoverInventory;
-	_inputData._inventoryIndex = _si;
+	if (_si != _transCurrentHoverItem) {
+		_transCurrentHoverItem = _si;
+		_vm->highlightInventoryItem(_si);						// enable
+	}
+
 	return true;
 
 }

Modified: scummvm/trunk/engines/parallaction/input.h
===================================================================
--- scummvm/trunk/engines/parallaction/input.h	2008-07-22 12:18:24 UTC (rev 33197)
+++ scummvm/trunk/engines/parallaction/input.h	2008-07-22 12:35:46 UTC (rev 33198)
@@ -70,6 +70,9 @@
 	bool		_mouseHidden;
 	ZonePtr			_hoverZone;
 
+	void	enterInventoryMode();
+	void 	exitInventoryMode();
+
 public:
 	enum {
 		kInputModeGame = 0,

Modified: scummvm/trunk/engines/parallaction/parallaction.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.cpp	2008-07-22 12:18:24 UTC (rev 33197)
+++ scummvm/trunk/engines/parallaction/parallaction.cpp	2008-07-22 12:35:46 UTC (rev 33198)
@@ -307,25 +307,6 @@
 		resumeJobs();
 		break;
 
-	case kEvOpenInventory:
-		_input->stopHovering();
-		if (hitZone(kZoneYou, data->_mousePos.x, data->_mousePos.y) == 0) {
-			setArrowCursor();
-		}
-		pauseJobs();
-		openInventory();
-		break;
-
-	case kEvCloseInventory: // closes inventory and possibly select item
-		closeInventory();
-		setInventoryCursor(data->_inventoryIndex);
-		resumeJobs();
-		break;
-
-	case kEvHoverInventory:
-		highlightInventoryItem(data->_inventoryIndex);						// enable
-		break;
-
 	case kEvWalk:
 		debugC(2, kDebugInput, "processInput: kEvWalk");
 		_input->stopHovering();


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