diff options
author | Paul Gilbert | 2012-06-13 21:06:57 +1000 |
---|---|---|
committer | Paul Gilbert | 2012-06-13 21:06:57 +1000 |
commit | 746dcf33da340702157dc7aca0f01265648189be (patch) | |
tree | 354464dccc9d107e41192fb7e335db8d86666e1b /engines/tony | |
parent | 5bafab9ad629595a1d270b60b2a91bd04dc1b7b9 (diff) | |
download | scummvm-rg350-746dcf33da340702157dc7aca0f01265648189be.tar.gz scummvm-rg350-746dcf33da340702157dc7aca0f01265648189be.tar.bz2 scummvm-rg350-746dcf33da340702157dc7aca0f01265648189be.zip |
TONY: Refactor RMPointer class to use the ScummVM CursorMan
Diffstat (limited to 'engines/tony')
-rw-r--r-- | engines/tony/game.cpp | 73 | ||||
-rw-r--r-- | engines/tony/game.h | 28 | ||||
-rw-r--r-- | engines/tony/gfxengine.cpp | 5 |
3 files changed, 64 insertions, 42 deletions
diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 0ccd2d8dc8..1b13fa98bf 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -29,6 +29,7 @@ #include "common/file.h" #include "common/savefile.h" #include "common/textconsole.h" +#include "graphics/cursorman.h" #include "tony/mpal/lzo.h" #include "tony/mpal/memory.h" #include "tony/mpal/mpal.h" @@ -1543,46 +1544,62 @@ void RMPointer::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim _ctx->n = _nCurPointer; if (_ctx->n == TA_COMBINE) _ctx->n = TA_USE; - // Copy the destination coordinates in the primitive - prim->setDst(_pos); + _cursorHotspot = _hotspot[_ctx->n]; - if (_pos._x >= 0 && _pos._y >= 0 && _pos._x < RM_SX && _pos._y < RM_SY) { - // Call the Draw method of the poitner - prim->getDst() -= _hotspot[_ctx->n]; - - if (_nCurSpecialPointer == 0) { - CORO_INVOKE_2(_pointer[_ctx->n]->draw, bigBuf, prim); - } else { - if (_nCurSpecialPointer == PTR_CUSTOM) - CORO_INVOKE_2(_nCurCustomPointer->draw, bigBuf, prim); - else - // Call the draw on the special pointer - CORO_INVOKE_2(_specialPointer[_nCurSpecialPointer - 1]->draw, bigBuf, prim); - } + // Call the Draw method of the pointer + if (_nCurSpecialPointer == 0) { + CORO_INVOKE_2(_pointer[_ctx->n]->draw, bigBuf, prim); + } else { + if (_nCurSpecialPointer == PTR_CUSTOM) + CORO_INVOKE_2(_nCurCustomPointer->draw, bigBuf, prim); + else + // Call the draw on the special pointer + CORO_INVOKE_2(_specialPointer[_nCurSpecialPointer - 1]->draw, bigBuf, prim); } CORO_END_CODE; } -void RMPointer::doFrame(RMGfxTargetBuffer *bigBuf) { - // Add it to the list of primitives - bigBuf->addPrim(new RMGfxPrimitive(this)); +int RMPointer::curAction(void) { + if (_nCurSpecialPointer != 0) + return 0; - // If there is a special pointer, does DoFrame - if (_nCurSpecialPointer != 0 && _nCurSpecialPointer != PTR_CUSTOM) - _specialPointer[_nCurSpecialPointer - 1]->doFrame(bigBuf, false); + return _nCurPointer; } -void RMPointer::removeThis(CORO_PARAM, bool &result) { - // Always remove from the OT list, to support disabling the pointer - result = true; +/** + * Show the cursor + */ +void RMPointer::showCursor() { + if (!CursorMan.isVisible()) { + CursorMan.showMouse(true); + + updateCursor(); + } } -int RMPointer::curAction(void) { - if (_nCurSpecialPointer != 0) - return 0; +/** + * Hide the cursor + */ +void RMPointer::hideCursor() { + if (CursorMan.isVisible()) { + CursorMan.showMouse(false); + } +} - return _nCurPointer; + +void RMPointer::updateCursor() { + // Create an intermediate buffer and draw the cursor onto it + RMGfxTargetBuffer buf; + buf.create(64, 64, 16); + RMGfxPrimitive prim; + + draw(Common::nullContext, buf, &prim); + + // Get the raw pixel data and set the cursor to it + const byte *cursorData = buf; + Graphics::PixelFormat pixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0); + CursorMan.replaceCursor(cursorData, 64, 64, _cursorHotspot._x, _cursorHotspot._y, 0, 1, &pixelFormat); } } // End of namespace Tony diff --git a/engines/tony/game.h b/engines/tony/game.h index db182dfa23..9ac8f76bcc 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -54,11 +54,11 @@ namespace Tony { delete raw; -class RMPointer : public RMGfxTask { +class RMPointer { private: RMGfxSourceBuffer8 *_pointer[16]; RMPoint _hotspot[16]; - RMPoint _pos; + RMPoint _cursorHotspot; RMItem *_specialPointer[16]; @@ -67,6 +67,8 @@ private: RMGfxSourceBuffer8 *_nCurCustomPointer; + void updateCursor(); + public: enum POINTER { PTR_NONE = 0, @@ -95,20 +97,13 @@ public: // Overloading of priorities int priority(); - // Overloading draw method - virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - - // Sets the current co-ordinates - void setCoord(const RMPoint &pt) { - _pos = pt; - } - - // Overloading of the method to see if rising from the list - virtual void removeThis(CORO_PARAM, bool &result); + // draw method + void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Sets a new action as current void setAction(RMTonyAction action) { _nCurPointer = action; + updateCursor(); } // Sets a new pointer @@ -116,6 +111,8 @@ public: _nCurSpecialPointer = ptr; if (_nCurSpecialPointer && _nCurSpecialPointer != PTR_CUSTOM) _specialPointer[ptr - 1]->setPattern(1); + + updateCursor(); } POINTER getSpecialPointer(void) { return (POINTER)_nCurSpecialPointer; @@ -124,10 +121,17 @@ public: // Set the new custom pointer void setCustomPointer(RMGfxSourceBuffer8 *ptr) { _nCurCustomPointer = ptr; + updateCursor(); } // Return the current action to be applied according to the pointer int curAction(void); + + /** Show the cursor */ + void showCursor(); + + /** Hide the cursor */ + void hideCursor(); }; class RMOptionButton: public RMGfxTaskSetPrior { diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index b167d0a546..deae0cb641 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -305,8 +305,9 @@ SKIPCLICKSINISTRO: _tony.setScrollPosition(_loc.scrollPosition()); if ((!_tony.inAction() && _bInput) || _bAlwaysDrawMouse) { - _point.setCoord(_input.mousePos()); - _point.doFrame(&_bigBuf); + _point.showCursor(); + } else { + _point.hideCursor(); } // ********************** |