Changeset 1695
- Timestamp:
- Sep 3, 2008, 8:29:53 PM (16 years ago)
- Location:
- code/branches/gui/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/gui/src/core/CorePrereqs.h
r1689 r1695 100 100 class ClassTreeMaskIterator; 101 101 class ClassTreeMaskNode; 102 class Clock; 102 103 class CommandEvaluation; 103 104 class CommandExecutor; -
code/branches/gui/src/core/RootGameState.cc
r1690 r1695 131 131 void RootGameState::start(int argc, char** argv) 132 132 { 133 // start global orxonox time 134 Clock clock; 135 133 136 parseArguments(argc, argv); 134 137 … … 140 143 gotoState(initialState); 141 144 142 Clock clock;143 145 while (this->activeChild_) 144 146 { -
code/branches/gui/src/orxonox/tools/Timer.cc
r1552 r1695 36 36 #include "core/ConsoleCommand.h" 37 37 #include "core/CommandExecutor.h" 38 #include "core/Clock.h" 38 39 39 40 namespace orxonox … … 125 126 @brief Updates the timer before the frames are rendered. 126 127 */ 127 void TimerBase::tick( float dt)128 void TimerBase::tick(const Clock& time) 128 129 { 129 130 if (this->bActive_) 130 131 { 131 132 // If active: Decrease the timer by the duration of the last frame 132 this->time_ -= dt;133 this->time_ -= time.getDeltaTimeMicroseconds(); 133 134 134 135 if (this->time_ <= 0) -
code/branches/gui/src/orxonox/tools/Timer.h
r1608 r1695 62 62 63 63 #include "OrxonoxPrereqs.h" 64 #include "objects/Tickable.h" 64 #include "util/Integers.h" 65 #include "core/OrxonoxClass.h" 65 66 66 67 namespace orxonox … … 72 73 73 74 //! TimerBase is the parent of the Timer class. 74 class _OrxonoxExport TimerBase : public Tickable75 class _OrxonoxExport TimerBase : public OrxonoxClass 75 76 { 76 77 public: … … 97 98 /** @brief Returns the remaining time until the Timer calls the function. @return The remaining time */ 98 99 inline float getRemainingTime() const 99 { return this->time_; }100 { return (float)this->time_ / 1000000.0f; } 100 101 /** @brief Gives the Timer some extra time. @param time The amount of extra time in seconds */ 101 102 inline void addTime(float time) 102 { this->time_ += time; }103 { if (time > 0.0f) this->time_ += (uint64_t)(time * 1000000.0f); } 103 104 /** @brief Decreases the remaining time of the Timer. @param time The amount of time to remove */ 104 105 inline void removeTime(float time) 105 { this->time_ -= time; }106 { if (time > 0.0f) this->time_ -= (uint64_t)(time * 1000000.0f); } 106 107 /** @brief Sets the interval of the Timer. @param interval The interval */ 107 108 inline void setInterval(float interval) 108 { this->interval_ = interval; }109 { this->interval_ = (uint64_t)(interval * 1000000.0f); } 109 110 /** @brief Sets bLoop to a given value. @param bLoop True = loop */ 110 111 inline void setLoop(bool bLoop) 111 112 { this->bLoop_ = bLoop; } 112 113 113 void tick( float dt);114 void tick(const Clock& time); 114 115 115 116 protected: … … 118 119 Executor* executor_; //!< The executor of the function that should be called when the time expires 119 120 120 float interval_; //!< The time-interval inseconds121 uint64_t interval_; //!< The time-interval in micro seconds 121 122 bool bLoop_; //!< If true, the function gets called every 'interval' seconds 122 123 bool bActive_; //!< If true, the Timer ticks and calls the function if the time's up 123 124 124 float time_;//!< Internal variable, counting the time till the next function-call125 uint64_t time_; //!< Internal variable, counting the time till the next function-call 125 126 }; 126 127 … … 155 156 this->deleteExecutor(); 156 157 157 this-> interval_ = interval;158 this->setInterval(interval); 158 159 this->bLoop_ = bLoop; 159 160 executor->setObject(object); … … 161 162 this->bActive_ = true; 162 163 163 this->time_ = interval;164 this->time_ = this->interval_; 164 165 } 165 166 }; … … 193 194 this->deleteExecutor(); 194 195 195 this-> interval_ = interval;196 this->setInterval(interval); 196 197 this->bLoop_ = bLoop; 197 198 this->executor_ = (Executor*)executor; 198 199 this->bActive_ = true; 199 200 200 this->time_ = interval;201 this->time_ = this->interval_; 201 202 } 202 203 };
Note: See TracChangeset
for help on using the changeset viewer.