aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorMax Horn2009-03-24 12:14:41 +0000
committerMax Horn2009-03-24 12:14:41 +0000
commit33895c0220c114653ee77a347452f03e8b8654f7 (patch)
tree022d97d59e18fc1159240396da6fa9c5070babe4 /engines
parent608b839720a028b5ecffa5955b024387740583d7 (diff)
downloadscummvm-rg350-33895c0220c114653ee77a347452f03e8b8654f7.tar.gz
scummvm-rg350-33895c0220c114653ee77a347452f03e8b8654f7.tar.bz2
scummvm-rg350-33895c0220c114653ee77a347452f03e8b8654f7.zip
SCI: Only pass the pointerpos to Menubar::mapPointer, not the full gfx_state_t
svn-id: r39662
Diffstat (limited to 'engines')
-rw-r--r--engines/sci/engine/kmenu.cpp6
-rw-r--r--engines/sci/gfx/menubar.cpp24
-rw-r--r--engines/sci/gfx/menubar.h9
3 files changed, 20 insertions, 19 deletions
diff --git a/engines/sci/engine/kmenu.cpp b/engines/sci/engine/kmenu.cpp
index 601011eff3..3304acf2de 100644
--- a/engines/sci/engine/kmenu.cpp
+++ b/engines/sci/engine/kmenu.cpp
@@ -193,7 +193,7 @@ reg_t kMenuSelect(EngineState *s, int funct_nr, int argc, reg_t *argv) {
/* Default to menu 0, unless the mouse was used to generate this effect */
if (mouse_down)
- s->_menubar->mapPointer(s->gfx_state, &menu_nr, &item_nr, port);
+ s->_menubar->mapPointer(s->gfx_state->pointer_pos, menu_nr, item_nr, port);
else
menu_nr = 0;
@@ -267,7 +267,7 @@ reg_t kMenuSelect(EngineState *s, int funct_nr, int argc, reg_t *argv) {
case SCI_EVT_MOUSE_RELEASE:
menu_mode = (s->gfx_state->pointer_pos.y < 10);
- claimed = !menu_mode && !s->_menubar->mapPointer(s->gfx_state, &menu_nr, &item_nr, port);
+ claimed = !menu_mode && !s->_menubar->mapPointer(s->gfx_state->pointer_pos, menu_nr, item_nr, port);
mouse_down = 0;
break;
@@ -281,7 +281,7 @@ reg_t kMenuSelect(EngineState *s, int funct_nr, int argc, reg_t *argv) {
}
if (mouse_down)
- s->_menubar->mapPointer(s->gfx_state, &menu_nr, &item_nr, port);
+ s->_menubar->mapPointer(s->gfx_state->pointer_pos, menu_nr, item_nr, port);
if ((item_nr > -1 && old_item == -1) || (menu_nr != old_menu)) { /* Update menu */
diff --git a/engines/sci/gfx/menubar.cpp b/engines/sci/gfx/menubar.cpp
index 242bba3f42..57b837085e 100644
--- a/engines/sci/gfx/menubar.cpp
+++ b/engines/sci/gfx/menubar.cpp
@@ -387,40 +387,40 @@ bool Menubar::itemValid(int menu_nr, int item_nr) const {
return false; // May not be selected
}
-bool Menubar::mapPointer(gfx_state_t *state, int *menu_nr, int *item_nr, gfxw_port_t *port) const {
+bool Menubar::mapPointer(const Common::Point &pointerPos, int &menu_nr, int &item_nr, gfxw_port_t *port) const {
- if (state->pointer_pos.y <= 10) { // Re-evaulate menu
+ if (pointerPos.y <= 10) { // Re-evaulate menu
int x = MENU_LEFT_BORDER;
for (uint i = 0; i < _menus.size(); i++) {
int newx = x + MENU_BORDER_SIZE * 2 + _menus[i]._titleWidth;
- if (state->pointer_pos.x < x)
+ if (pointerPos.x < x)
return false;
- if (state->pointer_pos.x < newx) {
- *menu_nr = i;
- *item_nr = -1;
+ if (pointerPos.x < newx) {
+ menu_nr = i;
+ item_nr = -1;
}
x = newx;
}
} else {
- int row = (state->pointer_pos.y / 10) - 1;
+ int row = (pointerPos.y / 10) - 1;
- if ((*menu_nr < 0) || (*menu_nr >= (int)_menus.size()))
+ if ((menu_nr < 0) || (menu_nr >= (int)_menus.size()))
return true; // No menu
- const Menu &menu = _menus[*menu_nr]; // Menu is valid, assume that it's popped up
+ const Menu &menu = _menus[menu_nr]; // Menu is valid, assume that it's popped up
if ((int)menu._items.size() <= row)
return true;
- if ((state->pointer_pos.x < port->bounds.x) || (state->pointer_pos.x > port->bounds.x + port->bounds.width))
+ if ((pointerPos.x < port->bounds.x) || (pointerPos.x > port->bounds.x + port->bounds.width))
return true;
- if (itemValid(*menu_nr, row))
- *item_nr = row; // Only modify if we'll be hitting a valid element
+ if (itemValid(menu_nr, row))
+ item_nr = row; // Only modify if we'll be hitting a valid element
}
diff --git a/engines/sci/gfx/menubar.h b/engines/sci/gfx/menubar.h
index 269777e97e..8d66085bbc 100644
--- a/engines/sci/gfx/menubar.h
+++ b/engines/sci/gfx/menubar.h
@@ -204,12 +204,13 @@ public:
/**
* Maps the pointer position to a (menu,item) tuple.
- * Parameters: (gfx_state_t *) state: The current state
- * ((int *) x (int *)) (menu_nr, item_nr): Pointers to the current menu/item tuple
- * (port_t *) port: The port of the currently active menu (if any)
+ * @param pointerPos the current pointer position
+ * @param menu_nr the current menu (updated by this function if necessary)
+ * @param item_nr the current menu item (updated by this function if necessary)
+ * @param port the port of the currently active menu (if any)
* @return true if the pointer is outside a valid port, false otherwise.
*/
- bool mapPointer(gfx_state_t *state, int *menu_nr, int *item_nr, gfxw_port_t *port) const;
+ bool mapPointer(const Common::Point &pointerPos, int &menu_nr, int &item_nr, gfxw_port_t *port) const;
};