Changeset 5876 for code/branches/core5/src
- Timestamp:
- Oct 4, 2009, 11:08:14 PM (15 years ago)
- Location:
- code/branches/core5/src
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core5/src/libraries/core/Core.cc
r5875 r5876 289 289 inputManager_.reset(new InputManager()); 290 290 291 // load the CEGUI interface291 // Load the CEGUI interface 292 292 guiManager_.reset(new GUIManager(graphicsManager_->getRenderWindow(), 293 293 inputManager_->getMousePosition(), graphicsManager_->isFullScreen())); … … 295 295 bGraphicsLoaded_ = true; 296 296 GameMode::bShowsGraphics_s = true; 297 298 // Load some sort of a debug overlay (only denoted by its name, "debug.oxo") 299 graphicsManager_->loadDebugOverlay(); 297 300 298 301 // Create singletons associated with graphics (in other libraries) -
code/branches/core5/src/libraries/core/GraphicsManager.cc
r5855 r5876 130 130 GraphicsManager::~GraphicsManager() 131 131 { 132 Loader::unload(debugOverlay_.get()); 133 132 134 Ogre::WindowEventUtilities::removeWindowEventListener(renderWindow_, ogreWindowEventListener_.get()); 133 135 // TODO: Destroy the console command … … 322 324 } 323 325 326 void GraphicsManager::loadDebugOverlay() 327 { 328 // Load debug overlay to show info about fps and tick time 329 COUT(4) << "Loading Debug Overlay..." << std::endl; 330 debugOverlay_.reset(new XMLFile("debug.oxo")); 331 Loader::open(debugOverlay_.get()); 332 } 333 334 /** 335 @note 336 A note about the Ogre::FrameListener: Even though we don't use them, 337 they still get called. However, the delta times are not correct (except 338 for timeSinceLastFrame, which is the most important). A little research 339 as shown that there is probably only one FrameListener that doesn't even 340 need the time. So we shouldn't run into problems. 341 */ 324 342 void GraphicsManager::update(const Clock& time) 325 343 { -
code/branches/core5/src/libraries/core/GraphicsManager.h
r5738 r5876 71 71 72 72 void upgradeToGraphics(); 73 void loadDebugOverlay(); 73 74 bool rendererLoaded() const { return renderWindow_ != NULL; } 74 75 … … 99 100 Ogre::Viewport* viewport_; //!< default full size viewport 100 101 101 // XML files for the resources 102 // XML files for the resources and the debug overlay 102 103 shared_ptr<XMLFile> resources_; //!< XML with resource locations 103 104 shared_ptr<XMLFile> extResources_; //!< XML with resource locations in the external path (only for dev runs) 105 shared_ptr<XMLFile> debugOverlay_; //!< XML with various debug overlays 104 106 105 107 // config values -
code/branches/core5/src/orxonox/gamestates/GSGraphics.cc
r5863 r5876 35 35 #include "GSGraphics.h" 36 36 37 #include "util/Clock.h"38 #include "util/Convert.h"39 37 #include "core/CommandExecutor.h" 40 38 #include "core/ConsoleCommand.h" 41 39 #include "core/Game.h" 42 40 #include "core/GUIManager.h" 43 #include "core/Loader.h"44 #include "core/XMLFile.h"45 46 41 // HACK: 47 42 #include "overlays/Map.h" … … 53 48 GSGraphics::GSGraphics(const GameStateInfo& info) 54 49 : GameState(info) 55 , debugOverlay_(0)56 50 { 57 51 } … … 65 59 This function is called when we enter this game state. 66 60 67 Since graphics is very important for our game this function does quite a lot: 68 \li starts graphics manager 69 \li loads debug overlay 70 \li manages render window 71 \li creates input manager 72 \li loads master key bindings 73 \li loads the SoundManager 74 \li loads ingame console 75 \li loads GUI interface (GUIManager) 76 \li creates console command to toggle GUI 61 There is only one thing to do here: 62 \li create console command to toggle GUI 77 63 */ 78 64 void GSGraphics::activate() 79 65 { 80 // load debug overlay81 COUT(3) << "Loading Debug Overlay..." << std::endl;82 this->debugOverlay_ = new XMLFile("debug.oxo");83 Loader::open(debugOverlay_);84 85 66 // add console command to toggle GUI 86 this->ccToggleGUI_ = createConsoleCommand(createFunctor(&GSGraphics::toggleGUI, this), "toggleGUI"); 87 CommandExecutor::addConsoleCommandShortcut(this->ccToggleGUI_); 67 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&GSGraphics::toggleGUI, this), "toggleGUI")); 88 68 } 89 69 … … 91 71 @brief 92 72 This function is called when the game state is left 93 94 Created references, input states and console commands are deleted.95 73 */ 96 74 void GSGraphics::deactivate() 97 75 { 98 /*99 if (this->ccToggleGUI_)100 {101 delete this->ccToggleGUI_;102 this->ccToggleGUI_ = 0;103 }104 */105 106 Loader::unload(this->debugOverlay_);107 delete this->debugOverlay_;108 109 76 // HACK: (destroys a resource smart pointer) 110 77 Map::hackDestroyMap(); … … 123 90 } 124 91 125 /**126 @note127 A note about the Ogre::FrameListener: Even though we don't use them,128 they still get called. However, the delta times are not correct (except129 for timeSinceLastFrame, which is the most important). A little research130 as shown that there is probably only one FrameListener that doesn't even131 need the time. So we shouldn't run into problems.132 */133 92 void GSGraphics::update(const Clock& time) 134 93 { -
code/branches/core5/src/orxonox/gamestates/GSGraphics.h
r5863 r5876 60 60 61 61 private: 62 XMLFile* debugOverlay_;63 ConsoleCommand* ccToggleGUI_; //!< Console command to toggle GUI64 62 }; 65 63 } -
code/branches/core5/src/orxonox/gamestates/GSIOConsole.cc
r5829 r5876 30 30 31 31 #include <iostream> 32 33 32 #include "core/ConsoleCommand.h" 33 #include "core/CommandExecutor.h" 34 34 #include "core/Game.h" 35 35 … … 49 49 void GSIOConsole::activate() 50 50 { 51 { 52 this->ccLoadMenu_ = createConsoleCommand(createFunctor(&GSIOConsole::loadMenu, this), "loadMenu"); 53 CommandExecutor::addConsoleCommandShortcut(this->ccLoadMenu_); 54 } 51 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&GSIOConsole::loadMenu, this), "loadMenu")); 55 52 } 56 53 57 54 void GSIOConsole::deactivate() 58 55 { 59 /*60 if (this->ccLoadMenu_)61 {62 delete this->ccLoadMenu_;63 this->ccLoadMenu_ = 0;64 }65 */66 56 } 67 57 -
code/branches/core5/src/orxonox/gamestates/GSIOConsole.h
r5842 r5876 47 47 private: 48 48 void loadMenu(); 49 50 // console commands51 ConsoleCommand* ccLoadMenu_;52 49 }; 53 50 } -
code/branches/core5/src/orxonox/gamestates/GSLevel.cc
r5863 r5876 37 37 #include "core/input/KeyBinderManager.h" 38 38 #include "core/ConsoleCommand.h" 39 #include "core/ConfigValueIncludes.h"40 #include "core/CoreIncludes.h"41 39 #include "core/Game.h" 42 40 #include "core/GameMode.h" … … 51 49 { 52 50 DeclareGameState(GSLevel, "level", false, false); 53 SetConsoleCommand(GSLevel, showIngameGUI, true);54 55 XMLFile* GSLevel::startFile_s = NULL;56 51 57 52 GSLevel::GSLevel(const GameStateInfo& info) … … 60 55 , guiMouseOnlyInputState_(0) 61 56 , guiKeysOnlyInputState_(0) 57 , startFile_(0) 62 58 { 63 RegisterObject(GSLevel);64 59 } 65 60 … … 68 63 } 69 64 70 void GSLevel::setConfigValues()71 {72 }73 74 65 void GSLevel::activate() 75 66 { 76 setConfigValues();77 78 67 if (GameMode::showsGraphics()) 79 68 { … … 87 76 guiKeysOnlyInputState_ = InputManager::getInstance().createInputState("guiKeysOnly"); 88 77 guiKeysOnlyInputState_->setKeyHandler(GUIManager::getInstancePtr()); 78 79 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&GSLevel::showIngameGUI, this), "showIngameGUI")); 89 80 } 90 81 … … 129 120 // unload all compositors (this is only necessary because we don't yet destroy all resources!) 130 121 Ogre::CompositorManager::getSingleton().removeAll(); 131 }132 122 133 // this call will delete every BaseObject!134 // But currently this will call methods of objects that exist no more135 // The only 'memory leak' is the ParticleSpawer. They would be deleted here136 // and call a sceneNode method that has already been destroy by the corresponding space ship.137 //Loader::close();138 139 if (GameMode::showsGraphics())140 {141 123 InputManager::getInstance().leaveState("game"); 142 124 } … … 158 140 void GSLevel::update(const Clock& time) 159 141 { 160 // Note: Temporarily moved to GS Graphics.142 // Note: Temporarily moved to GSRoot. 161 143 //// Call the scene objects 162 144 //for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it) … … 168 150 // call the loader 169 151 COUT(0) << "Loading level..." << std::endl; 170 startFile_ s= new XMLFile(LevelManager::getInstance().getDefaultLevel());171 Loader::open(startFile_ s);152 startFile_ = new XMLFile(LevelManager::getInstance().getDefaultLevel()); 153 Loader::open(startFile_); 172 154 } 173 155 174 156 void GSLevel::unloadLevel() 175 157 { 176 Loader::unload(startFile_s); 177 178 delete startFile_s; 158 Loader::unload(startFile_); 159 delete startFile_; 179 160 } 180 161 } -
code/branches/core5/src/orxonox/gamestates/GSLevel.h
r5863 r5876 38 38 namespace orxonox 39 39 { 40 class _OrxonoxExport GSLevel : public GameState , public OrxonoxClass40 class _OrxonoxExport GSLevel : public GameState 41 41 { 42 42 public: 43 43 GSLevel(const GameStateInfo& info); 44 44 ~GSLevel(); 45 void setConfigValues();46 45 47 46 void activate(); … … 49 48 void update(const Clock& time); 50 49 51 static void showIngameGUI(bool show);52 53 static XMLFile* startFile_s;54 55 50 protected: 56 51 void loadLevel(); 57 52 void unloadLevel(); 53 void showIngameGUI(bool show); 58 54 59 55 InputState* gameInputState_; //!< input state for normal ingame playing 60 56 InputState* guiMouseOnlyInputState_; //!< input state if we only need the mouse to use the GUI 61 57 InputState* guiKeysOnlyInputState_; //!< input state if we only need the keys to use the GUI 58 59 XMLFile* startFile_; 62 60 }; 63 61 } -
code/branches/core5/src/orxonox/gamestates/GSMainMenu.cc
r5863 r5876 31 31 #include <OgreSceneManager.h> 32 32 33 #include "util/Clock.h"34 33 #include "core/input/InputManager.h" 35 34 #include "core/input/InputState.h" … … 57 56 58 57 // create an empty Scene 59 this->scene_ = new Scene( 0);58 this->scene_ = new Scene(NULL); 60 59 // and a Camera 61 60 this->camera_ = this->scene_->getSceneManager()->createCamera("mainMenu/Camera"); 61 // Load sound 62 this->ambient_ = new SoundMainMenu(); 62 63 } 63 64 … … 77 78 GraphicsManager::getInstance().setCamera(this->camera_); 78 79 79 this->ccStartStandalone_ = createConsoleCommand(createFunctor(&GSMainMenu::startStandalone, this), "startGame"); 80 CommandExecutor::addConsoleCommandShortcut(this->ccStartStandalone_); 81 this->ccStartServer_ = createConsoleCommand(createFunctor(&GSMainMenu::startServer, this), "startServer"); 82 CommandExecutor::addConsoleCommandShortcut(this->ccStartServer_); 83 this->ccStartClient_ = createConsoleCommand(createFunctor(&GSMainMenu::startClient, this), "startClient"); 84 CommandExecutor::addConsoleCommandShortcut(this->ccStartClient_); 85 this->ccStartDedicated_ = createConsoleCommand(createFunctor(&GSMainMenu::startDedicated, this), "startDedicated"); 86 CommandExecutor::addConsoleCommandShortcut(this->ccStartDedicated_); 87 this->ccStartMainMenu_ = createConsoleCommand(createFunctor(&GSMainMenu::startMainMenu, this), "startMainMenu"); 88 CommandExecutor::addConsoleCommandShortcut(this->ccStartMainMenu_); 80 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&GSMainMenu::startStandalone, this), "startGame")); 81 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&GSMainMenu::startServer, this), "startServer")); 82 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&GSMainMenu::startClient, this), "startClient")); 83 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&GSMainMenu::startDedicated, this), "startDedicated")); 84 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&GSMainMenu::startMainMenu, this), "startMainMenu")); 89 85 90 86 KeyBinderManager::getInstance().setToDefault(); 91 87 InputManager::getInstance().enterState("mainMenu"); 92 88 93 this->ambient_ = new SoundMainMenu();94 89 this->ambient_->play(true); 95 90 } … … 97 92 void GSMainMenu::deactivate() 98 93 { 99 this->ambient_-> destroy();94 this->ambient_->stop(); 100 95 101 96 InputManager::getInstance().leaveState("mainMenu"); … … 103 98 GUIManager::getInstance().setCamera(0); 104 99 GraphicsManager::getInstance().setCamera(0); 105 106 /*107 if (this->ccStartGame_)108 {109 delete this->ccStartGame_;110 this->ccStartGame_ = 0;111 }112 */113 100 } 114 101 -
code/branches/core5/src/orxonox/gamestates/GSMainMenu.h
r5842 r5876 58 58 Ogre::Camera* camera_; 59 59 60 // console commands61 ConsoleCommand* ccStartStandalone_;62 ConsoleCommand* ccStartServer_;63 ConsoleCommand* ccStartClient_;64 ConsoleCommand* ccStartDedicated_;65 ConsoleCommand* ccStartMainMenu_;66 67 60 // ambient sound for the main menu 68 61 SoundMainMenu* ambient_; -
code/branches/core5/src/orxonox/gamestates/GSRoot.cc
r5855 r5876 48 48 , timeFactorPauseBackup_(1.0f) 49 49 { 50 this->ccSetTimeFactor_ = 0;51 this->ccPause_ = 0;52 50 } 53 51 … … 63 61 64 62 // time factor console command 65 this->ccSetTimeFactor_= createConsoleCommand(createFunctor(&GSRoot::setTimeFactor, this), "setTimeFactor");66 CommandExecutor::addConsoleCommandShortcut( this->ccSetTimeFactor_).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);63 ConsoleCommand* command = createConsoleCommand(createFunctor(&GSRoot::setTimeFactor, this), "setTimeFactor"); 64 CommandExecutor::addConsoleCommandShortcut(command).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0); 67 65 68 66 // time factor console command 69 this->ccPause_= createConsoleCommand(createFunctor(&GSRoot::pause, this), "pause");70 CommandExecutor::addConsoleCommandShortcut( this->ccPause_).accessLevel(AccessLevel::Offline);67 command = createConsoleCommand(createFunctor(&GSRoot::pause, this), "pause"); 68 CommandExecutor::addConsoleCommandShortcut(command).accessLevel(AccessLevel::Offline); 71 69 } 72 70 73 71 void GSRoot::deactivate() 74 72 { 75 /*76 if (this->ccSetTimeFactor_)77 {78 delete this->ccSetTimeFactor_;79 this->ccSetTimeFactor_ = 0;80 }81 82 if (this->ccPause_)83 {84 delete this->ccPause_;85 this->ccPause_ = 0;86 }87 */88 73 } 89 74 -
code/branches/core5/src/orxonox/gamestates/GSRoot.h
r5850 r5876 55 55 bool bPaused_; 56 56 float timeFactorPauseBackup_; 57 58 // console commands59 ConsoleCommand* ccSetTimeFactor_;60 ConsoleCommand* ccPause_;61 57 }; 62 58 }
Note: See TracChangeset
for help on using the changeset viewer.