aboutsummaryrefslogtreecommitdiff
path: root/engines/pink
diff options
context:
space:
mode:
Diffstat (limited to 'engines/pink')
-rw-r--r--engines/pink/cel_decoder.cpp30
-rw-r--r--engines/pink/cel_decoder.h14
-rw-r--r--engines/pink/cursor_mgr.cpp59
-rw-r--r--engines/pink/cursor_mgr.h3
-rw-r--r--engines/pink/director.cpp15
5 files changed, 85 insertions, 36 deletions
diff --git a/engines/pink/cel_decoder.cpp b/engines/pink/cel_decoder.cpp
index 1e7a36a9ef..39b797b348 100644
--- a/engines/pink/cel_decoder.cpp
+++ b/engines/pink/cel_decoder.cpp
@@ -51,14 +51,14 @@ bool CelDecoder::loadStream(Common::SeekableReadStream *stream) {
return true;
}
-uint32 CelDecoder::getX(){
+int32 CelDecoder::getX(){
CelVideoTrack *track = (CelVideoTrack*) getTrack(0);
if (!track)
return -1;
return track->getX();
}
-uint32 CelDecoder::getY() {
+int32 CelDecoder::getY() {
CelVideoTrack *track = (CelVideoTrack*) getTrack(0);
if (!track)
return -1;
@@ -92,6 +92,16 @@ Common::Rect &CelDecoder::getRectangle() {
return track->getRect();
}
+void CelDecoder::setX(int32 x) {
+ CelVideoTrack *track = (CelVideoTrack*) getTrack(0);
+ track->setX(x);
+}
+
+void CelDecoder::setY(int32 y) {
+ CelVideoTrack *track = (CelVideoTrack*) getTrack(0);
+ track->setY(y);
+}
+
CelDecoder::CelVideoTrack::CelVideoTrack(Common::SeekableReadStream *stream, uint16 frameCount, uint16 width, uint16 height, bool skipHeader)
: FlicVideoTrack(stream, frameCount, width, height, 1), _center(0,0), _transparentColourIndex(0){
readHeader();
@@ -141,12 +151,12 @@ void CelDecoder::CelVideoTrack::readHeader() {
_fileStream->seek(_offsetFrame1);
}
-uint32 CelDecoder::CelVideoTrack::getX() const {
- return _center.x - getWidth() / 2;
+int32 CelDecoder::CelVideoTrack::getX() const {
+ return (_center.x - getWidth() / 2) < 0 ? 0 : _center.x - getWidth() / 2;
}
-uint32 CelDecoder::CelVideoTrack::getY() const {
- return _center.y - getHeight() / 2;
+int32 CelDecoder::CelVideoTrack::getY() const {
+ return (_center.y - getHeight() / 2) < 0 ? 0 : _center.y - getHeight() / 2;
}
uint16 CelDecoder::CelVideoTrack::getTransparentColourIndex() {
@@ -196,4 +206,12 @@ const Graphics::Surface *CelDecoder::CelVideoTrack::decodeNextFrame() {
return _surface;
}
+void CelDecoder::CelVideoTrack::setX(int32 x) {
+ _center.x = x ;//+ getWidth() / 2;
+}
+
+void CelDecoder::CelVideoTrack::setY(int32 y) {
+ _center.y = y;//+ getHeight() / 2;
+}
+
} // End of namepsace Pink \ No newline at end of file
diff --git a/engines/pink/cel_decoder.h b/engines/pink/cel_decoder.h
index c3ecce0a38..d52318bfda 100644
--- a/engines/pink/cel_decoder.h
+++ b/engines/pink/cel_decoder.h
@@ -32,28 +32,34 @@ class CelDecoder : public Video::FlicDecoder {
public:
virtual bool loadStream(Common::SeekableReadStream *stream);
- uint32 getX();
- uint32 getY();
+ int32 getX();
+ int32 getY();
uint16 getTransparentColourIndex();
Common::Point getCenter();
Common::Rect &getRectangle();
const Graphics::Surface *getCurrentFrame();
+ void setX(int32 x);
+ void setY(int32 y);
+
protected:
class CelVideoTrack : public FlicVideoTrack {
public:
CelVideoTrack(Common::SeekableReadStream *stream, uint16 frameCount, uint16 width, uint16 height, bool skipHeader = false);
virtual void readHeader();
- uint32 getX() const;
- uint32 getY() const;
+ int32 getX() const;
+ int32 getY() const;
uint16 getTransparentColourIndex();
Common::Point getCenter();
Common::Rect &getRect();
const Graphics::Surface *getCurrentFrame();
+ void setX(int32 x);
+ void setY(int32 y);
+
private:
const Graphics::Surface *decodeNextFrame();
void readPrefixChunk();
diff --git a/engines/pink/cursor_mgr.cpp b/engines/pink/cursor_mgr.cpp
index d845349131..00259b7241 100644
--- a/engines/pink/cursor_mgr.cpp
+++ b/engines/pink/cursor_mgr.cpp
@@ -30,7 +30,7 @@
namespace Pink {
CursorMgr::CursorMgr(PinkEngine *game, GamePage *page)
- : _actor(nullptr), _action(nullptr), _page(page), _game(game),
+ : _actor(nullptr), _page(page), _game(game),
_isPlayingAnimation(0), _firstFrameIndex(0)
{}
@@ -38,37 +38,42 @@ CursorMgr::~CursorMgr() {}
void CursorMgr::setCursor(uint index, Common::Point point, const Common::String &itemName) {
if (index == kClickableFirstFrameCursor) {
- if (!_isPlayingAnimation) {
- _isPlayingAnimation = 1;
- _time = _game->getTotalPlayTime();
- _firstFrameIndex = index;
- _isSecondFrame = 0;
+ startAnimation(index);
+ return hideItem();
+ }
+ else if (index != kHoldingItemCursor){
+
+ if (index != kPDASecondCursor) {
_game->setCursor(index);
+ _isPlayingAnimation = 0;
+ return hideItem();
}
- return;
- }
- if (index != kHoldingItemCursor){
- _isPlayingAnimation = 0;
- _game->setCursor(index);
- return;
+
+ hideItem();
+ return startAnimation(index);
}
_game->setCursor(index);
+ _isPlayingAnimation = 0;
+
_actor = _actor ? _actor : _page->findActor(kCursor);
assert(_actor);
Action *action = _actor->findAction(itemName);
- assert(action);
- if (action != _action) {
- _action = action;
+ assert(dynamic_cast<ActionCEL*>(action));
+
+ if (action != _actor->getAction()) {
_actor->setAction(action, 0);
+ CelDecoder *decoder = static_cast<ActionCEL*>(action)->getDecoder();
+ decoder->setX(point.x);
+ decoder->setY(point.y);
+ }
+ else {
+ CelDecoder *decoder = static_cast<ActionCEL*>(action)->getDecoder();
+ decoder->setX(point.x);
+ decoder->setY(point.y);
}
- assert(dynamic_cast<ActionCEL*>(action));
- CelDecoder *decoder = static_cast<ActionCEL*>(_action)->getDecoder();
- // this is buggy
- //decoder->setX(point.x);
- //decoder->setY(point.y);
}
void CursorMgr::update() {
@@ -99,4 +104,18 @@ void CursorMgr::setCursor(Common::String &cursorName, Common::Point point) {
setCursor(index, point, Common::String());
}
+void CursorMgr::hideItem() {
+ if (_actor) _actor->hide();
+}
+
+void CursorMgr::startAnimation(int index) {
+ if (!_isPlayingAnimation) {
+ _isPlayingAnimation = 1;
+ _time = _game->getTotalPlayTime();
+ _firstFrameIndex = index;
+ _isSecondFrame = 0;
+ _game->setCursor(index);
+ }
+}
+
} // End of namespace Pink \ No newline at end of file
diff --git a/engines/pink/cursor_mgr.h b/engines/pink/cursor_mgr.h
index 643e052ef6..1a0094d689 100644
--- a/engines/pink/cursor_mgr.h
+++ b/engines/pink/cursor_mgr.h
@@ -45,10 +45,9 @@ public:
private:
void hideItem();
- void stopAnimation();
+ void startAnimation(int index);
Actor *_actor;
- Action *_action;
GamePage *_page;
PinkEngine *_game;
diff --git a/engines/pink/director.cpp b/engines/pink/director.cpp
index 4003ca5073..d92269e95a 100644
--- a/engines/pink/director.cpp
+++ b/engines/pink/director.cpp
@@ -29,7 +29,7 @@
namespace Pink {
Director::Director(OSystem *system)
- : _system(system), showBounds(0) {}
+ : _system(system), showBounds(1) {}
void Director::draw() {
_system->fillScreen(0);
@@ -48,11 +48,18 @@ void Director::drawSprite(ActionCEL *sprite) {
}
else surface = decoder->getCurrentFrame();
+ int h = surface->h;
+ if (surface->h + decoder->getY() > 480)
+ h = 480 - decoder->getY();
+ int w = surface->w;
+ if (surface->w + decoder->getX() > 640)
+ w = 640 - decoder->getX();
+
if (!showBounds) {
Graphics::Surface *screen = _system->lockScreen();
- for (int y = 0; y < decoder->getHeight(); ++y) {
- for (int x = 0; x < decoder->getWidth(); ++x) {
+ for (int y = 0; y < h; ++y) {
+ for (int x = 0; x < w; ++x) {
uint16 spritePixelColourIndex = *(byte*)surface->getBasePtr(x, y);
if (spritePixelColourIndex != decoder->getTransparentColourIndex()) {
*(byte *) screen->getBasePtr(decoder->getX() + x, decoder->getY() + y) = spritePixelColourIndex;
@@ -63,7 +70,7 @@ void Director::drawSprite(ActionCEL *sprite) {
}
else _system->copyRectToScreen(surface->getPixels(), surface->pitch,
decoder->getX(), decoder->getY(),
- surface->w, surface->h);
+ w, h);
}