- Timestamp:
- Nov 25, 2009, 4:52:37 PM (15 years ago)
- Location:
- code/branches/presentation2
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation2
- Property svn:mergeinfo changed
/code/branches/ingamemenu (added) merged: 6003,6018-6020,6022-6023 /code/branches/menu (added) merged: 5941,5944,5952,6024,6032,6036,6047-6049,6051,6145-6146,6148
- Property svn:mergeinfo changed
-
code/branches/presentation2/src/libraries/core/GUIManager.cc
r6105 r6150 50 50 51 51 #include "util/Clock.h" 52 #include "util/Convert.h" 52 53 #include "util/Debug.h" 53 54 #include "util/Exception.h" 54 55 #include "util/OrxAssert.h" 56 #include "ConsoleCommand.h" 57 #include "Core.h" 58 #include "input/InputManager.h" 55 59 #include "LuaState.h" 56 60 #include "PathConfig.h" … … 85 89 GUIManager* GUIManager::singletonPtr_s = 0; 86 90 91 SetConsoleCommandShortcut(GUIManager, showGUI).accessLevel(AccessLevel::User).defaultValue(1, false).defaultValue(2, true); 92 SetConsoleCommandShortcut(GUIManager, hideGUI).accessLevel(AccessLevel::User); 93 87 94 /** 88 95 @brief … … 101 108 , resourceProvider_(0) 102 109 , camera_(NULL) 110 , bShowIngameGUI_(false) 103 111 { 104 112 using namespace CEGUI; … … 113 121 // setup scripting 114 122 luaState_.reset(new LuaState()); 123 rootFileInfo_ = Resource::getInfo("InitialiseGUI.lua", "GUI"); 124 // This is necessary to ensure that input events also use the right resource info when triggering lua functions 125 luaState_->setDefaultResourceInfo(this->rootFileInfo_); 115 126 scriptModule_.reset(new LuaScriptModule(luaState_->getInternalLuaState())); 116 127 … … 127 138 128 139 // Initialise the basic Lua code 129 rootFileInfo_ = Resource::getInfo("InitialiseGUI.lua", "GUI");130 140 this->luaState_->doFile("InitialiseGUI.lua", "GUI", false); 131 141 … … 203 213 For more details check out loadGUI_2.lua where the function presides. 204 214 */ 205 void GUIManager::showGUI(const std::string& name) 206 { 207 this->luaState_->doString("showGUI(\"" + name + "\")", rootFileInfo_); 215 /*static*/ void GUIManager::showGUI(const std::string& name, bool hidePrevious, bool showCursor) 216 { 217 std::pair<std::set<std::string>::iterator,bool> result = GUIManager::getInstance().showingGUIs_.insert(name); 218 if(GUIManager::getInstance().showingGUIs_.size() == 1 && result.second == true) //!< If it's the first GUI. 219 { 220 // InputManager::getInstance().enterState("guiMouseOnly"); 221 } 222 GUIManager::getInstance().executeCode("showGUI(\"" + name + "\", " + multi_cast<std::string>(hidePrevious) + ", " + multi_cast<std::string>(showCursor) + ")"); 223 } 224 225 /** 226 @brief 227 Hack-ish. Needed for GUIOverlay. 228 */ 229 void GUIManager::showGUIExtra(const std::string& name, const std::string& ptr, bool hidePrevious, bool showCursor) 230 { 231 std::pair<std::set<std::string>::iterator,bool> result = this->showingGUIs_.insert(name); 232 if(this->showingGUIs_.size() == 1 && result.second == true) //!< If it's the first GUI. 233 { 234 // this->executeCode("showCursor()"); 235 // InputManager::getInstance().enterState("guiMouseOnly"); 236 } 237 this->executeCode("showGUI(\"" + name + "\", " + multi_cast<std::string>(hidePrevious) + ", " + multi_cast<std::string>(showCursor) + ", " + ptr + ")"); 238 } 239 240 /** 241 @brief 242 Hides specified GUI. 243 @param name 244 The name of the GUI. 245 */ 246 /*static*/ void GUIManager::hideGUI(const std::string& name) 247 { 248 GUIManager::getInstance().showingGUIs_.erase(name); 249 GUIManager::getInstance().executeCode("hideGUI(\"" + name + "\")"); 250 if(GUIManager::getInstance().showingGUIs_.size() == 0) 251 { 252 // GUIManager::getInstance().executeCode("hideCursor()"); 253 // InputManager::getInstance().leaveState("guiMouseOnly"); 254 } 255 } 256 257 void GUIManager::toggleIngameGUI() 258 { 259 if ( this->bShowIngameGUI_==false ) 260 { 261 GUIManager::showGUI("InGameMenu"); 262 this->bShowIngameGUI_ = true; 263 } 264 else 265 { 266 GUIManager::hideGUI("InGameMenu"); 267 this->bShowIngameGUI_ = false; 268 } 269 } 270 271 void GUIManager::keyESC() 272 { 273 this->executeCode("keyESC()"); 274 } 275 276 void GUIManager::setBackground(const std::string& name) 277 { 278 this->executeCode("setBackground(\"" + name + "\")"); 208 279 } 209 280
Note: See TracChangeset
for help on using the changeset viewer.