Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 25, 2009, 11:53:04 PM (16 years ago)
Author:
rgrieder
Message:
  • Started working on cleaning up the GameState mess ;)
  • Cleaned out GUIManager
  • Renamed GSGUI to GSMainMenu
  • "—state blah" has been changed to —server, —client, —standalone, —dedicated
  • —console starts the game in the console (no level loading there yet, but "loadMenu")
  • adjusted run scripts
File:
1 moved

Legend:

Unmodified
Added
Removed
  • code/branches/gui/src/orxonox/gamestates/GSMainMenu.cc

    r2848 r2850  
    2828
    2929#include "OrxonoxStableHeaders.h"
    30 #include "GSGUI.h"
     30#include "GSMainMenu.h"
    3131
    32 #include <OgreViewport.h>
     32//#include <OgreViewport.h>
     33#include <OgreSceneManager.h>
    3334#include "core/Clock.h"
    3435#include "core/ConsoleCommand.h"
     
    3738#include "core/input/SimpleInputState.h"
    3839#include "gui/GUIManager.h"
     40#include "objects/Scene.h"
    3941#include "GraphicsManager.h"
    4042
    4143namespace orxonox
    4244{
    43     AddGameState(GSGUI, "mainMenu");
     45    AddGameState(GSMainMenu, "mainMenu");
    4446
    45     GSGUI::GSGUI(const std::string& name)
     47    GSMainMenu::GSMainMenu(const std::string& name)
    4648        : GameState(name)
     49        , inputState_(0)
    4750    {
    4851    }
    4952
    50     GSGUI::~GSGUI()
     53    GSMainMenu::~GSMainMenu()
    5154    {
    5255    }
    5356
    54     void GSGUI::activate()
     57    void GSMainMenu::activate()
    5558    {
    56         guiManager_ = GUIManager::getInstancePtr();
     59        inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("mainMenu");
     60        inputState_->setHandler(GUIManager::getInstancePtr());
     61        inputState_->setJoyStickHandler(&InputManager::EMPTY_HANDLER);
     62
     63        // create an empty Scene
     64        this->scene_ = new Scene(0);
     65        // and a Camera
     66        this->camera_ = this->scene_->getSceneManager()->createCamera("mainMenu/Camera");
    5767
    5868        // show main menu
    59         //guiManager_->loadScene("MainMenu");
    60         guiManager_->showGUI("MainMenu", 0);
    61         GraphicsManager::getInstance().getViewport()->setCamera(guiManager_->getCamera());
     69        GUIManager::getInstance().showGUI("mainMenu");
     70        GUIManager::getInstance().setCamera(this->camera_);
     71        GraphicsManager::getInstance().setCamera(this->camera_);
    6272
    6373        {
    64             // time factor console command
    65             FunctorMember<GSGUI>* functor = createFunctor(&GSGUI::startGame);
     74            FunctorMember<GSMainMenu>* functor = createFunctor(&GSMainMenu::startGame);
    6675            functor->setObject(this);
    6776            this->ccStartGame_ = createConsoleCommand(functor, "startGame");
    6877            CommandExecutor::addConsoleCommandShortcut(this->ccStartGame_);
    6978        }
     79       
     80        InputManager::getInstance().requestEnterState("mainMenu");
    7081    }
    7182
    72     void GSGUI::deactivate()
     83    void GSMainMenu::deactivate()
    7384    {
     85        InputManager::getInstance().requestLeaveState("game");
     86        InputManager::getInstance().requestDestroyState("game");
     87
    7488        if (this->ccStartGame_)
    7589        {
     
    7892        }
    7993
    80         guiManager_->hideGUI();
     94        GUIManager::getInstance().executeCode("hideGUI()");
    8195    }
    8296
    83     void GSGUI::update(const Clock& time)
     97    void GSMainMenu::update(const Clock& time)
    8498    {
    85         // tick CEGUI
    86         guiManager_->update(time);
    8799    }
    88100
    89     void GSGUI::startGame()
     101    void GSMainMenu::startGame()
    90102    {
    91103        // HACK - HACK
    92104        Game::getInstance().popState();
    93         Game::getInstance().requestState("standalone");
    94         Game::getInstance().requestState("level");
     105        Game::getInstance().requestStates("standalone, level");
    95106    }
    96107}
Note: See TracChangeset for help on using the changeset viewer.