DIRECTOR: Support individual auto-puppet sprites properties

According to "Director in a Nutshell, page 15", autoPuppet unlike
puppet is not a single property, instead it is individual for each
sprite property, ie we can have auto-puppet locH of sprite, but
other properties are not auto-puppet.

This change adds support for individual auto-puppet properties.
This commit is contained in:
Harishankar Kumar 2023-07-17 00:45:48 +05:30 committed by Eugene Sandulenko
parent b1da9423b9
commit e01bb235f7
4 changed files with 101 additions and 7 deletions

View File

@ -368,7 +368,7 @@ void Channel::setCast(CastMemberID memberID) {
if (!_sprite->_puppet && g_director->getVersion() >= 600) {
// Based on Director in a Nutshell, page 15
_sprite->_autoPuppet = true;
_sprite->setAutoPuppet(kAPCast, true);
}
}
@ -550,7 +550,7 @@ void Channel::setWidth(int w) {
if (!_sprite->_puppet && g_director->getVersion() >= 600) {
// Based on Director in a Nutshell, page 15
_sprite->_autoPuppet = true;
_sprite->setAutoPuppet(kAPWidth, true);
}
}
@ -561,7 +561,7 @@ void Channel::setHeight(int h) {
if (!_sprite->_puppet && g_director->getVersion() >= 600) {
// Based on Director in a Nutshell, page 15
_sprite->_autoPuppet = true;
_sprite->setAutoPuppet(kAPHeight, true);
}
}
@ -583,7 +583,7 @@ void Channel::setBbox(int l, int t, int r, int b) {
if (!_sprite->_puppet && g_director->getVersion() >= 600) {
// Based on Director in a Nutshell, page 15
_sprite->_autoPuppet = true;
_sprite->setAutoPuppet(kAPBbox, true);
}
}
@ -599,7 +599,7 @@ void Channel::setPosition(int x, int y, bool force) {
if (!_sprite->_puppet && g_director->getVersion() >= 600) {
// Based on Director in a Nutshell, page 15
_sprite->_autoPuppet = true;
_sprite->setAutoPuppet(kAPLoc, true);
}
}

View File

@ -1446,6 +1446,11 @@ void Lingo::setTheSprite(Datum &id1, int field, Datum &d) {
if (newColor != sprite->_backColor) {
sprite->_backColor = newColor;
channel->_dirty = true;
if (!sprite->_puppet && g_director->getVersion() >= 600) {
// Based on Director in a Nutshell, page 15
sprite->setAutoPuppet(kAPBackColor, true);
}
}
}
break;
@ -1457,6 +1462,11 @@ void Lingo::setTheSprite(Datum &id1, int field, Datum &d) {
sprite->_blendAmount = blend;
channel->_dirty = true;
}
if (!sprite->_puppet && g_director->getVersion() >= 600) {
// Based on Director in a Nutshell, page 15
sprite->setAutoPuppet(kAPBlend, true);
}
}
break;
case kTheCastNum:
@ -1526,6 +1536,11 @@ void Lingo::setTheSprite(Datum &id1, int field, Datum &d) {
sprite->_foreColor = newColor;
channel->_dirty = true;
}
if (!sprite->_puppet && g_director->getVersion() >= 600) {
// Based on Director in a Nutshell, page 15
sprite->setAutoPuppet(kAPForeColor, true);
}
}
break;
case kTheHeight:
@ -1534,6 +1549,12 @@ void Lingo::setTheSprite(Datum &id1, int field, Datum &d) {
channel->setHeight(d.asInt());
channel->_dirty = true;
}
if (!sprite->_puppet && g_director->getVersion() >= 600) {
// Based on Director in a Nutshell, page 15
sprite->setAutoPuppet(kAPHeight, true);
}
break;
case kTheImmediate:
sprite->_immediate = (bool)d.asInt();
@ -1543,6 +1564,12 @@ void Lingo::setTheSprite(Datum &id1, int field, Datum &d) {
sprite->_ink = static_cast<InkType>(d.asInt());
channel->_dirty = true;
}
if (!sprite->_puppet && g_director->getVersion() >= 600) {
// Based on Director in a Nutshell, page 15
sprite->setAutoPuppet(kAPInk, true);
}
break;
case kTheLineSize:
if (d.asInt() != sprite->_thickness) {
@ -1567,6 +1594,12 @@ void Lingo::setTheSprite(Datum &id1, int field, Datum &d) {
}
channel->setPosition(d.asInt(), channel->_currentPoint.y);
}
if (!sprite->_puppet && g_director->getVersion() >= 600) {
// Based on Director in a Nutshell, page 15
sprite->setAutoPuppet(kAPLocH, true);
}
break;
case kTheLocV:
if (d.asInt() != channel->_currentPoint.y) {
@ -1576,9 +1609,21 @@ void Lingo::setTheSprite(Datum &id1, int field, Datum &d) {
}
channel->setPosition(channel->_currentPoint.x, d.asInt());
}
if (!sprite->_puppet && g_director->getVersion() >= 600) {
// Based on Director in a Nutshell, page 15
sprite->setAutoPuppet(kAPLocV, true);
}
break;
case kTheMoveableSprite:
sprite->_moveable = (bool)d.asInt();
if (!sprite->_puppet && g_director->getVersion() >= 600) {
// Based on Director in a Nutshell, page 15
sprite->setAutoPuppet(kAPMoveable, true);
}
break;
case kTheMovieRate:
channel->_movieRate = d.asFloat();
@ -1616,6 +1661,12 @@ void Lingo::setTheSprite(Datum &id1, int field, Datum &d) {
);
channel->_dirty = true;
}
if (!sprite->_puppet && g_director->getVersion() >= 600) {
// Based on Director in a Nutshell, page 15
sprite->setAutoPuppet(kAPRect, true);
}
break;
case kTheStartTime:
channel->_startTime = d.asInt();
@ -1668,6 +1719,12 @@ void Lingo::setTheSprite(Datum &id1, int field, Datum &d) {
channel->setWidth(d.asInt());
channel->_dirty = true;
}
if (!sprite->_puppet && g_director->getVersion() >= 600) {
// Based on Director in a Nutshell, page 15
sprite->setAutoPuppet(kAPWidth, true);
}
break;
default:
warning("Lingo::setTheSprite(): Unprocessed setting field \"%s\" of sprite", field2str(field));

