Changeset 1662 for code/branches/gui/src/orxonox/gamestates/GSLevel.cc
- Timestamp:
- Aug 19, 2008, 8:12:15 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/gui/src/orxonox/gamestates/GSLevel.cc
r1661 r1662 23 23 * Reto Grieder 24 24 * Co-authors: 25 * ...25 * Fabian 'x3n' Landau 26 26 * 27 27 */ … … 30 30 #include "GSLevel.h" 31 31 32 #include "GraphicsEngine.h"33 32 #include "core/ConsoleCommand.h" 34 33 #include "core/input/InputManager.h" 35 34 #include "core/input/SimpleInputState.h" 36 35 #include "core/input/KeyBinder.h" 36 #include "core/Loader.h" 37 37 #include "overlays/console/InGameConsole.h" 38 38 #include "gui/GUIManager.h" 39 #include "objects/Backlight.h" 40 #include "tools/ParticleInterface.h" 41 #include "Radar.h" 42 #include "Settings.h" 43 #include "GraphicsEngine.h" 39 44 40 45 namespace orxonox … … 43 48 : GameState("level") 44 49 , timefactor_(1.0f) 50 , keyBinder_(0) 51 , radar_(0) 52 , startLevel_(0) 53 , hud_(0) 45 54 { 46 55 } … … 52 61 void GSLevel::enter() 53 62 { 54 KeyBinder* keyBinder = new KeyBinder(); 55 keyBinder->loadBindings(); 56 InputManager::getInstance().createInputState<SimpleInputState>("game", 20)->setHandler(keyBinder); 63 keyBinder_ = new KeyBinder(); 64 keyBinder_->loadBindings(); 65 InputManager::getInstance().createInputState<SimpleInputState>("game", 20)->setHandler(keyBinder_); 66 67 // create Ogre SceneManager for the level 68 GraphicsEngine::getInstance().createNewScene(); 69 70 // Start the Radar 71 this->radar_ = new Radar(); 72 73 // Load the HUD 74 COUT(3) << "Orxonox: Loading HUD" << std::endl; 75 hud_ = new Level(Settings::getDataPath() + "overlay/hud.oxo"); 76 Loader::load(hud_); 77 78 // call the loader 79 COUT(0) << "Loading level..." << std::endl; 80 startLevel_ = new Level(Settings::getDataPath() + "levels/sample.oxw"); 81 Loader::open(startLevel_); 57 82 58 83 // add console commands 59 //ConsoleCommand* command = createConsoleCommand(createFunctor(&classname::function), ) 60 //CommandExecutor::addConsoleCommandShortcut(command); 84 FunctorMember<GSLevel>* functor = createFunctor(&GSLevel::setTimeFactor); 85 functor->setObject(this); 86 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "setTimeFactor")); 87 88 // level is loaded: we can start capturing the input 89 InputManager::getInstance().requestEnterState("game"); 61 90 } 62 91 63 92 void GSLevel::leave() 64 93 { 94 InputManager::getInstance().requestLeaveState("game"); 95 96 // TODO: Remove and destroy console command 97 98 Loader::unload(startLevel_); 99 delete this->startLevel_; 100 101 Loader::unload(hud_); 102 delete this->hud_; 103 104 // this call will delete every BaseObject! 105 // But currently this will call methods of objects that exist no more 106 // The only 'memory leak' is the ParticleSpawer. They would be deleted here 107 // and call a sceneNode method that has already been destroy by the corresponding space ship. 108 //Loader::close(); 109 110 delete this->radar_; 111 112 // TODO: delete SceneManager 113 114 InputManager::getInstance().destroyState("game"); 115 delete this->keyBinder_; 65 116 } 66 117 … … 74 125 it->tick(dt * this->timefactor_); 75 126 127 // TODO: split file into server/client/standalone 76 128 // call server/client with normal dt 77 129 //if (client_g) … … 87 139 Changes the speed of Orxonox 88 140 */ 89 //void GSLevel::setTimeFactor(float factor)90 //{91 // float change = factor / Orxonox::getInstance().getTimeFactor();92 // Orxonox::getInstance().timefactor_ = factor;93 //for (Iterator<ParticleInterface> it = ObjectList<ParticleInterface>::begin(); it; ++it)94 //it->setSpeedFactor(it->getSpeedFactor() * change);141 void GSLevel::setTimeFactor(float factor) 142 { 143 float change = factor / this->timefactor_; 144 this->timefactor_ = factor; 145 for (Iterator<ParticleInterface> it = ObjectList<ParticleInterface>::begin(); it; ++it) 146 it->setSpeedFactor(it->getSpeedFactor() * change); 95 147 96 //for (Iterator<Backlight> it = ObjectList<Backlight>::begin(); it; ++it)97 // it->setTimeFactor(Orxonox::getInstance().getTimeFactor());98 //}148 for (Iterator<Backlight> it = ObjectList<Backlight>::begin(); it; ++it) 149 it->setTimeFactor(timefactor_); 150 } 99 151 }
Note: See TracChangeset
for help on using the changeset viewer.