Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 19, 2009, 6:11:00 PM (15 years ago)
Author:
rgrieder
Message:

Moved global game clock to Core. Use getGameClock() for a const reference to an object that can tell you the time since the game was started or since the last capture() (which is usually once a frame).

Location:
code/branches/gui/src/core
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/gui/src/core/Core.cc

    r2800 r2807  
    9494    SetCommandLineArgument(limitToCPU, 0).information("0: off | #cpu");
    9595
    96     /**
    97         @brief Constructor: Registers the object and sets the config-values.
    98         @param A reference to a global variable, used to avoid an infinite recursion in getSoftDebugLevel()
    99     */
    100     Core::Core(int argc, char** argv)
     96    Core::Core()
    10197    {
    10298        RegisterRootObject(Core);
     
    104100        assert(Core::singletonRef_s == 0);
    105101        Core::singletonRef_s = this;
     102    }
     103
     104    Clock* Core::initialise(int argc, char** argv)
     105    {
     106        // Set up a basic clock to keep time
     107        this->gameClock_ = new Clock();
    106108
    107109        // Parse command line arguments fist
     
    173175       
    174176        this->loaded_ = true;
     177
     178        // Return non const pointer to the game's clock for the main loop
     179        return this->gameClock_;
    175180    }
    176181
     
    194199        // Also delete external console command that don't belong to an Identifier
    195200        CommandExecutor::destroyExternalCommands();
     201
     202        delete this->gameClock_;
    196203
    197204        assert(Core::singletonRef_s);
  • code/branches/gui/src/core/Core.h

    r2800 r2807  
    6161    {
    6262        public:
    63             Core(int argc, char** argv);
     63            Core();
    6464            ~Core();
     65
     66            Clock* initialise(int argc, char** argv);
    6567            void setConfigValues();
    6668
    67             bool isLoaded() { return this->loaded_; }
    6869            void update(const Clock& time);
    6970
     
    7475            static const std::string& getLanguage();
    7576            static void  resetLanguage();
     77
     78            static const Clock& getGameClock() { return *getInstance().gameClock_; }
    7679
    7780            static void tsetMediaPath(const std::string& path)
     
    120123            TclThreadManager*     tclThreadManager_;
    121124
     125            Clock*                gameClock_;
     126
    122127            int softDebugLevel_;                            //!< The debug level
    123128            int softDebugLevelConsole_;                     //!< The debug level for the console
Note: See TracChangeset for help on using the changeset viewer.