Moved the cursor movement code in the GUI
svn-id: r44664
This commit is contained in:
parent
4c35022f6b
commit
91a16e0c7d
9 changed files with 36 additions and 41 deletions
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -388,16 +388,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.
|
||||
*
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue