diff options
author | whiterandrek | 2018-06-14 22:45:41 +0300 |
---|---|---|
committer | Eugene Sandulenko | 2018-06-28 23:51:32 +0200 |
commit | 861ef3be97eb7efca8d812aab953c8e0aaf32e08 (patch) | |
tree | c63cc2cf2031ae9c1aaa9675468892fe90606c42 /engines/pink/cursor_mgr.cpp | |
parent | bc4d32df8bb40b26d1999e08ecfe5d74f0e1e3b6 (diff) | |
download | scummvm-rg350-861ef3be97eb7efca8d812aab953c8e0aaf32e08.tar.gz scummvm-rg350-861ef3be97eb7efca8d812aab953c8e0aaf32e08.tar.bz2 scummvm-rg350-861ef3be97eb7efca8d812aab953c8e0aaf32e08.zip |
PINK: rework CursorMgr
Diffstat (limited to 'engines/pink/cursor_mgr.cpp')
-rw-r--r-- | engines/pink/cursor_mgr.cpp | 75 |
1 files changed, 33 insertions, 42 deletions
diff --git a/engines/pink/cursor_mgr.cpp b/engines/pink/cursor_mgr.cpp index a7bfbf3531..46861696dd 100644 --- a/engines/pink/cursor_mgr.cpp +++ b/engines/pink/cursor_mgr.cpp @@ -20,12 +20,10 @@ * */ -#include "pink/pink.h" -#include "pink/cel_decoder.h" #include "pink/cursor_mgr.h" -#include "pink/objects/actions/action_cel.h" -#include "pink/objects/actors/actor.h" -#include "pink/objects/pages/game_page.h" +#include "pink/pink.h" +#include "pink/objects/pages/page.h" +#include "pink/objects/actors/cursor_actor.h" namespace Pink { @@ -34,37 +32,23 @@ CursorMgr::CursorMgr(PinkEngine *game, Page *page) _isPlayingAnimation(0), _firstFrameIndex(0) {} void CursorMgr::setCursor(uint index, const Common::Point point, const Common::String &itemName) { - if (index == kClickableFirstFrameCursor) { + switch (index) { + case kClickableFirstFrameCursor: + case kPDAClickableFirstFrameCursor: startAnimation(index); - return hideItem(); - } else if (index != kHoldingItemCursor) { - - if (index != kPDAClickableFirstFrameCursor) { - _game->setCursor(index); - _isPlayingAnimation = 0; - return hideItem(); - } - hideItem(); - return startAnimation(index); - } - - _game->setCursor(index); - _isPlayingAnimation = 0; - - _actor = _actor ? _actor : _page->findActor(kCursor); - assert(_actor); - - Action *action = _actor->findAction(itemName); - assert(dynamic_cast<ActionCEL*>(action)); - - if (action != _actor->getAction()) { - _actor->setAction(action); + break; + case kHoldingItemCursor: + _game->setCursor(index); + _isPlayingAnimation = false; + showItem(itemName, point); + break; + default: + _game->setCursor(index); + _isPlayingAnimation = false; + hideItem(); + break; } - - ActionCEL *sprite = static_cast<ActionCEL*>(action); - sprite->setCenter(point); - } void CursorMgr::update() { @@ -90,7 +74,7 @@ void CursorMgr::setCursor(const Common::String &cursorName, const Common::Point //else //assert(0); - setCursor(index, point, Common::String()); + setCursor(index, point, ""); } void CursorMgr::hideItem() { @@ -98,14 +82,21 @@ void CursorMgr::hideItem() { _actor->setAction(kHideAction); } -void CursorMgr::startAnimation(int index) { - if (!_isPlayingAnimation) { - _isPlayingAnimation = 1; - _time = _game->getTotalPlayTime(); - _firstFrameIndex = index; - _isSecondFrame = 0; - _game->setCursor(index); - } +void CursorMgr::startAnimation(uint index) { + if (_isPlayingAnimation) + return; + + _game->setCursor(index); + _time = _game->getTotalPlayTime(); + _firstFrameIndex = index; + _isPlayingAnimation = true; + _isSecondFrame = false; +} + +void CursorMgr::showItem(const Common::String &itemName, const Common::Point point) { + if (!_actor) + _actor = static_cast<CursorActor*>(_page->findActor(kCursor)); + _actor->setCursorItem(itemName, point); } } // End of namespace Pink |