mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-03 17:33:05 +00:00
Merged inventory input code from different files.
svn-id: r33198
This commit is contained in:
parent
a38234d6e6
commit
5ea9bdd99a
@ -235,14 +235,7 @@ bool Input::translateGameInput() {
|
|||||||
|
|
||||||
if (_mouseButtons == kMouseRightDown) {
|
if (_mouseButtons == kMouseRightDown) {
|
||||||
// right button down shows inventory
|
// right button down shows inventory
|
||||||
|
enterInventoryMode();
|
||||||
if (_vm->hitZone(kZoneYou, _mousePos.x, _mousePos.y) && (_activeItem._id != 0)) {
|
|
||||||
_activeItem._index = (_activeItem._id >> 16) & 0xFFFF;
|
|
||||||
_engineFlags |= kEngineDragging;
|
|
||||||
}
|
|
||||||
|
|
||||||
_inputData._event = kEvOpenInventory;
|
|
||||||
_transCurrentHoverItem = -1;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -282,7 +275,51 @@ bool Input::translateGameInput() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stopHovering();
|
||||||
|
_vm->pauseJobs();
|
||||||
|
_vm->openInventory();
|
||||||
|
|
||||||
|
_transCurrentHoverItem = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Input::exitInventoryMode() {
|
||||||
|
// right up hides inventory
|
||||||
|
|
||||||
|
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(item));
|
||||||
|
|
||||||
|
if (z) {
|
||||||
|
_vm->dropItem(z->u.merge->_obj1);
|
||||||
|
_vm->dropItem(z->u.merge->_obj2);
|
||||||
|
_vm->addInventoryItem(z->u.merge->_obj3);
|
||||||
|
_vm->_cmdExec->run(z->_commands);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
_vm->closeInventory();
|
||||||
|
_vm->setInventoryCursor(item);
|
||||||
|
_vm->resumeJobs();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Input::translateInventoryInput() {
|
bool Input::translateInventoryInput() {
|
||||||
@ -295,37 +332,15 @@ bool Input::translateInventoryInput() {
|
|||||||
int16 _si = _vm->getHoverInventoryItem(_mousePos.x, _mousePos.y);
|
int16 _si = _vm->getHoverInventoryItem(_mousePos.x, _mousePos.y);
|
||||||
|
|
||||||
if (_mouseButtons == kMouseRightUp) {
|
if (_mouseButtons == kMouseRightUp) {
|
||||||
// right up hides inventory
|
exitInventoryMode();
|
||||||
|
|
||||||
_inputData._event = kEvCloseInventory;
|
|
||||||
_inputData._inventoryIndex = _vm->getHoverInventoryItem(_mousePos.x, _mousePos.y);
|
|
||||||
_vm->highlightInventoryItem(-1); // disable
|
|
||||||
|
|
||||||
if ((_engineFlags & kEngineDragging) == 0) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
_engineFlags &= ~kEngineDragging;
|
|
||||||
ZonePtr z = _vm->hitZone(kZoneMerge, _activeItem._index, _vm->getInventoryItemIndex(_inputData._inventoryIndex));
|
|
||||||
|
|
||||||
if (z) {
|
|
||||||
_vm->dropItem(z->u.merge->_obj1);
|
|
||||||
_vm->dropItem(z->u.merge->_obj2);
|
|
||||||
_vm->addInventoryItem(z->u.merge->_obj3);
|
|
||||||
_vm->_cmdExec->run(z->_commands);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_si == _transCurrentHoverItem) {
|
if (_si != _transCurrentHoverItem) {
|
||||||
_inputData._event = kEvNone;
|
_transCurrentHoverItem = _si;
|
||||||
return true;
|
_vm->highlightInventoryItem(_si); // enable
|
||||||
}
|
}
|
||||||
|
|
||||||
_transCurrentHoverItem = _si;
|
|
||||||
_inputData._event = kEvHoverInventory;
|
|
||||||
_inputData._inventoryIndex = _si;
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -70,6 +70,9 @@ class Input {
|
|||||||
bool _mouseHidden;
|
bool _mouseHidden;
|
||||||
ZonePtr _hoverZone;
|
ZonePtr _hoverZone;
|
||||||
|
|
||||||
|
void enterInventoryMode();
|
||||||
|
void exitInventoryMode();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum {
|
enum {
|
||||||
kInputModeGame = 0,
|
kInputModeGame = 0,
|
||||||
|
@ -307,25 +307,6 @@ void Parallaction::processInput(InputData *data) {
|
|||||||
resumeJobs();
|
resumeJobs();
|
||||||
break;
|
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:
|
case kEvWalk:
|
||||||
debugC(2, kDebugInput, "processInput: kEvWalk");
|
debugC(2, kDebugInput, "processInput: kEvWalk");
|
||||||
_input->stopHovering();
|
_input->stopHovering();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user