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  Common::String formatInfo();
113 
114  void replaceFrom(Sprite *nextSprite);
115 
116  Frame *_frame;
117  Score *_score;
118  Movie *_movie;
119 
120  Graphics::FloodFill *_matte; // matte for quickdraw shape
121 
122  CastMemberID _scriptId;
123  byte _colorcode; // x40 editable, 0x80 moveable
124  byte _blendAmount;
125  uint32 _unk3;
126 
127  bool _enabled;
128  SpriteType _spriteType;
129  byte _inkData;
130  InkType _ink;
131  bool _trails;
132 
133  CastMemberID _castId;
134  uint16 _pattern;
135  CastMember *_cast;
136 
137  byte _thickness;
138 
139  // These fields are used for tracking the position, width and height of the sprite,
140  // as received from the score frame data.
141  // Don't change these; instead adjust the equivalent properties in Channel.
142  Common::Point _startPoint;
143  int16 _width;
144  int16 _height;
145 
146  bool _moveable;
147  bool _editable;
148  bool _puppet;
149  uint32 _autoPuppet; // autopuppet, based upon Director in a Nutshell, page 15
150  bool _immediate;
151  uint32 _backColor;
152  uint32 _foreColor;
153 
154  byte _volume;
155  bool _stretch;
156 
157  uint32 _spriteListIdx; // D6+
158  SpriteInfo _spriteInfo; // D6+
159 
160  // D7+
161  byte _flags;
162  byte _fgColorG, _fgColorB; // R component sits in _foreColor
163  byte _bgColorG, _bgColorB; // R component sits in _backColor
164  int32 _angleRot;
165  int32 _angleSkew;
166 
167  Common::Array<BehaviorElement> _behaviors; // D6+
168 };
169 
170 } // End of namespace Director
171 
172 #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: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