Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1653


Ignore:
Timestamp:
Aug 5, 2008, 9:50:26 PM (16 years ago)
Author:
rgrieder
Message:
  • getInstance is probably more suitable than getSingleton (as x3n has already done so in most of his classes) I changed it in Orxonox and GraphicsEngine. Maybe more to come.
  • Removed derivation from BaseObject in InputState (templates work well too, don't need a factory at all)
Location:
code/branches/gui/src
Files:
30 edited

Legend:

Unmodified
Added
Removed
  • code/branches/gui/src/core/input/ExtendedInputState.cc

    r1642 r1653  
    3737#include <assert.h>
    3838#include "core/Debug.h"
    39 #include "core/CoreIncludes.h"
    4039
    4140namespace orxonox
    4241{
    43     CreateFactory(ExtendedInputState);
    44 
    4542    using namespace InputDevice;
    46 
    47     ExtendedInputState::ExtendedInputState()
    48     {
    49         RegisterObject(ExtendedInputState);
    50     }
    5143
    5244    void ExtendedInputState::numberOfJoySticksChanged(unsigned int n)
  • code/branches/gui/src/core/input/ExtendedInputState.h

    r1646 r1653  
    4848    {
    4949        friend class InputManager;
    50         friend class ClassFactory<ExtendedInputState>;
    5150
    5251    public:
     
    6867
    6968    private:
    70         ExtendedInputState();
     69        ExtendedInputState() { }
    7170        ~ExtendedInputState() { }
    7271
  • code/branches/gui/src/core/input/InputManager.cc

    r1646 r1653  
    161161            setConfigValues();
    162162
    163             stateEmpty_ = createSimpleInputState("empty", -1);
     163            stateEmpty_ = createInputState<SimpleInputState>("empty", -1);
    164164            stateEmpty_->setHandler(new EmptyHandler());
    165165            activeStates_[stateEmpty_->getPriority()] = stateEmpty_;
    166166
    167             stateDetector_ = createSimpleInputState("detector", 101);
     167            stateDetector_ = createInputState<SimpleInputState>("detector", 101);
    168168            KeyDetector* temp = new KeyDetector();
    169169            temp->loadBindings("storeKeyStroke");
    170170            stateDetector_->setHandler(temp);
    171171
    172             stateCalibrator_ = createSimpleInputState("calibrator", 100);
     172            stateCalibrator_ = createInputState<SimpleInputState>("calibrator", 100);
    173173            stateCalibrator_->setHandler(new EmptyHandler());
    174174            InputBuffer* buffer = new InputBuffer();
     
    10371037    /**
    10381038    @brief
    1039         Returns a new SimpleInputState and configures it first.
    1040     */
    1041     SimpleInputState* InputManager::createSimpleInputState(const std::string &name, int priority)
    1042     {
    1043         SimpleInputState* state = new SimpleInputState();
    1044         if (_configureInputState(state, name, priority))
    1045             return state;
    1046         else
    1047         {
    1048             delete state;
    1049             return 0;
    1050         }
    1051     }
    1052 
    1053     /**
    1054     @brief
    1055         Returns a new ExtendedInputState and configures it first.
    1056     */
    1057     ExtendedInputState* InputManager::createExtendedInputState(const std::string &name, int priority)
    1058     {
    1059         ExtendedInputState* state = new ExtendedInputState();
    1060         if (_configureInputState(state, name, priority))
    1061             return state;
    1062         else
    1063         {
    1064             delete state;
    1065             return 0;
    1066         }
    1067     }
    1068 
    1069     /**
    1070     @brief
    1071         Returns a new InputState of type 'type' and configures it first.
    1072     @param type
    1073         String name of the class (used by the factory)
    1074     */
    1075     InputState* InputManager::createInputState(const std::string& type, const std::string &name, int priority)
    1076     {
    1077         InputState* state = dynamic_cast<InputState*>(Factory::getIdentifier(type)->fabricate());
    1078         if (_configureInputState(state, name, priority))
    1079             return state;
    1080         else
    1081         {
    1082             delete state;
    1083             return 0;
    1084         }
    1085     }
    1086 
    1087     /**
    1088     @brief
    10891039        Removes an input state internally.
    10901040    @param name
  • code/branches/gui/src/core/input/InputManager.h

    r1645 r1653  
    102102        void setWindowExtents(const int width, const int height);
    103103
    104         SimpleInputState*   createSimpleInputState  (const std::string& name, int priority);
    105         ExtendedInputState* createExtendedInputState(const std::string& name, int priority);
    106         InputState*         createInputState(const std::string& type, const std::string &name, int priority);
     104        template <class T>
     105        T* createInputState(const std::string& name, int priority)
     106        {
     107            T* state = new T;
     108            if (_configureInputState(state, name, priority))
     109                return state;
     110            else
     111            {
     112                delete state;
     113                return 0;
     114            }
     115        }
     116
    107117        bool destroyState          (const std::string& name);
    108118        InputState* getState       (const std::string& name);
  • code/branches/gui/src/core/input/InputState.h

    r1646 r1653  
    4040#include <vector>
    4141#include "core/Executor.h"
    42 #include "core/BaseObject.h"
    43 #include "core/CoreIncludes.h"
    4442#include "InputInterfaces.h"
    4543
    4644namespace orxonox
    4745{
    48     class _CoreExport InputState : public BaseObject
     46    class _CoreExport InputState
    4947    {
    5048        friend class InputManager;
     
    8987
    9088    protected:
    91         InputState() : priority_(0), executorOnEnter_(0), executorOnLeave_(0)
    92         { RegisterObject(InputState); }
     89        InputState() : priority_(0), executorOnEnter_(0), executorOnLeave_(0) { }
    9390        virtual ~InputState() { }
    9491
  • code/branches/gui/src/core/input/KeyDetector.cc

    r1638 r1653  
    6868    void KeyDetector::loadBindings(const std::string& command)
    6969    {
     70        this->command_ = command;
    7071        clearBindings();
    7172        setConfigValues();
    72         this->command_ = command;
    7373    }
    7474
  • code/branches/gui/src/core/input/SimpleInputState.cc

    r1642 r1653  
    3838#include "core/Debug.h"
    3939#include "core/Executor.h"
    40 #include "core/CoreIncludes.h"
    4140
    4241namespace orxonox
    4342{
    44     CreateFactory(SimpleInputState);
    45 
    4643    using namespace InputDevice;
    4744
     
    5148        , joyStickHandlerAll_(0)
    5249    {
    53         RegisterObject(SimpleInputState);
    5450    }
    5551
  • code/branches/gui/src/core/input/SimpleInputState.h

    r1646 r1653  
    4646    {
    4747        friend class InputManager;
    48         friend class ClassFactory<SimpleInputState>;
    4948
    5049    public:
  • code/branches/gui/src/orxonox/GraphicsEngine.cc

    r1652 r1653  
    6464namespace orxonox
    6565{
     66    SetConsoleCommand(GraphicsEngine, printScreen, true).setKeybindMode(KeybindMode::OnPress);
     67
    6668    GraphicsEngine* GraphicsEngine::singletonRef_s = 0;
    6769
     
    7274        The only instance of GraphicsEngine.
    7375    */
    74     /*static*/ GraphicsEngine& GraphicsEngine::getSingleton()
     76    /*static*/ GraphicsEngine& GraphicsEngine::getInstance()
    7577    {
    7678        assert(singletonRef_s);
     
    128130        if (this->root_)
    129131            delete this->root_;
    130         this->root_ = 0;
    131         this->levelSceneManager_ = 0;
    132         this->renderWindow_ = 0;
    133132
    134133#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32
     
    154153        CCOUT(3) << "Setting up..." << std::endl;
    155154
    156         // TODO: LogManager doesn't work on linux platform. The why is yet unknown.
     155        // TODO: LogManager doesn't work on oli platform. The why is yet unknown.
    157156#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32
    158157        // create a new logManager
     
    193192        root_ = new Ogre::Root(ogrePluginsFile_, ogreConfigFile_, ogreLogFile_);
    194193
    195         if (!root_->getInstalledPlugins().size())
    196         {
    197             ThrowException(PluginsNotFound, "No Ogre plugins declared. Cannot load Ogre.");
    198         }
    199 
    200 #if 0 // Ogre 1.4.3 doesn't support setDebugOutputEnabled(.)
    201 //#if ORXONOX_PLATFORM != ORXONOX_PLATFORM_WIN32
     194        // We don't need plugins for the dedicated..
     195        //if (!root_->getInstalledPlugins().size() > 0)
     196        //{
     197        //    ThrowException(PluginsNotFound, "No Ogre plugins declared. Cannot load Ogre.");
     198        //}
     199
     200#if 0 // Ogre 1.4.3 doesn't yet support setDebugOutputEnabled(.)
     201#if ORXONOX_PLATFORM != ORXONOX_PLATFORM_WIN32
    202202        // tame the ogre ouput so we don't get all the mess in the console
    203203        Ogre::Log* defaultLog = Ogre::LogManager::getSingleton().getDefaultLog();
     
    206206        defaultLog->addListener(this);
    207207#endif
     208#endif
    208209
    209210        CCOUT(4) << "Creating Ogre Root done" << std::endl;
     
    233234            cf.load(Settings::getDataPath() + resourceFile_);
    234235        }
    235         catch (Ogre::Exception& ex)
    236         {
    237             COUT(1) << ex.getFullDescription() << std::endl;
     236        catch (...)
     237        {
     238            //COUT(1) << ex.getFullDescription() << std::endl;
    238239            COUT(0) << "Have you forgotten to set the data path in orxnox.ini?" << std::endl;
    239240            throw;
     
    300301    }
    301302
    302     bool GraphicsEngine::initialiseResources()
     303    void GraphicsEngine::initialiseResources()
    303304    {
    304305        CCOUT(4) << "Initialising resources" << std::endl;
     
    313314            }*/
    314315        }
    315         catch (Ogre::Exception& e)
    316         {
    317             CCOUT(2) << "Error: There was an Error when initialising the resources." << std::endl;
    318             CCOUT(2) << "ErrorMessage: " << e.getFullDescription() << std::endl;
    319             return false;
    320         }
    321         return true;
     316        catch (...)
     317        {
     318            CCOUT(2) << "Error: There was a serious error when initialising the resources." << std::endl;
     319            throw;
     320        }
    322321    }
    323322
     
    326325        Creates the SceneManager
    327326    */
    328     bool GraphicsEngine::createNewScene()
     327    void GraphicsEngine::createNewScene()
    329328    {
    330329        CCOUT(4) << "Creating new SceneManager..." << std::endl;
     
    332331        {
    333332            CCOUT(2) << "SceneManager already exists! Skipping." << std::endl;
    334             return false;
    335333        }
    336334        this->levelSceneManager_ = this->root_->createSceneManager(Ogre::ST_GENERIC, "LevelSceneManager");
    337         CCOUT(3) << "Created SceneManager: " << levelSceneManager_ << std::endl;
    338         return true;
     335        CCOUT(3) << "Created SceneManager: " << levelSceneManager_->getName() << std::endl;
    339336    }
    340337
     
    487484    }
    488485
     486
     487    /*static*/ void GraphicsEngine::printScreen()
     488    {
     489        if (getInstance().renderWindow_)
     490        {
     491            getInstance().renderWindow_->writeContentsToTimestampedFile("shot_", ".jpg");
     492        }
     493    }
    489494}
  • code/branches/gui/src/orxonox/GraphicsEngine.h

    r1652 r1653  
    6262        void declareRessourceLocations();
    6363        void loadRenderer();
    64         bool initialiseResources();
    65         bool createNewScene();
     64        void initialiseResources();
     65        void createNewScene();
    6666
    6767        void setLevelSceneManager(Ogre::SceneManager* sceneMgr) { this->levelSceneManager_ = sceneMgr; }
     
    8787        { return this->detailLevelParticle_; }
    8888
    89         static GraphicsEngine& getSingleton();
    90         static GraphicsEngine* getSingletonPtr() { return singletonRef_s; }
     89        // console commands
     90        static void printScreen();
     91
     92        static GraphicsEngine& getInstance();
     93        static GraphicsEngine* getInstancePtr() { return singletonRef_s; }
    9194
    9295    private:
  • code/branches/gui/src/orxonox/Orxonox.cc

    r1646 r1653  
    112112    , mode_(GameMode::GM_Unspecified)
    113113    , debugRefreshTime_(0.0f)
    114     , ogre_(0)
     114    , graphicsEngine_(0)
    115115    , inputManager_(0)
    116116    , radar_(0)
     
    157157      delete inputManager_;
    158158
    159     if (this->ogre_)
    160       delete ogre_;
     159    if (this->graphicsEngine_)
     160      delete graphicsEngine_;
    161161
    162162    if (network::Client::getSingleton())
     
    212212  }
    213213
    214 
    215   /**
    216    * Starts the whole Game.
    217    * @param path path to config (in home dir or something)
    218    */
    219   void Orxonox::start()
    220   {
    221 #ifdef _DEBUG
    222     ConfigFileManager::getSingleton()->setFile(CFT_Settings, "orxonox_d.ini");
     214    /**
     215    @brief
     216        Starts the whole Game.
     217    @param path
     218        path to config (in home dir or something)
     219    */
     220    void Orxonox::start()
     221    {
     222#if ORXONOX_DEBUG_MODE == 1
     223        ConfigFileManager::getSingleton()->setFile(CFT_Settings, "orxonox_d.ini");
    223224#else
    224     ConfigFileManager::getSingleton()->setFile(CFT_Settings, "orxonox.ini");
     225        ConfigFileManager::getSingleton()->setFile(CFT_Settings, "orxonox.ini");
    225226#endif
    226     Factory::createClassHierarchy();
    227 
    228     setConfigValues();
    229 
    230     const Settings::CommandLineArgument* mode = Settings::getCommandLineArgument("mode");
    231     assert(mode);
    232     if (!mode->bHasDefaultValue_)
     227
     228        // creates the class hierarchy for all classes with factories
     229        Factory::createClassHierarchy();
     230
     231        setConfigValues();
     232
     233        const Settings::CommandLineArgument* mode = Settings::getCommandLineArgument("mode");
     234        assert(mode);
     235        if (!mode->bHasDefaultValue_)
     236        {
     237            Settings::setGameMode(mode->value_);
     238            this->mode_ = Settings::getGameMode();
     239        }
     240        COUT(3) << "Orxonox: Game mode is " << mode_.name << "." << std::endl;
     241
     242        const Settings::CommandLineArgument* dataPath = Settings::getCommandLineArgument("dataPath");
     243        assert(dataPath);
     244        if (!dataPath->bHasDefaultValue_)
     245        {
     246            if (*dataPath->value_.getString().end() != '/' && *dataPath->value_.getString().end() != '\\')
     247                Settings::tsetDataPath(dataPath->value_.getString() + "/");
     248            else
     249                Settings::tsetDataPath(dataPath->value_.getString());
     250        }
     251
     252        try
     253        {
     254            // initialise TCL
     255            TclBind::getInstance().setDataPath(Settings::getDataPath());
     256
     257            graphicsEngine_ = new GraphicsEngine();
     258            graphicsEngine_->setup();       // creates ogre root and other essentials
     259
     260            if (mode_.showsGraphics)
     261            {
     262                graphicsEngine_->loadRenderer();    // creates the render window
     263
     264                // TODO: Spread this so that this call only initialises things needed for the Console and GUI
     265                graphicsEngine_->initialiseResources();
     266
     267                // Calls the InputManager which sets up the input devices.
     268                // The render window width and height are used to set up the mouse movement.
     269                inputManager_ = new InputManager();
     270                inputManager_->initialise(graphicsEngine_->getWindowHandle(),
     271                    graphicsEngine_->getWindowWidth(), graphicsEngine_->getWindowHeight(), true, true, true);
     272                KeyBinder* keyBinder = new KeyBinder();
     273                keyBinder->loadBindings();
     274                inputManager_->createInputState<SimpleInputState>("game", 20)->setHandler(keyBinder);
     275
     276                // Load the InGameConsole
     277                console_ = new InGameConsole();
     278                console_->initialise();
     279
     280                // load the CEGUI interface
     281                guiManager_ = new GUIManager();
     282                guiManager_->initialise();
     283            }
     284            else
     285            {
     286                // TODO: Initialise a not yet written console that operates in the shell we
     287                // started the game from.
     288                // We probably want to use std::cin to catch input (OIS uses DirectX or X server)
     289            }
     290
     291            bool showGUI = true;
     292            if (mode_.mode != GameMode::Unspecified)
     293            {
     294                showGUI = false;
     295                // a game mode was specified with the command line
     296                // we therefore load the game and level directly
     297
     298                if (!loadLevel(this->mode_))
     299                {
     300                    COUT(1) << "Loading with predefined mode failed. Showing main menu." << std::endl;
     301                    showGUI = true;
     302                    mode_ = GameMode::GM_Unspecified;
     303                }
     304            }
     305
     306            if (showGUI)
     307            {
     308                // show main menu
     309                GUIManager::getInstance().showGUI("MainMenu", 0);
     310                GraphicsEngine::getInstance().getViewport()->setCamera(GUIManager::getInstance().getCamera());
     311            }
     312        }
     313        catch (std::exception& ex)
     314        {
     315            COUT(1) << ex.what() << std::endl;
     316            COUT(1) << "Loading sequence aborted." << std::endl;
     317            return;
     318        }
     319
     320        modeRequest_ = mode_;
     321        // here happens the game
     322        startRenderLoop();
     323
     324        if (mode_.mode == GameMode::Client)
     325            network::Client::getSingleton()->closeConnection();
     326
     327        if (mode_.hasServer)
     328            server_g->close();
     329    }
     330
     331    /*static*/ void Orxonox::loadGame(const std::string& name)
    233332    {
    234       Settings::setGameMode(mode->value_);
    235       this->mode_ = Settings::getGameMode();
     333        const GameMode& mode = Settings::getGameMode(name);
     334        if (mode.mode == GameMode::None)
     335            return;
     336
     337        getSingleton().modeRequest_ = mode;
    236338    }
    237     COUT(3) << "Orxonox: Game mode is " << mode_.name << "." << std::endl;
    238 
    239     const Settings::CommandLineArgument* dataPath = Settings::getCommandLineArgument("dataPath");
    240     assert(dataPath);
    241     if (!dataPath->bHasDefaultValue_)
     339
     340    bool Orxonox::loadLevel(const GameMode& mode)
    242341    {
    243       if (*dataPath->value_.getString().end() != '/' && *dataPath->value_.getString().end() != '\\')
    244         Settings::tsetDataPath(dataPath->value_.getString() + "/");
    245       else
    246         Settings::tsetDataPath(dataPath->value_.getString());
     342        bool success = true;
     343
     344        if (mode.showsGraphics)
     345        {
     346            // create Ogre SceneManager for the level
     347            graphicsEngine_->createNewScene();
     348
     349            if (!loadPlayground())
     350                return false;
     351        }
     352
     353        switch (mode.mode)
     354        {
     355        case GameMode::Server:
     356            success &= serverLoad();
     357            break;
     358        case GameMode::Client:
     359            success &= clientLoad();
     360            break;
     361        case GameMode::Dedicated:
     362            success &= serverLoad();
     363            break;
     364        case GameMode::Standalone:
     365            success &= standaloneLoad();
     366            break;
     367        default: // never happens
     368            assert(false);
     369        }
     370
     371        if (success)
     372        {
     373            InputManager::getInstance().requestEnterState("game");
     374            this->mode_ = mode;
     375        }
     376
     377        return success;
    247378    }
    248 
    249     try
    250     {
    251         // initialise TCL
    252         TclBind::getInstance().setDataPath(Settings::getDataPath());
    253 
    254         ogre_ = new GraphicsEngine();
    255         ogre_->setup();       // creates ogre root and other essentials
    256 
    257         if (mode_.showsGraphics)
    258         {
    259           ogre_->loadRenderer();    // creates the render window
    260 
    261           // TODO: Spread this so that this call only initialises things needed for the Console and GUI
    262           ogre_->initialiseResources();
    263 
    264           // Calls the InputManager which sets up the input devices.
    265           // The render window width and height are used to set up the mouse movement.
    266           inputManager_ = new InputManager();
    267           inputManager_->initialise(ogre_->getWindowHandle(),
    268                 ogre_->getWindowWidth(), ogre_->getWindowHeight(), true, true, true);
    269           KeyBinder* keyBinder = new KeyBinder();
    270           keyBinder->loadBindings();
    271           inputManager_->createSimpleInputState("game", 20)->setHandler(keyBinder);
    272 
    273           // Load the InGameConsole
    274           console_ = new InGameConsole();
    275           console_->initialise();
    276 
    277           // load the CEGUI interface
    278           guiManager_ = new GUIManager();
    279           guiManager_->initialise();
    280         }
    281 
    282         bool showGUI = true;
    283         if (mode_.mode != GameMode::Unspecified)
    284         {
    285           showGUI = false;
    286           // a game mode was specified with the command line
    287           // we therefore load the game and level directly
    288 
    289           if (!loadLevel(this->mode_))
    290           {
    291             COUT(1) << "Loading with predefined mode failed. Showing main menu." << std::endl;
    292             showGUI = true;
    293             mode_ = GameMode::GM_Unspecified;
    294           }
    295         }
    296        
    297         if (showGUI)
    298         {
    299           // show main menu
    300           GUIManager::getInstance().showGUI("MainMenu", 0);
    301           GraphicsEngine::getSingleton().getViewport()->setCamera(GUIManager::getInstance().getCamera());
    302         }
    303     }
    304     catch (std::exception& ex)
    305     {
    306       COUT(1) << ex.what() << std::endl;
    307       COUT(1) << "Loading sequence aborted." << std::endl;
    308       return;
    309     }
    310 
    311     modeRequest_ = mode_;
    312     // here happens the game
    313     startRenderLoop();
    314 
    315     if (mode_.mode == GameMode::Client)
    316       network::Client::getSingleton()->closeConnection();
    317 
    318     if (mode_.hasServer)
    319       server_g->close();
    320   }
    321 
    322   /*static*/ void Orxonox::loadGame(const std::string& name)
    323   {
    324       const GameMode& mode = Settings::getGameMode(name);
    325       if (mode.mode == GameMode::None)
    326           return;
    327 
    328       getSingleton().modeRequest_ = mode;
    329   }
    330 
    331   bool Orxonox::loadLevel(const GameMode& mode)
    332   {
    333       bool success = true;
    334 
    335       if (mode.showsGraphics)
    336       {
    337         // create Ogre SceneManager for the level
    338         ogre_->createNewScene();
    339 
    340         if (!loadPlayground())
    341             return false;
    342       }
    343 
    344       switch (mode.mode)
    345       {
    346       case GameMode::Server:
    347         success &= serverLoad();
    348         break;
    349       case GameMode::Client:
    350         success &= clientLoad();
    351         break;
    352       case GameMode::Dedicated:
    353         success &= serverLoad();
    354         break;
    355       case GameMode::Standalone:
    356         success &= standaloneLoad();
    357         break;
    358       default: // never happens
    359           assert(false);
    360       }
    361      
    362       if (success)
    363       {
    364         InputManager::getInstance().requestEnterState("game");
    365         this->mode_ = mode;
    366       }
    367 
    368       return success;
    369   }
    370379
    371380  /**
     
    528537        if (timeAfterTick > refreshStartTime + refreshTime)
    529538        {
    530           GraphicsEngine::getSingleton().setAverageTickTime(
     539          GraphicsEngine::getInstance().setAverageTickTime(
    531540              (float)tickTime * 0.001 / (frameCount - oldFrameCount));
    532541          float avgFPS = (float)(frameCount - oldFrameCount) / (timeAfterTick - refreshStartTime) * 1000000.0;
    533           GraphicsEngine::getSingleton().setAverageFramesPerSecond(avgFPS);
     542          GraphicsEngine::getInstance().setAverageFramesPerSecond(avgFPS);
    534543
    535544          oldFrameCount = frameCount;
     
    552561          // make sure the window stays active even when not focused
    553562          // (probably only necessary on windows)
    554           GraphicsEngine::getSingleton().setWindowActivity(true);
     563          GraphicsEngine::getInstance().setWindowActivity(true);
    555564
    556565          // tick CEGUI
  • code/branches/gui/src/orxonox/Orxonox.h

    r1646 r1653  
    8484
    8585    private:
    86       Level*                startLevel_;    //!< current hard coded default level
    87       Level*                hud_;           //!< 'level' object fo the HUD
    88       //audio::AudioManager*  auMan_;         //!< audio manager
    89       Ogre::Timer*          timer_;         //!< Main loop timer
    90       bool                  bAbort_;        //!< aborts the render loop if true
    91       float                 timefactor_;    //!< A factor to change the gamespeed
     86      Level*                startLevel_;       //!< current hard coded default level
     87      Level*                hud_;              //!< 'level' object fo the HUD
     88      //audio::AudioManager*  auMan_;            //!< audio manager
     89      Ogre::Timer*          timer_;            //!< Main loop timer
     90      bool                  bAbort_;           //!< aborts the render loop if true
     91      float                 timefactor_;       //!< A factor to change the gamespeed
    9292
    9393      // this is used to identify the mode (server/client/...) we're in
     
    9999
    100100      // By Orxonox managed singleton pointers
    101       GraphicsEngine*       ogre_;          //!< our dearest graphics engine <3
     101      GraphicsEngine*       graphicsEngine_;   //!< our dearest graphics engine <3
    102102      InputManager*         inputManager_;
    103       Radar*                radar_;         //!< represents the Radar (not the HUD part)
     103      Radar*                radar_;            //!< represents the Radar (not the HUD part)
    104104      InGameConsole*        console_;
    105105      GUIManager*           guiManager_;
  • code/branches/gui/src/orxonox/OrxonoxPrereqs.h

    r1646 r1653  
    8484    class Backlight;
    8585    class Camera;
    86     class Fighter;
    8786    class Model;
    8887    class NPC;
     
    131130}
    132131
     132namespace CEGUI
     133{
     134    class LuaScriptModule;
     135
     136    class OgreCEGUIRenderer;
     137    class OgreCEGUIResourceProvider;
     138    class OgreCEGUITexture;
     139}
     140
     141struct lua_State;
     142
    133143#endif /* _OrxonoxPrereqs_H__ */
  • code/branches/gui/src/orxonox/gui/GUIManager.cc

    r1646 r1653  
    2929/**
    3030    @file
    31     @brief Implementation of the GUIManager class.
     31    @brief
     32        Implementation of the GUIManager class.
    3233*/
    3334
     
    120121            {
    121122                // get the render window
    122                 renderWindow_ = GraphicsEngine::getSingleton().getRenderWindow();
     123                renderWindow_ = GraphicsEngine::getInstance().getRenderWindow();
    123124
    124125                // Full screen viewport with Z order = 0 (top most). Don't yet feed a camera (so nothing gets rendered)
     
    150151
    151152                // register us as input handler
    152                 SimpleInputState* state = InputManager::getInstance().createSimpleInputState("gui", 30);
     153                SimpleInputState* state = InputManager::getInstance().createInputState<SimpleInputState>("gui", 30);
    153154                state->setHandler(this);
    154155                state->setJoyStickHandler(new EmptyHandler());
     
    159160            catch (CEGUI::Exception& ex)
    160161            {
    161 #if CEGUI_VERSION_MINOR < 6
     162#if CEGUI_VERSION_MAJOR == 0 && CEGUI_VERSION_MINOR < 6
    162163                throw GeneralException(ex.getMessage().c_str());
    163164#else
  • code/branches/gui/src/orxonox/gui/GUIManager.h

    r1647 r1653  
    4141#include <CEGUISystem.h>
    4242#include "core/input/InputInterfaces.h"
    43 
    44 // forward declarations
    45 namespace CEGUI
    46 {
    47     class OgreCEGUIRenderer;
    48     class LuaScriptModule;
    49 }
    50 struct lua_State;
    5143
    5244namespace orxonox // tolua_export
  • code/branches/gui/src/orxonox/objects/Ambient.cc

    r1638 r1653  
    6565
    6666    bool Ambient::create(){
    67       GraphicsEngine::getSingleton().getLevelSceneManager()->setAmbientLight(ambientLight_);
     67      GraphicsEngine::getInstance().getLevelSceneManager()->setAmbientLight(ambientLight_);
    6868      return Synchronisable::create();
    6969    }
     
    7676    void Ambient::setAmbientLight(const ColourValue& colour)
    7777    {
    78         GraphicsEngine::getSingleton().getLevelSceneManager()->setAmbientLight(colour);
     78        GraphicsEngine::getInstance().getLevelSceneManager()->setAmbientLight(colour);
    7979      ambientLight_=colour;     
    8080    }
  • code/branches/gui/src/orxonox/objects/Backlight.cc

    r1638 r1653  
    5858        this->attachObject(this->billboard_.getBillboardSet());
    5959
    60         this->ribbonTrail_ = GraphicsEngine::getSingleton().getLevelSceneManager()->createRibbonTrail(this->getName() + "RibbonTrail");
    61         this->ribbonTrailNode_ = GraphicsEngine::getSingleton().getLevelSceneManager()->getRootSceneNode()->createChildSceneNode(this->getName() + "RibbonTrailNode");
     60        this->ribbonTrail_ = GraphicsEngine::getInstance().getLevelSceneManager()->createRibbonTrail(this->getName() + "RibbonTrail");
     61        this->ribbonTrailNode_ = GraphicsEngine::getInstance().getLevelSceneManager()->getRootSceneNode()->createChildSceneNode(this->getName() + "RibbonTrailNode");
    6262        this->ribbonTrailNode_->attachObject(this->ribbonTrail_);
    6363        this->ribbonTrail_->addNode(this->getNode());
     
    7676        {
    7777            this->detachObject(this->billboard_.getBillboardSet());
    78             GraphicsEngine::getSingleton().getLevelSceneManager()->destroySceneNode(this->getName() + "RibbonTrailNode");
    79             GraphicsEngine::getSingleton().getLevelSceneManager()->destroyRibbonTrail(this->ribbonTrail_);
     78            GraphicsEngine::getInstance().getLevelSceneManager()->destroySceneNode(this->getName() + "RibbonTrailNode");
     79            GraphicsEngine::getInstance().getLevelSceneManager()->destroyRibbonTrail(this->ribbonTrail_);
    8080        }
    8181    }
  • code/branches/gui/src/orxonox/objects/Camera.cc

    r1638 r1653  
    5252  {
    5353    this->bHasFocus_ = false;
    54     this->cameraNode_ = GraphicsEngine::getSingleton().getLevelSceneManager()->getRootSceneNode()->createChildSceneNode(node->getName() + "Camera");
     54    this->cameraNode_ = GraphicsEngine::getInstance().getLevelSceneManager()->getRootSceneNode()->createChildSceneNode(node->getName() + "Camera");
    5555    if( node != NULL )
    5656      this->setPositionNode(node);
     
    6060  {
    6161    CameraHandler::getInstance()->releaseFocus(this);
    62     GraphicsEngine::getSingleton().getLevelSceneManager()->getRootSceneNode()->removeAndDestroyChild(cameraNode_->getName());
     62    GraphicsEngine::getInstance().getLevelSceneManager()->getRootSceneNode()->removeAndDestroyChild(cameraNode_->getName());
    6363  }
    6464
  • code/branches/gui/src/orxonox/objects/CameraHandler.cc

    r1640 r1653  
    4444  CameraHandler::CameraHandler()
    4545  {
    46     this->cam_ = GraphicsEngine::getSingleton().getLevelSceneManager()->createCamera("Cam");
    47     GraphicsEngine::getSingleton().getViewport()->setCamera(this->cam_);
    48     //GraphicsEngine::getSingleton().getRenderWindow()->addViewport(this->cam_, 2, 0.4, 0.4, 0.2, 0.2);
     46    this->cam_ = GraphicsEngine::getInstance().getLevelSceneManager()->createCamera("Cam");
     47    GraphicsEngine::getInstance().getViewport()->setCamera(this->cam_);
     48    //GraphicsEngine::getInstance().getRenderWindow()->addViewport(this->cam_, 2, 0.4, 0.4, 0.2, 0.2);
    4949    /*this->activeCamera_ = *ObjectList<Camera>::begin();
    5050    this->activeCamera_->cam_ = this->cam_;*/
  • code/branches/gui/src/orxonox/objects/ParticleSpawner.cc

    r1638 r1653  
    7979        this->setPosition(this->getNode()->getParent()->getPosition());
    8080        this->getNode()->getParent()->removeChild(this->getNode());
    81         GraphicsEngine::getSingleton().getLevelSceneManager()->getRootSceneNode()->addChild(this->getNode());
     81        GraphicsEngine::getInstance().getLevelSceneManager()->getRootSceneNode()->addChild(this->getNode());
    8282        if (this->particle_)
    8383            this->particle_->setEnabled(false);
  • code/branches/gui/src/orxonox/objects/Skybox.cc

    r1638 r1653  
    5656    void Skybox::setSkybox(const std::string& skyboxname)
    5757    {
    58         GraphicsEngine::getSingleton().getLevelSceneManager()->setSkyBox(true, skyboxname);
     58        GraphicsEngine::getInstance().getLevelSceneManager()->setSkyBox(true, skyboxname);
    5959    }
    6060
     
    9292    {
    9393        BaseObject::changedVisibility();
    94         GraphicsEngine::getSingleton().getLevelSceneManager()->setSkyBox(this->isVisible(), this->skyboxSrc_);
     94        GraphicsEngine::getInstance().getLevelSceneManager()->setSkyBox(this->isVisible(), this->skyboxSrc_);
    9595    }
    9696}
  • code/branches/gui/src/orxonox/objects/WorldEntity.cc

    r1638 r1653  
    4949        RegisterObject(WorldEntity);
    5050
    51         if (GraphicsEngine::getSingleton().getLevelSceneManager())
     51        if (GraphicsEngine::getInstance().getLevelSceneManager())
    5252        {
    5353            std::ostringstream name;
    5454            name << (WorldEntity::worldEntityCounter_s++);
    5555            this->setName("WorldEntity" + name.str());
    56             this->node_ = GraphicsEngine::getSingleton().getLevelSceneManager()->getRootSceneNode()->createChildSceneNode(this->getName());
     56            this->node_ = GraphicsEngine::getInstance().getLevelSceneManager()->getRootSceneNode()->createChildSceneNode(this->getName());
    5757
    5858            registerAllVariables();
     
    7777        {
    7878            this->getNode()->removeAndDestroyAllChildren();
    79             GraphicsEngine::getSingleton().getLevelSceneManager()->destroySceneNode(this->getName());
     79            GraphicsEngine::getInstance().getLevelSceneManager()->destroySceneNode(this->getName());
    8080        }
    8181    }
     
    178178    void WorldEntity::attachObject(const WorldEntity& obj) const
    179179    {
    180         GraphicsEngine::getSingleton().getLevelSceneManager()->getRootSceneNode()->removeChild(obj.getNode());
     180        GraphicsEngine::getInstance().getLevelSceneManager()->getRootSceneNode()->removeChild(obj.getNode());
    181181        this->getNode()->addChild(obj.getNode());
    182182    }
     
    184184    void WorldEntity::attachObject(WorldEntity* obj) const
    185185    {
    186         GraphicsEngine::getSingleton().getLevelSceneManager()->getRootSceneNode()->removeChild(obj->getNode());
     186        GraphicsEngine::getInstance().getLevelSceneManager()->getRootSceneNode()->removeChild(obj->getNode());
    187187        this->getNode()->addChild(obj->getNode());
    188188    }
  • code/branches/gui/src/orxonox/overlays/OrxonoxOverlay.cc

    r1633 r1653  
    115115            // We'll have to get the aspect ratio manually for the first time. Afterwards windowResized() gets
    116116            // called automatically by the GraphicsEngine.
    117             this->windowResized(GraphicsEngine::getSingleton().getWindowWidth(),
    118                 GraphicsEngine::getSingleton().getWindowHeight());
     117            this->windowResized(GraphicsEngine::getInstance().getWindowWidth(),
     118                GraphicsEngine::getInstance().getWindowHeight());
    119119
    120120            this->changedVisibility();
  • code/branches/gui/src/orxonox/overlays/console/InGameConsole.cc

    r1642 r1653  
    147147    {
    148148        // create the corresponding input state
    149         InputManager::getInstance().createSimpleInputState("console", 40)
     149        InputManager::getInstance().createInputState<SimpleInputState>("console", 40)
    150150            ->setKeyHandler(Shell::getInstance().getInputBuffer());
    151151
     
    219219        this->consoleOverlayContainer_->addChild(this->consoleOverlayNoise_);
    220220
    221         this->windowResized(GraphicsEngine::getSingleton().getWindowWidth(), GraphicsEngine::getSingleton().getWindowHeight());
     221        this->windowResized(GraphicsEngine::getInstance().getWindowWidth(), GraphicsEngine::getInstance().getWindowHeight());
    222222
    223223        // move overlay "above" the top edge of the screen
  • code/branches/gui/src/orxonox/overlays/debug/DebugFPSText.cc

    r1625 r1653  
    4949    void DebugFPSText::tick(float dt)
    5050    {
    51         float fps = GraphicsEngine::getSingleton().getAverageFramesPerSecond();
     51        float fps = GraphicsEngine::getInstance().getAverageFramesPerSecond();
    5252        this->text_->setCaption(this->getCaption() + convertToString(fps));
    5353    }
  • code/branches/gui/src/orxonox/overlays/debug/DebugRTRText.cc

    r1625 r1653  
    4949    void DebugRTRText::tick(float dt)
    5050    {
    51         float rtr = GraphicsEngine::getSingleton().getAverageTickTime();
     51        float rtr = GraphicsEngine::getInstance().getAverageTickTime();
    5252        this->text_->setCaption(this->getCaption() + convertToString(rtr));
    5353    }
  • code/branches/gui/src/orxonox/tools/BillboardSet.cc

    r1638 r1653  
    5050        std::ostringstream name;
    5151        name << (BillboardSet::billboardSetCounter_s++);
    52         this->billboardSet_ = GraphicsEngine::getSingleton().getLevelSceneManager()->createBillboardSet("Billboard" + name.str(), count);
     52        this->billboardSet_ = GraphicsEngine::getInstance().getLevelSceneManager()->createBillboardSet("Billboard" + name.str(), count);
    5353        this->billboardSet_->createBillboard(Vector3::ZERO);
    5454        this->billboardSet_->setMaterialName(file);
     
    5959        std::ostringstream name;
    6060        name << (BillboardSet::billboardSetCounter_s++);
    61         this->billboardSet_ = GraphicsEngine::getSingleton().getLevelSceneManager()->createBillboardSet("Billboard" + name.str(), count);
     61        this->billboardSet_ = GraphicsEngine::getInstance().getLevelSceneManager()->createBillboardSet("Billboard" + name.str(), count);
    6262        this->billboardSet_->createBillboard(Vector3::ZERO, colour);
    6363        this->billboardSet_->setMaterialName(file);
     
    6868        std::ostringstream name;
    6969        name << (BillboardSet::billboardSetCounter_s++);
    70         this->billboardSet_ = GraphicsEngine::getSingleton().getLevelSceneManager()->createBillboardSet("Billboard" + name.str(), count);
     70        this->billboardSet_ = GraphicsEngine::getInstance().getLevelSceneManager()->createBillboardSet("Billboard" + name.str(), count);
    7171        this->billboardSet_->createBillboard(position);
    7272        this->billboardSet_->setMaterialName(file);
     
    7777        std::ostringstream name;
    7878        name << (BillboardSet::billboardSetCounter_s++);
    79         this->billboardSet_ = GraphicsEngine::getSingleton().getLevelSceneManager()->createBillboardSet("Billboard" + name.str(), count);
     79        this->billboardSet_ = GraphicsEngine::getInstance().getLevelSceneManager()->createBillboardSet("Billboard" + name.str(), count);
    8080        this->billboardSet_->createBillboard(position, colour);
    8181        this->billboardSet_->setMaterialName(file);
     
    8585    {
    8686        if (this->billboardSet_)
    87             GraphicsEngine::getSingleton().getLevelSceneManager()->destroyBillboardSet(this->billboardSet_);
     87            GraphicsEngine::getInstance().getLevelSceneManager()->destroyBillboardSet(this->billboardSet_);
    8888    }
    8989}
  • code/branches/gui/src/orxonox/tools/Light.cc

    r1638 r1653  
    4949        std::ostringstream name;
    5050        name << (Light::lightCounter_s++);
    51         this->light_ = GraphicsEngine::getSingleton().getLevelSceneManager()->createLight("Light" + name.str());
     51        this->light_ = GraphicsEngine::getInstance().getLevelSceneManager()->createLight("Light" + name.str());
    5252        this->light_->setType(type);
    5353        this->light_->setDiffuseColour(diffuse);
     
    5858    {
    5959        if (this->light_)
    60             GraphicsEngine::getSingleton().getLevelSceneManager()->destroyLight(this->light_);
     60            GraphicsEngine::getInstance().getLevelSceneManager()->destroyLight(this->light_);
    6161    }
    6262}
  • code/branches/gui/src/orxonox/tools/Mesh.cc

    r1638 r1653  
    4949        std::ostringstream name;
    5050        name << (Mesh::meshCounter_s++);
    51         this->entity_ = GraphicsEngine::getSingleton().getLevelSceneManager()->createEntity("Mesh" + name.str(), file);
     51        this->entity_ = GraphicsEngine::getInstance().getLevelSceneManager()->createEntity("Mesh" + name.str(), file);
    5252    }
    5353
     
    5555    {
    5656        if (this->entity_)
    57             GraphicsEngine::getSingleton().getLevelSceneManager()->destroyEntity(this->entity_);
     57            GraphicsEngine::getInstance().getLevelSceneManager()->destroyEntity(this->entity_);
    5858    }
    5959}
  • code/branches/gui/src/orxonox/tools/ParticleInterface.cc

    r1638 r1653  
    5555    this->bEnabled_ = true;
    5656    this->detaillevel_ = (unsigned int)detaillevel;
    57     this->particleSystem_ = GraphicsEngine::getSingleton().getLevelSceneManager()->createParticleSystem("particles" + getConvertedValue<unsigned int, std::string>(ParticleInterface::counter_s++), templateName);
     57    this->particleSystem_ = GraphicsEngine::getInstance().getLevelSceneManager()->createParticleSystem("particles" + getConvertedValue<unsigned int, std::string>(ParticleInterface::counter_s++), templateName);
    5858    this->particleSystem_->setSpeedFactor(Orxonox::getSingleton().getTimeFactor());
    5959
    60     if (GraphicsEngine::getSingleton().getDetailLevelParticle() < (unsigned int)this->detaillevel_)
     60    if (GraphicsEngine::getInstance().getDetailLevelParticle() < (unsigned int)this->detaillevel_)
    6161    {
    6262      this->bVisible_ = false;
     
    7272  {
    7373    this->particleSystem_->removeAllEmitters();
    74     GraphicsEngine::getSingleton().getLevelSceneManager()->destroyParticleSystem(particleSystem_);
     74    GraphicsEngine::getInstance().getLevelSceneManager()->destroyParticleSystem(particleSystem_);
    7575  }
    7676
Note: See TracChangeset for help on using the changeset viewer.