Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/buildsystem3/src/orxonox/gamestates/GSRoot.h @ 2731

Last change on this file since 2731 was 2685, checked in by rgrieder, 16 years ago

Fixed install target:

  • log and config file go a to separate folder each
  • The SignalHandler crash log is now "orxonox_crash.log" to avoid opening the file twice which might result in problems
  • moved tcl scripts to media/tcl8.#/ as a temporary solution. I've also created a ticket to fix this.
  • UPDATE YOUR MEDIA REPOSITORY
  • orxonox.log pre-main gets written to either %TEMP% (windows) or /tmp (Unix) and when the path was set, the content is copied.
  • removed Settings class and moved media path to Core
  • media, log and config path are now all in Core where only the media path can be configured via ini file or command line
  • Core::isDevBuild() tells whether we are running in the build or the installation directory (determined by the presence of "orxonox_dev_build.kepp_me" in the binary dir)
  • renamed Settings::getDataPath to Core::getMediaPath
  • Property svn:eol-style set to native
File size: 3.7 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 <OgreLog.h>
36#include "core/RootGameState.h"
37#include "core/OrxonoxClass.h"
38
39namespace orxonox
40{
41    class _OrxonoxExport GSRoot : public RootGameState, public OrxonoxClass
42    {
43        friend class ClassIdentifier<GSRoot>;
44
45    public:
46        struct statisticsTickInfo
47        {
48            uint64_t    tickTime;
49            uint32_t    tickLength;
50        };
51   
52    public:
53        GSRoot();
54        ~GSRoot();
55
56        void exitGame()
57        { requestState("root"); }
58
59        // this has to be public because proteced triggers a bug in msvc
60        // when taking the function address.
61        void setTimeFactor(float factor);
62        void pause();
63        float getTimeFactor() { return this->timeFactor_; }
64
65        float getAvgTickTime() { return this->avgTickTime_; }
66        float getAvgFPS()      { return this->avgFPS_; }
67
68        inline void addTickTime(uint32_t length)
69            { assert(!this->statisticsTickTimes_.empty()); this->statisticsTickTimes_.back().tickLength += length;
70              this->periodTickTime_+=length; }
71
72    private:
73        void enter();
74        void leave();
75        void ticked(const Clock& time);
76
77        void setConfigValues();
78        void setThreadAffinity(unsigned int limitToCPU);
79
80        float                 timeFactor_;       //!< A factor that sets the gamespeed. 1 is normal.
81        bool                  bPaused_;
82        float                 timeFactorPauseBackup_;
83        TclBind*              tclBind_;
84        TclThreadManager*     tclThreadManager_;
85        Shell*                shell_;
86        LuaBind*              luaBind_;
87
88        // variables for time statistics
89        uint64_t              statisticsStartTime_;
90        std::list<statisticsTickInfo>
91                              statisticsTickTimes_;
92        uint32_t              periodTickTime_;
93        float                 avgFPS_;
94        float                 avgTickTime_;
95
96        // config values
97        unsigned int          statisticsRefreshCycle_;
98        unsigned int          statisticsAvgLength_;
99
100        // console commands
101        ConsoleCommand*       ccExit_;
102        ConsoleCommand*       ccSelectGameState_;
103        ConsoleCommand*       ccSetTimeFactor_;
104        ConsoleCommand*       ccPause_;
105    };
106
107    class _OrxonoxExport TimeFactorListener : virtual public OrxonoxClass
108    {
109        friend class GSRoot;
110
111        public:
112            TimeFactorListener();
113            virtual ~TimeFactorListener() {}
114
115        protected:
116            virtual void changedTimeFactor(float factor_new, float factor_old) {}
117            inline float getTimeFactor() const
118                { return TimeFactorListener::timefactor_s; }
119
120        private:
121            static float timefactor_s;
122    };
123}
124
125#endif /* _GSRoot_H__ */
Note: See TracBrowser for help on using the repository browser.