Changeset 7957 for code/branches
- Timestamp:
- Feb 24, 2011, 4:15:06 PM (14 years ago)
- Location:
- code/branches/kicklib/src/libraries/core
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/kicklib/src/libraries/core/GUIManager.cc
r7941 r7957 112 112 */ 113 113 GUIManager::GUIManager(const std::pair<int, int>& mousePosition) 114 : resourceProvider_(NULL) 114 : destroyer_(*this, &GUIManager::cleanup) 115 , guiRenderer_(NULL) 116 , luaState_(NULL) 117 , scriptModule_(NULL) 118 , guiSystem_(NULL) 119 , resourceProvider_(NULL) 115 120 , camera_(NULL) 116 121 { … … 123 128 124 129 // Note: No SceneManager specified yet 125 guiRenderer_ .reset(new OgreCEGUIRenderer(GraphicsManager::getInstance().getRenderWindow(), Ogre::RENDER_QUEUE_OVERLAY, false, 3000));130 guiRenderer_ = new OgreCEGUIRenderer(GraphicsManager::getInstance().getRenderWindow(), Ogre::RENDER_QUEUE_OVERLAY, false, 3000); 126 131 resourceProvider_ = guiRenderer_->createResourceProvider(); 127 132 resourceProvider_->setDefaultResourceGroup("General"); 128 133 129 134 // Setup scripting 130 luaState_ .reset(new LuaState());135 luaState_ = new LuaState(); 131 136 rootFileInfo_ = Resource::getInfo("InitialiseGUI.lua"); 132 137 // This is necessary to ensure that input events also use the right resource info when triggering lua functions 133 138 luaState_->setDefaultResourceInfo(this->rootFileInfo_); 134 scriptModule_ .reset(new LuaScriptModule(luaState_->getInternalLuaState()));139 scriptModule_ = new LuaScriptModule(luaState_->getInternalLuaState()); 135 140 scriptModule_->setDefaultPCallErrorHandler(LuaState::ERROR_HANDLER_NAME); 136 141 … … 138 143 std::auto_ptr<CEGUILogger> ceguiLogger(new CEGUILogger()); 139 144 ceguiLogger->setLogFilename(PathConfig::getLogPathString() + "cegui.log"); 140 // set the log level according to ours (translate by subtracting 1)145 // Set the log level according to ours (translate by subtracting 1) 141 146 ceguiLogger->setLoggingLevel( 142 147 static_cast<LoggingLevel>(OutputHandler::getInstance().getSoftDebugLevel("logFile") - 1)); … … 144 149 145 150 // Create the CEGUI system singleton 146 guiSystem_ .reset(new System(guiRenderer_.get(), resourceProvider_, 0, scriptModule_.get()));151 guiSystem_ = new System(guiRenderer_, resourceProvider_, 0, scriptModule_); 147 152 148 153 // Align CEGUI mouse with OIS mouse … … 169 174 } 170 175 171 /** 172 @brief 173 Basically shuts down CEGUI (member smart pointers) but first unloads our Tolua modules. 174 */ 175 GUIManager::~GUIManager() 176 { 176 void GUIManager::cleanup() 177 { 178 using namespace CEGUI; 179 180 delete guiSystem_; 181 delete guiRenderer_; 182 delete scriptModule_; 183 delete luaState_; 177 184 } 178 185 -
code/branches/kicklib/src/libraries/core/GUIManager.h
r7874 r7957 44 44 #include <boost/scoped_ptr.hpp> 45 45 #include <boost/shared_ptr.hpp> 46 #include <loki/ScopeGuard.h> 46 47 47 48 #include "util/OgreForwardRefs.h" … … 77 78 public: 78 79 GUIManager(const std::pair<int, int>& mousePosition); 79 ~GUIManager(); 80 //! Leave empty and use cleanup() instead 81 ~GUIManager() {} 80 82 81 83 void setConfigValues(void); … … 95 97 const std::string& createInputState(const std::string& name, TriBool::Value showCursor = TriBool::True, TriBool::Value useKeyboard = TriBool::True, bool bBlockJoyStick = false); // tolua_export 96 98 LuaState* getLuaState(void) 97 { return this->luaState_ .get(); }99 { return this->luaState_; } 98 100 99 101 //! Returns the root window for all menu sheets … … 118 120 private: 119 121 GUIManager(const GUIManager& instance); //!< private and undefined copy c'tor (this is a singleton class) 122 123 /// Destructor that also executes when object fails to construct 124 void cleanup(); 125 120 126 void executeCode(const std::string& str); 121 127 … … 138 144 virtual void windowFocusChanged(bool bFocus); 139 145 140 scoped_ptr<CEGUI::OgreCEGUIRenderer> guiRenderer_; //!< CEGUI's interface to the Ogre Engine 141 scoped_ptr<LuaState> luaState_; //!< LuaState, access point to the Lua engine 142 scoped_ptr<CEGUI::LuaScriptModule> scriptModule_; //!< CEGUI's script module to use Lua 143 scoped_ptr<CEGUI::System> guiSystem_; //!< CEGUI's main system 146 /// Surrogate for the destructor 147 Loki::ObjScopeGuardImpl0<GUIManager, void (GUIManager::*)()> destroyer_; 148 149 CEGUI::OgreCEGUIRenderer* guiRenderer_; //!< CEGUI's interface to the Ogre Engine 150 CEGUI::ResourceProvider* resourceProvider_; //!< CEGUI's resource provider 151 LuaState* luaState_; //!< LuaState, access point to the Lua engine 152 CEGUI::LuaScriptModule* scriptModule_; //!< CEGUI's script module to use Lua 153 CEGUI::System* guiSystem_; //!< CEGUI's main system 144 154 shared_ptr<ResourceInfo> rootFileInfo_; //!< Resource information about the root script 145 CEGUI::ResourceProvider* resourceProvider_; //!< CEGUI's resource provider146 155 CEGUI::Logger* ceguiLogger_; //!< CEGUI's logger to be able to log CEGUI errors in our log 147 156 CEGUI::Window* rootWindow_; //!< Root node for all windows
Note: See TracChangeset
for help on using the changeset viewer.