[Scummvm-git-logs] scummvm master -> 63071473af4487f26ac7d7da0e7097a1f709c5e1

npjg nathanael.gentrydb8 at gmail.com
Tue Jul 7 03:16:38 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:
63071473af Revert "GRAPHICS: MACGUI: Remove colour settings from base widget"


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

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

This reverts commit 39c4a0f524fb181cfd4cba5eb724ca8caeaae097.

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 997c11dac0..ee9b660321 100644
--- a/engines/director/castmember.cpp
+++ b/engines/director/castmember.cpp
@@ -420,6 +420,9 @@ 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) {
@@ -462,13 +465,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, 0, 0xff, _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, getForeColor(), getBackColor(), _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);
+		_widget = new Graphics::MacButton(Graphics::MacButtonType(_buttonType), getAlignment(), g_director->getStage(), 0, 0, _initialRect.width(), _initialRect.height(), g_director->_wm, _ftext, macFont, getForeColor(), 0xff);
 		((Graphics::MacButton *)_widget)->draw();
 		_widget->_focusable = true;
 
diff --git a/engines/director/castmember.h b/engines/director/castmember.h
index 88f190e2dd..b68f347aa0 100644
--- a/engines/director/castmember.h
+++ b/engines/director/castmember.h
@@ -64,6 +64,9 @@ 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;
@@ -88,6 +91,7 @@ public:
 
 	void createMatte();
 	Graphics::Surface *getMatte();
+	// virtual void setColors(int *fgcolor, int *bgcolor) override;
 
 	Image::ImageDecoder *_img;
 	Graphics::FloodFill *_matte;
@@ -147,8 +151,8 @@ public:
 class TextCastMember : public CastMember {
 public:
 	TextCastMember(Cast *cast, uint16 castId, Common::ReadStreamEndian &stream, uint16 version, bool asButton = false);
-	void setColors(int *fgcolor, int *bgcolor);
-	void getColors(int *fgcolor, int *bgcolor);
+	virtual void setColors(int *fgcolor, int *bgcolor) override;
+	virtual void getColors(int *fgcolor, int *bgcolor) override;
 
 	void setText(const char *text);
 	virtual void createWidget() override;
@@ -158,6 +162,9 @@ 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 2465767b2a..ba8442a208 100644
--- a/engines/director/lingo/lingo-the.cpp
+++ b/engines/director/lingo/lingo-the.cpp
@@ -981,11 +981,7 @@ Datum Lingo::getTheCast(Datum &id1, int field) {
 
 	switch (field) {
 	case kTheBackColor:
-		if (member->_type == kCastText) {
-			((TextCastMember *)member)->getColors(nullptr, &d.u.i);
-		} else {
-			warning("Lingo::getTheCast(): Attempted to set access color of non-text cast");
-		}
+		member->getColors(nullptr, &d.u.i);
 		break;
 	case kTheCastType:
 		d.u.i = castType;
@@ -994,11 +990,7 @@ Datum Lingo::getTheCast(Datum &id1, int field) {
 		d = Datum(castInfo->fileName);
 		break;
 	case kTheForeColor:
-		if (member->_type == kCastText) {
-			((TextCastMember *)member)->getColors(&d.u.i, nullptr);
-		} else {
-			warning("Lingo::getTheCast(): Attempted to access color of non-text cast");
-		}
+		member->getColors(&d.u.i, nullptr);
 		break;
 	case kTheHeight:
 		d.u.i = cast->getCastMemberInitialRect(id).height();
@@ -1066,11 +1058,7 @@ void Lingo::setTheCast(Datum &id1, int field, Datum &d) {
 	switch (field) {
 	case kTheBackColor: {
 		int color = _vm->transformColor(d.asInt());
-		if (member->_type == kCastText) {
-			((TextCastMember *)member)->setColors(nullptr, &color);
-		} else {
-			warning("Lingo::setTheCast(): Attempted to access color of non-text cast");
-		}
+		member->setColors(nullptr, &color);
 		break;
 	}
 	case kTheCastType:
@@ -1088,12 +1076,7 @@ void Lingo::setTheCast(Datum &id1, int field, Datum &d) {
 		break;
 	case kTheForeColor: {
 		int color = _vm->transformColor(d.asInt());
-
-		if (member->_type == kCastText) {
-			((TextCastMember *)member)->setColors(&color, nullptr);
-		} else {
-			warning("Lingo::setTheCast(): Attempted to access color of non-text cast");
-		}
+		member->setColors(&color, nullptr);
 		break;
 	}
 	case kTheHeight:
diff --git a/graphics/macgui/macbutton.cpp b/graphics/macgui/macbutton.cpp
index c21a03e78d..9b32f096d1 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) :
-	MacText(parent, x, y, w, h, wm, s, macFont, 0, 0xff, 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, int fgcolor, int bgcolor) :
+	MacText(parent, x, y, w, h, wm, s, macFont, fgcolor, bgcolor, w, textAlignment) {
 
 	_buttonType = buttonType;
 
diff --git a/graphics/macgui/macbutton.h b/graphics/macgui/macbutton.h
index 1dfa427566..7f1cccc4c5 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);
+	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);
 
 	virtual void setActive(bool active) override;
 
diff --git a/graphics/macgui/mactext.h b/graphics/macgui/mactext.h
index e3d755c865..cf5227d70a 100644
--- a/graphics/macgui/mactext.h
+++ b/graphics/macgui/mactext.h
@@ -253,7 +253,6 @@ 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 1d5239be3b..75bbeedb8d 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) :
+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) :
 	_focusable(focusable), _parent(parent), _border(border), _gutter(gutter), _shadow(shadow), _wm(wm) {
 	_contentIsDirty = true;
 	_priority = 0;
@@ -37,6 +37,9 @@ 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);
 
@@ -44,7 +47,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(0xff);
+	_composeSurface->clear(_bgcolor);
 
 	_maskSurface = new ManagedSurface(_dims.width(), _dims.height());
 	_maskSurface->clear(1);
@@ -80,6 +83,13 @@ 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 b26d0c50fd..e93c47fb74 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);
+	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);
 	virtual ~MacWidget();
 
 	/**
@@ -69,6 +69,8 @@ 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;
 	}
@@ -86,6 +88,8 @@ protected:
 	uint16 _gutter;
 	uint16 _shadow;
 
+	int _fgcolor, _bgcolor;
+
 	Graphics::ManagedSurface *_composeSurface;
 	Graphics::ManagedSurface *_maskSurface;
 




More information about the Scummvm-git-logs mailing list