Skip to content
Permalink
Browse files

DIRECTOR: Fixed CenterOut transitions

  • Loading branch information
sev- committed Mar 25, 2020
1 parent 768f8b8 commit 069e4232caa6a5a0ba6b4b8e1226fb84d9dc2635
Showing with 93 additions and 43 deletions.
  1. +93 −43 engines/director/transitions.cpp
@@ -142,65 +142,94 @@ struct {
TRANS(kTransDissolveBits, kTransAlgoDissolve, kTransDirBits)
};

struct TransParams {
TransitionType type;
uint duration;
uint chunkSize;

int steps;
int stepDuration;

int xStepSize;
int yStepSize;

int xpos, ypos;

TransParams() {
type = kTransNone;
duration = 250;
chunkSize = 1;
steps = 0;
stepDuration = 0;

xStepSize = yStepSize = 0;
xpos = ypos = 0;
}
};

static void initTransParams(TransParams &t, Score *score);

void Frame::playTransition(Score *score) {
uint16 duration = MAX<uint16>(250, _transDuration); // When duration is < 1/4s, make it 1/4
TransParams t;

if (_transChunkSize == 0)
_transChunkSize = 1; // equal to 1 step
t.type = _transType;
t.duration = MAX<uint16>(250, _transDuration); // When duration is < 1/4s, make it 1/4
t.chunkSize = MAX<uint>(1, _transChunkSize);

uint16 stepDuration = duration / _transChunkSize;
uint16 steps = duration / stepDuration;
initTransParams(t, score);

switch (_transType) {
case kTransCenterOutHorizontal: // 5
{
uint16 stepSize = score->_movieRect.width() / steps / 2;
Common::Rect r = score->_movieRect;

for (uint16 i = 1; i < steps; i++) {
r.setWidth(stepSize * i * 2);
r.moveTo(score->_movieRect.width() / 2 - stepSize * i, 0);
for (uint16 i = 0; i < t.steps; i++) {
t.xpos += t.xStepSize;

r.setWidth(t.xpos * 2);
r.moveTo(score->_movieRect.width() / 2 - t.xpos, 0);

g_system->delayMillis(stepDuration);
g_system->delayMillis(t.stepDuration);
processQuitEvent();

score->_backSurface->copyRectToSurface(*score->_surface, 0, 0, r);

g_system->copyRectToScreen(score->_backSurface->getPixels(), score->_backSurface->pitch, score->_movieRect.width() / 2 - stepSize * i, 0, r.width(), r.height()); // transition
g_system->copyRectToScreen(score->_backSurface->getPixels(), score->_backSurface->pitch, score->_movieRect.width() / 2 - t.xpos, 0, r.width(), r.height()); // transition
g_system->updateScreen();
}
}
break;

case kTransCenterOutVertical: // 7
{
uint16 stepSize = score->_movieRect.height() / steps / 2;
Common::Rect r = score->_movieRect;

for (uint16 i = 1; i < steps; i++) {
r.setHeight(stepSize * i * 2);
r.moveTo(0, score->_movieRect.height() / 2 - stepSize * i);
for (uint16 i = 0; i < t.steps; i++) {
t.ypos += t.yStepSize;

g_system->delayMillis(stepDuration * 20);
r.setHeight(t.ypos * 2);
r.moveTo(0, score->_movieRect.height() / 2 - t.ypos);

g_system->delayMillis(t.stepDuration);
processQuitEvent();

score->_backSurface->copyRectToSurface(*score->_surface, 0, 0, r);

g_system->copyRectToScreen(score->_backSurface->getPixels(), score->_backSurface->pitch, 0, score->_movieRect.height() / 2 - stepSize * i, r.width(), r.height()); // transition
g_system->copyRectToScreen(score->_backSurface->getPixels(), score->_backSurface->pitch, 0, score->_movieRect.height() / 2 - t.ypos, r.width(), r.height()); // transition
g_system->updateScreen();
}
}
break;

case kTransCoverDown: // 29
{
uint16 stepSize = score->_movieRect.height() / steps;
uint16 stepSize = score->_movieRect.height() / t.steps;
Common::Rect r = score->_movieRect;

for (uint16 i = 1; i < steps; i++) {
for (uint16 i = 1; i < t.steps; i++) {
r.setHeight(stepSize * i);

g_system->delayMillis(stepDuration);
g_system->delayMillis(t.stepDuration);
processQuitEvent();

g_system->copyRectToScreen(score->_surface->getPixels(), score->_surface->pitch, 0, 0, r.width(), r.height()); // transition
@@ -211,14 +240,14 @@ void Frame::playTransition(Score *score) {

case kTransCoverDownLeft: // 30
{
uint16 stepSize = score->_movieRect.width() / steps;
uint16 stepSize = score->_movieRect.width() / t.steps;
Common::Rect r = score->_movieRect;

for (uint16 i = 1; i < steps; i++) {
for (uint16 i = 1; i < t.steps; i++) {
r.setWidth(stepSize * i);
r.setHeight(stepSize * i);

g_system->delayMillis(stepDuration);
g_system->delayMillis(t.stepDuration);
processQuitEvent();

g_system->copyRectToScreen(score->_surface->getPixels(), score->_surface->pitch, score->_movieRect.width() - stepSize * i, 0, r.width(), r.height()); // transition
@@ -229,14 +258,14 @@ void Frame::playTransition(Score *score) {

case kTransCoverDownRight: // 31
{
uint16 stepSize = score->_movieRect.width() / steps;
uint16 stepSize = score->_movieRect.width() / t.steps;
Common::Rect r = score->_movieRect;

for (uint16 i = 1; i < steps; i++) {
for (uint16 i = 1; i < t.steps; i++) {
r.setWidth(stepSize * i);
r.setHeight(stepSize * i);

g_system->delayMillis(stepDuration);
g_system->delayMillis(t.stepDuration);
processQuitEvent();

g_system->copyRectToScreen(score->_surface->getPixels(), score->_surface->pitch, 0, 0, r.width(), r.height()); // transition
@@ -247,13 +276,13 @@ void Frame::playTransition(Score *score) {

case kTransCoverLeft: // 32
{
uint16 stepSize = score->_movieRect.width() / steps;
uint16 stepSize = score->_movieRect.width() / t.steps;
Common::Rect r = score->_movieRect;

for (uint16 i = 1; i < steps; i++) {
for (uint16 i = 1; i < t.steps; i++) {
r.setWidth(stepSize * i);

g_system->delayMillis(stepDuration);
g_system->delayMillis(t.stepDuration);
processQuitEvent();

g_system->copyRectToScreen(score->_surface->getPixels(), score->_surface->pitch, score->_movieRect.width() - stepSize * i, 0, r.width(), r.height()); // transition
@@ -264,13 +293,13 @@ void Frame::playTransition(Score *score) {

case kTransCoverRight: // 33
{
uint16 stepSize = score->_movieRect.width() / steps;
uint16 stepSize = score->_movieRect.width() / t.steps;
Common::Rect r = score->_movieRect;

for (uint16 i = 1; i < steps; i++) {
for (uint16 i = 1; i < t.steps; i++) {
r.setWidth(stepSize * i);

g_system->delayMillis(stepDuration);
g_system->delayMillis(t.stepDuration);
processQuitEvent();

g_system->copyRectToScreen(score->_surface->getPixels(), score->_surface->pitch, 0, 0, r.width(), r.height()); // transition
@@ -281,13 +310,13 @@ void Frame::playTransition(Score *score) {

case kTransCoverUp: // 34
{
uint16 stepSize = score->_movieRect.height() / steps;
uint16 stepSize = score->_movieRect.height() / t.steps;
Common::Rect r = score->_movieRect;

for (uint16 i = 1; i < steps; i++) {
for (uint16 i = 1; i < t.steps; i++) {
r.setHeight(stepSize * i);

g_system->delayMillis(stepDuration);
g_system->delayMillis(t.stepDuration);
processQuitEvent();

g_system->copyRectToScreen(score->_surface->getPixels(), score->_surface->pitch, 0, score->_movieRect.height() - stepSize * i, r.width(), r.height()); // transition
@@ -298,14 +327,14 @@ void Frame::playTransition(Score *score) {

case kTransCoverUpLeft: // 35
{
uint16 stepSize = score->_movieRect.width() / steps;
uint16 stepSize = score->_movieRect.width() / t.steps;
Common::Rect r = score->_movieRect;

for (uint16 i = 1; i < steps; i++) {
for (uint16 i = 1; i < t.steps; i++) {
r.setWidth(stepSize * i);
r.setHeight(stepSize * i);

g_system->delayMillis(stepDuration);
g_system->delayMillis(t.stepDuration);
processQuitEvent();

g_system->copyRectToScreen(score->_surface->getPixels(), score->_surface->pitch, score->_movieRect.width() - stepSize * i, score->_movieRect.height() - stepSize * i, r.width(), r.height()); // transition
@@ -316,14 +345,14 @@ void Frame::playTransition(Score *score) {

case kTransCoverUpRight: // 36
{
uint16 stepSize = score->_movieRect.width() / steps;
uint16 stepSize = score->_movieRect.width() / t.steps;
Common::Rect r = score->_movieRect;

for (uint16 i = 1; i < steps; i++) {
for (uint16 i = 1; i < t.steps; i++) {
r.setWidth(stepSize * i);
r.setHeight(stepSize * i);

g_system->delayMillis(stepDuration);
g_system->delayMillis(t.stepDuration);
processQuitEvent();

g_system->copyRectToScreen(score->_surface->getPixels(), score->_surface->pitch, 0, score->_movieRect.height() - stepSize * i, r.width(), r.height()); // transition
@@ -334,15 +363,36 @@ void Frame::playTransition(Score *score) {

case kTransDissolvePixels: // 51
{
warning("Frame::playTransition(): Unhandled transition type %s %d %d", transProps[_transType].name, duration, _transChunkSize);
warning("Frame::playTransition(): Unhandled transition type %s %d %d", transProps[_transType].name, t.duration, _transChunkSize);
}
break;

default:
warning("Frame::playTransition(): Unhandled transition type %s %d %d", transProps[_transType].name, duration, _transChunkSize);
warning("Frame::playTransition(): Unhandled transition type %s %d %d", transProps[_transType].name, t.duration, _transChunkSize);
break;

}
}

static void initTransParams(TransParams &t, Score *score) {
if (transProps[t.type].dir == kTransDirHorizontal) {
int w = score->_movieRect.width() / 2;

t.steps = w / t.chunkSize;
t.xStepSize = w / t.steps;
t.xpos = w % t.steps;
} else if (transProps[t.type].dir == kTransDirVertical) {
int h = score->_movieRect.height() / 2;

t.steps = h / t.chunkSize;
t.yStepSize = h / t.steps;
t.ypos = h % t.steps;
} else {
t.steps = score->_movieRect.width() / t.chunkSize;
}

t.stepDuration = t.duration / t.steps;
}


} // End of namespace Director

0 comments on commit 069e423

Please sign in to comment.
You can’t perform that action at this time.