Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/gui/src/orxonox/gamestates/GSRoot.cc @ 1661

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

started implementing the GameStates. Not much for now, but most of the Orxonox.cc code has been copied to GSRoot, GSGraphics and GSLevel.
There is no level currently, but the main menu is shown. This is more of an svn save because I would really like to have Member ConsoleCommands.

  • Property svn:eol-style set to native
File size: 2.8 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#include "OrxonoxStableHeaders.h"
30#include "GSRoot.h"
31
32#include <cassert>
33#include "core/Factory.h"
34#include "core/ConfigFileManager.h"
35#include "core/ConfigValueIncludes.h"
36#include "core/ConsoleCommand.h"
37#include "core/Debug.h"
38//#include "core/Exception.h"
39#include "core/TclBind.h"
40#include "core/Core.h"
41#include "GraphicsEngine.h"
42#include "Settings.h"
43
44namespace orxonox
45{
46    GSRoot::GSRoot()
47        : GameState("root")
48        , graphicsEngine_(0)
49    {
50    }
51
52    GSRoot::~GSRoot()
53    {
54    }
55
56    void GSRoot::enter()
57    {
58#if ORXONOX_DEBUG_MODE == 1
59        ConfigFileManager::getSingleton()->setFile(CFT_Settings, "orxonox_d.ini");
60#else
61        ConfigFileManager::getSingleton()->setFile(CFT_Settings, "orxonox.ini");
62#endif
63
64        // creates the class hierarchy for all classes with factories
65        Factory::createClassHierarchy();
66
67        // TODO: config values
68        //setConfigValues();
69
70        const Settings::CommandLineArgument* dataPath = Settings::getCommandLineArgument("dataPath");
71        assert(dataPath);
72        if (!dataPath->bHasDefaultValue_)
73        {
74            if (*dataPath->value_.getString().end() != '/' && *dataPath->value_.getString().end() != '\\')
75                Settings::tsetDataPath(dataPath->value_.getString() + "/");
76            else
77                Settings::tsetDataPath(dataPath->value_.getString());
78        }
79
80        // initialise TCL
81        TclBind::getInstance().setDataPath(Settings::getDataPath());
82
83        graphicsEngine_ = new GraphicsEngine();
84        graphicsEngine_->setup();       // creates ogre root and other essentials
85
86    }
87
88    void GSRoot::leave()
89    {
90        if (this->graphicsEngine_)
91            delete graphicsEngine_;
92    }
93
94    bool GSRoot::tick(float dt)
95    {
96        if (this->getActiveChild())
97            this->getActiveChild()->tick(dt);
98        return true;
99    }
100}
Note: See TracBrowser for help on using the repository browser.