22 #ifndef MEDIASTATION_ACTOR_H 23 #define MEDIASTATION_ACTOR_H 25 #include "common/events.h" 26 #include "common/keyboard.h" 28 #include "mediastation/datafile.h" 29 #include "mediastation/mediascript/eventhandler.h" 30 #include "mediastation/mediascript/scriptconstants.h" 31 #include "mediastation/mediascript/scriptvalue.h" 36 kActorTypeEmpty = 0x0000,
37 kActorTypeScreen = 0x0001,
38 kActorTypeStage = 0x0002,
39 kActorTypePath = 0x0004,
40 kActorTypeSound = 0x0005,
41 kActorTypeTimer = 0x0006,
42 kActorTypeImage = 0x0007,
43 kActorTypeHotspot = 0x000b,
44 kActorTypeSprite = 0x000e,
45 kActorTypeLKZazu = 0x000f,
46 kActorTypeLKConstellations = 0x0010,
47 kActorTypeDocument = 0x0011,
48 kActorTypeImageSet = 0x001d,
49 kActorTypeCursor = 0x000c,
50 kActorTypePrinter = 0x0019,
51 kActorTypeMovie = 0x0016,
52 kActorTypePalette = 0x0017,
53 kActorTypeText = 0x001a,
54 kActorTypeFont = 0x001b,
55 kActorTypeCamera = 0x001c,
56 kActorTypeCanvas = 0x001e,
57 kActorTypeXsnd = 0x001f,
58 kActorTypeXsndMidi = 0x0020,
59 kActorTypeRecorder = 0x0021,
60 kActorTypeFunction = 0x0069
63 enum ActorHeaderSectionType {
64 kActorHeaderEmptySection = 0x0000,
65 kActorHeaderEventHandler = 0x0017,
66 kActorHeaderChildActorId = 0x0019,
67 kActorHeaderActorId = 0x001a,
68 kActorHeaderChunkReference = 0x001b,
69 kActorHeaderMovieAnimationChunkReference = 0x06a4,
70 kActorHeaderMovieAudioChunkReference = 0x06a5,
71 kActorHeaderActorReference = 0x077b,
72 kActorHeaderBoundingBox = 0x001c,
73 kActorHeaderMouseActiveArea = 0x001d,
74 kActorHeaderZIndex = 0x001e,
75 kActorHeaderStartup = 0x001f,
76 kActorHeaderTransparency = 0x0020,
77 kActorHeaderHasOwnSubfile = 0x0021,
78 kActorHeaderCursorResourceId = 0x0022,
79 kActorHeaderFrameRate = 0x0024,
80 kActorHeaderLoadType = 0x0032,
81 kActorHeaderSoundInfo = 0x0033,
82 kActorHeaderMovieLoadType = 0x0037,
83 kActorHeaderSpriteChunkCount = 0x03e8,
84 kActorHeaderPalette = 0x05aa,
85 kActorHeaderDissolveFactor = 0x05dc,
86 kActorHeaderGetOffstageEvents = 0x05dd,
87 kActorHeaderX = 0x05de,
88 kActorHeaderY = 0x05df,
89 kActorHeaderScaleXAndY = 0x77a,
90 kActorHeaderScaleX = 0x77c,
91 kActorHeaderScaleY = 0x77d,
92 kActorHeaderUnk0 = 0x7d0,
93 kActorHeaderActorName = 0x0bb8,
96 kActorHeaderStartPoint = 0x060e,
97 kActorHeaderEndPoint = 0x060f,
98 kActorHeaderPathTotalSteps = 0x0610,
99 kActorHeaderStepRate = 0x0611,
100 kActorHeaderDuration = 0x0612,
103 kActorHeaderViewportOrigin = 0x076f,
104 kActorHeaderLensOpen = 0x0770,
107 kActorHeaderStageSize = 0x0771,
108 kActorHeaderCylindricalX = 0x0772,
109 kActorHeaderCylindricalY = 0x0773,
112 kActorHeaderEditable = 0x03eb,
113 kActorHeaderFontId = 0x0258,
114 kActorHeaderInitialText = 0x0259,
115 kActorHeaderTextMaxLength = 0x25a,
116 kActorHeaderTextJustification = 0x025b,
117 kActorHeaderTextPosition = 0x25f,
118 kActorHeaderTextUnk1 = 0x262,
119 kActorHeaderTextUnk2 = 0x263,
120 kActorHeaderTextCharacterClass = 0x0266,
123 kActorHeaderSpriteClip = 0x03e9,
124 kActorHeaderCurrentSpriteClip = 0x03ea
140 enum MouseEventFlag {
142 kMouseDownFlag = 0x01,
144 kMouseMovedFlag = 0x04,
145 kMouseExitFlag = 0x10,
146 kMouseEnterFlag = 0x08,
147 kMouseUnk1Flag = 0x20,
148 kMouseOutOfFocusFlag = 0x40,
157 Actor(ActorType type) : _type(type) {};
161 virtual void process() {
return; }
166 virtual bool isSpatialActor()
const {
return false; }
168 virtual void initFromParameterStream(
Chunk &chunk);
169 virtual void readParameter(
Chunk &chunk, ActorHeaderSectionType paramType);
170 virtual void loadIsComplete();
174 virtual void readChunk(
Chunk &chunk);
175 virtual void readSubfile(
Subfile &subfile,
Chunk &chunk);
177 void processTimeEventHandlers();
178 void runEventHandlerIfExists(EventType eventType,
const ScriptValue &arg);
179 void runEventHandlerIfExists(EventType eventType);
181 ActorType type()
const {
return _type; }
182 uint id()
const {
return _id; }
183 uint contextId()
const {
return _contextId; }
184 void setId(uint
id) { _id = id; }
185 void setContextId(uint
id) { _contextId = id; }
187 uint32 _chunkReference = 0;
188 uint _actorReference = 0;
191 ActorType _type = kActorTypeEmpty;
192 bool _loadIsComplete =
false;
197 uint _lastProcessedTime = 0;
208 virtual void readParameter(
Chunk &chunk, ActorHeaderSectionType paramType)
override;
209 virtual void loadIsComplete()
override;
211 virtual bool isSpatialActor()
const override {
return true; }
212 virtual bool isVisible()
const {
return _isVisible; }
213 virtual Common::Rect getBbox()
const {
return _boundingBox; }
214 int zIndex()
const {
return _zIndex; }
216 virtual void invalidateMouse();
217 virtual bool interactsWithMouse()
const {
return false; }
219 virtual uint16 findActorToAcceptMouseEvents(
223 bool inBounds) {
return kNoFlag; }
224 virtual uint16 findActorToAcceptKeyboardEvents(
229 virtual void mouseDownEvent(
const Common::Event &event) {
return; }
230 virtual void mouseUpEvent(
const Common::Event &event) {
return; }
231 virtual void mouseEnteredEvent(
const Common::Event &event) {
return; }
232 virtual void mouseExitedEvent(
const Common::Event &event) {
return; }
233 virtual void mouseMovedEvent(
const Common::Event &event) {
return; }
234 virtual void mouseOutOfFocusEvent(
const Common::Event &event) {
return; }
235 virtual void keyboardEvent(
const Common::Event &event) {
return; }
237 void setParentStage(
StageActor *parentStage) { _parentStage = parentStage; }
238 void setToNoParentStage() { _parentStage =
nullptr; }
239 StageActor *getParentStage()
const {
return _parentStage; }
241 virtual void invalidateLocalBounds();
246 double _dissolveFactor = 0.0;
247 double _scaleX = 0.0;
248 double _scaleY = 0.0;
250 bool _isVisible =
false;
251 bool _hasTransparency =
false;
252 bool _getOffstageEvents =
false;
255 void moveTo(int16 x, int16 y);
256 void moveToCentered(int16 x, int16 y);
258 void setZIndex(
int zIndex);
259 virtual void setMousePosition(int16 x, int16 y);
261 virtual void setDissolveFactor(
double dissolveFactor);
262 virtual void invalidateLocalZIndex();