[Scummvm-cvs-logs] scummvm master -> 58380d5661cce68823859e83ca9e55ebff0221b3
dreammaster
dreammaster at scummvm.org
Sat Jul 25 02:21:13 CEST 2015
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
58380d5661 SHERLOCK: RT: Fix operation of Quit dialog
Commit: 58380d5661cce68823859e83ca9e55ebff0221b3
https://github.com/scummvm/scummvm/commit/58380d5661cce68823859e83ca9e55ebff0221b3
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2015-07-24T20:20:18-04:00
Commit Message:
SHERLOCK: RT: Fix operation of Quit dialog
Changed paths:
engines/sherlock/events.cpp
engines/sherlock/events.h
engines/sherlock/tattoo/widget_options.cpp
engines/sherlock/tattoo/widget_quit.cpp
diff --git a/engines/sherlock/events.cpp b/engines/sherlock/events.cpp
index 0f3b781..cb8a428 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 3dd4da2..9718a30 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 dd5fd70..0135a15 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 472ef48..dc80a3d 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();
}
}
More information about the Scummvm-git-logs
mailing list