From 1808dcdc3011d7e7ceed9cad98410e99ec0f61c0 Mon Sep 17 00:00:00 2001 From: Dmitry Iskrich Date: Tue, 5 Jul 2016 18:45:18 +0300 Subject: DIRECTOR: Add modified flag, Lingo: Handle some common cast fields --- engines/director/lingo/lingo-the.cpp | 134 ++++++++++++++++++++++++++++++----- engines/director/lingo/lingo.h | 2 + engines/director/score.cpp | 3 + engines/director/score.h | 1 + 4 files changed, 123 insertions(+), 17 deletions(-) diff --git a/engines/director/lingo/lingo-the.cpp b/engines/director/lingo/lingo-the.cpp index 5ee41551a0..b3c070286a 100644 --- a/engines/director/lingo/lingo-the.cpp +++ b/engines/director/lingo/lingo-the.cpp @@ -101,33 +101,42 @@ static struct TheEntityFieldProto { { kTheSprite, "volume", kTheVolume }, { kTheSprite, "width", kTheWidth }, - { kTheCast, "backColor", kTheBackColor }, + //Common cast fields + { kTheCast, "width", kTheWidth }, + { kTheCast, "height", kTheHeight }, + { kTheCast, "filename", kTheFilename }, + { kTheCast, "scriptText", kTheScriptText }, { kTheCast, "castType", kTheCastType }, + { kTheCast, "name", kTheName }, + { kTheCast, "rect", kTheRect }, + { kTheCast, "number", kTheNumber }, + { kTheCast, "modified", kTheModified }, + { kTheCast, "loaded", kTheLoaded }, + { kTheCast, "purgePriority",kThePurgePriority }, //0 Never purge, 1 Purge Last, 2 Purge next, 2 Purge normal + + //Shape fields + { kTheCast, "backColor", kTheBackColor }, + { kTheCast, "foreColor", kTheForeColor }, + + //Digital video fields { kTheCast, "controller", kTheController }, - { kTheCast, "depth", kTheDepth }, { kTheCast, "directToStage",kTheDirectToStage }, - { kTheCast, "filename", kTheFilename }, - { kTheCast, "foreColor", kTheForeColor }, { kTheCast, "frameRate", kTheFrameRate }, - { kTheCast, "hilite", kTheHilite }, - { kTheCast, "height", kTheHeight }, { kTheCast, "loop", kTheLoop }, - { kTheCast, "loaded", kTheLoaded }, - { kTheCast, "modified", kTheModified }, - { kTheCast, "number", kTheNumber }, - { kTheCast, "name", kTheName }, - { kTheCast, "palette", kThePalette }, { kTheCast, "pausedAtStart",kThePausedAtStart }, - { kTheCast, "picture", kThePicture }, { kTheCast, "preload", kThePreload }, - { kTheCast, "purgePriority",kThePurgePriority }, - { kTheCast, "rect", kTheRect }, + { kTheCast, "sound", kTheSound }, // 0-1 off-on + + //Bitmap fields + { kTheCast, "depth", kTheDepth }, { kTheCast, "regPoint", kTheRegPoint }, - { kTheCast, "scriptText", kTheScriptText }, + { kTheCast, "palette", kThePalette }, + { kTheCast, "picture", kThePicture }, + + //TextCast fields { kTheCast, "size", kTheSize }, - { kTheCast, "sound", kTheSound }, + { kTheCast, "hilite", kTheHilite }, { kTheCast, "text", kTheText }, - { kTheCast, "width", kTheWidth }, { kTheWindow, "drawRect", kTheDrawRect }, { kTheWindow, "filename", kTheFilename }, @@ -206,6 +215,8 @@ Datum Lingo::getTheEntity(TheEntity entity, int id, TheField field) { case kTheSprite: d = getTheSprite(id, field); break; + case kTheCast: + d = getTheCast(id, field); case kThePerFrameHook: warning("STUB: getting the perframehook"); break; @@ -254,5 +265,94 @@ Datum Lingo::getTheSprite(int id, TheField field) { return d; } +Datum Lingo::getTheCast(int id, TheField field) { + Datum d; + d.type = INT; + + Cast *cast; + if (!_vm->_currentScore->_casts.contains(id)) { + + if (field == kTheLoaded) { + d.u.i = 0; + } + + return d; + } else { + error ("Not cast %d found", id); + } + cast = _vm->_currentScore->_casts[id]; + + switch (field) { + case kTheCastType: + d.u.i = cast->type; + break; + case kTheWidth: + d.u.i = cast->initialRect.width(); + break; + case kTheHeight: + d.u.i = cast->initialRect.height(); + break; + case kTheBackColor: + { + if (cast->type != kCastShape) + error("Field %d of cast %d not found", field, id); + ShapeCast *shape = static_cast(_vm->_currentScore->_casts[id]); + d.u.i = shape->bgCol; + } + break; + case kTheForeColor: + { + if (cast->type != kCastShape) + error("Field %d of cast %d not found", field, id); + ShapeCast *shape = static_cast(_vm->_currentScore->_casts[id]); + d.u.i = shape->fgCol; + } + break; + case kTheLoaded: + d.u.i = 1; //Not loaded handled above + break; + default: + error("Unprocessed getting field %d of cast %d", field, id); + //TODO find out about String fields + } +} + +void Lingo::setTheCast(int id, TheField field, Datum &d) { + Cast *cast = _vm->_currentScore->_casts[id]; + switch (field) { + case kTheCastType: + cast->type = static_cast(d.u.i); + cast->modified = 1; + break; + case kTheWidth: + cast->initialRect.setWidth(d.u.i); + cast->modified = 1; + break; + case kTheHeight: + cast->initialRect.setHeight(d.u.i); + cast->modified = 1; + break; + case kTheBackColor: + { + if (cast->type != kCastShape) + error("Field %d of cast %d not found", field, id); + ShapeCast *shape = static_cast(_vm->_currentScore->_casts[id]); + shape->bgCol = d.u.i; + shape->modified = 1; + } + break; + case kTheForeColor: + { + if (cast->type != kCastShape) + error("Field %d of cast %d not found", field, id); + ShapeCast *shape = static_cast(_vm->_currentScore->_casts[id]); + shape->fgCol = d.u.i; + shape->modified = 1; + } + break; + default: + error("Unprocessed getting field %d of cast %d", field, id); + } +} } // End of namespace Director diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h index 8527d33369..de3847c188 100644 --- a/engines/director/lingo/lingo.h +++ b/engines/director/lingo/lingo.h @@ -226,8 +226,10 @@ public: public: void setTheEntity(TheEntity entity, int id, TheField field, Datum &d); void setTheSprite(int id, TheField field, Datum &d); + void setTheCast(int id, TheField field, Datum &d); Datum getTheEntity(TheEntity entity, int id, TheField field); Datum getTheSprite(int id, TheField field); + Datum getTheCast(int id, TheField field); public: ScriptData *_currentScript; diff --git a/engines/director/score.cpp b/engines/director/score.cpp index 53b26629c2..24d0b3494f 100644 --- a/engines/director/score.cpp +++ b/engines/director/score.cpp @@ -654,6 +654,7 @@ BitmapCast::BitmapCast(Common::SeekableSubReadStreamEndian &stream) { /*uint16 unk1 =*/ stream.readUint16(); /*uint16 unk2 =*/ stream.readUint16(); } + modified = 0; } TextCast::TextCast(Common::SeekableSubReadStreamEndian &stream) { @@ -678,6 +679,7 @@ TextCast::TextCast(Common::SeekableSubReadStreamEndian &stream) { textFlags.push_back(kTextFlagDoNotWrap); //again supposition fontSize = stream.readUint16(); + modified = 0; } ShapeCast::ShapeCast(Common::SeekableSubReadStreamEndian &stream) { @@ -691,6 +693,7 @@ ShapeCast::ShapeCast(Common::SeekableSubReadStreamEndian &stream) { fillType = stream.readByte(); lineThickness = stream.readByte(); lineDirection = stream.readByte(); + modified = 0; } Common::Rect Score::readRect(Common::SeekableSubReadStreamEndian &stream) { diff --git a/engines/director/score.h b/engines/director/score.h index 2f17783d0e..b0164edb86 100644 --- a/engines/director/score.h +++ b/engines/director/score.h @@ -170,6 +170,7 @@ enum TransitionType { struct Cast { CastType type; Common::Rect initialRect; + byte modified; }; struct BitmapCast : Cast { -- cgit v1.2.3