22 #ifndef MEDIASTATION_EVENTS_H 23 #define MEDIASTATION_EVENTS_H 25 #include "common/events.h" 26 #include "common/hash-ptr.h" 27 #include "common/ptr.h" 28 #include "common/str.h" 29 #include "common/queue.h" 31 #include "mediastation/mediascript/scriptconstants.h" 32 #include "mediastation/mediascript/scriptvalue.h" 37 kEventClassInvalid = 0x00,
38 kEventClassSystem = 0x01,
39 kEventClassMouse = 0x02,
40 kEventClassKeyboard = 0x04,
41 kEventClassDisplay = 0x08,
42 kEventClassTimerService = 0x10,
43 kEventClassScriptTimer = 0x20,
44 kEventClassActor = 0x40
46 const char *eventClassToStr(EventClass eventClass);
52 enum EventClassHandlerType {
53 kNoEventClassHandler = 0x00,
54 kStageDirectorEventClassHandler = 0x06,
55 kDisplayUpdateEventClassHandler = 0x08,
56 kTimerServiceClassHandler = 0x10,
57 kActorEventClassHandler = 0x40,
61 EventClass eventClass = kEventClassInvalid;
62 EventType type = kEventTypeInvalid;
64 Event(EventClass eventClass_, EventType eventType_)
65 : eventClass(eventClass_), type(eventType_) {}
67 virtual Event *clone()
const = 0;
72 uint disableScreenAutoUpdateToken = 0;
75 :
Event(kEventClassDisplay, eventType_), disableScreenAutoUpdateToken(token_) {}
84 uint32 triggerTime = 0;
88 :
Event(kEventClassTimerService, kTimerServiceAlarmEvent), triggerTime(triggerTime_), entry(entry_) {}
98 :
Event(kEventClassScriptTimer, kTimerScriptEvent), entry(entry_) {}
107 ActorEvent(uint16 actorId_, EventType eventType_)
108 :
Event(kEventClassActor, eventType_), actorId(actorId_) {}
110 :
Event(kEventClassActor, eventType_), actorId(actorId_), arg(arg_) {}
117 bool disableScreenAutoUpdate =
false;
119 ScreenBranchEvent(uint16 actorId_, uint16 screenId_,
bool disableScreenAutoUpdate_)
120 :
ActorEvent(actorId_, kScreenBranchEvent), screenId(screenId_), disableScreenAutoUpdate(disableScreenAutoUpdate_) {}
129 :
Event(kEventClassMouse, eventType_), position(position_) {}
138 :
Event(kEventClassKeyboard, eventType_), keyCode(keyCode_) {}
143 enum PreDisplaySyncState {
144 kPreDisplaySyncForceScreenUpdate = 0,
145 kPreDisplaySyncNoScreenUpdateRequested = 1,
146 kPreDisplaySyncStateBlockScreenUpdate = 2
154 virtual PreDisplaySyncState preDisplaySync() = 0;
156 void registerForSyncCalls();
157 void unregisterForSyncCalls();
166 void queueEvent(
const Event &event);
177 void dispatchImtEvents();
178 PreDisplaySyncState preDisplaySync();
179 void updateDisplay();
183 void dispatchImtEvent(
const Event &event);
190 uint32 currentReceiverTime();
191 virtual void timerEvent(
const TimerEvent &event) = 0;
200 void setDuration(uint32 duration) { _duration = duration; }
201 uint32 calculateFirstExpirationTime(uint32 currentTime);
202 uint32 calculateNextExpirationTime(uint32 currentTime);
203 uint32 deltaTimeAtExpiration()
const;
204 uint32 expirationTime()
const {
return _expirationTime; }
205 bool shouldReschedule()
const {
return _shouldRepeat; }
208 bool operator==(
const TimerEntry &other)
const;
209 bool operator<(
const TimerEntry &other)
const;
210 bool operator>(
const TimerEntry &other)
const;
214 uint32 _expirationTime = 0;
215 uint32 _actualExpirationTime = 0;
216 uint32 _duration = 0;
217 bool _shouldRepeat =
false;
225 void startTimer(
TimerEntry &entry, uint32 duration);
226 void startTimer(
TimerEntry &entry,
double duration);
228 void queueExpiredTimerEvents();