ScummVM API documentation
actor.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 ILLUSIONS_ACTOR_H
23 #define ILLUSIONS_ACTOR_H
24 
25 #include "illusions/resources/actorresource.h"
26 #include "illusions/resources/backgroundresource.h"
27 #include "illusions/graphics.h"
28 #include "illusions/pathfinder.h"
29 #include "common/algorithm.h"
30 #include "common/func.h"
31 #include "common/list.h"
32 #include "graphics/surface.h"
33 
34 namespace Illusions {
35 
36 class Control;
37 class IllusionsEngine;
38 class SequenceOpcodes;
39 struct OpCall;
40 
41 enum ActorFlags {
42  ACTOR_FLAG_IS_VISIBLE = 1,
43  ACTOR_FLAG_HAS_WALK_POINTS = 2,
44  ACTOR_FLAG_SCALED = 4,
45  ACTOR_FLAG_PRIORITY = 8,
46  ACTOR_FLAG_HAS_WALK_RECTS = 0x10,
47  ACTOR_FLAG_REGION = 0x20,
48  ACTOR_FLAG_40 = 0x40,
49  ACTOR_FLAG_80 = 0x80,
50  ACTOR_FLAG_100 = 0x100,
51  ACTOR_FLAG_200 = 0x200,
52  ACTOR_FLAG_400 = 0x400,
53  ACTOR_FLAG_800 = 0x800,
54  ACTOR_FLAG_1000 = 0x1000,
55  ACTOR_FLAG_2000 = 0x2000,
56  ACTOR_FLAG_4000 = 0x4000,
57  ACTOR_FLAG_8000 = 0x8000
58 };
59 
60 enum ControlObjectID {
61  CURSOR_OBJECT_ID = 0x40004
62 };
63 
64 const uint kSubObjectsCount = 15;
65 
67  uint32 _sequenceId;
68  uint32 _newSequenceId;
70  : _sequenceId(0), _newSequenceId(0) {}
71  DefaultSequence(uint32 sequenceId, uint32 newSequenceId)
72  : _sequenceId(sequenceId), _newSequenceId(newSequenceId) {}
73 };
74 
76 public:
77  uint32 use(uint32 sequenceId);
78  void set(uint32 sequenceId, uint32 newSequenceId);
79 protected:
81  typedef Items::iterator ItemsIterator;
82  struct DefaultSequenceEqual : public Common::UnaryFunction<const DefaultSequence&, bool> {
83  uint32 _sequenceId;
84  DefaultSequenceEqual(uint32 sequenceId) : _sequenceId(sequenceId) {}
85  bool operator()(const DefaultSequence &defaultSequence) const {
86  return defaultSequence._sequenceId == _sequenceId;
87  }
88  };
90 };
91 
93 
94 class Actor {
95 public:
97  ~Actor();
98  void pause();
99  void unpause();
100  void createSurface(SurfInfo &surfInfo);
101  void destroySurface();
102  void initSequenceStack();
103  void pushSequenceStack(int16 value);
104  int16 popSequenceStack();
105  void setControlRoutine(ActorControlRoutine *controlRoutine);
106  void runControlRoutine(Control *control, uint32 deltaTime);
107  bool findNamedPoint(uint32 namedPointId, Common::Point &pt);
108 public:
109  IllusionsEngine *_vm;
110  byte _drawFlags;
111  uint _spriteFlags;
112 
113  int _pauseCtr;
114  uint _flags;
115 
116  int _scale;
117  int16 _frameIndex;
118  int16 _newFrameIndex;
119  SurfInfo _surfInfo;
120  Graphics::Surface *_surface;
121 
122  FramesList *_frames;
123  NamedPoints *_namedPoints;
124 
125  ScaleLayer *_scaleLayer;
126  PriorityLayer *_priorityLayer;
127  RegionLayer *_regionLayer;
128  PathWalkPoints *_pathWalkPoints;
129  PathWalkRects *_pathWalkRects;
130 
131  uint _seqStackCount;
132  int16 _seqStack[5];
133 
134  Common::Point _position;
135  Common::Point _position2;
136  uint _facing;
137  int _regionIndex;
138 
139  uint32 _fontId;
140  int16 _actorIndex;
141 
142  DefaultSequences _defaultSequences;
143 
144  uint32 _parentObjectId;
145  int _linkIndex;
146  int _linkIndex2;
147  uint32 _subobjects[kSubObjectsCount];
148 
149  uint32 _notifyThreadId1;
150  uint32 _notifyId3C;
151 
152  uint32 _notifyThreadId2;
153  byte *_entryTblPtr;
154 
155  ActorControlRoutine *_controlRoutine;
156 
157  uint32 _sequenceId;
158  int _seqCodeValue2;
159  byte *_seqCodeIp;
160  int _seqCodeValue1;
161  int _seqCodeValue3;
162 
163  int _pathCtrX, _pathCtrY;
164  int _pathAngle;
165  int32 _posXShl, _posYShl;
166  uint _pathPointIndex;
167  uint _pathPointsCount;
168  Common::Point _pathInitialPos;
169  bool _pathInitialPosFlag;
170  bool _pathFlag50;
171  PointArray *_pathNode;
172  uint _pathPoints;
173  uint32 _walkCallerThreadId1;
174 
175  RGB _color;
176  int16 _choiceJumpOffs;
177 
178 };
179 
180 class Control {
181 public:
183  ~Control();
184  void pause();
185  void unpause();
186  void appearActor();
187  void disappearActor();
188  bool isActorVisible();
189  void activateObject();
190  void deactivateObject();
191  void readPointsConfig(byte *pointsConfig);
192  void setActorPosition(Common::Point position);
193  Common::Point getActorPosition();
194  void setActorScale(int scale);
195  void faceActor(uint facing);
196  void linkToObject(uint32 parentObjectId, uint32 linkedObjectValue);
197  void unlinkObject();
198  void clearNotifyThreadId1();
199  void clearNotifyThreadId2();
200  void setPriority(int16 priority);
201  uint32 getOverlapPriority();
202  uint32 getDrawPriority();
203  uint32 getPriority();
204  Common::Point calcPosition(Common::Point posDelta);
205  uint32 getSubActorParent();
206  void getCollisionRectAccurate(Common::Rect &collisionRect);
207  void getCollisionRect(Common::Rect &collisionRect);
208  void setActorUsePan(int usePan);
209  void setActorFrameIndex(int16 frameIndex);
210  void stopActor();
211  void startSequenceActor(uint32 sequenceId, int value, uint32 notifyThreadId);
212  void stopSequenceActor();
213  void startTalkActor(uint32 sequenceId, byte *entryTblPtr, uint32 threadId);
214  void sequenceActor();
215  void setActorIndex(int actorIndex);
216  void setActorIndexTo1();
217  void setActorIndexTo2();
218  void startSubSequence(int linkIndex, uint32 sequenceId);
219  void stopSubSequence(int linkIndex);
220  void startMoveActor(uint32 sequenceId, Common::Point destPt, uint32 callerThreadId1, uint32 callerThreadId2);
221  PointArray *createPath(Common::Point destPt);
222  void updateActorMovement(uint32 deltaTime);
223  void refreshSequenceCode();
224  void getActorFrameDimensions(WidthHeight &dimensions);
225  void drawActorRect(const Common::Rect r, byte color);
226  void fillActor(byte color);
227  bool isPixelCollision(Common::Point &pt);
228 public:
229  IllusionsEngine *_vm;
230  uint _flags;
231  int _pauseCtr;
232  int16 _priority;
233  Actor *_actor;
234  uint32 _sceneId;
235  uint32 _objectId;
236  uint32 _actorTypeId;
237  WRect _bounds;
238  Common::Point _feetPt;
239  Common::Point _position;
240  Common::Point _subobjectsPos[kSubObjectsCount];
241  void startSequenceActorIntern(uint32 sequenceId, int value, byte *entryTblPtr, uint32 notifyThreadId);
242  void execSequenceOpcode(OpCall &opCall);
243 };
244 
245 class Controls {
246 public:
248  ~Controls();
249  void placeBackgroundObject(BackgroundObject *backgroundObject);
250  void placeActor(uint32 actorTypeId, Common::Point placePt, uint32 sequenceId, uint32 objectId, uint32 notifyThreadId);
251  void placeSequenceLessActor(uint32 objectId, Common::Point placePt, WidthHeight dimensions, int16 priority);
252  void placeActorLessObject(uint32 objectId, Common::Point feetPt, Common::Point pt, int16 priority, uint flags);
253  void placeSubActor(uint32 objectId, int linkIndex, uint32 actorTypeId, uint32 sequenceId);
254  void placeDialogItem(uint16 objectNum, uint32 actorTypeId, uint32 sequenceId, Common::Point placePt, int16 choiceJumpOffs);
255  void destroyControls();
256  void destroyActiveControls();
257  void destroyControlsBySceneId(uint32 sceneId);
258  void destroyDialogItems();
259  void threadIsDead(uint32 threadId);
260  void pauseControls();
261  void unpauseControls();
262  void pauseControlsBySceneId(uint32 sceneId);
263  void unpauseControlsBySceneId(uint32 sceneId);
264  bool getOverlappedObject(Control *control, Common::Point pt, Control **outOverlappedControl, int minPriority);
265  bool getOverlappedObjectAccurate(Control *control, Common::Point pt, Control **outOverlappedControl, int minPriority);
266  bool getDialogItemAtPos(Control *control, Common::Point pt, Control **outOverlappedControl);
267  bool getOverlappedWalkObject(Control *control, Common::Point pt, Control **outOverlappedControl);
268  void destroyControl(Control *control);
269  bool findNamedPoint(uint32 namedPointId, Common::Point &pt);
270  void actorControlRoutine(Control *control, uint32 deltaTime);
271  void dialogItemControlRoutine(Control *control, uint32 deltaTime);
272  void disappearActors();
273  void appearActors();
274  void pauseActors(uint32 objectId);
275  void unpauseActors(uint32 objectId);
276 public:
279  IllusionsEngine *_vm;
280  Items _controls;
281  SequenceOpcodes *_sequenceOpcodes;
282  uint32 _nextTempObjectId;
283  Actor *newActor();
284  Control *newControl();
285  uint32 newTempObjectId();
286  void destroyControlInternal(Control *control);
287 };
288 
289 } // End of namespace Illusions
290 
291 #endif // ILLUSIONS_ACTOR_H
Definition: backgroundresource.h:91
Definition: graphics.h:44
Definition: surface.h:66
Definition: backgroundresource.h:82
Definition: actor.h:94
Definition: array.h:52
Definition: graphics.h:59
T * iterator
Definition: array.h:54
Definition: rect.h:144
Definition: actor.h:34
Definition: actor.h:245
Definition: backgroundresource.h:119
Graphics::Surface * scale(const Graphics::Surface &srcImage, int xSize, int ySize)
Definition: graphics.h:38
Definition: sequenceopcodes.h:35
Definition: graphics.h:31
Definition: backgroundresource.h:126
Definition: backgroundresource.h:72
Definition: rect.h:45
Definition: actor.h:66
Definition: list_intern.h:51
Definition: actor.h:180
Definition: scriptopcodes.h:32
Definition: func.h:473
Definition: graphics.h:49
Definition: func.h:43
Definition: illusions.h:80
Definition: actor.h:75
Definition: backgroundresource.h:111
Definition: actorresource.h:76