diff options
author | eriktorbjorn | 2011-05-16 23:37:20 +0200 |
---|---|---|
committer | eriktorbjorn | 2011-05-16 23:37:20 +0200 |
commit | 9dbf05890919bbe248e32a0cfd48b0f42d7f820a (patch) | |
tree | c29dedf1767d1d2d6cd942168f743ae09a2c24fb /engines/tsage | |
parent | d47eceeb2fdd122efb143d00097c0cf159552bb2 (diff) | |
download | scummvm-rg350-9dbf05890919bbe248e32a0cfd48b0f42d7f820a.tar.gz scummvm-rg350-9dbf05890919bbe248e32a0cfd48b0f42d7f820a.tar.bz2 scummvm-rg350-9dbf05890919bbe248e32a0cfd48b0f42d7f820a.zip |
TSAGE: Fix graphics button behaviour (slightly hackish)
Don't rely on event.mousePos staying the same throughout the loop.
This makes sure the button stays highlighted for as long as the
mouse button is depressed, unless the mouse is moved off the button.
The calculation of mousePos is slightly hackish. It should probably
use a GfxManager object for that, but this will do for now.
Diffstat (limited to 'engines/tsage')
-rw-r--r-- | engines/tsage/graphics.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/engines/tsage/graphics.cpp b/engines/tsage/graphics.cpp index 85dfc5d058..a212c5dd77 100644 --- a/engines/tsage/graphics.cpp +++ b/engines/tsage/graphics.cpp @@ -670,12 +670,18 @@ void GfxElement::drawFrame() { * @event Event to process */ bool GfxElement::focusedEvent(Event &event) { + Common::Point mousePos = event.mousePos; bool highlightFlag = false; - while (!_vm->getEventManager()->shouldQuit()) { + // HACK: It should use the GfxManager object to figure out the relative + // position, but for now this seems like the easiest way. + int xOffset = mousePos.x - _globals->_events._mousePos.x; + int yOffset = mousePos.y - _globals->_events._mousePos.y; + + while (event.eventType != EVENT_BUTTON_UP && !_vm->getEventManager()->shouldQuit()) { g_system->delayMillis(10); - if (_bounds.contains(event.mousePos)) { + if (_bounds.contains(mousePos)) { if (!highlightFlag) { // First highlight call to show the highlight highlightFlag = true; @@ -687,8 +693,12 @@ bool GfxElement::focusedEvent(Event &event) { highlight(); } - if (_globals->_events.getEvent(event, EVENT_BUTTON_UP)) - break; + if (_globals->_events.getEvent(event, EVENT_MOUSE_MOVE | EVENT_BUTTON_UP)) { + if (event.eventType == EVENT_MOUSE_MOVE) { + mousePos.x = event.mousePos.x + xOffset; + mousePos.y = event.mousePos.y + yOffset; + } + } } if (highlightFlag) { |