aboutsummaryrefslogtreecommitdiff
path: root/engines/tsage/graphics.cpp
diff options
context:
space:
mode:
authorMatthew Hoops2011-05-31 14:16:29 -0400
committerMatthew Hoops2011-05-31 14:16:29 -0400
commitaa49b38c5a8032586cb94fc4ca07149eecabe64a (patch)
treeea5c7617f8c482c8cf4141b728b3ccff5a7f84c7 /engines/tsage/graphics.cpp
parentd3ea9ab2a9334747eb445c1b45aa30cb17ffdf1b (diff)
parentc86a6c466fabe31fbf36363aa8d0ac8ea6001b9f (diff)
downloadscummvm-rg350-aa49b38c5a8032586cb94fc4ca07149eecabe64a.tar.gz
scummvm-rg350-aa49b38c5a8032586cb94fc4ca07149eecabe64a.tar.bz2
scummvm-rg350-aa49b38c5a8032586cb94fc4ca07149eecabe64a.zip
Merge remote branch 'upstream/master' into t7g-ios
Conflicts: engines/groovie/script.cpp
Diffstat (limited to 'engines/tsage/graphics.cpp')
-rw-r--r--engines/tsage/graphics.cpp56
1 files changed, 35 insertions, 21 deletions
diff --git a/engines/tsage/graphics.cpp b/engines/tsage/graphics.cpp
index c50da6beef..cc11343c9c 100644
--- a/engines/tsage/graphics.cpp
+++ b/engines/tsage/graphics.cpp
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#include "tsage/events.h"
@@ -673,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;
@@ -690,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) {
@@ -867,7 +874,7 @@ GfxDialog::~GfxDialog() {
void GfxDialog::setDefaults() {
GfxElement::setDefaults();
- // Initialise the embedded graphics manager
+ // Initialize the embedded graphics manager
_gfxManager.setDefaults();
// Figure out a rect needed for all the added elements
@@ -970,9 +977,10 @@ GfxButton *GfxDialog::execute(GfxButton *defaultButton) {
// Event loop
GfxButton *selectedButton = NULL;
- while (!_vm->getEventManager()->shouldQuit()) {
+ bool breakFlag = false;
+ while (!_vm->getEventManager()->shouldQuit() && !breakFlag) {
Event event;
- while (_globals->_events.getEvent(event)) {
+ while (_globals->_events.getEvent(event) && !breakFlag) {
// Adjust mouse positions to be relative within the dialog
event.mousePos.x -= _gfxManager._bounds.left;
event.mousePos.y -= _gfxManager._bounds.top;
@@ -981,19 +989,25 @@ GfxButton *GfxDialog::execute(GfxButton *defaultButton) {
if ((*i)->process(event))
selectedButton = static_cast<GfxButton *>(*i);
}
- }
- if (selectedButton)
- break;
- else if (!event.handled) {
- if ((event.eventType == EVENT_KEYPRESS) && (event.kbd.keycode == Common::KEYCODE_ESCAPE)) {
- selectedButton = NULL;
- break;
- } else if ((event.eventType == EVENT_KEYPRESS) && (event.kbd.keycode == Common::KEYCODE_RETURN)) {
- selectedButton = defaultButton;
+ if (selectedButton) {
+ breakFlag = true;
break;
+ } else if (!event.handled) {
+ if ((event.eventType == EVENT_KEYPRESS) && (event.kbd.keycode == Common::KEYCODE_ESCAPE)) {
+ selectedButton = NULL;
+ breakFlag = true;
+ break;
+ } else if ((event.eventType == EVENT_KEYPRESS) && (event.kbd.keycode == Common::KEYCODE_RETURN)) {
+ selectedButton = defaultButton;
+ breakFlag = true;
+ break;
+ }
}
}
+
+ g_system->delayMillis(10);
+ g_system->updateScreen();
}
_gfxManager.deactivate();
@@ -1195,7 +1209,7 @@ int GfxFont::getStringWidth(const char *s) {
/**
* Returns the maximum number of characters for words that will fit into a given width
*
- * @s Message to be analysed
+ * @s Message to be analyzed
* @maxWidth Maximum allowed width
*/
int GfxFont::getStringFit(const char *&s, int maxWidth) {
@@ -1241,7 +1255,7 @@ int GfxFont::getStringFit(const char *&s, int maxWidth) {
* Fills out the passed rect with the dimensions of a given string word-wrapped to a
* maximum specified width
*
- * @s Message to be analysed
+ * @s Message to be analyzed
* @bounds Rectangle to put output size into
* @maxWidth Maximum allowed line width in pixels
*/