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 class Sprite {
69 public:
70  Sprite(Frame *frame = nullptr);
71  Sprite(const Sprite &sprite);
72  Sprite& operator=(const Sprite &sprite);
73  bool operator==(const Sprite &sprite);
74  ~Sprite();
75 
76  Frame *getFrame() const { return _frame; }
77  Score *getScore() const { return _score; }
78 
79  void reset();
80 
81  bool getEditable();
82 
83  bool respondsToMouse();
84  bool isActive();
85  bool shouldHilite();
86  bool checkSpriteType();
87 
88  uint16 getPattern();
89  void setPattern(uint16 pattern);
90 
91  void setCast(CastMemberID memberID, bool replaceDims = true);
92  bool isQDShape();
93  Graphics::Surface *getQDMatte();
94  void createQDMatte();
95  MacShape *getShape();
96  uint32 getForeColor();
97  uint32 getBackColor();
98  void setAutoPuppet(AutoPuppetProperty property, bool value);
99  bool getAutoPuppet(AutoPuppetProperty property);
100 
101  inline int getWidth() { return _width; }
102  void setWidth(int w);
103  inline int getHeight() { return _height; }
104  void setHeight(int h);
105 
106  Common::Rect getBbox(bool unstretched);
107  void setBbox(int l, int t, int r, int b);
108 
109  Common::Point getPosition();
110  void setPosition(int x, int y);
111 
112  Frame *_frame;
113  Score *_score;
114  Movie *_movie;
115 
116  Graphics::FloodFill *_matte; // matte for quickdraw shape
117 
118  CastMemberID _scriptId;
119  byte _colorcode; // x40 editable, 0x80 moveable
120  byte _blendAmount;
121  uint32 _unk3;
122 
123  bool _enabled;
124  SpriteType _spriteType;
125  byte _inkData;
126  InkType _ink;
127  bool _trails;
128 
129  CastMemberID _castId;
130  uint16 _pattern;
131  CastMember *_cast;
132 
133  byte _thickness;
134 
135  // These fields are used for tracking the position, width and height of the sprite,
136  // as received from the score frame data.
137  // Don't change these; instead adjust the equivalent properties in Channel.
138  Common::Point _startPoint;
139  int16 _width;
140  int16 _height;
141 
142  bool _moveable;
143  bool _editable;
144  bool _puppet;
145  uint32 _autoPuppet; // autopuppet, based upon Director in a Nutshell, page 15
146  bool _immediate;
147  uint32 _backColor;
148  uint32 _foreColor;
149 
150  byte _volume;
151  bool _stretch;
152 
153  uint32 _spriteListIdx; // D6+
154  SpriteInfo _spriteInfo; // D6+
155 
156  // D7+
157  byte _flags;
158  byte _fgColorG, _fgColorB; // R component sits in _foreColor
159  byte _bgColorG, _bgColorB; // R component sits in _backColor
160  int32 _angleRot;
161  int32 _angleSkew;
162 
163  Common::Array<BehaviorElement> _behaviors; // D6+
164 };
165 
166 } // End of namespace Director
167 
168 #endif
Definition: surface.h:67
Definition: array.h:52
Definition: surface.h:629
Definition: rect.h:524
Definition: movie.h:88
Definition: archive.h:36
Definition: sprite.h:68
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