[1661] | 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 "core/Factory.h" |
---|
| 33 | #include "core/ConfigFileManager.h" |
---|
| 34 | #include "core/ConfigValueIncludes.h" |
---|
| 35 | #include "core/ConsoleCommand.h" |
---|
| 36 | #include "core/Debug.h" |
---|
[1662] | 37 | #include "core/Exception.h" |
---|
[1661] | 38 | #include "core/TclBind.h" |
---|
| 39 | #include "core/Core.h" |
---|
| 40 | #include "GraphicsEngine.h" |
---|
| 41 | #include "Settings.h" |
---|
| 42 | |
---|
| 43 | namespace orxonox |
---|
| 44 | { |
---|
| 45 | GSRoot::GSRoot() |
---|
| 46 | : GameState("root") |
---|
| 47 | , graphicsEngine_(0) |
---|
| 48 | { |
---|
| 49 | } |
---|
| 50 | |
---|
| 51 | GSRoot::~GSRoot() |
---|
| 52 | { |
---|
| 53 | } |
---|
| 54 | |
---|
| 55 | void GSRoot::enter() |
---|
| 56 | { |
---|
| 57 | #if ORXONOX_DEBUG_MODE == 1 |
---|
| 58 | ConfigFileManager::getSingleton()->setFile(CFT_Settings, "orxonox_d.ini"); |
---|
| 59 | #else |
---|
| 60 | ConfigFileManager::getSingleton()->setFile(CFT_Settings, "orxonox.ini"); |
---|
| 61 | #endif |
---|
| 62 | |
---|
| 63 | // creates the class hierarchy for all classes with factories |
---|
| 64 | Factory::createClassHierarchy(); |
---|
| 65 | |
---|
| 66 | const Settings::CommandLineArgument* dataPath = Settings::getCommandLineArgument("dataPath"); |
---|
| 67 | assert(dataPath); |
---|
| 68 | if (!dataPath->bHasDefaultValue_) |
---|
| 69 | { |
---|
| 70 | if (*dataPath->value_.getString().end() != '/' && *dataPath->value_.getString().end() != '\\') |
---|
| 71 | Settings::tsetDataPath(dataPath->value_.getString() + "/"); |
---|
| 72 | else |
---|
| 73 | Settings::tsetDataPath(dataPath->value_.getString()); |
---|
| 74 | } |
---|
| 75 | |
---|
| 76 | // initialise TCL |
---|
| 77 | TclBind::getInstance().setDataPath(Settings::getDataPath()); |
---|
| 78 | |
---|
[1662] | 79 | // initialise graphics engine. Doesn't load the render window yet! |
---|
[1661] | 80 | graphicsEngine_ = new GraphicsEngine(); |
---|
| 81 | graphicsEngine_->setup(); // creates ogre root and other essentials |
---|
| 82 | |
---|
[1662] | 83 | // console commands |
---|
| 84 | FunctorMember<GSRoot>* functor = createFunctor(&GSRoot::loadGame); |
---|
| 85 | functor->setObject(this); |
---|
| 86 | CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "loadGame")); |
---|
[1661] | 87 | } |
---|
| 88 | |
---|
| 89 | void GSRoot::leave() |
---|
| 90 | { |
---|
| 91 | if (this->graphicsEngine_) |
---|
| 92 | delete graphicsEngine_; |
---|
| 93 | } |
---|
| 94 | |
---|
| 95 | bool GSRoot::tick(float dt) |
---|
| 96 | { |
---|
| 97 | if (this->getActiveChild()) |
---|
| 98 | this->getActiveChild()->tick(dt); |
---|
| 99 | return true; |
---|
| 100 | } |
---|
[1662] | 101 | |
---|
| 102 | /** |
---|
| 103 | @brief |
---|
| 104 | Requests a state. |
---|
| 105 | */ |
---|
| 106 | void GSRoot::loadGame(const std::string& name) |
---|
| 107 | { |
---|
| 108 | this->requestState(name); |
---|
| 109 | } |
---|
[1661] | 110 | } |
---|