From f9673182254d2a3ea4bb770ce031d89985c8cba9 Mon Sep 17 00:00:00 2001 From: Martin Kiewitz Date: Fri, 5 Feb 2010 21:09:36 +0000 Subject: SCI: remaining cursor functions now also directly called svn-id: r47914 --- engines/sci/graphics/cursor.cpp | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'engines/sci/graphics/cursor.cpp') diff --git a/engines/sci/graphics/cursor.cpp b/engines/sci/graphics/cursor.cpp index 5de0166c98..ac4ef0a227 100644 --- a/engines/sci/graphics/cursor.cpp +++ b/engines/sci/graphics/cursor.cpp @@ -28,9 +28,11 @@ #include "common/events.h" #include "sci/sci.h" +#include "sci/event.h" #include "sci/engine/state.h" #include "sci/graphics/palette.h" #include "sci/graphics/screen.h" +#include "sci/graphics/coordadjuster.h" #include "sci/graphics/view.h" #include "sci/graphics/cursor.h" @@ -42,7 +44,7 @@ GfxCursor::GfxCursor(ResourceManager *resMan, GfxPalette *palette, GfxScreen *sc _upscaledHires = _screen->getUpscaledHires(); // center mouse cursor setPosition(Common::Point(_screen->getDisplayWidth() / 2, _screen->getDisplayHeight() / 2)); - setMoveZone(Common::Rect(0, 0, _screen->getDisplayWidth(), _screen->getDisplayHeight())); + kernelSetMoveZone(Common::Rect(0, 0, _screen->getDisplayWidth(), _screen->getDisplayHeight())); _isVisible = true; } @@ -51,6 +53,11 @@ GfxCursor::~GfxCursor() { purgeCache(); } +void GfxCursor::init(GfxCoordAdjuster *coordAdjuster, SciEvent *event) { + _coordAdjuster = coordAdjuster; + _event = event; +} + void GfxCursor::kernelShow() { CursorMan.showMouse(true); _isVisible = true; @@ -224,4 +231,27 @@ void GfxCursor::refreshPosition() { setPosition(mousePoint); } +void GfxCursor::kernelSetMoveZone(Common::Rect zone) { + _moveZone = zone; +} + +void GfxCursor::kernelSetPos(Common::Point pos) { + _coordAdjuster->setCursorPos(pos); + kernelMoveCursor(pos); +} + +void GfxCursor::kernelMoveCursor(Common::Point pos) { + _coordAdjuster->moveCursor(pos); + if (pos.x > _screen->getWidth() || pos.y > _screen->getHeight()) { + warning("attempt to place cursor at invalid coordinates (%d, %d)", pos.y, pos.x); + return; + } + + setPosition(pos); + + // Trigger event reading to make sure the mouse coordinates will + // actually have changed the next time we read them. + _event->get(SCI_EVENT_PEEK); +} + } // End of namespace Sci -- cgit v1.2.3