Skip to content

Commit

Permalink
DIRECTOR: Handle cover up/down transitions
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Iskrich authored and sev- committed Aug 3, 2016
1 parent e51e28c commit 055fb9e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
39 changes: 36 additions & 3 deletions engines/director/score.cpp
Expand Up @@ -729,7 +729,8 @@ void Frame::prepareFrame(Archive &_movie, Graphics::ManagedSurface &surface, Gra
renderSprites(_movie, surface, movieRect, false);
renderSprites(_movie, trailSurface, movieRect, true);
if (_transType != 0)
playTransition();
//TODO Handle changing area case
playTransition(surface, movieRect);
if (_sound1 != 0 || _sound2 != 0) {
playSoundChannel();
}
Expand All @@ -741,8 +742,40 @@ void Frame::playSoundChannel() {
debug(0, "Sound1 %d", _sound1);
}

void Frame::playTransition() {
warning("STUB: playTransition(%d, %d, %d)", _transType, _transDuration, _transChunkSize);
void Frame::playTransition(Graphics::ManagedSurface &frameSurface, Common::Rect transRect) {
uint16 duration = _transDuration * 250; // _transDuration in 1/4 of sec
duration = (duration == 0 ? 250 : duration); // director support transition duration = 0, but animation play like value = 1, idk.
uint16 stepDuration = duration / _transChunkSize;
uint16 steps = duration / stepDuration;

switch (_transType) {
case kTransCoverDown: {
uint16 stepSize = transRect.height() / steps;
Common::Rect r = transRect;
for (uint16 i = 1; i < steps; i++) {
r.setHeight(stepSize * i);
g_system->delayMillis(stepDuration);
g_system->copyRectToScreen(frameSurface.getPixels(), frameSurface.pitch, 0, 0, r.width(), r.height());
g_system->updateScreen();
}
}
break;
case kTransCoverUp: {
uint16 stepSize = transRect.height() / steps;
Common::Rect r = transRect;
for (uint16 i = 1; i < steps; i++) {
r.setHeight(stepSize*i);
g_system->delayMillis(stepDuration);
g_system->copyRectToScreen(frameSurface.getPixels(), frameSurface.pitch, 0, transRect.height() - stepSize * i, r.width(), r.height());
g_system->updateScreen();
}
}
break;
default:
warning("Unhandled transition type %d", _transType);
break;

}
}

void Frame::renderSprites(Archive &_movie, Graphics::ManagedSurface &surface, Common::Rect movieRect, bool renderTrail) {
Expand Down
2 changes: 1 addition & 1 deletion engines/director/score.h
Expand Up @@ -237,7 +237,7 @@ class Frame {
void prepareFrame(Archive &_movie, Graphics::ManagedSurface &surface, Graphics::ManagedSurface &trailSurface, Common::Rect movieRect);
uint16 getSpriteIDFromPos(Common::Point pos);
private:
void playTransition();
void playTransition(Graphics::ManagedSurface &frameSurface, Common::Rect transRect);
void playSoundChannel();
void renderSprites(Archive &_movie, Graphics::ManagedSurface &surface, Common::Rect movieRect, bool renderTrail);
void readSprite(Common::SeekableReadStream &stream, uint16 offset, uint16 size);
Expand Down

0 comments on commit 055fb9e

Please sign in to comment.