Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 21, 2008, 3:50:44 PM (16 years ago)
Author:
rgrieder
Message:
  • removed all our FrameListeners except one (OrxListener will soon be vanished too) —> all timers are now tickable
  • some minor irrelevant changes in orxonox.cc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/input/src/orxonox/tools/Timer.h

    r900 r916  
    5858#define _Timer_H__
    5959
    60 #include <OgreFrameListener.h>
    6160#include "../OrxonoxPrereqs.h"
     61#include "objects/Tickable.h"
    6262
    6363namespace orxonox
    6464{
    6565    //! TimerBase is the parent of the Timer class.
    66     class _OrxonoxExport TimerBase : public OrxonoxClass
     66    class _OrxonoxExport TimerBase : public Tickable
    6767    {
    68         //friend class TimerFrameListener;
    69         friend class Orxonox;
    70 
    7168        public:
    7269            TimerBase();
     
    8481            /** @brief Returns true if the Timer is active (= not stoped, not paused). @return True = Time is active */
    8582            inline bool isActive() const { return this->bActive_; }
     83
     84            void tick(float dt);
    8685
    8786        protected:
     
    146145    };
    147146
    148 #if 0
    149     //! The TimerFrameListener manages all Timers in the game.
    150     class TimerFrameListener : public Ogre::FrameListener
    151     {
    152         private:
    153             /** @brief Gets called before a frame gets rendered. */
    154             bool frameStarted(const Ogre::FrameEvent &evt)
    155             {
    156                 // Iterate through all Timers
    157                 for (Iterator<TimerBase> it = ObjectList<TimerBase>::start(); it; )
    158                 {
    159                     if (it->isActive())
    160                     {
    161                         // If active: Decrease the timer by the duration of the last frame
    162                         it->time_ -= evt.timeSinceLastFrame;
    163 
    164                         if (it->time_ <= 0)
    165                         {
    166                             // It's time to call the function
    167                             if (it->bLoop_)
    168                                 it->time_ += it->interval_; // Q: Why '+=' and not '='? A: Think about it. It's more accurate like that. Seriously.
    169                             else
    170                                 it->stopTimer(); // Stop the timer if we don't want to loop
    171 
    172                             (it++)->run();
    173                         }
    174                         else
    175                             ++it;
    176                     }
    177                     else
    178                         ++it;
    179                 }
    180 
    181                 return FrameListener::frameStarted(evt);
    182             }
    183     };
    184 #endif
    185147}
    186148
Note: See TracChangeset for help on using the changeset viewer.