Changeset 2850 for code/branches/gui/src/orxonox/gamestates
- Timestamp:
- Mar 25, 2009, 11:53:04 PM (16 years ago)
- Location:
- code/branches/gui/src/orxonox/gamestates
- Files:
-
- 7 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
code/branches/gui/src/orxonox/gamestates/CMakeLists.txt
r2710 r2850 1 1 ADD_SOURCE_FILES(ORXONOX_SRC_FILES 2 GSClient.cc 2 3 GSDedicated.cc 3 GSClient.cc4 4 GSGraphics.cc 5 GSGUI.cc6 5 GSIOConsole.cc 7 6 GSLevel.cc 7 GSMainMenu.cc 8 8 GSRoot.cc 9 9 GSServer.cc -
code/branches/gui/src/orxonox/gamestates/GSGraphics.cc
r2848 r2850 35 35 #include "util/Debug.h" 36 36 #include "core/ConfigValueIncludes.h" 37 #include "core/Clock.h" 37 38 #include "core/Core.h" 38 39 #include "core/CoreIncludes.h" … … 146 147 this->inputManager_->update(time); // tick console 147 148 this->console_->update(time); 149 this->guiManager_->update(time); 148 150 149 151 uint64_t timeAfterTick = time.getRealMicroseconds(); … … 152 154 Game::getInstance().addTickTime(timeAfterTick - timeBeforeTick); 153 155 156 // Render 154 157 this->graphicsManager_->update(time); 155 158 } -
code/branches/gui/src/orxonox/gamestates/GSIOConsole.cc
r2844 r2850 53 53 void GSIOConsole::activate() 54 54 { 55 { 56 FunctorMember<GSIOConsole>* functor = createFunctor(&GSIOConsole::loadMenu); 57 functor->setObject(this); 58 this->ccLoadMenu_ = createConsoleCommand(functor, "loadMenu"); 59 CommandExecutor::addConsoleCommandShortcut(this->ccLoadMenu_); 60 } 55 61 } 56 62 57 63 void GSIOConsole::deactivate() 58 64 { 65 if (this->ccLoadMenu_) 66 { 67 delete this->ccLoadMenu_; 68 this->ccLoadMenu_ = 0; 69 } 59 70 } 60 71 61 72 void GSIOConsole::update(const Clock& time) 62 73 { 74 std::cout << ">"; 63 75 std::string command; 64 76 std::getline(std::cin, command); 65 77 CommandExecutor::execute(command, true); 66 78 } 79 80 void GSIOConsole::loadMenu() 81 { 82 Game::getInstance().popState(); 83 Game::getInstance().requestStates("graphics, mainMenu"); 84 } 67 85 } -
code/branches/gui/src/orxonox/gamestates/GSIOConsole.h
r2844 r2850 46 46 47 47 private: 48 void loadMenu(); 48 49 50 // console commands 51 ConsoleCommand* ccLoadMenu_; 49 52 }; 50 53 } -
code/branches/gui/src/orxonox/gamestates/GSLevel.cc
r2848 r2850 49 49 #include "LevelManager.h" 50 50 #include "PlayerManager.h" 51 #include "gui/GUIManager.h" 51 52 52 53 namespace orxonox … … 86 87 if (GameMode::showsGraphics()) 87 88 { 89 { 90 FunctorMember<GSLevel>* functor = createFunctor(&GSLevel::toggleGUI); 91 functor->setObject(this); 92 this->ccToggleGUI_ = createConsoleCommand(functor, "toggleGUI"); 93 CommandExecutor::addConsoleCommandShortcut(this->ccToggleGUI_); 94 } 95 88 96 inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("game"); 89 97 keyBinder_ = new KeyBinder(); … … 110 118 if (GameMode::showsGraphics()) 111 119 { 112 // TODO: insert slomo console command with113 // .accessLevel(AccessLevel::Offline).defaultValue(0, 1.0).axisParamIndex(0).isAxisRelative(false);114 115 120 // keybind console command 116 121 FunctorMember<GSLevel>* functor1 = createFunctor(&GSLevel::keybind); … … 125 130 InputManager::getInstance().setKeyDetectorCallback(std::string("keybind ") + keyDetectorCallbackCode_); 126 131 132 // InGame GUI test 133 GUIManager::getInstance().showGUI("inGameTest"); 134 127 135 // level is loaded: we can start capturing the input 128 136 InputManager::getInstance().requestEnterState("game"); … … 143 151 this->ccTkeybind_ = 0; 144 152 } 153 if (this->ccToggleGUI_) 154 { 155 delete this->ccToggleGUI_; 156 this->ccToggleGUI_ = 0; 157 } 158 145 159 146 160 // this call will delete every BaseObject! … … 219 233 220 234 delete this->startFile_; 235 } 236 237 void GSLevel::toggleGUI() 238 { 239 if (GameMode::showsGraphics()) 240 { 241 GUIManager::getInstance().executeCode("toggleGUI()"); 242 } 221 243 } 222 244 -
code/branches/gui/src/orxonox/gamestates/GSLevel.h
r2844 r2850 47 47 void update(const Clock& time); 48 48 49 void toggleGUI(); 50 49 51 protected: 50 52 void loadLevel(); … … 70 72 ConsoleCommand* ccKeybind_; 71 73 ConsoleCommand* ccTkeybind_; 72 74 ConsoleCommand* ccToggleGUI_; 73 75 }; 74 76 } -
code/branches/gui/src/orxonox/gamestates/GSMainMenu.cc
r2848 r2850 28 28 29 29 #include "OrxonoxStableHeaders.h" 30 #include "GS GUI.h"30 #include "GSMainMenu.h" 31 31 32 #include <OgreViewport.h> 32 //#include <OgreViewport.h> 33 #include <OgreSceneManager.h> 33 34 #include "core/Clock.h" 34 35 #include "core/ConsoleCommand.h" … … 37 38 #include "core/input/SimpleInputState.h" 38 39 #include "gui/GUIManager.h" 40 #include "objects/Scene.h" 39 41 #include "GraphicsManager.h" 40 42 41 43 namespace orxonox 42 44 { 43 AddGameState(GS GUI, "mainMenu");45 AddGameState(GSMainMenu, "mainMenu"); 44 46 45 GS GUI::GSGUI(const std::string& name)47 GSMainMenu::GSMainMenu(const std::string& name) 46 48 : GameState(name) 49 , inputState_(0) 47 50 { 48 51 } 49 52 50 GS GUI::~GSGUI()53 GSMainMenu::~GSMainMenu() 51 54 { 52 55 } 53 56 54 void GS GUI::activate()57 void GSMainMenu::activate() 55 58 { 56 guiManager_ = GUIManager::getInstancePtr(); 59 inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("mainMenu"); 60 inputState_->setHandler(GUIManager::getInstancePtr()); 61 inputState_->setJoyStickHandler(&InputManager::EMPTY_HANDLER); 62 63 // create an empty Scene 64 this->scene_ = new Scene(0); 65 // and a Camera 66 this->camera_ = this->scene_->getSceneManager()->createCamera("mainMenu/Camera"); 57 67 58 68 // show main menu 59 //guiManager_->loadScene("MainMenu");60 guiManager_->showGUI("MainMenu", 0);61 GraphicsManager::getInstance(). getViewport()->setCamera(guiManager_->getCamera());69 GUIManager::getInstance().showGUI("mainMenu"); 70 GUIManager::getInstance().setCamera(this->camera_); 71 GraphicsManager::getInstance().setCamera(this->camera_); 62 72 63 73 { 64 // time factor console command 65 FunctorMember<GSGUI>* functor = createFunctor(&GSGUI::startGame); 74 FunctorMember<GSMainMenu>* functor = createFunctor(&GSMainMenu::startGame); 66 75 functor->setObject(this); 67 76 this->ccStartGame_ = createConsoleCommand(functor, "startGame"); 68 77 CommandExecutor::addConsoleCommandShortcut(this->ccStartGame_); 69 78 } 79 80 InputManager::getInstance().requestEnterState("mainMenu"); 70 81 } 71 82 72 void GS GUI::deactivate()83 void GSMainMenu::deactivate() 73 84 { 85 InputManager::getInstance().requestLeaveState("game"); 86 InputManager::getInstance().requestDestroyState("game"); 87 74 88 if (this->ccStartGame_) 75 89 { … … 78 92 } 79 93 80 guiManager_->hideGUI();94 GUIManager::getInstance().executeCode("hideGUI()"); 81 95 } 82 96 83 void GS GUI::update(const Clock& time)97 void GSMainMenu::update(const Clock& time) 84 98 { 85 // tick CEGUI86 guiManager_->update(time);87 99 } 88 100 89 void GS GUI::startGame()101 void GSMainMenu::startGame() 90 102 { 91 103 // HACK - HACK 92 104 Game::getInstance().popState(); 93 Game::getInstance().requestState("standalone"); 94 Game::getInstance().requestState("level"); 105 Game::getInstance().requestStates("standalone, level"); 95 106 } 96 107 } -
code/branches/gui/src/orxonox/gamestates/GSMainMenu.h
r2844 r2850 27 27 */ 28 28 29 #ifndef _GS GUI_H__30 #define _GS GUI_H__29 #ifndef _GSMainMenu_H__ 30 #define _GSMainMenu_H__ 31 31 32 32 #include "OrxonoxPrereqs.h" 33 #include <OgrePrerequisites.h> 33 34 #include "core/GameState.h" 34 35 35 36 namespace orxonox 36 37 { 37 class _OrxonoxExport GS GUI: public GameState38 class _OrxonoxExport GSMainMenu : public GameState 38 39 { 39 40 public: 40 GS GUI(const std::string& name);41 ~GS GUI();41 GSMainMenu(const std::string& name); 42 ~GSMainMenu(); 42 43 43 44 void activate(); … … 48 49 49 50 private: 50 GUIManager* guiManager_; 51 SimpleInputState* inputState_; 52 Scene* scene_; 53 Ogre::Camera* camera_; 51 54 52 55 // console commands … … 55 58 } 56 59 57 #endif /* _GS GUI_H__ */60 #endif /* _GSMainMenu_H__ */ -
code/branches/gui/src/orxonox/gamestates/GSRoot.cc
r2848 r2850 44 44 { 45 45 AddGameState(GSRoot, "root"); 46 SetCommandLineSwitch(startWithConsole); 46 SetCommandLineSwitch(console); 47 // Shortcuts for easy direct loading 48 SetCommandLineSwitch(server); 49 SetCommandLineSwitch(client); 50 SetCommandLineSwitch(dedicated); 51 SetCommandLineSwitch(standalone); 47 52 48 53 GSRoot::GSRoot(const std::string& name) … … 63 68 { 64 69 // reset game speed to normal 65 t imeFactor_ = 1.0f;70 this->timeFactor_ = 1.0f; 66 71 67 72 { … … 81 86 } 82 87 88 // Load level directly? 89 bool loadLevel = false; 90 if (CommandLine::getValue("standalone").getBool()) 91 { 92 Game::getInstance().requestStates("graphics, standalone, level"); 93 loadLevel = true; 94 } 95 if (CommandLine::getValue("server").getBool()) 96 { 97 Game::getInstance().requestStates("graphics, server, level"); 98 loadLevel = true; 99 } 100 if (CommandLine::getValue("client").getBool()) 101 { 102 Game::getInstance().requestStates("graphics, standalone, level"); 103 loadLevel = true; 104 } 105 if (CommandLine::getValue("dedicated").getBool()) 106 { 107 Game::getInstance().requestStates("dedicated, level"); 108 loadLevel = true; 109 } 110 83 111 // Determine where to start 84 if (CommandLine::getValue("startWithConsole").getBool()) 85 { 86 // Start the game in the console 87 Game::getInstance().requestState("ioConsole"); 88 } 89 else 90 { 91 // Start in GUI main menu 92 Game::getInstance().requestState("graphics"); 93 Game::getInstance().requestState("mainMenu"); 94 } 95 112 if (!loadLevel) 113 { 114 if (CommandLine::getValue("console").getBool()) 115 { 116 // Start the game in the console without 3D graphics 117 Game::getInstance().requestState("ioConsole"); 118 } 119 else 120 { 121 // Start in GUI mode 122 Game::getInstance().requestStates("graphics, mainMenu"); 123 } 124 } 96 125 } 97 126 … … 113 142 void GSRoot::update(const Clock& time) 114 143 { 144 if (this->getActivity().topState) 145 { 146 // This state can not 'survive' on its own. 147 // Load a user interface therefore 148 Game::getInstance().requestState("ioConsole"); 149 } 150 115 151 uint64_t timeBeforeTick = time.getRealMicroseconds(); 116 152 … … 132 168 uint64_t timeAfterTick = time.getRealMicroseconds(); 133 169 134 // Also add our tick time to the list in GSRoot170 // Also add our tick time 135 171 Game::getInstance().addTickTime(timeAfterTick - timeBeforeTick); 136 172 }
Note: See TracChangeset
for help on using the changeset viewer.