diff options
author | Filippos Karapetis | 2009-10-05 16:43:24 +0000 |
---|---|---|
committer | Filippos Karapetis | 2009-10-05 16:43:24 +0000 |
commit | 91a16e0c7dd97b24461901d03b1b485eea833dcc (patch) | |
tree | bac7a9a3f565f692d9cfdcbff1849b95fe1854e7 /engines | |
parent | 4c35022f6b3b5cc77fa90eb306e96a14fbb91a99 (diff) | |
download | scummvm-rg350-91a16e0c7dd97b24461901d03b1b485eea833dcc.tar.gz scummvm-rg350-91a16e0c7dd97b24461901d03b1b485eea833dcc.tar.bz2 scummvm-rg350-91a16e0c7dd97b24461901d03b1b485eea833dcc.zip |
Moved the cursor movement code in the GUI
svn-id: r44664
Diffstat (limited to 'engines')
-rw-r--r-- | engines/sci/engine/game.cpp | 3 | ||||
-rw-r--r-- | engines/sci/engine/kevent.cpp | 2 | ||||
-rw-r--r-- | engines/sci/engine/kgraphics.cpp | 9 | ||||
-rw-r--r-- | engines/sci/gfx/operations.cpp | 15 | ||||
-rw-r--r-- | engines/sci/gfx/operations.h | 10 | ||||
-rw-r--r-- | engines/sci/gui/gui.cpp | 13 | ||||
-rw-r--r-- | engines/sci/gui/gui.h | 3 | ||||
-rw-r--r-- | engines/sci/gui32/gui32.cpp | 20 | ||||
-rw-r--r-- | engines/sci/gui32/gui32.h | 2 |
9 files changed, 36 insertions, 41 deletions
diff --git a/engines/sci/engine/game.cpp b/engines/sci/engine/game.cpp index 00230f0f3c..caf828b586 100644 --- a/engines/sci/engine/game.cpp +++ b/engines/sci/engine/game.cpp @@ -31,6 +31,7 @@ #include "sci/engine/state.h" #include "sci/engine/kernel.h" #include "sci/engine/kernel_types.h" +#include "sci/gui/gui.h" #include "sci/gfx/gfx_widgets.h" #include "sci/gfx/gfx_state_internal.h" // required for GfxPort, GfxVisual #include "sci/gfx/menubar.h" @@ -210,7 +211,7 @@ int _reset_graphics_input(EngineState *s) { gfxop_fill_box(s->gfx_state, gfx_rect(0, 0, 320, 200), s->ega_colors[0]); // Fill screen black gfxop_update(s->gfx_state); - gfxop_set_pointer_position(s->gfx_state, Common::Point(160, 150)); + s->gui->moveCursor(160, 150); s->pic_is_new = 0; s->pic_visible_map = GFX_MASK_NONE; // Other values only make sense for debugging diff --git a/engines/sci/engine/kevent.cpp b/engines/sci/engine/kevent.cpp index 475e3200ca..b8af6f0ab0 100644 --- a/engines/sci/engine/kevent.cpp +++ b/engines/sci/engine/kevent.cpp @@ -65,7 +65,7 @@ reg_t kGetEvent(EngineState *s, int argc, reg_t *argv) { PUT_SEL32V(obj, x, s->gfx_state->pointer_pos.x); PUT_SEL32V(obj, y, s->gfx_state->pointer_pos.y); - //gfxop_set_pointer_position(s->gfx_state, Common::Point(s->gfx_state->pointer_pos.x, s->gfx_state->pointer_pos.y)); + //s->gui->moveCursor(s->gfx_state->pointer_pos.x, s->gfx_state->pointer_pos.y); switch (e.type) { case SCI_EVT_QUIT: diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp index 410818363b..06dcd73c95 100644 --- a/engines/sci/engine/kgraphics.cpp +++ b/engines/sci/engine/kgraphics.cpp @@ -276,10 +276,8 @@ static reg_t kSetCursorSci0(EngineState *s, int argc, reg_t *argv) { gfxop_set_pointer_cursor(s->gfx_state, cursor); // Set pointer position, if requested - if (argc >= 4) { - Common::Point newPos = Common::Point(argv[2].toSint16() + s->port->_bounds.x, argv[3].toSint16() + s->port->_bounds.y); - gfxop_set_pointer_position(s->gfx_state, newPos); - } + if (argc >= 4) + s->gui->moveCursor(argv[2].toSint16() + s->port->_bounds.x, argv[3].toSint16() + s->port->_bounds.y); return s->r_acc; } @@ -292,8 +290,7 @@ static reg_t kSetCursorSci11(EngineState *s, int argc, reg_t *argv) { CursorMan.showMouse(argv[0].toSint16() != 0); break; case 2: - gfxop_set_pointer_position(s->gfx_state, - Common::Point(argv[0].toUint16() + s->port->_bounds.x, argv[1].toUint16() + s->port->_bounds.y)); + s->gui->moveCursor(argv[0].toUint16() + s->port->_bounds.x, argv[1].toUint16() + s->port->_bounds.y); break; case 4: { int16 top = argv[0].toSint16(); diff --git a/engines/sci/gfx/operations.cpp b/engines/sci/gfx/operations.cpp index adbe812a6b..65fdfc1de7 100644 --- a/engines/sci/gfx/operations.cpp +++ b/engines/sci/gfx/operations.cpp @@ -1040,21 +1040,6 @@ void gfxop_set_pointer_view(GfxState *state, int nr, int loop, int cel, Common:: } } -void gfxop_set_pointer_position(GfxState *state, Common::Point pos) { - state->pointer_pos = pos; - - if (pos.x > 320 || pos.y > 200) { - debug("[GFX] Attempt to place pointer at invalid coordinates (%d, %d)\n", pos.x, pos.y); - return; // Not fatal - } - - g_system->warpMouse(pos.x * state->driver->getMode()->scaleFactor, pos.y * state->driver->getMode()->scaleFactor); - - // Trigger event reading to make sure the mouse coordinates will - // actually have changed the next time we read them. - gfxop_get_event(state, SCI_EVT_PEEK); -} - void gfxop_set_pointer_zone(GfxState *state, Common::Rect rect) { state->pointerZone = rect; } diff --git a/engines/sci/gfx/operations.h b/engines/sci/gfx/operations.h index d73ef50aab..f20bbf176a 100644 --- a/engines/sci/gfx/operations.h +++ b/engines/sci/gfx/operations.h @@ -389,16 +389,6 @@ void gfxop_set_pointer_cursor(GfxState *state, int nr); void gfxop_set_pointer_view(GfxState *state, int nr, int loop, int cel, Common::Point *hotspot); /** - * Teleports the mouse pointer to a specific position. - * - * Depending on the graphics driver, this operation may be without any effect - * - * @param[in] state The state the pointer is in - * @param[in] pos The position to teleport it to - */ -void gfxop_set_pointer_position(GfxState *state, Common::Point pos); - -/** * Limits the mouse movement to a given rectangle. * * @param[in] state The affected state diff --git a/engines/sci/gui/gui.cpp b/engines/sci/gui/gui.cpp index 6180a4a6d7..50c0298d11 100644 --- a/engines/sci/gui/gui.cpp +++ b/engines/sci/gui/gui.cpp @@ -403,7 +403,7 @@ void SciGui::setNowSeen(reg_t objectReference) { _gfx->SetNowSeen(objectReference); } -void SciGui::moveCursor(int16 x, int16 y) { +void SciGui::moveCursor(int16 x, int16 y, int16 scaleFactor) { Common::Point newPos; x += _windowMgr->_picWind->rect.left; @@ -411,7 +411,16 @@ void SciGui::moveCursor(int16 x, int16 y) { newPos.x = CLIP<int16>(x, _windowMgr->_picWind->rect.left, _windowMgr->_picWind->rect.right - 1); newPos.y = CLIP<int16>(y, _windowMgr->_picWind->rect.top, _windowMgr->_picWind->rect.bottom - 1); - gfxop_set_pointer_position(_s->gfx_state, newPos); + if (x > _screen->_width || y > _screen->_height) { + debug("[GFX] Attempt to place pointer at invalid coordinates (%d, %d)\n", x, y); + return; // Not fatal + } + + g_system->warpMouse(x * scaleFactor, y * scaleFactor); + + // Trigger event reading to make sure the mouse coordinates will + // actually have changed the next time we read them. + gfxop_get_event(_s->gfx_state, SCI_EVT_PEEK); } } // End of namespace Sci diff --git a/engines/sci/gui/gui.h b/engines/sci/gui/gui.h index f760138321..8c6423bd9f 100644 --- a/engines/sci/gui/gui.h +++ b/engines/sci/gui/gui.h @@ -85,7 +85,8 @@ public: virtual void addToPicView(GuiResourceId viewId, GuiViewLoopNo loopNo, GuiViewCelNo celNo, int16 leftPos, int16 topPos, int16 priority, int16 control); virtual void setNowSeen(reg_t objectReference); - virtual void moveCursor(int16 x, int16 y); + virtual void moveCursor(int16 x, int16 y, int16 scaleFactor = 1); + void moveCursor(Common::Point p, int16 scaleFactor = 1) { moveCursor(p.x, p.y, scaleFactor); } private: OSystem *_system; diff --git a/engines/sci/gui32/gui32.cpp b/engines/sci/gui32/gui32.cpp index f4babfba7f..125a8d68a2 100644 --- a/engines/sci/gui32/gui32.cpp +++ b/engines/sci/gui32/gui32.cpp @@ -1994,7 +1994,7 @@ void SciGui32::setNowSeen(reg_t objectReference) { } -void SciGui32::moveCursor(int16 x, int16 y) { +void SciGui32::moveCursor(int16 x, int16 y, int16 scaleFactor) { Common::Point newPos; // newPos = s->gfx_state->pointer_pos; @@ -2007,9 +2007,21 @@ void SciGui32::moveCursor(int16 x, int16 y) { if (newPos.y > s->port->zone.y + s->port->zone.height) newPos.y = s->port->zone.y + s->port->zone.height; - if (newPos.x < 0) newPos.x = 0; - if (newPos.y < 0) newPos.y = 0; - gfxop_set_pointer_position(s->gfx_state, newPos); + if (newPos.x < 0) + newPos.x = 0; + if (newPos.y < 0) + newPos.y = 0; + + if (x > 320 || y > 200) { + debug("[GFX] Attempt to place pointer at invalid coordinates (%d, %d)\n", x, y); + return; // Not fatal + } + + g_system->warpMouse(x * scaleFactor, y * scaleFactor); + + // Trigger event reading to make sure the mouse coordinates will + // actually have changed the next time we read them. + gfxop_get_event(s->gfx_state, SCI_EVT_PEEK); } } // End of namespace Sci diff --git a/engines/sci/gui32/gui32.h b/engines/sci/gui32/gui32.h index 28c6c95852..0dd702ee1d 100644 --- a/engines/sci/gui32/gui32.h +++ b/engines/sci/gui32/gui32.h @@ -80,7 +80,7 @@ public: void addToPicView(GuiResourceId viewId, GuiViewLoopNo loopNo, GuiViewCelNo celNo, int16 leftPos, int16 topPos, int16 priority, int16 control); void setNowSeen(reg_t objectReference); - void moveCursor(int16 x, int16 y); + void moveCursor(int16 x, int16 y, int16 scaleFactor = 1); private: OSystem *_system; |