Skip to content

Commit

Permalink
DIRECTOR: Using shared casts for 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 aac6c96 commit 0b9e360
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
3 changes: 3 additions & 0 deletions engines/director/director.h
Expand Up @@ -67,6 +67,9 @@ class DirectorEngine : public ::Engine {
const byte *getPalette() const { return _currentPalette; }
uint16 getPaletteColorCount() const { return _currentPaletteLength; }
void loadSharedCastsFrom(Common::String filename);
Common::HashMap<int, Common::SeekableReadStream *> getSharedDIB() const { return _sharedDIB; }
Common::HashMap<int, Common::SeekableReadStream *> getSharedSTXT() const { return _sharedSTXT; }
Common::HashMap<int, Cast *> getSharedCasts() const { return _sharedCasts; }

Common::HashMap<Common::String, Score *> *_movies;
Score *_currentScore;
Expand Down
24 changes: 20 additions & 4 deletions engines/director/score.cpp
Expand Up @@ -1118,7 +1118,18 @@ void Frame::renderSprites(Graphics::ManagedSurface &surface, bool renderTrail) {
if ((_sprites[i]->_trails == 0 && renderTrail) || (_sprites[i]->_trails == 1 && !renderTrail))
continue;

Cast *cast = _vm->_currentScore->_casts[_sprites[i]->_castId];
Cast *cast;
if (!_vm->_currentScore->_casts.contains(_sprites[i]->_castId)) {
if (!_vm->getSharedCasts().contains(_sprites[i]->_castId)) {
warning("Cast id %d not found", _sprites[i]->_castId);
continue;
} else {
cast = _vm->getSharedCasts().getVal(_sprites[i]->_castId);
}
} else {
cast = _vm->_currentScore->_casts[_sprites[i]->_castId];
}

if (cast->type == kCastText) {
renderText(surface, i);
continue;
Expand All @@ -1128,11 +1139,16 @@ void Frame::renderSprites(Graphics::ManagedSurface &surface, bool renderTrail) {
uint32 imgId = 1024 + _sprites[i]->_castId;

if (!_vm->_currentScore->getArchive()->hasResource(MKTAG('D', 'I', 'B', ' '), imgId)) {
continue;
if (!_vm->getSharedDIB().contains(imgId)) {
warning("DIB id %d not found", imgId);
continue;
} else {
img.loadStream(*_vm->getSharedDIB().getVal(imgId));
}
} else {
img.loadStream(*_vm->_currentScore->getArchive()->getResource(MKTAG('D', 'I', 'B', ' '), imgId));
}

img.loadStream(*_vm->_currentScore->getArchive()->getResource(MKTAG('D', 'I', 'B', ' '), imgId));

uint32 regX = static_cast<BitmapCast *>(_sprites[i]->_cast)->regX;
uint32 regY = static_cast<BitmapCast *>(_sprites[i]->_cast)->regY;
uint32 rectLeft = static_cast<BitmapCast *>(_sprites[i]->_cast)->initialRect.left;
Expand Down

0 comments on commit 0b9e360

Please sign in to comment.