Skip to content

Commit

Permalink
DIRECTOR: Add modified flag, Lingo: Handle some common cast 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 98603a4 commit 1808dcd
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 17 deletions.
134 changes: 117 additions & 17 deletions engines/director/lingo/lingo-the.cpp
Expand Up @@ -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 },
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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<ShapeCast *>(_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<ShapeCast *>(_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<CastType>(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<ShapeCast *>(_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<ShapeCast *>(_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
2 changes: 2 additions & 0 deletions engines/director/lingo/lingo.h
Expand Up @@ -226,8 +226,10 @@ class Lingo {
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;
Expand Down
3 changes: 3 additions & 0 deletions engines/director/score.cpp
Expand Up @@ -654,6 +654,7 @@ BitmapCast::BitmapCast(Common::SeekableSubReadStreamEndian &stream) {
/*uint16 unk1 =*/ stream.readUint16();
/*uint16 unk2 =*/ stream.readUint16();
}
modified = 0;
}

TextCast::TextCast(Common::SeekableSubReadStreamEndian &stream) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions engines/director/score.h
Expand Up @@ -170,6 +170,7 @@ enum TransitionType {
struct Cast {
CastType type;
Common::Rect initialRect;
byte modified;
};

struct BitmapCast : Cast {
Expand Down

0 comments on commit 1808dcd

Please sign in to comment.