ScummVM API documentation
sprite.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef DIRECTOR_SPRITE_H
23 #define DIRECTOR_SPRITE_H
24 
25 #include "director/spriteinfo.h"
26 
27 namespace Director {
28 
29 class Frame;
30 class BitmapCastMember;
31 class ShapeCastMember;
32 class TextCastMember;
33 
34 /* Director in a Nutshell, page 15:
35 The following properties of a sprite are auto-puppeted whenever the property is
36 set: backColor, blend, editable, foreColor, beight, ink, loc, locH, locV, member,
37 moveable, rect, and width Auto-puppeting of individual properties has no effect
38 on the puppet of sprite property. */
39 enum AutoPuppetProperty {
40  kAPNone = 0,
41  kAPCast,
42  kAPBackColor,
43  kAPBbox,
44  kAPBlend,
45  kAPEditable,
46  kAPForeColor,
47  kAPHeight,
48  kAPInk,
49  kAPLoc,
50  kAPLocH,
51  kAPLocV,
52  kAPMember,
53  kAPMoveable,
54  kAPRect,
55  kAPWidth,
56  kAPThickness,
57 };
58 
59 enum ThicknessFlags {
60  kTThickness = 0x0F,
61  kTHasBlend = 0x10,
62  kTFlipH = 0x20,
63  kTFlipV = 0x40,
64  kTFlip = (kTFlipH | kTFlipV),
65  kTTweened = 0x80,
66 };
67 
68 // Director treats changes of sprites between score frames as deltas.
69 // Only the delta is applied to what's on the screen.
70 // If a sprite has the puppet flag, or a field has been autopuppeted,
71 // then that will block the sprite/fields from being updated by the score.
72 // In addition, the program can turn off the puppet flag at any time, which
73 // will revert the sprite to whatever was in the score.
74 
75 // In order to keep a single frame read and copying pass, when reading the frame
76 // data we keep track of what fields have changed, so that the frame can be
77 // stored as a full copy but applied as a delta.
78 
79 enum SpriteCopyBackMask {
80  kSCBNoMask = -1,
81  kSCBScriptId = 0x00001,
82  kSCBSpriteType = 0x00002,
83  kSCBEnabled = 0x00004,
84  kSCBForeColor = 0x00008,
85  kSCBBackColor = 0x00010,
86  kSCBThickness = 0x00020,
87  kSCBInk = 0x00040,
88  kSCBPattern = 0x00080,
89  kSCBCastId = 0x00100,
90  kSCBStartPoint = 0x00200,
91  kSCBHeight = 0x00400,
92  kSCBWidth = 0x00800,
93  kSCBMoveable = 0x01000,
94  kSCBBlendAmount = 0x02000,
95  kSCBSpriteListIdx = 0x04000,
96  kSCBFlags = 0x08000,
97  kSCBAngle = 0x10000,
98 };
99 
100 class Sprite {
101 public:
102  Sprite(Frame *frame = nullptr);
103  Sprite(const Sprite &sprite);
104  Sprite& operator=(const Sprite &sprite);
105  bool operator==(const Sprite &sprite);
106  ~Sprite();
107 
108  Frame *getFrame() const { return _frame; }
109  Score *getScore() const { return _score; }
110 
111  void reset();
112 
113  bool getEditable();
114 
115  bool respondsToMouse();
116  bool isActive();
117  bool shouldHilite();
118  bool checkSpriteType();
119 
120  uint16 getPattern();
121  void setPattern(uint16 pattern);
122 
123  void setCast(CastMemberID memberID, bool replaceDims = true);
124  bool isQDShape();
125  Graphics::Surface *getQDMatte();
126  void createQDMatte();
127  MacShape *getShape();
128  uint32 getForeColor();
129  uint32 getBackColor();
130  void setAutoPuppet(AutoPuppetProperty property, bool value);
131  bool getAutoPuppet(AutoPuppetProperty property);
132 
133  inline int getWidth() { return _width; }
134  void setWidth(int w);
135  inline int getHeight() { return _height; }
136  void setHeight(int h);
137 
138  Common::Rect getBbox(bool unstretched);
139  void setBbox(int l, int t, int r, int b);
140 
141  Common::Point getPosition();
142  void setPosition(int x, int y);
143 
144  Common::String formatInfo();
145 
146  void replaceFrom(Sprite *nextSprite);
147 
148  Frame *_frame;
149  Score *_score;
150  Movie *_movie;
151 
152  Graphics::FloodFill *_matte; // matte for quickdraw shape
153 
154  uint32 _copyBackMask;
155 
156  CastMemberID _scriptId;
157  byte _colorcode; // x40 editable, 0x80 moveable
158  byte _blendAmount;
159  uint32 _unk3;
160 
161  bool _enabled;
162  SpriteType _spriteType;
163  byte _inkData;
164  InkType _ink;
165  bool _trails;
166 
167  CastMemberID _castId;
168  uint16 _pattern;
169  CastMember *_cast;
170 
171  byte _thickness;
172 
173  // These fields are used for tracking the position, width and height of the sprite,
174  // as received from the score frame data.
175  // Don't change these; instead adjust the equivalent properties in Channel.
176  Common::Point _startPoint;
177  int16 _width;
178  int16 _height;
179 
180  bool _moveable;
181  bool _editable;
182  bool _puppet;
183  uint32 _autoPuppet; // autopuppet, based upon Director in a Nutshell, page 15
184  bool _immediate;
185  uint32 _backColor;
186  uint32 _foreColor;
187 
188  byte _volume;
189  bool _stretch;
190 
191  uint32 _spriteListIdx; // D6+
192  SpriteInfo _spriteInfo; // D6+
193 
194  // D7+
195  byte _flags;
196  byte _fgColorG, _fgColorB; // R component sits in _foreColor
197  byte _bgColorG, _bgColorB; // R component sits in _backColor
198  int32 _angleRot;
199  int32 _angleSkew;
200 
201  Common::Array<BehaviorElement> _behaviors; // D6+
202 };
203 
204 } // End of namespace Director
205 
206 #endif
Definition: str.h:59
Definition: surface.h:67
Definition: array.h:52
Definition: surface.h:631
Definition: rect.h:524
Definition: movie.h:88
Definition: archive.h:36
Definition: sprite.h:100
Definition: score.h:66
Definition: rect.h:144
Definition: director.h:134
Definition: spriteinfo.h:43
Definition: frame.h:180
Definition: castmember.h:48
Definition: types.h:419