Changeset 6150 for code/branches/presentation2/src
- Timestamp:
- Nov 25, 2009, 4:52:37 PM (15 years ago)
- Location:
- code/branches/presentation2
- Files:
-
- 21 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/CMakeLists.txt
r6105 r6150 86 86 TOLUA_FILES 87 87 CommandExecutor.h 88 Game.h 88 89 Loader.h 89 90 LuaState.h 91 input/InputManager.h 90 92 DEFINE_SYMBOL 91 93 "CORE_SHARED_BUILD" -
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 -
code/branches/presentation2/src/libraries/core/GUIManager.h
r5929 r6150 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 hidePrevious=false, bool showCursor=true); 71 void showGUIExtra(const std::string& name, const std::string& ptr, bool hidePrevious=false, bool showCursor=true); 72 static void hideGUI(const std::string& name); 73 void toggleIngameGUI(); 74 void keyESC(); 75 void setBackground(const std::string& name); 71 76 72 77 void setCamera(Ogre::Camera* camera); … … 82 87 private: 83 88 GUIManager(const GUIManager& instance); //!< private and undefined copy c'tor (this is a singleton class) 89 90 std::set<std::string> showingGUIs_; //!< Keeps track of all the GUIs that are currently showing. 91 92 void executeCode(const std::string& str); 84 93 85 94 // keyHandler functions … … 105 114 106 115 static GUIManager* singletonPtr_s; //!< Singleton reference to GUIManager 116 bool bShowIngameGUI_; 107 117 108 118 }; -
code/branches/presentation2/src/libraries/core/Game.cc
r6121 r6150 51 51 #include "GameMode.h" 52 52 #include "GameState.h" 53 #include "GUIManager.h" 53 54 54 55 namespace orxonox … … 57 58 { Game::getInstance().stop(); } 58 59 SetConsoleCommandShortcutExternAlias(stop_game, "exit"); 60 static void key_esc() 61 { Game::getInstance().keyESC(); } 62 SetConsoleCommandShortcutExternAlias(key_esc, "keyESC"); 59 63 static void printFPS() 60 64 { COUT(0) << Game::getInstance().getAvgFPS() << std::endl; } … … 327 331 } 328 332 333 void Game::keyESC() 334 { 335 if( this->getState("mainMenu") && this->getState("mainMenu")->getActivity().active==true ) 336 this->stop(); 337 else 338 GUIManager::getInstance().keyESC(); 339 } 340 329 341 void Game::stop() 330 342 { … … 557 569 558 570 shared_ptr<GameState> state = this->getState(name); 559 state->activate ();571 state->activateInternal(); 560 572 if (!this->loadedStates_.empty()) 561 573 this->loadedStates_.back()->activity_.topState = false; … … 576 588 if (!this->loadedStates_.empty()) 577 589 this->loadedStates_.back()->activity_.topState = true; 578 state->deactivate ();590 state->deactivateInternal(); 579 591 } 580 592 catch (...) -
code/branches/presentation2/src/libraries/core/Game.h
r6121 r6150 59 59 #define DeclareGameState(className, stateName, bIgnoreTickTime, bGraphicsMode) \ 60 60 static bool BOOST_PP_CAT(bGameStateDummy_##className, __LINE__) = orxonox::Game::declareGameState<className>(#className, stateName, bIgnoreTickTime, bGraphicsMode) 61 61 // tolua_begin 62 62 namespace orxonox 63 63 { 64 // tolua_end 65 64 66 //! Helper object required before GameStates are being constructed 65 67 struct GameStateInfo … … 77 79 You should only create this singleton once because it owns the Core class! (see remark there) 78 80 */ 79 class _CoreExport Game : public Singleton<Game>, public OrxonoxClass 80 { 81 // tolua_begin 82 class _CoreExport Game 83 // tolua_end 84 : public Singleton<Game>, public OrxonoxClass 85 { // tolua_export 81 86 friend class Singleton<Game>; 82 87 typedef std::vector<shared_ptr<GameState> > GameStateVector; … … 95 100 void run(); 96 101 void stop(); 97 98 void requestState(const std::string& name); 99 void requestStates(const std::string& names); 100 void popState(); 102 void keyESC(); 103 104 static Game& getInstance(){ return Singleton<Game>::getInstance(); } // tolua_export 105 106 void requestState(const std::string& name); //tolua_export 107 void requestStates(const std::string& names); //tolua_export 108 void popState(); //tolua_export 101 109 102 110 const Clock& getGameClock() { return *this->gameClock_; } … … 188 196 static std::map<std::string, GameStateInfo> gameStateDeclarations_s; 189 197 static Game* singletonPtr_s; //!< Pointer to the Singleton 190 }; 198 }; //tolua_export 191 199 192 200 template <class T> … … 214 222 return true; 215 223 } 216 } 224 } //tolua_export 217 225 218 226 #endif /* _Game_H__ */ -
code/branches/presentation2/src/libraries/core/GameState.cc
r5738 r6150 83 83 this->activity_.active = false; 84 84 this->activity_.deactivating = true; 85 this-> activate();85 this->deactivate(); 86 86 this->activity_.deactivating = false; 87 87 this->activity_.suspended = false; -
code/branches/presentation2/src/libraries/core/LuaState.cc
r6105 r6150 116 116 } 117 117 118 void LuaState::includeString(const std::string& code, shared_ptr<ResourceInfo>sourceFileInfo)118 void LuaState::includeString(const std::string& code, const shared_ptr<ResourceInfo>& sourceFileInfo) 119 119 { 120 120 // Parse string with provided include parser (otherwise don't preparse at all) … … 138 138 } 139 139 140 void LuaState::doString(const std::string& code, shared_ptr<ResourceInfo>sourceFileInfo)140 void LuaState::doString(const std::string& code, const shared_ptr<ResourceInfo>& sourceFileInfo) 141 141 { 142 142 // Save the oold source file info … … 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/presentation2/src/libraries/core/LuaState.h
r5781 r6150 57 57 58 58 void doFile(const std::string& filename, const std::string& resourceGroup = "General", bool bSearchOtherPaths = true); // tolua_export 59 void doString(const std::string& code, shared_ptr<ResourceInfo>sourceFileInfo = shared_ptr<ResourceInfo>());59 void doString(const std::string& code, const shared_ptr<ResourceInfo>& sourceFileInfo = shared_ptr<ResourceInfo>()); 60 60 61 61 void includeFile(const std::string& filename, const std::string& resourceGroup = "General", bool bSearchOtherPaths = true); // tolua_export 62 void includeString(const std::string& code, shared_ptr<ResourceInfo>sourceFileInfo = shared_ptr<ResourceInfo>());62 void includeString(const std::string& code, const shared_ptr<ResourceInfo>& sourceFileInfo = shared_ptr<ResourceInfo>()); 63 63 64 64 void luaPrint(const std::string& str); // tolua_export … … 71 71 void setIncludeParser(std::string (*function)(const std::string&)) { includeParseFunction_ = function; } 72 72 lua_State* getInternalLuaState() { return luaState_; } 73 74 void setDefaultResourceInfo(const shared_ptr<ResourceInfo>& sourceFileInfo) { this->sourceFileInfo_ = sourceFileInfo; } 75 const shared_ptr<ResourceInfo>& getDefaultResourceInfo() { return this->sourceFileInfo_; } 73 76 74 77 static bool addToluaInterface(int (*function)(lua_State*), const std::string& name); -
code/branches/presentation2/src/libraries/core/input/InputManager.h
r6084 r6150 41 41 #include "InputState.h" 42 42 43 // tolua_begin 43 44 namespace orxonox 44 45 { … … 63 64 If the OIS::InputManager or the Keyboard fail, an exception is thrown. 64 65 */ 65 class _CoreExport InputManager : public Singleton<InputManager>, public WindowEventListener 66 { 66 class _CoreExport InputManager 67 // tolua_end 68 : public Singleton<InputManager>, public WindowEventListener 69 { // tolua_export 67 70 friend class Singleton<InputManager>; 68 71 public: … … 139 142 False if name was not found, true otherwise. 140 143 */ 141 bool enterState(const std::string& name); 144 bool enterState(const std::string& name); // tolua_export 142 145 /** 143 146 @brief … … 146 149 False if name was not found, true otherwise. 147 150 */ 148 bool leaveState(const std::string& name); 151 bool leaveState(const std::string& name); // tolua_export 149 152 /** 150 153 @brief … … 167 170 OIS::InputManager* getOISInputManager() { return this->oisInputManager_; } 168 171 std::pair<int, int> getMousePosition() const; 172 173 static InputManager& getInstance() { return *singletonPtr_s; } // tolua_export 169 174 170 175 private: // functions … … 207 212 208 213 static InputManager* singletonPtr_s; //!< Pointer reference to the singleton 209 }; 210 } 214 }; // tolua_export 215 } // tolua_export 211 216 212 217 #endif /* _InputManager_H__ */ -
code/branches/presentation2/src/modules/overlays/GUIOverlay.cc
r5980 r6150 73 73 out << reinterpret_cast<long>(this); 74 74 str = out.str(); 75 GUIManager::getInstance().executeCode("showCursor()"); 76 InputManager::getInstance().enterState("guiMouseOnly"); 77 GUIManager::getInstance().executeCode("showGUI(\"" + this->guiName_ + "\", " + str + ")"); 75 COUT(1) << "GUIManager ptr: " << str << std::endl; 76 GUIManager::getInstance().showGUIExtra(this->guiName_, str); 78 77 79 78 COUT(3) << "Showing GUI " << this->guiName_ << std::endl; … … 81 80 else 82 81 { 83 GUIManager::getInstance().executeCode("hideGUI(\"" + this->guiName_ + "\")"); 84 GUIManager::getInstance().executeCode("hideCursor()"); 85 InputManager::getInstance().leaveState("guiMouseOnly"); 82 GUIManager::hideGUI(this->guiName_); 86 83 COUT(3) << "Hiding GUI " << this->guiName_ << std::endl; 87 84 } -
code/branches/presentation2/src/modules/weapons/weaponmodes/HsW01.cc
r6108 r6150 40 40 #include "weaponsystem/WeaponSystem.h" 41 41 #include "worldentities/WorldEntity.h" 42 #include "worldentities/pawns/Pawn.h" 42 43 43 44 namespace orxonox … … 104 105 void HsW01::shot() 105 106 { 107 assert( this->getWeapon() && this->getWeapon()->getWeaponPack() && this->getWeapon()->getWeaponPack()->getWeaponSystem() && this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn() ); 106 108 Projectile* projectile = new Projectile(this); 107 109 Model* model = new Model(projectile); … … 111 113 model->setScale(5); 112 114 113 this->computeMuzzleParameters( );115 this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition()); 114 116 projectile->setOrientation(this->getMuzzleOrientation()); 115 117 projectile->setPosition(this->getMuzzlePosition()); -
code/branches/presentation2/src/orxonox/gamestates/GSGraphics.cc
r5929 r6150 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/presentation2/src/orxonox/gamestates/GSGraphics.h
r5929 r6150 57 57 void update(const Clock& time); 58 58 59 void toggleGUI();60 61 59 private: 62 60 }; -
code/branches/presentation2/src/orxonox/gamestates/GSLevel.cc
r5966 r6150 56 56 , guiKeysOnlyInputState_(0) 57 57 , startFile_(0) 58 , bShowIngameGUI_(false) 58 59 { 59 60 } … … 78 79 guiKeysOnlyInputState_ = InputManager::getInstance().createInputState("guiKeysOnly"); 79 80 guiKeysOnlyInputState_->setKeyHandler(GUIManager::getInstancePtr()); 80 81 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&GSLevel::showIngameGUI, this), "showIngameGUI"));82 81 } 83 82 … … 94 93 // connect the HumanPlayer to the game 95 94 PlayerManager::getInstance().clientConnected(0); 96 }97 }98 99 void GSLevel::showIngameGUI(bool show)100 {101 if (show)102 {103 GUIManager::getInstance().showGUI("inGameTest");104 GUIManager::getInstance().executeCode("showCursor()");105 InputManager::getInstance().enterState("guiMouseOnly");106 }107 else108 {109 GUIManager::getInstance().executeCode("hideGUI(\"inGameTest\")");110 GUIManager::getInstance().executeCode("hideCursor()");111 InputManager::getInstance().leaveState("guiMouseOnly");112 95 } 113 96 } -
code/branches/presentation2/src/orxonox/gamestates/GSLevel.h
r5929 r6150 52 52 void loadLevel(); 53 53 void unloadLevel(); 54 void showIngameGUI(bool show);55 54 56 55 InputState* gameInputState_; //!< input state for normal ingame playing … … 60 59 XMLFile* startFile_; 61 60 std::set<BaseObject*> staticObjects_; 61 bool bShowIngameGUI_; 62 62 }; 63 63 } -
code/branches/presentation2/src/orxonox/gamestates/GSMainMenu.cc
r6117 r6150 83 83 { 84 84 // show main menu 85 GUIManager::getInstance().showGUI("MainMenu" );85 GUIManager::getInstance().showGUI("MainMenu", true, false); 86 86 GUIManager::getInstance().setCamera(this->camera_); 87 GUIManager::getInstance().setBackground("MainMenuBackground"); 88 // GUIManager::getInstance().setBackground(""); 87 89 GraphicsManager::getInstance().setCamera(this->camera_); 88 90 … … 118 120 119 121 GUIManager::getInstance().setCamera(0); 122 GUIManager::getInstance().setBackground(""); 123 GUIManager::hideGUI("MainMenu"); 120 124 GraphicsManager::getInstance().setCamera(0); 121 125 } -
code/branches/presentation2/src/orxonox/pickup/PickupInventory.cc
r5781 r6150 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/presentation2/src/orxonox/pickup/PickupSpawner.cc
r5929 r6150 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 } -
code/branches/presentation2/src/orxonox/weaponsystem/WeaponMode.cc
r6112 r6150 196 196 } 197 197 198 void WeaponMode::computeMuzzleParameters( )198 void WeaponMode::computeMuzzleParameters(const Vector3& target) 199 199 { 200 200 if (this->weapon_) … … 204 204 Pawn* pawn = this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn(); 205 205 Vector3 muzzleDirection; 206 if ( pawn->getTarget() ) 207 { 208 muzzleDirection = pawn->getTarget()->getWorldPosition() - this->muzzlePosition_; 209 } 210 else 211 muzzleDirection = pawn->getAimPosition() - this->muzzlePosition_; 206 muzzleDirection = target - this->muzzlePosition_; 212 207 // COUT(0) << "muzzleDirection " << muzzleDirection << endl; 213 208 this->muzzleOrientation_ = (this->weapon_->getWorldOrientation() * WorldEntity::FRONT).getRotationTo(muzzleDirection) * this->weapon_->getWorldOrientation(); -
code/branches/presentation2/src/orxonox/weaponsystem/WeaponMode.h
r6108 r6150 109 109 { return this->muzzleOffset_; } 110 110 111 void computeMuzzleParameters( );111 void computeMuzzleParameters(const Vector3& target); 112 112 const Vector3& getMuzzlePosition() const 113 113 { return this->muzzlePosition_; }
Note: See TracChangeset
for help on using the changeset viewer.