[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 | |
---|
[2850] | 29 | #include "GSMainMenu.h" |
---|
[1661] | 30 | |
---|
[2850] | 31 | #include <OgreSceneManager.h> |
---|
[3196] | 32 | |
---|
| 33 | #include "core/input/InputManager.h" |
---|
[3327] | 34 | #include "core/input/InputState.h" |
---|
[3196] | 35 | #include "core/Game.h" |
---|
[2800] | 36 | #include "core/Clock.h" |
---|
[2844] | 37 | #include "core/ConsoleCommand.h" |
---|
[3370] | 38 | #include "core/GraphicsManager.h" |
---|
| 39 | #include "core/GUIManager.h" |
---|
[3196] | 40 | #include "objects/Scene.h" |
---|
| 41 | #include "sound/SoundMainMenu.h" |
---|
[1661] | 42 | |
---|
| 43 | namespace orxonox |
---|
| 44 | { |
---|
[3280] | 45 | DeclareGameState(GSMainMenu, "mainMenu", false, true); |
---|
[2844] | 46 | |
---|
[3370] | 47 | GSMainMenu::GSMainMenu(const GameStateInfo& info) |
---|
| 48 | : GameState(info) |
---|
[2850] | 49 | , inputState_(0) |
---|
[1661] | 50 | { |
---|
[3327] | 51 | inputState_ = InputManager::getInstance().createInputState("mainMenu"); |
---|
[2850] | 52 | inputState_->setHandler(GUIManager::getInstancePtr()); |
---|
[3327] | 53 | inputState_->setJoyStickHandler(&InputHandler::EMPTY); |
---|
[5695] | 54 | inputState_->setIsExclusiveMouse(false); |
---|
[1688] | 55 | |
---|
[2850] | 56 | // create an empty Scene |
---|
| 57 | this->scene_ = new Scene(0); |
---|
| 58 | // and a Camera |
---|
| 59 | this->camera_ = this->scene_->getSceneManager()->createCamera("mainMenu/Camera"); |
---|
[3370] | 60 | } |
---|
[2850] | 61 | |
---|
[3370] | 62 | GSMainMenu::~GSMainMenu() |
---|
| 63 | { |
---|
| 64 | InputManager::getInstance().destroyState("mainMenu"); |
---|
| 65 | |
---|
| 66 | this->scene_->getSceneManager()->destroyCamera(this->camera_); |
---|
| 67 | delete this->scene_; |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | void GSMainMenu::activate() |
---|
| 71 | { |
---|
[1661] | 72 | // show main menu |
---|
[5695] | 73 | GUIManager::getInstance().showGUI("MainMenu"); |
---|
[2850] | 74 | GUIManager::getInstance().setCamera(this->camera_); |
---|
| 75 | GraphicsManager::getInstance().setCamera(this->camera_); |
---|
[2844] | 76 | |
---|
| 77 | { |
---|
[3094] | 78 | FunctorMember<GSMainMenu>* functor = createFunctor(&GSMainMenu::startStandalone); |
---|
[2844] | 79 | functor->setObject(this); |
---|
[3094] | 80 | this->ccStartStandalone_ = createConsoleCommand(functor, "startGame"); |
---|
| 81 | CommandExecutor::addConsoleCommandShortcut(this->ccStartStandalone_); |
---|
[2844] | 82 | } |
---|
[3094] | 83 | { |
---|
| 84 | FunctorMember<GSMainMenu>* functor = createFunctor(&GSMainMenu::startServer); |
---|
| 85 | functor->setObject(this); |
---|
| 86 | this->ccStartServer_ = createConsoleCommand(functor, "startServer"); |
---|
| 87 | CommandExecutor::addConsoleCommandShortcut(this->ccStartServer_); |
---|
| 88 | } |
---|
| 89 | { |
---|
| 90 | FunctorMember<GSMainMenu>* functor = createFunctor(&GSMainMenu::startClient); |
---|
| 91 | functor->setObject(this); |
---|
| 92 | this->ccStartClient_ = createConsoleCommand(functor, "startClient"); |
---|
| 93 | CommandExecutor::addConsoleCommandShortcut(this->ccStartClient_); |
---|
| 94 | } |
---|
| 95 | { |
---|
| 96 | FunctorMember<GSMainMenu>* functor = createFunctor(&GSMainMenu::startDedicated); |
---|
| 97 | functor->setObject(this); |
---|
| 98 | this->ccStartDedicated_ = createConsoleCommand(functor, "startDedicated"); |
---|
| 99 | CommandExecutor::addConsoleCommandShortcut(this->ccStartDedicated_); |
---|
| 100 | } |
---|
[2853] | 101 | |
---|
[3327] | 102 | InputManager::getInstance().enterState("mainMenu"); |
---|
[3060] | 103 | |
---|
| 104 | this->ambient_ = new SoundMainMenu(); |
---|
| 105 | this->ambient_->play(true); |
---|
[1661] | 106 | } |
---|
| 107 | |
---|
[2850] | 108 | void GSMainMenu::deactivate() |
---|
[1661] | 109 | { |
---|
[3060] | 110 | delete this->ambient_; |
---|
| 111 | |
---|
[3327] | 112 | InputManager::getInstance().leaveState("mainMenu"); |
---|
[2850] | 113 | |
---|
[2927] | 114 | GUIManager::getInstance().setCamera(0); |
---|
| 115 | GraphicsManager::getInstance().setCamera(0); |
---|
| 116 | |
---|
[2928] | 117 | /* |
---|
[2844] | 118 | if (this->ccStartGame_) |
---|
| 119 | { |
---|
| 120 | delete this->ccStartGame_; |
---|
| 121 | this->ccStartGame_ = 0; |
---|
| 122 | } |
---|
[2928] | 123 | */ |
---|
[1661] | 124 | } |
---|
| 125 | |
---|
[2850] | 126 | void GSMainMenu::update(const Clock& time) |
---|
[1661] | 127 | { |
---|
[2844] | 128 | } |
---|
[1661] | 129 | |
---|
[3094] | 130 | void GSMainMenu::startStandalone() |
---|
[2844] | 131 | { |
---|
| 132 | // HACK - HACK |
---|
| 133 | Game::getInstance().popState(); |
---|
[2850] | 134 | Game::getInstance().requestStates("standalone, level"); |
---|
[1661] | 135 | } |
---|
[3094] | 136 | |
---|
| 137 | void GSMainMenu::startServer() |
---|
| 138 | { |
---|
| 139 | // HACK - HACK |
---|
| 140 | Game::getInstance().popState(); |
---|
| 141 | Game::getInstance().requestStates("server, level"); |
---|
| 142 | } |
---|
| 143 | |
---|
| 144 | void GSMainMenu::startClient() |
---|
| 145 | { |
---|
| 146 | // HACK - HACK |
---|
| 147 | Game::getInstance().popState(); |
---|
| 148 | Game::getInstance().requestStates("client, level"); |
---|
| 149 | } |
---|
| 150 | |
---|
| 151 | void GSMainMenu::startDedicated() |
---|
| 152 | { |
---|
| 153 | // HACK - HACK |
---|
| 154 | Game::getInstance().popState(); |
---|
| 155 | Game::getInstance().popState(); |
---|
| 156 | Game::getInstance().requestStates("dedicated, level"); |
---|
| 157 | } |
---|
[1661] | 158 | } |
---|