| [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" |
|---|
| [3060] | 42 | #include "sound/SoundMainMenu.h" |
|---|
| [1661] | 43 | |
|---|
| 44 | namespace orxonox |
|---|
| 45 | { |
|---|
| [2850] | 46 | AddGameState(GSMainMenu, "mainMenu"); |
|---|
| [2844] | 47 | |
|---|
| [2850] | 48 | GSMainMenu::GSMainMenu(const std::string& name) |
|---|
| [2844] | 49 | : GameState(name) |
|---|
| [2850] | 50 | , inputState_(0) |
|---|
| [1661] | 51 | { |
|---|
| 52 | } |
|---|
| 53 | |
|---|
| [2850] | 54 | GSMainMenu::~GSMainMenu() |
|---|
| [1661] | 55 | { |
|---|
| 56 | } |
|---|
| 57 | |
|---|
| [2850] | 58 | void GSMainMenu::activate() |
|---|
| [1661] | 59 | { |
|---|
| [2850] | 60 | inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("mainMenu"); |
|---|
| 61 | inputState_->setHandler(GUIManager::getInstancePtr()); |
|---|
| 62 | inputState_->setJoyStickHandler(&InputManager::EMPTY_HANDLER); |
|---|
| [1688] | 63 | |
|---|
| [2850] | 64 | // create an empty Scene |
|---|
| 65 | this->scene_ = new Scene(0); |
|---|
| 66 | // and a Camera |
|---|
| 67 | this->camera_ = this->scene_->getSceneManager()->createCamera("mainMenu/Camera"); |
|---|
| 68 | |
|---|
| [1661] | 69 | // show main menu |
|---|
| [2957] | 70 | GUIManager::getInstance().showGUI("mainmenu_2"); |
|---|
| [2850] | 71 | GUIManager::getInstance().setCamera(this->camera_); |
|---|
| 72 | GraphicsManager::getInstance().setCamera(this->camera_); |
|---|
| [2844] | 73 | |
|---|
| 74 | { |
|---|
| [3094] | 75 | FunctorMember<GSMainMenu>* functor = createFunctor(&GSMainMenu::startStandalone); |
|---|
| [2844] | 76 | functor->setObject(this); |
|---|
| [3094] | 77 | this->ccStartStandalone_ = createConsoleCommand(functor, "startGame"); |
|---|
| 78 | CommandExecutor::addConsoleCommandShortcut(this->ccStartStandalone_); |
|---|
| [2844] | 79 | } |
|---|
| [3094] | 80 | { |
|---|
| 81 | FunctorMember<GSMainMenu>* functor = createFunctor(&GSMainMenu::startServer); |
|---|
| 82 | functor->setObject(this); |
|---|
| 83 | this->ccStartServer_ = createConsoleCommand(functor, "startServer"); |
|---|
| 84 | CommandExecutor::addConsoleCommandShortcut(this->ccStartServer_); |
|---|
| 85 | } |
|---|
| 86 | { |
|---|
| 87 | FunctorMember<GSMainMenu>* functor = createFunctor(&GSMainMenu::startClient); |
|---|
| 88 | functor->setObject(this); |
|---|
| 89 | this->ccStartClient_ = createConsoleCommand(functor, "startClient"); |
|---|
| 90 | CommandExecutor::addConsoleCommandShortcut(this->ccStartClient_); |
|---|
| 91 | } |
|---|
| 92 | { |
|---|
| 93 | FunctorMember<GSMainMenu>* functor = createFunctor(&GSMainMenu::startDedicated); |
|---|
| 94 | functor->setObject(this); |
|---|
| 95 | this->ccStartDedicated_ = createConsoleCommand(functor, "startDedicated"); |
|---|
| 96 | CommandExecutor::addConsoleCommandShortcut(this->ccStartDedicated_); |
|---|
| 97 | } |
|---|
| [2853] | 98 | |
|---|
| [2850] | 99 | InputManager::getInstance().requestEnterState("mainMenu"); |
|---|
| [3060] | 100 | |
|---|
| 101 | this->ambient_ = new SoundMainMenu(); |
|---|
| 102 | this->ambient_->play(true); |
|---|
| [1661] | 103 | } |
|---|
| 104 | |
|---|
| [2850] | 105 | void GSMainMenu::deactivate() |
|---|
| [1661] | 106 | { |
|---|
| [3060] | 107 | delete this->ambient_; |
|---|
| 108 | |
|---|
| [2869] | 109 | InputManager::getInstance().requestLeaveState("mainMenu"); |
|---|
| 110 | InputManager::getInstance().requestDestroyState("mainMenu"); |
|---|
| [2850] | 111 | |
|---|
| [2927] | 112 | GUIManager::getInstance().setCamera(0); |
|---|
| 113 | GraphicsManager::getInstance().setCamera(0); |
|---|
| 114 | this->scene_->getSceneManager()->destroyCamera(this->camera_); |
|---|
| 115 | delete this->scene_; |
|---|
| 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 | } |
|---|