Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/gamestates/GSMainMenu.cc @ 3341

Last change on this file since 3341 was 3327, checked in by rgrieder, 15 years ago

Merged all remaining revisions from core4 back to the trunk.

  • Property svn:eol-style set to native
File size: 4.8 KB
RevLine 
[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"
[3196]38#include "objects/Scene.h"
[1661]39#include "gui/GUIManager.h"
[3196]40#include "sound/SoundMainMenu.h"
[2801]41#include "GraphicsManager.h"
[1661]42
43namespace orxonox
44{
[3280]45    DeclareGameState(GSMainMenu, "mainMenu", false, true);
[2844]46
[3280]47    GSMainMenu::GSMainMenu(const GameStateConstrParams& params)
48        : GameState(params)
[2850]49        , inputState_(0)
[1661]50    {
51    }
52
[2850]53    GSMainMenu::~GSMainMenu()
[1661]54    {
55    }
56
[2850]57    void GSMainMenu::activate()
[1661]58    {
[3327]59        inputState_ = InputManager::getInstance().createInputState("mainMenu");
[2850]60        inputState_->setHandler(GUIManager::getInstancePtr());
[3327]61        inputState_->setJoyStickHandler(&InputHandler::EMPTY);
[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
[3280]69        GUIManager::getInstance().showGUI("mainmenu_3");
[2850]70        GUIManager::getInstance().setCamera(this->camera_);
71        GraphicsManager::getInstance().setCamera(this->camera_);
[2844]72
73        {
[3094]74            FunctorMember<GSMainMenu>* functor = createFunctor(&GSMainMenu::startStandalone);
[2844]75            functor->setObject(this);
[3094]76            this->ccStartStandalone_ = createConsoleCommand(functor, "startGame");
77            CommandExecutor::addConsoleCommandShortcut(this->ccStartStandalone_);
[2844]78        }
[3094]79        {
80            FunctorMember<GSMainMenu>* functor = createFunctor(&GSMainMenu::startServer);
81            functor->setObject(this);
82            this->ccStartServer_ = createConsoleCommand(functor, "startServer");
83            CommandExecutor::addConsoleCommandShortcut(this->ccStartServer_);
84        }
85        {
86            FunctorMember<GSMainMenu>* functor = createFunctor(&GSMainMenu::startClient);
87            functor->setObject(this);
88            this->ccStartClient_ = createConsoleCommand(functor, "startClient");
89            CommandExecutor::addConsoleCommandShortcut(this->ccStartClient_);
90        }
91        {
92            FunctorMember<GSMainMenu>* functor = createFunctor(&GSMainMenu::startDedicated);
93            functor->setObject(this);
94            this->ccStartDedicated_ = createConsoleCommand(functor, "startDedicated");
95            CommandExecutor::addConsoleCommandShortcut(this->ccStartDedicated_);
96        }
[2853]97
[3327]98        InputManager::getInstance().enterState("mainMenu");
[3060]99
100        this->ambient_ = new SoundMainMenu();
101        this->ambient_->play(true);
[1661]102    }
103
[2850]104    void GSMainMenu::deactivate()
[1661]105    {
[3060]106        delete this->ambient_;
107
[3327]108        InputManager::getInstance().leaveState("mainMenu");
109        InputManager::getInstance().destroyState("mainMenu");
[2850]110
[2927]111        GUIManager::getInstance().setCamera(0);
112        GraphicsManager::getInstance().setCamera(0);
113        this->scene_->getSceneManager()->destroyCamera(this->camera_);
114        delete this->scene_;
115
[2928]116/*
[2844]117        if (this->ccStartGame_)
118        {
119            delete this->ccStartGame_;
120            this->ccStartGame_ = 0;
121        }
[2928]122*/
[1661]123    }
124
[2850]125    void GSMainMenu::update(const Clock& time)
[1661]126    {
[2844]127    }
[1661]128
[3094]129    void GSMainMenu::startStandalone()
[2844]130    {
131        // HACK - HACK
132        Game::getInstance().popState();
[2850]133        Game::getInstance().requestStates("standalone, level");
[1661]134    }
[3094]135
136    void GSMainMenu::startServer()
137    {
138        // HACK - HACK
139        Game::getInstance().popState();
140        Game::getInstance().requestStates("server, level");
141    }
142
143    void GSMainMenu::startClient()
144    {
145        // HACK - HACK
146        Game::getInstance().popState();
147        Game::getInstance().requestStates("client, level");
148    }
149
150    void GSMainMenu::startDedicated()
151    {
152        // HACK - HACK
153        Game::getInstance().popState();
154        Game::getInstance().popState();
155        Game::getInstance().requestStates("dedicated, level");
156    }
[1661]157}
Note: See TracBrowser for help on using the repository browser.