[Scummvm-git-logs] scummvm master -> 8a9f5dec72722e32c0598f025e997974f7c884a6

sev- sev at scummvm.org
Tue Jul 14 23:43:29 UTC 2020


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

Summary:
7a14a762df DIRECTOR: Refactor FontStyle loading
8a9f5dec72 DIRECTOR: Load text formatting for CastInfo


Commit: 7a14a762df44bc47c840c7b3080de08e7fb13807
    https://github.com/scummvm/scummvm/commit/7a14a762df44bc47c840c7b3080de08e7fb13807
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-07-15T01:43:16+02:00

Commit Message:
DIRECTOR: Refactor FontStyle loading

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


diff --git a/engines/director/castmember.cpp b/engines/director/castmember.cpp
index 894db3f2ce..58f26c0e32 100644
--- a/engines/director/castmember.cpp
+++ b/engines/director/castmember.cpp
@@ -444,12 +444,12 @@ Graphics::TextAlign TextCastMember::getAlignment() {
 }
 
 void TextCastMember::importStxt(const Stxt *stxt) {
-	_fontId = stxt->_fontId;
-	_textSlant = stxt->_textSlant;
-	_fontSize = stxt->_fontSize;
-	_fgpalinfo1 = stxt->_palinfo1;
-	_fgpalinfo2 = stxt->_palinfo2;
-	_fgpalinfo3 = stxt->_palinfo3;
+	_fontId = stxt->_style.fontId;
+	_textSlant = stxt->_style.textSlant;
+	_fontSize = stxt->_style.fontSize;
+	_fgpalinfo1 = stxt->_style.r;
+	_fgpalinfo2 = stxt->_style.g;
+	_fgpalinfo3 = stxt->_style.b;
 	_ftext = stxt->_ftext;
 	_ptext = stxt->_ptext;
 
diff --git a/engines/director/stxt.cpp b/engines/director/stxt.cpp
index 9da9c3f413..e5d45f7634 100644
--- a/engines/director/stxt.cpp
+++ b/engines/director/stxt.cpp
@@ -30,13 +30,9 @@ namespace Director {
 Stxt::Stxt(Common::SeekableSubReadStreamEndian &textStream) {
 	// TODO: Side effects on textStream make this a little hard to understand in context?
 
-	_fontId = 0;
-	_fontSize = 12;
 	_textType = kTextTypeFixed;
 	_textAlign = kTextAlignLeft;
 	_textShadow = kSizeNone;
-	_textSlant = 0;
-	_palinfo1 = _palinfo2 = _palinfo3 = 0;
 	_unk1f = _unk2f = 0;
 	_unk3f = 0;
 
@@ -70,27 +66,12 @@ Stxt::Stxt(Common::SeekableSubReadStreamEndian &textStream) {
 	uint32 prevPos = 0;
 
 	while (formattingCount) {
-		uint32 formatStartOffset = textStream.readUint32();
-		uint16 height = textStream.readUint16();
-		uint16 ascent = textStream.readUint16();
+		debugC(3, kDebugText, "Stxt init: formattingCount: %u", formattingCount);
+		_style.read(textStream);
 
-		_fontId = textStream.readUint16();
-		_textSlant = textStream.readByte();
-		byte padding = textStream.readByte();
-		_fontSize = textStream.readUint16();
+		assert(prevPos <= _style.formatStartOffset);  // If this is triggered, we have to implement sorting
 
-		_palinfo1 = textStream.readUint16();
-		_palinfo2 = textStream.readUint16();
-		_palinfo3 = textStream.readUint16();
-
-		debugC(3, kDebugText, "Stxt init: formattingCount: %u, formatStartOffset: %d, height: %d ascent: %d, fontId: %d, textSlant: %d padding: 0x%02x",
-				formattingCount, formatStartOffset, height, ascent, _fontId, _textSlant, padding);
-
-		debugC(3, kDebugText, "        fontSize: %d, p0: %x p1: %x p2: %x", _fontSize, _palinfo1, _palinfo2, _palinfo3);
-
-		assert(prevPos <= formatStartOffset);  // If this is triggered, we have to implement sorting
-
-		while (prevPos != formatStartOffset) {
+		while (prevPos != _style.formatStartOffset) {
 			char f = text.firstChar();
 			_ftext += text.firstChar();
 			text.deleteChar(0);
@@ -105,7 +86,7 @@ Stxt::Stxt(Common::SeekableSubReadStreamEndian &textStream) {
 
 		debugCN(4, kDebugText, "*");
 
-		_ftext += Common::String::format("\001\016%04x%02x%04x%04x%04x%04x", _fontId, _textSlant, _fontSize, _palinfo1, _palinfo2, _palinfo3);
+		_ftext += Common::String::format("\001\016%04x%02x%04x%04x%04x%04x", _style.fontId, _style.textSlant, _style.fontSize, _style.r, _style.g, _style.b);
 
 		formattingCount--;
 	}
@@ -115,4 +96,37 @@ Stxt::Stxt(Common::SeekableSubReadStreamEndian &textStream) {
 	debugC(4, kDebugText, "#### text:\n%s\n####", Common::toPrintable(_ftext).c_str());
 }
 
+FontStyle::FontStyle() {
+	formatStartOffset = 0;
+	height = 0;
+	ascent = 0;
+
+	fontId = 0;
+	textSlant = 0;
+
+	fontSize = 12;
+
+	r = g = b = 0;
+}
+
+void FontStyle::read(Common::ReadStreamEndian &stream) {
+	formatStartOffset = stream.readUint32();
+	height = stream.readUint16();
+	ascent = stream.readUint16();
+
+	fontId = stream.readUint16();
+	textSlant = stream.readByte();
+	stream.readByte(); // padding
+	fontSize = stream.readUint16();
+
+	r = stream.readUint16();
+	g = stream.readUint16();
+	b = stream.readUint16();
+
+	debugC(3, kDebugText, "FontStyle::read(): formatStartOffset: %d, height: %d ascent: %d, fontId: %d, textSlant: %d",
+			formatStartOffset, height, ascent, fontId, textSlant);
+
+	debugC(3, kDebugText, "        fontSize: %d, r: %x g: %x b: %x", fontSize, r, g, b);
+}
+
 } // End of namespace Director
diff --git a/engines/director/stxt.h b/engines/director/stxt.h
index a16b12b51e..8bd705c57f 100644
--- a/engines/director/stxt.h
+++ b/engines/director/stxt.h
@@ -25,6 +25,22 @@
 
 namespace Director {
 
+struct FontStyle {
+	uint32 formatStartOffset;
+	uint16 height;
+	uint16 ascent;
+
+	uint16 fontId;
+	byte textSlant;
+
+	uint16 fontSize;
+
+	uint16 r, g, b;
+
+	FontStyle();
+	void read(Common::ReadStreamEndian &textStream);
+};
+
 class Stxt {
 public:
 	Stxt(Common::SeekableSubReadStreamEndian &textStream);
@@ -32,13 +48,11 @@ public:
 public:
 	Common::String _ftext;
 	Common::String _ptext;
-	uint32 _fontId;
-	uint16 _fontSize;
 	TextType _textType;
 	TextAlignType _textAlign;
 	SizeType _textShadow;
-	byte _textSlant;
-	uint16 _palinfo1, _palinfo2, _palinfo3;
+
+	FontStyle _style;
 	uint16 _unk1f;
 	uint16 _unk2f;
 	byte _unk3f;


Commit: 8a9f5dec72722e32c0598f025e997974f7c884a6
    https://github.com/scummvm/scummvm/commit/8a9f5dec72722e32c0598f025e997974f7c884a6
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-07-15T01:43:16+02:00

Commit Message:
DIRECTOR: Load text formatting for CastInfo

Changed paths:
    engines/director/cast.cpp
    engines/director/castmember.h
    engines/director/stxt.cpp
    engines/director/stxt.h


diff --git a/engines/director/cast.cpp b/engines/director/cast.cpp
index bdf3e6e553..09e908246e 100644
--- a/engines/director/cast.cpp
+++ b/engines/director/cast.cpp
@@ -840,8 +840,13 @@ void Cast::loadCastData(Common::SeekableSubReadStreamEndian &stream, uint16 id,
 			// fallthrough
 		case 7:
 			if (castStrings[6].len) {
-				warning("Cast::loadCastData(): STUB: scriptStyle (%d bytes)", castStrings[6].len);
-				Common::hexdump(castStrings[6].data, castStrings[6].len);
+				entryStream = new Common::MemoryReadStreamEndian(castStrings[6].data, castStrings[6].len, stream.isBE());
+
+				int16 count = entryStream->readUint16();
+
+				for (uint i = 0; i < count; i++)
+					ci->scriptStyle.read(*entryStream);
+				delete entryStream;
 			}
 			// fallthrough
 		case 6:
diff --git a/engines/director/castmember.h b/engines/director/castmember.h
index eb1a687493..f379721b48 100644
--- a/engines/director/castmember.h
+++ b/engines/director/castmember.h
@@ -26,6 +26,7 @@
 #include "graphics/font.h"
 
 #include "director/archive.h"
+#include "director/stxt.h"
 
 namespace Graphics {
 struct Surface;
@@ -228,7 +229,7 @@ struct CastMemberInfo {
 	Common::String fileName;
 	Common::String type;
 	EditInfo scriptEditInfo;
-	// scriptStyle
+	FontStyle scriptStyle;
 	EditInfo textEditInfo;
 	Common::String modifiedBy;
 	Common::String comments;
diff --git a/engines/director/stxt.cpp b/engines/director/stxt.cpp
index e5d45f7634..5c11ed5a40 100644
--- a/engines/director/stxt.cpp
+++ b/engines/director/stxt.cpp
@@ -123,10 +123,8 @@ void FontStyle::read(Common::ReadStreamEndian &stream) {
 	g = stream.readUint16();
 	b = stream.readUint16();
 
-	debugC(3, kDebugText, "FontStyle::read(): formatStartOffset: %d, height: %d ascent: %d, fontId: %d, textSlant: %d",
-			formatStartOffset, height, ascent, fontId, textSlant);
-
-	debugC(3, kDebugText, "        fontSize: %d, r: %x g: %x b: %x", fontSize, r, g, b);
+	debugC(3, kDebugLoading, "FontStyle::read(): formatStartOffset: %d, height: %d ascent: %d, fontId: %d, textSlant: %d, fontSize: %d, r: %x g: %x b: %x",
+			formatStartOffset, height, ascent, fontId, textSlant, fontSize, r, g, b);
 }
 
 } // End of namespace Director
diff --git a/engines/director/stxt.h b/engines/director/stxt.h
index 8bd705c57f..e771bf95ec 100644
--- a/engines/director/stxt.h
+++ b/engines/director/stxt.h
@@ -23,6 +23,10 @@
 #ifndef DIRECTOR_STXT_H
 #define DIRECTOR_STXT_H
 
+namespace Common {
+class ReadStreamEndian;
+}
+
 namespace Director {
 
 struct FontStyle {




More information about the Scummvm-git-logs mailing list