[Scummvm-git-logs] scummvm master -> d92a3f33b088f86c64462825cc70827b253ef50e

npjg nathanael.gentrydb8 at gmail.com
Wed Jul 29 04:51:59 UTC 2020


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

Summary:
70acf3add0 DIRECTOR: Selectively set dirty flag in setTheSprite
04061d531c DIRECTOR: Mark cast dimension setters read-only
4768478f6b DIRECTOR: Enforce proper types for cast colour setters
d92a3f33b0 DIRECTOR: Implement basic alpha transparency


Commit: 70acf3add0c68516a5e099b76052bbae23d677e5
    https://github.com/scummvm/scummvm/commit/70acf3add0c68516a5e099b76052bbae23d677e5
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2020-07-29T00:47:26-04:00

Commit Message:
DIRECTOR: Selectively set dirty flag in setTheSprite

Changed paths:
    engines/director/lingo/lingo-the.cpp


diff --git a/engines/director/lingo/lingo-the.cpp b/engines/director/lingo/lingo-the.cpp
index 682c536012..10cd15a8e5 100644
--- a/engines/director/lingo/lingo-the.cpp
+++ b/engines/director/lingo/lingo-the.cpp
@@ -1210,37 +1210,39 @@ void Lingo::setTheSprite(Datum &id1, int field, Datum &d) {
 	if (!sprite->_enabled)
 		sprite->_enabled = true;
 
-	channel->_dirty = true;
 	switch (field) {
 	case kTheBackColor:
 		if (d.asInt() != sprite->_backColor) {
 			sprite->_backColor = d.asInt();
-		} else {
-			channel->_dirty = false;
+			channel->_dirty = true;
 		}
 		break;
 	case kTheBlend:
-		sprite->_blend = d.asInt();
+		if (d.asInt() != sprite->_blend) {
+			sprite->_blend = d.asInt();
+			channel->_dirty = true;
+		}
 		break;
 	case kTheCastNum:
 		if (d.asInt() != sprite->_castId) {
 			g_director->getCurrentStage()->addDirtyRect(channel->getBbox());
-
 			channel->setCast(d.asInt());
-		} else {
-			channel->_dirty = false;
+			channel->_dirty = true;
 		}
 		break;
 	case kTheConstraint:
-		if (d.type == CASTREF) {
-			// Reference: CastMember ID
-			// Find the first channel that uses this cast.
-			for (uint i = 0; i < score->_channels.size(); i++)
-				if (score->_channels[i]->_sprite->_castId == d.u.i)
-					d.u.i = i;
-		}
+		if (d.asInt() != (int)channel->_constraint) {
+			if (d.type == CASTREF) {
+				// Reference: CastMember ID
+				// Find the first channel that uses this cast.
+				for (uint i = 0; i < score->_channels.size(); i++)
+					if (score->_channels[i]->_sprite->_castId == d.u.i)
+						d.u.i = i;
+			}
 
-		channel->_constraint = d.u.i;
+			channel->_constraint = d.u.i;
+			channel->_dirty = true;
+		}
 		break;
 	case kTheCursor:
 		if (d.type == INT) {
@@ -1256,26 +1258,30 @@ void Lingo::setTheSprite(Datum &id1, int field, Datum &d) {
 	case kTheForeColor:
 		if (d.asInt() != sprite->_foreColor) {
 			sprite->_foreColor = d.asInt();
-		} else {
-			channel->_dirty = false;
+			channel->_dirty = true;
 		}
 		break;
 	case kTheHeight:
 		if (d.asInt() != channel->_height) {
 			g_director->getCurrentStage()->addDirtyRect(channel->getBbox());
 			channel->setHeight(d.asInt());
-		} else {
-			channel->_dirty = false;
+			channel->_dirty = true;
 		}
 		break;
 	case kTheImmediate:
 		sprite->_immediate = d.asInt();
 		break;
 	case kTheInk:
-		sprite->_ink = static_cast<InkType>(d.asInt());
+		if (d.asInt() != sprite->_ink) {
+			sprite->_ink = static_cast<InkType>(d.asInt());
+			channel->_dirty = true;
+		}
 		break;
 	case kTheLineSize:
-		sprite->_thickness = d.asInt();
+		if (d.asInt() != sprite->_thickness) {
+			sprite->_thickness = d.asInt();
+			channel->_dirty = true;
+		}
 		break;
 	case kTheLoc:
 		warning("STUB: Lingo::setTheSprite(): Unprocessed setting field \"%s\" of sprite", field2str(field));
@@ -1284,16 +1290,14 @@ void Lingo::setTheSprite(Datum &id1, int field, Datum &d) {
 		if (d.asInt() != channel->_currentPoint.x) {
 			g_director->getCurrentMovie()->getStage()->addDirtyRect(channel->getBbox());
 			channel->_currentPoint.x = d.asInt();
-		} else {
-			channel->_dirty = false;
+			channel->_dirty = true;
 		}
 		break;
 	case kTheLocV:
 		if (d.asInt() != channel->_currentPoint.y) {
 			g_director->getCurrentMovie()->getStage()->addDirtyRect(channel->getBbox());
 			channel->_currentPoint.y = d.asInt();
-		} else {
-			channel->_dirty = false;
+			channel->_dirty = true;
 		}
 		break;
 	case kTheMoveableSprite:
@@ -1306,7 +1310,10 @@ void Lingo::setTheSprite(Datum &id1, int field, Datum &d) {
 		sprite->_movieTime = d.asInt();
 		break;
 	case kThePattern:
-		sprite->setPattern(d.asInt());
+		if (d.asInt() != sprite->getPattern()){
+			sprite->setPattern(d.asInt());
+			channel->_dirty = true;
+		}
 		break;
 	case kThePuppet:
 		sprite->_puppet = d.asInt();
@@ -1322,34 +1329,43 @@ void Lingo::setTheSprite(Datum &id1, int field, Datum &d) {
 		sprite->_stopTime = d.asInt();
 		break;
 	case kTheStretch:
-		sprite->_stretch = d.asInt();
+		if (d.asInt() != sprite->_stretch) {
+			sprite->_stretch = d.asInt();
+			channel->_dirty = true;
 
-		if (!d.asInt()) {
-			g_director->getCurrentStage()->addDirtyRect(channel->getBbox());
+			if (sprite->_stretch) {
+				g_director->getCurrentStage()->addDirtyRect(channel->getBbox());
 
-			channel->_width = sprite->_width;
-			channel->_height = sprite->_height;
+				channel->_width = sprite->_width;
+				channel->_height = sprite->_height;
+			}
 		}
 		break;
 	case kTheTrails:
 		sprite->_trails = d.asInt();
 		break;
 	case kTheType:
-		sprite->_spriteType = static_cast<SpriteType>(d.asInt());
+		if (d.asInt() != sprite->_spriteType) {
+			sprite->_spriteType = static_cast<SpriteType>(d.asInt());
+			channel->_dirty = true;
+		}
 		break;
 	case kTheVisibility:
 	case kTheVisible:
-		channel->_visible = (d.asInt() == 0 ? false : true);
+		if (d.asInt() != channel->_visible) {
+			channel->_visible = d.asInt();
+			channel->_dirty = true;
+		}
 		break;
 	case kTheVolume:
+		// TODO: Should changing digital video flags mark as dirty?
 		sprite->_volume = d.asInt();
 		break;
 	case kTheWidth:
 		if (d.asInt() != channel->_width) {
 			g_director->getCurrentStage()->addDirtyRect(channel->getBbox());
 			channel->setWidth(d.asInt());
-		} else {
-			channel->_dirty = false;
+			channel->_dirty = true;
 		}
 		break;
 	default:


Commit: 04061d531c8e3f0ef8f529e7fa42a7f3b7a6683f
    https://github.com/scummvm/scummvm/commit/04061d531c8e3f0ef8f529e7fa42a7f3b7a6683f
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2020-07-29T00:47:26-04:00

Commit Message:
DIRECTOR: Mark cast dimension setters read-only

Changed paths:
    engines/director/lingo/lingo-the.cpp


diff --git a/engines/director/lingo/lingo-the.cpp b/engines/director/lingo/lingo-the.cpp
index 10cd15a8e5..9e05fd7343 100644
--- a/engines/director/lingo/lingo-the.cpp
+++ b/engines/director/lingo/lingo-the.cpp
@@ -1650,8 +1650,7 @@ void Lingo::setTheCast(Datum &id1, int field, Datum &d) {
 		}
 		break;
 	case kTheHeight:
-		cast->getCastMemberInitialRect(id).setHeight(d.asInt());
-		cast->setCastMemberModified(id);
+		warning("Lingo::setTheCast(): Attempt to set read-only field \"%s\" of cast %d", field2str(field), id);
 		break;
 	case kTheHilite:
 		// TODO: Understand how texts can be selected programmatically as well.
@@ -1743,8 +1742,7 @@ void Lingo::setTheCast(Datum &id1, int field, Datum &d) {
 		}
 		break;
 	case kTheWidth:
-		cast->getCastMemberInitialRect(id).setWidth(d.asInt());
-		cast->setCastMemberModified(id);
+		warning("Lingo::setTheCast(): Attempt to set read-only field \"%s\" of cast %d", field2str(field), id);
 		break;
 	default:
 		warning("Lingo::setTheCast(): Unprocessed setting field \"%s\" of cast %d", field2str(field), id);


Commit: 4768478f6b14f1ba7e03dd9b70816c7da5866d44
    https://github.com/scummvm/scummvm/commit/4768478f6b14f1ba7e03dd9b70816c7da5866d44
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2020-07-29T00:47:26-04:00

Commit Message:
DIRECTOR: Enforce proper types for cast colour setters

Changed paths:
    engines/director/lingo/lingo-the.cpp


diff --git a/engines/director/lingo/lingo-the.cpp b/engines/director/lingo/lingo-the.cpp
index 9e05fd7343..e42189e004 100644
--- a/engines/director/lingo/lingo-the.cpp
+++ b/engines/director/lingo/lingo-the.cpp
@@ -1587,11 +1587,11 @@ void Lingo::setTheCast(Datum &id1, int field, Datum &d) {
 
 	switch (field) {
 	case kTheBackColor:
-		{
+		if (castType == kCastText) {
 			int color = _vm->transformColor(d.asInt());
 			member->setColors(nullptr, &color);
-			break;
 		}
+		break;
 	case kTheCastType:
 		warning("Lingo::setTheCast(): Attempt to set read-only field %s of cast %d", entity2str(field), id);
 		break;
@@ -1637,11 +1637,11 @@ void Lingo::setTheCast(Datum &id1, int field, Datum &d) {
 		castInfo->fileName = d.asString();
 		break;
 	case kTheForeColor:
-		{
+		if (castType == kCastText) {
 			int color = _vm->transformColor(d.asInt());
 			member->setColors(&color, nullptr);
-			break;
 		}
+		break;
 	case kTheFrameRate:
 		if (castType == kCastDigitalVideo) {
 			((DigitalVideoCastMember *)member)->_frameRate = d.asInt();


Commit: d92a3f33b088f86c64462825cc70827b253ef50e
    https://github.com/scummvm/scummvm/commit/d92a3f33b088f86c64462825cc70827b253ef50e
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2020-07-29T00:47:26-04:00

Commit Message:
DIRECTOR: Implement basic alpha transparency

This finishes the implementation for blend of sprite, as well.

Changed paths:
    engines/director/channel.cpp
    engines/director/director.h
    engines/director/graphics.cpp
    engines/director/lingo/lingo-the.cpp


diff --git a/engines/director/channel.cpp b/engines/director/channel.cpp
index dc9ca8edb8..7b5dfec58c 100644
--- a/engines/director/channel.cpp
+++ b/engines/director/channel.cpp
@@ -58,7 +58,7 @@ Channel::~Channel() {
 }
 
 DirectorPlotData Channel::getPlotData() {
-	DirectorPlotData pd(g_director->_wm, _sprite->_spriteType, _sprite->_ink, getBackColor(), getForeColor());
+	DirectorPlotData pd(g_director->_wm, _sprite->_spriteType, _sprite->_ink, _sprite->_blend, getBackColor(), getForeColor());
 	pd.colorWhite = pd._wm->_colorWhite;
 	pd.colorBlack = pd._wm->_colorBlack;
 	pd.dst = nullptr;
@@ -91,7 +91,8 @@ const Graphics::Surface *Channel::getMask(bool forceMatte) {
 		_sprite->_ink == kInkTypeNotCopy ||
 		_sprite->_ink == kInkTypeNotTrans ||
 		_sprite->_ink == kInkTypeNotReverse ||
-		_sprite->_ink == kInkTypeNotGhost;
+		_sprite->_ink == kInkTypeNotGhost ||
+		_sprite->_blend > 0;
 
 	if (needsMatte || forceMatte) {
 		// Mattes are only supported in bitmaps for now. Shapes don't need mattes,
diff --git a/engines/director/director.h b/engines/director/director.h
index c4574290da..5ad693af3d 100644
--- a/engines/director/director.h
+++ b/engines/director/director.h
@@ -137,6 +137,7 @@ struct DirectorPlotData {
 	InkType ink;
 	int colorWhite;
 	int colorBlack;
+	int alpha;
 
 	int backColor;
 	int foreColor;
@@ -144,7 +145,7 @@ struct DirectorPlotData {
 
 	void setApplyColor(); // graphics.cpp
 
-	DirectorPlotData(Graphics::MacWindowManager *w, SpriteType s,InkType i, uint b, uint f) : _wm(w), sprite(s), ink(i), backColor(b), foreColor(f) {
+	DirectorPlotData(Graphics::MacWindowManager *w, SpriteType s, InkType i, int a, uint b, uint f) : _wm(w), sprite(s), ink(i), alpha(a), backColor(b), foreColor(f) {
 		srf = nullptr;
 		ms = nullptr;
 		dst = nullptr;
diff --git a/engines/director/graphics.cpp b/engines/director/graphics.cpp
index 25a85fb27b..173bcd0b5c 100644
--- a/engines/director/graphics.cpp
+++ b/engines/director/graphics.cpp
@@ -845,6 +845,21 @@ void inkDrawPixel(int x, int y, int src, void *data) {
 		src = *dst;
 
 		*dst = tmpDst;
+	} else if (p->alpha) {
+		// Sprite blend does not respect colourization; defaults to matte ink
+		byte rSrc, gSrc, bSrc;
+		byte rDst, gDst, bDst;
+
+		g_director->_wm->decomposeColor(src, rSrc, gSrc, bSrc);
+		g_director->_wm->decomposeColor(*dst, rDst, gDst, bDst);
+
+		double alpha = (double)p->alpha / 100.0;
+		rDst = static_cast<byte>((rSrc * alpha) + (rDst * (1.0 - alpha)));
+		gDst = static_cast<byte>((gSrc * alpha) + (gDst * (1.0 - alpha)));
+		bDst = static_cast<byte>((bSrc * alpha) + (bDst * (1.0 - alpha)));
+
+		*dst = p->_wm->findBestColor(rDst, gDst, bDst);
+		return;
 	}
 
  	switch (p->ink) {
diff --git a/engines/director/lingo/lingo-the.cpp b/engines/director/lingo/lingo-the.cpp
index e42189e004..eadb6d1501 100644
--- a/engines/director/lingo/lingo-the.cpp
+++ b/engines/director/lingo/lingo-the.cpp
@@ -1219,7 +1219,7 @@ void Lingo::setTheSprite(Datum &id1, int field, Datum &d) {
 		break;
 	case kTheBlend:
 		if (d.asInt() != sprite->_blend) {
-			sprite->_blend = d.asInt();
+			sprite->_blend = (d.asInt() == 100 ? 0 : d.asInt());
 			channel->_dirty = true;
 		}
 		break;




More information about the Scummvm-git-logs mailing list