[Scummvm-git-logs] scummvm master -> 1945e3ec5cc45d0791be7b0a17e8e9a5c1320c2a

sev- sev at scummvm.org
Wed Jun 30 14:29:21 UTC 2021


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

Summary:
dc6dd68776 DIRECTOR: change the original sprite when we are setting cast num
bb26ca4d46 GRAPHICS: MACGUI: reset variable for handling events for macwidgets when wm won't handle events correctly
1359be17be DIRECTOR: clear the events when we are calling MessageDialog box in b_alert.
b512f33263 GRAPHICS: MACGUI: pass an event of lbutton_up to those widgets should clear widgets correctly.
6db3b93050 GRAPHICS: MACGUI: add an overload version for findBestColor
ba858522eb GRAPHICS: MACGUI: add basic color changing support for mactext
ba9f97df4d DIRECTOR: fix setting color for text castmember
787454f908 GRAPHICS: MACGUI: support partial color setting in mactext
ced3a58b10 DIRECTOR: fix setting width and height to puppet sprites
d46866f893 DIRECTOR: implement matte for quick draw shape
7c147b16fb DIRECTOR: support QDshape matte for intersect and within check
4a38579f44 DIRECTOR: don't regard quick draw shape as matte type
7eb039d174 DIRECTOR: fix intersect check. add 1 offset for constrain boundary
c759e27fe7 GRAPHICS: MACGUI: introduce _fixedDims to mactext, which represent for whether mactext should auto expanding.
b2ea651b9d DIRECTOR: auto expand text widgets for D3/4
1d20fa758f DIRECTOR: don't hilite puppet sprites.
506ee5200a DIRECTOR: removing changing original sprites when setting cast member.
be199c07ab DIRECTOR: more precise definition for shouldHilite for D3
b659c964f7 DIRECTOR: make debug output more readable
202f6ce7e5 GRAPHICS: MACGUI: move set fixed dims to ctor for mactext
d0317fa1bb DIRECTOR: use text style to determine whether text should fix dims
bcd33eeba3 DIRECTOR: fix rendering text to suit for different style text
d11835cffc DIRECTOR: implement immediateSprite.
f9014d0381 DIRECTOR: remove changing original sprites in immediateSprite and puppetSprite
bd0da46c2f DIRECTOR: fix size parameter passing when we have auto expand text
1945e3ec5c GRAPHICS: MACGUI: realloc surface after changing dims


Commit: dc6dd687762e878971ab707a16c9ec79ed518a1e
    https://github.com/scummvm/scummvm/commit/dc6dd687762e878971ab707a16c9ec79ed518a1e
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-06-30T16:29:00+02:00

Commit Message:
DIRECTOR: change the original sprite when we are setting cast num

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 d0cb4af99a..061019922e 100644
--- a/engines/director/lingo/lingo-the.cpp
+++ b/engines/director/lingo/lingo-the.cpp
@@ -1311,6 +1311,8 @@ void Lingo::setTheSprite(Datum &id1, int field, Datum &d) {
 			if (castId != sprite->_castId) {
 				g_director->getCurrentWindow()->addDirtyRect(channel->getBbox());
 				channel->setCast(castId);
+				// TODO: find the correct way to replace widget, instead of changing the original one.
+				score->getOriginalSpriteById(id)->setCast(castId);
 				channel->_dirty = true;
 			}
 		}


Commit: bb26ca4d465eaae4bb3abdace1e3061a6184f58c
    https://github.com/scummvm/scummvm/commit/bb26ca4d465eaae4bb3abdace1e3061a6184f58c
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-06-30T16:29:00+02:00

Commit Message:
GRAPHICS: MACGUI: reset variable for handling events for macwidgets when wm won't handle events correctly

Changed paths:
    graphics/macgui/macwindowmanager.cpp
    graphics/macgui/macwindowmanager.h


diff --git a/graphics/macgui/macwindowmanager.cpp b/graphics/macgui/macwindowmanager.cpp
index e6883f34c6..04cae68dbd 100644
--- a/graphics/macgui/macwindowmanager.cpp
+++ b/graphics/macgui/macwindowmanager.cpp
@@ -282,6 +282,12 @@ void MacWindowManager::setMode(uint32 mode) {
 		_fontMan->forceBuiltinFonts();
 }
 
