[Scummvm-git-logs] scummvm master -> ca89722d5795aed26b398107b9330f1beb4388cd
sev-
sev at scummvm.org
Tue May 2 22:01:34 CEST 2017
This automated email contains information about 15 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
1de51c10dd DIRECTOR: Add Stxt.h
61e4181f5f DIRECTOR: Add _loadedStxts member to Score
2bb427d6e1 DIRECTOR: Preload Stxts in Score
e69855acef DIRECTOR: Use preloaded Stxt for rendering
fca74091c3 DIRECTOR: Delete Stxts in ~Score
4ae5453af8 DIRECTOR: Add stxt.cpp
6a741a88c9 GRAPHICS: Pass interlinear as constructor argument to MacText
bad6cc32ef DIRECTOR: Equip textCast with _ftext
84a65f9df0 DIRECTOR: Init textCasts with Stxts in Score
61cd407405 DIRECTOR: Use text from textCasts
8b9e029c1e DIRECTOR: Remove now-useless textId parameter from renderButton
d6f651064b DIRECTOR: Add TextCast::importStxt
415d9d660e DIRECTOR: Add CachedMacText
bd7ded3f56 DIRECTOR: Add CachedMacText to TextCast
ca89722d57 DIRECTOR: Use CachedMacText for rendering
Commit: 1de51c10dd6e27e970d7b83a469b4a1656176237
https://github.com/scummvm/scummvm/commit/1de51c10dd6e27e970d7b83a469b4a1656176237
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2017-05-02T21:01:23+01:00
Commit Message:
DIRECTOR: Add Stxt.h
Changed paths:
A engines/director/stxt.h
diff --git a/engines/director/stxt.h b/engines/director/stxt.h
new file mode 100644
index 0000000..ff8f1d1
--- /dev/null
+++ b/engines/director/stxt.h
@@ -0,0 +1,118 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef DIRECTOR_STXT_H
+#define DIRECTOR_STXT_H
+
+#include "engines/director/director.h"
+
+namespace Director {
+
+class Stxt {
+public:
+ Stxt (Common::SeekableSubReadStreamEndian &textStream) {
+ uint32 unk1 = textStream.readUint32();
+ uint32 strLen = textStream.readUint32();
+ uint32 dataLen = textStream.readUint32();
+ Common::String text;
+
+ for (uint32 i = 0; i < strLen; i++) {
+ byte ch = textStream.readByte();
+ if (ch == 0x0d) {
+ ch = '\n';
+ }
+ text += ch;
+ }
+ debugC(3, kDebugText, "Stxt init: unk1: %d strLen: %d dataLen: %d textlen: %u", unk1, strLen, dataLen, text.size());
+ if (strLen < 200)
+ debugC(3, kDebugText, "text: '%s'", text.c_str());
+
+ uint16 formattingCount = textStream.readUint16();
+ uint32 prevPos = 0;
+
+ while (formattingCount) {
+ uint32 formatStartOffset = textStream.readUint32();
+ uint16 unk1f = textStream.readUint16();
+ uint16 unk2f = textStream.readUint16();
+
+ _fontId = textStream.readUint16();
+ _textSlant = textStream.readByte();
+ byte unk3f = textStream.readByte();
+ _fontSize = textStream.readUint16();
+
+ _palinfo1 = textStream.readUint16();
+ _palinfo2 = textStream.readUint16();
+ _palinfo3 = textStream.readUint16();
+
+ debugC(3, kDebugText, "Stxt init: formattingCount: %u, formatStartOffset: %d, unk1: %d unk2: %d, fontId: %d, textSlant: %d",
+ formattingCount, formatStartOffset, unk1f, unk2f, _fontId, _textSlant);
+
+ debugC(3, kDebugText, " unk3: %d, fontSize: %d, p0: %x p1: %x p2: %x", unk3f, _fontSize, _palinfo1, _palinfo2, _palinfo3);
+
+ assert(prevPos <= formatStartOffset); // If this is triggered, we have to implement sorting
+
+ while (prevPos != formatStartOffset) {
+ char f = text.firstChar();
+ _ftext += text.firstChar();
+ text.deleteChar(0);
+
+ if (f == '\001') // Insert two \001s as a replacement
+ _ftext += '\001';
+
+ prevPos++;
+
+ debugCN(4, kDebugText, "%c", f);
+ }
+
+ debugCN(4, kDebugText, "*");
+
+ _ftext += Common::String::format("\001\015%c%c%c%c%c%c%c%c%c%c%c%c",
+ (_fontId >> 8) & 0xff, _fontId & 0xff,
+ _textSlant & 0xff, unk3f & 0xff,
+ (_fontSize >> 8) & 0xff, _fontSize & 0xff,
+ (_palinfo1 >> 8) & 0xff, _palinfo1 & 0xff,
+ (_palinfo2 >> 8) & 0xff, _palinfo2 & 0xff,
+ (_palinfo3 >> 8) & 0xff, _palinfo3 & 0xff);
+
+ formattingCount--;
+ }
+
+ debugC(4, kDebugText, "%s", text.c_str());
+ _ftext += text;
+ }
+public:
+ Common::String _ftext;
+ uint32 _fontId;
+ uint16 _fontSize;
+ TextType _textType;
+ TextAlignType _textAlign;
+ SizeType _textShadow;
+ byte _textSlant;
+ uint16 _palinfo1, _palinfo2, _palinfo3;
+ uint16 _unk1f;
+ uint16 _unk2f;
+ byte _unk3f;
+};
+
+} // End of namespace Director
+
+#endif
Commit: 61e4181f5fdb45f456f5d059e435461d0e99180f
https://github.com/scummvm/scummvm/commit/61e4181f5fdb45f456f5d059e435461d0e99180f
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2017-05-02T21:01:23+01:00
Commit Message:
DIRECTOR: Add _loadedStxts member to Score
Changed paths:
engines/director/score.cpp
engines/director/score.h
diff --git a/engines/director/score.cpp b/engines/director/score.cpp
index 355900e..217fc12 100644
--- a/engines/director/score.cpp
+++ b/engines/director/score.cpp
@@ -92,6 +92,7 @@ Score::Score(DirectorEngine *vm) {
_loadedButtons = new Common::HashMap<int, ButtonCast *>();
_loadedShapes = new Common::HashMap<int, ShapeCast *>();
_loadedScripts = new Common::HashMap<int, ScriptCast *>();
+ _loadedStxts = new Common::HashMap<int, const Stxt *>();
}
void Score::setArchive(Archive *archive) {
diff --git a/engines/director/score.h b/engines/director/score.h
index 7b11e0d..cd1f488 100644
--- a/engines/director/score.h
+++ b/engines/director/score.h
@@ -28,6 +28,7 @@
#include "director/archive.h"
#include "director/cast.h"
#include "director/images.h"
+#include "engines/director/stxt.h"
namespace Graphics {
class ManagedSurface;
@@ -133,6 +134,7 @@ public:
Common::HashMap<int, BitmapCast *> *_loadedBitmaps;
Common::HashMap<int, ShapeCast *> *_loadedShapes;
Common::HashMap<int, ScriptCast *> *_loadedScripts;
+ Common::HashMap<int, const Stxt *> *_loadedStxts;
private:
uint16 _versionMinor;
Commit: 2bb427d6e12c5ef9c6e52987f0edfb70b2288e02
https://github.com/scummvm/scummvm/commit/2bb427d6e12c5ef9c6e52987f0edfb70b2288e02
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2017-05-02T21:01:23+01:00
Commit Message:
DIRECTOR: Preload Stxts in Score
Changed paths:
engines/director/score.cpp
diff --git a/engines/director/score.cpp b/engines/director/score.cpp
index 217fc12..be36011 100644
--- a/engines/director/score.cpp
+++ b/engines/director/score.cpp
@@ -190,6 +190,13 @@ void Score::loadArchive() {
for (Common::Array<uint16>::iterator iterator = stxt.begin(); iterator != stxt.end(); ++iterator) {
loadScriptText(*_movieArchive->getResource(MKTAG('S','T','X','T'), *iterator));
+ // Load STXTS
+
+ // TODO: make sure the Stxt is eventually destroyed
+ _loadedStxts->setVal(*iterator,
+ new Stxt(*_movieArchive->getResource(MKTAG('S','T','X','T'),
+ *iterator))
+ );
}
}
}
Commit: e69855acef229e29f04f09f3c170a3be8f36a720
https://github.com/scummvm/scummvm/commit/e69855acef229e29f04f09f3c170a3be8f36a720
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2017-05-02T21:01:23+01:00
Commit Message:
DIRECTOR: Use preloaded Stxt for rendering
Changed paths:
engines/director/frame.cpp
engines/director/frame.h
diff --git a/engines/director/frame.cpp b/engines/director/frame.cpp
index 0caaf59..178b8b8 100644
--- a/engines/director/frame.cpp
+++ b/engines/director/frame.cpp
@@ -593,7 +593,9 @@ void Frame::renderSprites(Graphics::ManagedSurface &surface, bool renderTrail) {
if (castType == kCastShape) {
renderShape(surface, i);
} else if (castType == kCastText) {
- renderText(surface, i, _vm->getVersion() < 4 ? _sprites[i]->_castId + 1024 : _sprites[i]->_textCast->children[0].index);
+ uint id = (_vm->getVersion() < 4) ? _sprites[i]->_castId + 1024 : _sprites[i]->_textCast->children[0].index;
+ const Stxt *stxt = _vm->getCurrentScore()->_loadedStxts->getVal(id);
+ renderText(surface, i, stxt, NULL);
} else if (castType == kCastButton) {
renderButton(surface, i, _vm->getVersion() < 4 ? _sprites[i]->_castId + 1024 : _sprites[i]->_buttonCast->children[0].index);
} else {
@@ -670,7 +672,8 @@ void Frame::renderButton(Graphics::ManagedSurface &surface, uint16 spriteId, uin
Common::Rect textRect(0, 0, width, height);
// pass the rect of the button into the label.
- renderText(surface, spriteId, _vm->getMainArchive()->getResource(MKTAG('S', 'T', 'X', 'T'), textId), &textRect);
+ const Stxt *stxt = _vm->getCurrentScore()->_loadedStxts->getVal(textId);
+ renderText(surface, spriteId, stxt, &textRect);
// TODO: review all cases to confirm if we should use text height.
// height = textRect.height();
@@ -725,102 +728,17 @@ void Frame::inkBasedBlit(Graphics::ManagedSurface &targetSurface, const Graphics
}
}
-void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteId, uint16 castId) {
- Common::SeekableSubReadStreamEndian *textStream = NULL;
- if (_vm->getCurrentScore()->_movieArchive->hasResource(MKTAG('S', 'T', 'X', 'T'), castId)) {
- textStream = _vm->getCurrentScore()->_movieArchive->getResource(MKTAG('S', 'T', 'X', 'T'), castId);
- } else if (_vm->getSharedSTXT() != nullptr) {
- textStream = _vm->getSharedSTXT()->getVal(spriteId + 1024);
- }
-
- renderText(surface, spriteId, textStream, NULL);
-}
-
-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();
- Common::String text;
-
- for (uint32 i = 0; i < strLen; i++) {
- byte ch = textStream->readByte();
- if (ch == 0x0d) {
- ch = '\n';
- }
- text += ch;
- }
-
- 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());
-
- uint16 formattingCount = textStream->readUint16();
- uint32 prevPos = 0;
-
- while (formattingCount) {
- uint32 formatStartOffset = textStream->readUint32();
- uint16 unk1f = textStream->readUint16();
- uint16 unk2f = textStream->readUint16();
-
- textCast->fontId = textStream->readUint16();
- textCast->textSlant = textStream->readByte();
- byte unk3f = textStream->readByte();
- textCast->fontSize = textStream->readUint16();
-
- textCast->palinfo1 = textStream->readUint16();
- textCast->palinfo2 = textStream->readUint16();
- textCast->palinfo3 = textStream->readUint16();
-
- debugC(3, kDebugText, "renderText: formattingCount: %u, formatStartOffset: %d, unk1: %d unk2: %d, fontId: %d, textSlant: %d",
- formattingCount, formatStartOffset, unk1f, unk2f, textCast->fontId, textCast->textSlant);
-
- debugC(3, kDebugText, " unk3: %d, fontSize: %d, p0: %x p1: %x p2: %x", unk3f, textCast->fontSize,
- textCast->palinfo1, textCast->palinfo2, textCast->palinfo3);
-
- assert (prevPos <= formatStartOffset); // If this is triggered, we have to implement sorting
-
- while (prevPos != formatStartOffset) {
- char f = text.firstChar();
- ftext += text.firstChar();
- text.deleteChar(0);
-
- if (f == '\001') // Insert two \001s as a replacement
- ftext += '\001';
-
- prevPos++;
-
- debugCN(4, kDebugText, "%c", f);
- }
-
- 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);
-
- formattingCount--;
- }
-
- ftext += text;
-
- debugC(4, kDebugText, "%s", text.c_str());
-
- return ftext;
-}
+void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteId, const Stxt *stxt, Common::Rect *textSize) {
+ TextCast *textCast = _sprites[spriteId]->_buttonCast != nullptr ? (TextCast*)_sprites[spriteId]->_buttonCast : _sprites[spriteId]->_textCast;
-void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteId, Common::SeekableSubReadStreamEndian *textStream, Common::Rect *textSize) {
- if (textStream == NULL)
- return;
+ textCast->fontId = stxt->_fontId;
+ textCast->textSlant = stxt->_textSlant;
+ textCast->fontSize = stxt->_fontSize;
+ textCast->palinfo1 = stxt->_palinfo1;
+ textCast->palinfo2 = stxt->_palinfo2;
+ textCast->palinfo3 = stxt->_palinfo3;
- 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;
@@ -851,8 +769,6 @@ void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteId, Commo
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)
@@ -870,7 +786,8 @@ void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteId, Commo
else
alignment++;
- Graphics::MacText mt(ftext, _vm->_wm, macFont, 0x00, 0xff, width, (Graphics::TextAlign)alignment);
+ Graphics::MacText mt(stxt->_ftext, _vm->_wm, macFont, 0x00, 0xff, width, (Graphics::TextAlign)alignment);
+
mt.setInterLinear(1);
mt.render();
const Graphics::ManagedSurface *textSurface = mt.getSurface();
diff --git a/engines/director/frame.h b/engines/director/frame.h
index 6b0c580..fd0dbc8 100644
--- a/engines/director/frame.h
+++ b/engines/director/frame.h
@@ -24,6 +24,7 @@
#define DIRECTOR_FRAME_H
#include "graphics/managed_surface.h"
+#include "engines/director/stxt.h"
namespace Image {
class ImageDecoder;
@@ -127,8 +128,7 @@ private:
void playTransition(Score *score);
void playSoundChannel();
void renderSprites(Graphics::ManagedSurface &surface, bool renderTrail);
- void renderText(Graphics::ManagedSurface &surface, uint16 spriteId, uint16 castId);
- void renderText(Graphics::ManagedSurface &surface, uint16 spriteId, Common::SeekableSubReadStreamEndian *textStream, Common::Rect *textSize);
+ void renderText(Graphics::ManagedSurface &surface, uint16 spriteId, const Stxt *stxt, Common::Rect *textSize);
void renderShape(Graphics::ManagedSurface &surface, uint16 spriteId);
void renderButton(Graphics::ManagedSurface &surface, uint16 spriteId, uint16 textId);
void readPaletteInfo(Common::SeekableSubReadStreamEndian &stream);
Commit: fca74091c3b48e03d0725f1193d157094434d437
https://github.com/scummvm/scummvm/commit/fca74091c3b48e03d0725f1193d157094434d437
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2017-05-02T21:01:23+01:00
Commit Message:
DIRECTOR: Delete Stxts in ~Score
Changed paths:
engines/director/score.cpp
diff --git a/engines/director/score.cpp b/engines/director/score.cpp
index be36011..65a3439 100644
--- a/engines/director/score.cpp
+++ b/engines/director/score.cpp
@@ -192,7 +192,6 @@ void Score::loadArchive() {
loadScriptText(*_movieArchive->getResource(MKTAG('S','T','X','T'), *iterator));
// Load STXTS
- // TODO: make sure the Stxt is eventually destroyed
_loadedStxts->setVal(*iterator,
new Stxt(*_movieArchive->getResource(MKTAG('S','T','X','T'),
*iterator))
@@ -284,6 +283,7 @@ Score::~Score() {
delete _font;
delete _labels;
+ delete _loadedStxts;
}
void Score::loadPalette(Common::SeekableSubReadStreamEndian &stream) {
Commit: 4ae5453af8ad35835ebecd07b9108fae4eec64a8
https://github.com/scummvm/scummvm/commit/4ae5453af8ad35835ebecd07b9108fae4eec64a8
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2017-05-02T21:01:23+01:00
Commit Message:
DIRECTOR: Add stxt.cpp
Changed paths:
A engines/director/stxt.cpp
engines/director/module.mk
engines/director/stxt.h
diff --git a/engines/director/module.mk b/engines/director/module.mk
index acfc4fd..55e1c26 100644
--- a/engines/director/module.mk
+++ b/engines/director/module.mk
@@ -14,6 +14,7 @@ MODULE_OBJS = \
score.o \
sound.o \
sprite.o \
+ stxt.o \
util.o \
lingo/lingo-gr.o \
lingo/lingo.o \
diff --git a/engines/director/stxt.cpp b/engines/director/stxt.cpp
new file mode 100644
index 0000000..4bdc42d
--- /dev/null
+++ b/engines/director/stxt.cpp
@@ -0,0 +1,99 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "engines/director/stxt.h"
+
+namespace Director {
+
+Stxt::Stxt (Common::SeekableSubReadStreamEndian &textStream) {
+ // TODO: Side effects on textStream make this a little hard to understand in context?
+ uint32 unk1 = textStream.readUint32();
+ uint32 strLen = textStream.readUint32();
+ uint32 dataLen = textStream.readUint32();
+ Common::String text;
+
+ for (uint32 i = 0; i < strLen; i++) {
+ byte ch = textStream.readByte();
+ if (ch == 0x0d) {
+ ch = '\n';
+ }
+ text += ch;
+ }
+ debugC(3, kDebugText, "Stxt init: unk1: %d strLen: %d dataLen: %d textlen: %u", unk1, strLen, dataLen, text.size());
+ if (strLen < 200)
+ debugC(3, kDebugText, "text: '%s'", text.c_str());
+
+ uint16 formattingCount = textStream.readUint16();
+ uint32 prevPos = 0;
+
+ while (formattingCount) {
+ uint32 formatStartOffset = textStream.readUint32();
+ uint16 unk1f = textStream.readUint16();
+ uint16 unk2f = textStream.readUint16();
+
+ _fontId = textStream.readUint16();
+ _textSlant = textStream.readByte();
+ byte unk3f = textStream.readByte();
+ _fontSize = textStream.readUint16();
+
+ _palinfo1 = textStream.readUint16();
+ _palinfo2 = textStream.readUint16();
+ _palinfo3 = textStream.readUint16();
+
+ debugC(3, kDebugText, "Stxt init: formattingCount: %u, formatStartOffset: %d, unk1: %d unk2: %d, fontId: %d, textSlant: %d",
+ formattingCount, formatStartOffset, unk1f, unk2f, _fontId, _textSlant);
+
+ debugC(3, kDebugText, " unk3: %d, fontSize: %d, p0: %x p1: %x p2: %x", unk3f, _fontSize, _palinfo1, _palinfo2, _palinfo3);
+
+ assert(prevPos <= formatStartOffset); // If this is triggered, we have to implement sorting
+
+ while (prevPos != formatStartOffset) {
+ char f = text.firstChar();
+ _ftext += text.firstChar();
+ text.deleteChar(0);
+
+ if (f == '\001') // Insert two \001s as a replacement
+ _ftext += '\001';
+
+ prevPos++;
+
+ debugCN(4, kDebugText, "%c", f);
+ }
+
+ debugCN(4, kDebugText, "*");
+
+ _ftext += Common::String::format("\001\015%c%c%c%c%c%c%c%c%c%c%c%c",
+ (_fontId >> 8) & 0xff, _fontId & 0xff,
+ _textSlant & 0xff, unk3f & 0xff,
+ (_fontSize >> 8) & 0xff, _fontSize & 0xff,
+ (_palinfo1 >> 8) & 0xff, _palinfo1 & 0xff,
+ (_palinfo2 >> 8) & 0xff, _palinfo2 & 0xff,
+ (_palinfo3 >> 8) & 0xff, _palinfo3 & 0xff);
+
+ formattingCount--;
+ }
+
+ debugC(4, kDebugText, "%s", text.c_str());
+ _ftext += text;
+}
+
+} // End of namespace Director
diff --git a/engines/director/stxt.h b/engines/director/stxt.h
index ff8f1d1..ab1c823 100644
--- a/engines/director/stxt.h
+++ b/engines/director/stxt.h
@@ -29,76 +29,7 @@ namespace Director {
class Stxt {
public:
- Stxt (Common::SeekableSubReadStreamEndian &textStream) {
- uint32 unk1 = textStream.readUint32();
- uint32 strLen = textStream.readUint32();
- uint32 dataLen = textStream.readUint32();
- Common::String text;
-
- for (uint32 i = 0; i < strLen; i++) {
- byte ch = textStream.readByte();
- if (ch == 0x0d) {
- ch = '\n';
- }
- text += ch;
- }
- debugC(3, kDebugText, "Stxt init: unk1: %d strLen: %d dataLen: %d textlen: %u", unk1, strLen, dataLen, text.size());
- if (strLen < 200)
- debugC(3, kDebugText, "text: '%s'", text.c_str());
-
- uint16 formattingCount = textStream.readUint16();
- uint32 prevPos = 0;
-
- while (formattingCount) {
- uint32 formatStartOffset = textStream.readUint32();
- uint16 unk1f = textStream.readUint16();
- uint16 unk2f = textStream.readUint16();
-
- _fontId = textStream.readUint16();
- _textSlant = textStream.readByte();
- byte unk3f = textStream.readByte();
- _fontSize = textStream.readUint16();
-
- _palinfo1 = textStream.readUint16();
- _palinfo2 = textStream.readUint16();
- _palinfo3 = textStream.readUint16();
-
- debugC(3, kDebugText, "Stxt init: formattingCount: %u, formatStartOffset: %d, unk1: %d unk2: %d, fontId: %d, textSlant: %d",
- formattingCount, formatStartOffset, unk1f, unk2f, _fontId, _textSlant);
-
- debugC(3, kDebugText, " unk3: %d, fontSize: %d, p0: %x p1: %x p2: %x", unk3f, _fontSize, _palinfo1, _palinfo2, _palinfo3);
-
- assert(prevPos <= formatStartOffset); // If this is triggered, we have to implement sorting
-
- while (prevPos != formatStartOffset) {
- char f = text.firstChar();
- _ftext += text.firstChar();
- text.deleteChar(0);
-
- if (f == '\001') // Insert two \001s as a replacement
- _ftext += '\001';
-
- prevPos++;
-
- debugCN(4, kDebugText, "%c", f);
- }
-
- debugCN(4, kDebugText, "*");
-
- _ftext += Common::String::format("\001\015%c%c%c%c%c%c%c%c%c%c%c%c",
- (_fontId >> 8) & 0xff, _fontId & 0xff,
- _textSlant & 0xff, unk3f & 0xff,
- (_fontSize >> 8) & 0xff, _fontSize & 0xff,
- (_palinfo1 >> 8) & 0xff, _palinfo1 & 0xff,
- (_palinfo2 >> 8) & 0xff, _palinfo2 & 0xff,
- (_palinfo3 >> 8) & 0xff, _palinfo3 & 0xff);
-
- formattingCount--;
- }
-
- debugC(4, kDebugText, "%s", text.c_str());
- _ftext += text;
- }
+ Stxt (Common::SeekableSubReadStreamEndian &textStream);
public:
Common::String _ftext;
uint32 _fontId;
Commit: 6a741a88c98da78ca860054fce387cb66f57d5cf
https://github.com/scummvm/scummvm/commit/6a741a88c98da78ca860054fce387cb66f57d5cf
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2017-05-02T21:01:23+01:00
Commit Message:
GRAPHICS: Pass interlinear as constructor argument to 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 178b8b8..e6a8505 100644
--- a/engines/director/frame.cpp
+++ b/engines/director/frame.cpp
@@ -786,9 +786,7 @@ void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteId, const
else
alignment++;
- Graphics::MacText mt(stxt->_ftext, _vm->_wm, macFont, 0x00, 0xff, width, (Graphics::TextAlign)alignment);
-
- mt.setInterLinear(1);
+ Graphics::MacText mt(stxt->_ftext, _vm->_wm, macFont, 0x00, 0xff, width, (Graphics::TextAlign)alignment, 1);
mt.render();
const Graphics::ManagedSurface *textSurface = mt.getSurface();
diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index 62c4e8e..0f9c120 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -42,7 +42,7 @@ MacText::~MacText(){
delete _macFont;
}
-MacText::MacText(Common::String s, MacWindowManager *wm, const MacFont *macFont, 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, int interlinear) {
_str = s;
_wm = wm;
_macFont = macFont;
@@ -53,8 +53,7 @@ MacText::MacText(Common::String s, MacWindowManager *wm, const MacFont *macFont,
_textMaxHeight = 0;
_surface = nullptr;
_textAlignment = textAlignment;
-
- _interLinear = 0; // 0 pixels between the lines by default
+ _interLinear = interlinear;
if (macFont) {
_defaultFormatting.font = wm->_fontMan->getFont(*macFont);
diff --git a/graphics/macgui/mactext.h b/graphics/macgui/mactext.h
index 25f6002..f0a3ed6 100644
--- a/graphics/macgui/mactext.h
+++ b/graphics/macgui/mactext.h
@@ -89,7 +89,8 @@ struct MacTextLine {
class MacText {
public:
MacText(Common::String s, MacWindowManager *wm, const MacFont *font, int fgcolor, int bgcolor,
- int maxWidth = -1, TextAlign textAlignment = kTextAlignLeft);
+ int maxWidth = -1, TextAlign textAlignment = kTextAlignLeft, int interlinear = 0);
+ // 0 pixels between the lines by default
~MacText();
void setInterLinear(int interLinear);
Commit: bad6cc32ef0ee2ff36ca3f67b2104d33b14084e9
https://github.com/scummvm/scummvm/commit/bad6cc32ef0ee2ff36ca3f67b2104d33b14084e9
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2017-05-02T21:01:23+01:00
Commit Message:
DIRECTOR: Equip textCast with _ftext
Changed paths:
engines/director/cast.h
diff --git a/engines/director/cast.h b/engines/director/cast.h
index 69641b5..b2ba7fc 100644
--- a/engines/director/cast.h
+++ b/engines/director/cast.h
@@ -136,6 +136,8 @@ public:
byte textSlant;
Common::Array<TextFlag> textFlags;
uint16 palinfo1, palinfo2, palinfo3;
+
+ Common::String _ftext;
};
enum ButtonType {
Commit: 84a65f9df0d895d841cad3191302ea592809af2d
https://github.com/scummvm/scummvm/commit/84a65f9df0d895d841cad3191302ea592809af2d
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2017-05-02T21:01:23+01:00
Commit Message:
DIRECTOR: Init textCasts with Stxts in Score
Changed paths:
engines/director/score.cpp
engines/director/score.h
diff --git a/engines/director/score.cpp b/engines/director/score.cpp
index 65a3439..7decd6b 100644
--- a/engines/director/score.cpp
+++ b/engines/director/score.cpp
@@ -198,6 +198,30 @@ void Score::loadArchive() {
);
}
}
+ copyCastStxts();
+ }
+}
+
+void copyStxt(TextCast *textCast, const Stxt *stxt) {
+ textCast->fontId = stxt->_fontId;
+ textCast->textSlant = stxt->_textSlant;
+ textCast->fontSize = stxt->_fontSize;
+ textCast->palinfo1 = stxt->_palinfo1;
+ textCast->palinfo2 = stxt->_palinfo2;
+ textCast->palinfo3 = stxt->_palinfo3;
+ textCast->_ftext = stxt->_ftext;
+}
+
+void Score::copyCastStxts() {
+ Common::HashMap<int, TextCast *>::iterator tc;
+ for (tc = _loadedText->begin(); tc != _loadedText->end(); ++tc) {
+ uint stxtid = (_vm->getVersion() < 4) ?
+ tc->_key + 1024 :
+ tc->_value->children[0].index;
+ if (_loadedStxts->getVal(stxtid)){
+ const Stxt *stxt = _loadedStxts->getVal(stxtid);
+ copyStxt(tc->_value, stxt);
+ }
}
}
diff --git a/engines/director/score.h b/engines/director/score.h
index cd1f488..b091774 100644
--- a/engines/director/score.h
+++ b/engines/director/score.h
@@ -83,6 +83,7 @@ public:
Sprite *getSpriteById(uint16 id);
void setSpriteCasts();
void loadSpriteImages(bool isSharedCast);
+ void copyCastStxts();
Graphics::ManagedSurface *getSurface() { return _surface; }
void loadCastInto(Sprite *sprite, int castId);
Commit: 61cd407405777a85bd6f40b3c1b04d340d811c34
https://github.com/scummvm/scummvm/commit/61cd407405777a85bd6f40b3c1b04d340d811c34
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2017-05-02T21:01:23+01:00
Commit Message:
DIRECTOR: Use text from textCasts
Changed paths:
engines/director/frame.cpp
engines/director/frame.h
diff --git a/engines/director/frame.cpp b/engines/director/frame.cpp
index e6a8505..770617e 100644
--- a/engines/director/frame.cpp
+++ b/engines/director/frame.cpp
@@ -593,9 +593,7 @@ void Frame::renderSprites(Graphics::ManagedSurface &surface, bool renderTrail) {
if (castType == kCastShape) {
renderShape(surface, i);
} else if (castType == kCastText) {
- uint id = (_vm->getVersion() < 4) ? _sprites[i]->_castId + 1024 : _sprites[i]->_textCast->children[0].index;
- const Stxt *stxt = _vm->getCurrentScore()->_loadedStxts->getVal(id);
- renderText(surface, i, stxt, NULL);
+ renderText(surface, i, NULL);
} else if (castType == kCastButton) {
renderButton(surface, i, _vm->getVersion() < 4 ? _sprites[i]->_castId + 1024 : _sprites[i]->_buttonCast->children[0].index);
} else {
@@ -672,8 +670,7 @@ void Frame::renderButton(Graphics::ManagedSurface &surface, uint16 spriteId, uin
Common::Rect textRect(0, 0, width, height);
// pass the rect of the button into the label.
- const Stxt *stxt = _vm->getCurrentScore()->_loadedStxts->getVal(textId);
- renderText(surface, spriteId, stxt, &textRect);
+ renderText(surface, spriteId, &textRect);
// TODO: review all cases to confirm if we should use text height.
// height = textRect.height();
@@ -729,15 +726,9 @@ void Frame::inkBasedBlit(Graphics::ManagedSurface &targetSurface, const Graphics
}
-void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteId, const Stxt *stxt, Common::Rect *textSize) {
+void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteId, Common::Rect *textSize) {
TextCast *textCast = _sprites[spriteId]->_buttonCast != nullptr ? (TextCast*)_sprites[spriteId]->_buttonCast : _sprites[spriteId]->_textCast;
- textCast->fontId = stxt->_fontId;
- textCast->textSlant = stxt->_textSlant;
- textCast->fontSize = stxt->_fontSize;
- textCast->palinfo1 = stxt->_palinfo1;
- textCast->palinfo2 = stxt->_palinfo2;
- textCast->palinfo3 = stxt->_palinfo3;
int x = _sprites[spriteId]->_startPoint.x; // +rectLeft;
int y = _sprites[spriteId]->_startPoint.y; // +rectTop;
@@ -786,7 +777,7 @@ void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteId, const
else
alignment++;
- Graphics::MacText mt(stxt->_ftext, _vm->_wm, macFont, 0x00, 0xff, width, (Graphics::TextAlign)alignment, 1);
+ Graphics::MacText mt(textCast->_ftext, _vm->_wm, macFont, 0x00, 0xff, width, (Graphics::TextAlign)alignment, 1);
mt.render();
const Graphics::ManagedSurface *textSurface = mt.getSurface();
diff --git a/engines/director/frame.h b/engines/director/frame.h
index fd0dbc8..546573f 100644
--- a/engines/director/frame.h
+++ b/engines/director/frame.h
@@ -128,7 +128,7 @@ private:
void playTransition(Score *score);
void playSoundChannel();
void renderSprites(Graphics::ManagedSurface &surface, bool renderTrail);
- void renderText(Graphics::ManagedSurface &surface, uint16 spriteId, const Stxt *stxt, Common::Rect *textSize);
+ void renderText(Graphics::ManagedSurface &surface, uint16 spriteId, Common::Rect *textSize);
void renderShape(Graphics::ManagedSurface &surface, uint16 spriteId);
void renderButton(Graphics::ManagedSurface &surface, uint16 spriteId, uint16 textId);
void readPaletteInfo(Common::SeekableSubReadStreamEndian &stream);
Commit: 8b9e029c1e661723ba0399b865c5b7b8ec542dd1
https://github.com/scummvm/scummvm/commit/8b9e029c1e661723ba0399b865c5b7b8ec542dd1
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2017-05-02T21:01:23+01:00
Commit Message:
DIRECTOR: Remove now-useless textId parameter from renderButton
Changed paths:
engines/director/frame.cpp
engines/director/frame.h
diff --git a/engines/director/frame.cpp b/engines/director/frame.cpp
index 770617e..af99248 100644
--- a/engines/director/frame.cpp
+++ b/engines/director/frame.cpp
@@ -595,7 +595,7 @@ void Frame::renderSprites(Graphics::ManagedSurface &surface, bool renderTrail) {
} else if (castType == kCastText) {
renderText(surface, i, NULL);
} else if (castType == kCastButton) {
- renderButton(surface, i, _vm->getVersion() < 4 ? _sprites[i]->_castId + 1024 : _sprites[i]->_buttonCast->children[0].index);
+ renderButton(surface, i);
} else {
if (!_sprites[i]->_bitmapCast) {
warning("No cast ID for sprite %d", i);
@@ -656,7 +656,7 @@ void Frame::renderShape(Graphics::ManagedSurface &surface, uint16 spriteId) {
inkBasedBlit(surface, tmpSurface, spriteId, shapeRect);
}
-void Frame::renderButton(Graphics::ManagedSurface &surface, uint16 spriteId, uint16 textId) {
+void Frame::renderButton(Graphics::ManagedSurface &surface, uint16 spriteId) {
uint16 castId = _sprites[spriteId]->_castId;
ButtonCast *button = _vm->getCurrentScore()->_loadedButtons->getVal(castId);
diff --git a/engines/director/frame.h b/engines/director/frame.h
index 546573f..e254171 100644
--- a/engines/director/frame.h
+++ b/engines/director/frame.h
@@ -130,7 +130,7 @@ private:
void renderSprites(Graphics::ManagedSurface &surface, bool renderTrail);
void renderText(Graphics::ManagedSurface &surface, uint16 spriteId, Common::Rect *textSize);
void renderShape(Graphics::ManagedSurface &surface, uint16 spriteId);
- void renderButton(Graphics::ManagedSurface &surface, uint16 spriteId, uint16 textId);
+ void renderButton(Graphics::ManagedSurface &surface, uint16 spriteId);
void readPaletteInfo(Common::SeekableSubReadStreamEndian &stream);
void readSprite(Common::SeekableSubReadStreamEndian &stream, uint16 offset, uint16 size);
void readMainChannels(Common::SeekableSubReadStreamEndian &stream, uint16 offset, uint16 size);
Commit: d6f651064b52fda31838a8260ef7e97d1c661cc5
https://github.com/scummvm/scummvm/commit/d6f651064b52fda31838a8260ef7e97d1c661cc5
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2017-05-02T21:01:23+01:00
Commit Message:
DIRECTOR: Add TextCast::importStxt
Changed paths:
engines/director/cast.cpp
engines/director/cast.h
engines/director/score.cpp
diff --git a/engines/director/cast.cpp b/engines/director/cast.cpp
index d71ae32..0dd6e53 100644
--- a/engines/director/cast.cpp
+++ b/engines/director/cast.cpp
@@ -179,6 +179,16 @@ TextCast::TextCast(Common::ReadStreamEndian &stream, uint16 version) {
modified = 0;
}
+void TextCast::importStxt(const Stxt *stxt) {
+ fontId = stxt->_fontId;
+ textSlant = stxt->_textSlant;
+ fontSize = stxt->_fontSize;
+ palinfo1 = stxt->_palinfo1;
+ palinfo2 = stxt->_palinfo2;
+ palinfo3 = stxt->_palinfo3;
+ _ftext = stxt->_ftext;
+}
+
ShapeCast::ShapeCast(Common::ReadStreamEndian &stream, uint16 version) {
if (version < 4) {
/*byte flags = */ stream.readByte();
diff --git a/engines/director/cast.h b/engines/director/cast.h
index b2ba7fc..a542bf7 100644
--- a/engines/director/cast.h
+++ b/engines/director/cast.h
@@ -30,6 +30,8 @@
namespace Director {
+class Stxt;
+
enum CastType {
kCastTypeNull = 0,
kCastBitmap = 1,
@@ -138,6 +140,7 @@ public:
uint16 palinfo1, palinfo2, palinfo3;
Common::String _ftext;
+ void importStxt(const Stxt *stxt);
};
enum ButtonType {
diff --git a/engines/director/score.cpp b/engines/director/score.cpp
index 7decd6b..2d78a70 100644
--- a/engines/director/score.cpp
+++ b/engines/director/score.cpp
@@ -202,16 +202,6 @@ void Score::loadArchive() {
}
}
-void copyStxt(TextCast *textCast, const Stxt *stxt) {
- textCast->fontId = stxt->_fontId;
- textCast->textSlant = stxt->_textSlant;
- textCast->fontSize = stxt->_fontSize;
- textCast->palinfo1 = stxt->_palinfo1;
- textCast->palinfo2 = stxt->_palinfo2;
- textCast->palinfo3 = stxt->_palinfo3;
- textCast->_ftext = stxt->_ftext;
-}
-
void Score::copyCastStxts() {
Common::HashMap<int, TextCast *>::iterator tc;
for (tc = _loadedText->begin(); tc != _loadedText->end(); ++tc) {
@@ -220,7 +210,7 @@ void Score::copyCastStxts() {
tc->_value->children[0].index;
if (_loadedStxts->getVal(stxtid)){
const Stxt *stxt = _loadedStxts->getVal(stxtid);
- copyStxt(tc->_value, stxt);
+ tc->_value->importStxt(stxt);
}
}
}
Commit: 415d9d660ecca0518c42e151eceedb58834ceb14
https://github.com/scummvm/scummvm/commit/415d9d660ecca0518c42e151eceedb58834ceb14
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2017-05-02T21:01:23+01:00
Commit Message:
DIRECTOR: Add CachedMacText
Changed paths:
A engines/director/cachedmactext.cpp
A engines/director/cachedmactext.h
engines/director/module.mk
diff --git a/engines/director/cachedmactext.cpp b/engines/director/cachedmactext.cpp
new file mode 100644
index 0000000..d2a40ad
--- /dev/null
+++ b/engines/director/cachedmactext.cpp
@@ -0,0 +1,115 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "engines/director/cachedmactext.h"
+#include "engines/director/cast.h"
+#include "graphics/macgui/macfontmanager.h"
+#include "graphics/macgui/mactext.h"
+#include "graphics/macgui/macwindowmanager.h"
+
+namespace Director {
+
+void CachedMacText::makeMacText() {
+ assert(_width != -1);
+ assert(_wm != NULL);
+
+ if ((int)_textCast->textAlign == -1)
+ _align = (Graphics::TextAlign)3;
+ else
+ _align = (Graphics::TextAlign)((int)_textCast->textAlign + 1);
+
+ _macText = new Graphics::MacText(_textCast->_ftext,
+ _wm,
+ _macFont,
+ 0x00,
+ 0xff,
+ _width,
+ _align,
+ 1);
+ // TODO destroy me
+}
+
+CachedMacText::CachedMacText(TextCast *const textCast,
+ int version,
+ int defaultWidth,
+ Graphics::MacWindowManager *const wm
+ )
+ :
+ _surface(NULL), _macFont(NULL),
+ _macText(NULL), _width(defaultWidth), _dirty(true), _textCast(textCast),
+ _wm(wm) {
+ _macFont = new Graphics::MacFont(_textCast->fontId,
+ _textCast->fontSize,
+ _textCast->textSlant);
+ // TODO destroy me
+
+ if (_width == -1) {
+ if (version >= 4) {
+ // This came from frame.cpp
+ _width = _textCast->initialRect.right;
+ } else {
+ _width = _textCast->initialRect.width();
+ }
+ }
+
+ if (_wm != NULL)
+ makeMacText();
+}
+
+void CachedMacText::setWm(Graphics::MacWindowManager *wm) {
+ if (wm != _wm) {
+ _dirty = true;
+ _wm = wm;
+ makeMacText();
+ }
+}
+
+void CachedMacText::clip(int width) {
+ if (width != _width) {
+ _dirty = true;
+ _width = width;
+ if (_wm != NULL)
+ makeMacText();
+ }
+}
+
+void CachedMacText::forceDirty() {
+ // STUB
+ assert(false);
+}
+
+const Graphics::ManagedSurface *CachedMacText::getSurface() {
+ assert(_wm != NULL);
+ if (_dirty) {
+ _macText->render();
+ _surface = _macText->getSurface();
+ _dirty = false;
+ }
+ return _surface;
+}
+
+int CachedMacText::getLineCount() {
+ assert(_macText != NULL);
+ return _macText->getLineCount();
+}
+
+} // End of namespace Director
diff --git a/engines/director/cachedmactext.h b/engines/director/cachedmactext.h
new file mode 100644
index 0000000..87d632b
--- /dev/null
+++ b/engines/director/cachedmactext.h
@@ -0,0 +1,66 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef DIRECTOR_CACHEDMACTEXT_H
+#define DIRECTOR_CACHEDMACTEXT_H
+
+#include "graphics/font.h"
+
+namespace Graphics {
+class MacFont;
+class ManagedSurface;
+class MacText;
+class MacWindowManager;
+}
+
+namespace Director {
+
+class TextCast;
+
+class CachedMacText {
+private:
+ int _width;
+ TextCast *const _textCast;
+ Graphics::MacWindowManager *_wm;
+ Graphics::MacFont *_macFont;
+ Graphics::MacText *_macText;
+ Graphics::TextAlign _align;
+ bool _dirty;
+ Graphics::ManagedSurface *_surface;
+ void makeMacText();
+public:
+ CachedMacText(TextCast *const textCast,
+ int version,
+ int defaultWidth = -1,
+ Graphics::MacWindowManager *const wm = NULL
+ );
+ void setWm(Graphics::MacWindowManager *wm);
+ void clip(int width);
+ void forceDirty();
+ const Graphics::ManagedSurface *getSurface();
+ int getLineCount();
+
+};
+
+} // End of namespace Director
+
+#endif
diff --git a/engines/director/module.mk b/engines/director/module.mk
index 55e1c26..73f4a4e 100644
--- a/engines/director/module.mk
+++ b/engines/director/module.mk
@@ -3,6 +3,7 @@ MODULE := engines/director
MODULE_OBJS = \
archive.o \
cast.o \
+ cachedmactext.o \
detection.o \
director.o \
events.o \
Commit: bd7ded3f56c61b4a9eb0798b34dcce17140af334
https://github.com/scummvm/scummvm/commit/bd7ded3f56c61b4a9eb0798b34dcce17140af334
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2017-05-02T21:01:23+01:00
Commit Message:
DIRECTOR: Add CachedMacText to TextCast
Changed paths:
engines/director/cast.cpp
engines/director/cast.h
diff --git a/engines/director/cast.cpp b/engines/director/cast.cpp
index 0dd6e53..0ee5a8f 100644
--- a/engines/director/cast.cpp
+++ b/engines/director/cast.cpp
@@ -21,6 +21,7 @@
*/
#include "director/director.h"
+#include "director/cachedmactext.h"
#include "director/cast.h"
#include "director/score.h"
@@ -177,6 +178,9 @@ TextCast::TextCast(Common::ReadStreamEndian &stream, uint16 version) {
}
modified = 0;
+
+ cachedMacText = new CachedMacText(this, version);
+ // TODO Destroy me
}
void TextCast::importStxt(const Stxt *stxt) {
diff --git a/engines/director/cast.h b/engines/director/cast.h
index a542bf7..7df9d94 100644
--- a/engines/director/cast.h
+++ b/engines/director/cast.h
@@ -31,6 +31,7 @@
namespace Director {
class Stxt;
+class CachedMacText;
enum CastType {
kCastTypeNull = 0,
@@ -141,6 +142,7 @@ public:
Common::String _ftext;
void importStxt(const Stxt *stxt);
+ CachedMacText *cachedMacText;
};
enum ButtonType {
Commit: ca89722d5795aed26b398107b9330f1beb4388cd
https://github.com/scummvm/scummvm/commit/ca89722d5795aed26b398107b9330f1beb4388cd
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2017-05-02T21:01:23+01:00
Commit Message:
DIRECTOR: Use CachedMacText for rendering
Changed paths:
engines/director/frame.cpp
diff --git a/engines/director/frame.cpp b/engines/director/frame.cpp
index af99248..cdf5283 100644
--- a/engines/director/frame.cpp
+++ b/engines/director/frame.cpp
@@ -29,6 +29,7 @@
#include "image/bmp.h"
#include "director/director.h"
+#include "director/cachedmactext.h"
#include "director/cast.h"
#include "director/frame.h"
#include "director/images.h"
@@ -770,21 +771,14 @@ void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteId, Commo
//uint32 rectLeft = textCast->initialRect.left;
//uint32 rectTop = textCast->initialRect.top;
-
- int alignment = (int)textCast->textAlign;
- if (alignment == -1)
- alignment = 3;
- else
- alignment++;
-
- Graphics::MacText mt(textCast->_ftext, _vm->_wm, macFont, 0x00, 0xff, width, (Graphics::TextAlign)alignment, 1);
- mt.render();
- const Graphics::ManagedSurface *textSurface = mt.getSurface();
+ textCast->cachedMacText->clip(width);
+ textCast->cachedMacText->setWm(_vm->_wm); // TODO this is not a good place to do it
+ const Graphics::ManagedSurface *textSurface = textCast->cachedMacText->getSurface();
height = textSurface->h;
if (textSize != NULL) {
// TODO: this offset could be due to incorrect fonts loaded!
- textSize->bottom = height + mt.getLineCount();
+ textSize->bottom = height + textCast->cachedMacText->getLineCount();
}
uint16 textX = 0, textY = 0;
More information about the Scummvm-git-logs
mailing list