[Scummvm-git-logs] scummvm master -> 069e4232caa6a5a0ba6b4b8e1226fb84d9dc2635

sev- sev at scummvm.org
Wed Mar 25 23:45:52 UTC 2020


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
069e4232ca DIRECTOR: Fixed CenterOut transitions


Commit: 069e4232caa6a5a0ba6b4b8e1226fb84d9dc2635
    https://github.com/scummvm/scummvm/commit/069e4232caa6a5a0ba6b4b8e1226fb84d9dc2635
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-03-26T00:45:19+01:00

Commit Message:
DIRECTOR: Fixed CenterOut transitions

Changed paths:
    engines/director/transitions.cpp


diff --git a/engines/director/transitions.cpp b/engines/director/transitions.cpp
index 6fc99c94d6..1f08441892 100644
--- a/engines/director/transitions.cpp
+++ b/engines/director/transitions.cpp
@@ -142,31 +142,59 @@ 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();
 			}
 		}
@@ -174,19 +202,20 @@ void Frame::playTransition(Score *score) {
 
 	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();
 			}
 		}
@@ -194,13 +223,13 @@ void Frame::playTransition(Score *score) {
 
 	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




More information about the Scummvm-git-logs mailing list