1.1 --- a/public/ITimerSystem.h Wed Sep 12 23:37:00 2007 +0000
1.2 +++ b/public/ITimerSystem.h Thu Sep 13 00:33:56 2007 +0000
1.3 @@ -48,7 +48,47 @@
1.4 {
1.5 class ITimer;
1.6
1.7 - typedef float (*SM_TIMELEFT_FUNCTION)();
1.8 + /**
1.9 + * @brief Interface for map timers.
1.10 + */
1.11 + class IMapTimer
1.12 + {
1.13 + public:
1.14 + /**
1.15 + * Returns the current map time limit in seconds.
1.16 + *
1.17 + * @return Time limit, in seconds, or
1.18 + * 0 if there is no limit.
1.19 + */
1.20 + virtual int GetMapTimeLimit() =0;
1.21 +
1.22 + /**
1.23 + * Returns how much time is left in the map.
1.24 + *
1.25 + * @param time_left Pointer to store time, in seconds.
1.26 + * @return True if there is a time limit, false
1.27 + * if the time limit is 0.
1.28 + */
1.29 + virtual bool GetMapTimeLeft(int *time_left) =0;
1.30 +
1.31 + /**
1.32 + * Extends the map limit (either positively or negatively) in seconds.
1.33 + *
1.34 + * @param extra_time Time to extend map by. If 0, the map will
1.35 + * be set to have no time limit.
1.36 + */
1.37 + virtual void ExtendMapTimeLimit(int extra_time) =0;
1.38 +
1.39 + /**
1.40 + * Tells the map timer whether it is being used or not.
1.41 + *
1.42 + * Map timers are automatically enabled when they are set, and
1.43 + * automatically disabled if being un-set.
1.44 + *
1.45 + * @param enabled True if enabling, false if disabling.
1.46 + */
1.47 + virtual void SetMapTimerStatus(bool enabled) =0;
1.48 + };
1.49
1.50 /**
1.51 * @brief Event callbacks for when a timer is executed.
1.52 @@ -76,10 +116,6 @@
1.53
1.54 #define TIMER_FLAG_REPEAT (1<<0) /**< Timer will repeat until stopped */
1.55 #define TIMER_FLAG_NO_MAPCHANGE (1<<1) /**< Timer will not carry over mapchanges */
1.56 - #define TIMER_FLAG_BEFORE_MAP_END (1<<2) /**< Timer will fire <interval> seconds before map end.
1.57 - This flag is cannot be used with REPEAT,
1.58 - and TIMER_FLAG_NO_MAPCHANGE is implied.
1.59 - */
1.60
1.61 class ITimerSystem : public SMInterface
1.62 {
1.63 @@ -130,12 +166,22 @@
1.64 virtual void FireTimerOnce(ITimer *pTimer, bool delayExec=false) =0;
1.65
1.66 /**
1.67 - * @brief Sets the function which is used to find the time left in the map.
1.68 + * @brief Sets the interface for dealing with map time limits.
1.69 *
1.70 - * @param fn Function that returns the time left in seconds.
1.71 - * @return The previous SM_TIMELEFT_FUNCTION pointer.
1.72 + * @param pMapTimer Map timer interface pointer.
1.73 + * @return Old pointer.
1.74 */
1.75 - virtual SM_TIMELEFT_FUNCTION SetTimeLeftFunction(SM_TIMELEFT_FUNCTION fn) =0;
1.76 + virtual IMapTimer *SetMapTimer(IMapTimer *pTimer) =0;
1.77 +
1.78 + /**
1.79 + * @brief Notifies the timer that the map timelimit has been extended.
1.80 + *
1.81 + * A time limit of 0 implies that there is no limit.
1.82 + *
1.83 + * @param old_limit Old limit, in seconds.
1.84 + * @param new_limit New limit, in seconds.
1.85 + */
1.86 + virtual void MapTimeLimitExtended(int old_limit, int new_limit) =0;
1.87 };
1.88 }
1.89