Changeset 6024 for code/branches/menu/src
- Timestamp:
- Nov 4, 2009, 2:14:53 PM (15 years ago)
- Location:
- code/branches/menu
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/menu
- Property svn:mergeinfo changed
/code/branches/ingamemenu (added) merged: 6003,6018-6020,6022-6023
- Property svn:mergeinfo changed
-
code/branches/menu/src/libraries/core/CMakeLists.txt
r5929 r6024 85 85 TOLUA_FILES 86 86 CommandExecutor.h 87 Game.h 87 88 Loader.h 88 89 LuaState.h -
code/branches/menu/src/libraries/core/GUIManager.cc
r5929 r6024 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" 55 57 #include "Core.h" 58 #include "input/InputManager.h" 56 59 #include "LuaState.h" 57 60 #include "PathConfig.h" … … 86 89 GUIManager* GUIManager::singletonPtr_s = 0; 87 90 91 SetConsoleCommandShortcut(GUIManager, showGUI).accessLevel(AccessLevel::User).defaultValue(1, true); 92 SetConsoleCommandShortcut(GUIManager, hideGUI).accessLevel(AccessLevel::User); 93 88 94 /** 89 95 @brief … … 204 210 For more details check out loadGUI_2.lua where the function presides. 205 211 */ 206 void GUIManager::showGUI(const std::string& name) 207 { 208 this->luaState_->doString("showGUI(\"" + name + "\")", rootFileInfo_); 212 /*static*/ void GUIManager::showGUI(const std::string& name, bool showCursor) 213 { 214 std::pair<std::set<std::string>::iterator,bool> result = GUIManager::getInstance().showingGUIs_.insert(name); 215 if(result.second == false) //!< GUI already showing. 216 return; 217 if(GUIManager::getInstance().showingGUIs_.size() == 1 && result.second == true) //!< If it's the first GUI. 218 { 219 // GUIManager::getInstance().executeCode("showCursor()"); 220 InputManager::getInstance().enterState("guiMouseOnly"); 221 } 222 GUIManager::getInstance().executeCode("showGUI(\"" + name + "\", " + 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 showCursor) 230 { 231 std::pair<std::set<std::string>::iterator,bool> result = this->showingGUIs_.insert(name); 232 if(result.second == false) //!< GUI already showing. 233 return; 234 if(this->showingGUIs_.size() == 1 && result.second == true) //!< If it's the first GUI. 235 { 236 this->executeCode("showCursor()"); 237 InputManager::getInstance().enterState("guiMouseOnly"); 238 } 239 this->executeCode("showGUI(\"" + name + "\", " + multi_cast<std::string>(showCursor) + ", " + ptr + ")"); 240 } 241 242 /** 243 @brief 244 Hides specified GUI. 245 @param name 246 The name of the GUI. 247 */ 248 /*static*/ void GUIManager::hideGUI(const std::string& name) 249 { 250 bool present = GUIManager::getInstance().showingGUIs_.erase(name); 251 if(!present) //!< If there was nothing to erase. 252 return; 253 GUIManager::getInstance().executeCode("hideGUI(\"" + name + "\")"); 254 if(GUIManager::getInstance().showingGUIs_.size() == 0) 255 { 256 GUIManager::getInstance().executeCode("hideCursor()"); 257 InputManager::getInstance().leaveState("guiMouseOnly"); 258 } 209 259 } 210 260 -
code/branches/menu/src/libraries/core/GUIManager.h
r5929 r6024 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, bool showCursor=true); 71 void showGUIExtra(const std::string& name, const std::string& ptr, bool showCursor=true); 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 -
code/branches/menu/src/libraries/core/Game.h
r5929 r6024 58 58 #define DeclareGameState(className, stateName, bIgnoreTickTime, bGraphicsMode) \ 59 59 static bool BOOST_PP_CAT(bGameStateDummy_##className, __LINE__) = orxonox::Game::declareGameState<className>(#className, stateName, bIgnoreTickTime, bGraphicsMode) 60 60 // tolua_begin 61 61 namespace orxonox 62 62 { 63 // tolua_end 63 64 class GameConfiguration; 64 65 … … 78 79 You should only create this singleton once because it owns the Core class! (see remark there) 79 80 */ 80 class _CoreExport Game : public Singleton<Game> 81 // tolua_begin 82 class _CoreExport Game 83 : public Singleton<Game> 81 84 { 85 // tolua_end 82 86 friend class Singleton<Game>; 83 87 typedef std::vector<shared_ptr<GameState> > GameStateVector; … … 95 99 void stop(); 96 100 97 void requestState(const std::string& name); 98 void requestStates(const std::string& names); 99 void popState(); 101 static Game& getInstance(){ return Singleton<Game>::getInstance(); } // tolua_export 102 103 void requestState(const std::string& name); //tolua_export 104 void requestStates(const std::string& names); //tolua_export 105 void popState(); //tolua_export 100 106 101 107 const Clock& getGameClock() { return *this->gameClock_; } … … 183 189 static std::map<std::string, GameStateInfo> gameStateDeclarations_s; 184 190 static Game* singletonPtr_s; //!< Pointer to the Singleton 185 }; 191 }; //tolua_export 186 192 187 193 template <class T> … … 209 215 return true; 210 216 } 211 } 217 } //tolua_export 212 218 213 219 #endif /* _Game_H__ */ -
code/branches/menu/src/libraries/core/LuaState.cc
r5929 r6024 164 164 if (sourceFileInfo != NULL) 165 165 origin = " originating from " + sourceFileInfo_->filename; 166 COUT( 2) << "Error in Lua-script" << origin << ": " << lua_tostring(luaState_, -1) << std::endl;166 COUT(1) << "Error in Lua-script" << origin << ": " << lua_tostring(luaState_, -1) << std::endl; 167 167 // return value is nil 168 168 lua_pushnil(luaState_); -
code/branches/menu/src/modules/overlays/GUIOverlay.cc
r5781 r6024 72 72 out << reinterpret_cast<long>(this); 73 73 str = out.str(); 74 GUIManager::getInstance().executeCode("showCursor()"); 75 InputManager::getInstance().enterState("guiMouseOnly"); 76 GUIManager::getInstance().executeCode("showGUI(\"" + this->guiName_ + "\", " + str + ")"); 74 COUT(1) << "GUIManager ptr: " << str << std::endl; 75 GUIManager::getInstance().showGUIExtra(this->guiName_, str); 77 76 } 78 77 else 79 78 { 80 GUIManager::getInstance().executeCode("hideGUI(\"" + this->guiName_ + "\")"); 81 GUIManager::getInstance().executeCode("hideCursor()"); 82 InputManager::getInstance().leaveState("guiMouseOnly"); 79 GUIManager::hideGUI(this->guiName_); 83 80 } 84 81 } -
code/branches/menu/src/orxonox/gamestates/GSGraphics.cc
r5929 r6024 64 64 void GSGraphics::activate() 65 65 { 66 // add console command to toggle GUI 67 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&GSGraphics::toggleGUI, this), "toggleGUI")); 66 68 67 } 69 68 … … 78 77 } 79 78 80 /**81 @brief82 Toggles the visibility of the current GUI83 84 This function just executes a Lua function in the main script of the GUI by accessing the GUIManager.85 For more details on this function check out the Lua code.86 */87 void GSGraphics::toggleGUI()88 {89 GUIManager::getInstance().executeCode("toggleGUI()");90 }91 92 79 void GSGraphics::update(const Clock& time) 93 80 { -
code/branches/menu/src/orxonox/gamestates/GSGraphics.h
r5929 r6024 57 57 void update(const Clock& time); 58 58 59 void toggleGUI();60 61 59 private: 62 60 }; -
code/branches/menu/src/orxonox/gamestates/GSLevel.cc
r5929 r6024 101 101 if (show) 102 102 { 103 GUIManager::getInstance().showGUI("inGameTest"); 104 GUIManager::getInstance().executeCode("showCursor()"); 105 InputManager::getInstance().enterState("guiMouseOnly"); 103 GUIManager::showGUI("inGameTest"); 106 104 } 107 105 else 108 106 { 109 GUIManager::getInstance().executeCode("hideGUI(\"inGameTest\")"); 110 GUIManager::getInstance().executeCode("hideCursor()"); 111 InputManager::getInstance().leaveState("guiMouseOnly"); 107 GUIManager::hideGUI("inGameTest"); 112 108 } 113 109 } -
code/branches/menu/src/orxonox/gamestates/GSMainMenu.cc
r5929 r6024 82 82 { 83 83 // show main menu 84 GUIManager::getInstance().showGUI("MainMenu" );84 GUIManager::getInstance().showGUI("MainMenu", false); 85 85 GUIManager::getInstance().setCamera(this->camera_); 86 86 GraphicsManager::getInstance().setCamera(this->camera_); … … 113 113 114 114 GUIManager::getInstance().setCamera(0); 115 GUIManager::hideGUI("MainMenu"); 115 116 GraphicsManager::getInstance().setCamera(0); 116 117 } -
code/branches/menu/src/orxonox/pickup/PickupInventory.cc
r5781 r6024 86 86 { 87 87 if(PickupInventory::getSingleton()->isVisible()) { 88 GUIManager::getInstance().executeCode("hideGUI(\"PickupInventory\")"); 89 GUIManager::getInstance().executeCode("hideCursor()"); 90 InputManager::getInstance().leaveState("guiMouseOnly"); 91 } 92 else 93 { 94 GUIManager::getInstance().showGUI("PickupInventory"); 95 GUIManager::getInstance().executeCode("showCursor()"); 96 InputManager::getInstance().enterState("guiMouseOnly"); 88 GUIManager::hideGUI("PickupInventory"); 89 } 90 else 91 { 92 GUIManager::showGUI("PickupInventory"); 97 93 } 98 94 PickupInventory::getSingleton()->setVisible(!PickupInventory::getSingleton()->isVisible()); -
code/branches/menu/src/orxonox/pickup/PickupSpawner.cc
r5929 r6024 96 96 // & load the GUI itself too, along with some empty windows 97 97 // = even less delays 98 GUIManager:: getInstance().showGUI("PickupInventory");99 GUIManager:: getInstance().executeCode("hideGUI(\"PickupInventory\")");98 GUIManager::showGUI("PickupInventory"); 99 GUIManager::hideGUI("PickupInventory"); 100 100 PickupInventory::getSingleton(); 101 101 }
Note: See TracChangeset
for help on using the changeset viewer.