Skip to content

Commit

Permalink
DIRECTOR: Calculate values for text rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Iskrich authored and sev- committed Aug 3, 2016
1 parent 0f58203 commit b460a7c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
5 changes: 3 additions & 2 deletions engines/director/director.cpp
Expand Up @@ -201,7 +201,6 @@ end repeat\n\
//FIXME
_mainArchive = new RIFFArchive();
_mainArchive->openFile("bookshelf_example.mmm");

_currentScore = new Score(this);
debug(0, "Score name %s", _currentScore->getMacName().c_str());

Expand Down Expand Up @@ -415,15 +414,17 @@ void DirectorEngine::loadSharedCastsFrom(Common::String filename) {
if (dib.size() != 0) {
Common::Array<uint16>::iterator iterator;
for (iterator = dib.begin(); iterator != dib.end(); ++iterator) {
debug(3, "Shared DIB %d", *iterator);
_sharedDIB->setVal(*iterator, shardcst->getResource(MKTAG('D','I','B',' '), *iterator));
}
}

Common::Array<uint16> stxt = shardcst->getResourceIDList(MKTAG('D','I','B',' '));
Common::Array<uint16> stxt = shardcst->getResourceIDList(MKTAG('S','T','X','T'));

if (stxt.size() != 0) {
Common::Array<uint16>::iterator iterator;
for (iterator = stxt.begin(); iterator != stxt.end(); ++iterator) {
debug(3, "Shared STXT %d", *iterator);
_sharedSTXT->setVal(*iterator, shardcst->getResource(MKTAG('S','T','X','T'), *iterator));
}
}
Expand Down
30 changes: 29 additions & 1 deletion engines/director/score.cpp
Expand Up @@ -1240,7 +1240,35 @@ Image::ImageDecoder *Frame::getImageFrom(uint16 spriteId) {


void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteID) {
warning("STUB: renderText()");
Cast *textCast = _vm->_currentScore->_casts[_sprites[spriteID]->_castId];
Common::SeekableSubReadStreamEndian *textStream;

if (_vm->_currentScore->_movieArchive->hasResource(MKTAG('S','T','X','T'), spriteID + 1024)) {
textStream = _vm->_currentScore->_movieArchive->getResource(MKTAG('S','T','X','T'), spriteID + 1024);
} else {
textStream = _vm->getSharedSTXT()->getVal(spriteID + 1024);
}
/*uint32 unk1 = */ textStream->readUint32();
uint32 strLen = textStream->readUint32();
/*uin32 dataLen = */ textStream->readUint32();
Common::String text;

for (uint32 i = 0; i < strLen; i++) {
byte ch = textStream->readByte();
if (ch == 0x0d) {
ch = '\n';
}
text += ch;
}

uint32 rectLeft = static_cast<TextCast *>(_sprites[spriteID]->_cast)->initialRect.left;
uint32 rectTop = static_cast<TextCast *>(_sprites[spriteID]->_cast)->initialRect.top;

int x = _sprites[spriteID]->_startPoint.x + rectLeft;
int y = _sprites[spriteID]->_startPoint.y + rectTop;
int height = _sprites[spriteID]->_height;
int width = _sprites[spriteID]->_width;
//TODO render text
}

void Frame::drawBackgndTransSprite(Graphics::ManagedSurface &target, const Graphics::Surface &sprite, Common::Rect &drawRect) {
Expand Down
3 changes: 2 additions & 1 deletion engines/director/score.h
Expand Up @@ -30,6 +30,7 @@
#include "graphics/managed_surface.h"
#include "common/str.h"
#include "image/image_decoder.h"
#include "graphics/font.h"

namespace Director {

Expand Down Expand Up @@ -290,7 +291,6 @@ class Frame {
Frame(DirectorEngine *vm);
Frame(const Frame &frame);
~Frame();

void readChannel(Common::SeekableSubReadStreamEndian &stream, uint16 offset, uint16 size);
void prepareFrame(Score *score);
uint16 getSpriteIDFromPos(Common::Point pos);
Expand Down Expand Up @@ -378,6 +378,7 @@ class Score {
Common::HashMap<uint16, Common::String> _fontMap;
Graphics::ManagedSurface *_surface;
Graphics::ManagedSurface *_trailSurface;
Graphics::Font *_font;
Archive *_movieArchive;
Common::Rect _movieRect;

Expand Down

0 comments on commit b460a7c

Please sign in to comment.