Skip to content

Commit

Permalink
DIRECTOR: Made DirectorEngine::_currentScore private
Browse files Browse the repository at this point in the history
  • Loading branch information
sev- committed Feb 9, 2017
1 parent 5fb5287 commit c444de0
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 43 deletions.
3 changes: 2 additions & 1 deletion engines/director/director.h
Expand Up @@ -98,7 +98,6 @@ class DirectorEngine : public ::Engine {
Common::HashMap<int, Cast *> *getSharedCasts() const { return _sharedCasts; }

Common::HashMap<Common::String, Score *> *_movies;
Score *_currentScore;

Common::RandomSource _rnd;
Graphics::MacWindowManager *_wm;
Expand Down Expand Up @@ -142,6 +141,8 @@ class DirectorEngine : public ::Engine {
uint16 _currentPaletteLength;
Lingo *_lingo;

Score *_currentScore;

Graphics::MacPatterns _director3Patterns;
Graphics::MacPatterns _director3QuickDrawPatterns;

Expand Down
32 changes: 16 additions & 16 deletions engines/director/frame.cpp
Expand Up @@ -560,7 +560,7 @@ void Frame::renderSprites(Graphics::ManagedSurface &surface, bool renderTrail) {
break;
}
} else {
if (!_vm->_currentScore->_casts.contains(_sprites[i]->_castId)) {
if (!_vm->getCurrentScore()->_casts.contains(_sprites[i]->_castId)) {
if (!_vm->getSharedCasts()->contains(_sprites[i]->_castId)) {
warning("Cast id %d not found", _sprites[i]->_castId);
continue;
Expand All @@ -569,7 +569,7 @@ void Frame::renderSprites(Graphics::ManagedSurface &surface, bool renderTrail) {
cast = _vm->getSharedCasts()->getVal(_sprites[i]->_castId);
}
} else {
cast = _vm->_currentScore->_casts[_sprites[i]->_castId];
cast = _vm->getCurrentScore()->_casts[_sprites[i]->_castId];
}
castType = cast->type;
}
Expand Down Expand Up @@ -661,7 +661,7 @@ void Frame::renderShape(Graphics::ManagedSurface &surface, uint16 spriteId) {

void Frame::renderButton(Graphics::ManagedSurface &surface, uint16 spriteId, uint16 textId) {
uint16 castId = _sprites[spriteId]->_castId;
ButtonCast *button = static_cast<ButtonCast *>(_vm->_currentScore->_casts[castId]);
ButtonCast *button = static_cast<ButtonCast *>(_vm->getCurrentScore()->_casts[castId]);

uint32 rectLeft = button->initialRect.left;
uint32 rectTop = button->initialRect.top;
Expand Down Expand Up @@ -703,14 +703,14 @@ void Frame::renderButton(Graphics::ManagedSurface &surface, uint16 spriteId, uin
Image::ImageDecoder *Frame::getImageFrom(uint16 spriteId) {
uint16 imgId = spriteId + 1024;

if (_vm->getVersion() >= 4 && _vm->_currentScore->_casts[spriteId]->children.size() > 0)
imgId = _vm->_currentScore->_casts[spriteId]->children[0].index;
if (_vm->getVersion() >= 4 && _vm->getCurrentScore()->_casts[spriteId]->children.size() > 0)
imgId = _vm->getCurrentScore()->_casts[spriteId]->children[0].index;

Image::ImageDecoder *img = NULL;

if (_vm->_currentScore->getArchive()->hasResource(MKTAG('D', 'I', 'B', ' '), imgId)) {
if (_vm->getCurrentScore()->getArchive()->hasResource(MKTAG('D', 'I', 'B', ' '), imgId)) {
img = new DIBDecoder();
img->loadStream(*_vm->_currentScore->getArchive()->getResource(MKTAG('D', 'I', 'B', ' '), imgId));
img->loadStream(*_vm->getCurrentScore()->getArchive()->getResource(MKTAG('D', 'I', 'B', ' '), imgId));
return img;
}

Expand All @@ -728,9 +728,9 @@ Image::ImageDecoder *Frame::getImageFrom(uint16 spriteId) {
pic = _vm->getSharedBMP()->getVal(imgId);
pic->seek(0); // TODO: this actually gets re-read every loop... we need to rewind it!
bc = static_cast<BitmapCast *>(_vm->getSharedCasts()->getVal(spriteId));
} else if (_vm->_currentScore->getArchive()->hasResource(MKTAG('B', 'I', 'T', 'D'), imgId)) {
pic = _vm->_currentScore->getArchive()->getResource(MKTAG('B', 'I', 'T', 'D'), imgId);
bc = static_cast<BitmapCast *>(_vm->_currentScore->_casts[spriteId]);
} else if (_vm->getCurrentScore()->getArchive()->hasResource(MKTAG('B', 'I', 'T', 'D'), imgId)) {
pic = _vm->getCurrentScore()->getArchive()->getResource(MKTAG('B', 'I', 'T', 'D'), imgId);
bc = static_cast<BitmapCast *>(_vm->getCurrentScore()->_casts[spriteId]);
}

if (pic != NULL && bc != NULL) {
Expand All @@ -741,7 +741,7 @@ Image::ImageDecoder *Frame::getImageFrom(uint16 spriteId) {
imgId, w, h, bc->flags, bc->someFlaggyThing, bc->unk1, bc->unk2);
img = new BITDDecoder(w, h);
} else if (_vm->getVersion() < 6) {
bc = static_cast<BitmapCast *>(_vm->_currentScore->_casts[spriteId]);
bc = static_cast<BitmapCast *>(_vm->getCurrentScore()->_casts[spriteId]);
int w = bc->initialRect.width(), h = bc->initialRect.height();

debugC(2, kDebugImages, "id: %d, w: %d, h: %d, flags: %x, some: %x, unk1: %d, unk2: %d",
Expand Down Expand Up @@ -798,8 +798,8 @@ void Frame::inkBasedBlit(Graphics::ManagedSurface &targetSurface, const Graphics
void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteId, uint16 castId) {
Common::SeekableSubReadStreamEndian *textStream = NULL;

if (_vm->_currentScore->_movieArchive->hasResource(MKTAG('S', 'T', 'X', 'T'), castId)) {
textStream = _vm->_currentScore->_movieArchive->getResource(MKTAG('S', 'T', 'X', 'T'), castId);
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);
}
Expand All @@ -812,7 +812,7 @@ void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteId, Commo
return;

uint16 castId = _sprites[spriteId]->_castId;
TextCast *textCast = static_cast<TextCast *>(_vm->_currentScore->_casts[castId]);
TextCast *textCast = static_cast<TextCast *>(_vm->getCurrentScore()->_casts[castId]);

uint32 unk1 = textStream->readUint32();
uint32 strLen = textStream->readUint32();
Expand Down Expand Up @@ -906,10 +906,10 @@ void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteId, Commo
if (_vm->getVersion() >= 4 && textSize != NULL)
width = textCast->initialRect.right;

if (_vm->_currentScore->_fontMap.contains(textCast->fontId)) {
if (_vm->getCurrentScore()->_fontMap.contains(textCast->fontId)) {
// We need to make sure that the Shared Cast fonts have been loaded in?
// might need a mapping table here of our own.
// textCast->fontId = _vm->_wm->_fontMan->getFontIdByName(_vm->_currentScore->_fontMap[textCast->fontId]);
// textCast->fontId = _vm->_wm->_fontMan->getFontIdByName(_vm->getCurrentScore()->_fontMap[textCast->fontId]);
}

Graphics::MacFont macFont = Graphics::MacFont(textCast->fontId, textCast->fontSize, textCast->textSlant);
Expand Down
4 changes: 2 additions & 2 deletions engines/director/lingo/lingo-builtins.cpp
Expand Up @@ -904,8 +904,8 @@ void Lingo::b_printFrom(int nargs) {
}

void Lingo::b_quit(int nargs) {
if (g_director->_currentScore)
g_director->_currentScore->_stopPlay = true;
if (g_director->getCurrentScore())
g_director->getCurrentScore()->_stopPlay = true;

g_lingo->pushVoid();
}
Expand Down
14 changes: 7 additions & 7 deletions engines/director/lingo/lingo-funcs.cpp
Expand Up @@ -185,7 +185,7 @@ void Lingo::func_goto(Datum &frame, Datum &movie) {
}

_vm->_nextMovie = *movie.u.s;
_vm->_currentScore->_stopPlay = true;
_vm->getCurrentScore()->_stopPlay = true;

_vm->_nextMovieFrameS.clear();
_vm->_nextMovieFrameI = -1;
Expand Down Expand Up @@ -221,24 +221,24 @@ void Lingo::func_goto(Datum &frame, Datum &movie) {
}

void Lingo::func_gotoloop() {
if (!_vm->_currentScore)
if (!_vm->getCurrentScore())
return;

_vm->_currentScore->gotoLoop();
_vm->getCurrentScore()->gotoLoop();
}

void Lingo::func_gotonext() {
if (!_vm->_currentScore)
if (!_vm->getCurrentScore())
return;

_vm->_currentScore->gotoNext();
_vm->getCurrentScore()->gotoNext();
}

void Lingo::func_gotoprevious() {
if (!_vm->_currentScore)
if (!_vm->getCurrentScore())
return;

_vm->_currentScore->gotoPrevious();
_vm->getCurrentScore()->gotoPrevious();
}

void Lingo::func_cursor(int c) {
Expand Down
34 changes: 17 additions & 17 deletions engines/director/lingo/lingo-the.cpp
Expand Up @@ -317,20 +317,20 @@ void Lingo::setTheSprite(Datum &id1, int field, Datum &d) {

d.toInt(); // Enforce Integer

if (!_vm->_currentScore) {
if (!_vm->getCurrentScore()) {
warning("The sprite %d field %d setting over non-active score", id, field);
return;
}

Sprite *sprite = _vm->_currentScore->getSpriteById(id);
Sprite *sprite = _vm->getCurrentScore()->getSpriteById(id);

if (!sprite)
return;

switch (field) {
case kTheCastNum:
if (_vm->_currentScore->_casts.contains(d.u.i)) {
sprite->_cast = _vm->_currentScore->_casts[d.u.i];
if (_vm->getCurrentScore()->_casts.contains(d.u.i)) {
sprite->_cast = _vm->getCurrentScore()->_casts[d.u.i];
sprite->_castId = d.u.i;
}
break;
Expand Down Expand Up @@ -519,12 +519,12 @@ Datum Lingo::getTheSprite(Datum &id1, int field) {
return d;
}

if (!_vm->_currentScore) {
if (!_vm->getCurrentScore()) {
warning("The sprite %d field %d setting over non-active score", id, field);
return d;
}

Sprite *sprite = _vm->_currentScore->getSpriteById(id);
Sprite *sprite = _vm->getCurrentScore()->getSpriteById(id);

if (!sprite)
return d;
Expand Down Expand Up @@ -630,14 +630,14 @@ Datum Lingo::getTheCast(Datum &id1, int field) {
return d;
}

if (!_vm->_currentScore) {
if (!_vm->getCurrentScore()) {
warning("The cast %d field %d setting over non-active score", id, field);
return d;
}

Cast *cast;
CastInfo *castInfo;
if (!_vm->_currentScore->_casts.contains(id)) {
if (!_vm->getCurrentScore()->_casts.contains(id)) {
if (field == kTheLoaded) {
d.type = INT;
d.u.i = 0;
Expand All @@ -648,8 +648,8 @@ Datum Lingo::getTheCast(Datum &id1, int field) {
warning("The cast %d found", id);
}

cast = _vm->_currentScore->_casts[id];
castInfo = _vm->_currentScore->_castsInfo[id];
cast = _vm->getCurrentScore()->_casts[id];
castInfo = _vm->getCurrentScore()->_castsInfo[id];

d.type = INT;

Expand Down Expand Up @@ -683,7 +683,7 @@ Datum Lingo::getTheCast(Datum &id1, int field) {
return d;
}

ShapeCast *shape = static_cast<ShapeCast *>(_vm->_currentScore->_casts[id]);
ShapeCast *shape = static_cast<ShapeCast *>(_vm->getCurrentScore()->_casts[id]);
d.u.i = shape->bgCol;
}
break;
Expand All @@ -695,7 +695,7 @@ Datum Lingo::getTheCast(Datum &id1, int field) {
return d;
}

ShapeCast *shape = static_cast<ShapeCast *>(_vm->_currentScore->_casts[id]);
ShapeCast *shape = static_cast<ShapeCast *>(_vm->getCurrentScore()->_casts[id]);
d.u.i = shape->fgCol;
}
break;
Expand All @@ -721,13 +721,13 @@ void Lingo::setTheCast(Datum &id1, int field, Datum &d) {
return;
}

if (!_vm->_currentScore) {
if (!_vm->getCurrentScore()) {
warning("The cast %d field %d setting over non-active score", id, field);
return;
}

Cast *cast = _vm->_currentScore->_casts[id];
CastInfo *castInfo = _vm->_currentScore->_castsInfo[id];
Cast *cast = _vm->getCurrentScore()->_casts[id];
CastInfo *castInfo = _vm->getCurrentScore()->_castsInfo[id];

if (!cast) {
warning("The cast %d found", id);
Expand Down Expand Up @@ -761,7 +761,7 @@ void Lingo::setTheCast(Datum &id1, int field, Datum &d) {
if (cast->type != kCastShape) {
warning("Field %d of cast %d not found", field, id);
}
ShapeCast *shape = static_cast<ShapeCast *>(_vm->_currentScore->_casts[id]);
ShapeCast *shape = static_cast<ShapeCast *>(_vm->getCurrentScore()->_casts[id]);
shape->bgCol = d.u.i;
shape->modified = 1;
}
Expand All @@ -772,7 +772,7 @@ void Lingo::setTheCast(Datum &id1, int field, Datum &d) {
warning("Field %d of cast %d not found", field, id);
return;
}
ShapeCast *shape = static_cast<ShapeCast *>(_vm->_currentScore->_casts[id]);
ShapeCast *shape = static_cast<ShapeCast *>(_vm->getCurrentScore()->_casts[id]);
shape->fgCol = d.u.i;
shape->modified = 1;
}
Expand Down

0 comments on commit c444de0

Please sign in to comment.