Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 1, 2008, 7:04:09 PM (16 years ago)
Author:
landauf
Message:

merged objecthierarchy branch back to trunk

Location:
code/trunk
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

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

    r1907 r2087  
    3232#include "core/input/InputManager.h"
    3333#include "core/CommandLine.h"
     34#include "core/Core.h"
    3435#include "network/Client.h"
    35 #include "Settings.h"
    3636
    3737namespace orxonox
    3838{
    39     SetCommandLineArgument(ip, "127.0.0.1").setInformation("#.#.#.#");
     39    SetCommandLineArgument(ip, "127.0.0.1").information("#.#.#.#");
    4040
    4141    GSClient::GSClient()
    42         : GSLevel("client")
     42        : GameState<GSGraphics>("client")
    4343        , client_(0)
    4444    {
     
    5151    void GSClient::enter()
    5252    {
    53         Settings::_getInstance().bIsClient_ = true;
     53        Core::setIsClient(true);
    5454
    55         GSLevel::enter();
    56 
    57         int serverPort = CommandLine::getArgument<int>("port")->getValue();
    58         std::string serverIP = CommandLine::getArgument<std::string>("ip")->getValue();
    59         this->client_ = new network::Client(serverIP, serverPort);
     55        this->client_ = new network::Client(CommandLine::getValue("ip").getString(), CommandLine::getValue("port"));
    6056
    6157        if(!client_->establishConnection())
    6258            ThrowException(InitialisationFailed, "Could not establish connection with server.");
    6359
     60        GSLevel::enter(this->getParent()->getViewport());
     61
    6462        client_->tick(0);
    65 
    66         // level is loaded: we can start capturing the input
    67         InputManager::getInstance().requestEnterState("game");
    6863    }
    6964
    7065    void GSClient::leave()
    7166    {
    72         InputManager::getInstance().requestLeaveState("game");
    73 
    74         // TODO: How do we unload the level in client mode?
     67        GSLevel::leave();
    7568
    7669        client_->closeConnection();
     
    7972        delete this->client_;
    8073
    81         GSLevel::leave();
    82 
    83         Settings::_getInstance().bIsClient_ = false;
     74        Core::setIsClient(false);
    8475    }
    8576
  • code/trunk/src/orxonox/gamestates/GSClient.h

    r1755 r2087  
    3333#include "network/NetworkPrereqs.h"
    3434#include "GSLevel.h"
     35#include "GSGraphics.h"
    3536
    3637namespace orxonox
    3738{
    38     class _OrxonoxExport GSClient : public GSLevel
     39    class _OrxonoxExport GSClient : public GameState<GSGraphics>, public GSLevel
    3940    {
    4041    public:
  • code/trunk/src/orxonox/gamestates/GSDedicated.cc

    r1790 r2087  
    3030#include "GSDedicated.h"
    3131
    32 #include <OgreRoot.h>
    33 #include <OgreSceneManager.h>
    34 #include "core/ConsoleCommand.h"
    3532#include "core/CommandLine.h"
    36 #include "core/Loader.h"
     33#include "core/Core.h"
    3734#include "network/Server.h"
    38 #include "objects/Tickable.h"
    39 #include "GraphicsEngine.h"
    40 #include "Settings.h"
    4135
    4236namespace orxonox
     
    4438    GSDedicated::GSDedicated()
    4539        : GameState<GSRoot>("dedicated")
    46         , timeFactor_(0)
    4740        , server_(0)
    48         , sceneManager_(0)
    49         , startLevel_(0)
    5041    {
    5142    }
     
    5748    void GSDedicated::enter()
    5849    {
    59         Settings::_getInstance().bHasServer_ = true;
     50        Core::setHasServer(true);
    6051
    61         // create Ogre SceneManager for the level
    62         this->sceneManager_ = Ogre::Root::getSingleton().createSceneManager(Ogre::ST_GENERIC, "LevelSceneManager");
    63         COUT(4) << "Created SceneManager: " << sceneManager_->getName() << std::endl;
     52        this->server_ = new network::Server(CommandLine::getValue("port"));
     53        COUT(0) << "Loading scene in server mode" << std::endl;
    6454
    65         // temporary hack
    66         GraphicsEngine::getInstance().setLevelSceneManager(this->sceneManager_);
    67 
    68         // reset game speed to normal
    69         timeFactor_ = 1.0f;
    70 
    71         int serverPort = CommandLine::getArgument<int>("port")->getValue();
    72         this->server_ = new network::Server(serverPort);
    73 
    74         // call the loader
    75         COUT(0) << "Loading level..." << std::endl;
    76         startLevel_ = new Level(Settings::getDataPath() + "levels/sample.oxw");
    77         Loader::open(startLevel_);
     55        GSLevel::enter(0);
    7856
    7957        server_->open();
    80 
    81         // add console commands
    82         FunctorMember01<GSDedicated, float>* functor = createFunctor(&GSDedicated::setTimeFactor);
    83         functor->setObject(this);
    84         CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "setTimeFactor")).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);;
    8558    }
    8659
    8760    void GSDedicated::leave()
    8861    {
    89         // TODO: Remove and destroy console command
    90 
    91         Loader::unload(startLevel_);
    92         delete this->startLevel_;
     62        GSLevel::leave();
    9363
    9464        this->server_->close();
    9565        delete this->server_;
    9666
    97         Ogre::Root::getSingleton().destroySceneManager(this->sceneManager_);
    98 
    99         Settings::_getInstance().bHasServer_ = false;
     67        Core::setHasServer(false);
    10068    }
    10169
    10270    void GSDedicated::ticked(const Clock& time)
    10371    {
    104         // Call the scene objects
    105         for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it)
    106             it->tick(time.getDeltaTime() * this->timeFactor_);
    107 
     72        GSLevel::ticked(time);
    10873        server_->tick(time.getDeltaTime());
    10974        this->tickChild(time);
    11075    }
    111 
    112     /**
    113     @brief
    114         Changes the speed of Orxonox
    115     */
    116     void GSDedicated::setTimeFactor(float factor)
    117     {
    118         this->timeFactor_ = factor;
    119     }
    12076}
  • code/trunk/src/orxonox/gamestates/GSDedicated.h

    r1755 r2087  
    3232#include "OrxonoxPrereqs.h"
    3333#include "network/NetworkPrereqs.h"
     34#include "GSLevel.h"
    3435#include "GSRoot.h"
    3536
    3637namespace orxonox
    3738{
    38     class _OrxonoxExport GSDedicated : public GameState<GSRoot>
     39    class _OrxonoxExport GSDedicated : public GameState<GSRoot>, public GSLevel
    3940    {
    4041    public:
    4142        GSDedicated();
    4243        ~GSDedicated();
    43 
    44         void setTimeFactor(float factor);
    45         float getTimeFactor() { return this->timeFactor_; }
    4644
    4745    private:
     
    5048        void ticked(const Clock& time);
    5149
    52         void loadLevel();
    53         void unloadLevel();
    54 
    55         float                 timeFactor_;       //!< A factor to change the gamespeed
    5650        network::Server*      server_;
    57         Ogre::SceneManager*   sceneManager_;
    58         Level*                startLevel_;       //!< current hard coded default level
    5951    };
    6052}
  • code/trunk/src/orxonox/gamestates/GSGUI.cc

    r1755 r2087  
    3131
    3232#include <OgreViewport.h>
    33 #include "GraphicsEngine.h"
    3433#include "core/input/InputManager.h"
    3534#include "core/input/SimpleInputState.h"
  • code/trunk/src/orxonox/gamestates/GSGraphics.cc

    r1891 r2087  
    4747#include "core/ConfigValueIncludes.h"
    4848#include "core/CoreIncludes.h"
     49#include "core/Core.h"
    4950#include "core/input/InputManager.h"
    5051#include "core/input/KeyBinder.h"
    5152#include "core/input/ExtendedInputState.h"
     53#include "core/Loader.h"
     54#include "core/XMLFile.h"
    5255#include "overlays/console/InGameConsole.h"
    5356#include "gui/GUIManager.h"
    5457#include "tools/WindowEventListener.h"
     58#include "objects/Tickable.h"
    5559#include "Settings.h"
    5660
     
    6468        , renderWindow_(0)
    6569        , viewport_(0)
     70        , bWindowEventListenerUpdateRequired_(false)
    6671        , inputManager_(0)
    6772        , console_(0)
     
    7681        , statisticsStartCount_(0)
    7782        , tickTime_(0)
     83        , debugOverlay_(0)
    7884    {
    7985        RegisterRootObject(GSGraphics);
     
    101107    void GSGraphics::enter()
    102108    {
    103         Settings::_getInstance().bShowsGraphics_ = true;
     109        Core::setShowsGraphics(true);
    104110
    105111        // initialise graphics engine. Doesn't load the render window yet!
     
    113119        this->initialiseResources();
    114120
    115 
    116         // HACK: temporary:
    117         graphicsEngine_->renderWindow_  = this->renderWindow_;
    118         graphicsEngine_->root_          = this->ogreRoot_;
    119         graphicsEngine_->viewport_      = this->viewport_;
    120 
     121        // We want to get informed whenever an object of type WindowEventListener is created
     122        // in order to later update the window size.
     123        bWindowEventListenerUpdateRequired_ = false;
     124        RegisterConstructionCallback(GSGraphics, orxonox::WindowEventListener, requestWindowEventListenerUpdate);
     125
     126        // load debug overlay
     127        COUT(3) << "Loading Debug Overlay..." << std::endl;
     128        this->debugOverlay_ = new XMLFile(Settings::getDataPath() + "overlay/debug.oxo");
     129        Loader::open(debugOverlay_);
    121130
    122131        // Calls the InputManager which sets up the input devices.
     
    133142        // Load the InGameConsole
    134143        console_ = new InGameConsole();
    135         console_->initialise();
     144        console_->initialise(this->renderWindow_->getWidth(), this->renderWindow_->getHeight());
    136145
    137146        // load the CEGUI interface
     
    165174        //delete this->masterKeyBinder_;
    166175        delete this->inputManager_;
     176
     177        Loader::unload(this->debugOverlay_);
     178        delete this->debugOverlay_;
    167179
    168180        // destroy render window
     
    196208        delete graphicsEngine_;
    197209
    198         Settings::_getInstance().bShowsGraphics_ = false;
     210        Core::setShowsGraphics(false);
    199211    }
    200212
     
    221233        this->console_->tick(dt);
    222234        this->tickChild(time);
    223        
     235
     236        /*** HACK *** HACK ***/
     237        // Call the Tickable objects
     238        for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it)
     239            it->tick(time.getDeltaTime());
     240        /*** HACK *** HACK ***/
     241
     242        if (this->bWindowEventListenerUpdateRequired_)
     243        {
     244            // Update all WindowEventListeners for the case a new one was created.
     245            this->windowResized(this->renderWindow_);
     246            this->bWindowEventListenerUpdateRequired_ = false;
     247        }
     248
    224249        unsigned long long timeAfterTick = time.getRealMicroseconds();
    225250
     
    487512        for (ObjectList<orxonox::WindowEventListener>::iterator it = ObjectList<orxonox::WindowEventListener>::begin(); it; ++it)
    488513            it->windowResized(this->renderWindow_->getWidth(), this->renderWindow_->getHeight());
     514
     515        // OIS needs this under linux even if we only use relative input measurement.
     516        if (this->inputManager_)
     517            this->inputManager_->setWindowExtents(renderWindow_->getWidth(), renderWindow_->getHeight());
    489518    }
    490519
     
    501530
    502531        // instruct InputManager to clear the buffers (core library so we cannot use the interface)
    503         InputManager::getInstance().clearBuffers();
     532        if (this->inputManager_)
     533            this->inputManager_->clearBuffers();
    504534    }
    505535
     
    512542    void GSGraphics::windowClosed(Ogre::RenderWindow *rw)
    513543    {
    514         // using CommandExecutor in order to avoid depending on Orxonox.h.
    515         //CommandExecutor::execute("exit", false);
    516544        this->requestState("root");
    517545    }
  • code/trunk/src/orxonox/gamestates/GSGraphics.h

    r1891 r2087  
    7777        void windowClosed      (Ogre::RenderWindow* rw);
    7878
     79        void requestWindowEventListenerUpdate() { this->bWindowEventListenerUpdateRequired_ = true; }
     80
    7981    private: // variables
    8082        Ogre::RenderWindow*   renderWindow_;          //!< the current render window
    8183        Ogre::Viewport*       viewport_;              //!< default full size viewport
     84        bool bWindowEventListenerUpdateRequired_;     //!< True if a new WindowEventListener was created but not yet updated.
    8285
    8386        // managed singletons
     
    97100        unsigned long         statisticsStartCount_;
    98101        unsigned int          tickTime_;
     102        XMLFile*              debugOverlay_;
    99103
    100104        // config values
  • code/trunk/src/orxonox/gamestates/GSIOConsole.cc

    r1755 r2087  
    3636
    3737#include "core/ConsoleCommand.h"
    38 #include "core/TclThreadManager.h"
    39 #include "GraphicsEngine.h"
    4038
    4139namespace orxonox
  • code/trunk/src/orxonox/gamestates/GSLevel.cc

    r1934 r2087  
    3030#include "GSLevel.h"
    3131
    32 #include <OgreSceneManager.h>
    33 #include <OgreRoot.h>
    3432#include "core/input/InputManager.h"
    3533#include "core/input/SimpleInputState.h"
    3634#include "core/input/KeyBinder.h"
    3735#include "core/Loader.h"
     36#include "core/XMLFile.h"
    3837#include "core/CommandExecutor.h"
    3938#include "core/ConsoleCommand.h"
     
    4140#include "core/ConfigValueIncludes.h"
    4241#include "core/CoreIncludes.h"
    43 #include "objects/Backlight.h"
     42#include "core/Core.h"
     43//#include "objects/Backlight.h"
    4444#include "objects/Tickable.h"
    4545#include "objects/Radar.h"
    46 #include "tools/ParticleInterface.h"
     46//#include "tools/ParticleInterface.h"
     47#include "CameraManager.h"
     48#include "LevelManager.h"
    4749#include "Settings.h"
    48 #include "GraphicsEngine.h"
    4950
    5051namespace orxonox
    5152{
    52     SetCommandLineArgument(level, "sample.oxw").setShortcut("l");
    53 
    54     GSLevel::GSLevel(const std::string& name)
    55         : GameState<GSGraphics>(name)
    56         , timeFactor_(1.0f)
    57         , sceneManager_(0)
     53    SetCommandLineArgument(level, "sample2.oxw").shortcut("l");
     54
     55    GSLevel::GSLevel()
     56//        : GameState<GSGraphics>(name)
     57        : timeFactor_(1.0f)
    5858        , keyBinder_(0)
    5959        , inputState_(0)
    6060        , radar_(0)
    61         , startLevel_(0)
    62         , hud_(0)
     61        , startFile_(0)
     62        , cameraManager_(0)
     63        , levelManager_(0)
    6364    {
    6465        RegisterObject(GSLevel);
     
    7576    }
    7677
    77     void GSLevel::enter()
    78     {
    79         inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("game", 20);
    80         keyBinder_ = new KeyBinder();
    81         keyBinder_->loadBindings("keybindings.ini");
    82         inputState_->setHandler(keyBinder_);
    83 
    84         // create Ogre SceneManager for the level
    85         this->sceneManager_ = Ogre::Root::getSingleton().createSceneManager(Ogre::ST_GENERIC, "LevelSceneManager");
    86         COUT(4) << "Created SceneManager: " << sceneManager_->getName() << std::endl;
    87 
    88         // temporary hack
    89         GraphicsEngine::getInstance().setLevelSceneManager(this->sceneManager_);
    90 
    91         // Start the Radar
    92         this->radar_ = new Radar();
    93 
    94         // Load the HUD
    95         COUT(3) << "Orxonox: Loading HUD" << std::endl;
    96         hud_ = new Level(Settings::getDataPath() + "overlay/hud.oxo");
    97         Loader::load(hud_);
    98 
    99         // reset game speed to normal
    100         timeFactor_ = 1.0f;
    101 
    102         // TODO: insert slomo console command with
    103         // .accessLevel(AccessLevel::Offline).defaultValue(0, 1.0).axisParamIndex(0).isAxisRelative(false);
    104 
    105         // keybind console command
    106         FunctorMember<GSLevel>* functor1 = createFunctor(&GSLevel::keybind);
    107         functor1->setObject(this);
    108         CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor1, "keybind"));
    109         FunctorMember<GSLevel>* functor2 = createFunctor(&GSLevel::tkeybind);
    110         functor2->setObject(this);
    111         CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor2, "tkeybind"));
    112         // set our console command as callback for the key detector
    113         InputManager::getInstance().setKeyDetectorCallback(std::string("keybind ") + keyDetectorCallbackCode_);
     78    void GSLevel::enter(Ogre::Viewport* viewport)
     79    {
     80        if (Core::showsGraphics())
     81        {
     82            inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("game", 20);
     83            keyBinder_ = new KeyBinder();
     84            keyBinder_->loadBindings("keybindings.ini");
     85            inputState_->setHandler(keyBinder_);
     86
     87            // create the global CameraManager
     88            assert(viewport);
     89            this->cameraManager_ = new CameraManager(viewport);
     90
     91            // Start the Radar
     92            this->radar_ = new Radar();
     93        }
     94
     95        if (Core::isMaster())
     96        {
     97            // create the global LevelManager
     98            this->levelManager_ = new LevelManager();
     99
     100            // reset game speed to normal
     101            timeFactor_ = 1.0f;
     102
     103            this->loadLevel();
     104        }
     105
     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
     111            // keybind console command
     112            FunctorMember<GSLevel>* functor1 = createFunctor(&GSLevel::keybind);
     113            functor1->setObject(this);
     114            CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor1, "keybind"));
     115            FunctorMember<GSLevel>* functor2 = createFunctor(&GSLevel::tkeybind);
     116            functor2->setObject(this);
     117            CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor2, "tkeybind"));
     118            // set our console command as callback for the key detector
     119            InputManager::getInstance().setKeyDetectorCallback(std::string("keybind ") + keyDetectorCallbackCode_);
     120
     121            // level is loaded: we can start capturing the input
     122            InputManager::getInstance().requestEnterState("game");
     123        }
     124
     125        if (Core::isMaster())
     126        {
     127            // time factor console command
     128            FunctorMember<GSLevel>* functor = createFunctor(&GSLevel::setTimeFactor);
     129            functor->setObject(this);
     130            CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "setTimeFactor")).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);;
     131        }
    114132    }
    115133
    116134    void GSLevel::leave()
    117135    {
    118         Loader::unload(hud_);
    119         delete this->hud_;
    120 
    121136        // this call will delete every BaseObject!
    122137        // But currently this will call methods of objects that exist no more
     
    125140        //Loader::close();
    126141
    127         delete this->radar_;
    128 
    129         Ogre::Root::getSingleton().destroySceneManager(this->sceneManager_);
    130 
    131         inputState_->setHandler(0);
    132         InputManager::getInstance().requestDestroyState("game");
    133         delete this->keyBinder_;
     142        if (Core::showsGraphics())
     143            InputManager::getInstance().requestLeaveState("game");
     144
     145        if (Core::isMaster())
     146            this->unloadLevel();
     147
     148        if (this->radar_)
     149            delete this->radar_;
     150
     151        if (this->cameraManager_)
     152            delete this->cameraManager_;
     153
     154        if (this->levelManager_)
     155            delete this->levelManager_;
     156
     157        if (Core::showsGraphics())
     158        {
     159            inputState_->setHandler(0);
     160            InputManager::getInstance().requestDestroyState("game");
     161            if (this->keyBinder_)
     162                delete this->keyBinder_;
     163        }
    134164    }
    135165
    136166    void GSLevel::ticked(const Clock& time)
    137167    {
    138         // Call the scene objects
    139         for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it)
    140             it->tick(time.getDeltaTime() * this->timeFactor_);
     168        // Commented by 1337: Temporarily moved to GSGraphics.
     169        //// Call the scene objects
     170        //for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it)
     171        //    it->tick(time.getDeltaTime() * this->timeFactor_);
    141172    }
    142173
     
    147178    void GSLevel::setTimeFactor(float factor)
    148179    {
     180/*
    149181        float change = factor / this->timeFactor_;
     182*/
    150183        this->timeFactor_ = factor;
     184/*
    151185        for (ObjectList<ParticleInterface>::iterator it = ObjectList<ParticleInterface>::begin(); it; ++it)
    152186            it->setSpeedFactor(it->getSpeedFactor() * change);
     
    154188        for (ObjectList<Backlight>::iterator it = ObjectList<Backlight>::begin(); it; ++it)
    155189            it->setTimeFactor(timeFactor_);
     190*/
    156191    }
    157192
     
    162197        std::string levelName;
    163198        CommandLine::getValue("level", &levelName);
    164         startLevel_ = new Level(Settings::getDataPath() + std::string("levels/") + levelName);
    165         Loader::open(startLevel_);
     199        startFile_ = new XMLFile(Settings::getDataPath() + std::string("levels/") + levelName);
     200        Loader::open(startFile_);
    166201    }
    167202
    168203    void GSLevel::unloadLevel()
    169204    {
    170         Loader::unload(startLevel_);
    171         delete this->startLevel_;
     205        //////////////////////////////////////////////////////////////////////////////////////////
     206        // TODO // TODO // TODO // TODO // TODO // TODO // TODO // TODO // TODO // TODO // TODO //
     207        //////////////////////////////////////////////////////////////////////////////////////////
     208        // Loader::unload(startFile_); // TODO: REACTIVATE THIS IF LOADER::UNLOAD WORKS PROPERLY /
     209        //////////////////////////////////////////////////////////////////////////////////////////
     210
     211        delete this->startFile_;
    172212    }
    173213
     
    192232    void GSLevel::keybindInternal(const std::string& command, bool bTemporary)
    193233    {
    194         static std::string bindingString = "";
    195         static bool bTemporarySaved = false;
    196         static bool bound = true;
    197         // note: We use a long name to make 'sure' that the user doesn't use it accidentally.
    198         // Howerver there will be no real issue if it happens anyway.
    199         if (command.find(keyDetectorCallbackCode_) != 0)
    200         {
    201             if (bound)
     234        if (Core::showsGraphics())
     235        {
     236            static std::string bindingString = "";
     237            static bool bTemporarySaved = false;
     238            static bool bound = true;
     239            // note: We use a long name to make 'sure' that the user doesn't use it accidentally.
     240            // Howerver there will be no real issue if it happens anyway.
     241            if (command.find(keyDetectorCallbackCode_) != 0)
    202242            {
    203                 COUT(0) << "Press any button/key or move a mouse/joystick axis" << std::endl;
    204                 InputManager::getInstance().requestEnterState("detector");
    205                 bindingString = command;
    206                 bTemporarySaved = bTemporary;
    207                 bound = false;
     243                if (bound)
     244                {
     245                    COUT(0) << "Press any button/key or move a mouse/joystick axis" << std::endl;
     246                    InputManager::getInstance().requestEnterState("detector");
     247                    bindingString = command;
     248                    bTemporarySaved = bTemporary;
     249                    bound = false;
     250                }
     251                //else:  We're still in a keybind command. ignore this call.
    208252            }
    209             //else:  We're still in a keybind command. ignore this call.
    210         }
    211         else
    212         {
    213             if (!bound)
     253            else
    214254            {
    215                 // user has pressed the key
    216                 std::string name = command.substr(this->keyDetectorCallbackCode_.size());
    217                 COUT(0) << "Binding string \"" << bindingString << "\" on key '" << name << "'" << std::endl;
    218                 this->keyBinder_->setBinding(bindingString, name, bTemporarySaved);
    219                 InputManager::getInstance().requestLeaveState("detector");
    220                 bound = true;
     255                if (!bound)
     256                {
     257                    // user has pressed the key
     258                    std::string name = command.substr(this->keyDetectorCallbackCode_.size());
     259                    COUT(0) << "Binding string \"" << bindingString << "\" on key '" << name << "'" << std::endl;
     260                    this->keyBinder_->setBinding(bindingString, name, bTemporarySaved);
     261                    InputManager::getInstance().requestLeaveState("detector");
     262                    bound = true;
     263                }
     264                // else: A key was pressed within the same tick, ignore it.
    221265            }
    222             // else: A key was pressed within the same tick, ignore it.
    223266        }
    224267    }
  • code/trunk/src/orxonox/gamestates/GSLevel.h

    r1887 r2087  
    3737namespace orxonox
    3838{
    39     class _OrxonoxExport GSLevel : public GameState<GSGraphics>, public OrxonoxClass
     39    class _OrxonoxExport GSLevel : public OrxonoxClass //,public GameState<GSGraphics>
    4040    {
    4141        friend class ClassIdentifier<GSLevel>;
    4242    public:
    43         GSLevel(const std::string& name);
    44         virtual ~GSLevel();
     43        GSLevel();
     44        ~GSLevel();
    4545
    4646        // this has to be public because proteced triggers a bug in msvc
     
    5050
    5151    protected:
    52         virtual void enter();
    53         virtual void leave();
    54         virtual void ticked(const Clock& time);
     52        void enter(Ogre::Viewport* viewport);
     53        void leave();
     54        void ticked(const Clock& time);
    5555
    5656        void loadLevel();
    5757        void unloadLevel();
    5858
    59         float timeFactor_;       //!< A factor to change the gamespeed
     59        float timeFactor_;       //!< A factor that sets the gamespeed. 1 is normal.
    6060
    6161        // console commands
     
    6464        void keybindInternal(const std::string& command, bool bTemporary);
    6565
    66         Ogre::SceneManager*   sceneManager_;
    6766        KeyBinder*            keyBinder_;        //!< tool that loads and manages the input bindings
    6867        SimpleInputState*     inputState_;
    6968        Radar*                radar_;            //!< represents the Radar (not the HUD part)
    70         Level*                startLevel_;       //!< current hard coded default level
    71         Level*                hud_;              //!< 'level' object fo the HUD
     69        XMLFile*              startFile_;        //!< current hard coded default level
     70        CameraManager*        cameraManager_;
     71        LevelManager*         levelManager_;
    7272
    7373        // config values
    7474        std::string           keyDetectorCallbackCode_;
    75        
     75
    7676    private:
    7777        void setConfigValues();
  • code/trunk/src/orxonox/gamestates/GSRoot.cc

    r1891 r2087  
    4141#include "core/TclThreadManager.h"
    4242#include "tools/Timer.h"
    43 #include "GraphicsEngine.h"
    4443#include "Settings.h"
    4544
     
    6160namespace orxonox
    6261{
    63     SetCommandLineArgument(dataPath, "").setInformation("PATH");
    64     SetCommandLineArgument(limitToCPU, 1).setInformation("0: off | #cpu");
     62    SetCommandLineArgument(dataPath, "").information("PATH");
     63    SetCommandLineArgument(limitToCPU, 1).information("0: off | #cpu");
    6564
    6665    GSRoot::GSRoot()
     
    9190        this->settings_ = new Settings();
    9291
    93         std::string dataPath;
    94         CommandLine::getValue("dataPath", &dataPath);
     92        std::string dataPath = CommandLine::getValue("dataPath");
    9593        if (dataPath != "")
    9694        {
     
    111109        // do this after ogre has initialised. Somehow Ogre changes the settings again (not through
    112110        // the timer though).
    113         int limitToCPU;
    114         CommandLine::getValue("limitToCPU", &limitToCPU);
     111        int limitToCPU = CommandLine::getValue("limitToCPU");
    115112        if (limitToCPU > 0)
    116113            setThreadAffinity((unsigned int)(limitToCPU - 1));
     
    157154        Copyright (c) 2000-2008 Torus Knot Software Ltd
    158155       
    159         OGRE is licensed under the LGPL. For more info, see ogre license info.
     156        OGRE is licensed under the LGPL. For more info, see OGRE license.
    160157    */
    161158    void GSRoot::setThreadAffinity(unsigned int limitToCPU)
  • code/trunk/src/orxonox/gamestates/GSServer.cc

    r1910 r2087  
    3030#include "GSServer.h"
    3131
    32 #include "core/ConsoleCommand.h"
    33 #include "core/input/InputManager.h"
    3432#include "core/CommandLine.h"
     33#include "core/Core.h"
    3534#include "network/Server.h"
    36 #include "Settings.h"
    3735
    3836namespace orxonox
    3937{
    40     SetCommandLineArgument(port, 55556).setShortcut("p").setInformation("0-65535");
     38    SetCommandLineArgument(port, 55556).shortcut("p").information("0-65535");
    4139
    4240    GSServer::GSServer()
    43         : GSLevel("server")
     41        : GameState<GSGraphics>("server")
    4442        , server_(0)
    4543    {
     
    5250    void GSServer::enter()
    5351    {
    54         Settings::_getInstance().bHasServer_ = true;
     52        Core::setHasServer(true);
    5553
    56         GSLevel::enter();
    57 
    58         int serverPort = CommandLine::getArgument<int>("port")->getValue();
    59         this->server_ = new network::Server(serverPort);
     54        this->server_ = new network::Server(CommandLine::getValue("port"));
    6055        COUT(0) << "Loading scene in server mode" << std::endl;
    6156
    62         this->loadLevel();
     57        GSLevel::enter(this->getParent()->getViewport());
    6358
    6459        server_->open();
    65 
    66         // add console commands
    67         FunctorMember<GSLevel>* functor = createFunctor(&GSLevel::setTimeFactor);
    68         functor->setObject(this);
    69         CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "setTimeFactor")).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);;
    70 
    71         // level is loaded: we can start capturing the input
    72         InputManager::getInstance().requestEnterState("game");
    7360    }
    7461
    7562    void GSServer::leave()
    7663    {
    77         InputManager::getInstance().requestLeaveState("game");
    78 
    79         // TODO: Remove and destroy console command
    80 
    81         this->unloadLevel();
     64        GSLevel::leave();
    8265
    8366        this->server_->close();
    8467        delete this->server_;
    8568
    86         GSLevel::leave();
    87        
    88         Settings::_getInstance().bHasServer_ = false;
     69        Core::setHasServer(false);
    8970    }
    9071
  • code/trunk/src/orxonox/gamestates/GSServer.h

    r1755 r2087  
    3333#include "network/NetworkPrereqs.h"
    3434#include "GSLevel.h"
     35#include "GSGraphics.h"
    3536
    3637namespace orxonox
    3738{
    38     class _OrxonoxExport GSServer : public GSLevel
     39    class _OrxonoxExport GSServer : public GameState<GSGraphics>, public GSLevel
    3940    {
    4041    public:
    4142        GSServer();
    4243        ~GSServer();
    43 
    4444
    4545    private:
  • code/trunk/src/orxonox/gamestates/GSStandalone.cc

    r1755 r2087  
    3030#include "GSStandalone.h"
    3131
    32 #include "core/input/InputManager.h"
    33 #include "core/ConsoleCommand.h"
     32#include "core/Core.h"
    3433
    3534namespace orxonox
    3635{
    3736    GSStandalone::GSStandalone()
    38         : GSLevel("standalone")
     37        : GameState<GSGraphics>("standalone")
    3938    {
    4039    }
     
    4645    void GSStandalone::enter()
    4746    {
    48         GSLevel::enter();
     47        Core::setIsStandalone(true);
    4948
    50         this->loadLevel();
    51 
    52         // add console commands
    53         FunctorMember<GSLevel>* functor = createFunctor(&GSLevel::setTimeFactor);
    54         functor->setObject(this);
    55         CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "setTimeFactor")).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);;
    56 
    57         // level is loaded: we can start capturing the input
    58         InputManager::getInstance().requestEnterState("game");
     49        GSLevel::enter(this->getParent()->getViewport());
    5950    }
    6051
    6152    void GSStandalone::leave()
    6253    {
    63         InputManager::getInstance().requestLeaveState("game");
     54        GSLevel::leave();
    6455
    65         // TODO: Remove and destroy console command
    66 
    67         this->unloadLevel();
    68 
    69         GSLevel::leave();
     56        Core::setIsStandalone(false);
    7057    }
    7158
  • code/trunk/src/orxonox/gamestates/GSStandalone.h

    r1755 r2087  
    3232#include "OrxonoxPrereqs.h"
    3333#include "GSLevel.h"
     34#include "GSGraphics.h"
    3435
    3536namespace orxonox
    3637{
    37     class _OrxonoxExport GSStandalone : public GSLevel
     38    class _OrxonoxExport GSStandalone : public GameState<GSGraphics>, public GSLevel
    3839    {
    3940    public:
Note: See TracChangeset for help on using the changeset viewer.