diff options
author | Filippos Karapetis | 2009-10-07 21:29:47 +0000 |
---|---|---|
committer | Filippos Karapetis | 2009-10-07 21:29:47 +0000 |
commit | 1562add63191c482acf99da61d6d8d1e2bf8903d (patch) | |
tree | 68d36e8e9219837a9febdb7791b572da9e7f3ed6 /engines/sci/gui | |
parent | 80d136a362e667d4e8ff0754fe634eba30e0590a (diff) | |
download | scummvm-rg350-1562add63191c482acf99da61d6d8d1e2bf8903d.tar.gz scummvm-rg350-1562add63191c482acf99da61d6d8d1e2bf8903d.tar.bz2 scummvm-rg350-1562add63191c482acf99da61d6d8d1e2bf8903d.zip |
- Cleaned up the cursor code
- Renamed gui -> _gui in EngineState, for consistency
- Added a reference to SciGuiCursor in EngineState, to be used by current code
- Renamed setCursorHide -> hideCursor, setCursorShow -> showCursor
- Moved the cursor zone limiting code inside SciGuiCursor. This code is currently not functioning, as we need to call refreshPosition() before each updateScreen() call to limit the cursor position.
svn-id: r44760
Diffstat (limited to 'engines/sci/gui')
-rw-r--r-- | engines/sci/gui/gui.cpp | 4 | ||||
-rw-r--r-- | engines/sci/gui/gui.h | 4 | ||||
-rw-r--r-- | engines/sci/gui/gui_cursor.cpp | 44 | ||||
-rw-r--r-- | engines/sci/gui/gui_cursor.h | 16 |
4 files changed, 52 insertions, 16 deletions
diff --git a/engines/sci/gui/gui.cpp b/engines/sci/gui/gui.cpp index c3ca647e80..331666edff 100644 --- a/engines/sci/gui/gui.cpp +++ b/engines/sci/gui/gui.cpp @@ -460,11 +460,11 @@ void SciGui::setNowSeen(reg_t objectReference) { _gfx->SetNowSeen(objectReference); } -void SciGui::setCursorHide() { +void SciGui::hideCursor() { _cursor->hide(); } -void SciGui::setCursorShow() { +void SciGui::showCursor() { _cursor->show(); } diff --git a/engines/sci/gui/gui.h b/engines/sci/gui/gui.h index ee32d66e9f..33a945a634 100644 --- a/engines/sci/gui/gui.h +++ b/engines/sci/gui/gui.h @@ -84,8 +84,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 setCursorHide(); - virtual void setCursorShow(); + virtual void hideCursor(); + virtual void showCursor(); virtual void setCursorShape(GuiResourceId cursorId); virtual void setCursorPos(Common::Point pos); virtual void moveCursor(Common::Point pos); diff --git a/engines/sci/gui/gui_cursor.cpp b/engines/sci/gui/gui_cursor.cpp index baf2be01f8..25ba1b9416 100644 --- a/engines/sci/gui/gui_cursor.cpp +++ b/engines/sci/gui/gui_cursor.cpp @@ -25,6 +25,7 @@ #include "graphics/cursorman.h" #include "common/util.h" +#include "common/events.h" #include "sci/sci.h" #include "sci/engine/state.h" @@ -35,16 +36,14 @@ namespace Sci { -SciGuiCursor::SciGuiCursor(EngineState *state, SciGuiPalette *palette) - : _s(state), _palette(palette) { - init(); -} +SciGuiCursor::SciGuiCursor(ResourceManager *resMan, SciGuiPalette *palette) + : _resMan(resMan), _palette(palette) { + _rawBitmap = NULL; -SciGuiCursor::~SciGuiCursor() { + setPosition(Common::Point(160, 150)); // TODO: how is that different in 640x400 games? } -void SciGuiCursor::init() { - _rawBitmap = NULL; +SciGuiCursor::~SciGuiCursor() { } void SciGuiCursor::show() { @@ -72,7 +71,7 @@ void SciGuiCursor::setShape(GuiResourceId resourceId) { } // Load cursor resource... - resource = _s->resMan->findResource(ResourceId(kResourceTypeCursor, resourceId), false); + resource = _resMan->findResource(ResourceId(kResourceTypeCursor, resourceId), false); if (!resource) error("cursor resource %d not found", resourceId); if (resource->size != SCI_CURSOR_SCI0_RESOURCESIZE) @@ -117,4 +116,33 @@ void SciGuiCursor::setPosition(Common::Point pos) { g_system->warpMouse(pos.x, pos.y); } +Common::Point SciGuiCursor::getPosition() { + return g_system->getEventManager()->getMousePos(); +} + +void SciGuiCursor::refreshPosition() { + bool clipped = false; + Common::Point mousePoint = getPosition(); + + if (mousePoint.x < _moveZone.left) { + mousePoint.x = _moveZone.left; + clipped = true; + } else if (mousePoint.x >= _moveZone.right) { + mousePoint.x = _moveZone.right - 1; + clipped = true; + } + + if (mousePoint.y < _moveZone.top) { + mousePoint.y = _moveZone.top; + clipped = true; + } else if (mousePoint.y >= _moveZone.bottom) { + mousePoint.y = _moveZone.bottom - 1; + clipped = true; + } + + // FIXME: Do this only when mouse is grabbed? + if (clipped) + g_system->warpMouse(mousePoint.x, mousePoint.y); +} + } // End of namespace Sci diff --git a/engines/sci/gui/gui_cursor.h b/engines/sci/gui/gui_cursor.h index 2a14f9e5e5..98ca7109a6 100644 --- a/engines/sci/gui/gui_cursor.h +++ b/engines/sci/gui/gui_cursor.h @@ -39,22 +39,30 @@ class SciGuiView; class SciGuiPalette; class SciGuiCursor { public: - SciGuiCursor(EngineState *state, SciGuiPalette *palette); + SciGuiCursor(ResourceManager *resMan, SciGuiPalette *palette); ~SciGuiCursor(); void show(); void hide(); void setShape(GuiResourceId resourceId); void setPosition(Common::Point pos); + Common::Point getPosition(); + void refreshPosition(); -private: - void init(); + /** + * Limits the mouse movement to a given rectangle. + * + * @param[in] rect The rectangle + */ + void setMoveZone(Common::Rect zone) { _moveZone = zone; } - EngineState *_s; +private: + ResourceManager *_resMan; SciGuiScreen *_screen; SciGuiPalette *_palette; byte *_rawBitmap; + Common::Rect _moveZone; // Rectangle in which the pointer can move }; } // End of namespace Sci |