aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/graphics
diff options
context:
space:
mode:
authorMartin Kiewitz2010-02-05 21:09:36 +0000
committerMartin Kiewitz2010-02-05 21:09:36 +0000
commitf9673182254d2a3ea4bb770ce031d89985c8cba9 (patch)
treef79a2408d9b051a7b478486b996d764e878c9554 /engines/sci/graphics
parent16efee3c0df7e796b21ec198064a8499d2a28dac (diff)
downloadscummvm-rg350-f9673182254d2a3ea4bb770ce031d89985c8cba9.tar.gz
scummvm-rg350-f9673182254d2a3ea4bb770ce031d89985c8cba9.tar.bz2
scummvm-rg350-f9673182254d2a3ea4bb770ce031d89985c8cba9.zip
SCI: remaining cursor functions now also directly called
svn-id: r47914
Diffstat (limited to 'engines/sci/graphics')
-rw-r--r--engines/sci/graphics/coordadjuster.cpp13
-rw-r--r--engines/sci/graphics/coordadjuster.h5
-rw-r--r--engines/sci/graphics/cursor.cpp32
-rw-r--r--engines/sci/graphics/cursor.h9
-rw-r--r--engines/sci/graphics/gui.cpp30
-rw-r--r--engines/sci/graphics/gui.h4
-rw-r--r--engines/sci/graphics/gui32.cpp30
-rw-r--r--engines/sci/graphics/gui32.h9
8 files changed, 58 insertions, 74 deletions
diff --git a/engines/sci/graphics/coordadjuster.cpp b/engines/sci/graphics/coordadjuster.cpp
index 1c5207b2b4..3c9e30c8c8 100644
--- a/engines/sci/graphics/coordadjuster.cpp
+++ b/engines/sci/graphics/coordadjuster.cpp
@@ -65,6 +65,19 @@ Common::Rect GfxCoordAdjuster16::onControl(Common::Rect rect) {
return adjustedRect;
}
+void GfxCoordAdjuster16::setCursorPos(Common::Point &pos) {
+ pos.y += _ports->getPort()->top;
+ pos.x += _ports->getPort()->left;
+}
+
+void GfxCoordAdjuster16::moveCursor(Common::Point &pos) {
+ pos.y += _ports->_picWind->rect.top;
+ pos.x += _ports->_picWind->rect.left;
+
+ pos.y = CLIP<int16>(pos.y, _ports->_picWind->rect.top, _ports->_picWind->rect.bottom - 1);
+ pos.x = CLIP<int16>(pos.x, _ports->_picWind->rect.left, _ports->_picWind->rect.right - 1);
+}
+
#ifdef ENABLE_SCI32
GfxCoordAdjuster32::GfxCoordAdjuster32(SegManager *segMan)
: _segMan(segMan) {
diff --git a/engines/sci/graphics/coordadjuster.h b/engines/sci/graphics/coordadjuster.h
index 4c9cc1a11a..e1fed1a539 100644
--- a/engines/sci/graphics/coordadjuster.h
+++ b/engines/sci/graphics/coordadjuster.h
@@ -47,7 +47,8 @@ public:
virtual void kernelLocalToGlobal(int16 &x, int16 &y, reg_t planeObject = NULL_REG) { };
virtual Common::Rect onControl(Common::Rect rect) { return rect; };
-
+ virtual void setCursorPos(Common::Point &pos) { };
+ virtual void moveCursor(Common::Point &pos) { };
private:
};
@@ -60,6 +61,8 @@ public:
void kernelLocalToGlobal(int16 &x, int16 &y, reg_t planeObject = NULL_REG);
Common::Rect onControl(Common::Rect rect);
+ void setCursorPos(Common::Point &pos);
+ void moveCursor(Common::Point &pos);
private:
GfxPorts *_ports;
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
diff --git a/engines/sci/graphics/cursor.h b/engines/sci/graphics/cursor.h
index 3de6621ead..a32df21a1b 100644
--- a/engines/sci/graphics/cursor.h
+++ b/engines/sci/graphics/cursor.h
@@ -45,6 +45,8 @@ public:
GfxCursor(ResourceManager *resMan, GfxPalette *palette, GfxScreen *screen);
~GfxCursor();
+ void init(GfxCoordAdjuster *coordAdjuster, SciEvent *event);
+
void kernelShow();
void kernelHide();
bool isVisible();
@@ -59,7 +61,10 @@ public:
*
* @param[in] rect The rectangle
*/
- void setMoveZone(Common::Rect zone) { _moveZone = zone; }
+ void kernelSetMoveZone(Common::Rect zone);
+
+ void kernelSetPos(Common::Point pos);
+ void kernelMoveCursor(Common::Point pos);
private:
void purgeCache();
@@ -67,6 +72,8 @@ private:
ResourceManager *_resMan;
GfxScreen *_screen;
GfxPalette *_palette;
+ GfxCoordAdjuster *_coordAdjuster;
+ SciEvent *_event;
bool _upscaledHires;
diff --git a/engines/sci/graphics/gui.cpp b/engines/sci/graphics/gui.cpp
index 387b058d6c..a2f41bf746 100644
--- a/engines/sci/graphics/gui.cpp
+++ b/engines/sci/graphics/gui.cpp
@@ -56,6 +56,7 @@ SciGui::SciGui(EngineState *state, GfxScreen *screen, GfxPalette *palette, GfxCa
_coordAdjuster = new GfxCoordAdjuster16(_ports);
_s->_gfxCoordAdjuster = _coordAdjuster;
+ _cursor->init(_coordAdjuster, _s->_event);
_compare = new GfxCompare(_s->_segMan, _s->_kernel, _cache, _screen, _coordAdjuster);
_s->_gfxCompare = _compare;
_transitions = new GfxTransitions(this, _screen, _palette, _s->resMan->isVGA());
@@ -269,35 +270,6 @@ void SciGui::shakeScreen(uint16 shakeCount, uint16 directions) {
}
}
-void SciGui::setCursorPos(Common::Point pos) {
- pos.y += _ports->getPort()->top;
- pos.x += _ports->getPort()->left;
- moveCursor(pos);
-}
-
-void SciGui::moveCursor(Common::Point pos) {
- pos.y += _ports->_picWind->rect.top;
- pos.x += _ports->_picWind->rect.left;
-
- pos.y = CLIP<int16>(pos.y, _ports->_picWind->rect.top, _ports->_picWind->rect.bottom - 1);
- pos.x = CLIP<int16>(pos.x, _ports->_picWind->rect.left, _ports->_picWind->rect.right - 1);
-
- if (pos.x > _screen->getWidth() || pos.y > _screen->getHeight()) {
- warning("attempt to place cursor at invalid coordinates (%d, %d)", pos.y, pos.x);
- return;
- }
-
- _cursor->setPosition(pos);
-
- // Trigger event reading to make sure the mouse coordinates will
- // actually have changed the next time we read them.
- _s->_event->get(SCI_EVENT_PEEK);
-}
-
-void SciGui::setCursorZone(Common::Rect zone) {
- _cursor->setMoveZone(zone);
-}
-
reg_t SciGui::portraitLoad(Common::String resourceName) {
//Portrait *myPortrait = new Portrait(_s->resMan, _screen, _palette, resourceName);
return NULL_REG;
diff --git a/engines/sci/graphics/gui.h b/engines/sci/graphics/gui.h
index 21e7288d92..74735925af 100644
--- a/engines/sci/graphics/gui.h
+++ b/engines/sci/graphics/gui.h
@@ -76,10 +76,6 @@ public:
virtual void shakeScreen(uint16 shakeCount, uint16 directions);
- virtual void setCursorPos(Common::Point pos);
- virtual void moveCursor(Common::Point pos);
- void setCursorZone(Common::Rect zone);
-
virtual reg_t portraitLoad(Common::String resourceName);
virtual void portraitShow(Common::String resourceName, Common::Point position, uint16 resourceNum, uint16 noun, uint16 verb, uint16 cond, uint16 seq);
virtual void portraitUnload(uint16 portraitId);
diff --git a/engines/sci/graphics/gui32.cpp b/engines/sci/graphics/gui32.cpp
index c7e21015b4..64ed619ac3 100644
--- a/engines/sci/graphics/gui32.cpp
+++ b/engines/sci/graphics/gui32.cpp
@@ -51,6 +51,7 @@ SciGui32::SciGui32(EngineState *state, GfxScreen *screen, GfxPalette *palette, G
_coordAdjuster = new GfxCoordAdjuster32(_s->_segMan);
_s->_gfxCoordAdjuster = _coordAdjuster;
+ _cursor->init(_coordAdjuster, _s->_event);
_compare = new GfxCompare(_s->_segMan, _s->_kernel, _cache, _screen, _coordAdjuster);
_s->_gfxCompare = _compare;
_paint32 = new GfxPaint32(_s->resMan, _s->_segMan, _s->_kernel, _cache, _screen, _palette);
@@ -92,35 +93,6 @@ void SciGui32::shakeScreen(uint16 shakeCount, uint16 directions) {
}
}
-void SciGui32::setCursorPos(Common::Point pos) {
- //pos.y += _gfx->GetPort()->top;
- //pos.x += _gfx->GetPort()->left;
- moveCursor(pos);
-}
-
-void SciGui32::moveCursor(Common::Point pos) {
- // pos.y += _windowMgr->_picWind->rect.top;
- // pos.x += _windowMgr->_picWind->rect.left;
-
- // pos.y = CLIP<int16>(pos.y, _windowMgr->_picWind->rect.top, _windowMgr->_picWind->rect.bottom - 1);
- // pos.x = CLIP<int16>(pos.x, _windowMgr->_picWind->rect.left, _windowMgr->_picWind->rect.right - 1);
-
- if (pos.x > _screen->getWidth() || pos.y > _screen->getHeight()) {
- warning("attempt to place cursor at invalid coordinates (%d, %d)", pos.y, pos.x);
- return;
- }
-
- _cursor->setPosition(pos);
-
- // Trigger event reading to make sure the mouse coordinates will
- // actually have changed the next time we read them.
- _s->_event->get(SCI_EVENT_PEEK);
-}
-
-void SciGui32::setCursorZone(Common::Rect zone) {
- _cursor->setMoveZone(zone);
-}
-
void SciGui32::drawRobot(GuiResourceId robotId) {
Robot *test = new Robot(_s->resMan, _screen, robotId);
test->draw();
diff --git a/engines/sci/graphics/gui32.h b/engines/sci/graphics/gui32.h
index e4b431df11..9ac52854da 100644
--- a/engines/sci/graphics/gui32.h
+++ b/engines/sci/graphics/gui32.h
@@ -50,15 +50,6 @@ public:
void shakeScreen(uint16 shakeCount, uint16 directions);
- void setNowSeen(reg_t objectReference);
- bool canBeHere(reg_t curObject, reg_t listReference);
- bool isItSkip(GuiResourceId viewId, int16 loopNo, int16 celNo, Common::Point position);
- void baseSetter(reg_t object);
-
- void setCursorPos(Common::Point pos);
- void moveCursor(Common::Point pos);
- void setCursorZone(Common::Rect zone);
-
void drawRobot(GuiResourceId robotId);
// FIXME: Don't store EngineState