Changeset 6003 for code/branches/ingamemenu/src/libraries
- Timestamp:
- Oct 28, 2009, 5:58:11 PM (15 years ago)
- Location:
- code/branches/ingamemenu/src/libraries/core
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/ingamemenu/src/libraries/core/GUIManager.cc
r5929 r6003 53 53 #include "util/Exception.h" 54 54 #include "util/OrxAssert.h" 55 #include "ConsoleCommand.h" 55 56 #include "Core.h" 57 #include "input/InputManager.h" 56 58 #include "LuaState.h" 57 59 #include "PathConfig.h" … … 86 88 GUIManager* GUIManager::singletonPtr_s = 0; 87 89 90 SetConsoleCommandShortcut(GUIManager, showGUI).accessLevel(AccessLevel::User); 91 SetConsoleCommandShortcut(GUIManager, hideGUI).accessLevel(AccessLevel::User); 92 88 93 /** 89 94 @brief … … 204 209 For more details check out loadGUI_2.lua where the function presides. 205 210 */ 206 void GUIManager::showGUI(const std::string& name) 207 { 208 this->luaState_->doString("showGUI(\"" + name + "\")", rootFileInfo_); 211 /*static*/ void GUIManager::showGUI(const std::string& name) 212 { 213 std::pair<std::set<std::string>::iterator,bool> result = GUIManager::getInstance().showingGUIs_.insert(name); 214 if(result.second == false) //!< GUI already showing. 215 return; 216 if(GUIManager::getInstance().showingGUIs_.size() == 1 && result.second == true) //!< If it's the first GUI. 217 { 218 GUIManager::getInstance().executeCode("showCursor()"); 219 InputManager::getInstance().enterState("guiMouseOnly"); 220 } 221 GUIManager::getInstance().executeCode("showGUI(\"" + name + "\")"); 222 } 223 224 /** 225 @brief 226 Hack-ish. Needed for GUIOverlay. 227 */ 228 void GUIManager::showGUIExtra(const std::string& name, const std::string& ptr) 229 { 230 std::pair<std::set<std::string>::iterator,bool> result = this->showingGUIs_.insert(name); 231 if(result.second == false) //!< GUI already showing. 232 return; 233 if(this->showingGUIs_.size() == 1 && result.second == true) //!< If it's the first GUI. 234 { 235 this->executeCode("showCursor()"); 236 InputManager::getInstance().enterState("guiMouseOnly"); 237 } 238 this->executeCode("showGUI(\"" + name + "\", " + ptr + ")"); 239 } 240 241 /** 242 @brief 243 Hides specified GUI. 244 @param name 245 The name of the GUI. 246 */ 247 /*static*/ void GUIManager::hideGUI(const std::string& name) 248 { 249 bool present = GUIManager::getInstance().showingGUIs_.erase(name); 250 if(!present) //!< If there was nothing to erase. 251 return; 252 GUIManager::getInstance().executeCode("hideGUI(\"" + name + "\")"); 253 if(GUIManager::getInstance().showingGUIs_.size() == 0) 254 { 255 GUIManager::getInstance().executeCode("hideCursor()"); 256 InputManager::getInstance().leaveState("guiMouseOnly"); 257 } 209 258 } 210 259 -
code/branches/ingamemenu/src/libraries/core/GUIManager.h
r5929 r6003 34 34 35 35 #include <map> 36 #include <set> 36 37 #include <string> 37 38 #include <CEGUIForwardRefs.h> … … 65 66 ~GUIManager(); 66 67 67 void update(const Clock& time); 68 void update(const Clock& time); 68 69 69 void showGUI(const std::string& name); 70 void executeCode(const std::string& str); 70 static void showGUI(const std::string& name); 71 void showGUIExtra(const std::string& name, const std::string& ptr); 72 static void hideGUI(const std::string& name); 71 73 72 74 void setCamera(Ogre::Camera* camera); … … 82 84 private: 83 85 GUIManager(const GUIManager& instance); //!< private and undefined copy c'tor (this is a singleton class) 86 87 std::set<std::string> showingGUIs_; //!< Keeps track of all the GUIs that are currently showing. 88 89 void executeCode(const std::string& str); 84 90 85 91 // keyHandler functions
Note: See TracChangeset
for help on using the changeset viewer.