Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/gui/src/orxonox/gamestates/GSRoot.h @ 2799

Last change on this file since 2799 was 2799, checked in by rgrieder, 15 years ago

Moved all core related initialisations from Main.cc and GSRoot.cc to Core.cc so that everything sticks together more obviously.

Renamed —directory command line argument: Name really doesn't say what it is.
using —writingPathSuffix now. Not much better, but at least you wonder

  • Property svn:eol-style set to native
File size: 3.5 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Reto Grieder
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#ifndef _GSRoot_H__
30#define _GSRoot_H__
31
32#include "OrxonoxPrereqs.h"
33
34#include <list>
35#include "core/RootGameState.h"
36#include "core/OrxonoxClass.h"
37
38namespace orxonox
39{
40    class _OrxonoxExport GSRoot : public RootGameState, public OrxonoxClass
41    {
42        friend class ClassIdentifier<GSRoot>;
43
44    public:
45        struct statisticsTickInfo
46        {
47            uint64_t    tickTime;
48            uint32_t    tickLength;
49        };
50   
51    public:
52        GSRoot();
53        ~GSRoot();
54
55        void exitGame()
56        { requestState("root"); }
57
58        // this has to be public because proteced triggers a bug in msvc
59        // when taking the function address.
60        void setTimeFactor(float factor);
61        void pause();
62        float getTimeFactor() { return this->timeFactor_; }
63
64        float getAvgTickTime() { return this->avgTickTime_; }
65        float getAvgFPS()      { return this->avgFPS_; }
66
67        inline void addTickTime(uint32_t length)
68            { assert(!this->statisticsTickTimes_.empty()); this->statisticsTickTimes_.back().tickLength += length;
69              this->periodTickTime_+=length; }
70
71    private:
72        void enter();
73        void leave();
74        void ticked(const Clock& time);
75
76        void setConfigValues();
77
78        float                 timeFactor_;       //!< A factor that sets the gamespeed. 1 is normal.
79        bool                  bPaused_;
80        float                 timeFactorPauseBackup_;
81
82        // variables for time statistics
83        uint64_t              statisticsStartTime_;
84        std::list<statisticsTickInfo>
85                              statisticsTickTimes_;
86        uint32_t              periodTickTime_;
87        float                 avgFPS_;
88        float                 avgTickTime_;
89
90        // config values
91        unsigned int          statisticsRefreshCycle_;
92        unsigned int          statisticsAvgLength_;
93
94        // console commands
95        ConsoleCommand*       ccExit_;
96        ConsoleCommand*       ccSelectGameState_;
97        ConsoleCommand*       ccSetTimeFactor_;
98        ConsoleCommand*       ccPause_;
99    };
100
101    class _OrxonoxExport TimeFactorListener : virtual public OrxonoxClass
102    {
103        friend class GSRoot;
104
105        public:
106            TimeFactorListener();
107            virtual ~TimeFactorListener() {}
108
109        protected:
110            virtual void changedTimeFactor(float factor_new, float factor_old) {}
111            inline float getTimeFactor() const
112                { return TimeFactorListener::timefactor_s; }
113
114        private:
115            static float timefactor_s;
116    };
117}
118
119#endif /* _GSRoot_H__ */
Note: See TracBrowser for help on using the repository browser.