Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/libraries/src/orxonox/gamestates/GSMainMenu.cc @ 5629

Last change on this file since 5629 was 3370, checked in by rgrieder, 15 years ago

Merged resource branch back to the trunk. Changes:

  • Automated graphics loading by evaluating whether a GameState requires it
  • Using native Tcl library (x3n)

Windows users: Update your dependency package!

  • Property svn:eol-style set to native
File size: 4.8 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 "GSMainMenu.h"
30
31#include <OgreSceneManager.h>
32
33#include "core/input/InputManager.h"
34#include "core/input/InputState.h"
35#include "core/Game.h"
36#include "core/Clock.h"
37#include "core/ConsoleCommand.h"
38#include "core/GraphicsManager.h"
39#include "core/GUIManager.h"
40#include "objects/Scene.h"
41#include "sound/SoundMainMenu.h"
42
43namespace orxonox
44{
45    DeclareGameState(GSMainMenu, "mainMenu", false, true);
46
47    GSMainMenu::GSMainMenu(const GameStateInfo& info)
48        : GameState(info)
49        , inputState_(0)
50    {
51        inputState_ = InputManager::getInstance().createInputState("mainMenu");
52        inputState_->setHandler(GUIManager::getInstancePtr());
53        inputState_->setJoyStickHandler(&InputHandler::EMPTY);
54
55        // create an empty Scene
56        this->scene_ = new Scene(0);
57        // and a Camera
58        this->camera_ = this->scene_->getSceneManager()->createCamera("mainMenu/Camera");
59    }
60
61    GSMainMenu::~GSMainMenu()
62    {
63        InputManager::getInstance().destroyState("mainMenu");
64
65        this->scene_->getSceneManager()->destroyCamera(this->camera_);
66        delete this->scene_;
67    }
68
69    void GSMainMenu::activate()
70    {
71        // show main menu
72        GUIManager::getInstance().showGUI("mainmenu_4");
73        GUIManager::getInstance().setCamera(this->camera_);
74        GraphicsManager::getInstance().setCamera(this->camera_);
75
76        {
77            FunctorMember<GSMainMenu>* functor = createFunctor(&GSMainMenu::startStandalone);
78            functor->setObject(this);
79            this->ccStartStandalone_ = createConsoleCommand(functor, "startGame");
80            CommandExecutor::addConsoleCommandShortcut(this->ccStartStandalone_);
81        }
82        {
83            FunctorMember<GSMainMenu>* functor = createFunctor(&GSMainMenu::startServer);
84            functor->setObject(this);
85            this->ccStartServer_ = createConsoleCommand(functor, "startServer");
86            CommandExecutor::addConsoleCommandShortcut(this->ccStartServer_);
87        }
88        {
89            FunctorMember<GSMainMenu>* functor = createFunctor(&GSMainMenu::startClient);
90            functor->setObject(this);
91            this->ccStartClient_ = createConsoleCommand(functor, "startClient");
92            CommandExecutor::addConsoleCommandShortcut(this->ccStartClient_);
93        }
94        {
95            FunctorMember<GSMainMenu>* functor = createFunctor(&GSMainMenu::startDedicated);
96            functor->setObject(this);
97            this->ccStartDedicated_ = createConsoleCommand(functor, "startDedicated");
98            CommandExecutor::addConsoleCommandShortcut(this->ccStartDedicated_);
99        }
100
101        InputManager::getInstance().enterState("mainMenu");
102
103        this->ambient_ = new SoundMainMenu();
104        this->ambient_->play(true);
105    }
106
107    void GSMainMenu::deactivate()
108    {
109        delete this->ambient_;
110
111        InputManager::getInstance().leaveState("mainMenu");
112
113        GUIManager::getInstance().setCamera(0);
114        GraphicsManager::getInstance().setCamera(0);
115
116/*
117        if (this->ccStartGame_)
118        {
119            delete this->ccStartGame_;
120            this->ccStartGame_ = 0;
121        }
122*/
123    }
124
125    void GSMainMenu::update(const Clock& time)
126    {
127    }
128
129    void GSMainMenu::startStandalone()
130    {
131        // HACK - HACK
132        Game::getInstance().popState();
133        Game::getInstance().requestStates("standalone, level");
134    }
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    }
157}
Note: See TracBrowser for help on using the repository browser.