Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 10, 2008, 1:37:36 AM (16 years ago)
Author:
rgrieder
Message:

merged gui back to trunk.
update the media repository!

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/tools/Timer.h

    r1608 r1755  
    6262
    6363#include "OrxonoxPrereqs.h"
    64 #include "objects/Tickable.h"
     64#include "core/OrxonoxClass.h"
    6565
    6666namespace orxonox
     
    7272
    7373    //! TimerBase is the parent of the Timer class.
    74     class _OrxonoxExport TimerBase : public Tickable
     74    class _OrxonoxExport TimerBase : public OrxonoxClass
    7575    {
    7676        public:
     
    9797            /** @brief Returns the remaining time until the Timer calls the function. @return The remaining time */
    9898            inline float getRemainingTime() const
    99                 { return this->time_; }
     99                { return (float)this->time_ / 1000000.0f; }
    100100            /** @brief Gives the Timer some extra time. @param time The amount of extra time in seconds */
    101101            inline void addTime(float time)
    102                 { this->time_ += time; }
     102                { if (time > 0.0f) this->time_ += (long long)(time * 1000000.0f); }
    103103            /** @brief Decreases the remaining time of the Timer. @param time The amount of time to remove */
    104104            inline void removeTime(float time)
    105                 { this->time_ -= time; }
     105                { if (time > 0.0f) this->time_ -= (long long)(time * 1000000.0f); }
    106106            /** @brief Sets the interval of the Timer. @param interval The interval */
    107107            inline void setInterval(float interval)
    108                 { this->interval_ = interval; }
     108                { this->interval_ = (long long)(interval * 1000000.0f); }
    109109            /** @brief Sets bLoop to a given value. @param bLoop True = loop */
    110110            inline void setLoop(bool bLoop)
    111111                { this->bLoop_ = bLoop; }
    112112
    113             void tick(float dt);
     113            void tick(const Clock& time);
    114114
    115115        protected:
     
    118118            Executor* executor_; //!< The executor of the function that should be called when the time expires
    119119
    120             float interval_;     //!< The time-interval in seconds
     120            long long interval_; //!< The time-interval in micro seconds
    121121            bool bLoop_;         //!< If true, the function gets called every 'interval' seconds
    122122            bool bActive_;       //!< If true, the Timer ticks and calls the function if the time's up
    123123
    124             float time_;         //!< Internal variable, counting the time till the next function-call
     124            long long time_;     //!< Internal variable, counting the time till the next function-call
    125125    };
    126126
     
    155155                this->deleteExecutor();
    156156
    157                 this->interval_ = interval;
     157                this->setInterval(interval);
    158158                this->bLoop_ = bLoop;
    159159                executor->setObject(object);
     
    161161                this->bActive_ = true;
    162162
    163                 this->time_ = interval;
     163                this->time_ = this->interval_;
    164164            }
    165165    };
     
    193193                this->deleteExecutor();
    194194
    195                 this->interval_ = interval;
     195                this->setInterval(interval);
    196196                this->bLoop_ = bLoop;
    197197                this->executor_ = (Executor*)executor;
    198198                this->bActive_ = true;
    199199
    200                 this->time_ = interval;
     200                this->time_ = this->interval_;
    201201            }
    202202    };
Note: See TracChangeset for help on using the changeset viewer.