Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 6, 2009, 1:59:00 AM (15 years ago)
Author:
landauf
Message:

Merged gui branch back to trunk.

I did 2 small changes in IngameManager.cc on line 777 and 888 (yes, really), because const_reverse_iterator strangely doesn't work on MinGW.

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/gamestates/GSLevel.cc

    r2826 r2896  
    2424 *   Co-authors:
    2525 *      Fabian 'x3n' Landau
     26 *      Benjamin Knecht
    2627 *
    2728 */
     
    3940#include "core/CommandLine.h"
    4041#include "core/ConfigValueIncludes.h"
     42#include "core/Core.h"
    4143#include "core/CoreIncludes.h"
    42 #include "core/Core.h"
     44#include "core/Game.h"
     45#include "core/GameMode.h"
    4346#include "objects/Tickable.h"
    4447#include "objects/Radar.h"
    4548#include "CameraManager.h"
     49#include "GraphicsManager.h"
    4650#include "LevelManager.h"
    4751#include "PlayerManager.h"
     52#include "gui/GUIManager.h"
    4853
    4954namespace orxonox
    5055{
     56    AddGameState(GSLevel, "level");
     57
    5158    SetCommandLineArgument(level, "presentation_dm.oxw").shortcut("l");
    52 
    53     GSLevel::GSLevel()
    54 //        : GameState<GSGraphics>(name)
    55         : keyBinder_(0)
    56         , inputState_(0)
     59    SetConsoleCommand(GSLevel, showIngameGUI, true);
     60
     61    GSLevel::GSLevel(const std::string& name)
     62        : GameState(name)
     63        , keyBinder_(0)
     64        , gameInputState_(0)
     65        , guiMouseOnlyInputState_(0)
     66        , guiKeysOnlyInputState_(0)
    5767        , radar_(0)
    5868        , startFile_(0)
     
    6474        this->ccKeybind_ = 0;
    6575        this->ccTkeybind_ = 0;
    66 
     76    }
     77
     78    GSLevel::~GSLevel()
     79    {
     80    }
     81
     82    void GSLevel::setConfigValues()
     83    {
     84        SetConfigValue(keyDetectorCallbackCode_, "KeybindBindingStringKeyName=");
     85    }
     86
     87    void GSLevel::activate()
     88    {
    6789        setConfigValues();
    68     }
    69 
    70     GSLevel::~GSLevel()
    71     {
    72     }
    73 
    74     void GSLevel::setConfigValues()
    75     {
    76         SetConfigValue(keyDetectorCallbackCode_, "KeybindBindingStringKeyName=");
    77     }
    78 
    79     void GSLevel::enter(Ogre::Viewport* viewport)
    80     {
    81         if (Core::showsGraphics())
    82         {
    83             inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("game", 20);
     90
     91        if (GameMode::showsGraphics())
     92        {
     93            gameInputState_ = InputManager::getInstance().createInputState<SimpleInputState>("game");
    8494            keyBinder_ = new KeyBinder();
    8595            keyBinder_->loadBindings("keybindings.ini");
    86             inputState_->setHandler(keyBinder_);
     96            gameInputState_->setHandler(keyBinder_);
     97
     98            guiMouseOnlyInputState_ = InputManager::getInstance().createInputState<SimpleInputState>("guiMouseOnly");
     99            guiMouseOnlyInputState_->setMouseHandler(GUIManager::getInstancePtr());
     100
     101            guiKeysOnlyInputState_ = InputManager::getInstance().createInputState<SimpleInputState>("guiKeysOnly");
     102            guiKeysOnlyInputState_->setKeyHandler(GUIManager::getInstancePtr());
    87103
    88104            // create the global CameraManager
    89             assert(viewport);
    90             this->cameraManager_ = new CameraManager(viewport);
     105            this->cameraManager_ = new CameraManager(GraphicsManager::getInstance().getViewport());
    91106
    92107            // Start the Radar
     
    96111        this->playerManager_ = new PlayerManager();
    97112
    98         if (Core::isMaster())
     113        if (GameMode::isMaster())
    99114        {
    100115            // create the global LevelManager
     
    104119        }
    105120
    106         if (Core::showsGraphics())
    107         {
    108             // TODO: insert slomo console command with
    109             // .accessLevel(AccessLevel::Offline).defaultValue(0, 1.0).axisParamIndex(0).isAxisRelative(false);
    110 
     121        if (GameMode::showsGraphics())
     122        {
    111123            // keybind console command
    112124            FunctorMember<GSLevel>* functor1 = createFunctor(&GSLevel::keybind);
     
    126138    }
    127139
    128     void GSLevel::leave()
     140    void GSLevel::showIngameGUI(bool show)
     141    {
     142        if (show)
     143        {
     144            GUIManager::getInstancePtr()->showGUI("inGameTest");
     145            GUIManager::getInstancePtr()->executeCode("showCursor()");
     146            InputManager::getInstance().requestEnterState("guiMouseOnly");
     147        }
     148        else
     149        {
     150            GUIManager::getInstancePtr()->executeCode("hideGUI(\"inGameTest\")");
     151            GUIManager::getInstancePtr()->executeCode("hideCursor()");
     152            InputManager::getInstance().requestLeaveState("guiMouseOnly");
     153        }
     154    }
     155
     156    void GSLevel::deactivate()
    129157    {
    130158        // destroy console commands
     
    139167            this->ccTkeybind_ = 0;
    140168        }
     169
    141170
    142171        // this call will delete every BaseObject!
     
    146175        //Loader::close();
    147176
    148         if (Core::showsGraphics())
     177        if (GameMode::showsGraphics())
    149178            InputManager::getInstance().requestLeaveState("game");
    150179
    151         if (Core::isMaster())
     180        if (GameMode::isMaster())
    152181            this->unloadLevel();
    153182
     
    176205        }
    177206
    178         if (Core::showsGraphics())
    179         {
    180             inputState_->setHandler(0);
     207        if (GameMode::showsGraphics())
     208        {
     209            gameInputState_->setHandler(0);
     210            guiMouseOnlyInputState_->setHandler(0);
     211            guiKeysOnlyInputState_->setHandler(0);
    181212            InputManager::getInstance().requestDestroyState("game");
    182213            if (this->keyBinder_)
     
    188219    }
    189220
    190     void GSLevel::ticked(const Clock& time)
    191     {
    192         // Commented by 1337: Temporarily moved to GSGraphics.
     221    void GSLevel::update(const Clock& time)
     222    {
     223        // Note: Temporarily moved to GSGraphics.
    193224        //// Call the scene objects
    194225        //for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it)
     
    233264        Command string that can be executed by the CommandExecutor
    234265        OR: Internal string "KeybindBindingStringKeyName=" used for the second call to identify
    235         the key/button/axis that has been activated. This is configured above in enter().
     266        the key/button/axis that has been activated. This is configured above in activate().
    236267    */
    237268    void GSLevel::keybindInternal(const std::string& command, bool bTemporary)
    238269    {
    239         if (Core::showsGraphics())
     270        if (GameMode::showsGraphics())
    240271        {
    241272            static std::string bindingString = "";
Note: See TracChangeset for help on using the changeset viewer.