From bb469dc84d9935335372c3c84c99ea99c06c3be4 Mon Sep 17 00:00:00 2001 From: Dmitry Iskrich Date: Mon, 4 Jul 2016 23:03:52 +0300 Subject: DIRECTOR: Lingo: Set/Get common sprite fields --- engines/director/lingo/lingo-the.cpp | 44 +++++++++++++++++++++++++++++++++--- engines/director/score.cpp | 8 +++++++ engines/director/score.h | 1 + 3 files changed, 50 insertions(+), 3 deletions(-) (limited to 'engines/director') diff --git a/engines/director/lingo/lingo-the.cpp b/engines/director/lingo/lingo-the.cpp index 168e9ee717..f772d0490f 100644 --- a/engines/director/lingo/lingo-the.cpp +++ b/engines/director/lingo/lingo-the.cpp @@ -24,6 +24,8 @@ namespace Director { +class Sprite; + static struct TheEntityProto { TheEntity entity; const char *name; @@ -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(d.u.i); + break; + default: error("Unprocessed setting field %d of sprite", field); } @@ -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); @@ -199,4 +236,5 @@ Datum Lingo::getTheSprite(int id, TheField field) { return d; } + } // End of namespace Director diff --git a/engines/director/score.cpp b/engines/director/score.cpp index 9e174987e8..dd3ab54eb8 100644 --- a/engines/director/score.cpp +++ b/engines/director/score.cpp @@ -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; diff --git a/engines/director/score.h b/engines/director/score.h index 8a3400b46d..ee0eaa2972 100644 --- a/engines/director/score.h +++ b/engines/director/score.h @@ -356,6 +356,7 @@ public: 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); -- cgit v1.2.3