[Scummvm-git-logs] scummvm master -> 39c4a0f524fb181cfd4cba5eb724ca8caeaae097

npjg nathanael.gentrydb8 at gmail.com
Tue Jul 7 03:06:10 UTC 2020


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

Summary:
e6d5f1d21c DIRECTOR: Restore accidentally removed null check
39c4a0f524 GRAPHICS: MACGUI: Remove colour settings from base widget


Commit: e6d5f1d21c77a299417b0c99a674026cb0ba9693
    https://github.com/scummvm/scummvm/commit/e6d5f1d21c77a299417b0c99a674026cb0ba9693
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2020-07-06T23:06:04-04:00

Commit Message:
DIRECTOR: Restore accidentally removed null check

Changed paths:
    engines/director/score.cpp


diff --git a/engines/director/score.cpp b/engines/director/score.cpp
index 46cbcf0bc6..78ab081811 100644
--- a/engines/director/score.cpp
+++ b/engines/director/score.cpp
@@ -197,8 +197,12 @@ MacShape *Channel::getShape() {
 	shape->lineSize = _sprite->_thickness & 0x3;
 	shape->pattern = _sprite->getPattern();
 
-	// We have already ahove checked for the proper cast type
 	if (g_director->getVersion() >= 3 && shape->spriteType == kCastMemberSprite) {
+		if (!_sprite->_cast) {
+			warning("Channel::getShape(): kCastMemberSprite has no cast defined");
+			return nullptr;
+		}
+
 		ShapeCastMember *sc = (ShapeCastMember *)_sprite->_cast;
 		switch (sc->_shapeType) {
 		case kShapeRectangle:


Commit: 39c4a0f524fb181cfd4cba5eb724ca8caeaae097
    https://github.com/scummvm/scummvm/commit/39c4a0f524fb181cfd4cba5eb724ca8caeaae097
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2020-07-06T23:06:04-04:00

Commit Message:
GRAPHICS: MACGUI: Remove colour settings from base widget

The Director engine, for which I introduced this setting, has also been updated.
To account for different ink types, the background colour will be applied in the
blitting step, and each text chunk keeps its own palette information.

Changed paths:
    engines/director/castmember.cpp
    engines/director/castmember.h
    engines/director/lingo/lingo-the.cpp
    graphics/macgui/macbutton.cpp
    graphics/macgui/macbutton.h
    graphics/macgui/mactext.h
    graphics/macgui/macwidget.cpp
    graphics/macgui/macwidget.h


diff --git a/engines/director/castmember.cpp b/engines/director/castmember.cpp
index ee9b660321..997c11dac0 100644
--- a/engines/director/castmember.cpp
+++ b/engines/director/castmember.cpp
@@ -420,9 +420,6 @@ void TextCastMember::setColors(int *fgcolor, int *bgcolor) {
 
 	if (bgcolor)
 		_bgcolor = *bgcolor;
-
-	_widget->setColors(_fgcolor, _bgcolor);
-	((Graphics::MacText *)_widget)->_fullRefresh = true;
 }
 
 void TextCastMember::getColors(int *fgcolor, int *bgcolor) {
@@ -465,13 +462,13 @@ void TextCastMember::createWidget() {
 
 	switch (_type) {
 	case kCastText:
-		_widget = new Graphics::MacText(g_director->getStage(), 0, 0, _initialRect.width(), _initialRect.height(), g_director->_wm, _ftext, macFont, getForeColor(), getBackColor(), _initialRect.width(), getAlignment(), 0, _borderSize, _gutterSize, _boxShadow, _textShadow);
+		_widget = new Graphics::MacText(g_director->getStage(), 0, 0, _initialRect.width(), _initialRect.height(), g_director->_wm, _ftext, macFont, 0, 0xff, _initialRect.width(), getAlignment(), 0, _borderSize, _gutterSize, _boxShadow, _textShadow);
 
 		((Graphics::MacText *)_widget)->draw();
 		break;
 
 	case kCastButton:
-		_widget = new Graphics::MacButton(Graphics::MacButtonType(_buttonType), getAlignment(), g_director->getStage(), 0, 0, _initialRect.width(), _initialRect.height(), g_director->_wm, _ftext, macFont, getForeColor(), 0xff);
+		_widget = new Graphics::MacButton(Graphics::MacButtonType(_buttonType), getAlignment(), g_director->getStage(), 0, 0, _initialRect.width(), _initialRect.height(), g_director->_wm, _ftext, macFont);
 		((Graphics::MacButton *)_widget)->draw();
 		_widget->_focusable = true;
 
diff --git a/engines/director/castmember.h b/engines/director/castmember.h
index b68f347aa0..88f190e2dd 100644
--- a/engines/director/castmember.h
+++ b/engines/director/castmember.h
@@ -64,9 +64,6 @@ public:
 	virtual bool isModified() { return _modified; }
 	virtual void createWidget() {}
 
-	virtual void setColors(int *fgcolor, int *bgcolor) { return; }
-	virtual void getColors(int *fgcolor, int *bgcolor) { return; }
-
 	CastType _type;
 	Common::Rect _initialRect;
 	Common::Rect _boundingRect;
@@ -91,7 +88,6 @@ public:
 
 	void createMatte();
 	Graphics::Surface *getMatte();
-	// virtual void setColors(int *fgcolor, int *bgcolor) override;
 
 	Image::ImageDecoder *_img;
 	Graphics::FloodFill *_matte;
@@ -151,8 +147,8 @@ public:
 class TextCastMember : public CastMember {
 public:
 	TextCastMember(Cast *cast, uint16 castId, Common::ReadStreamEndian &stream, uint16 version, bool asButton = false);
-	virtual void setColors(int *fgcolor, int *bgcolor) override;
-	virtual void getColors(int *fgcolor, int *bgcolor) override;
+	void setColors(int *fgcolor, int *bgcolor);
+	void getColors(int *fgcolor, int *bgcolor);
 
 	void setText(const char *text);
 	virtual void createWidget() override;
@@ -162,9 +158,6 @@ public:
 	virtual bool setEditable(bool editable) override;
 	Graphics::TextAlign getAlignment();
 
-	uint getBackColor() { return _bgcolor; }
-	uint getForeColor() { return _fgcolor; }
-
 	SizeType _borderSize;
 	SizeType _gutterSize;
 	SizeType _boxShadow;
diff --git a/engines/director/lingo/lingo-the.cpp b/engines/director/lingo/lingo-the.cpp
index ba8442a208..2465767b2a 100644
--- a/engines/director/lingo/lingo-the.cpp
+++ b/engines/director/lingo/lingo-the.cpp
@@ -981,7 +981,11 @@ Datum Lingo::getTheCast(Datum &id1, int field) {
 
 	switch (field) {
 	case kTheBackColor:
-		member->getColors(nullptr, &d.u.i);
+		if (member->_type == kCastText) {
+			((TextCastMember *)member)->getColors(nullptr, &d.u.i);
+		} else {
+			warning("Lingo::getTheCast(): Attempted to set access color of non-text cast");
+		}
 		break;
 	case kTheCastType:
 		d.u.i = castType;
@@ -990,7 +994,11 @@ Datum Lingo::getTheCast(Datum &id1, int field) {
 		d = Datum(castInfo->fileName);
 		break;
 	case kTheForeColor:
-		member->getColors(&d.u.i, nullptr);
+		if (member->_type == kCastText) {
+			((TextCastMember *)member)->getColors(&d.u.i, nullptr);
+		} else {
+			warning("Lingo::getTheCast(): Attempted to access color of non-text cast");
+		}
 		break;
 	case kTheHeight:
 		d.u.i = cast->getCastMemberInitialRect(id).height();
@@ -1058,7 +1066,11 @@ void Lingo::setTheCast(Datum &id1, int field, Datum &d) {
 	switch (field) {
 	case kTheBackColor: {
 		int color = _vm->transformColor(d.asInt());
-		member->setColors(nullptr, &color);
+		if (member->_type == kCastText) {
+			((TextCastMember *)member)->setColors(nullptr, &color);
+		} else {
+			warning("Lingo::setTheCast(): Attempted to access color of non-text cast");
+		}
 		break;
 	}
 	case kTheCastType:
@@ -1076,7 +1088,12 @@ void Lingo::setTheCast(Datum &id1, int field, Datum &d) {
 		break;
 	case kTheForeColor: {
 		int color = _vm->transformColor(d.asInt());
-		member->setColors(&color, nullptr);
+
+		if (member->_type == kCastText) {
+			((TextCastMember *)member)->setColors(&color, nullptr);
+		} else {
+			warning("Lingo::setTheCast(): Attempted to access color of non-text cast");
+		}
 		break;
 	}
 	case kTheHeight:
diff --git a/graphics/macgui/macbutton.cpp b/graphics/macgui/macbutton.cpp
index 9b32f096d1..c21a03e78d 100644
--- a/graphics/macgui/macbutton.cpp
+++ b/graphics/macgui/macbutton.cpp
@@ -33,8 +33,8 @@
 
 namespace Graphics {
 
-MacButton::MacButton(MacButtonType buttonType, TextAlign textAlignment, MacWidget *parent, int x, int y, int w, int h, MacWindowManager *wm, const Common::U32String &s, const MacFont *macFont, int fgcolor, int bgcolor) :
-	MacText(parent, x, y, w, h, wm, s, macFont, fgcolor, bgcolor, w, textAlignment) {
+MacButton::MacButton(MacButtonType buttonType, TextAlign textAlignment, MacWidget *parent, int x, int y, int w, int h, MacWindowManager *wm, const Common::U32String &s, const MacFont *macFont) :
+	MacText(parent, x, y, w, h, wm, s, macFont, 0, 0xff, w, textAlignment) {
 
 	_buttonType = buttonType;
 
diff --git a/graphics/macgui/macbutton.h b/graphics/macgui/macbutton.h
index 7f1cccc4c5..1dfa427566 100644
--- a/graphics/macgui/macbutton.h
+++ b/graphics/macgui/macbutton.h
@@ -39,7 +39,7 @@ enum MacButtonType {
 
 class MacButton : public MacText {
 public:
-	MacButton(MacButtonType buttonType, TextAlign textAlignment, MacWidget *parent, int x, int y, int w, int h, MacWindowManager *wm, const Common::U32String &s, const MacFont *macFont, int fgcolor, int bgcolor);
+	MacButton(MacButtonType buttonType, TextAlign textAlignment, MacWidget *parent, int x, int y, int w, int h, MacWindowManager *wm, const Common::U32String &s, const MacFont *macFont);
 
 	virtual void setActive(bool active) override;
 
diff --git a/graphics/macgui/mactext.h b/graphics/macgui/mactext.h
index cf5227d70a..e3d755c865 100644
--- a/graphics/macgui/mactext.h
+++ b/graphics/macgui/mactext.h
@@ -253,6 +253,7 @@ protected:
 	int _maxWidth;
 	int _interLinear;
 	int _textShadow;
+	uint _fgcolor, _bgcolor;
 
 	int _textMaxWidth;
 	int _textMaxHeight;
diff --git a/graphics/macgui/macwidget.cpp b/graphics/macgui/macwidget.cpp
index 75bbeedb8d..1d5239be3b 100644
--- a/graphics/macgui/macwidget.cpp
+++ b/graphics/macgui/macwidget.cpp
@@ -27,7 +27,7 @@
 
 namespace Graphics {
 
-MacWidget::MacWidget(MacWidget *parent, int x, int y, int w, int h, MacWindowManager *wm, bool focusable, uint16 border, uint16 gutter, uint16 shadow, uint fgcolor, uint bgcolor) :
+MacWidget::MacWidget(MacWidget *parent, int x, int y, int w, int h, MacWindowManager *wm, bool focusable, uint16 border, uint16 gutter, uint16 shadow) :
 	_focusable(focusable), _parent(parent), _border(border), _gutter(gutter), _shadow(shadow), _wm(wm) {
 	_contentIsDirty = true;
 	_priority = 0;
@@ -37,9 +37,6 @@ MacWidget::MacWidget(MacWidget *parent, int x, int y, int w, int h, MacWindowMan
 	_dims.top = y;
 	_dims.bottom = y + h + (2 * border) + gutter + shadow;
 
-	_fgcolor = fgcolor;
-	_bgcolor = bgcolor;
-
 	if (parent)
 		parent->_children.push_back(this);
 
@@ -47,7 +44,7 @@ MacWidget::MacWidget(MacWidget *parent, int x, int y, int w, int h, MacWindowMan
 	_maskSurface = nullptr;
 
 	_composeSurface = new ManagedSurface(_dims.width(), _dims.height());
-	_composeSurface->clear(_bgcolor);
+	_composeSurface->clear(0xff);
 
 	_maskSurface = new ManagedSurface(_dims.width(), _dims.height());
 	_maskSurface->clear(1);
@@ -83,13 +80,6 @@ void MacWidget::blit(ManagedSurface *g, Common::Rect &dest) {
 	g->transBlitFrom(*_composeSurface, _composeSurface->getBounds(), dest, kColorGreen2);
 }
 
-void MacWidget::setColors(int fg, int bg) {
-	_fgcolor = fg;
-	_bgcolor = bg;
-
-	_contentIsDirty = true;
-}
-
 bool MacWidget::processEvent(Common::Event &event) {
 	return false;
 }
diff --git a/graphics/macgui/macwidget.h b/graphics/macgui/macwidget.h
index e93c47fb74..b26d0c50fd 100644
--- a/graphics/macgui/macwidget.h
+++ b/graphics/macgui/macwidget.h
@@ -40,7 +40,7 @@ class MacWindowManager;
 class MacWidget {
 
 public:
-	MacWidget(MacWidget *parent, int x, int y, int w, int h, MacWindowManager *wm, bool focusable, uint16 border = 0, uint16 gutter = 0, uint16 shadow = 0, uint fgcolor = 0, uint bgcolor= 0xff);
+	MacWidget(MacWidget *parent, int x, int y, int w, int h, MacWindowManager *wm, bool focusable, uint16 border = 0, uint16 gutter = 0, uint16 shadow = 0);
 	virtual ~MacWidget();
 
 	/**
@@ -69,8 +69,6 @@ public:
 	virtual bool hasAllFocus() { return _active; }
 	virtual bool isEditable() { return _editable; }
 
-	virtual void setColors(int fg, int bg);
-
 	virtual void setDimensions(const Common::Rect &r) {
 		_dims = r;
 	}
@@ -88,8 +86,6 @@ protected:
 	uint16 _gutter;
 	uint16 _shadow;
 
-	int _fgcolor, _bgcolor;
-
 	Graphics::ManagedSurface *_composeSurface;
 	Graphics::ManagedSurface *_maskSurface;
 




More information about the Scummvm-git-logs mailing list