Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 3092 was 3060, checked in by scheusso, 16 years ago

merged sound2 back to trunk

  • Property svn:eol-style set to native
File size: 3.4 KB
Line 
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 "GSMainMenu.h"
31
32//#include <OgreViewport.h>
33#include <OgreSceneManager.h>
34#include "core/Clock.h"
35#include "core/ConsoleCommand.h"
36#include "core/Game.h"
37#include "core/input/InputManager.h"
38#include "core/input/SimpleInputState.h"
39#include "gui/GUIManager.h"
40#include "objects/Scene.h"
41#include "GraphicsManager.h"
42#include "sound/SoundMainMenu.h"
43
44namespace orxonox
45{
46    AddGameState(GSMainMenu, "mainMenu");
47
48    GSMainMenu::GSMainMenu(const std::string& name)
49        : GameState(name)
50        , inputState_(0)
51    {
52    }
53
54    GSMainMenu::~GSMainMenu()
55    {
56    }
57
58    void GSMainMenu::activate()
59    {
60        inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("mainMenu");
61        inputState_->setHandler(GUIManager::getInstancePtr());
62        inputState_->setJoyStickHandler(&InputManager::EMPTY_HANDLER);
63
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
69        // show main menu
70        GUIManager::getInstance().showGUI("mainmenu_2");
71        GUIManager::getInstance().setCamera(this->camera_);
72        GraphicsManager::getInstance().setCamera(this->camera_);
73
74        {
75            FunctorMember<GSMainMenu>* functor = createFunctor(&GSMainMenu::startGame);
76            functor->setObject(this);
77            this->ccStartGame_ = createConsoleCommand(functor, "startGame");
78            CommandExecutor::addConsoleCommandShortcut(this->ccStartGame_);
79        }
80
81        InputManager::getInstance().requestEnterState("mainMenu");
82
83        this->ambient_ = new SoundMainMenu();
84        this->ambient_->play(true);
85    }
86
87    void GSMainMenu::deactivate()
88    {
89        delete this->ambient_;
90
91        InputManager::getInstance().requestLeaveState("mainMenu");
92        InputManager::getInstance().requestDestroyState("mainMenu");
93
94        GUIManager::getInstance().setCamera(0);
95        GraphicsManager::getInstance().setCamera(0);
96        this->scene_->getSceneManager()->destroyCamera(this->camera_);
97        delete this->scene_;
98
99/*
100        if (this->ccStartGame_)
101        {
102            delete this->ccStartGame_;
103            this->ccStartGame_ = 0;
104        }
105*/
106    }
107
108    void GSMainMenu::update(const Clock& time)
109    {
110    }
111
112    void GSMainMenu::startGame()
113    {
114        // HACK - HACK
115        Game::getInstance().popState();
116        Game::getInstance().requestStates("standalone, level");
117    }
118}
Note: See TracBrowser for help on using the repository browser.