ScummVM API documentation
statics.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 NGI_STATICS_H
23 #define NGI_STATICS_H
24 
25 #include "ngi/gfx.h"
26 
27 namespace NGI {
28 
29 class ExCommand;
30 
31 class StepArray : public CObject {
32  int _currPointIndex;
33  PointList _points;
34  bool _isEos;
35 
36  public:
37  StepArray();
38  void clear();
39 
40  int getCurrPointIndex() const { return _currPointIndex; }
41  int getPointsCount() const { return _points.size(); }
42 
43  Common::Point getCurrPoint() const;
44  Common::Point getPoint(int index, int offset) const;
45  bool gotoNextPoint();
46  void insertPoints(const PointList &points);
47 };
48 
49 class StaticPhase : public Picture {
50  public:
51  int16 _initialCountdown;
52  int16 _countdown;
53  int16 _field_68;
54  int16 _field_6A;
56 
57  public:
58  StaticPhase();
59 
60  bool load(MfcArchive &file) override;
61 
62  virtual Common::String toXML();
63 
64  ExCommand *getExCommand() { return _exCommand.get(); }
65 };
66 
67 class DynamicPhase : public StaticPhase {
68  public:
69  int _someX;
70  int _someY;
71  Common::Rect _rect;
72  int16 _field_7C;
73  int16 _field_7E;
74  int _dynFlags;
75 
76  public:
77  DynamicPhase();
78  DynamicPhase(DynamicPhase *src, bool reverse);
79 
80  bool load(MfcArchive &file) override;
81 
82  Common::String toXML() override;
83 
84  int getDynFlags() { return _dynFlags; }
85 };
86 
87 class Statics : public DynamicPhase {
88  public:
89  int16 _staticsId;
90  Common::String _staticsName;
91  Picture _picture;
92 
93  public:
94  Statics();
95  Statics(Statics *src, bool reverse);
96 
97  bool load(MfcArchive &file) override;
98  void init() override;
99  Statics *getStaticsById(int itemId);
100 
101  Common::Point getSomeXY() const;
102  Common::Point getCenter() const;
103 };
104 
105 class StaticANIObject;
106 
107 class Movement : public GameObject {
108  public:
109  Common::Point _somePoint;
110  int _lastFrameSpecialFlag;
111  int _flipFlag;
112  int _updateFlag1;
113  Statics *_staticsObj1;
114  Statics *_staticsObj2;
115  int _mx;
116  int _my;
117  int _m2x;
118  int _m2y;
119  int _field_50;
120  int _counterMax;
121  int _counter;
124  int _field_78;
125  PointList _framePosOffsets;
126  Movement *_currMovement;
127  int _field_84;
128  DynamicPhase *_currDynamicPhase;
129  int _field_8C;
130  int _currDynamicPhaseIndex;
131  int _field_94;
132 
133  public:
134  Movement();
135  ~Movement() override;
136 
137  Movement(Movement *src, StaticANIObject *ani);
138  Movement(Movement *src, int *flag1, int flag2, StaticANIObject *ani);
139 
140  bool load(MfcArchive &file) override;
141  bool load(MfcArchive &file, StaticANIObject *ani);
142 
143  Common::Point getCurrDynamicPhaseXY() const;
144  Common::Point getCenter() const;
145  Dims getDimensionsOfPhase(int phaseIndex) const;
146 
147  Common::Point calcSomeXY(int idx, int dynidx);
148 
149  void initStatics(StaticANIObject *ani);
150  void updateCurrDynamicPhase();
151 
152  void setAlpha(int alpha);
153 
154  void setDynamicPhaseIndex(int index);
155  DynamicPhase *getDynamicPhaseByIndex(int idx);
156 
157  int calcDuration();
158  int countPhasesWithFlag(int maxidx, int flag);
159 
160  void removeFirstPhase();
161  bool gotoNextFrame(void (*_callback1)(int, Common::Point *point, int, int), void (*callback2)(int *));
162  bool gotoPrevFrame();
163  void gotoFirstFrame();
164  void gotoLastFrame();
165 
166  void loadPixelData();
167  void freePixelData();
168 
169  void draw(bool flipFlag, int angle);
170 };
171 
172 class StaticANIObject : public GameObject {
173  public:
174  Movement *_movement;
175  Statics *_statics;
176  int _shadowsOn;
177  int16 _field_30;
178  int16 _field_32;
179  int _field_34;
180  int _initialCounter;
181  void (*_callback1)(int, Common::Point *point, int, int);
182  void (*_callback2)(int *);
187  StepArray _stepArray;
188  int16 _field_96;
189  int _messageQueueId;
190  int _messageNum;
191  int _animExFlag;
192  int _counter;
193  int _someDynamicPhaseIndex;
194 
195 public:
196  int16 _sceneId;
197 
198 public:
199  StaticANIObject();
200  ~StaticANIObject() override;
202 
203  bool load(MfcArchive &file) override;
204 
205  void setOXY(int x, int y);
206  Statics *getStaticsById(int id);
207  Statics *getStaticsByName(const Common::String &name);
208  Movement *getMovementById(int id);
209  int getMovementIdById(int itemId) const;
210  Movement *getMovementByName(const Common::String &name);
211  Common::Point getCurrDimensions() const;
212 
213  Common::Point getSomeXY() const;
214 
215  void clearFlags();
216  void setFlags40(bool state);
217  bool isIdle();
218  void setAlpha(int alpha);
219 
220  void deleteFromGlobalMessageQueue();
221  bool queueMessageQueue(MessageQueue *msg);
222  void restartMessageQueue(MessageQueue *msg);
223  MessageQueue *getMessageQueue();
224  bool trySetMessageQueue(int msgNum, int qId);
225  void startMQIfIdle(int qId, int flag);
226 
227  void initMovements();
228  void loadMovementsPixelData();
229  void freeMovementsPixelData();
230  void preloadMovements(MovTable *mt);
231 
232  void setSomeDynamicPhaseIndex(int val) { _someDynamicPhaseIndex = val; }
233  void adjustSomeXY();
234 
235  bool startAnim(int movementId, int messageQueueId, int dynPhaseIdx);
236  bool startAnimEx(int movid, int parId, int flag1, int flag2);
237  void startAnimSteps(int movementId, int messageQueueId, int x, int y, const PointList &points, int someDynamicPhaseIndex);
238 
239  void hide();
240  void show1(int x, int y, int movementId, int mqId);
241  void show2(int x, int y, int movementId, int mqId);
242  void playIdle();
243  void update(int counterdiff);
244 
245  Statics *addReverseStatics(Statics *ani);
246  void draw();
247  void draw2();
248 
250  MovTable *countMovements();
251  Common::Point *calcStepLen(Common::Point *p);
252  void setSpeed(int speed);
253 
254  void updateStepPos();
255  void stopAnim_maybe();
256  Common::Point *calcNextStep(Common::Point *point);
257 
258  MessageQueue *changeStatics1(int msgNum);
259  void changeStatics2(int objId);
260 
261  bool getPixelAtPos(int x, int y, uint32 *pixel, bool hitOnly = false);
262  bool isPixelHitAtPos(int x, int y);
263 };
264 
265 } // End of namespace NGI
266 
267 #endif /* NGI_STATICS_H */
Definition: gfx.h:137
Definition: str.h:59
Definition: utils.h:39
Definition: statics.h:67
Definition: rect.h:144
Definition: statics.h:107
Definition: ptr.h:572
Common::Array< Statics * > _staticsList
Definition: statics.h:186
Definition: statics.h:31
Common::Array< Movement * > _movements
Definition: statics.h:184
Definition: statics.h:87
Definition: gfx.h:80
Definition: messages.h:108
Definition: rect.h:45
size_type size() const
Definition: array.h:315
Common::Array< DynamicPhase * > _dynamicPhases
Definition: statics.h:123
Definition: statics.h:172
Definition: messages.h:59
Definition: statics.h:49
Definition: anihandler.h:25
PointerType get() const
Definition: ptr.h:636
Definition: utils.h:106