[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" |
---|
[2850] | 30 | #include "GSMainMenu.h" |
---|
[1661] | 31 | |
---|
[2850] | 32 | //#include <OgreViewport.h> |
---|
| 33 | #include <OgreSceneManager.h> |
---|
[2800] | 34 | #include "core/Clock.h" |
---|
[2844] | 35 | #include "core/ConsoleCommand.h" |
---|
[2848] | 36 | #include "core/Game.h" |
---|
[1661] | 37 | #include "core/input/InputManager.h" |
---|
| 38 | #include "core/input/SimpleInputState.h" |
---|
| 39 | #include "gui/GUIManager.h" |
---|
[2850] | 40 | #include "objects/Scene.h" |
---|
[2801] | 41 | #include "GraphicsManager.h" |
---|
[1661] | 42 | |
---|
| 43 | namespace orxonox |
---|
| 44 | { |
---|
[2850] | 45 | AddGameState(GSMainMenu, "mainMenu"); |
---|
[2844] | 46 | |
---|
[2850] | 47 | GSMainMenu::GSMainMenu(const std::string& name) |
---|
[2844] | 48 | : GameState(name) |
---|
[2850] | 49 | , inputState_(0) |
---|
[1661] | 50 | { |
---|
| 51 | } |
---|
| 52 | |
---|
[2850] | 53 | GSMainMenu::~GSMainMenu() |
---|
[1661] | 54 | { |
---|
| 55 | } |
---|
| 56 | |
---|
[2850] | 57 | void GSMainMenu::activate() |
---|
[1661] | 58 | { |
---|
[2850] | 59 | inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("mainMenu"); |
---|
| 60 | inputState_->setHandler(GUIManager::getInstancePtr()); |
---|
| 61 | inputState_->setJoyStickHandler(&InputManager::EMPTY_HANDLER); |
---|
[1688] | 62 | |
---|
[2850] | 63 | // create an empty Scene |
---|
| 64 | this->scene_ = new Scene(0); |
---|
| 65 | // and a Camera |
---|
| 66 | this->camera_ = this->scene_->getSceneManager()->createCamera("mainMenu/Camera"); |
---|
| 67 | |
---|
[1661] | 68 | // show main menu |
---|
[2853] | 69 | GUIManager::getInstance().showGUI("mainmenu"); |
---|
[2850] | 70 | GUIManager::getInstance().setCamera(this->camera_); |
---|
| 71 | GraphicsManager::getInstance().setCamera(this->camera_); |
---|
[2844] | 72 | |
---|
| 73 | { |
---|
[2850] | 74 | FunctorMember<GSMainMenu>* functor = createFunctor(&GSMainMenu::startGame); |
---|
[2844] | 75 | functor->setObject(this); |
---|
| 76 | this->ccStartGame_ = createConsoleCommand(functor, "startGame"); |
---|
| 77 | CommandExecutor::addConsoleCommandShortcut(this->ccStartGame_); |
---|
| 78 | } |
---|
[2853] | 79 | |
---|
[2850] | 80 | InputManager::getInstance().requestEnterState("mainMenu"); |
---|
[1661] | 81 | } |
---|
| 82 | |
---|
[2850] | 83 | void GSMainMenu::deactivate() |
---|
[1661] | 84 | { |
---|
[2869] | 85 | InputManager::getInstance().requestLeaveState("mainMenu"); |
---|
| 86 | InputManager::getInstance().requestDestroyState("mainMenu"); |
---|
[2850] | 87 | |
---|
[2927] | 88 | GUIManager::getInstance().setCamera(0); |
---|
| 89 | GraphicsManager::getInstance().setCamera(0); |
---|
| 90 | this->scene_->getSceneManager()->destroyCamera(this->camera_); |
---|
| 91 | delete this->scene_; |
---|
| 92 | |
---|
[2928] | 93 | /* |
---|
[2844] | 94 | if (this->ccStartGame_) |
---|
| 95 | { |
---|
| 96 | delete this->ccStartGame_; |
---|
| 97 | this->ccStartGame_ = 0; |
---|
| 98 | } |
---|
[2928] | 99 | */ |
---|
[1661] | 100 | } |
---|
| 101 | |
---|
[2850] | 102 | void GSMainMenu::update(const Clock& time) |
---|
[1661] | 103 | { |
---|
[2844] | 104 | } |
---|
[1661] | 105 | |
---|
[2850] | 106 | void GSMainMenu::startGame() |
---|
[2844] | 107 | { |
---|
| 108 | // HACK - HACK |
---|
| 109 | Game::getInstance().popState(); |
---|
[2850] | 110 | Game::getInstance().requestStates("standalone, level"); |
---|
[1661] | 111 | } |
---|
| 112 | } |
---|