aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorNicola Mettifogo2008-07-22 12:35:46 +0000
committerNicola Mettifogo2008-07-22 12:35:46 +0000
commit5ea9bdd99aac134e739f06b4934a8ff5278633a1 (patch)
treed0a3ca0b534dfd3c4cdcdf711a4a9c8bdd307844 /engines
parenta38234d6e6f564b3eb6ed7db63bd907fc1d695fb (diff)
downloadscummvm-rg350-5ea9bdd99aac134e739f06b4934a8ff5278633a1.tar.gz
scummvm-rg350-5ea9bdd99aac134e739f06b4934a8ff5278633a1.tar.bz2
scummvm-rg350-5ea9bdd99aac134e739f06b4934a8ff5278633a1.zip
Merged inventory input code from different files.
svn-id: r33198
Diffstat (limited to 'engines')
-rw-r--r--engines/parallaction/input.cpp73
-rw-r--r--engines/parallaction/input.h3
-rw-r--r--engines/parallaction/parallaction.cpp19
3 files changed, 47 insertions, 48 deletions
diff --git a/engines/parallaction/input.cpp b/engines/parallaction/input.cpp
index a2f42508c9..1af1ed15fa 100644
--- a/engines/parallaction/input.cpp
+++ b/engines/parallaction/input.cpp
@@ -235,14 +235,7 @@ bool Input::translateGameInput() {
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 @@ bool Input::translateGameInput() {
}
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 @@ bool Input::translateInventoryInput() {
_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;
}
diff --git a/engines/parallaction/input.h b/engines/parallaction/input.h
index c0630e410a..2a97077603 100644
--- a/engines/parallaction/input.h
+++ b/engines/parallaction/input.h
@@ -70,6 +70,9 @@ class Input {
bool _mouseHidden;
ZonePtr _hoverZone;
+ void enterInventoryMode();
+ void exitInventoryMode();
+
public:
enum {
kInputModeGame = 0,
diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp
index f7a6fbf260..a45e678e73 100644
--- a/engines/parallaction/parallaction.cpp
+++ b/engines/parallaction/parallaction.cpp
@@ -307,25 +307,6 @@ void Parallaction::processInput(InputData *data) {
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();