+void MacWindowManager::clearHandlingWidgets() {
+	_mouseDown = false;
+	setActiveWidget(nullptr);
+	_hoveredWidget = nullptr;
+}
+
 void MacWindowManager::setActiveWidget(MacWidget *widget) {
 	if (_activeWidget == widget)
 		return;
diff --git a/graphics/macgui/macwindowmanager.h b/graphics/macgui/macwindowmanager.h
index fee8f0657e..14270d8a7f 100644
--- a/graphics/macgui/macwindowmanager.h
+++ b/graphics/macgui/macwindowmanager.h
@@ -324,6 +324,13 @@ public:
 	 */
 	Common::U32String getTextFromClipboard(const Common::U32String &format = Common::U32String(), int *size = nullptr);
 
+	/**
+	 * reset events for current widgets. i.e. we reset those variables which are used for handling events for macwidgets.
+	 * e.g. we clear the active widget, set mouse down false, clear the hoveredWidget
+	 * this function should be called when we are going to other level to handling events. thus wm may not handle events correctly.
+	 */
+	void clearHandlingWidgets();
+
 public:
 	MacFontManager *_fontMan;
 	uint32 _mode;


Commit: 1359be17be4a836ca5a9bd3bf507d39c077e5b16
    https://github.com/scummvm/scummvm/commit/1359be17be4a836ca5a9bd3bf507d39c077e5b16
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-06-30T16:29:00+02:00

Commit Message:
DIRECTOR: clear the events when we are calling MessageDialog box in b_alert.

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


diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp
index 867e6e9e72..bc5d634078 100644
--- a/engines/director/lingo/lingo-builtins.cpp
+++ b/engines/director/lingo/lingo-builtins.cpp
@@ -1500,6 +1500,7 @@ void LB::b_alert(int nargs) {
 	if (!debugChannelSet(-1, kDebugFewFramesOnly)) {
 		GUI::MessageDialog dialog(alert.c_str(), "OK");
 		dialog.runModal();
+		g_director->_wm->clearHandlingWidgets();
 	}
 }
 


Commit: b512f33263b2805c325915b9476515d051c7c69c
    https://github.com/scummvm/scummvm/commit/b512f33263b2805c325915b9476515d051c7c69c
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-06-30T16:29:00+02:00

Commit Message:
GRAPHICS: MACGUI: pass an event of lbutton_up to those widgets should clear widgets correctly.

Changed paths:
    engines/director/lingo/lingo-builtins.cpp
    graphics/macgui/macwindowmanager.cpp


diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp
index bc5d634078..782e1346e1 100644
--- a/engines/director/lingo/lingo-builtins.cpp
+++ b/engines/director/lingo/lingo-builtins.cpp
@@ -1498,9 +1498,9 @@ void LB::b_alert(int nargs) {
 	warning("b_alert(%s)", alert.c_str());
 
 	if (!debugChannelSet(-1, kDebugFewFramesOnly)) {
+		g_director->_wm->clearHandlingWidgets();
 		GUI::MessageDialog dialog(alert.c_str(), "OK");
 		dialog.runModal();
-		g_director->_wm->clearHandlingWidgets();
 	}
 }
 
diff --git a/graphics/macgui/macwindowmanager.cpp b/graphics/macgui/macwindowmanager.cpp
index 04cae68dbd..779bd3a9d0 100644
--- a/graphics/macgui/macwindowmanager.cpp
+++ b/graphics/macgui/macwindowmanager.cpp
@@ -283,7 +283,12 @@ void MacWindowManager::setMode(uint32 mode) {
 }
 
 void MacWindowManager::clearHandlingWidgets() {
-	_mouseDown = false;
+	// pass a LBUTTONUP event to those widgets should clear those state
+	Common::Event event;
+	event.type = Common::EVENT_LBUTTONUP;
+	event.mouse = _lastClickPos;
+	processEvent(event);
+
 	setActiveWidget(nullptr);
 	_hoveredWidget = nullptr;
 }


Commit: 6db3b93050a2ea55fe05c86fa6bab1856cdae7e8
    https://github.com/scummvm/scummvm/commit/6db3b93050a2ea55fe05c86fa6bab1856cdae7e8
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-06-30T16:29:00+02:00

Commit Message:
GRAPHICS: MACGUI: add an overload version for findBestColor

Changed paths:
    graphics/macgui/macwindowmanager.cpp
    graphics/macgui/macwindowmanager.h


diff --git a/graphics/macgui/macwindowmanager.cpp b/graphics/macgui/macwindowmanager.cpp
index 779bd3a9d0..49a4a42dde 100644
--- a/graphics/macgui/macwindowmanager.cpp
+++ b/graphics/macgui/macwindowmanager.cpp
@@ -1165,6 +1165,12 @@ void MacWindowManager::passPalette(const byte *pal, uint size) {
 	setFullRefresh(true);
 }
 
+uint MacWindowManager::findBestColor(uint32 color) {
+	byte r, g, b;
+	decomposeColor(color, r, g, b);
+	return findBestColor(r, g, b);
+}
+
 uint MacWindowManager::findBestColor(byte cr, byte cg, byte cb) {
 	if (_pixelformat.bytesPerPixel == 4)
 		return _pixelformat.RGBToColor(cr, cg, cb);
diff --git a/graphics/macgui/macwindowmanager.h b/graphics/macgui/macwindowmanager.h
index 14270d8a7f..c8eb6ecaa0 100644
--- a/graphics/macgui/macwindowmanager.h
+++ b/graphics/macgui/macwindowmanager.h
@@ -300,6 +300,7 @@ public:
 
 	void passPalette(const byte *palette, uint size);
 	uint findBestColor(byte cr, byte cg, byte cb);
+	uint findBestColor(uint32 color);
 	void decomposeColor(uint32 color, byte &r, byte &g, byte &b);
 
 	const byte *getPalette() { return _palette; }


Commit: ba858522eb830f1e1b77f5713d5624712c0196a1
    https://github.com/scummvm/scummvm/commit/ba858522eb830f1e1b77f5713d5624712c0196a1
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-06-30T16:29:00+02:00

Commit Message:
GRAPHICS: MACGUI: add basic color changing support for mactext

Changed paths:
    graphics/macgui/mactext.cpp
    graphics/macgui/mactext.h


diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index c2d1eeabfa..63a8c871d6 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -228,10 +228,7 @@ void MacText::init() {
 	_selStart = -1;
 
 	_defaultFormatting.wm = _wm;
-	// try to set fgcolor as default color in chunks
-	if (_wm->_mode & kWMModeWin95) {
-		_defaultFormatting.fgcolor = _fgcolor;
-	}
+	_defaultFormatting.fgcolor = _fgcolor;
 	_currentFormatting = _defaultFormatting;
 	_composeSurface->clear(_bgcolor);
 
@@ -329,6 +326,29 @@ void MacText::setMaxWidth(int maxWidth) {
 	_contentIsDirty = true;
 }
 
+void MacText::setColors(uint32 fg, uint32 bg) {
+	_bgcolor = bg;
+	_fgcolor = fg;
+	for (uint i = 0; i < _textLines.size(); i++)
+		setTextColor(fg, i);
+}
+
+void MacText::setTextColor(uint32 color, uint32 line) {
+	if (line >= _textLines.size()) {
+		warning("MacText::setTextColor(): line %d is out of bounds", line);
+		return;
+	}
+
+	uint fgcol = _wm->findBestColor(color);
+	for (uint j = 0; j < _textLines[line].chunks.size(); j++) {
+		_textLines[line].chunks[j].fgcolor = fgcol;
+	}
+
+	_fullRefresh = true;
+	render();
+	_contentIsDirty = true;
+}
+
 void MacText::setDefaultFormatting(uint16 fontId, byte textSlant, uint16 fontSize,
 		uint16 palinfo1, uint16 palinfo2, uint16 palinfo3) {
 	_defaultFormatting.setValues(_defaultFormatting.wm, fontId, textSlant, fontSize, palinfo1, palinfo2, palinfo3);
diff --git a/graphics/macgui/mactext.h b/graphics/macgui/mactext.h
index 623d05a9e0..c053358408 100644
--- a/graphics/macgui/mactext.h
+++ b/graphics/macgui/mactext.h
@@ -183,6 +183,10 @@ public:
 	virtual void setActive(bool active) override;
 	void setEditable(bool editable);
 
+	void setColors(uint32 fg, uint32 bg) override;
+	// set fgcolor for line x
+	void setTextColor(uint32 color, uint32 line);
+
 	void appendText(const Common::U32String &str, int fontId = kMacFontChicago, int fontSize = 12, int fontSlant = kMacFontRegular, bool skipAdd = false);
 	void appendText(const Common::String &str, int fontId = kMacFontChicago, int fontSize = 12, int fontSlant = kMacFontRegular, bool skipAdd = false);
 	void appendText(const Common::U32String &str, int fontId = kMacFontChicago, int fontSize = 12, int fontSlant = kMacFontRegular, uint16 r = 0, uint16 g = 0, uint16 b = 0, bool skipAdd = false);


Commit: ba9f97df4d95e4372af64550124125620815d263
    https://github.com/scummvm/scummvm/commit/ba9f97df4d95e4372af64550124125620815d263
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-06-30T16:29:00+02:00

Commit Message:
DIRECTOR: fix setting color for text castmember

Changed paths:
    engines/director/castmember.cpp


diff --git a/engines/director/castmember.cpp b/engines/director/castmember.cpp
index 23b086ac4a..f28fe3f4e0 100644
--- a/engines/director/castmember.cpp
+++ b/engines/director/castmember.cpp
@@ -658,6 +658,12 @@ void TextCastMember::setColors(uint32 *fgcolor, uint32 *bgcolor) {
 
 	if (bgcolor)
 		_bgcolor = *bgcolor;
+
+	// if we want to keep the format unchanged, then we need to modify _ftext as well
+	if (_widget)
+		((Graphics::MacText *)_widget)->setColors(_fgcolor, _bgcolor);
+	else
+		_modified = true;
 }
 
 Graphics::TextAlign TextCastMember::getAlignment() {


Commit: 787454f908a0ded7fee321576d49da0f69379078
    https://github.com/scummvm/scummvm/commit/787454f908a0ded7fee321576d49da0f69379078
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-06-30T16:29:00+02:00

Commit Message:
GRAPHICS: MACGUI: support partial color setting in mactext

Changed paths:
    graphics/macgui/mactext.cpp
    graphics/macgui/mactext.h


diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index 63a8c871d6..f5996f821d 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -349,6 +349,84 @@ void MacText::setTextColor(uint32 color, uint32 line) {
 	_contentIsDirty = true;
 }
 
+void MacText::getChunkPosFromIndex(int index, uint &lineNum, uint &chunkNum, uint &offset) {
+	if (_textLines.empty()) {
+		lineNum = chunkNum = offset = 0;
+		return;
+	}
+	for (uint i = 0; i < _textLines.size(); i++) {
+		if (getLineCharWidth(i) <= index) {
+			index -= getLineCharWidth(i);
+		} else {
+			lineNum = i;
+			chunkNum = _textLines[i].getChunkNum(&index);
+			offset = index;
+			return;
+		}
+	}
+	lineNum = _textLines.size() - 1;
+	chunkNum = _textLines[lineNum].chunks.size() - 1;
+	offset = 0;
+}
+
+void MacText::setTextColor(uint32 color, uint32 start, uint32 end) {
+	if (_textLines.empty())
+		return;
+	if (start > end)
+		SWAP(start, end);
+
+	uint startRow, startCol;
+	uint endRow, endCol;
+	uint offset;
+
+	getChunkPosFromIndex(start, startRow, startCol, offset);
+	// if offset != 0, then we need to split the chunk
+	if (offset != 0) {
+		uint textSize = _textLines[startRow].chunks[startCol].text.size();
+		MacFontRun newChunk = _textLines[startRow].chunks[startCol];
+		newChunk.text = newChunk.text.substr(offset, textSize - offset);
+		_textLines[startRow].chunks[startCol].text = _textLines[startRow].chunks[startCol].text.substr(0, offset);
+		_textLines[startRow].chunks.insert_at(startCol + 1, newChunk);
+		startCol++;
+	}
+
+	getChunkPosFromIndex(end, endRow, endCol, offset);
+	if (offset != 0) {
+		uint textSize = _textLines[endRow].chunks[endCol].text.size();
+		MacFontRun newChunk = _textLines[endRow].chunks[endCol];
+		newChunk.text = newChunk.text.substr(offset, textSize - offset);
+		_textLines[endRow].chunks[endCol].text = _textLines[endRow].chunks[endCol].text.substr(0, offset);
+		_textLines[endRow].chunks.insert_at(endCol + 1, newChunk);
+		endCol++;
+	}
+
+	uint col = _wm->findBestColor(color);
+	// after spliting, we are going to modify the colors now
+	for (uint i = startRow; i <= endRow; i++) {
+		uint from, to;
+		if (i == startRow && i == endRow) {
+			from = startCol;
+			to = endCol;
+		} else if (i == startRow) {
+			from = startCol;
+			to = _textLines[startRow].chunks.size();
+		} else if (i == endRow) {
+			from = 0;
+			to = endCol;
+		} else {
+			from = 0;
+			to = _textLines[i].chunks.size();
+		}
+		for (uint j = from; j < to; j++) {
+			_textLines[i].chunks[j].fgcolor = col;
+		}
+	}
+
+	_fullRefresh = true;
+	render();
+	_contentIsDirty = true;
+}
+
 void MacText::setDefaultFormatting(uint16 fontId, byte textSlant, uint16 fontSize,
 		uint16 palinfo1, uint16 palinfo2, uint16 palinfo3) {
 	_defaultFormatting.setValues(_defaultFormatting.wm, fontId, textSlant, fontSize, palinfo1, palinfo2, palinfo3);
diff --git a/graphics/macgui/mactext.h b/graphics/macgui/mactext.h
index c053358408..fe9a91de99 100644
--- a/graphics/macgui/mactext.h
+++ b/graphics/macgui/mactext.h
@@ -186,6 +186,7 @@ public:
 	void setColors(uint32 fg, uint32 bg) override;
 	// set fgcolor for line x
 	void setTextColor(uint32 color, uint32 line);
+	void setTextColor(uint32 color, uint32 start, uint32 end);
 
 	void appendText(const Common::U32String &str, int fontId = kMacFontChicago, int fontSize = 12, int fontSlant = kMacFontRegular, bool skipAdd = false);
 	void appendText(const Common::String &str, int fontId = kMacFontChicago, int fontSize = 12, int fontSlant = kMacFontRegular, bool skipAdd = false);
@@ -220,6 +221,7 @@ public:
 	void addNewLine(int *row, int *col);
 	void insertChar(byte c, int *row, int *col);
 
+	void getChunkPosFromIndex(int index, uint &lineNum, uint &chunkNum, uint &offset);
 	void getRowCol(int x, int y, int *sx, int *sy, int *row, int *col);
 	Common::U32String getTextChunk(int startRow, int startCol, int endRow, int endCol, bool formatted = false, bool newlines = true);
 


Commit: ced3a58b103a67688ef811d26f8a9c72f0fee737
    https://github.com/scummvm/scummvm/commit/ced3a58b103a67688ef811d26f8a9c72f0fee737
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-06-30T16:29:00+02:00

Commit Message:
DIRECTOR: fix setting width and height to puppet sprites

Changed paths:
    engines/director/channel.cpp


diff --git a/engines/director/channel.cpp b/engines/director/channel.cpp
index e554e76766..a1a5692574 100644
--- a/engines/director/channel.cpp
+++ b/engines/director/channel.cpp
@@ -398,13 +398,13 @@ void Channel::replaceSprite(Sprite *nextSprite) {
 
 void Channel::setWidth(int w) {
 	if (_sprite->_puppet && _sprite->_stretch) {
-		_width = w;
+		_width = MAX<int>(w, 0);
 	}
 }
 
 void Channel::setHeight(int h) {
 	if (_sprite->_puppet && _sprite->_stretch) {
-		_height = h;
+		_height = MAX<int>(h, 0);
 	}
 }
 


Commit: d46866f893d1431336870e08bb165b91ab5ec944
    https://github.com/scummvm/scummvm/commit/d46866f893d1431336870e08bb165b91ab5ec944
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-06-30T16:29:00+02:00

Commit Message:
DIRECTOR: implement matte for quick draw shape

Changed paths:
    engines/director/sprite.cpp
    engines/director/sprite.h


diff --git a/engines/director/sprite.cpp b/engines/director/sprite.cpp
index e5f9afd3fd..f7455c5366 100644
--- a/engines/director/sprite.cpp
+++ b/engines/director/sprite.cpp
@@ -54,6 +54,7 @@ Sprite::Sprite(Frame *frame) {
 	_ink = kInkTypeCopy;
 	_trails = 0;
 
+	_matte = nullptr;
 	_cast = nullptr;
 
 	_thickness = 0;
@@ -73,6 +74,7 @@ Sprite::Sprite(Frame *frame) {
 }
 
 Sprite::~Sprite() {
+	delete _matte;
 }
 
 bool Sprite::isQDShape() {
@@ -118,6 +120,86 @@ bool Sprite::isActive() {
 			|| _movie->getScriptContext(kCastScript, _castId) != nullptr;
 }
 
+void Sprite::createQDMatte() {
+	Graphics::ManagedSurface tmp;
+	tmp.create(_width, _height, g_director->_pixelformat);
+	tmp.clear(g_director->_wm->_colorWhite);
+
+	MacShape *ms = new MacShape();
+
+	ms->ink = _ink;
+	ms->spriteType = _spriteType;
+	ms->foreColor = _foreColor;
+	ms->backColor = _backColor;
+	ms->lineSize = _thickness & 0x3;
+	ms->pattern = getPattern();
+
+	Common::Rect srcRect(_width, _height);
+
+	Common::Rect fillAreaRect((int)srcRect.width(), (int)srcRect.height());
+	Graphics::MacPlotData plotFill(&tmp, nullptr, &g_director->getPatterns(), ms->pattern, 0, 0, 1, ms->backColor);
+
+	Common::Rect strokeRect(MAX((int)srcRect.width() - ms->lineSize, 0), MAX((int)srcRect.height() - ms->lineSize, 0));
+	Graphics::MacPlotData plotStroke(&tmp, nullptr, &g_director->getPatterns(), 1, 0, 0, ms->lineSize, ms->backColor);
+
+	switch (_spriteType) {
+	case kRectangleSprite:
+		Graphics::drawFilledRect(fillAreaRect, g_director->_wm->_colorBlack, g_director->_wm->getDrawPixel(), &plotFill);
+		// fall through
+	case kOutlinedRectangleSprite:
+		Graphics::drawRect(strokeRect, g_director->_wm->_colorBlack, g_director->_wm->getDrawPixel(), &plotStroke);
+		break;
+	case kRoundedRectangleSprite:
+		Graphics::drawRoundRect(fillAreaRect, 12, g_director->_wm->_colorBlack, true, g_director->_wm->getDrawPixel(), &plotFill);
+		// fall through
+	case kOutlinedRoundedRectangleSprite:
+		Graphics::drawRoundRect(strokeRect, 12, g_director->_wm->_colorBlack, false, g_director->_wm->getDrawPixel(), &plotStroke);
+		break;
+	case kOvalSprite:
+		Graphics::drawEllipse(fillAreaRect.left, fillAreaRect.top, fillAreaRect.right, fillAreaRect.bottom, g_director->_wm->_colorBlack, true, g_director->_wm->getDrawPixel(), &plotFill);
+		// fall through
+	case kOutlinedOvalSprite:
+		Graphics::drawEllipse(strokeRect.left, strokeRect.top, strokeRect.right, strokeRect.bottom, g_director->_wm->_colorBlack, false, g_director->_wm->getDrawPixel(), &plotStroke);
+		break;
+	case kLineTopBottomSprite:
+		Graphics::drawLine(strokeRect.left, strokeRect.top, strokeRect.right, strokeRect.bottom, g_director->_wm->_colorBlack, g_director->_wm->getDrawPixel(), &plotStroke);
+		break;
+	case kLineBottomTopSprite:
+		Graphics::drawLine(strokeRect.left, strokeRect.bottom, strokeRect.right, strokeRect.top, g_director->_wm->_colorBlack, g_director->_wm->getDrawPixel(), &plotStroke);
+		break;
+	default:
+		warning("Sprite:createQDMatte Expected shape type but got type %d", _spriteType);
+	}
+
+	Graphics::Surface managedSurface;
+	managedSurface.create(_width, _height, g_director->_pixelformat);
+	managedSurface.copyFrom(tmp);
+
+	_matte = new Graphics::FloodFill(&managedSurface, g_director->_wm->_colorWhite, 0, true);
+
+	for (int yy = 0; yy < managedSurface.h; yy++) {
+		_matte->addSeed(0, yy);
+		_matte->addSeed(managedSurface.w - 1, yy);
+	}
+
+	for (int xx = 0; xx < managedSurface.w; xx++) {
+		_matte->addSeed(xx, 0);
+		_matte->addSeed(xx, managedSurface.h - 1);
+	}
+
+	_matte->fillMask();
+	tmp.free();
+	managedSurface.free();
+}
+
+Graphics::Surface *Sprite::getQDMatte() {
+	if (!isQDShape() || _ink != kInkTypeMatte)
+		return nullptr;
+	if (!_matte)
+		createQDMatte();
+	return _matte ? _matte->getMask() : nullptr;
+}
+
 bool Sprite::shouldHilite() {
 	if (!isActive())
 		return false;
diff --git a/engines/director/sprite.h b/engines/director/sprite.h
index 36df4750d5..02faa8651b 100644
--- a/engines/director/sprite.h
+++ b/engines/director/sprite.h
@@ -76,6 +76,8 @@ public:
 
 	void setCast(uint16 castid);
 	bool isQDShape();
+	Graphics::Surface *getQDMatte();
+	void createQDMatte();
 
 	Frame *_frame;
 	Score *_score;
@@ -83,7 +85,7 @@ public:
 
 	uint16 _scriptId;
 	uint16 _scriptCastIndex;
-	byte _colorcode;  // x40 editable, 0x80 moveable
+	byte _colorcode; // x40 editable, 0x80 moveable
 	byte _blendAmount;
 	uint32 _unk3;
 
@@ -98,6 +100,8 @@ public:
 	uint16 _pattern;
 	CastMember *_cast;
 
+	Graphics::FloodFill *_matte; // matte for quickdraw shape
+
 	byte _thickness;
 	Common::Point _startPoint;
 	int16 _width;


Commit: 7c147b16fbe451f39427759c3c19a112c49c381a
    https://github.com/scummvm/scummvm/commit/7c147b16fbe451f39427759c3c19a112c49c381a
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-06-30T16:29:00+02:00

Commit Message:
DIRECTOR: support QDshape matte for intersect and within check

Changed paths:
    engines/director/channel.cpp


diff --git a/engines/director/channel.cpp b/engines/director/channel.cpp
index a1a5692574..2e9548e67f 100644
--- a/engines/director/channel.cpp
+++ b/engines/director/channel.cpp
@@ -208,12 +208,19 @@ bool Channel::isMatteIntersect(Channel *channel) {
 	Common::Rect yourBbox = channel->getBbox();
 	Common::Rect intersectRect = myBbox.findIntersectingRect(yourBbox);
 
-	if (intersectRect.isEmpty() || !_sprite->_cast || _sprite->_cast->_type != kCastBitmap ||
-			!channel->_sprite->_cast || channel->_sprite->_cast->_type != kCastBitmap)
+	if (!myBbox.contains(yourBbox))
 		return false;
-
-	Graphics::Surface *myMatte = ((BitmapCastMember *)_sprite->_cast)->getMatte();
-	Graphics::Surface *yourMatte = ((BitmapCastMember *)channel->_sprite->_cast)->getMatte();
+	Graphics::Surface *myMatte = nullptr;
+	Graphics::Surface *yourMatte = nullptr;
+
+	if (_sprite->_cast && _sprite->_cast->_type == kCastBitmap)
+		myMatte = ((BitmapCastMember *)_sprite->_cast)->getMatte();
+	if (channel->_sprite->_cast && channel->_sprite->_cast->_type == kCastBitmap)
+		yourMatte = ((BitmapCastMember *)channel->_sprite->_cast)->getMatte();
+	if (_sprite->isQDShape())
+		myMatte = _sprite->getQDMatte();
+	if (channel->_sprite->isQDShape())
+		yourMatte = channel->_sprite->getQDMatte();
 
 	if (myMatte && yourMatte) {
 		for (int i = intersectRect.top; i < intersectRect.bottom; i++) {
@@ -229,17 +236,25 @@ bool Channel::isMatteIntersect(Channel *channel) {
 	return false;
 }
 
+// this contains channel. i.e. myBox contain yourBox
 bool Channel::isMatteWithin(Channel *channel) {
 	Common::Rect myBbox = getBbox();
 	Common::Rect yourBbox = channel->getBbox();
 	Common::Rect intersectRect = myBbox.findIntersectingRect(yourBbox);
 
-	if (!myBbox.contains(yourBbox) || !_sprite->_cast || _sprite->_cast->_type != kCastBitmap ||
-			!channel->_sprite->_cast || channel->_sprite->_cast->_type != kCastBitmap)
+	if (!myBbox.contains(yourBbox))
 		return false;
-
-	Graphics::Surface *myMatte = ((BitmapCastMember *)_sprite->_cast)->getMatte();
-	Graphics::Surface *yourMatte = ((BitmapCastMember *)channel->_sprite->_cast)->getMatte();
+	Graphics::Surface *myMatte = nullptr;
+	Graphics::Surface *yourMatte = nullptr;
+
+	if (_sprite->_cast && _sprite->_cast->_type == kCastBitmap)
+		myMatte = ((BitmapCastMember *)_sprite->_cast)->getMatte();
+	if (channel->_sprite->_cast && channel->_sprite->_cast->_type == kCastBitmap)
+		yourMatte = ((BitmapCastMember *)channel->_sprite->_cast)->getMatte();
+	if (_sprite->isQDShape())
+		myMatte = _sprite->getQDMatte();
+	if (channel->_sprite->isQDShape())
+		yourMatte = channel->_sprite->getQDMatte();
 
 	if (myMatte && yourMatte) {
 		for (int i = intersectRect.top; i < intersectRect.bottom; i++) {


Commit: 4a38579f44c9331d9dfddce1f67e6dbda0e988f2
    https://github.com/scummvm/scummvm/commit/4a38579f44c9331d9dfddce1f67e6dbda0e988f2
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-06-30T16:29:00+02:00

Commit Message:
DIRECTOR: don't regard quick draw shape as matte type

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


diff --git a/engines/director/lingo/lingo-code.cpp b/engines/director/lingo/lingo-code.cpp
index 08b48b81fa..c2f50d8089 100644
--- a/engines/director/lingo/lingo-code.cpp
+++ b/engines/director/lingo/lingo-code.cpp
@@ -843,7 +843,8 @@ void LC::c_intersects() {
 		return;
 	}
 
-	if (sprite1->_sprite->_ink == kInkTypeMatte && sprite2->_sprite->_ink == kInkTypeMatte) {
+	// don't regard quick draw shape as matte type
+	if ((!sprite1->_sprite->isQDShape() && sprite1->_sprite->_ink == kInkTypeMatte) && (!sprite2->_sprite->isQDShape() && sprite2->_sprite->_ink == kInkTypeMatte)) {
 		g_lingo->push(Datum(sprite2->isMatteIntersect(sprite1)));
 	} else {
 		g_lingo->push(Datum(sprite2->getBbox().intersects(sprite1->getBbox())));
@@ -863,7 +864,8 @@ void LC::c_within() {
 		return;
 	}
 
-	if (sprite1->_sprite->_ink == kInkTypeMatte && sprite2->_sprite->_ink == kInkTypeMatte) {
+	// don't regard quick draw shape as matte type
+	if ((!sprite1->_sprite->isQDShape() && sprite1->_sprite->_ink == kInkTypeMatte) && (!sprite2->_sprite->isQDShape() && sprite2->_sprite->_ink == kInkTypeMatte)) {
 		g_lingo->push(Datum(sprite2->isMatteWithin(sprite1)));
 	} else {
 		g_lingo->push(Datum(sprite2->getBbox().contains(sprite1->getBbox())));


Commit: 7eb039d174363ecafcba1a6a58872a70a8ad0d74
    https://github.com/scummvm/scummvm/commit/7eb039d174363ecafcba1a6a58872a70a8ad0d74
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-06-30T16:29:00+02:00

Commit Message:
DIRECTOR: fix intersect check. add 1 offset for constrain boundary

Changed paths:
    engines/director/channel.cpp


diff --git a/engines/director/channel.cpp b/engines/director/channel.cpp
index 2e9548e67f..5412f9e6ae 100644
--- a/engines/director/channel.cpp
+++ b/engines/director/channel.cpp
@@ -208,7 +208,7 @@ bool Channel::isMatteIntersect(Channel *channel) {
 	Common::Rect yourBbox = channel->getBbox();
 	Common::Rect intersectRect = myBbox.findIntersectingRect(yourBbox);
 
-	if (!myBbox.contains(yourBbox))
+	if (intersectRect.isEmpty())
 		return false;
 	Graphics::Surface *myMatte = nullptr;
 	Graphics::Surface *yourMatte = nullptr;
@@ -217,10 +217,6 @@ bool Channel::isMatteIntersect(Channel *channel) {
 		myMatte = ((BitmapCastMember *)_sprite->_cast)->getMatte();
 	if (channel->_sprite->_cast && channel->_sprite->_cast->_type == kCastBitmap)
 		yourMatte = ((BitmapCastMember *)channel->_sprite->_cast)->getMatte();
-	if (_sprite->isQDShape())
-		myMatte = _sprite->getQDMatte();
-	if (channel->_sprite->isQDShape())
-		yourMatte = channel->_sprite->getQDMatte();
 
 	if (myMatte && yourMatte) {
 		for (int i = intersectRect.top; i < intersectRect.bottom; i++) {
@@ -251,10 +247,6 @@ bool Channel::isMatteWithin(Channel *channel) {
 		myMatte = ((BitmapCastMember *)_sprite->_cast)->getMatte();
 	if (channel->_sprite->_cast && channel->_sprite->_cast->_type == kCastBitmap)
 		yourMatte = ((BitmapCastMember *)channel->_sprite->_cast)->getMatte();
-	if (_sprite->isQDShape())
-		myMatte = _sprite->getQDMatte();
-	if (channel->_sprite->isQDShape())
-		yourMatte = channel->_sprite->getQDMatte();
 
 	if (myMatte && yourMatte) {
 		for (int i = intersectRect.top; i < intersectRect.bottom; i++) {
@@ -543,6 +535,10 @@ void Channel::addDelta(Common::Point pos) {
 		constraintBbox.left += regPoint.x;
 		constraintBbox.right -= regPoint.x;
 
+		// offset for the boundary
+		constraintBbox.right++;
+		constraintBbox.bottom++;
+
 		if (!constraintBbox.contains(currentBbox)) {
 			if (currentBbox.top < constraintBbox.top) {
 				pos.y += constraintBbox.top - currentBbox.top;


Commit: c759e27fe766c4666ad2921c932d9b27fe872908
    https://github.com/scummvm/scummvm/commit/c759e27fe766c4666ad2921c932d9b27fe872908
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-06-30T16:29:00+02:00

Commit Message:
GRAPHICS: MACGUI: introduce _fixedDims to mactext, which represent for whether mactext should auto expanding.

Changed paths:
    graphics/macgui/mactext.cpp
    graphics/macgui/mactext.h


diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index f5996f821d..9218ee10fe 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -224,6 +224,8 @@ void MacText::init() {
 	_textMaxHeight = 0;
 	_surface = nullptr;
 
+	_fixedDims = true;
+
 	_selEnd = -1;
 	_selStart = -1;
 
@@ -955,6 +957,19 @@ void MacText::recalcDims() {
 	}
 
 	_textMaxHeight = y - _interLinear;
+
+	if (!_fixedDims) {
+		int newBottom = _dims.top + _textMaxHeight + (2 * _border) + _gutter + _shadow;
+		if (newBottom > _dims.bottom) {
+			_dims.bottom = newBottom;
+			delete _composeSurface;
+			_composeSurface = new ManagedSurface(_dims.width(), _dims.height(), _wm->_pixelformat);
+			reallocSurface();
+			_fullRefresh = true;
+			_contentIsDirty = true;
+			render();
+		}
+	}
 }
 
 void MacText::setAlignOffset(TextAlign align) {
diff --git a/graphics/macgui/mactext.h b/graphics/macgui/mactext.h
index fe9a91de99..15ec20192a 100644
--- a/graphics/macgui/mactext.h
+++ b/graphics/macgui/mactext.h
@@ -216,6 +216,9 @@ public:
 	void setText(const Common::U32String &str);
 	void setText(const Common::String &str);
 
+	void setFixDims(bool fixed) { _fixedDims = fixed; }
+	bool getFixDims() { return _fixedDims; }
+
 	void deleteSelection();
 	void deletePreviousChar(int *row, int *col);
 	void addNewLine(int *row, int *col);
@@ -302,6 +305,8 @@ protected:
 	int _interLinear;
 	int _textShadow;
 
+	bool _fixedDims;
+
 	int _selEnd;
 	int _selStart;
 


Commit: b2ea651b9da09875ecb58e0936fecc63b2b6c0eb
    https://github.com/scummvm/scummvm/commit/b2ea651b9da09875ecb58e0936fecc63b2b6c0eb
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-06-30T16:29:00+02:00

Commit Message:
DIRECTOR: auto expand text widgets for D3/4

Changed paths:
    engines/director/castmember.cpp
    engines/director/channel.cpp
    engines/director/channel.h


diff --git a/engines/director/castmember.cpp b/engines/director/castmember.cpp
index f28fe3f4e0..a673f35365 100644
--- a/engines/director/castmember.cpp
+++ b/engines/director/castmember.cpp
@@ -697,6 +697,8 @@ Graphics::MacWidget *TextCastMember::createWidget(Common::Rect &bbox, Channel *c
 	case kCastText:
 		// use initialRect for the dimensions just like button
 		widget = new Graphics::MacText(g_director->getCurrentWindow(), bbox.left, bbox.top, _initialRect.width(), _initialRect.height(), g_director->_wm, _ftext, macFont, getForeColor(), getBackColor(), _initialRect.width(), getAlignment(), 0, _borderSize, _gutterSize, _boxShadow, _textShadow, Common::kMacCentralEurope);
+		// D3/4, mactext will auto expand
+		((Graphics::MacText *)widget)->setFixDims(g_director->getVersion() <= 200);
 		((Graphics::MacText *)widget)->setSelRange(g_director->getCurrentMovie()->_selStart, g_director->getCurrentMovie()->_selEnd);
 		((Graphics::MacText *)widget)->setEditable(_editable);
 		((Graphics::MacText *)widget)->draw();
diff --git a/engines/director/channel.cpp b/engines/director/channel.cpp
index 5412f9e6ae..9de826fba5 100644
--- a/engines/director/channel.cpp
+++ b/engines/director/channel.cpp
@@ -28,6 +28,7 @@
 #include "director/channel.h"
 #include "director/sprite.h"
 #include "director/castmember.h"
+#include "director/window.h"
 
 #include "graphics/macgui/mactext.h"
 #include "graphics/macgui/macbutton.h"
@@ -329,12 +330,32 @@ void Channel::setClean(Sprite *nextSprite, int spriteId, bool partial) {
 		replaceWidget(previousCastId);
 	}
 
-	setEditable(_sprite->_editable);
+	updateTextCast();
 	updateGlobalAttr();
 
 	_dirty = false;
 }
 
+// this is used to for setting and updating text castmember
+// e.g. set editable, update dims for auto expanding
+void Channel::updateTextCast() {
+	if (!_sprite->_cast || _sprite->_cast->_type != kCastText)
+		return;
+	setEditable(_sprite->_editable);
+
+	if (_widget) {
+		Graphics::MacText *textWidget = (Graphics::MacText *)_widget;
+		// if we got auto expand text, then we update dims to sprite
+		if (!textWidget->getFixDims() && (_sprite->_width != _widget->_dims.width() || _sprite->_height != _widget->_dims.height())) {
+			_sprite->_width = _widget->_dims.width();
+			_sprite->_height = _widget->_dims.height();
+			_width = _sprite->_width;
+			_height = _sprite->_height;
+			g_director->getCurrentWindow()->addDirtyRect(_widget->_dims);
+		}
+	}
+}
+
 void Channel::setEditable(bool editable) {
 	if (_sprite->_cast && _sprite->_cast->_type == kCastText) {
 		// if the sprite is editable, then we refresh the selEnd and setStart
diff --git a/engines/director/channel.h b/engines/director/channel.h
index 7436478255..f03ff153e3 100644
--- a/engines/director/channel.h
+++ b/engines/director/channel.h
@@ -64,6 +64,7 @@ public:
 	void replaceSprite(Sprite *nextSprite);
 	void replaceWidget(uint16 previousCastId = 0);
 	bool updateWidget();
+	void updateTextCast();
 
 	void updateGlobalAttr();
 


Commit: 1d20fa758f730d84f6d5ee1dd619671a53dc7046
    https://github.com/scummvm/scummvm/commit/1d20fa758f730d84f6d5ee1dd619671a53dc7046
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-06-30T16:29:00+02:00

Commit Message:
DIRECTOR: don't hilite puppet sprites.

Changed paths:
    engines/director/sprite.cpp


diff --git a/engines/director/sprite.cpp b/engines/director/sprite.cpp
index f7455c5366..b3b4b48410 100644
--- a/engines/director/sprite.cpp
+++ b/engines/director/sprite.cpp
@@ -207,6 +207,9 @@ bool Sprite::shouldHilite() {
 	if (_moveable)
 		return false;
 
+	if (_puppet)
+		return false;
+
 	if (g_director->getVersion() < 400 && _ink == kInkTypeMatte)
 		return true;
 


Commit: 506ee5200aa8c7fc2a0773bb3bc395edb495f198
    https://github.com/scummvm/scummvm/commit/506ee5200aa8c7fc2a0773bb3bc395edb495f198
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-06-30T16:29:00+02:00

Commit Message:
DIRECTOR: removing changing original sprites when setting cast member.

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 061019922e..d0cb4af99a 100644
--- a/engines/director/lingo/lingo-the.cpp
+++ b/engines/director/lingo/lingo-the.cpp
@@ -1311,8 +1311,6 @@ void Lingo::setTheSprite(Datum &id1, int field, Datum &d) {
 			if (castId != sprite->_castId) {
 				g_director->getCurrentWindow()->addDirtyRect(channel->getBbox());
 				channel->setCast(castId);
-				// TODO: find the correct way to replace widget, instead of changing the original one.
-				score->getOriginalSpriteById(id)->setCast(castId);
 				channel->_dirty = true;
 			}
 		}


Commit: be199c07abe9395d5822dd8460ceb9e7ed88a4ac
    https://github.com/scummvm/scummvm/commit/be199c07abe9395d5822dd8460ceb9e7ed88a4ac
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-06-30T16:29:00+02:00

Commit Message:
DIRECTOR: more precise definition for shouldHilite for D3

Changed paths:
    engines/director/sprite.cpp


diff --git a/engines/director/sprite.cpp b/engines/director/sprite.cpp
index b3b4b48410..439122d1c9 100644
--- a/engines/director/sprite.cpp
+++ b/engines/director/sprite.cpp
@@ -210,8 +210,12 @@ bool Sprite::shouldHilite() {
 	if (_puppet)
 		return false;
 
-	if (g_director->getVersion() < 400 && _ink == kInkTypeMatte)
-		return true;
+	if (_ink == kInkTypeMatte) {
+		if (g_director->getVersion() < 300)
+			return true;
+		if (isQDShape())
+			return true;
+	}
 
 	if (_cast) {
 		// we have our own check for button, thus we don't need it here


Commit: b659c964f7925ee2ab58f70400e074639c99ed56
    https://github.com/scummvm/scummvm/commit/b659c964f7925ee2ab58f70400e074639c99ed56
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-06-30T16:29:00+02:00

Commit Message:
DIRECTOR: make debug output more readable

Changed paths:
    engines/director/cast.cpp


diff --git a/engines/director/cast.cpp b/engines/director/cast.cpp
index c79d216a77..78f1ce6d2a 100644
--- a/engines/director/cast.cpp
+++ b/engines/director/cast.cpp
@@ -1076,10 +1076,10 @@ void Cast::loadCastInfo(Common::SeekableReadStreamEndian &stream, uint16 id) {
 
 	InfoEntries castInfo = Movie::loadInfoEntries(stream, _version);
 
-	debugCN(4, kDebugLoading, "Cast::loadCastInfo(): str(%d): '", castInfo.strings.size());
+	debugCN(4, kDebugLoading, "Cast::loadCastInfo(): castId: %s str(%d): '", numToCastNum(id), castInfo.strings.size());
 
 	for (uint i = 0; i < castInfo.strings.size(); i++) {
-		debugCN(4, kDebugLoading, "%s'", castInfo.strings[i].readString().c_str());
+		debugCN(4, kDebugLoading, "%s'", Common::toPrintable(castInfo.strings[i].readString()).c_str());
 		if (i != castInfo.strings.size() - 1)
 			debugCN(4, kDebugLoading, ", '");
 	}


Commit: 202f6ce7e5c8904a160f03289db2cf683d966a1a
    https://github.com/scummvm/scummvm/commit/202f6ce7e5c8904a160f03289db2cf683d966a1a
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-06-30T16:29:00+02:00

Commit Message:
GRAPHICS: MACGUI: move set fixed dims to ctor for mactext

Changed paths:
    graphics/macgui/mactext.cpp
    graphics/macgui/mactext.h


diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index 9218ee10fe..d6496fa385 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -94,13 +94,14 @@ uint MacTextLine::getChunkNum(int *col) {
 }
 
 
-MacText::MacText(MacWidget *parent, int x, int y, int w, int h, MacWindowManager *wm, const Common::U32String &s, const MacFont *macFont, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, int interlinear, uint16 border, uint16 gutter, uint16 boxShadow, uint16 textShadow) :
+MacText::MacText(MacWidget *parent, int x, int y, int w, int h, MacWindowManager *wm, const Common::U32String &s, const MacFont *macFont, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, int interlinear, uint16 border, uint16 gutter, uint16 boxShadow, uint16 textShadow, bool fixedDims) :
 	MacWidget(parent, x, y, w, h, wm, true, border, gutter, boxShadow),
 	_macFont(macFont), _maxWidth(maxWidth), _textAlignment(textAlignment), _interLinear(interlinear) {
 
 	_str = s;
 	_fullRefresh = true;
 
+	_fixedDims = fixedDims;
 	_wm = wm;
 	_fgcolor = fgcolor;
 	_bgcolor = bgcolor;
@@ -119,12 +120,13 @@ MacText::MacText(MacWidget *parent, int x, int y, int w, int h, MacWindowManager
 	init();
 }
 
-MacText::MacText(MacWidget *parent, int x, int y, int w, int h, MacWindowManager *wm, const Common::String &s, const MacFont *macFont, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, int interlinear, uint16 border, uint16 gutter, uint16 boxShadow, uint16 textShadow, Common::CodePage encodeType) :
+MacText::MacText(MacWidget *parent, int x, int y, int w, int h, MacWindowManager *wm, const Common::String &s, const MacFont *macFont, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, int interlinear, uint16 border, uint16 gutter, uint16 boxShadow, uint16 textShadow, Common::CodePage encodeType, bool fixedDims) :
 	MacWidget(parent, x, y, w, h, wm, true, border, gutter, boxShadow),
 	_macFont(macFont), _maxWidth(maxWidth), _textAlignment(textAlignment), _interLinear(interlinear) {
 
 	_str = Common::U32String(s, encodeType);
 
+	_fixedDims = fixedDims;
 	_wm = wm;
 	_fgcolor = fgcolor;
 	_bgcolor = bgcolor;
@@ -144,12 +146,13 @@ MacText::MacText(MacWidget *parent, int x, int y, int w, int h, MacWindowManager
 }
 
 // NOTE: This constructor and the one afterward are for MacText engines that don't use widgets. This is the classic was MacText was constructed.
-MacText::MacText(const Common::U32String &s, MacWindowManager *wm, const MacFont *macFont, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, int interlinear) :
+MacText::MacText(const Common::U32String &s, MacWindowManager *wm, const MacFont *macFont, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, int interlinear, bool fixedDims) :
 	MacWidget(nullptr, 0, 0, 0, 0, wm, false, 0, 0, 0),
 	_macFont(macFont), _maxWidth(maxWidth), _textAlignment(textAlignment), _interLinear(interlinear) {
 
 	_str = s;
 
+	_fixedDims = fixedDims;
 	_wm = wm;
 	_fgcolor = fgcolor;
 	_bgcolor = bgcolor;
@@ -168,12 +171,13 @@ MacText::MacText(const Common::U32String &s, MacWindowManager *wm, const MacFont
 	init();
 }
 
-MacText::MacText(const Common::String &s, MacWindowManager *wm, const MacFont *macFont, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, int interlinear, Common::CodePage encodeType) :
+MacText::MacText(const Common::String &s, MacWindowManager *wm, const MacFont *macFont, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, int interlinear, Common::CodePage encodeType, bool fixedDims) :
 	MacWidget(nullptr, 0, 0, 0, 0, wm, false, 0, 0, 0),
 	_macFont(macFont), _maxWidth(maxWidth), _textAlignment(textAlignment), _interLinear(interlinear) {
 
 	_str = Common::U32String(s, encodeType);
 
+	_fixedDims = fixedDims;
 	_wm = wm;
 	_fgcolor = fgcolor;
 	_bgcolor = bgcolor;
@@ -193,12 +197,13 @@ MacText::MacText(const Common::String &s, MacWindowManager *wm, const MacFont *m
 }
 
 // Working with plain Font
-MacText::MacText(const Common::U32String &s, MacWindowManager *wm, const Font *font, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, int interlinear) :
+MacText::MacText(const Common::U32String &s, MacWindowManager *wm, const Font *font, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, int interlinear, bool fixedDims) :
 	MacWidget(nullptr, 0, 0, 0, 0, wm, false, 0, 0, 0),
 	_macFont(nullptr), _maxWidth(maxWidth), _textAlignment(textAlignment), _interLinear(interlinear) {
 
 	_str = s;
 
+	_fixedDims = fixedDims;
 	_wm = wm;
 	_fgcolor = fgcolor;
 	_bgcolor = bgcolor;
diff --git a/graphics/macgui/mactext.h b/graphics/macgui/mactext.h
index 15ec20192a..ee5dd133d6 100644
--- a/graphics/macgui/mactext.h
+++ b/graphics/macgui/mactext.h
@@ -145,14 +145,14 @@ struct SelectedText {
 
 class MacText : public MacWidget {
 public:
-	MacText(MacWidget *parent, int x, int y, int w, int h, MacWindowManager *wm, const Common::U32String &s, const MacFont *font, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment = kTextAlignLeft, int interlinear = 0, uint16 border = 0, uint16 gutter = 0, uint16 boxShadow = 0, uint16 textShadow = 0);
-	MacText(MacWidget *parent, int x, int y, int w, int h, MacWindowManager *wm, const Common::String &s, const MacFont *font, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment = kTextAlignLeft, int interlinear = 0, uint16 border = 0, uint16 gutter = 0, uint16 boxShadow = 0, uint16 textShadow = 0, Common::CodePage encodeType = Common::kMacCentralEurope);
+	MacText(MacWidget *parent, int x, int y, int w, int h, MacWindowManager *wm, const Common::U32String &s, const MacFont *font, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment = kTextAlignLeft, int interlinear = 0, uint16 border = 0, uint16 gutter = 0, uint16 boxShadow = 0, uint16 textShadow = 0, bool fixedDims = true);
+	MacText(MacWidget *parent, int x, int y, int w, int h, MacWindowManager *wm, const Common::String &s, const MacFont *font, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment = kTextAlignLeft, int interlinear = 0, uint16 border = 0, uint16 gutter = 0, uint16 boxShadow = 0, uint16 textShadow = 0, Common::CodePage encodeType = Common::kMacCentralEurope, bool fixedDims = true);
 	// 0 pixels between the lines by default
 
-	MacText(const Common::U32String &s, MacWindowManager *wm, const MacFont *font, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, int interlinear = 0);
-	MacText(const Common::String &s, MacWindowManager *wm, const MacFont *font, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, int interlinear = 0, Common::CodePage encodeType = Common::kMacCentralEurope);
+	MacText(const Common::U32String &s, MacWindowManager *wm, const MacFont *font, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, int interlinear = 0, bool fixedDims = true);
+	MacText(const Common::String &s, MacWindowManager *wm, const MacFont *font, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, int interlinear = 0, Common::CodePage encodeType = Common::kMacCentralEurope, bool fixedDims = true);
 
-	MacText(const Common::U32String &s, MacWindowManager *wm, const Font *font, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, int interlinear = 0);
+	MacText(const Common::U32String &s, MacWindowManager *wm, const Font *font, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, int interlinear = 0, bool fixedDims = true);
 
 	virtual ~MacText();
 


Commit: d0317fa1bbfa224f94f828cd9129082a39dd45d2
    https://github.com/scummvm/scummvm/commit/d0317fa1bbfa224f94f828cd9129082a39dd45d2
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-06-30T16:29:00+02:00

Commit Message:
DIRECTOR: use text style to determine whether text should fix dims

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


diff --git a/engines/director/castmember.cpp b/engines/director/castmember.cpp
index a673f35365..d576cb2c98 100644
--- a/engines/director/castmember.cpp
+++ b/engines/director/castmember.cpp
@@ -548,7 +548,7 @@ TextCastMember::TextCastMember(Cast *cast, uint16 castId, Common::SeekableReadSt
 		_borderSize = static_cast<SizeType>(stream.readByte());
 		_gutterSize = static_cast<SizeType>(stream.readByte());
 		_boxShadow = static_cast<SizeType>(stream.readByte());
-		byte pad1 = stream.readByte();
+		_textType = static_cast<TextType>(stream.readByte());
 		_textAlign = static_cast<TextAlignType>(stream.readUint16());
 		_bgpalinfo1 = stream.readUint16();
 		_bgpalinfo2 = stream.readUint16();
@@ -582,8 +582,8 @@ TextCastMember::TextCastMember(Cast *cast, uint16 castId, Common::SeekableReadSt
 			totalTextHeight = stream.readUint16();
 		}
 
-		debugC(2, kDebugLoading, "TextCastMember(): flags1: %d, border: %d gutter: %d shadow: %d pad1: %x align: %04x",
-				_flags1, _borderSize, _gutterSize, _boxShadow, pad1, _textAlign);
+		debugC(2, kDebugLoading, "TextCastMember(): flags1: %d, border: %d gutter: %d shadow: %d textType: %d align: %04x",
+				_flags1, _borderSize, _gutterSize, _boxShadow, _textType, _textAlign);
 		debugC(2, kDebugLoading, "TextCastMember(): background rgb: 0x%04x 0x%04x 0x%04x, pad2: %x pad3: %d pad4: %d shadow: %d flags: %d totHeight: %d",
 				_bgpalinfo1, _bgpalinfo2, _bgpalinfo3, pad2, pad3, pad4, _textShadow, _textFlags, totalTextHeight);
 		if (debugChannelSet(2, kDebugLoading)) {
@@ -695,10 +695,7 @@ Graphics::MacWidget *TextCastMember::createWidget(Common::Rect &bbox, Channel *c
 
 	switch (_type) {
 	case kCastText:
-		// use initialRect for the dimensions just like button
-		widget = new Graphics::MacText(g_director->getCurrentWindow(), bbox.left, bbox.top, _initialRect.width(), _initialRect.height(), g_director->_wm, _ftext, macFont, getForeColor(), getBackColor(), _initialRect.width(), getAlignment(), 0, _borderSize, _gutterSize, _boxShadow, _textShadow, Common::kMacCentralEurope);
-		// D3/4, mactext will auto expand
-		((Graphics::MacText *)widget)->setFixDims(g_director->getVersion() <= 200);
+		widget = new Graphics::MacText(g_director->getCurrentWindow(), bbox.left, bbox.top, bbox.width(), bbox.height(), g_director->_wm, _ftext, macFont, getForeColor(), getBackColor(), _initialRect.width(), getAlignment(), 0, _borderSize, _gutterSize, _boxShadow, _textShadow, Common::kMacCentralEurope, _textType == kTextTypeFixed);
 		((Graphics::MacText *)widget)->setSelRange(g_director->getCurrentMovie()->_selStart, g_director->getCurrentMovie()->_selEnd);
 		((Graphics::MacText *)widget)->setEditable(_editable);
 		((Graphics::MacText *)widget)->draw();
diff --git a/engines/director/channel.cpp b/engines/director/channel.cpp
index 9de826fba5..1bf3c0e48d 100644
--- a/engines/director/channel.cpp
+++ b/engines/director/channel.cpp
@@ -406,6 +406,7 @@ void Channel::replaceSprite(Sprite *nextSprite) {
 
 	*_sprite = *nextSprite;
 
+	// TODO: auto expand text size is meaning less for us, not all text
 	// since we are using initialRect for the text cast member now, then the sprite size is meaning less for us.
 	// thus, we keep the _sprite size here
 	if (hasTextCastMember(_sprite) && widgetKeeped) {
diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index d6496fa385..fd6b53801c 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -229,8 +229,6 @@ void MacText::init() {
 	_textMaxHeight = 0;
 	_surface = nullptr;
 
-	_fixedDims = true;
-
 	_selEnd = -1;
 	_selStart = -1;
 
@@ -970,9 +968,12 @@ void MacText::recalcDims() {
 			delete _composeSurface;
 			_composeSurface = new ManagedSurface(_dims.width(), _dims.height(), _wm->_pixelformat);
 			reallocSurface();
+			if (!_fullRefresh) {
+				_fullRefresh = true;
+				render();
+			}
 			_fullRefresh = true;
 			_contentIsDirty = true;
-			render();
 		}
 	}
 }


Commit: bcd33eeba34a40362b8bd9ab57acf060ea5ac29b
    https://github.com/scummvm/scummvm/commit/bcd33eeba34a40362b8bd9ab57acf060ea5ac29b
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-06-30T16:29:00+02:00

Commit Message:
DIRECTOR: fix rendering text to suit for different style text

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


diff --git a/engines/director/channel.cpp b/engines/director/channel.cpp
index 1bf3c0e48d..47d498d229 100644
--- a/engines/director/channel.cpp
+++ b/engines/director/channel.cpp
@@ -392,7 +392,7 @@ void Channel::replaceSprite(Sprite *nextSprite) {
 		return;
 
 	bool newSprite = (_sprite->_spriteType == kInactiveSprite && nextSprite->_spriteType != kInactiveSprite);
-	bool widgetKeeped = true;
+	bool widgetKeeped = _sprite->_cast && _widget;
 
 	// update the _sprite we stored in channel, and point the originalSprite to the new one
 	// release the widget, because we may having the new one
diff --git a/engines/director/sprite.cpp b/engines/director/sprite.cpp
index 439122d1c9..5e0b241484 100644
--- a/engines/director/sprite.cpp
+++ b/engines/director/sprite.cpp
@@ -287,7 +287,7 @@ void Sprite::setCast(uint16 castId) {
 
 		// TODO: Respect sprite width/height settings. Need to determine how to read
 		// them properly.
-		if (_cast->_type != kCastShape) {
+		if (_cast->_type != kCastShape && _cast->_type != kCastText) {
 			Common::Rect dims = _cast->getInitialRect();
 			_width = dims.width();
 			_height = dims.height();
diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index fd6b53801c..28c6d52413 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -229,6 +229,9 @@ void MacText::init() {
 	_textMaxHeight = 0;
 	_surface = nullptr;
 
+	if (!_fixedDims)
+		_dims.right = MAX<int>(_dims.right, _dims.left + _maxWidth + (2 * _border) + (2 * _gutter) + _shadow);
+
 	_selEnd = -1;
 	_selStart = -1;
 


Commit: d11835cffca6baf1c474ea5971c20a6e190e8038
    https://github.com/scummvm/scummvm/commit/d11835cffca6baf1c474ea5971c20a6e190e8038
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-06-30T16:29:00+02:00

Commit Message:
DIRECTOR: implement immediateSprite.

Changed paths:
    engines/director/lingo/lingo-builtins.cpp
    engines/director/lingo/lingo-builtins.h


diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp
index 782e1346e1..5aa2eca4d4 100644
--- a/engines/director/lingo/lingo-builtins.cpp
+++ b/engines/director/lingo/lingo-builtins.cpp
@@ -226,6 +226,7 @@ static struct BuiltinProto {
 	{ "unLoadCast",		LB::b_unLoadCast,	0, 2, false, 300, CBLTIN },	//		D3.1 c
 	{ "updateStage",	LB::b_updateStage,	0, 0, false, 200, CBLTIN },	// D2 c
 	{ "zoomBox",		LB::b_zoomBox,		-1,0, false, 200, CBLTIN },	// D2 c
+	{"immediateSprite", LB::b_immediateSprite, -1, 0, false, 200, CBLTIN}, // D2 c
 	// Point
 	{ "point",			LB::b_point,		2, 2, true,  400, FBLTIN },	//			D4 f
 	{ "inside",			LB::b_inside,		2, 2, true,  400, FBLTIN },	//			D4 f
@@ -1899,6 +1900,48 @@ void LB::b_puppetSound(int nargs) {
 	sound->playCastMember(castId, channel);
 }
 
+void LB::b_immediateSprite(int nargs) {
+	Score *sc = g_director->getCurrentMovie()->getScore();
+	if (!sc) {
+		warning("b_immediateSprite: no score");
+		g_lingo->dropStack(nargs);
+		return;
+	}
+
+	if (nargs == 2) {
+		Datum state = g_lingo->pop();
+		Datum sprite = g_lingo->pop();
+
+		Sprite *sp = sc->getSpriteById(sprite.asInt());
+		if ((uint)sprite.asInt() < sc->_channels.size()) {
+			if (sc->getNextFrame() && !sp->_immediate) {
+				// same as puppetSprite
+				Channel *channel = sc->getChannelById(sprite.asInt());
+
+				channel->replaceSprite(sc->_frames[sc->getNextFrame()]->_sprites[sprite.asInt()]);
+				channel->_dirty = true;
+			}
+
+			sc->getSpriteById(sprite.asInt())->_immediate = (bool)state.asInt();
+			sc->getOriginalSpriteById(sprite.asInt())->_immediate = (bool)state.asInt();
+		} else {
+			warning("b_immediateSprite: sprite index out of bounds");
+		}
+	} else if (nargs == 0 && g_director->getVersion() < 400) {
+		g_lingo->dropStack(nargs);
+
+		if (g_lingo->_currentChannelId == -1) {
+			warning("b_immediateSprite: channel Id is missing");
+			return;
+		}
+		sc->getSpriteById(g_lingo->_currentChannelId)->_immediate = true;
+		sc->getOriginalSpriteById(g_lingo->_currentChannelId)->_immediate = true;
+	} else {
+		warning("b_immediateSprite: unexpectedly received %d arguments", nargs);
+		g_lingo->dropStack(nargs);
+	}
+}
+
 void LB::b_puppetSprite(int nargs) {
 	Score *sc = g_director->getCurrentMovie()->getScore();
 	if (!sc) {
diff --git a/engines/director/lingo/lingo-builtins.h b/engines/director/lingo/lingo-builtins.h
index 9ef1e7b67b..a7819e9d6a 100644
--- a/engines/director/lingo/lingo-builtins.h
+++ b/engines/director/lingo/lingo-builtins.h
@@ -122,6 +122,7 @@ void b_unLoad(int nargs);
 void b_unLoadCast(int nargs);
 void b_updateStage(int nargs);
 void b_zoomBox(int nargs);
+void b_immediateSprite(int nargs);
 
 void b_abort(int nargs);
 void b_continue(int nargs);


Commit: f9014d0381746a57b460a81357fb00dfd5f6fddc
    https://github.com/scummvm/scummvm/commit/f9014d0381746a57b460a81357fb00dfd5f6fddc
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-06-30T16:29:00+02:00

Commit Message:
DIRECTOR: remove changing original sprites in immediateSprite and puppetSprite

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


diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp
index 5aa2eca4d4..142db50cbb 100644
--- a/engines/director/lingo/lingo-builtins.cpp
+++ b/engines/director/lingo/lingo-builtins.cpp
@@ -1923,7 +1923,6 @@ void LB::b_immediateSprite(int nargs) {
 			}
 
 			sc->getSpriteById(sprite.asInt())->_immediate = (bool)state.asInt();
-			sc->getOriginalSpriteById(sprite.asInt())->_immediate = (bool)state.asInt();
 		} else {
 			warning("b_immediateSprite: sprite index out of bounds");
 		}
@@ -1935,7 +1934,6 @@ void LB::b_immediateSprite(int nargs) {
 			return;
 		}
 		sc->getSpriteById(g_lingo->_currentChannelId)->_immediate = true;
-		sc->getOriginalSpriteById(g_lingo->_currentChannelId)->_immediate = true;
 	} else {
 		warning("b_immediateSprite: unexpectedly received %d arguments", nargs);
 		g_lingo->dropStack(nargs);
@@ -1966,7 +1964,6 @@ void LB::b_puppetSprite(int nargs) {
 			}
 
 			sc->getSpriteById(sprite.asInt())->_puppet = (bool)state.asInt();
-			sc->getOriginalSpriteById(sprite.asInt())->_puppet = (bool)state.asInt();
 		} else {
 			warning("b_puppetSprite: sprite index out of bounds");
 		}
@@ -1978,7 +1975,6 @@ void LB::b_puppetSprite(int nargs) {
 			return;
 		}
 		sc->getSpriteById(g_lingo->_currentChannelId)->_puppet = true;
-		sc->getOriginalSpriteById(g_lingo->_currentChannelId)->_puppet = true;
 	} else {
 		warning("b_puppetSprite: unexpectedly received %d arguments", nargs);
 		g_lingo->dropStack(nargs);


Commit: bd0da46c2fb0e999140217987a28dff79d2601ed
    https://github.com/scummvm/scummvm/commit/bd0da46c2fb0e999140217987a28dff79d2601ed
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-06-30T16:29:00+02:00

Commit Message:
DIRECTOR: fix size parameter passing when we have auto expand text

Changed paths:
    engines/director/castmember.cpp


diff --git a/engines/director/castmember.cpp b/engines/director/castmember.cpp
index d576cb2c98..68ec6ec93c 100644
--- a/engines/director/castmember.cpp
+++ b/engines/director/castmember.cpp
@@ -692,10 +692,16 @@ void TextCastMember::importStxt(const Stxt *stxt) {
 Graphics::MacWidget *TextCastMember::createWidget(Common::Rect &bbox, Channel *channel) {
 	Graphics::MacFont *macFont = new Graphics::MacFont(_fontId, _fontSize, _textSlant);
 	Graphics::MacWidget *widget = nullptr;
+	Common::Rect dims(bbox);
 
 	switch (_type) {
 	case kCastText:
-		widget = new Graphics::MacText(g_director->getCurrentWindow(), bbox.left, bbox.top, bbox.width(), bbox.height(), g_director->_wm, _ftext, macFont, getForeColor(), getBackColor(), _initialRect.width(), getAlignment(), 0, _borderSize, _gutterSize, _boxShadow, _textShadow, Common::kMacCentralEurope, _textType == kTextTypeFixed);
+		// for mactext, we can expand now, but we can't shrink. so we may pass the small size when we have adjustToFit text style
+		if (_textType == kTextTypeAdjustToFit) {
+			dims.right = MIN<int>(dims.right, dims.left + _initialRect.width());
+			dims.bottom = MIN<int>(dims.bottom, dims.top + _initialRect.height());
+		}
+		widget = new Graphics::MacText(g_director->getCurrentWindow(), bbox.left, bbox.top, dims.width(), dims.height(), g_director->_wm, _ftext, macFont, getForeColor(), getBackColor(), _initialRect.width(), getAlignment(), 0, _borderSize, _gutterSize, _boxShadow, _textShadow, Common::kMacCentralEurope, _textType == kTextTypeFixed);
 		((Graphics::MacText *)widget)->setSelRange(g_director->getCurrentMovie()->_selStart, g_director->getCurrentMovie()->_selEnd);
 		((Graphics::MacText *)widget)->setEditable(_editable);
 		((Graphics::MacText *)widget)->draw();


Commit: 1945e3ec5cc45d0791be7b0a17e8e9a5c1320c2a
    https://github.com/scummvm/scummvm/commit/1945e3ec5cc45d0791be7b0a17e8e9a5c1320c2a
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-06-30T16:29:00+02:00

Commit Message:
GRAPHICS: MACGUI: realloc surface after changing dims

Changed paths:
    graphics/macgui/mactext.cpp


diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index 28c6d52413..407637e728 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -229,8 +229,14 @@ void MacText::init() {
 	_textMaxHeight = 0;
 	_surface = nullptr;
 
-	if (!_fixedDims)
+	if (!_fixedDims) {
+		int right = _dims.right;
 		_dims.right = MAX<int>(_dims.right, _dims.left + _maxWidth + (2 * _border) + (2 * _gutter) + _shadow);
+		if (right != _dims.right) {
+			delete _composeSurface;
+			_composeSurface = new ManagedSurface(_dims.width(), _dims.height(), _wm->_pixelformat);
+		}
+	}
 
 	_selEnd = -1;
 	_selStart = -1;




More information about the Scummvm-git-logs mailing list