aboutsummaryrefslogtreecommitdiff
path: root/engines/sherlock
diff options
context:
space:
mode:
authorPaul Gilbert2015-07-24 20:20:18 -0400
committerPaul Gilbert2015-07-24 20:20:18 -0400
commit58380d5661cce68823859e83ca9e55ebff0221b3 (patch)
tree9494889e23469cc1db597dd44ed9b2c58f5c390b /engines/sherlock
parentc6e18844038e087f373923731265beac58485a31 (diff)
downloadscummvm-rg350-58380d5661cce68823859e83ca9e55ebff0221b3.tar.gz
scummvm-rg350-58380d5661cce68823859e83ca9e55ebff0221b3.tar.bz2
scummvm-rg350-58380d5661cce68823859e83ca9e55ebff0221b3.zip
SHERLOCK: RT: Fix operation of Quit dialog
Diffstat (limited to 'engines/sherlock')
-rw-r--r--engines/sherlock/events.cpp20
-rw-r--r--engines/sherlock/events.h3
-rw-r--r--engines/sherlock/tattoo/widget_options.cpp2
-rw-r--r--engines/sherlock/tattoo/widget_quit.cpp34
4 files changed, 26 insertions, 33 deletions
diff --git a/engines/sherlock/events.cpp b/engines/sherlock/events.cpp
index 0f3b781520..cb8a4288f2 100644
--- a/engines/sherlock/events.cpp
+++ b/engines/sherlock/events.cpp
@@ -162,7 +162,9 @@ void Events::pollEvents() {
Common::Event event;
while (g_system->getEventManager()->pollEvent(event)) {
- // Handle keypress
+ _mousePos = event.mouse;
+
+ // Handle events
switch (event.type) {
case Common::EVENT_QUIT:
case Common::EVENT_RTL:
@@ -204,8 +206,8 @@ void Events::pollEventsAndWait() {
}
void Events::warpMouse(const Common::Point &pt) {
- Common::Point p = pt - _vm->_screen->_currentScroll;
- g_system->warpMouse(p.x, p.y);
+ _mousePos = pt - _vm->_screen->_currentScroll;
+ g_system->warpMouse(_mousePos.x, _mousePos.y);
}
void Events::warpMouse() {
@@ -214,6 +216,10 @@ void Events::warpMouse() {
screen._currentScroll.y + SHERLOCK_SCREEN_HEIGHT / 2));
}
+Common::Point Events::mousePos() const {
+ return _vm->_screen->_currentScroll + _mousePos;
+}
+
bool Events::checkForNextFrameCounter() {
// Check for next game frame
uint32 milli = g_system->getMillis();
@@ -233,14 +239,6 @@ bool Events::checkForNextFrameCounter() {
return false;
}
-Common::Point Events::screenMousePos() const {
- return g_system->getEventManager()->getMousePos();
-}
-
-Common::Point Events::mousePos() const {
- return screenMousePos() + _vm->_screen->_currentScroll;
-}
-
Common::KeyState Events::getKey() {
return _pendingKeys.pop();
}
diff --git a/engines/sherlock/events.h b/engines/sherlock/events.h
index 3dd4da2411..9718a30fd3 100644
--- a/engines/sherlock/events.h
+++ b/engines/sherlock/events.h
@@ -44,6 +44,7 @@ private:
uint32 _priorFrameTime;
ImageFile *_cursorImages;
int _mouseButtons;
+ Common::Point _mousePos;
/**
* Check whether it's time to display the next screen frame
@@ -133,7 +134,7 @@ public:
/**
* Get the current mouse position
*/
- Common::Point screenMousePos() const;
+ Common::Point screenMousePos() const { return _mousePos; }
/**
* Get the current mouse position within the scene, adjusted by the scroll position
diff --git a/engines/sherlock/tattoo/widget_options.cpp b/engines/sherlock/tattoo/widget_options.cpp
index dd5fd701a8..0135a157c8 100644
--- a/engines/sherlock/tattoo/widget_options.cpp
+++ b/engines/sherlock/tattoo/widget_options.cpp
@@ -104,6 +104,7 @@ void WidgetOptions::handleEvents() {
} else {
_selector = -1;
if (_outsideMenu && (events._released || events._rightReleased)) {
+ events.clearEvents();
close();
return;
}
@@ -161,6 +162,7 @@ void WidgetOptions::handleEvents() {
// Option selected
if (events._released || events._rightReleased) {
+ events.clearEvents();
_outsideMenu = false;
int temp = _selector;
_selector = 255;
diff --git a/engines/sherlock/tattoo/widget_quit.cpp b/engines/sherlock/tattoo/widget_quit.cpp
index 472ef48772..dc80a3dc47 100644
--- a/engines/sherlock/tattoo/widget_quit.cpp
+++ b/engines/sherlock/tattoo/widget_quit.cpp
@@ -79,26 +79,26 @@ void WidgetQuit::handleEvents() {
Events &events = *_vm->_events;
Talk &talk = *_vm->_talk;
Common::Point mousePos = events.mousePos();
- Common::Rect btn1Rect(_bounds.left, _bounds.top + (_surface.fontHeight() + 4) * 2 + 3, _bounds.right,
+ Common::Rect yesRect(_bounds.left, _bounds.top + (_surface.fontHeight() + 4) * 2 + 3, _bounds.right,
_bounds.top + (_surface.fontHeight() + 4) * 2 + 3 + _surface.fontHeight() + 7);
- Common::Rect btn2Rect(_bounds.left, _bounds.top + (_surface.fontHeight() + 4) * 2 + _surface.fontHeight() + 10,
+ Common::Rect noRect(_bounds.left, _bounds.top + (_surface.fontHeight() + 4) * 2 + _surface.fontHeight() + 10,
_bounds.right, _bounds.top + (_surface.fontHeight() + 4) * 2 + 10 + _surface.fontHeight() * 2 + 7);
if (talk._talkToAbort)
return;
+ // Determine the highlighted item
+ _select = -1;
+ if (yesRect.contains(mousePos))
+ _select = 1;
+ else if (noRect.contains(mousePos))
+ _select = 0;
+
if (events.kbHit()) {
Common::KeyState keyState = events.getKey();
switch (keyState.keycode) {
case Common::KEYCODE_TAB:
- _select = -1;
-
- if (btn1Rect.contains(mousePos))
- _select = 1;
- else if (btn2Rect.contains(mousePos))
- _select = 0;
-
// If the mouse is not over any of the options, move the mouse so that it points to the first option
if (_select == -1)
events.warpMouse(Common::Point(_bounds.right - 10, _bounds.top + (_surface.fontHeight() + 4) * 2
@@ -126,15 +126,8 @@ void WidgetQuit::handleEvents() {
}
}
- // Check for highlight
- _select = -1;
- if (btn1Rect.contains(mousePos))
- _select = 0;
- else if (btn2Rect.contains(mousePos))
- _select = 1;
-
+ // Check for change of the highlighted item
if (_select != _oldSelect) {
- // Highlight changed,
byte color = (_select == 1) ? COMMAND_HIGHLIGHTED : INFO_TOP;
int yp = (_surface.fontHeight() + 4) * 2 + 8;
_surface.writeString(FIXED(Yes), Common::Point((_surface.w() - _surface.stringWidth(FIXED(Yes))) / 2, yp), color);
@@ -150,11 +143,10 @@ void WidgetQuit::handleEvents() {
_outsideMenu = true;
if (events._released || events._rightReleased) {
- _select = -1;
- _outsideMenu = false;
-
+ events.clearEvents();
close();
- if (btn1Rect.contains(mousePos))
+ if (_select == 1)
+ // Yes selected
_vm->quitGame();
}
}