Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 21, 2009, 10:17:59 PM (16 years ago)
Author:
rgrieder
Message:

Removed GameState template and renamed GameStateBase to GameState.
Moved statistics stuff (fps and tick time) to Game and removed the remaining hacks in GSGraphics and GSRoot.

Location:
code/branches/gui/src/orxonox/gamestates
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • code/branches/gui/src/orxonox/gamestates/GSClient.cc

    r2807 r2817  
    4141
    4242    GSClient::GSClient()
    43         : GameState<GSGraphics>("client")
     43        : GameState("client")
    4444        , client_(0)
    4545    {
  • code/branches/gui/src/orxonox/gamestates/GSClient.h

    r2171 r2817  
    3131
    3232#include "OrxonoxPrereqs.h"
     33#include "core/GameState.h"
    3334#include "network/NetworkPrereqs.h"
    3435#include "GSLevel.h"
    35 #include "GSGraphics.h"
    3636
    3737namespace orxonox
    3838{
    39     class _OrxonoxExport GSClient : public GameState<GSGraphics>, public GSLevel
     39    class _OrxonoxExport GSClient : public GameState, public GSLevel
    4040    {
    4141    public:
  • code/branches/gui/src/orxonox/gamestates/GSDedicated.cc

    r2801 r2817  
    4141{
    4242    GSDedicated::GSDedicated()
    43         : GameState<GSRoot>("dedicated")
     43        : GameState("dedicated")
    4444        , server_(0)
    4545        , timeSinceLastUpdate_(0)
  • code/branches/gui/src/orxonox/gamestates/GSDedicated.h

    r2662 r2817  
    3131
    3232#include "OrxonoxPrereqs.h"
     33#include "core/GameState.h"
    3334#include "network/NetworkPrereqs.h"
    3435#include "GSLevel.h"
    35 #include "GSRoot.h"
    3636
    3737namespace orxonox
    3838{
    39     class _OrxonoxExport GSDedicated : public GameState<GSRoot>, public GSLevel
     39    class _OrxonoxExport GSDedicated : public GameState, public GSLevel
    4040    {
    4141    public:
  • code/branches/gui/src/orxonox/gamestates/GSGUI.cc

    r2808 r2817  
    4040{
    4141    GSGUI::GSGUI()
    42         : GameState<GSGraphics>("gui")
     42        : GameState("gui")
    4343    {
    4444    }
  • code/branches/gui/src/orxonox/gamestates/GSGUI.h

    r1755 r2817  
    3232#include "OrxonoxPrereqs.h"
    3333#include "core/GameState.h"
    34 #include "GSGraphics.h"
    3534
    3635namespace orxonox
    3736{
    38     class _OrxonoxExport GSGUI : public GameState<GSGraphics>
     37    class _OrxonoxExport GSGUI : public GameState
    3938    {
    4039    public:
  • code/branches/gui/src/orxonox/gamestates/GSGraphics.cc

    r2816 r2817  
    4444#include "overlays/console/InGameConsole.h"
    4545#include "gui/GUIManager.h"
    46 
    47 // for compatibility
    4846#include "GraphicsManager.h"
     47#include "Game.h"
    4948
    5049namespace orxonox
    5150{
    5251    GSGraphics::GSGraphics()
    53         : GameState<GSRoot>("graphics")
     52        : GameState("graphics")
    5453        , inputManager_(0)
    5554        , console_(0)
     
    157156        uint64_t timeAfterTick = time.getRealMicroseconds();
    158157
    159         // Also add our tick time to the list in GSRoot
    160         this->getParent()->addTickTime(timeAfterTick - timeBeforeTick);
    161 
    162         // Update statistics overlay. Note that the values only change periodically in GSRoot.
    163         GraphicsManager::getInstance().setAverageFramesPerSecond(this->getParent()->getAvgFPS());
    164         GraphicsManager::getInstance().setAverageTickTime(this->getParent()->getAvgTickTime());
     158        // Also add our tick time
     159        Game::getInstance().addTickTime(timeAfterTick - timeBeforeTick);
    165160
    166161        this->graphicsManager_->update(time);
  • code/branches/gui/src/orxonox/gamestates/GSGraphics.h

    r2816 r2817  
    3434#include "core/OrxonoxClass.h"
    3535#include "tools/WindowEventListener.h"
    36 #include "GSRoot.h"
    3736
    3837namespace orxonox
    3938{
    40     class _OrxonoxExport GSGraphics : public GameState<GSRoot>, public WindowEventListener
     39    class _OrxonoxExport GSGraphics : public GameState, public WindowEventListener
    4140    {
    4241        friend class ClassIdentifier<GSGraphics>;
  • code/branches/gui/src/orxonox/gamestates/GSIOConsole.cc

    r2087 r2817  
    4040{
    4141    GSIOConsole::GSIOConsole()
    42         : GameState<GSRoot>("ioConsole")
     42        : GameState("ioConsole")
    4343    {
    4444    }
  • code/branches/gui/src/orxonox/gamestates/GSIOConsole.h

    r1755 r2817  
    3333#include <OgrePrerequisites.h>
    3434#include "core/GameState.h"
    35 #include "GSRoot.h"
    3635
    3736namespace orxonox
    3837{
    39     class _OrxonoxExport GSIOConsole : public GameState<GSRoot>
     38    class _OrxonoxExport GSIOConsole : public GameState
    4039    {
    4140    public:
  • code/branches/gui/src/orxonox/gamestates/GSLevel.cc

    r2814 r2817  
    5353
    5454    GSLevel::GSLevel()
    55 //        : GameState<GSGraphics>(name)
     55//        : GameState(name)
    5656        : keyBinder_(0)
    5757        , inputState_(0)
  • code/branches/gui/src/orxonox/gamestates/GSLevel.h

    r2801 r2817  
    3131
    3232#include "OrxonoxPrereqs.h"
     33#include "core/GameState.h"
    3334#include "core/OrxonoxClass.h"
    3435
  • code/branches/gui/src/orxonox/gamestates/GSRoot.cc

    r2805 r2817  
    3333#include "util/Debug.h"
    3434#include "core/Core.h"
    35 #include "core/ConfigValueIncludes.h"
    3635#include "core/CoreIncludes.h"
    3736#include "core/ConsoleCommand.h"
    3837#include "tools/Timer.h"
    3938#include "objects/Tickable.h"
     39#include "Game.h"
    4040
    4141namespace orxonox
     
    4747        , timeFactorPauseBackup_(1.0f)
    4848    {
    49         RegisterRootObject(GSRoot);
    50         setConfigValues();
    51 
    5249        this->ccSetTimeFactor_ = 0;
    5350        this->ccPause_ = 0;
     
    5855    }
    5956
    60     void GSRoot::setConfigValues()
    61     {
    62         SetConfigValue(statisticsRefreshCycle_, 250000)
    63             .description("Sets the time in microseconds interval at which average fps, etc. get updated.");
    64         SetConfigValue(statisticsAvgLength_, 1000000)
    65             .description("Sets the time in microseconds interval at which average fps, etc. gets calculated.");
    66     }
    67 
    6857    void GSRoot::enter()
    6958    {
     
    7160        timeFactor_ = 1.0f;
    7261
    73         // reset frame counter
    74         this->statisticsStartTime_ = 0;
    75         this->statisticsTickTimes_.clear();
    76         this->periodTickTime_ = 0;
    77         this->avgFPS_ = 0.0f;
    78         this->avgTickTime_ = 0.0f;
    79 
    8062        {
    8163            // add console commands
    82             FunctorMember01<GameStateBase, const std::string&>* functor = createFunctor(&GameStateBase::requestState);
     64            FunctorMember01<GameState, const std::string&>* functor = createFunctor(&GameState::requestState);
    8365            functor->setObject(this);
    8466            this->ccSelectGameState_ = createConsoleCommand(functor, "selectGameState");
     
    144126        uint64_t timeAfterTick = time.getRealMicroseconds();
    145127
    146         // STATISTICS
    147         assert(timeAfterTick - timeBeforeTick >= 0 );
    148         statisticsTickInfo tickInfo = {timeAfterTick, timeAfterTick - timeBeforeTick};
    149         statisticsTickTimes_.push_back(tickInfo);
    150         assert(statisticsTickTimes_.back().tickLength==tickInfo.tickLength);
    151         this->periodTickTime_ += tickInfo.tickLength;
     128        // Also add our tick time to the list in GSRoot
     129        Game::getInstance().addTickTime(timeAfterTick - timeBeforeTick);
    152130
    153         // Ticks GSGraphics or GSDedicated
    154131        this->tickChild(time);
    155 
    156         if (timeAfterTick > statisticsStartTime_ + statisticsRefreshCycle_)
    157         {
    158             std::list<statisticsTickInfo>::iterator it = this->statisticsTickTimes_.begin();
    159             assert(it != this->statisticsTickTimes_.end());
    160             int64_t lastTime = timeAfterTick - statisticsAvgLength_;
    161             if ((int64_t)it->tickTime < lastTime)
    162             {
    163                 do
    164                 {
    165                     assert(this->periodTickTime_ > it->tickLength);
    166                     this->periodTickTime_ -= it->tickLength;
    167                     ++it;
    168                     assert(it != this->statisticsTickTimes_.end());
    169                 } while ((int64_t)it->tickTime < lastTime);
    170                 this->statisticsTickTimes_.erase(this->statisticsTickTimes_.begin(), it);
    171             }
    172 
    173             uint32_t framesPerPeriod = this->statisticsTickTimes_.size();
    174             this->avgFPS_ = (float)framesPerPeriod / (timeAfterTick - this->statisticsTickTimes_.front().tickTime) * 1000000.0;
    175             this->avgTickTime_ = (float)this->periodTickTime_ / framesPerPeriod / 1000.0;
    176 
    177             statisticsStartTime_ = timeAfterTick;
    178         }
    179 
    180132    }
    181133
  • code/branches/gui/src/orxonox/gamestates/GSRoot.h

    r2805 r2817  
    3838namespace orxonox
    3939{
    40     class _OrxonoxExport GSRoot : public RootGameState, public OrxonoxClass
     40    class _OrxonoxExport GSRoot : public RootGameState
    4141    {
    4242        friend class ClassIdentifier<GSRoot>;
    4343
    4444    public:
    45         struct statisticsTickInfo
    46         {
    47             uint64_t    tickTime;
    48             uint32_t    tickLength;
    49         };
    5045   
    5146    public:
     
    5954        float getTimeFactor() { return this->timeFactor_; }
    6055
    61         float getAvgTickTime() { return this->avgTickTime_; }
    62         float getAvgFPS()      { return this->avgFPS_; }
    63 
    64         inline void addTickTime(uint32_t length)
    65             { assert(!this->statisticsTickTimes_.empty()); this->statisticsTickTimes_.back().tickLength += length;
    66               this->periodTickTime_+=length; }
    67 
    6856    private:
    6957        void enter();
     
    7159        void ticked(const Clock& time);
    7260
    73         void setConfigValues();
    74 
    7561        float                 timeFactor_;       //!< A factor that sets the gamespeed. 1 is normal.
    7662        bool                  bPaused_;
    7763        float                 timeFactorPauseBackup_;
    78 
    79         // variables for time statistics
    80         uint64_t              statisticsStartTime_;
    81         std::list<statisticsTickInfo>
    82                               statisticsTickTimes_;
    83         uint32_t              periodTickTime_;
    84         float                 avgFPS_;
    85         float                 avgTickTime_;
    86 
    87         // config values
    88         unsigned int          statisticsRefreshCycle_;
    89         unsigned int          statisticsAvgLength_;
    9064
    9165        // console commands
  • code/branches/gui/src/orxonox/gamestates/GSServer.cc

    r2801 r2817  
    3939
    4040    GSServer::GSServer()
    41         : GameState<GSGraphics>("server")
     41        : GameState("server")
    4242        , server_(0)
    4343    {
  • code/branches/gui/src/orxonox/gamestates/GSServer.h

    r2171 r2817  
    3131
    3232#include "OrxonoxPrereqs.h"
     33#include "core/GameState.h"
    3334#include "network/NetworkPrereqs.h"
    3435#include "GSLevel.h"
    35 #include "GSGraphics.h"
    3636
    3737namespace orxonox
    3838{
    39     class _OrxonoxExport GSServer : public GameState<GSGraphics>, public GSLevel
     39    class _OrxonoxExport GSServer : public GameState, public GSLevel
    4040    {
    4141    public:
  • code/branches/gui/src/orxonox/gamestates/GSStandalone.cc

    r2808 r2817  
    4040{
    4141    GSStandalone::GSStandalone()
    42         : GameState<GSGraphics>("standalone")
     42        : GameState("standalone")
    4343    {
    4444    }
  • code/branches/gui/src/orxonox/gamestates/GSStandalone.h

    r2808 r2817  
    3131
    3232#include "OrxonoxPrereqs.h"
     33#include "core/GameState.h"
    3334#include "GSLevel.h"
    34 #include "GSGraphics.h"
    3535
    3636namespace orxonox
    3737{
    38     class _OrxonoxExport GSStandalone : public GameState<GSGraphics>, public GSLevel
     38    class _OrxonoxExport GSStandalone : public GameState, public GSLevel
    3939    {
    4040    public:
Note: See TracChangeset for help on using the changeset viewer.