Skip to content

Commit

Permalink
DIRECTOR: Lingo: Set/Get common sprite fields
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 fb51685 commit bb469dc
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 3 deletions.
44 changes: 41 additions & 3 deletions engines/director/lingo/lingo-the.cpp
Expand Up @@ -24,6 +24,8 @@

namespace Director {

class Sprite;

static struct TheEntityProto {
TheEntity entity;
const char *name;
Expand Down Expand Up @@ -159,10 +161,28 @@ void Lingo::setTheEntity(TheEntity entity, int id, TheField field, Datum &d) {
}

void Lingo::setTheSprite(int id, TheField field, Datum &d) {
Sprite *sprite = _vm->_currentScore->getSpriteById(id);

switch (field) {
case kTheCastNum:
warning("STUB: setting thecastnum of sprite %d", id);
if (_vm->_currentScore->_casts.contains(d.u.i)) {
sprite->_cast = _vm->_currentScore->_casts[d.u.i];
sprite->_castId = d.u.i;
}
break;
case kTheWidth:
sprite->_width = d.u.i;
break;
case kTheHeight:
sprite->_height = d.u.i;
break;
case kTheTrails:
sprite->_trails = d.u.i;
break;
case kTheInk:
sprite->_ink = static_cast<InkType>(d.u.i);
break;

default:
error("Unprocessed setting field %d of sprite", field);
}
Expand All @@ -187,10 +207,27 @@ Datum Lingo::getTheEntity(TheEntity entity, int id, TheField field) {

Datum Lingo::getTheSprite(int id, TheField field) {
Datum d;

Sprite *sprite = _vm->_currentScore->getSpriteById(id);
switch (field) {
case kTheCastNum:
warning("STUB: getting thecastnum of sprite %d", id);
d.type = INT;
d.u.i = sprite->_castId;
break;
case kTheWidth:
d.type = INT;
d.u.i = sprite->_width;
break;
case kTheHeight:
d.type = INT;
d.u.i = sprite->_height;
break;
case kTheTrails:
d.type = INT;
d.u.i = sprite->_trails;
break;
case kTheInk:
d.type = INT;
d.u.i = sprite->_ink;
break;
default:
error("Unprocessed getting field %d of sprite", field);
Expand All @@ -199,4 +236,5 @@ Datum Lingo::getTheSprite(int id, TheField field) {
return d;
}


} // End of namespace Director
8 changes: 8 additions & 0 deletions engines/director/score.cpp
Expand Up @@ -821,6 +821,14 @@ void Score::processEvents() {
}
}

Sprite *Score::getSpriteById(uint16 id) {
if (_frames[_currentFrame]->_sprites[id]) {
return _frames[_currentFrame]->_sprites[id];
} else {
error("Sprite on frame %d width id %d not found", _currentFrame, id);
}
}

Frame::Frame(DirectorEngine *vm) {
_vm = vm;
_transDuration = 0;
Expand Down
1 change: 1 addition & 0 deletions engines/director/score.h
Expand Up @@ -356,6 +356,7 @@ class Score {
void loadCastData(Common::SeekableSubReadStreamEndian &stream);
void setCurrentFrame(uint16 frameId) { _currentFrame = frameId; }
Common::String getMacName() const { return _macName; }
Sprite *getSpriteById(uint16 id);
private:
void update();
void readVersion(uint32 rid);
Expand Down

0 comments on commit bb469dc

Please sign in to comment.