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

ysj1173886760 42030331+ysj1173886760 at users.noreply.github.com
Fri Jul 9 01:42:38 UTC 2021


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

Summary:
4c9db11696 GRAPHICS: MACGUI: amend setting bgcolor and fgcolor. drawing color by fgcolor
d86a1e021c DIRECTOR: rendering editable text separately.
cd227d47e9 DIRECTOR: rendering ink copy editable text separately
947764159c DIRECTOR: fix rendering text separately. read fg color though text, instead of argument
b6b5881d7f DIRECTOR: Add a version check for adding palette in loadCast


Commit: 4c9db11696a163dd9273a825bc1d74e54ee9a5cf
    https://github.com/scummvm/scummvm/commit/4c9db11696a163dd9273a825bc1d74e54ee9a5cf
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-07-09T09:41:31+08:00

Commit Message:
GRAPHICS: MACGUI: amend setting bgcolor and fgcolor. drawing color by fgcolor

Changed paths:
    graphics/macgui/mactext.cpp


diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index f4c361cf71..1e2cb6c9b6 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -271,7 +271,7 @@ void MacText::init() {
 	_cursorRect = new Common::Rect(0, 0, 1, 1);
 
 	_cursorSurface = new ManagedSurface(1, kCursorMaxHeight, _wm->_pixelformat);
-	_cursorSurface->clear(_wm->_colorBlack);
+	_cursorSurface->clear(_fgcolor);
 	_cursorSurface2 = new ManagedSurface(1, kCursorMaxHeight, _wm->_pixelformat);
 	_cursorSurface2->clear(_bgcolor);
 
@@ -343,8 +343,14 @@ void MacText::setMaxWidth(int maxWidth) {
 void MacText::setColors(uint32 fg, uint32 bg) {
 	_bgcolor = bg;
 	_fgcolor = fg;
+	// also set the cursor color
+	_cursorSurface->clear(_fgcolor);
 	for (uint i = 0; i < _textLines.size(); i++)
 		setTextColor(fg, i);
+
+	_fullRefresh = true;
+	render();
+	_contentIsDirty = true;
 }
 
 void MacText::setTextSize(int textSize) {
@@ -370,9 +376,7 @@ void MacText::setTextColor(uint32 color, uint32 line) {
 		_textLines[line].chunks[j].fgcolor = fgcol;
 	}
 
-	_fullRefresh = true;
-	render();
-	_contentIsDirty = true;
+	// if we are calling this func separately, then here need a refresh
 }
 
 void MacText::getChunkPosFromIndex(int index, uint &lineNum, uint &chunkNum, uint &offset) {
@@ -1317,8 +1321,10 @@ bool MacText::draw(bool forceRedraw) {
 	if (_cursorState && !((_inTextSelection || _selectedText.endY != -1) && _active))
 		_composeSurface->blitFrom(*_cursorSurface, *_cursorRect, Common::Point(_cursorX + offset.x, _cursorY + offset.y));
 
-	if (_selectedText.endY != -1)
+	if (_selectedText.endY != -1) {
+		debug("drawing selectio");
 		drawSelection(offset.x, offset.y);
+	}
 
 	return true;
 }


Commit: d86a1e021cea8cc26ac6fd17defdb0c642a60b49
    https://github.com/scummvm/scummvm/commit/d86a1e021cea8cc26ac6fd17defdb0c642a60b49
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-07-09T09:41:31+08:00

Commit Message:
DIRECTOR: rendering editable text separately.

Changed paths:
    engines/director/channel.cpp


diff --git a/engines/director/channel.cpp b/engines/director/channel.cpp
index d6b3753ff5..7fcce5ebf0 100644
--- a/engines/director/channel.cpp
+++ b/engines/director/channel.cpp
@@ -80,7 +80,9 @@ DirectorPlotData Channel::getPlotData() {
 		pd.ms = getShape();
 		pd.applyColor = false;
 	} else {
-		pd.setApplyColor();
+		// for the editable text sprite, we shall apply color in mactext. because those editable part may changed without let director knowing it
+		if (!(_sprite->_spriteType == kTextSprite && _sprite->_cast && _sprite->_cast->isEditable()))
+			pd.setApplyColor();
 	}
 
 	return pd;
@@ -492,14 +494,20 @@ void Channel::replaceWidget(CastMemberID previousCastId, bool force) {
 		Common::Rect bbox(getBbox());
 		_sprite->_cast->setModified(false);
 
-//		if (_sprite->_cast->_type == kCastText)
-//			debug("%s %d\n", ((TextCastMember *)_sprite->_cast)->_ftext.c_str(), ((TextCastMember *)_sprite->_cast)->_editable);
 		_widget = _sprite->_cast->createWidget(bbox, this);
 		if (_widget) {
 			_widget->_priority = _priority;
 			_widget->draw();
 
 			if (_sprite->_cast->_type == kCastText || _sprite->_cast->_type == kCastButton) {
+				// for editable test cast, we didn't apply the color, thus, we should set color when we are creating cast member
+				// this should be amend to setting colors before we create castmember.
+				// but currently, fgcolor is not available in mactext due to the fact that we are using _ftext to decide render formatting
+				if (_sprite->_cast->_type == kCastText && _sprite->_cast->isEditable()) {
+					((Graphics::MacText *)_widget)->setColors(_sprite->_foreColor, _sprite->_backColor);
+					((Graphics::MacText *)_widget)->draw();
+				}
+
 				_sprite->_width = _widget->_dims.width();
 				_sprite->_height = _widget->_dims.height();
 				_width = _sprite->_width;


Commit: cd227d47e9addbf9abc86a839ce57e35f690117c
    https://github.com/scummvm/scummvm/commit/cd227d47e9addbf9abc86a839ce57e35f690117c
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-07-09T09:41:31+08:00

Commit Message:
DIRECTOR: rendering ink copy editable text separately

Changed paths:
    engines/director/channel.cpp


diff --git a/engines/director/channel.cpp b/engines/director/channel.cpp
index 7fcce5ebf0..27aa8bd26c 100644
--- a/engines/director/channel.cpp
+++ b/engines/director/channel.cpp
@@ -68,6 +68,10 @@ Channel::~Channel() {
 	delete _sprite;
 }
 
+bool isCopyEditableTextSprite(Sprite *sprite) {
+	return sprite->_spriteType == kTextSprite && sprite->_cast && sprite->_cast->isEditable() && sprite->_ink == kInkTypeCopy;
+}
+
 DirectorPlotData Channel::getPlotData() {
 	DirectorPlotData pd(g_director->_wm, _sprite->_spriteType, _sprite->_ink, _sprite->_blend, getBackColor(), getForeColor());
 	pd.colorWhite = pd._wm->_colorWhite;
@@ -81,7 +85,7 @@ DirectorPlotData Channel::getPlotData() {
 		pd.applyColor = false;
 	} else {
 		// for the editable text sprite, we shall apply color in mactext. because those editable part may changed without let director knowing it
-		if (!(_sprite->_spriteType == kTextSprite && _sprite->_cast && _sprite->_cast->isEditable()))
+		if (!isCopyEditableTextSprite(_sprite))
 			pd.setApplyColor();
 	}
 
@@ -503,7 +507,7 @@ void Channel::replaceWidget(CastMemberID previousCastId, bool force) {
 				// for editable test cast, we didn't apply the color, thus, we should set color when we are creating cast member
 				// this should be amend to setting colors before we create castmember.
 				// but currently, fgcolor is not available in mactext due to the fact that we are using _ftext to decide render formatting
-				if (_sprite->_cast->_type == kCastText && _sprite->_cast->isEditable()) {
+				if (isCopyEditableTextSprite(_sprite)) {
 					((Graphics::MacText *)_widget)->setColors(_sprite->_foreColor, _sprite->_backColor);
 					((Graphics::MacText *)_widget)->draw();
 				}


Commit: 947764159cfce6e93a36e9cc6aa0274b69ad984e
    https://github.com/scummvm/scummvm/commit/947764159cfce6e93a36e9cc6aa0274b69ad984e
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-07-09T09:41:31+08:00

Commit Message:
DIRECTOR: fix rendering text separately. read fg color though text, instead of argument

Changed paths:
    engines/director/channel.cpp
    graphics/macgui/mactext.cpp
    graphics/macgui/mactext.h


diff --git a/engines/director/channel.cpp b/engines/director/channel.cpp
index 27aa8bd26c..c4d05d13d3 100644
--- a/engines/director/channel.cpp
+++ b/engines/director/channel.cpp
@@ -68,10 +68,6 @@ Channel::~Channel() {
 	delete _sprite;
 }
 
-bool isCopyEditableTextSprite(Sprite *sprite) {
-	return sprite->_spriteType == kTextSprite && sprite->_cast && sprite->_cast->isEditable() && sprite->_ink == kInkTypeCopy;
-}
-
 DirectorPlotData Channel::getPlotData() {
 	DirectorPlotData pd(g_director->_wm, _sprite->_spriteType, _sprite->_ink, _sprite->_blend, getBackColor(), getForeColor());
 	pd.colorWhite = pd._wm->_colorWhite;
@@ -84,9 +80,7 @@ DirectorPlotData Channel::getPlotData() {
 		pd.ms = getShape();
 		pd.applyColor = false;
 	} else {
-		// for the editable text sprite, we shall apply color in mactext. because those editable part may changed without let director knowing it
-		if (!isCopyEditableTextSprite(_sprite))
-			pd.setApplyColor();
+		pd.setApplyColor();
 	}
 
 	return pd;
@@ -504,13 +498,6 @@ void Channel::replaceWidget(CastMemberID previousCastId, bool force) {
 			_widget->draw();
 
 			if (_sprite->_cast->_type == kCastText || _sprite->_cast->_type == kCastButton) {
-				// for editable test cast, we didn't apply the color, thus, we should set color when we are creating cast member
-				// this should be amend to setting colors before we create castmember.
-				// but currently, fgcolor is not available in mactext due to the fact that we are using _ftext to decide render formatting
-				if (isCopyEditableTextSprite(_sprite)) {
-					((Graphics::MacText *)_widget)->setColors(_sprite->_foreColor, _sprite->_backColor);
-					((Graphics::MacText *)_widget)->draw();
-				}
 
 				_sprite->_width = _widget->_dims.width();
 				_sprite->_height = _widget->_dims.height();
diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index 1e2cb6c9b6..67928e64d4 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -275,6 +275,13 @@ void MacText::init() {
 	_cursorSurface2 = new ManagedSurface(1, kCursorMaxHeight, _wm->_pixelformat);
 	_cursorSurface2->clear(_bgcolor);
 
+	// currently, we are not using fg color to render text. And we are not passing fg color correctly, thus we read it our self.
+	int color = getFgColor();
+	if (color != -1) {
+		debug(9, "Reading fg color though text, instead of the argument");
+		_fgcolor = color;
+	}
+
 	reallocSurface();
 	setAlignOffset(_textAlignment);
 	updateCursorPos();
@@ -291,6 +298,19 @@ MacText::~MacText() {
 	delete _cursorSurface2;
 }
 
+// this func returns the fg color of the first character we met in text
+int MacText::getFgColor() {
+	if (_textLines.empty())
+		return -1;
+	for (uint i = 0; i < _textLines.size(); i++) {
+		for (uint j = 0; j < _textLines[i].chunks.size(); j++) {
+			if (!_textLines[i].chunks[j].text.empty())
+				return _textLines[i].chunks[j].fgcolor;
+		}
+	}
+	return -1;
+}
+
 // we are doing this because we may need to dealing with the plain byte. See ctor of mactext which contains String str instead of U32String str
 // thus, if we are passing the str, meaning we are using plainByteMode. And when we calculating the string width. we need to convert it to it's orignal state first;
 int MacText::getStringWidth(const Font *font, const Common::U32String &str) {
@@ -910,17 +930,17 @@ void MacText::render(int from, int to) {
 
 		// TODO: _textMaxWidth, when -1, was not rendering ANY text.
 		for (uint j = 0; j < _textLines[i].chunks.size(); j++) {
-			debug(9, "MacText::render: line %d[%d] h:%d at %d,%d (%s) fontid: %d on %dx%d, fgcolor: %d bgcolor: %d, font: %p",
-				i, j, _textLines[i].height, xOffset, _textLines[i].y, _textLines[i].chunks[j].text.encode().c_str(),
-				_textLines[i].chunks[j].fontId, _surface->w, _surface->h, _textLines[i].chunks[j].fgcolor, _bgcolor,
-				(const void *)_textLines[i].chunks[j].getFont());
+			debug(0, "MacText::render: line %d[%d] h:%d at %d,%d (%s) fontid: %d on %dx%d, fgcolor: %d bgcolor: %d, font: %p",
+				  i, j, _textLines[i].height, xOffset, _textLines[i].y, _textLines[i].chunks[j].text.encode().c_str(),
+				  _textLines[i].chunks[j].fontId, _surface->w, _surface->h, _textLines[i].chunks[j].fgcolor, _bgcolor,
+				  (const void *)_textLines[i].chunks[j].getFont());
 
 			if (_textLines[i].chunks[j].text.empty())
 				continue;
 
 			int yOffset = 0;
 			if (_textLines[i].chunks[j].font->getFontAscent() < maxAscentForRow) {
-				yOffset = maxAscentForRow -_textLines[i].chunks[j].font->getFontAscent();
+				yOffset = maxAscentForRow - _textLines[i].chunks[j].font->getFontAscent();
 			}
 
 			if (_plainByteMode) {
diff --git a/graphics/macgui/mactext.h b/graphics/macgui/mactext.h
index 4733131ebf..951c930ee0 100644
--- a/graphics/macgui/mactext.h
+++ b/graphics/macgui/mactext.h
@@ -221,6 +221,7 @@ private:
 	// getStringWidth for mactext version, because we may have the plain bytes mode
 	int getStringWidth(const Font *font, const Common::U32String &str);
 	int getAlignOffset(int row);
+	int getFgColor();
 
 public:
 	void appendTextDefault(const Common::U32String &str, bool skipAdd = false);


Commit: b6b5881d7fc0150e69171b3ca1a042019336a076
    https://github.com/scummvm/scummvm/commit/b6b5881d7fc0150e69171b3ca1a042019336a076
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-07-09T09:41:31+08:00

Commit Message:
DIRECTOR: Add a version check for adding palette in loadCast

Changed paths:
    engines/director/cast.cpp


diff --git a/engines/director/cast.cpp b/engines/director/cast.cpp
index e7e15be8f7..6b36410ba2 100644
--- a/engines/director/cast.cpp
+++ b/engines/director/cast.cpp
@@ -322,7 +322,13 @@ void Cast::loadCast() {
 
 			debugC(2, kDebugLoading, "****** Loading Palette CLUT, #%d", clutList[i]);
 			PaletteV4 p = loadPalette(*pal);
-			g_director->addPalette(clutList[i] & 0xff, p.palette, p.length);
+
+			// for D2, we are using palette cast member id to resolve palette Id, so we are using lowest 1 bit to represent cast id. see Also loadCastChildren
+			if (g_director->getVersion() == 200)
+				g_director->addPalette(clutList[i] & 0xff, p.palette, p.length);
+			else
+				g_director->addPalette(clutList[i], p.palette, p.length);
+
 			delete pal;
 		}
 	}




More information about the Scummvm-git-logs mailing list