[Scummvm-git-logs] scummvm master -> 23b6dbbede9a1990e30d48d90af5017e8b7dd473

sev- sev at scummvm.org
Sun Apr 30 09:48:17 CEST 2017


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

Summary:
af664fe757 GRAPHICS: Use MacFont in lieu of Graphics::Font in MacText
ed2f09b13f GRAPHICS: Delete MacFont in MacText
b6eb8a1a66 DIRECTOR: consolidate font, width instructions in renderText
132785ccb0 DIRECTOR: clean up renderText: move warning block down
03831698ac DIRECTOR: remove redundant/ineffective assignments to width
23b6dbbede DIRECTOR: clean up renderText: separate reading & actual rendering


Commit: af664fe757b0834e011e93420911428b361c516e
    https://github.com/scummvm/scummvm/commit/af664fe757b0834e011e93420911428b361c516e
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2017-04-30T09:48:08+02:00

Commit Message:
GRAPHICS: Use MacFont in lieu of Graphics::Font in MacText

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


diff --git a/engines/director/frame.cpp b/engines/director/frame.cpp
index ba5b903..3b3c1ff 100644
--- a/engines/director/frame.cpp
+++ b/engines/director/frame.cpp
@@ -846,11 +846,10 @@ void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteId, Commo
 		return;
 	}
 
-	Graphics::MacFont macFont = Graphics::MacFont(textCast->fontId, textCast->fontSize, textCast->textSlant);
+	Graphics::MacFont *macFont = new Graphics::MacFont(textCast->fontId, textCast->fontSize, textCast->textSlant);
+	// TODO: MacText must destroy me
 
-	const Graphics::Font *font = _vm->_wm->_fontMan->getFont(macFont);
-
-	debugC(3, kDebugText, "renderText: x: %d y: %d w: %d h: %d font: '%s'", x, y, width, height, _vm->_wm->_fontMan->getFontName(macFont));
+	debugC(3, kDebugText, "renderText: x: %d y: %d w: %d h: %d font: '%s'", x, y, width, height, _vm->_wm->_fontMan->getFontName(*macFont));
 
 	int alignment = (int)textCast->textAlign;
 	if (alignment == -1)
@@ -866,7 +865,7 @@ void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteId, Commo
 		}
 	}
 
-	Graphics::MacText mt(ftext, _vm->_wm, font, 0x00, 0xff, width, (Graphics::TextAlign)alignment);
+	Graphics::MacText mt(ftext, _vm->_wm, macFont, 0x00, 0xff, width, (Graphics::TextAlign)alignment);
 	mt.setInterLinear(1);
 	mt.render();
 	const Graphics::ManagedSurface *textSurface = mt.getSurface();
diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index 180b081..9dcb380 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -37,10 +37,10 @@ const Font *MacFontRun::getFont() {
 	return font;
 }
 
