Changeset 6412 for code/branches/pickup2/src/libraries/core/GUIManager.cc
- Timestamp:
- Dec 25, 2009, 1:18:03 PM (15 years ago)
- Location:
- code/branches/pickup2
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/pickup2
- Property svn:mergeinfo changed
-
code/branches/pickup2/src/libraries/core/GUIManager.cc
r5929 r6412 40 40 #include <CEGUIResourceProvider.h> 41 41 #include <CEGUISystem.h> 42 #include <CEGUIWindow.h> 42 43 #include <ogreceguirenderer/OgreCEGUIRenderer.h> 43 44 … … 50 51 51 52 #include "util/Clock.h" 53 #include "util/Convert.h" 52 54 #include "util/Debug.h" 53 55 #include "util/Exception.h" 54 56 #include "util/OrxAssert.h" 57 #include "ConsoleCommand.h" 55 58 #include "Core.h" 56 59 #include "LuaState.h" … … 60 63 namespace orxonox 61 64 { 65 static void key_esc() 66 { GUIManager::getInstance().keyESC(); } 67 SetConsoleCommandShortcutExternAlias(key_esc, "keyESC"); 68 62 69 class CEGUILogger : public CEGUI::DefaultLogger 63 70 { … … 75 82 default: OrxAssert(false, "CEGUI log level out of range, inpect immediately!"); 76 83 } 77 OutputHandler::getOutStream( ).setOutputLevel(orxonoxLevel)84 OutputHandler::getOutStream(orxonoxLevel) 78 85 << "CEGUI: " << message << std::endl; 79 86 … … 85 92 86 93 GUIManager* GUIManager::singletonPtr_s = 0; 94 95 SetConsoleCommandShortcut(GUIManager, showGUI).accessLevel(AccessLevel::User).defaultValue(1, false).defaultValue(2, true); 96 SetConsoleCommandShortcut(GUIManager, hideGUI).accessLevel(AccessLevel::User); 87 97 88 98 /** … … 102 112 , resourceProvider_(0) 103 113 , camera_(NULL) 114 , bShowIngameGUI_(false) 104 115 { 105 116 using namespace CEGUI; … … 114 125 // setup scripting 115 126 luaState_.reset(new LuaState()); 127 rootFileInfo_ = Resource::getInfo("InitialiseGUI.lua"); 128 // This is necessary to ensure that input events also use the right resource info when triggering lua functions 129 luaState_->setDefaultResourceInfo(this->rootFileInfo_); 116 130 scriptModule_.reset(new LuaScriptModule(luaState_->getInternalLuaState())); 117 131 … … 121 135 // set the log level according to ours (translate by subtracting 1) 122 136 ceguiLogger->setLoggingLevel( 123 static_cast<LoggingLevel>( Core::getSoftDebugLevel(OutputHandler::LD_Logfile) - 1));137 static_cast<LoggingLevel>(OutputHandler::getInstance().getSoftDebugLevel("logFile") - 1)); 124 138 this->ceguiLogger_ = ceguiLogger.release(); 125 139 … … 127 141 guiSystem_.reset(new System(guiRenderer_.get(), resourceProvider_, 0, scriptModule_.get())); 128 142 129 // Initialise the basic lua code 130 rootFileInfo_ = Resource::getInfo("InitialiseGUI.lua", "GUI"); 131 this->luaState_->doFile("InitialiseGUI.lua", "GUI", false); 143 // Initialise the basic Lua code 144 this->luaState_->doFile("InitialiseGUI.lua"); 132 145 133 146 // Align CEGUI mouse with OIS mouse 134 147 guiSystem_->injectMousePosition(mousePosition.first, mousePosition.second); 135 148 136 // Hide the mouse cursor unless playing in full screen mode149 // Hide the mouse cursor unless playing in full screen mode 137 150 if (!bFullScreen) 138 151 CEGUI::MouseCursor::getSingleton().hide(); … … 157 170 This time value is then used to provide a fluent animation of the GUI. 158 171 */ 159 void GUIManager:: update(const Clock& time)172 void GUIManager::preUpdate(const Clock& time) 160 173 { 161 174 assert(guiSystem_); … … 204 217 For more details check out loadGUI_2.lua where the function presides. 205 218 */ 206 void GUIManager::showGUI(const std::string& name) 207 { 208 this->luaState_->doString("showGUI(\"" + name + "\")", rootFileInfo_); 219 /*static*/ void GUIManager::showGUI(const std::string& name, bool hidePrevious, bool showCursor) 220 { 221 GUIManager::getInstance().executeCode("showGUI(\"" + name + "\", " + multi_cast<std::string>(hidePrevious) + ", " + multi_cast<std::string>(showCursor) + ")"); 222 } 223 224 /** 225 @brief 226 Hack-ish. Needed for GUIOverlay. 227 */ 228 void GUIManager::showGUIExtra(const std::string& name, const std::string& ptr, bool hidePrevious, bool showCursor) 229 { 230 this->executeCode("showGUI(\"" + name + "\", " + multi_cast<std::string>(hidePrevious) + ", " + multi_cast<std::string>(showCursor) + ", " + ptr + ")"); 231 } 232 233 /** 234 @brief 235 Hides specified GUI. 236 @param name 237 The name of the GUI. 238 */ 239 /*static*/ void GUIManager::hideGUI(const std::string& name) 240 { 241 GUIManager::getInstance().executeCode("hideGUI(\"" + name + "\")"); 242 } 243 244 void GUIManager::keyESC() 245 { 246 this->executeCode("keyESC()"); 247 } 248 249 void GUIManager::setBackground(const std::string& name) 250 { 251 this->executeCode("setBackground(\"" + name + "\")"); 209 252 } 210 253 … … 280 323 code of the mouse button as it is used by CEGUI 281 324 282 Simple conver tion from mouse event code in Orxonox to the one used in CEGUI.325 Simple conversion from mouse event code in Orxonox to the one used in CEGUI. 283 326 */ 284 327 static inline CEGUI::MouseButton convertButton(MouseButtonCode::ByEnum button) … … 305 348 } 306 349 } 350 351 void GUIManager::subscribeEventHelper(CEGUI::Window* window, const std::string& event, const std::string& function) 352 { 353 window->subscribeScriptedEvent(event, function); 354 } 307 355 }
Note: See TracChangeset
for help on using the changeset viewer.