diff options
author | Filippos Karapetis | 2015-12-07 10:31:46 +0200 |
---|---|---|
committer | Willem Jan Palenstijn | 2015-12-23 21:33:53 +0100 |
commit | 5ccc0fd7c6469e1b1bac6b32a4624a88e0c78278 (patch) | |
tree | 7edd01eba5c5f60dd68a11db4ee60eedb2cd4780 | |
parent | 4f1a8f9fa4bdd1ae11460ac89463772c4814a1e1 (diff) | |
download | scummvm-rg350-5ccc0fd7c6469e1b1bac6b32a4624a88e0c78278.tar.gz scummvm-rg350-5ccc0fd7c6469e1b1bac6b32a4624a88e0c78278.tar.bz2 scummvm-rg350-5ccc0fd7c6469e1b1bac6b32a4624a88e0c78278.zip |
LAB: Clean up checkGadgetHit() a bit
-rw-r--r-- | engines/lab/eventman.cpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/engines/lab/eventman.cpp b/engines/lab/eventman.cpp index b1b1a68e70..1c204b75eb 100644 --- a/engines/lab/eventman.cpp +++ b/engines/lab/eventman.cpp @@ -60,10 +60,10 @@ static byte MouseData[] = {1, 1, 0, 0, 0, 0, 0, 0, 0, 0, Gadget *EventManager::checkGadgetHit(GadgetList *gadgetList, Common::Point pos) { for (GadgetList::iterator gadgetItr = gadgetList->begin(); gadgetItr != gadgetList->end(); ++gadgetItr) { Gadget *gadget = *gadgetItr; - if ((pos.x >= gadget->x) && (pos.y >= gadget->y) && - (pos.x <= (gadget->x + gadget->_image->_width)) && - (pos.y <= (gadget->y + gadget->_image->_height)) && - !(GADGETOFF & gadget->_flags)) { + Common::Rect gadgetRect(gadget->x, gadget->y, gadget->x + gadget->_image->_width - 1, gadget->y + gadget->_image->_height - 1); + bool gadgetIsEnabled = !(gadget->_flags & GADGETOFF); + + if (gadgetRect.contains(pos) && gadgetIsEnabled) { if (_vm->_isHiRes) { _hitGadget = gadget; } else { @@ -86,8 +86,6 @@ Gadget *EventManager::checkGadgetHit(GadgetList *gadgetList, Common::Point pos) return NULL; } - - void EventManager::attachGadgetList(GadgetList *gadgetList) { if (_screenGadgetList != gadgetList) _lastGadgetHit = nullptr; |