Changeset 1662
- Timestamp:
- Aug 19, 2008, 8:12:15 PM (16 years ago)
- Location:
- code/branches/gui/src
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/gui/src/core/ConsoleCommand.cc
r1505 r1662 31 31 namespace orxonox 32 32 { 33 ConsoleCommand::ConsoleCommand(Functor Static* functor, const std::string& name) : ExecutorStatic(functor, name)33 ConsoleCommand::ConsoleCommand(Functor* functor, const std::string& name) : Executor(functor, name) 34 34 { 35 35 this->accessLevel_ = AccessLevel::None; -
code/branches/gui/src/core/ConsoleCommand.h
r1549 r1662 70 70 } 71 71 72 class _CoreExport ConsoleCommand : public Executor Static72 class _CoreExport ConsoleCommand : public Executor 73 73 { 74 74 public: 75 ConsoleCommand(Functor Static* functor, const std::string& name = "");75 ConsoleCommand(Functor* functor, const std::string& name = ""); 76 76 77 77 inline ConsoleCommand& setDescription(const std::string& description) 78 { this->Executor Static::setDescription(description); return (*this); }78 { this->Executor::setDescription(description); return (*this); } 79 79 inline ConsoleCommand& setDescriptionParam(int param, const std::string& description) 80 { this->Executor Static::setDescriptionParam(param, description); return (*this); }80 { this->Executor::setDescriptionParam(param, description); return (*this); } 81 81 inline ConsoleCommand& setDescriptionReturnvalue(const std::string& description) 82 { this->Executor Static::setDescriptionReturnvalue(description); return (*this); }82 { this->Executor::setDescriptionReturnvalue(description); return (*this); } 83 83 inline ConsoleCommand& setDefaultValues(const MultiTypeMath& param1) 84 { this->Executor Static::setDefaultValues(param1); return (*this); }84 { this->Executor::setDefaultValues(param1); return (*this); } 85 85 inline ConsoleCommand& setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2) 86 { this->Executor Static::setDefaultValues(param1, param2); return (*this); }86 { this->Executor::setDefaultValues(param1, param2); return (*this); } 87 87 inline ConsoleCommand& setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3) 88 { this->Executor Static::setDefaultValues(param1, param2, param3); return (*this); }88 { this->Executor::setDefaultValues(param1, param2, param3); return (*this); } 89 89 inline ConsoleCommand& setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4) 90 { this->Executor Static::setDefaultValues(param1, param2, param3, param4); return (*this); }90 { this->Executor::setDefaultValues(param1, param2, param3, param4); return (*this); } 91 91 inline ConsoleCommand& setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4, const MultiTypeMath& param5) 92 { this->Executor Static::setDefaultValues(param1, param2, param3, param4, param5); return (*this); }92 { this->Executor::setDefaultValues(param1, param2, param3, param4, param5); return (*this); } 93 93 inline ConsoleCommand& setDefaultValue(unsigned int index, const MultiTypeMath& param) 94 { this->Executor Static::setDefaultValue(index, param); return (*this); }94 { this->Executor::setDefaultValue(index, param); return (*this); } 95 95 96 96 inline ConsoleCommand& setAccessLevel(AccessLevel::Level level) … … 135 135 }; 136 136 137 inline ConsoleCommand* createConsoleCommand(Functor Static* functor, const std::string& name = "")137 inline ConsoleCommand* createConsoleCommand(Functor* functor, const std::string& name = "") 138 138 { 139 139 return new ConsoleCommand(functor, name); -
code/branches/gui/src/orxonox/Orxonox.cc
r1661 r1662 88 88 namespace orxonox 89 89 { 90 SetConsoleCommand(Orxonox, exit, true).setKeybindMode(KeybindMode::OnPress);91 SetConsoleCommand(Orxonox, slomo, true).setAccessLevel(AccessLevel::Offline).setDefaultValue(0, 1.0).setAxisParamIndex(0).setIsAxisRelative(false);92 SetConsoleCommand(Orxonox, setTimeFactor, true).setAccessLevel(AccessLevel::Offline).setDefaultValue(0, 1.0);93 SetConsoleCommand(Orxonox, loadGame, true).setAccessLevel(AccessLevel::User).setDefaultValue(0, "standalone");90 //SetConsoleCommand(Orxonox, exit, true).setKeybindMode(KeybindMode::OnPress); 91 //SetConsoleCommand(Orxonox, slomo, true).setAccessLevel(AccessLevel::Offline).setDefaultValue(0, 1.0).setAxisParamIndex(0).setIsAxisRelative(false); 92 //SetConsoleCommand(Orxonox, setTimeFactor, true).setAccessLevel(AccessLevel::Offline).setDefaultValue(0, 1.0); 93 //SetConsoleCommand(Orxonox, loadGame, true).setAccessLevel(AccessLevel::User).setDefaultValue(0, "standalone"); 94 94 95 95 /** -
code/branches/gui/src/orxonox/gamestates/GSGUI.cc
r1661 r1662 33 33 #include "core/input/InputManager.h" 34 34 #include "core/input/SimpleInputState.h" 35 #include "core/input/KeyBinder.h"36 #include "overlays/console/InGameConsole.h"37 35 #include "gui/GUIManager.h" 38 36 -
code/branches/gui/src/orxonox/gamestates/GSGraphics.cc
r1661 r1662 35 35 #include <OgreWindowEventUtilities.h> 36 36 37 #include "core/ConsoleCommand.h" 38 #include "core/ConfigValueIncludes.h" 37 39 #include "core/input/InputManager.h" 38 #include "core/input/SimpleInputState.h"39 #include "core/input/KeyBinder.h"40 40 #include "core/Core.h" 41 42 #include "GraphicsEngine.h"43 41 #include "overlays/console/InGameConsole.h" 44 42 #include "gui/GUIManager.h" 43 #include "GraphicsEngine.h" 45 44 46 45 namespace orxonox … … 88 87 guiManager_ = new GUIManager(); 89 88 guiManager_->initialise(); 89 90 // use the ogre timer class to measure time. 91 timer_ = new Ogre::Timer(); 92 93 // add console commands 94 FunctorMember<GSGraphics>* functor = createFunctor(&GSGraphics::exitGame); 95 functor->setObject(this); 96 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "exit")); 90 97 } 91 98 92 99 void GSGraphics::leave() 93 100 { 94 if (this->guiManager_) 95 delete guiManager_; 96 97 if (this->console_) 98 delete this->console_; 99 100 if (inputManager_) 101 delete inputManager_; 102 103 // TODO: deintialise graphics 104 } 105 101 delete this->timer_; 102 103 delete this->guiManager_; 104 105 delete this->console_; 106 107 delete this->inputManager_; 108 109 // TODO: destroy render window 110 } 111 112 /** 113 Main loop of the orxonox game. 114 We use the Ogre::Timer to measure time since it uses the most precise 115 method an a platform (however the windows timer lacks time when under 116 heavy kernel load!). 117 There is a simple mechanism to measure the average time spent in our 118 ticks as it may indicate performance issues. 119 A note about the Ogre::FrameListener: Even though we don't use them, 120 they still get called. However, the delta times are not correct (except 121 for timeSinceLastFrame, which is the most important). A little research 122 as shown that there is probably only one FrameListener that doesn't even 123 need the time. So we shouldn't run into problems. 124 */ 106 125 bool GSGraphics::tick(float dt) 107 126 { 127 // note: paramter 'dt' is of no meaning 128 108 129 Ogre::Root& ogreRoot = Ogre::Root::getSingleton(); 109 110 // use the ogre timer class to measure time.111 if (!timer_)112 timer_ = new Ogre::Timer();113 130 114 131 unsigned long frameCount = 0; … … 146 163 this->getActiveChild()->tick(dt); 147 164 165 // tick console 166 this->console_->tick(dt); 167 148 168 // get current time once again 149 169 timeAfterTick = timer_->getMicroseconds(); -
code/branches/gui/src/orxonox/gamestates/GSGraphics.h
r1661 r1662 31 31 32 32 #include "OrxonoxPrereqs.h" 33 #include <OgrePrerequisites.h> 33 34 #include "core/GameState.h" 35 #include "core/OrxonoxClass.h" 34 36 35 37 namespace orxonox … … 43 45 bool tick(float dt); 44 46 void setConfigValues(); 47 48 void exitGame() { this->bAbort_ = true; } 45 49 46 50 private: -
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 } -
code/branches/gui/src/orxonox/gamestates/GSLevel.h
r1661 r1662 49 49 void setTimeFactor(float factor); 50 50 51 float timefactor_; //!< A factor to change the gamespeed 51 float timefactor_; //!< A factor to change the gamespeed 52 53 KeyBinder* keyBinder_; //!< tool that loads and manages the input bindings 54 Radar* radar_; //!< represents the Radar (not the HUD part) 55 Level* startLevel_; //!< current hard coded default level 56 Level* hud_; //!< 'level' object fo the HUD 52 57 }; 53 58 } -
code/branches/gui/src/orxonox/gamestates/GSRoot.cc
r1661 r1662 30 30 #include "GSRoot.h" 31 31 32 #include <cassert>33 32 #include "core/Factory.h" 34 33 #include "core/ConfigFileManager.h" … … 36 35 #include "core/ConsoleCommand.h" 37 36 #include "core/Debug.h" 38 //#include "core/Exception.h"37 #include "core/Exception.h" 39 38 #include "core/TclBind.h" 40 39 #include "core/Core.h" … … 65 64 Factory::createClassHierarchy(); 66 65 67 // TODO: config values68 //setConfigValues();69 70 66 const Settings::CommandLineArgument* dataPath = Settings::getCommandLineArgument("dataPath"); 71 67 assert(dataPath); … … 81 77 TclBind::getInstance().setDataPath(Settings::getDataPath()); 82 78 79 // initialise graphics engine. Doesn't load the render window yet! 83 80 graphicsEngine_ = new GraphicsEngine(); 84 81 graphicsEngine_->setup(); // creates ogre root and other essentials 85 82 83 // console commands 84 FunctorMember<GSRoot>* functor = createFunctor(&GSRoot::loadGame); 85 functor->setObject(this); 86 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "loadGame")); 86 87 } 87 88 … … 98 99 return true; 99 100 } 101 102 /** 103 @brief 104 Requests a state. 105 */ 106 void GSRoot::loadGame(const std::string& name) 107 { 108 this->requestState(name); 109 } 100 110 } -
code/branches/gui/src/orxonox/gamestates/GSRoot.h
r1661 r1662 42 42 43 43 bool tick(float dt); 44 void loadGame(const std::string& name); 44 45 45 46 private: -
code/branches/gui/src/orxonox/gui/GUIManager.cc
r1661 r1662 163 163 // load the background scene 164 164 loadScenes(); 165 //CEGUI::KeyEventArgs e; 166 //e.codepoint 165 167 } 166 168 catch (CEGUI::Exception& ex) -
code/branches/gui/src/orxonox/objects/Backlight.cc
r1654 r1662 68 68 this->ribbonTrail_->setMaterialName("Trail/backlighttrail"); 69 69 70 this->setTimeFactor(Orxonox::getInstance().getTimeFactor()); 70 //this->setTimeFactor(Orxonox::getInstance().getTimeFactor()); 71 this->setTimeFactor(1.0f); 71 72 } 72 73 -
code/branches/gui/src/orxonox/overlays/console/InGameConsole.h
r1642 r1662 37 37 38 38 #include "core/Shell.h" 39 #include " objects/Tickable.h"39 #include "core/OrxonoxClass.h" 40 40 #include "tools/WindowEventListener.h" 41 41 … … 43 43 namespace orxonox 44 44 { 45 class _OrxonoxExport InGameConsole : public TickableReal, public ShellListener, public WindowEventListener45 class _OrxonoxExport InGameConsole : virtual public OrxonoxClass, public ShellListener, public WindowEventListener 46 46 { 47 47 public: // functions -
code/branches/gui/src/orxonox/tools/ParticleInterface.cc
r1654 r1662 56 56 this->detaillevel_ = (unsigned int)detaillevel; 57 57 this->particleSystem_ = GraphicsEngine::getInstance().getLevelSceneManager()->createParticleSystem("particles" + getConvertedValue<unsigned int, std::string>(ParticleInterface::counter_s++), templateName); 58 this->particleSystem_->setSpeedFactor(Orxonox::getInstance().getTimeFactor()); 58 //this->particleSystem_->setSpeedFactor(Orxonox::getInstance().getTimeFactor()); 59 this->particleSystem_->setSpeedFactor(1.0f); 59 60 60 61 if (GraphicsEngine::getInstance().getDetailLevelParticle() < (unsigned int)this->detaillevel_) … … 171 172 void ParticleInterface::setSpeedFactor(float factor) 172 173 { 173 this->particleSystem_->setSpeedFactor(Orxonox::getInstance().getTimeFactor() * factor); 174 //this->particleSystem_->setSpeedFactor(Orxonox::getInstance().getTimeFactor() * factor); 175 this->particleSystem_->setSpeedFactor(1.0f * factor); 174 176 } 175 177 float ParticleInterface::getSpeedFactor() const 176 178 { 177 return (this->particleSystem_->getSpeedFactor() / Orxonox::getInstance().getTimeFactor()); 179 //return (this->particleSystem_->getSpeedFactor() / Orxonox::getInstance().getTimeFactor()); 180 return (this->particleSystem_->getSpeedFactor() / 1.0f); 178 181 } 179 182
Note: See TracChangeset
for help on using the changeset viewer.