aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/pink/cursor_mgr.cpp75
-rw-r--r--engines/pink/cursor_mgr.h11
-rw-r--r--engines/pink/objects/actors/cursor_actor.h9
-rw-r--r--engines/pink/pda_mgr.h3
4 files changed, 48 insertions, 50 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
diff --git a/engines/pink/cursor_mgr.h b/engines/pink/cursor_mgr.h
index d7f17bb429..231c87a76b 100644
--- a/engines/pink/cursor_mgr.h
+++ b/engines/pink/cursor_mgr.h
@@ -31,7 +31,7 @@
namespace Pink {
-class Actor;
+class CursorActor;
class Action;
class Page;
class PinkEngine;
@@ -47,16 +47,17 @@ public:
void setPage(Page *page) { _page = page; }
private:
+ void startAnimation(uint index);
+
+ void showItem(const Common::String &itemName, const Common::Point point);
void hideItem();
- void startAnimation(int index);
- Actor *_actor;
+private:
Page *_page;
PinkEngine *_game;
-
+ CursorActor *_actor;
uint _time;
uint _firstFrameIndex;
-
bool _isPlayingAnimation;
bool _isSecondFrame;
};
diff --git a/engines/pink/objects/actors/cursor_actor.h b/engines/pink/objects/actors/cursor_actor.h
index 2d5eb281e8..ff4c5de9c3 100644
--- a/engines/pink/objects/actors/cursor_actor.h
+++ b/engines/pink/objects/actors/cursor_actor.h
@@ -25,12 +25,11 @@
#include "common/debug.h"
-#include "pink/objects/actions/action.h"
+#include "pink/objects/actions/action_cel.h"
#include "pink/objects/actors/actor.h"
namespace Pink {
-//same as actor
class CursorActor : public Actor {
public:
void toConsole() override {
@@ -43,6 +42,12 @@ public:
bool isCursor() override {
return true;
}
+
+ void setCursorItem(const Common::String &name, const Common::Point point) {
+ if (!_action || _action->getName() != name)
+ setAction(name);
+ static_cast<ActionCEL*>(_action)->setCenter(point);
+ }
};
} // End of namespace Pink
diff --git a/engines/pink/pda_mgr.h b/engines/pink/pda_mgr.h
index c2e09ee287..5d84f497fe 100644
--- a/engines/pink/pda_mgr.h
+++ b/engines/pink/pda_mgr.h
@@ -24,11 +24,12 @@
#define PINK_PDA_MGR_H
#include "pink/cursor_mgr.h"
-#include "utils.h"
+#include "pink/utils.h"
namespace Pink {
class PinkEngine;
+class Actor;
class LeadActor;
class Command;
class PDAPage;