Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1646 for code/branches/gui/src


Ignore:
Timestamp:
Jul 24, 2008, 10:40:22 PM (17 years ago)
Author:
rgrieder
Message:
  • privatised InputState c'tors
  • added destruction code for GUIManager
  • fixed some issues and bugs
  • found 2400 memory leaks ;)
  • haven't done anything about it
  • converted GUIManager to Ogre Singleton
  • added NULL checkers in Loader
Location:
code/branches/gui/src
Files:
10 edited

Legend:

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

    r1625 r1646  
    6464    void Loader::add(const Level* level, const ClassTreeMask& mask)
    6565    {
     66        if (!level)
     67            return;
    6668        Loader::levels_s.insert(Loader::levels_s.end(), std::pair<const Level*, ClassTreeMask>(level, mask));
    6769    }
     
    6971    void Loader::remove(const Level* level)
    7072    {
     73        if (!level)
     74            return;
    7175        for (std::vector<std::pair<const Level*, ClassTreeMask> >::iterator it = Loader::levels_s.begin(); it != Loader::levels_s.end(); ++it)
    7276        {
     
    108112    bool Loader::load(const Level* level, const ClassTreeMask& mask)
    109113    {
     114        if (!level)
     115            return false;
     116
    110117        Loader::currentMask_s = level->getMask() * mask;
    111118
     
    165172    void Loader::unload(const Level* level, const ClassTreeMask& mask)
    166173    {
     174        if (!level)
     175            return;
    167176        for (Iterator<BaseObject> it = ObjectList<BaseObject>::begin(); it; )
    168177        {
  • code/branches/gui/src/core/input/ExtendedInputState.h

    r1642 r1646  
    4747    class _CoreExport ExtendedInputState : public InputState
    4848    {
     49        friend class InputManager;
     50        friend class ClassFactory<ExtendedInputState>;
     51
    4952    public:
    50         ExtendedInputState();
    51         ~ExtendedInputState() { }
    52 
    5353        bool addKeyHandler        (KeyHandler* handler);
    5454        bool removeKeyHandler     (KeyHandler* handler);
     
    6868
    6969    private:
     70        ExtendedInputState();
     71        ~ExtendedInputState() { }
     72
    7073        void tickInput(float dt);
    7174        void tickInput(float dt, unsigned int device);
  • code/branches/gui/src/core/input/InputManager.cc

    r1645 r1646  
    429429                    (*rit).second->onLeave();
    430430                }
    431                 activeStates_.clear();
    432                 _updateActiveStates();
     431                //activeStates_.clear();
     432                //_updateActiveStates();
    433433
    434434                // destroy all input states
     
    438438                }
    439439
    440                 stateEmpty_ = 0;
    441                 stateCalibrator_ = 0;
    442                 stateDetector_ = 0;
     440                //stateEmpty_ = 0;
     441                //stateCalibrator_ = 0;
     442                //stateDetector_ = 0;
    443443
    444444                // destroy the devices
     
    448448
    449449                // 0 joy sticks now
    450                 _redimensionLists();
     450                //_redimensionLists();
    451451
    452452                OIS::InputManager::destroyInputSystem(inputSystem_);
    453                 inputSystem_ = 0;
     453                //inputSystem_ = 0;
    454454
    455455                CCOUT(3) << "Destroying done." << std::endl;
     
    509509    {
    510510        assert(state);
     511        std::map<int, InputState*>::iterator it = this->activeStates_.find(state->getPriority());
     512        if (it != this->activeStates_.end())
     513        {
     514            this->activeStates_.erase(it);
     515            _updateActiveStates();
     516        }
    511517        inputStatesByPriority_.erase(state->getPriority());
    512518        inputStatesByName_.erase(state->getName());
  • code/branches/gui/src/core/input/InputState.h

    r1642 r1646  
    5151
    5252    public:
    53         InputState() : priority_(0), executorOnEnter_(0), executorOnLeave_(0)
    54         { RegisterObject(InputState); }
    55         virtual ~InputState() { }
    56 
    5753        const std::string& getName() const { return name_; }
    5854        int getPriority()            const { return priority_; }
     
    9389
    9490    protected:
     91        InputState() : priority_(0), executorOnEnter_(0), executorOnLeave_(0)
     92        { RegisterObject(InputState); }
     93        virtual ~InputState() { }
     94
    9595        virtual void numberOfJoySticksChanged(unsigned int n) = 0;
    9696        void setInputDeviceEnabled(unsigned int device, bool bEnabled)
  • code/branches/gui/src/core/input/SimpleInputState.h

    r1642 r1646  
    4545    class _CoreExport SimpleInputState : public InputState
    4646    {
     47        friend class InputManager;
     48        friend class ClassFactory<SimpleInputState>;
     49
    4750    public:
    48         SimpleInputState();
    49         ~SimpleInputState() { }
    50 
    5151        void setKeyHandler        (KeyHandler* handler) { keyHandler_ = handler; update(); }
    5252        void setMouseHandler      (MouseHandler* handler) { mouseHandler_ = handler; update(); }
     
    5757
    5858    private:
     59        SimpleInputState();
     60        ~SimpleInputState() { }
     61
    5962        void tickInput(float dt);
    6063        void tickInput(float dt, unsigned int device);
  • code/branches/gui/src/orxonox/Orxonox.cc

    r1645 r1646  
    115115    , inputManager_(0)
    116116    , radar_(0)
     117    , console_(0)
     118    , guiManager_(0)
    117119  {
    118120    RegisterRootObject(Orxonox);
     
    142144    if (this->radar_)
    143145      delete this->radar_;
     146
     147    if (this->guiManager_)
     148      delete guiManager_;
    144149
    145150    //if (this->auMan_)
     
    271276
    272277          // load the CEGUI interface
    273           GUIManager::getInstance().initialise();
     278          guiManager_ = new GUIManager();
     279          guiManager_->initialise();
    274280        }
    275281
  • code/branches/gui/src/orxonox/Orxonox.h

    r1642 r1646  
    103103      Radar*                radar_;         //!< represents the Radar (not the HUD part)
    104104      InGameConsole*        console_;
     105      GUIManager*           guiManager_;
    105106
    106107      static Orxonox *singletonRef_s;
  • code/branches/gui/src/orxonox/OrxonoxPrereqs.h

    r1625 r1646  
    118118    class OverlayGroup;
    119119    class OverlayText;
     120
     121    //gui
     122    class GUIManager;
    120123}
    121124
  • code/branches/gui/src/orxonox/gui/GUIManager.cc

    r1645 r1646  
    5858    SetConsoleCommandShortcut(GUIManager, showGUI_s).setKeybindMode(KeybindMode::OnPress);
    5959
     60    GUIManager* GUIManager::singletonRef_s = 0;
     61
    6062    GUIManager::GUIManager()
    6163        //: emptySceneManager_(0)
     
    7173        , state_(Uninitialised)
    7274    {
     75        assert(singletonRef_s == 0);
     76        singletonRef_s = this;
    7377    }
    7478
    7579    GUIManager::~GUIManager()
    7680    {
    77         // TODO: destruct at least something
     81        if (backgroundCamera_)
     82            backgroundSceneManager_->destroyCamera(backgroundCamera_);
     83
     84        if (backgroundSceneManager_)
     85            Ogre::Root::getSingleton().destroySceneManager(backgroundSceneManager_);
     86
     87        InputManager::getInstance().destroyState("gui");
     88
     89        if (guiSystem_)
     90            delete guiSystem_;
     91
     92        if (scriptModule_)
     93        {
     94            // destroy our own tolua interfaces
     95                //lua_pushnil(luaState_);
     96                //lua_setglobal(luaState_, "Orxonox");
     97                //lua_pushnil(luaState_);
     98                //lua_setglobal(luaState_, "Core");
     99            // TODO: deleting the script module fails an assertation.
     100            // However there is not much we can do about it since it occurs too when
     101            // we don't open Core or Orxonox. Might be a CEGUI issue.
     102            // The memory leak is not a problem anyway..
     103            //delete scriptModule_;
     104        }
     105
     106        if (guiRenderer_)
     107            delete guiRenderer_;
     108
     109        singletonRef_s = 0;
    78110    }
    79111
     
    104136                // setup scripting
    105137                this->scriptModule_ = new LuaScriptModule();
     138                this->luaState_ = this->scriptModule_->getLuaState();
    106139
    107140                // create the CEGUI system singleton
     
    267300
    268301
    269     /**
    270     @brief
    271         Returns a unique instance of GUIManager.
    272     @return
    273         The instance
    274     */
    275     GUIManager& GUIManager::getInstance()
    276     {
    277         static GUIManager instance;
    278         return instance;
    279     }
    280 
    281302    inline CEGUI::MouseButton GUIManager::convertButton(MouseButton::Enum button)
    282303    {
  • code/branches/gui/src/orxonox/gui/GUIManager.h

    r1641 r1646  
    4848    class LuaScriptModule;
    4949}
     50struct lua_State;
    5051
    5152namespace orxonox // tolua_export
     
    6869        };
    6970
     71        GUIManager();
     72        ~GUIManager();
     73
    7074        bool initialise();
    7175        void tick(float dt);
     
    7579        Ogre::Camera* getCamera() { return this->backgroundCamera_; }
    7680
    77         static GUIManager& getInstance(); // tolua_export
    7881        static void showGUI_s(const std::string& name, Ogre::SceneManager* sceneManager)//bool showBackground)
    7982        {
     
    8184        }
    8285
     86        static GUIManager& getInstance()    { assert(singletonRef_s); return *singletonRef_s; } // tolua_export
     87        static GUIManager* getInstancePtr() { return singletonRef_s; }
     88
    8389    private:
    84         GUIManager();
    8590        GUIManager(const GUIManager& instance);
    86         ~GUIManager();
    8791
    8892        void keyPressed (const KeyEvent& evt)
     
    119123        CEGUI::System*            guiSystem_;
    120124        CEGUI::Imageset*          backgroundImage_;
     125        lua_State*                luaState_;
    121126
    122127        State state_;
    123128
     129        static CEGUI::MouseButton convertButton(MouseButton::Enum button);
    124130
    125         static CEGUI::MouseButton convertButton(MouseButton::Enum button);
     131        static GUIManager*        singletonRef_s;
    126132    }; // tolua_export
    127133
Note: See TracChangeset for help on using the changeset viewer.