diff options
author | Filippos Karapetis | 2015-12-08 16:50:44 +0200 |
---|---|---|
committer | Willem Jan Palenstijn | 2015-12-23 21:33:55 +0100 |
commit | 0b2bf45a09ba2b5d1fc1593e629118c03b99f38f (patch) | |
tree | 5ce6d9031836bcb494b023f06008e62fa08b1736 | |
parent | 2d0fab7f4c1e4c7f8e88aee6a867a98a8917de86 (diff) | |
download | scummvm-rg350-0b2bf45a09ba2b5d1fc1593e629118c03b99f38f.tar.gz scummvm-rg350-0b2bf45a09ba2b5d1fc1593e629118c03b99f38f.tar.bz2 scummvm-rg350-0b2bf45a09ba2b5d1fc1593e629118c03b99f38f.zip |
LAB: Simplify the gadget enabling/disabling code
-rw-r--r-- | engines/lab/eventman.cpp | 3 | ||||
-rw-r--r-- | engines/lab/interface.cpp | 9 | ||||
-rw-r--r-- | engines/lab/interface.h | 5 |
3 files changed, 7 insertions, 10 deletions
diff --git a/engines/lab/eventman.cpp b/engines/lab/eventman.cpp index ad56b46fbc..7760ba2085 100644 --- a/engines/lab/eventman.cpp +++ b/engines/lab/eventman.cpp @@ -63,9 +63,8 @@ Gadget *EventManager::checkGadgetHit(GadgetList *gadgetList, Common::Point pos) for (GadgetList::iterator gadgetItr = gadgetList->begin(); gadgetItr != gadgetList->end(); ++gadgetItr) { Gadget *gadget = *gadgetItr; 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 (gadgetRect.contains(pos) && gadget->isEnabled) { if (_vm->_isHiRes) { _hitGadget = gadget; } else { diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp index 13cbd1e581..d041160349 100644 --- a/engines/lab/interface.cpp +++ b/engines/lab/interface.cpp @@ -48,6 +48,7 @@ Gadget *createButton(uint16 x, uint16 y, uint16 id, uint16 key, Image *im, Image gptr->_keyEquiv = key; gptr->_image = im; gptr->_altImage = imalt; + gptr->isEnabled = true; return gptr; } else @@ -69,7 +70,7 @@ void drawGadgetList(GadgetList *gadgetList) { for (GadgetList::iterator gadget = gadgetList->begin(); gadget != gadgetList->end(); ++gadget) { (*gadget)->_image->drawImage((*gadget)->x, (*gadget)->y); - if (GADGETOFF & (*gadget)->_flags) + if (!(*gadget)->isEnabled) disableGadget((*gadget), 1); } } @@ -79,7 +80,7 @@ void drawGadgetList(GadgetList *gadgetList) { */ void disableGadget(Gadget *curgad, uint16 pencolor) { g_lab->_graphics->overlayRect(pencolor, curgad->x, curgad->y, curgad->x + curgad->_image->_width - 1, curgad->y + curgad->_image->_height - 1); - curgad->_flags |= GADGETOFF; + curgad->isEnabled = false; } /** @@ -87,7 +88,7 @@ void disableGadget(Gadget *curgad, uint16 pencolor) { */ void enableGadget(Gadget *curgad) { curgad->_image->drawImage(curgad->x, curgad->y); - curgad->_flags &= !(GADGETOFF); + curgad->isEnabled = true; } /** @@ -114,7 +115,7 @@ Gadget *LabEngine::checkNumGadgetHit(GadgetList *gadgetList, uint16 key) { Gadget *gadget = *gadgetItr; if ((gkey - 1 == gadget->_gadgetID || (gkey == 0 && gadget->_gadgetID == 9) || (gadget->_keyEquiv != 0 && makeGadgetKeyEquiv(key) == gadget->_keyEquiv)) - && !(GADGETOFF & gadget->_flags)) { + && gadget->isEnabled) { _event->mouseHide(); gadget->_altImage->drawImage(gadget->x, gadget->y); _event->mouseShow(); diff --git a/engines/lab/interface.h b/engines/lab/interface.h index bd9c3c9697..50e89e38f7 100644 --- a/engines/lab/interface.h +++ b/engines/lab/interface.h @@ -46,13 +46,10 @@ struct IntuiMessage { struct Gadget { uint16 x, y, _gadgetID; uint16 _keyEquiv; // if not zero, a key that activates gadget - uint32 _flags; + bool isEnabled; Image *_image, *_altImage; }; -// Defines for the GadgetFlags portion -#define GADGETOFF 0x01 - typedef Common::List<Gadget *> GadgetList; // Defines for the Class variable in IntuiMessage |