Skip to content

Commit

Permalink
DIRECTOR: Load labels
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 f858362 commit 254b1e3
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
35 changes: 35 additions & 0 deletions engines/director/score.cpp
Expand Up @@ -46,6 +46,10 @@ Score::Score(Archive &movie) {
loadFrames(*_movieArchive->getResource(MKTAG('V','W','S','C'), 1024));
loadConfig(*_movieArchive->getResource(MKTAG('V','W','C','F'), 1024));
loadCastData(*_movieArchive->getResource(MKTAG('V','W','C','R'), 1024));

if (_movieArchive->hasResource(MKTAG('V','W','L','B'), 1024)) {
loadLabels(*_movieArchive->getResource(MKTAG('V','W','L','B'), 1024));
}
}

void Score::loadFrames(Common::SeekableReadStream &stream) {
Expand Down Expand Up @@ -131,6 +135,37 @@ void Score::loadCastData(Common::SeekableReadStream &stream) {
}
}

void Score::loadLabels(Common::SeekableReadStream &stream) {
uint16 count = stream.readUint16BE() + 1;
uint16 offset = count * 4 + 2;

uint16 frame = stream.readUint16BE();
uint16 stringPos = stream.readUint16BE() + offset;

for (uint16 i = 0; i < count; i++) {

uint16 nextFrame = stream.readUint16BE();
uint16 nextStringPos = stream.readUint16BE() + offset;
uint16 streamPos = stream.pos();

stream.seek(stringPos);

for (uint16 j = stringPos; j < nextStringPos; j++) {
_labels[frame] += stream.readByte();
}

stream.seek(streamPos);

frame = nextFrame;
stringPos = nextStringPos;
}

Common::HashMap<uint16, Common::String>::iterator j;
for (j = _labels.begin(); j != _labels.end(); ++j) {
debug("Frame %d, Label %s", j->_key, j->_value.c_str());
}
}

BitmapCast::BitmapCast(Common::SeekableReadStream &stream) {
/*byte flags = */ stream.readByte();
/*uint16 someFlaggyThing = */ stream.readUint16BE();
Expand Down
3 changes: 3 additions & 0 deletions engines/director/score.h
Expand Up @@ -25,6 +25,7 @@
#include "common/array.h"
#include "director/resource.h"
#include "graphics/managed_surface.h"
#include "common/str.h"

namespace Director {

Expand Down Expand Up @@ -195,9 +196,11 @@ class Score {
void loadConfig(Common::SeekableReadStream &stream);
void loadCastData(Common::SeekableReadStream &stream);
void loadFrames(Common::SeekableReadStream &stream);
void loadLabels(Common::SeekableReadStream &stream);
public:
Common::Array<Frame *> _frames;
Common::HashMap<int, Cast *> _casts;
Common::HashMap<uint16, Common::String> _labels;

private:
uint16 _versionMinor;
Expand Down

0 comments on commit 254b1e3

Please sign in to comment.