DIRECTOR: Moved transitions code to separate file

This commit is contained in:
Eugene Sandulenko 2020-03-24 01:03:51 +01:00
parent e82c6da8f9
commit 0a25627a70
3 changed files with 179 additions and 144 deletions

View File

@ -438,150 +438,6 @@ void Frame::playSoundChannel() {
debug(0, "STUB: playSoundChannel(), Sound1 %d Sound2 %d", _sound1, _sound2);
}
void Frame::playTransition(Score *score) {
uint16 duration = _transDuration * 250; // _transDuration in 1/4 of sec
duration = (duration == 0 ? 250 : duration); // director supports transition duration = 0, but animation play like value = 1, idk.
if (_transChunkSize == 0)
_transChunkSize = 1; // equal to 1 step
uint16 stepDuration = duration / _transChunkSize;
uint16 steps = duration / stepDuration;
switch (_transType) {
case kTransCoverDown:
{
uint16 stepSize = score->_movieRect.height() / steps;
Common::Rect r = score->_movieRect;
for (uint16 i = 1; i < steps; i++) {
r.setHeight(stepSize * i);
g_system->delayMillis(stepDuration);
processQuitEvent();
g_system->copyRectToScreen(score->_surface->getPixels(), score->_surface->pitch, 0, 0, r.width(), r.height()); // transition
g_system->updateScreen();
}
}
break;
case kTransCoverUp:
{
uint16 stepSize = score->_movieRect.height() / steps;
Common::Rect r = score->_movieRect;
for (uint16 i = 1; i < steps; i++) {
r.setHeight(stepSize * i);
g_system->delayMillis(stepDuration);
processQuitEvent();
g_system->copyRectToScreen(score->_surface->getPixels(), score->_surface->pitch, 0, score->_movieRect.height() - stepSize * i, r.width(), r.height()); // transition
g_system->updateScreen();
}
}
break;
case kTransCoverRight: {
uint16 stepSize = score->_movieRect.width() / steps;
Common::Rect r = score->_movieRect;
for (uint16 i = 1; i < steps; i++) {
r.setWidth(stepSize * i);
g_system->delayMillis(stepDuration);
processQuitEvent();
g_system->copyRectToScreen(score->_surface->getPixels(), score->_surface->pitch, 0, 0, r.width(), r.height()); // transition
g_system->updateScreen();
}
}
break;
case kTransCoverLeft: {
uint16 stepSize = score->_movieRect.width() / steps;
Common::Rect r = score->_movieRect;
for (uint16 i = 1; i < steps; i++) {
r.setWidth(stepSize * i);
g_system->delayMillis(stepDuration);
processQuitEvent();
g_system->copyRectToScreen(score->_surface->getPixels(), score->_surface->pitch, score->_movieRect.width() - stepSize * i, 0, r.width(), r.height()); // transition
g_system->updateScreen();
}
}
break;
case kTransCoverUpLeft: {
uint16 stepSize = score->_movieRect.width() / steps;
Common::Rect r = score->_movieRect;
for (uint16 i = 1; i < steps; i++) {
r.setWidth(stepSize * i);
r.setHeight(stepSize * i);
g_system->delayMillis(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
g_system->updateScreen();
}
}
break;
case kTransCoverUpRight: {
uint16 stepSize = score->_movieRect.width() / steps;
Common::Rect r = score->_movieRect;
for (uint16 i = 1; i < steps; i++) {
r.setWidth(stepSize * i);
r.setHeight(stepSize * i);
g_system->delayMillis(stepDuration);
processQuitEvent();
g_system->copyRectToScreen(score->_surface->getPixels(), score->_surface->pitch, 0, score->_movieRect.height() - stepSize * i, r.width(), r.height()); // transition
g_system->updateScreen();
}
}
break;
case kTransCoverDownLeft: {
uint16 stepSize = score->_movieRect.width() / steps;
Common::Rect r = score->_movieRect;
for (uint16 i = 1; i < steps; i++) {
r.setWidth(stepSize * i);
r.setHeight(stepSize * i);
g_system->delayMillis(stepDuration);
processQuitEvent();
g_system->copyRectToScreen(score->_surface->getPixels(), score->_surface->pitch, score->_movieRect.width() - stepSize * i, 0, r.width(), r.height()); // transition
g_system->updateScreen();
}
}
break;
case kTransCoverDownRight: {
uint16 stepSize = score->_movieRect.width() / steps;
Common::Rect r = score->_movieRect;
for (uint16 i = 1; i < steps; i++) {
r.setWidth(stepSize * i);
r.setHeight(stepSize * i);
g_system->delayMillis(stepDuration);
processQuitEvent();
g_system->copyRectToScreen(score->_surface->getPixels(), score->_surface->pitch, 0, 0, r.width(), r.height()); // transition
g_system->updateScreen();
}
}
break;
default:
warning("Frame::playTransition(): Unhandled transition type %d %d %d", _transType, duration, _transChunkSize);
break;
}
}
void Frame::renderSprites(Graphics::ManagedSurface &surface, bool renderTrail) {
for (uint16 i = 0; i <= _numChannels; i++) {
if (!_sprites[i]->_enabled)

View File

@ -16,6 +16,7 @@ MODULE_OBJS = \
sound.o \
sprite.o \
stxt.o \
transitions.o \
util.o \
lingo/lingo-gr.o \
lingo/lingo.o \

View File

@ -0,0 +1,178 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "common/system.h"
#include "graphics/managed_surface.h"
#include "director/director.h"
#include "director/frame.h"
#include "director/score.h"
#include "director/util.h"
namespace Director {
void Frame::playTransition(Score *score) {
uint16 duration = _transDuration * 250; // _transDuration in 1/4 of sec
duration = (duration == 0 ? 250 : duration); // director supports transition duration = 0, but animation play like value = 1, idk.
if (_transChunkSize == 0)
_transChunkSize = 1; // equal to 1 step
uint16 stepDuration = duration / _transChunkSize;
uint16 steps = duration / stepDuration;
switch (_transType) {
case kTransCoverDown:
{
uint16 stepSize = score->_movieRect.height() / steps;
Common::Rect r = score->_movieRect;
for (uint16 i = 1; i < steps; i++) {
r.setHeight(stepSize * i);
g_system->delayMillis(stepDuration);
processQuitEvent();
g_system->copyRectToScreen(score->_surface->getPixels(), score->_surface->pitch, 0, 0, r.width(), r.height()); // transition
g_system->updateScreen();
}
}
break;
case kTransCoverUp:
{
uint16 stepSize = score->_movieRect.height() / steps;
Common::Rect r = score->_movieRect;
for (uint16 i = 1; i < steps; i++) {
r.setHeight(stepSize * i);
g_system->delayMillis(stepDuration);
processQuitEvent();
g_system->copyRectToScreen(score->_surface->getPixels(), score->_surface->pitch, 0, score->_movieRect.height() - stepSize * i, r.width(), r.height()); // transition
g_system->updateScreen();
}
}
break;
case kTransCoverRight: {
uint16 stepSize = score->_movieRect.width() / steps;
Common::Rect r = score->_movieRect;
for (uint16 i = 1; i < steps; i++) {
r.setWidth(stepSize * i);
g_system->delayMillis(stepDuration);
processQuitEvent();
g_system->copyRectToScreen(score->_surface->getPixels(), score->_surface->pitch, 0, 0, r.width(), r.height()); // transition
g_system->updateScreen();
}
}
break;
case kTransCoverLeft: {
uint16 stepSize = score->_movieRect.width() / steps;
Common::Rect r = score->_movieRect;
for (uint16 i = 1; i < steps; i++) {
r.setWidth(stepSize * i);
g_system->delayMillis(stepDuration);
processQuitEvent();
g_system->copyRectToScreen(score->_surface->getPixels(), score->_surface->pitch, score->_movieRect.width() - stepSize * i, 0, r.width(), r.height()); // transition
g_system->updateScreen();
}
}
break;
case kTransCoverUpLeft: {
uint16 stepSize = score->_movieRect.width() / steps;
Common::Rect r = score->_movieRect;
for (uint16 i = 1; i < steps; i++) {
r.setWidth(stepSize * i);
r.setHeight(stepSize * i);
g_system->delayMillis(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
g_system->updateScreen();
}
}
break;
case kTransCoverUpRight: {
uint16 stepSize = score->_movieRect.width() / steps;
Common::Rect r = score->_movieRect;
for (uint16 i = 1; i < steps; i++) {
r.setWidth(stepSize * i);
r.setHeight(stepSize * i);
g_system->delayMillis(stepDuration);
processQuitEvent();
g_system->copyRectToScreen(score->_surface->getPixels(), score->_surface->pitch, 0, score->_movieRect.height() - stepSize * i, r.width(), r.height()); // transition
g_system->updateScreen();
}
}
break;
case kTransCoverDownLeft: {
uint16 stepSize = score->_movieRect.width() / steps;
Common::Rect r = score->_movieRect;
for (uint16 i = 1; i < steps; i++) {
r.setWidth(stepSize * i);
r.setHeight(stepSize * i);
g_system->delayMillis(stepDuration);
processQuitEvent();
g_system->copyRectToScreen(score->_surface->getPixels(), score->_surface->pitch, score->_movieRect.width() - stepSize * i, 0, r.width(), r.height()); // transition
g_system->updateScreen();
}
}
break;
case kTransCoverDownRight: {
uint16 stepSize = score->_movieRect.width() / steps;
Common::Rect r = score->_movieRect;
for (uint16 i = 1; i < steps; i++) {
r.setWidth(stepSize * i);
r.setHeight(stepSize * i);
g_system->delayMillis(stepDuration);
processQuitEvent();
g_system->copyRectToScreen(score->_surface->getPixels(), score->_surface->pitch, 0, 0, r.width(), r.height()); // transition
g_system->updateScreen();
}
}
break;
default:
warning("Frame::playTransition(): Unhandled transition type %d %d %d", _transType, duration, _transChunkSize);
break;
}
}
} // End of namespace Director