-MacText::MacText(Common::String s, MacWindowManager *wm, const Font *font, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment) {
+MacText::MacText(Common::String s, MacWindowManager *wm, const MacFont *macFont, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment) {
 	_str = s;
 	_wm = wm;
-	_font = font;
+	_macFont = macFont;
 	_fgcolor = fgcolor;
 	_bgcolor = bgcolor;
 	_maxWidth = maxWidth;
@@ -51,7 +51,12 @@ MacText::MacText(Common::String s, MacWindowManager *wm, const Font *font, int f
 
 	_interLinear = 0; // 0 pixels between the lines by default
 
-	_defaultFormatting.font = font;
+	if (macFont) {
+		_defaultFormatting.font = wm->_fontMan->getFont(*macFont);
+	} else {
+		_defaultFormatting.font = NULL;
+	}
+
 	_defaultFormatting.wm = wm;
 
 	_currentFormatting = _defaultFormatting;
diff --git a/graphics/macgui/mactext.h b/graphics/macgui/mactext.h
index 85c8559..c9d24a0 100644
--- a/graphics/macgui/mactext.h
+++ b/graphics/macgui/mactext.h
@@ -88,7 +88,7 @@ struct MacTextLine {
 
 class MacText {
 public:
-	MacText(Common::String s, MacWindowManager *wm, const Graphics::Font *font, int fgcolor, int bgcolor,
+	MacText(Common::String s, MacWindowManager *wm, const MacFont *font, int fgcolor, int bgcolor,
 				int maxWidth = -1, TextAlign textAlignment = kTextAlignLeft);
 
 	void setInterLinear(int interLinear);
@@ -113,7 +113,7 @@ private:
 	MacWindowManager *_wm;
 
 	Common::String _str;
-	const Graphics::Font *_font;
+	const MacFont *_macFont;
 	int _fgcolor, _bgcolor;
 
 	int _maxWidth;


Commit: ed2f09b13f31f4d9c372c2d7f8f0f66d7acb854d
    https://github.com/scummvm/scummvm/commit/ed2f09b13f31f4d9c372c2d7f8f0f66d7acb854d
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2017-04-30T09:48:08+02:00

Commit Message:
GRAPHICS: Delete MacFont in MacText

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


diff --git a/engines/director/frame.cpp b/engines/director/frame.cpp
index 3b3c1ff..49c755c 100644
--- a/engines/director/frame.cpp
+++ b/engines/director/frame.cpp
@@ -847,7 +847,6 @@ void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteId, Commo
 	}
 
 	Graphics::MacFont *macFont = new Graphics::MacFont(textCast->fontId, textCast->fontSize, textCast->textSlant);
-	// TODO: MacText must destroy me
 
 	debugC(3, kDebugText, "renderText: x: %d y: %d w: %d h: %d font: '%s'", x, y, width, height, _vm->_wm->_fontMan->getFontName(*macFont));
 
diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index 9dcb380..62c4e8e 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -37,6 +37,11 @@ const Font *MacFontRun::getFont() {
 	return font;
 }
 
+
+MacText::~MacText(){
+	delete _macFont;
+}
+
 MacText::MacText(Common::String s, MacWindowManager *wm, const MacFont *macFont, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment) {
 	_str = s;
 	_wm = wm;
diff --git a/graphics/macgui/mactext.h b/graphics/macgui/mactext.h
index c9d24a0..25f6002 100644
--- a/graphics/macgui/mactext.h
+++ b/graphics/macgui/mactext.h
@@ -90,7 +90,7 @@ class MacText {
 public:
 	MacText(Common::String s, MacWindowManager *wm, const MacFont *font, int fgcolor, int bgcolor,
 				int maxWidth = -1, TextAlign textAlignment = kTextAlignLeft);
-
+	~MacText();
 	void setInterLinear(int interLinear);
 
 	void draw(ManagedSurface *g, int x, int y, int w, int h, int xoff, int yoff);


Commit: b6eb8a1a6697ba068590e50164cb5e4f37a1c1df
    https://github.com/scummvm/scummvm/commit/b6eb8a1a6697ba068590e50164cb5e4f37a1c1df
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2017-04-30T09:48:08+02:00

Commit Message:
DIRECTOR: consolidate font, width instructions in renderText

Changed paths:
    engines/director/frame.cpp


diff --git a/engines/director/frame.cpp b/engines/director/frame.cpp
index 49c755c..8911a60 100644
--- a/engines/director/frame.cpp
+++ b/engines/director/frame.cpp
@@ -742,6 +742,38 @@ void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteId, Commo
 		return;
 
 	TextCast *textCast = _sprites[spriteId]->_buttonCast != nullptr ? (TextCast*)_sprites[spriteId]->_buttonCast : _sprites[spriteId]->_textCast;
+	int x = _sprites[spriteId]->_startPoint.x; // +rectLeft;
+	int y = _sprites[spriteId]->_startPoint.y; // +rectTop;
+	int height = textCast->initialRect.height(); //_sprites[spriteId]->_height;
+	int width;
+
+	if (_vm->getVersion() >= 4 && textSize != NULL)
+		width = textCast->initialRect.right;
+	else
+		width = textCast->initialRect.width(); //_sprites[spriteId]->_width;
+
+	if (width == 0 || height == 0) {
+		warning("renderText: Requested to draw on an empty surface: %d x %d", width, height);
+		return;
+	}
+
+	if (_vm->getVersion() >= 4) {
+		if (textSize == NULL)
+			width = textCast->initialRect.right;
+		else {
+			width = textSize->width();
+		}
+	}
+
+	if (_vm->getCurrentScore()->_fontMap.contains(textCast->fontId)) {
+		// We need to make sure that the Shared Cast fonts have been loaded in?
+		// might need a mapping table here of our own.
+		// textCast->fontId = _vm->_wm->_fontMan->getFontIdByName(_vm->getCurrentScore()->_fontMap[textCast->fontId]);
+	}
+
+	Graphics::MacFont* macFont = new Graphics::MacFont(textCast->fontId, textCast->fontSize, textCast->textSlant);
+
+	debugC(3, kDebugText, "renderText: x: %d y: %d w: %d h: %d font: '%s'", x, y, width, height, _vm->_wm->_fontMan->getFontName(*macFont));
 
 	uint32 unk1 = textStream->readUint32();
 	uint32 strLen = textStream->readUint32();
@@ -827,28 +859,6 @@ void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteId, Commo
 	//uint32 rectLeft = textCast->initialRect.left;
 	//uint32 rectTop = textCast->initialRect.top;
 
-	int x = _sprites[spriteId]->_startPoint.x; // +rectLeft;
-	int y = _sprites[spriteId]->_startPoint.y; // +rectTop;
-	int height = textCast->initialRect.height(); //_sprites[spriteId]->_height;
-	int width = textCast->initialRect.width(); //_sprites[spriteId]->_width;
-
-	if (_vm->getVersion() >= 4 && textSize != NULL)
-		width = textCast->initialRect.right;
-
-	if (_vm->getCurrentScore()->_fontMap.contains(textCast->fontId)) {
-		// We need to make sure that the Shared Cast fonts have been loaded in?
-		// might need a mapping table here of our own.
-		// textCast->fontId = _vm->_wm->_fontMan->getFontIdByName(_vm->getCurrentScore()->_fontMap[textCast->fontId]);
-	}
-
-	if (width == 0 || height == 0) {
-		warning("renderText: Requested to draw on an empty surface: %d x %d", width, height);
-		return;
-	}
-
-	Graphics::MacFont *macFont = new Graphics::MacFont(textCast->fontId, textCast->fontSize, textCast->textSlant);
-
-	debugC(3, kDebugText, "renderText: x: %d y: %d w: %d h: %d font: '%s'", x, y, width, height, _vm->_wm->_fontMan->getFontName(*macFont));
 
 	int alignment = (int)textCast->textAlign;
 	if (alignment == -1)
@@ -856,14 +866,6 @@ void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteId, Commo
 	else
 		alignment++;
 
-	if (_vm->getVersion() >= 4) {
-		if (textSize == NULL)
-			width = textCast->initialRect.right;
-		else {
-			width = textSize->width();
-		}
-	}
-
 	Graphics::MacText mt(ftext, _vm->_wm, macFont, 0x00, 0xff, width, (Graphics::TextAlign)alignment);
 	mt.setInterLinear(1);
 	mt.render();


Commit: 132785ccb05db73da8d4cbe420acf55e2bc9e581
    https://github.com/scummvm/scummvm/commit/132785ccb05db73da8d4cbe420acf55e2bc9e581
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2017-04-30T09:48:08+02:00

Commit Message:
DIRECTOR: clean up renderText: move warning block down

This changes slightly the semantics of the method; however, I assume we
want to print (or not) the warning based on the width/height values that
will in fact be used *in* the method.

Changed paths:
    engines/director/frame.cpp


diff --git a/engines/director/frame.cpp b/engines/director/frame.cpp
index 8911a60..30be867 100644
--- a/engines/director/frame.cpp
+++ b/engines/director/frame.cpp
@@ -752,11 +752,6 @@ void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteId, Commo
 	else
 		width = textCast->initialRect.width(); //_sprites[spriteId]->_width;
 
-	if (width == 0 || height == 0) {
-		warning("renderText: Requested to draw on an empty surface: %d x %d", width, height);
-		return;
-	}
-
 	if (_vm->getVersion() >= 4) {
 		if (textSize == NULL)
 			width = textCast->initialRect.right;
@@ -771,7 +766,12 @@ void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteId, Commo
 		// textCast->fontId = _vm->_wm->_fontMan->getFontIdByName(_vm->getCurrentScore()->_fontMap[textCast->fontId]);
 	}
 
-	Graphics::MacFont* macFont = new Graphics::MacFont(textCast->fontId, textCast->fontSize, textCast->textSlant);
+	if (width == 0 || height == 0) {
+		warning("renderText: Requested to draw on an empty surface: %d x %d", width, height);
+		return;
+	}
+
+	Graphics::MacFont *macFont = new Graphics::MacFont(textCast->fontId, textCast->fontSize, textCast->textSlant);
 
 	debugC(3, kDebugText, "renderText: x: %d y: %d w: %d h: %d font: '%s'", x, y, width, height, _vm->_wm->_fontMan->getFontName(*macFont));
 


Commit: 03831698ac508a4cb210fb6835565782f7a49a08
    https://github.com/scummvm/scummvm/commit/03831698ac508a4cb210fb6835565782f7a49a08
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2017-04-30T09:48:08+02:00

Commit Message:
DIRECTOR: remove redundant/ineffective assignments to width

Changed paths:
    engines/director/frame.cpp


diff --git a/engines/director/frame.cpp b/engines/director/frame.cpp
index 30be867..ec22cc1 100644
--- a/engines/director/frame.cpp
+++ b/engines/director/frame.cpp
@@ -747,17 +747,14 @@ void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteId, Commo
 	int height = textCast->initialRect.height(); //_sprites[spriteId]->_height;
 	int width;
 
-	if (_vm->getVersion() >= 4 && textSize != NULL)
-		width = textCast->initialRect.right;
-	else
-		width = textCast->initialRect.width(); //_sprites[spriteId]->_width;
-
 	if (_vm->getVersion() >= 4) {
 		if (textSize == NULL)
 			width = textCast->initialRect.right;
 		else {
 			width = textSize->width();
 		}
+	} else {
+		width = textCast->initialRect.width(); //_sprites[spriteId]->_width;
 	}
 
 	if (_vm->getCurrentScore()->_fontMap.contains(textCast->fontId)) {


Commit: 23b6dbbede9a1990e30d48d90af5017e8b7dd473
    https://github.com/scummvm/scummvm/commit/23b6dbbede9a1990e30d48d90af5017e8b7dd473
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2017-04-30T09:48:08+02:00

Commit Message:
DIRECTOR: clean up renderText: separate reading & actual rendering

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


diff --git a/engines/director/frame.cpp b/engines/director/frame.cpp
index ec22cc1..0caaf59 100644
--- a/engines/director/frame.cpp
+++ b/engines/director/frame.cpp
@@ -737,41 +737,10 @@ void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteId, uint1
 	renderText(surface, spriteId, textStream, NULL);
 }
 
-void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteId, Common::SeekableSubReadStreamEndian *textStream, Common::Rect *textSize) {
-	if (textStream == NULL)
-		return;
-
-	TextCast *textCast = _sprites[spriteId]->_buttonCast != nullptr ? (TextCast*)_sprites[spriteId]->_buttonCast : _sprites[spriteId]->_textCast;
-	int x = _sprites[spriteId]->_startPoint.x; // +rectLeft;
-	int y = _sprites[spriteId]->_startPoint.y; // +rectTop;
-	int height = textCast->initialRect.height(); //_sprites[spriteId]->_height;
-	int width;
-
-	if (_vm->getVersion() >= 4) {
-		if (textSize == NULL)
-			width = textCast->initialRect.right;
-		else {
-			width = textSize->width();
-		}
-	} else {
-		width = textCast->initialRect.width(); //_sprites[spriteId]->_width;
-	}
-
-	if (_vm->getCurrentScore()->_fontMap.contains(textCast->fontId)) {
-		// We need to make sure that the Shared Cast fonts have been loaded in?
-		// might need a mapping table here of our own.
-		// textCast->fontId = _vm->_wm->_fontMan->getFontIdByName(_vm->getCurrentScore()->_fontMap[textCast->fontId]);
-	}
-
-	if (width == 0 || height == 0) {
-		warning("renderText: Requested to draw on an empty surface: %d x %d", width, height);
-		return;
-	}
-
-	Graphics::MacFont *macFont = new Graphics::MacFont(textCast->fontId, textCast->fontSize, textCast->textSlant);
-
-	debugC(3, kDebugText, "renderText: x: %d y: %d w: %d h: %d font: '%s'", x, y, width, height, _vm->_wm->_fontMan->getFontName(*macFont));
-
+Common::String Frame::readTextStream(Common::SeekableSubReadStreamEndian *textStream, TextCast *textCast) {
+	// TODO: move me somewhere more appropriate
+	// TODO: remove ugly side effects on textStream?
+	Common::String ftext;
 	uint32 unk1 = textStream->readUint32();
 	uint32 strLen = textStream->readUint32();
 	uint32 dataLen = textStream->readUint32();
@@ -785,8 +754,6 @@ void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteId, Commo
 		text += ch;
 	}
 
-	Common::String ftext;
-
 	debugC(3, kDebugText, "renderText: unk1: %d strLen: %d dataLen: %d textlen: %u", unk1, strLen, dataLen, text.size());
 	if (strLen < 200)
 		debugC(3, kDebugText, "text: '%s'", text.c_str());
@@ -832,12 +799,12 @@ void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteId, Commo
 		debugCN(4, kDebugText, "*");
 
 		ftext += Common::String::format("\001\015%c%c%c%c%c%c%c%c%c%c%c%c",
-						(textCast->fontId >> 8) & 0xff, textCast->fontId & 0xff,
-						textCast->textSlant & 0xff, unk3f & 0xff,
-						(textCast->fontSize >> 8) & 0xff, textCast->fontSize & 0xff,
-						(textCast->palinfo1 >> 8) & 0xff, textCast->palinfo1 & 0xff,
-						(textCast->palinfo2 >> 8) & 0xff, textCast->palinfo2 & 0xff,
-						(textCast->palinfo3 >> 8) & 0xff, textCast->palinfo3 & 0xff);
+										(textCast->fontId >> 8) & 0xff, textCast->fontId & 0xff,
+										textCast->textSlant & 0xff, unk3f & 0xff,
+										(textCast->fontSize >> 8) & 0xff, textCast->fontSize & 0xff,
+										(textCast->palinfo1 >> 8) & 0xff, textCast->palinfo1 & 0xff,
+										(textCast->palinfo2 >> 8) & 0xff, textCast->palinfo2 & 0xff,
+										(textCast->palinfo3 >> 8) & 0xff, textCast->palinfo3 & 0xff);
 
 		formattingCount--;
 	}
@@ -846,6 +813,46 @@ void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteId, Commo
 
 	debugC(4, kDebugText, "%s", text.c_str());
 
+	return ftext;
+}
+
+void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteId, Common::SeekableSubReadStreamEndian *textStream, Common::Rect *textSize) {
+	if (textStream == NULL)
+		return;
+
+	TextCast *textCast = _sprites[spriteId]->_buttonCast != nullptr ? (TextCast*)_sprites[spriteId]->_buttonCast : _sprites[spriteId]->_textCast;
+	int x = _sprites[spriteId]->_startPoint.x; // +rectLeft;
+	int y = _sprites[spriteId]->_startPoint.y; // +rectTop;
+	int height = textCast->initialRect.height(); //_sprites[spriteId]->_height;
+	int width;
+
+	if (_vm->getVersion() >= 4) {
+		if (textSize == NULL)
+			width = textCast->initialRect.right;
+		else {
+			width = textSize->width();
+		}
+	} else {
+		width = textCast->initialRect.width(); //_sprites[spriteId]->_width;
+	}
+
+	if (_vm->getCurrentScore()->_fontMap.contains(textCast->fontId)) {
+		// We need to make sure that the Shared Cast fonts have been loaded in?
+		// might need a mapping table here of our own.
+		// textCast->fontId = _vm->_wm->_fontMan->getFontIdByName(_vm->getCurrentScore()->_fontMap[textCast->fontId]);
+	}
+
+	if (width == 0 || height == 0) {
+		warning("renderText: Requested to draw on an empty surface: %d x %d", width, height);
+		return;
+	}
+
+	Graphics::MacFont *macFont = new Graphics::MacFont(textCast->fontId, textCast->fontSize, textCast->textSlant);
+
+	debugC(3, kDebugText, "renderText: x: %d y: %d w: %d h: %d font: '%s'", x, y, width, height, _vm->_wm->_fontMan->getFontName(*macFont));
+
+	Common::String ftext = readTextStream(textStream, textCast);
+
 	uint16 boxShadow = (uint16)textCast->boxShadow;
 	uint16 borderSize = (uint16)textCast->borderSize;
 	if (textSize != NULL)
diff --git a/engines/director/frame.h b/engines/director/frame.h
index e2a4a1f..6b0c580 100644
--- a/engines/director/frame.h
+++ b/engines/director/frame.h
@@ -135,6 +135,7 @@ private:
 	void readSprite(Common::SeekableSubReadStreamEndian &stream, uint16 offset, uint16 size);
 	void readMainChannels(Common::SeekableSubReadStreamEndian &stream, uint16 offset, uint16 size);
 	Image::ImageDecoder *getImageFrom(uint16 spriteId);
+	Common::String readTextStream(Common::SeekableSubReadStreamEndian *textStream, TextCast *textCast);
 	void drawBackgndTransSprite(Graphics::ManagedSurface &target, const Graphics::Surface &sprite, Common::Rect &drawRect);
 	void drawMatteSprite(Graphics::ManagedSurface &target, const Graphics::Surface &sprite, Common::Rect &drawRect);
 	void drawGhostSprite(Graphics::ManagedSurface &target, const Graphics::Surface &sprite, Common::Rect &drawRect);





More information about the Scummvm-git-logs mailing list