Changeset 5661 for code/branches/resource2/src/core/GUIManager.cc
- Timestamp:
- Aug 19, 2009, 12:19:11 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/resource2/src/core/GUIManager.cc
r5658 r5661 27 27 * 28 28 */ 29 30 /**31 @file32 @brief33 Implementation of the GUIManager class.34 */35 29 36 30 #include "GUIManager.h" … … 60 54 #include "Clock.h" 61 55 #include "LuaState.h" 56 #include "Resource.h" 62 57 63 58 namespace orxonox … … 115 110 116 111 // setup scripting 117 scriptModule_.reset(new LuaScriptModule());118 luaState_ = scriptModule_->getLuaState();112 luaState_.reset(new LuaState()); 113 scriptModule_.reset(new LuaScriptModule(luaState_->getInternalLuaState())); 119 114 120 115 // Create our own logger to specify the filepath … … 129 124 guiSystem_.reset(new System(guiRenderer_.get(), resourceProvider_, 0, scriptModule_.get())); 130 125 131 // do this after 'new CEGUI::Sytem' because that creates the lua state in the first place 132 LuaState::openToluaInterfaces(this->luaState_); 133 134 // initialise the basic lua code 135 this->loadLuaCode(); 136 } 137 138 /** 139 @brief 140 Destructor of the GUIManager 141 126 // Initialise the basic lua code 127 rootFileInfo_ = Resource::getInfo("InitialiseGUI.lua", "GUI"); 128 this->luaState_->doFile("InitialiseGUI.lua", "GUI", false); 129 } 130 131 /** 132 @brief 142 133 Basically shuts down CEGUI (member smart pointers) but first unloads our Tolua modules. 143 134 */ 144 135 GUIManager::~GUIManager() 145 136 { 146 // destroy our own tolua interfaces147 LuaState::closeToluaInterfaces(this->luaState_);148 }149 150 /**151 @brief152 Calls main Lua script153 @todo154 This function calls the main Lua script for our GUI.155 156 Additionally we set the datapath variable in Lua. This is needed so Lua can access the data used for the GUI.157 */158 void GUIManager::loadLuaCode()159 {160 // set datapath for GUI data161 lua_pushfstring(this->scriptModule_->getLuaState(), Core::getDataPathString().c_str());162 lua_setglobal(this->scriptModule_->getLuaState(), "datapath");163 // call main Lua script164 this->scriptModule_->executeScriptFile("loadGUI_3.lua", "GUI");165 137 } 166 138 … … 209 181 void GUIManager::executeCode(const std::string& str) 210 182 { 211 try 212 { 213 this->scriptModule_->executeString(str); 214 } 215 catch (const CEGUI::Exception& ex) 216 { 217 COUT(2) << "CEGUI Error: \"" << ex.getMessage() << "\" while executing code \"" << str << "\"" << std::endl; 218 } 219 catch (...) 220 { 221 COUT(2) << "Couldn't execute GUI related Lua code due to unknown reasons." << std::endl; 222 } 183 this->luaState_->doString(str, rootFileInfo_); 223 184 } 224 185 … … 234 195 void GUIManager::showGUI(const std::string& name) 235 196 { 236 this-> executeCode(std::string("showGUI(\"") + name + "\")");197 this->luaState_->doString("showGUI(\"" + name + "\")", rootFileInfo_); 237 198 } 238 199
Note: See TracChangeset
for help on using the changeset viewer.