View File

@ -62,7 +62,7 @@ Sprite::Sprite(Frame *frame) {
_moveable = false;
_editable = false;
_puppet = false;
_autoPuppet = false; // Based on Director in a Nutshell, page 15
_autoPuppet = kAPNone; // Based on Director in a Nutshell, page 15
_immediate = false;
_backColor = g_director->_wm->_colorWhite;
_foreColor = g_director->_wm->_colorBlack;
@ -391,6 +391,17 @@ void Sprite::setPattern(uint16 pattern) {
}
}
void Sprite::setAutoPuppet(AutoPuppetProperty property, bool value) {
if (value)
_autoPuppet |= (1 << property);
else
_autoPuppet &= ~(1 << property);
}
bool Sprite::getAutoPuppet(AutoPuppetProperty property) {
return (_autoPuppet & (1 << property)) != 0;
}
bool Sprite::checkSpriteType() {
// check whether the sprite type match the cast type
// if it doesn't match, then we treat it as transparent

View File

@ -29,6 +29,30 @@ class BitmapCastMember;
class ShapeCastMember;
class TextCastMember;
/* Director in a Nutshell, page 15:
The following properties of a sprite are auto-puppeted whenever the property is
set: backColor, blend, editable, foreColor, beight, ink, loc, locH, locV, member,
moveable, rect, and width Auto-puppeting of individual properties has no effect
on the puppet of sprite property. */
enum AutoPuppetProperty {
kAPNone = 0,
kAPCast,
kAPBackColor,
kAPBbox,
kAPBlend,
kAPEditable,
kAPForeColor,
kAPHeight,
kAPInk,
kAPLoc,
kAPLocH,
kAPLocV,
kAPMember,
kAPMoveable,
kAPRect,
kAPWidth,
};
class Sprite {
public:
Sprite(Frame *frame = nullptr);
@ -56,6 +80,8 @@ public:
MacShape *getShape();
uint32 getForeColor();
uint32 getBackColor();
void setAutoPuppet(AutoPuppetProperty property, bool value);
bool getAutoPuppet(AutoPuppetProperty property);
Frame *_frame;
Score *_score;
@ -85,7 +111,7 @@ public:
bool _moveable;
bool _editable;
bool _puppet;
bool _autoPuppet; // autopuppet, based upon Director in a Nutshell, page 15
uint32 _autoPuppet; // autopuppet, based upon Director in a Nutshell, page 15
bool _immediate;
uint32 _backColor;
uint32 _foreColor;