Changeset 7876 for code/trunk/src/orxonox/gamestates
- Timestamp:
- Feb 13, 2011, 5:49:41 PM (14 years ago)
- Location:
- code/trunk/src/orxonox/gamestates
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/orxonox/gamestates/GSLevel.cc
r7870 r7876 51 51 DeclareGameState(GSLevel, "level", false, false); 52 52 53 static const std::string __CC_startMainMenu_name = "startMainMenu"; 54 static const std::string __CC_changeGame_name = "changeGame"; 55 56 SetConsoleCommand(__CC_startMainMenu_name, &GSLevel::startMainMenu).deactivate(); 57 SetConsoleCommand(__CC_changeGame_name, &GSLevel::changeGame).defaultValues(BLANKSTRING).deactivate(); 58 53 59 GSLevel::GSLevel(const GameStateInfo& info) 54 60 : GameState(info) … … 94 100 // connect the HumanPlayer to the game 95 101 PlayerManager::getInstance().clientConnected(0); 96 } 102 103 ModifyConsoleCommand(__CC_startMainMenu_name).activate(); 104 } 105 106 if (GameMode::isStandalone()) 107 ModifyConsoleCommand(__CC_changeGame_name).activate(); 97 108 } 98 109 … … 121 132 InputManager::getInstance().destroyState("guiKeysOnly"); 122 133 InputManager::getInstance().destroyState("guiMouseOnly"); 123 } 134 135 ModifyConsoleCommand(__CC_startMainMenu_name ).deactivate(); 136 } 137 138 if (GameMode::isStandalone()) 139 ModifyConsoleCommand(__CC_changeGame_name).deactivate(); 124 140 } 125 141 … … 166 182 COUT(3) << " Try harder!" << std::endl; 167 183 } 184 185 /** 186 @brief 187 Starts the MainMenu. 188 */ 189 /*static*/ void GSLevel::startMainMenu(void) 190 { 191 // HACK 192 Game::getInstance().popState(); 193 Game::getInstance().popState(); 194 } 195 196 /** 197 @brief 198 Terminates the current game and starts a new game. 199 @param level 200 The filename of the level to be started. 201 */ 202 /*static*/ void GSLevel::changeGame(const std::string& level) 203 { 204 if(level != BLANKSTRING) 205 LevelManager::getInstance().setDefaultLevel(level); 206 207 // HACK 208 Game::getInstance().popState(); 209 Game::getInstance().popState(); 210 Game::getInstance().requestStates("standalone, level"); 211 } 168 212 } -
code/trunk/src/orxonox/gamestates/GSLevel.h
r6417 r7876 49 49 void update(const Clock& time); 50 50 51 static void startMainMenu(void); //!< Starts the MainMenu 52 static void changeGame(const std::string& level); //!< Terminates the current game and starts a new game. 53 51 54 protected: 52 55 void loadLevel(); -
code/trunk/src/orxonox/gamestates/GSMainMenu.cc
r7854 r7876 31 31 #include <OgreSceneManager.h> 32 32 33 #include "core/input/KeyBinderManager.h"34 #include "core/Game.h"35 33 #include "core/ConfigValueIncludes.h" 36 34 #include "core/CoreIncludes.h" 35 #include "core/Game.h" 37 36 #include "core/GraphicsManager.h" 38 37 #include "core/GUIManager.h" 39 38 #include "core/command/ConsoleCommand.h" 39 #include "core/input/KeyBinderManager.h" 40 #include "network/Client.h" 41 #include "util/StringUtils.h" 42 #include "LevelManager.h" 40 43 #include "Scene.h" 41 44 #include "sound/AmbientSound.h" … … 52 55 static const std::string __CC_startClient_name = "startClient"; 53 56 static const std::string __CC_startDedicated_name = "startDedicated"; 54 static const std::string __CC_startMainMenu_name = "startMainMenu";55 57 static const std::string __CC_setMainMenuSoundPath_name = "setMMSoundPath"; 56 58 57 SetConsoleCommand(__CC_startStandalone_name, &GSMainMenu::startStandalone).deactivate(); 58 SetConsoleCommand(__CC_startServer_name, &GSMainMenu::startServer ).deactivate(); 59 SetConsoleCommand(__CC_startClient_name, &GSMainMenu::startClient ).deactivate(); 60 SetConsoleCommand(__CC_startDedicated_name, &GSMainMenu::startDedicated ).deactivate(); 61 SetConsoleCommand(__CC_startMainMenu_name, &GSMainMenu::startMainMenu ).deactivate(); 59 SetConsoleCommand(__CC_startStandalone_name, &GSMainMenu::startStandalone).defaultValues(BLANKSTRING).deactivate(); 60 SetConsoleCommand(__CC_startServer_name, &GSMainMenu::startServer ).defaultValues(BLANKSTRING).deactivate(); 61 SetConsoleCommand(__CC_startClient_name, &GSMainMenu::startClient ).defaultValues(BLANKSTRING).deactivate(); 62 SetConsoleCommand(__CC_startDedicated_name, &GSMainMenu::startDedicated ).defaultValues(BLANKSTRING).deactivate(); 62 63 SetConsoleCommand(__CC_setMainMenuSoundPath_name, &GSMainMenu::setMainMenuSoundPath).hide(); 63 64 … … 106 107 ModifyConsoleCommand(__CC_startClient_name ).activate(); 107 108 ModifyConsoleCommand(__CC_startDedicated_name ).activate(); 108 ModifyConsoleCommand(__CC_startMainMenu_name ).activate();109 109 ModifyConsoleCommand(__CC_setMainMenuSoundPath_name).setObject(this); 110 110 … … 138 138 ModifyConsoleCommand(__CC_startClient_name ).deactivate(); 139 139 ModifyConsoleCommand(__CC_startDedicated_name ).deactivate(); 140 ModifyConsoleCommand(__CC_startMainMenu_name ).deactivate();141 140 ModifyConsoleCommand(__CC_setMainMenuSoundPath_name).setObject(0); 142 141 } … … 171 170 } 172 171 173 void GSMainMenu::startStandalone() 174 { 175 // HACK - HACK 172 /** 173 @brief 174 Start a level in standalone mode. 175 @param level 176 The filename of the level to be started. If empty, the default level is started. 177 */ 178 void GSMainMenu::startStandalone(const std::string& level) 179 { 180 if(level != BLANKSTRING) 181 LevelManager::getInstance().setDefaultLevel(level); 182 183 // HACK 176 184 Game::getInstance().popState(); 177 185 Game::getInstance().requestStates("standalone, level"); 178 186 } 179 187 180 void GSMainMenu::startServer() 181 { 182 // HACK - HACK 188 /** 189 @brief 190 Start a level in server mode. 191 @param level 192 The filename of the level to be started. If empty, the default level is started. 193 */ 194 void GSMainMenu::startServer(const std::string& level) 195 { 196 if(level != BLANKSTRING) 197 LevelManager::getInstance().setDefaultLevel(level); 198 199 // HACK 183 200 Game::getInstance().popState(); 184 201 Game::getInstance().requestStates("server, level"); 185 202 } 186 203 187 void GSMainMenu::startClient() 188 { 189 // HACK - HACK 204 /** 205 @brief 206 Connect to a game as client. 207 @param destination 208 The destination to connect to. If empty, the client connects to the default destination. 209 */ 210 void GSMainMenu::startClient(const std::string& destination) 211 { 212 if(destination != BLANKSTRING) 213 Client::getInstance()->setDestination(destination, NETWORK_PORT); 214 215 // HACK 190 216 Game::getInstance().popState(); 191 217 Game::getInstance().requestStates("client, level"); 192 218 } 193 219 194 void GSMainMenu::startDedicated() 195 { 196 // HACK - HACK 220 /** 221 @brief 222 Start a level in dedicated mode. 223 @param level 224 The filename of the level to be started. If empty, the default level is started. 225 */ 226 void GSMainMenu::startDedicated(const std::string& level) 227 { 228 if(level != BLANKSTRING) 229 LevelManager::getInstance().setDefaultLevel(level); 230 231 // HACK 197 232 Game::getInstance().popState(); 198 233 Game::getInstance().popState(); 199 234 Game::getInstance().requestStates("server, level"); 200 235 } 201 void GSMainMenu::startMainMenu() 202 { 203 // HACK - HACK 204 Game::getInstance().popState(); 205 Game::getInstance().popState(); 206 Game::getInstance().requestStates("mainmenu"); 207 } 236 208 237 } -
code/trunk/src/orxonox/gamestates/GSMainMenu.h
r6746 r7876 53 53 void setMainMenuSoundPath(const std::string& path); 54 54 55 static void startStandalone(); 56 static void startServer(); 57 static void startClient(); 58 static void startDedicated(); 59 static void startMainMenu(); 55 static void startStandalone(const std::string& level = BLANKSTRING); //!< Start a level in standalone mode. 56 static void startServer(const std::string& level = BLANKSTRING); //!< Start a level in server mode. 57 static void startClient(const std::string& destination = BLANKSTRING); //!< Connect to a game as client. 58 static void startDedicated(const std::string& level = BLANKSTRING); //!< Start a level in dedicated mode. 60 59 static void startIOConsole(); 61 60
Note: See TracChangeset
for help on using the changeset viewer.