Changeset 6412 for code/branches/pickup2/src/orxonox/gamestates
- Timestamp:
- Dec 25, 2009, 1:18:03 PM (15 years ago)
- Location:
- code/branches/pickup2
- Files:
-
- 6 deleted
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/pickup2
- Property svn:mergeinfo changed
-
code/branches/pickup2/src/orxonox/gamestates/CMakeLists.txt
r5929 r6412 1 1 ADD_SOURCE_FILES(ORXONOX_SRC_FILES 2 2 GSClient.cc 3 GSDedicated.cc4 GSDedicatedClient.cc5 3 GSGraphics.cc 6 GSIOConsole.cc7 4 GSLevel.cc 8 5 GSMainMenu.cc -
code/branches/pickup2/src/orxonox/gamestates/GSClient.cc
r5929 r6412 29 29 #include "GSClient.h" 30 30 31 #include "util/ Clock.h"31 #include "util/Debug.h" 32 32 #include "util/Exception.h" 33 #include "core/CommandLine .h"33 #include "core/CommandLineParser.h" 34 34 #include "core/Game.h" 35 35 #include "core/GameMode.h" … … 38 38 namespace orxonox 39 39 { 40 DeclareGameState(GSClient, "client", false, true);40 DeclareGameState(GSClient, "client", false, false); 41 41 42 42 SetCommandLineArgument(ip, "127.0.0.1").information("Sever IP as string in the form #.#.#.#"); … … 56 56 GameMode::setIsClient(true); 57 57 58 this->client_ = new Client(CommandLine ::getValue("ip").getString(), CommandLine::getValue("port"));58 this->client_ = new Client(CommandLineParser::getValue("ip").getString(), CommandLineParser::getValue("port")); 59 59 60 60 if(!client_->establishConnection()) -
code/branches/pickup2/src/orxonox/gamestates/GSGraphics.cc
r5929 r6412 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/pickup2/src/orxonox/gamestates/GSGraphics.h
r5929 r6412 57 57 void update(const Clock& time); 58 58 59 void toggleGUI();60 61 59 private: 62 60 }; -
code/branches/pickup2/src/orxonox/gamestates/GSLevel.cc
r5929 r6412 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 } … … 117 100 if (GameMode::showsGraphics()) 118 101 { 119 // disconnect the HumanPlayer120 PlayerManager::getInstance().clientDisconnected(0);121 122 102 // unload all compositors (this is only necessary because we don't yet destroy all resources!) 123 103 Ogre::CompositorManager::getSingleton().removeAll(); … … 125 105 InputManager::getInstance().leaveState("game"); 126 106 } 107 108 // disconnect all HumanPlayers 109 PlayerManager::getInstance().disconnectAllClients(); 127 110 128 111 if (GameMode::isMaster()) … … 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/branches/pickup2/src/orxonox/gamestates/GSLevel.h
r5929 r6412 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/pickup2/src/orxonox/gamestates/GSMainMenu.cc
r5929 r6412 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 … … 91 96 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&GSMainMenu::startDedicated), "startDedicated")); 92 97 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&GSMainMenu::startMainMenu), "startMainMenu")); 93 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&GSMainMenu::startIOConsole), "startIOConsole")); 98 99 // create command to change sound path 100 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&GSMainMenu::setMainMenuSoundPath, this), "setMMSoundPath")); 94 101 95 102 KeyBinderManager::getInstance().setToDefault(); 96 103 InputManager::getInstance().enterState("mainMenu"); 97 104 105 this->setConfigValues(); 106 98 107 if (GameMode::playsSound()) 99 108 { 100 this->ambient_->setLoop (true);101 this->ambient_->play(); 109 this->ambient_->setLooping(true); 110 this->ambient_->play(); // works without source 102 111 } 103 112 } … … 113 122 114 123 GUIManager::getInstance().setCamera(0); 124 GUIManager::getInstance().setBackground(""); 125 GUIManager::hideGUI("MainMenu"); 115 126 GraphicsManager::getInstance().setCamera(0); 116 127 } … … 118 129 void GSMainMenu::update(const Clock& time) 119 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); 120 156 } 121 157 … … 146 182 Game::getInstance().popState(); 147 183 Game::getInstance().popState(); 148 Game::getInstance().requestStates(" dedicated, level");184 Game::getInstance().requestStates("server, level"); 149 185 } 150 186 void GSMainMenu::startMainMenu() … … 155 191 Game::getInstance().requestStates("mainmenu"); 156 192 } 157 void GSMainMenu::startIOConsole()158 {159 // HACK - HACK160 Game::getInstance().popState();161 Game::getInstance().popState();162 Game::getInstance().requestStates("ioConsole");163 }164 193 } -
code/branches/pickup2/src/orxonox/gamestates/GSMainMenu.h
r5929 r6412 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/branches/pickup2/src/orxonox/gamestates/GSRoot.cc
r5929 r6412 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 … … 90 90 void GSRoot::update(const Clock& time) 91 91 { 92 if (this->getActivity().topState)92 for (ObjectList<Timer>::iterator it = ObjectList<Timer>::begin(); it; ) 93 93 { 94 // This state can not 'survive' on its own.95 // Load a user interface therefore96 Game::getInstance().requestState("ioConsole");94 Timer* object = *it; 95 ++it; 96 object->tick(time); 97 97 } 98 99 for (ObjectList<Timer>::iterator it = ObjectList<Timer>::begin(); it; )100 (it++)->tick(time);101 98 102 99 /*** HACK *** HACK ***/ … … 108 105 leveldt = 0.0f; 109 106 } 107 float realdt = leveldt * TimeFactorListener::getTimeFactor(); 110 108 for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ) 111 (it++)->tick(leveldt * this->timeFactor_); 109 { 110 Tickable* object = *it; 111 ++it; 112 object->tick(realdt); 113 } 112 114 /*** HACK *** HACK ***/ 113 115 } … … 126 128 if (!this->bPaused_) 127 129 { 128 TimeFactorListener::timefactor_s = factor; 129 130 for (ObjectList<TimeFactorListener>::iterator it = ObjectList<TimeFactorListener>::begin(); it != ObjectList<TimeFactorListener>::end(); ++it) 131 it->changedTimeFactor(factor, this->timeFactor_); 132 133 this->timeFactor_ = factor; 130 TimeFactorListener::setTimeFactor(factor); 134 131 } 135 132 else … … 144 141 if (!this->bPaused_) 145 142 { 146 this->timeFactorPauseBackup_ = this->timeFactor_;143 this->timeFactorPauseBackup_ = TimeFactorListener::getTimeFactor(); 147 144 this->setTimeFactor(0.0f); 148 145 this->bPaused_ = true; … … 155 152 } 156 153 } 154 155 float GSRoot::getTimeFactor() 156 { 157 return TimeFactorListener::getTimeFactor(); 158 } 157 159 } -
code/branches/pickup2/src/orxonox/gamestates/GSRoot.h
r5929 r6412 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_; -
code/branches/pickup2/src/orxonox/gamestates/GSServer.cc
r5929 r6412 30 30 31 31 #include "util/Debug.h" 32 #include "core/CommandLine .h"32 #include "core/CommandLineParser.h" 33 33 #include "core/Game.h" 34 34 #include "core/GameMode.h" … … 37 37 namespace orxonox 38 38 { 39 DeclareGameState(GSServer, "server", false, true);39 DeclareGameState(GSServer, "server", false, false); 40 40 41 41 SetCommandLineArgument(port, 55556).shortcut("p").information("Network communication port to be used 0-65535 (default: 55556)"); … … 55 55 GameMode::setHasServer(true); 56 56 57 this->server_ = new Server(CommandLine ::getValue("port"));57 this->server_ = new Server(CommandLineParser::getValue("port")); 58 58 COUT(0) << "Loading scene in server mode" << std::endl; 59 59
Note: See TracChangeset
for help on using the changeset viewer.