25 #ifndef PEGASUS_TIMERS_H 26 #define PEGASUS_TIMERS_H 28 #include "common/rational.h" 29 #include "common/func.h" 31 #include "pegasus/constants.h" 32 #include "pegasus/notification.h" 33 #include "pegasus/util.h" 44 virtual void startIdling();
45 virtual void stopIdling();
46 bool isIdling()
const {
return _isIdling; }
49 virtual void useIdleTime() {}
52 Idler *_nextIdler, *_prevIdler;
57 kPalindromeLoopTimeBase = 2,
58 kMaintainTimeBaseZero = 4
66 TimeBase(
const TimeScale = kDefaultTimeScale);
69 virtual void setTime(
const TimeValue,
const TimeScale = 0);
70 virtual TimeValue getTime(
const TimeScale = 0);
72 virtual void setScale(
const TimeScale
scale) { _preferredScale =
scale; }
73 virtual TimeScale getScale()
const {
return _preferredScale; }
80 virtual bool isRunning();
83 virtual void resume();
84 bool isPaused()
const {
return _paused; }
86 virtual void setFlags(
const uint32 flags) { _flags = flags; }
87 virtual uint32 getFlags()
const {
return _flags; }
89 virtual void setStart(
const TimeValue,
const TimeScale = 0);
90 virtual TimeValue getStart(
const TimeScale = 0)
const;
92 virtual void setStop(
const TimeValue,
const TimeScale = 0);
93 virtual TimeValue getStop(
const TimeScale = 0)
const;
95 virtual void setSegment(
const TimeValue,
const TimeValue,
const TimeScale = 0);
96 virtual void getSegment(TimeValue&, TimeValue&,
const TimeScale = 0)
const;
98 virtual TimeValue getDuration(
const TimeScale = 0)
const;
100 virtual void setMasterTimeBase(
TimeBase *timeBase);
102 void disposeAllCallBacks();
105 virtual void checkCallBacks();
110 virtual void updateTime();
113 TimeScale _preferredScale;
117 uint32 _startTime, _startScale;
118 uint32 _stopTime, _stopScale;
122 uint32 _lastMillis, _pauseStart;
129 kCallBackAtExtremes = 4
133 enum CallBackTrigger {
151 void initCallBack(
TimeBase *, CallBackType type);
153 void releaseCallBack();
155 void scheduleCallBack(CallBackTrigger trigger, uint32 param2, uint32 param3);
156 void cancelCallBack();
159 virtual void callBack() = 0;
168 CallBackTrigger _trigger;
169 uint32 _param2, _param3;
170 bool _hasBeenTriggered;
173 void disposeCallBack();
181 TimeValue getLastTime()
const {
return _lastTime; }
184 void useIdleTime()
override;
185 virtual void timeChanged(
const TimeValue) {}
196 void setNotification(
Notification *notifier) { _notifier = notifier; }
198 void setCallBackFlag(
const NotificationFlags flag) { _callBackFlag = flag; }
199 NotificationFlags getCallBackFlag()
const {
return _callBackFlag; }
202 void callBack()
override;
205 NotificationFlags _callBackFlag;
210 TimeValue percentSeconds(
const uint32 percent) {
return getScale() * percent / 100; }
218 void primeFuse(
const TimeValue,
const TimeScale = 1);
221 bool isFuseLit() {
return _fuseTimer.isRunning() || _fuseTimer.isPaused(); }
222 void advanceFuse(
const TimeValue);
223 TimeValue getTimeRemaining();
224 TimeScale getFuseScale() {
return _fuseTimer.getScale(); }
226 void pauseFuse() { _fuseTimer.pause(); }
227 void resumeFuse() { _fuseTimer.resume(); }
228 bool isFusePaused() {
return _fuseTimer.isPaused(); }
231 void receiveNotification(
Notification *,
const NotificationFlags)
override;
232 virtual void invokeAction() {}
246 void invokeAction()
override {
if (_functor && _functor->isValid()) (*_functor)(); }
Definition: rational.h:40
Graphics::Surface * scale(const Graphics::Surface &srcImage, int xSize, int ySize)
Definition: notification.h:53
Definition: notification.h:83
Definition: ai_action.h:33