Changeset 6417 for code/trunk/src/orxonox/gamestates
- Timestamp:
- Dec 25, 2009, 10:23:58 PM (15 years ago)
- Location:
- code/trunk
- Files:
-
- 2 deleted
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/gamestates/GSGraphics.cc
r5929 r6417 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/trunk/src/orxonox/gamestates/GSGraphics.h
r5929 r6417 57 57 void update(const Clock& time); 58 58 59 void toggleGUI();60 61 59 private: 62 60 }; -
code/trunk/src/orxonox/gamestates/GSLevel.cc
r5966 r6417 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 … … 91 90 // level is loaded: we can start capturing the input 92 91 InputManager::getInstance().enterState("game"); 93 92 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 } … … 122 105 InputManager::getInstance().leaveState("game"); 123 106 } 124 107 125 108 // disconnect all HumanPlayers 126 109 PlayerManager::getInstance().disconnectAllClients(); … … 152 135 for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); ++it) 153 136 this->staticObjects_.insert(*it); 154 137 155 138 // call the loader 156 139 COUT(0) << "Loading level..." << std::endl; … … 171 154 if (find == this->staticObjects_.end()) 172 155 { 173 COUT(3) << ++i << ": " << it->getIdentifier()->getName() << " (" << *it << ")"<< std::endl;156 COUT(3) << ++i << ": " << it->getIdentifier()->getName() << " (" << *it << ')' << std::endl; 174 157 } 175 158 } -
code/trunk/src/orxonox/gamestates/GSLevel.h
r5929 r6417 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/trunk/src/orxonox/gamestates/GSMainMenu.cc
r6105 r6417 36 36 #include "core/Game.h" 37 37 #include "core/ConsoleCommand.h" 38 #include "core/ConfigValueIncludes.h" 39 #include "core/CoreIncludes.h" 38 40 #include "core/GraphicsManager.h" 39 41 #include "core/GUIManager.h" … … 49 51 , inputState_(0) 50 52 { 53 RegisterRootObject(GSMainMenu); 51 54 inputState_ = InputManager::getInstance().createInputState("mainMenu"); 52 55 inputState_->setMouseMode(MouseMode::Nonexclusive); … … 64 67 // Load sound 65 68 this->ambient_ = new AmbientSound(0); 66 this->ambient_->setS ource("ambient/mainmenu.wav");69 this->ambient_->setSyncMode(0x0); 67 70 } 68 71 } … … 71 74 { 72 75 if (GameMode::playsSound()) 73 delete this->ambient_;76 this->ambient_->destroy(); 74 77 75 78 InputManager::getInstance().destroyState("mainMenu"); … … 82 85 { 83 86 // show main menu 84 GUIManager::getInstance().showGUI("MainMenu" );87 GUIManager::getInstance().showGUI("MainMenu", true, GraphicsManager::getInstance().isFullScreen()); 85 88 GUIManager::getInstance().setCamera(this->camera_); 89 GUIManager::getInstance().setBackground("MainMenuBackground"); 90 // GUIManager::getInstance().setBackground(""); 86 91 GraphicsManager::getInstance().setCamera(this->camera_); 87 92 … … 92 97 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&GSMainMenu::startMainMenu), "startMainMenu")); 93 98 99 // create command to change sound path 100 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&GSMainMenu::setMainMenuSoundPath, this), "setMMSoundPath")); 101 94 102 KeyBinderManager::getInstance().setToDefault(); 95 103 InputManager::getInstance().enterState("mainMenu"); 96 104 105 this->setConfigValues(); 106 97 107 if (GameMode::playsSound()) 98 108 { 99 this->ambient_->setLoop (true);100 this->ambient_->play(); 109 this->ambient_->setLooping(true); 110 this->ambient_->play(); // works without source 101 111 } 102 112 } … … 112 122 113 123 GUIManager::getInstance().setCamera(0); 124 GUIManager::getInstance().setBackground(""); 125 GUIManager::hideGUI("MainMenu"); 114 126 GraphicsManager::getInstance().setCamera(0); 115 127 } … … 117 129 void GSMainMenu::update(const Clock& time) 118 130 { 131 } 132 133 void GSMainMenu::setConfigValues() 134 { 135 SetConfigValue(soundPathMain_, "mainmenu.ogg") 136 .description("Contains the path to the main menu sound file.") 137 .callback(this, &GSMainMenu::reloadSound); 138 } 139 140 void GSMainMenu::reloadSound() 141 { 142 if (GameMode::playsSound()) 143 { 144 this->ambient_->setAmbientSource(soundPathMain_); 145 } 146 } 147 148 const std::string& GSMainMenu::getMainMenuSoundPath() 149 { 150 return soundPathMain_; 151 } 152 153 void GSMainMenu::setMainMenuSoundPath(const std::string& path) 154 { 155 ModifyConfigValue(soundPathMain_, set, path); 119 156 } 120 157 -
code/trunk/src/orxonox/gamestates/GSMainMenu.h
r5929 r6417 34 34 #include "util/OgreForwardRefs.h" 35 35 #include "core/GameState.h" 36 #include "core/OrxonoxClass.h" 36 37 37 38 namespace orxonox 38 39 { 39 class _OrxonoxExport GSMainMenu : public GameState 40 class _OrxonoxExport GSMainMenu : public GameState, public OrxonoxClass 40 41 { 41 42 public: … … 46 47 void deactivate(); 47 48 void update(const Clock& time); 49 50 void setConfigValues(); 51 void reloadSound(); 52 const std::string& getMainMenuSoundPath(); 53 void setMainMenuSoundPath(const std::string& path); 48 54 49 55 static void startStandalone(); … … 61 67 // ambient sound for the main menu 62 68 AmbientSound* ambient_; 69 std::string soundPathMain_; 63 70 }; 64 71 } -
code/trunk/src/orxonox/gamestates/GSRoot.cc
r6105 r6417 30 30 31 31 #include "util/Clock.h" 32 #include "core/BaseObject.h" 32 33 #include "core/ConsoleCommand.h" 33 34 #include "core/Game.h" … … 45 46 GSRoot::GSRoot(const GameStateInfo& info) 46 47 : GameState(info) 47 , timeFactor_(1.0f)48 48 , bPaused_(false) 49 49 , timeFactorPauseBackup_(1.0f) … … 55 55 NetworkFunctionBase::destroyAllNetworkFunctions(); 56 56 } 57 57 58 58 void GSRoot::printObjects() 59 59 { 60 60 unsigned int nr=0; 61 for(ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it; ++it){ 62 if( dynamic_cast<Synchronisable*>(*it) ) 61 for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it; ++it) 62 { 63 if (dynamic_cast<Synchronisable*>(*it)) 63 64 COUT(0) << "object: " << it->getIdentifier()->getName() << " id: " << dynamic_cast<Synchronisable*>(*it)->getObjectID() << std::endl; 64 65 else … … 67 68 } 68 69 COUT(0) << "currently got " << nr << " objects" << std::endl; 69 70 70 } 71 71 … … 73 73 { 74 74 // reset game speed to normal 75 this->timeFactor_ = 1.0f;75 TimeFactorListener::setTimeFactor(1.0f); 76 76 77 77 // time factor console command … … 91 91 { 92 92 for (ObjectList<Timer>::iterator it = ObjectList<Timer>::begin(); it; ) 93 (it++)->tick(time); 93 { 94 Timer* object = *it; 95 ++it; 96 object->tick(time); 97 } 94 98 95 99 /*** HACK *** HACK ***/ … … 101 105 leveldt = 0.0f; 102 106 } 107 float realdt = leveldt * TimeFactorListener::getTimeFactor(); 103 108 for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ) 104 (it++)->tick(leveldt * this->timeFactor_); 109 { 110 Tickable* object = *it; 111 ++it; 112 object->tick(realdt); 113 } 105 114 /*** HACK *** HACK ***/ 106 115 } … … 119 128 if (!this->bPaused_) 120 129 { 121 TimeFactorListener::timefactor_s = factor; 122 123 for (ObjectList<TimeFactorListener>::iterator it = ObjectList<TimeFactorListener>::begin(); it != ObjectList<TimeFactorListener>::end(); ++it) 124 it->changedTimeFactor(factor, this->timeFactor_); 125 126 this->timeFactor_ = factor; 130 TimeFactorListener::setTimeFactor(factor); 127 131 } 128 132 else … … 137 141 if (!this->bPaused_) 138 142 { 139 this->timeFactorPauseBackup_ = this->timeFactor_;143 this->timeFactorPauseBackup_ = TimeFactorListener::getTimeFactor(); 140 144 this->setTimeFactor(0.0f); 141 145 this->bPaused_ = true; … … 148 152 } 149 153 } 154 155 float GSRoot::getTimeFactor() 156 { 157 return TimeFactorListener::getTimeFactor(); 158 } 150 159 } -
code/trunk/src/orxonox/gamestates/GSRoot.h
r5929 r6417 51 51 void setTimeFactor(float factor); 52 52 void pause(); 53 float getTimeFactor() { return this->timeFactor_; }53 float getTimeFactor(); 54 54 55 55 private: 56 float timeFactor_; //!< A factor that sets the gamespeed. 1 is normal.57 56 bool bPaused_; 58 57 float timeFactorPauseBackup_;
Note: See TracChangeset
for help on using the changeset viewer.