Changeset 2896 for code/trunk/src/orxonox
- Timestamp:
- Apr 6, 2009, 1:59:00 AM (16 years ago)
- Location:
- code/trunk
- Files:
-
- 4 deleted
- 115 edited
- 6 copied
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/gui merged: 2796,2798-2801,2805,2807-2808,2811,2814-2817,2834,2840-2850,2853-2854,2859,2862-2863,2869,2875,2887,2892
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/CMakeLists.txt
r2748 r2896 20 20 SET_SOURCE_FILES(ORXONOX_SRC_FILES 21 21 CameraManager.cc 22 Graphics Engine.cc22 GraphicsManager.cc 23 23 LevelManager.cc 24 24 Main.cc -
code/trunk/src/orxonox/CameraManager.cc
- Property svn:mergeinfo changed
/code/branches/gui/src/orxonox/CameraManager.cc (added) merged: 2834,2848,2850
r2893 r2896 35 35 #include <OgreResource.h> 36 36 37 #include "core/ Core.h"37 #include "core/GameMode.h" 38 38 #include "core/Iterator.h" 39 39 #include "objects/worldentities/Camera.h" … … 41 41 #include "tools/Shader.h" 42 42 #include "util/String.h" 43 #include "gui/GUIManager.h" 43 44 44 45 namespace orxonox … … 74 75 void CameraManager::requestFocus(Camera* camera) 75 76 { 76 if (! Core::showsGraphics())77 if (!GameMode::showsGraphics()) 77 78 return; 78 79 … … 99 100 void CameraManager::releaseFocus(Camera* camera) 100 101 { 101 if (! Core::showsGraphics())102 if (!GameMode::showsGraphics()) 102 103 return; 103 104 … … 141 142 142 143 this->viewport_->setCamera(camera); 144 GUIManager::getInstance().setCamera(camera); 143 145 144 146 // reactivate all visible compositors - Property svn:mergeinfo changed
-
code/trunk/src/orxonox/CameraManager.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/orxonox/Main.cc
r2873 r2896 38 38 39 39 #include "OrxonoxStableHeaders.h" 40 #include "OrxonoxConfig.h" 40 41 41 #include <exception> 42 #include <cassert> 42 #include "util/Debug.h" 43 #include "core/Identifier.h" 44 #include "core/Game.h" 43 45 44 #include "OrxonoxConfig.h" 45 #include "util/Debug.h" 46 #include "util/SignalHandler.h" 47 #include "core/ConfigFileManager.h" 48 #include "core/CommandLine.h" 49 #include "core/CommandExecutor.h" 50 #include "core/Identifier.h" 51 #include "core/Core.h" 52 #include "core/Language.h" 53 54 #include "gamestates/GSRoot.h" 55 #include "gamestates/GSGraphics.h" 56 #include "gamestates/GSStandalone.h" 57 #include "gamestates/GSServer.h" 58 #include "gamestates/GSClient.h" 59 #include "gamestates/GSDedicated.h" 60 #include "gamestates/GSGUI.h" 61 #include "gamestates/GSIOConsole.h" 62 63 #ifdef ORXONOX_PLATFORM_APPLE 64 #include <CoreFoundation/CoreFoundation.h> 65 66 // This function will locate the path to our application on OS X, 67 // unlike windows you can not rely on the curent working directory 68 // for locating your configuration files and resources. 69 std::string macBundlePath() 70 { 71 char path[1024]; 72 CFBundleRef mainBundle = CFBundleGetMainBundle(); 73 assert(mainBundle); 74 75 CFURLRef mainBundleURL = CFBundleCopyBundleURL(mainBundle); 76 assert(mainBundleURL); 77 78 CFStringRef cfStringRef = CFURLCopyFileSystemPath( mainBundleURL, kCFURLPOSIXPathStyle); 79 assert(cfStringRef); 80 81 CFStringGetCString(cfStringRef, path, 1024, kCFStringEncodingASCII); 82 83 CFRelease(mainBundleURL); 84 CFRelease(cfStringRef); 85 86 return std::string(path); 87 } 88 #endif 89 90 91 SetCommandLineArgument(settingsFile, "orxonox.ini"); 92 SetCommandLineArgument(configFileDirectory, ""); 93 46 /* 47 @brief 48 Main method. Game starts here (except for static initialisations). 49 */ 94 50 int main(int argc, char** argv) 95 51 { 96 using namespace orxonox; 52 { 53 orxonox::Game orxonox(argc, argv); 97 54 98 // Parse command line arguments 99 try 100 { 101 CommandLine::parseAll(argc, argv); 102 } 103 catch (ArgumentException& ex) 104 { 105 COUT(1) << ex.what() << std::endl; 106 COUT(0) << "Usage:" << std::endl << "orxonox " << CommandLine::getUsageInformation() << std::endl; 107 } 55 orxonox.setStateHierarchy( 56 "root" 57 " graphics" 58 " mainMenu" 59 " standalone" 60 " level" 61 " server" 62 " level" 63 " client" 64 " level" 65 " dedicated" 66 " level" 67 " ioConsole" 68 ); 108 69 109 // Do this after parsing the command line to allow customisation 110 Core::postMainInitialisation(); 111 112 // create a signal handler (only active for linux) 113 SignalHandler signalHandler; 114 signalHandler.doCatch(argv[0], Core::getLogPathString() + "orxonox_crash.log"); 115 116 // Create the ConfigFileManager before creating the GameStates in order to have 117 // setConfigValues() in the constructor (required). 118 ConfigFileManager* configFileManager = new ConfigFileManager(); 119 configFileManager->setFilename(ConfigFileType::Settings, CommandLine::getValue("settingsFile").getString()); 120 // create the Core settings to configure the output level 121 Language* language = new Language(); 122 Core* core = new Core(); 123 124 // put GameStates in its own scope so we can destroy the identifiers at the end of main(). 125 { 126 // create the gamestates 127 GSRoot root; 128 GSGraphics graphics; 129 GSStandalone standalone; 130 GSServer server; 131 GSClient client; 132 GSDedicated dedicated; 133 GSGUI gui; 134 GSIOConsole ioConsole; 135 136 // make the hierarchy 137 root.addChild(&graphics); 138 graphics.addChild(&standalone); 139 graphics.addChild(&server); 140 graphics.addChild(&client); 141 graphics.addChild(&gui); 142 root.addChild(&ioConsole); 143 root.addChild(&dedicated); 144 145 // Here happens the game 146 root.start(); 147 } 148 149 // destroy singletons 150 delete core; 151 delete language; 152 delete configFileManager; 70 orxonox.run(); 71 } // orxonox gets destroyed right here! 153 72 154 73 // Clean up class hierarchy stuff (identifiers, xmlport, configvalue, consolecommand) 155 Identifier::destroyAllIdentifiers(); 156 // destroy command line arguments 157 CommandLine::destroyAllArguments(); 158 // Also delete external console command that don't belong to an Identifier 159 CommandExecutor::destroyExternalCommands(); 74 // Needs to be done after Game destructor because of ~OrxonoxClass 75 orxonox::Identifier::destroyAllIdentifiers(); 160 76 161 77 return 0; -
code/trunk/src/orxonox/OrxonoxPrereqs.h
r2893 r2896 77 77 namespace MunitionType 78 78 { 79 80 81 82 79 enum Enum 83 80 { laserGunMunition }; … … 97 94 98 95 99 class GraphicsEngine; 96 class GraphicsManager; 97 class OgreWindowEventListener; 100 98 class Settings; 101 99 … … 250 248 //gui 251 249 class GUIManager; 252 253 // game states254 class GSRoot;255 class GSGraphics;256 class GSIO;257 class GSIOConsole;258 class GSLevel;259 class GSStandalone;260 class GSServer;261 class GSClient;262 class GSGUI;263 250 } 264 251 -
code/trunk/src/orxonox/PlayerManager.cc
r2662 r2896 31 31 32 32 #include "LevelManager.h" 33 #include "core/ Core.h"33 #include "core/GameMode.h" 34 34 #include "core/CoreIncludes.h" 35 35 #include "objects/Level.h" … … 58 58 void PlayerManager::clientConnected(unsigned int clientID) 59 59 { 60 if ( Core::isMaster())60 if (GameMode::isMaster()) 61 61 { 62 62 COUT(3) << "client connected" << std::endl; … … 77 77 void PlayerManager::clientDisconnected(unsigned int clientID) 78 78 { 79 if ( Core::isMaster())79 if (GameMode::isMaster()) 80 80 { 81 81 COUT(3) << "client disconnected" << std::endl; … … 97 97 PlayerInfo* PlayerManager::getClient(unsigned int clientID) const 98 98 { 99 if ( Core::isMaster())99 if (GameMode::isMaster()) 100 100 { 101 101 std::map<unsigned int, PlayerInfo*>::const_iterator it = this->clients_.find(clientID); -
code/trunk/src/orxonox/gamestates/CMakeLists.txt
r2710 r2896 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/trunk/src/orxonox/gamestates/GSClient.cc
r2171 r2896 31 31 32 32 #include "core/input/InputManager.h" 33 #include "core/Clock.h" 33 34 #include "core/CommandLine.h" 34 #include "core/Core.h" 35 #include "core/Game.h" 36 #include "core/GameMode.h" 35 37 #include "network/Client.h" 36 38 37 39 namespace orxonox 38 40 { 41 AddGameState(GSClient, "client"); 42 39 43 SetCommandLineArgument(ip, "127.0.0.1").information("#.#.#.#"); 40 44 41 GSClient::GSClient( )42 : GameState <GSGraphics>("client")45 GSClient::GSClient(const std::string& name) 46 : GameState(name) 43 47 , client_(0) 44 48 { … … 49 53 } 50 54 51 void GSClient:: enter()55 void GSClient::activate() 52 56 { 53 Core::setIsClient(true);57 GameMode::setIsClient(true); 54 58 55 59 this->client_ = new Client(CommandLine::getValue("ip").getString(), CommandLine::getValue("port")); … … 58 62 ThrowException(InitialisationFailed, "Could not establish connection with server."); 59 63 60 GSLevel::enter(this->getParent()->getViewport()); 61 62 client_->tick(0); 64 client_->update(Game::getInstance().getGameClock()); 63 65 } 64 66 65 void GSClient:: leave()67 void GSClient::deactivate() 66 68 { 67 GSLevel::leave();68 69 69 client_->closeConnection(); 70 70 … … 72 72 delete this->client_; 73 73 74 Core::setIsClient(false);74 GameMode::setIsClient(false); 75 75 } 76 76 77 void GSClient:: ticked(const Clock& time)77 void GSClient::update(const Clock& time) 78 78 { 79 GSLevel::ticked(time); 80 client_->tick(time.getDeltaTime()); 81 82 this->tickChild(time); 79 client_->update(time); 83 80 } 84 81 } -
code/trunk/src/orxonox/gamestates/GSClient.h
r2171 r2896 31 31 32 32 #include "OrxonoxPrereqs.h" 33 #include "core/GameState.h" 33 34 #include "network/NetworkPrereqs.h" 34 #include "GSLevel.h"35 #include "GSGraphics.h"36 35 37 36 namespace orxonox 38 37 { 39 class _OrxonoxExport GSClient : public GameState <GSGraphics>, public GSLevel38 class _OrxonoxExport GSClient : public GameState 40 39 { 41 40 public: 42 GSClient( );41 GSClient(const std::string& name); 43 42 ~GSClient(); 44 43 44 void activate(); 45 void deactivate(); 46 void update(const Clock& time); 45 47 46 48 private: 47 void enter();48 void leave();49 void ticked(const Clock& time);50 51 49 Client* client_; 52 50 }; -
code/trunk/src/orxonox/gamestates/GSDedicated.cc
r2662 r2896 30 30 #include "GSDedicated.h" 31 31 32 #include "core/Clock.h" 32 33 #include "core/CommandLine.h" 33 #include "core/Core.h" 34 #include "core/Game.h" 35 #include "core/GameMode.h" 34 36 #include "core/Iterator.h" 35 37 #include "network/Server.h" … … 39 41 namespace orxonox 40 42 { 41 GSDedicated::GSDedicated() 42 : GameState<GSRoot>("dedicated") 43 AddGameState(GSDedicated, "dedicated"); 44 45 GSDedicated::GSDedicated(const std::string& name) 46 : GameState(name) 43 47 , server_(0) 44 48 , timeSinceLastUpdate_(0) … … 50 54 } 51 55 52 void GSDedicated:: enter()56 void GSDedicated::activate() 53 57 { 54 Core::setHasServer(true);58 GameMode::setHasServer(true); 55 59 56 60 this->server_ = new Server(CommandLine::getValue("port")); 57 61 COUT(0) << "Loading scene in server mode" << std::endl; 58 62 59 GSLevel::enter(0);60 61 63 server_->open(); 62 64 } 63 65 64 void GSDedicated:: leave()66 void GSDedicated::deactivate() 65 67 { 66 GSLevel::leave();67 68 68 this->server_->close(); 69 69 delete this->server_; 70 70 71 Core::setHasServer(false);71 GameMode::setHasServer(false); 72 72 } 73 73 74 void GSDedicated:: ticked(const Clock& time)74 void GSDedicated::update(const Clock& time) 75 75 { 76 76 // static float startTime = time.getSecondsPrecise(); … … 82 82 // COUT(0) << "estimated ticks/sec: " << nrOfTicks/(time.getSecondsPrecise()-startTime) << endl; 83 83 timeSinceLastUpdate_ -= static_cast<unsigned int>(timeSinceLastUpdate_ / NETWORK_PERIOD) * NETWORK_PERIOD; 84 GSLevel::ticked(time); 85 server_->tick(time.getDeltaTime()); 86 this->tickChild(time); 84 server_->update(time); 87 85 } 88 86 else -
code/trunk/src/orxonox/gamestates/GSDedicated.h
r2662 r2896 31 31 32 32 #include "OrxonoxPrereqs.h" 33 #include "core/GameState.h" 33 34 #include "network/NetworkPrereqs.h" 34 #include "GSLevel.h"35 #include "GSRoot.h"36 35 37 36 namespace orxonox 38 37 { 39 class _OrxonoxExport GSDedicated : public GameState <GSRoot>, public GSLevel38 class _OrxonoxExport GSDedicated : public GameState 40 39 { 41 40 public: 42 GSDedicated( );41 GSDedicated(const std::string& name); 43 42 ~GSDedicated(); 44 43 44 void activate(); 45 void deactivate(); 46 void update(const Clock& time); 47 45 48 private: 46 void enter(); 47 void leave(); 48 void ticked(const Clock& time); 49 50 Server* server_; 51 float timeSinceLastUpdate_; 49 Server* server_; 50 float timeSinceLastUpdate_; 52 51 }; 53 52 } -
code/trunk/src/orxonox/gamestates/GSGraphics.cc
r2759 r2896 23 23 * Reto Grieder 24 24 * Co-authors: 25 * ... 26 * 25 * Benjamin Knecht 26 * 27 */ 28 29 /** 30 @file 31 @brief Implementation of Graphics GameState class. 27 32 */ 28 33 … … 30 35 #include "GSGraphics.h" 31 36 32 #include <fstream>33 37 #include <boost/filesystem.hpp> 34 35 #include <OgreCompositorManager.h>36 #include <OgreConfigFile.h>37 #include <OgreFrameListener.h>38 #include <OgreRoot.h>39 #include <OgreLogManager.h>40 #include <OgreException.h>41 38 #include <OgreRenderWindow.h> 42 #include <OgreRenderSystem.h> 43 #include <OgreTextureManager.h> 44 #include <OgreViewport.h> 45 #include <OgreWindowEventUtilities.h> 46 47 #include "SpecialConfig.h" 39 48 40 #include "util/Debug.h" 49 #include "util/Exception.h" 50 #include "util/String.h" 51 #include "util/SubString.h" 41 #include "core/ConfigValueIncludes.h" 42 #include "core/Clock.h" 52 43 #include "core/ConsoleCommand.h" 53 #include "core/Co nfigValueIncludes.h"44 #include "core/Core.h" 54 45 #include "core/CoreIncludes.h" 55 #include "core/Core.h" 46 #include "core/Game.h" 47 #include "core/GameMode.h" 56 48 #include "core/input/InputManager.h" 57 49 #include "core/input/KeyBinder.h" 58 #include "core/input/ ExtendedInputState.h"50 #include "core/input/SimpleInputState.h" 59 51 #include "core/Loader.h" 60 52 #include "core/XMLFile.h" 61 53 #include "overlays/console/InGameConsole.h" 62 54 #include "gui/GUIManager.h" 63 #include "tools/WindowEventListener.h" 64 65 // for compatibility 66 #include "GraphicsEngine.h" 55 #include "GraphicsManager.h" 67 56 68 57 namespace orxonox 69 58 { 70 GSGraphics::GSGraphics() 71 : GameState<GSRoot>("graphics") 72 , renderWindow_(0) 73 , viewport_(0) 74 , bWindowEventListenerUpdateRequired_(false) 59 AddGameState(GSGraphics, "graphics"); 60 61 GSGraphics::GSGraphics(const std::string& name) 62 : GameState(name) 75 63 , inputManager_(0) 76 64 , console_(0) 77 65 , guiManager_(0) 78 , ogreRoot_(0) 79 , ogreLogger_(0) 80 , graphicsEngine_(0) 66 , graphicsManager_(0) 81 67 , masterKeyBinder_(0) 68 , masterInputState_(0) 82 69 , debugOverlay_(0) 83 70 { 84 71 RegisterRootObject(GSGraphics); 72 } 73 74 GSGraphics::~GSGraphics() 75 { 76 } 77 78 /** 79 @brief 80 this function does nothing 81 82 Indeed. Here goes nothing. 83 */ 84 void GSGraphics::setConfigValues() 85 { 86 } 87 88 /** 89 @brief 90 This function is called when we enter this game state. 91 92 Since graphics is very important for our game this function does quite a lot: 93 \li starts graphics manager 94 \li loads debug overlay 95 \li manages render window 96 \li creates input manager 97 \li loads master key bindings 98 \li loads ingame console 99 \li loads GUI interface (GUIManager) 100 \li creates console command to toggle GUI 101 */ 102 void GSGraphics::activate() 103 { 104 GameMode::setShowsGraphics(true); 105 85 106 setConfigValues(); 86 } 87 88 GSGraphics::~GSGraphics() 89 { 90 } 91 92 void GSGraphics::setConfigValues() 93 { 94 SetConfigValue(resourceFile_, "resources.cfg") 95 .description("Location of the resources file in the data path."); 96 SetConfigValue(ogreConfigFile_, "ogre.cfg") 97 .description("Location of the Ogre config file"); 98 SetConfigValue(ogrePluginsFolder_, ORXONOX_OGRE_PLUGINS_FOLDER) 99 .description("Folder where the Ogre plugins are located."); 100 SetConfigValue(ogrePlugins_, ORXONOX_OGRE_PLUGINS) 101 .description("Comma separated list of all plugins to load."); 102 SetConfigValue(ogreLogFile_, "ogre.log") 103 .description("Logfile for messages from Ogre. Use \"\" to suppress log file creation."); 104 SetConfigValue(ogreLogLevelTrivial_ , 5) 105 .description("Corresponding orxonox debug level for ogre Trivial"); 106 SetConfigValue(ogreLogLevelNormal_ , 4) 107 .description("Corresponding orxonox debug level for ogre Normal"); 108 SetConfigValue(ogreLogLevelCritical_, 2) 109 .description("Corresponding orxonox debug level for ogre Critical"); 110 } 111 112 void GSGraphics::enter() 113 { 114 Core::setShowsGraphics(true); 115 116 // initialise graphics engine. Doesn't load the render window yet! 117 graphicsEngine_ = new GraphicsEngine(); 118 119 // Ogre setup procedure 120 setupOgre(); 121 // load all the required plugins for Ogre 122 loadOgrePlugins(); 123 // read resource declaration file 124 this->declareResources(); 125 // Reads ogre config and creates the render window 126 this->loadRenderer(); 127 128 // TODO: Spread this so that this call only initialises things needed for the Console and GUI 129 this->initialiseResources(); 130 131 // We want to get informed whenever an object of type WindowEventListener is created 132 // in order to later update the window size. 133 bWindowEventListenerUpdateRequired_ = false; 134 RegisterConstructionCallback(GSGraphics, orxonox::WindowEventListener, requestWindowEventListenerUpdate); 107 108 // initialise graphics manager. Doesn't load the render window yet! 109 this->graphicsManager_ = new GraphicsManager(); 110 this->graphicsManager_->initialise(); 135 111 136 112 // load debug overlay … … 139 115 Loader::open(debugOverlay_); 140 116 117 // The render window width and height are used to set up the mouse movement. 118 size_t windowHnd = 0; 119 Ogre::RenderWindow* renderWindow = GraphicsManager::getInstance().getRenderWindow(); 120 renderWindow->getCustomAttribute("WINDOW", &windowHnd); 121 141 122 // Calls the InputManager which sets up the input devices. 142 // The render window width and height are used to set up the mouse movement.143 123 inputManager_ = new InputManager(); 144 size_t windowHnd = 0;145 this->renderWindow_->getCustomAttribute("WINDOW", &windowHnd); 146 inputManager_->initialise(windowHnd, renderWindow_->getWidth(), renderWindow_->getHeight(), true);147 // Configure master input state with a KeyBinder124 inputManager_->initialise(windowHnd, renderWindow->getWidth(), renderWindow->getHeight(), true); 125 126 // load master key bindings 127 masterInputState_ = InputManager::getInstance().createInputState<SimpleInputState>("master", true); 148 128 masterKeyBinder_ = new KeyBinder(); 149 129 masterKeyBinder_->loadBindings("masterKeybindings.ini"); 150 inputManager_->getMasterInputState()->addKeyHandler(masterKeyBinder_);130 masterInputState_->setKeyHandler(masterKeyBinder_); 151 131 152 132 // Load the InGameConsole 153 133 console_ = new InGameConsole(); 154 console_->initialise( this->renderWindow_->getWidth(), this->renderWindow_->getHeight());134 console_->initialise(renderWindow->getWidth(), renderWindow->getHeight()); 155 135 156 136 // load the CEGUI interface 157 137 guiManager_ = new GUIManager(); 158 guiManager_->initialise(this->renderWindow_); 159 160 // add console commands 161 FunctorMember<GSGraphics>* functor1 = createFunctor(&GSGraphics::printScreen); 162 functor1->setObject(this); 163 ccPrintScreen_ = createConsoleCommand(functor1, "printScreen"); 164 CommandExecutor::addConsoleCommandShortcut(ccPrintScreen_); 165 } 166 167 void GSGraphics::leave() 168 { 169 using namespace Ogre; 170 171 delete this->ccPrintScreen_; 172 173 // remove our WindowEventListener first to avoid bad calls after the window has been destroyed 174 Ogre::WindowEventUtilities::removeWindowEventListener(this->renderWindow_, this); 138 guiManager_->initialise(renderWindow); 139 140 // add console command to toggle GUI 141 FunctorMember<GSGraphics>* functor = createFunctor(&GSGraphics::toggleGUI); 142 functor->setObject(this); 143 this->ccToggleGUI_ = createConsoleCommand(functor, "toggleGUI"); 144 CommandExecutor::addConsoleCommandShortcut(this->ccToggleGUI_); 145 146 // enable master input 147 InputManager::getInstance().requestEnterState("master"); 148 } 149 150 /** 151 @brief 152 This function is called when the game state is left 153 154 Created references, input states and console commands are deleted. 155 */ 156 void GSGraphics::deactivate() 157 { 158 159 if (this->ccToggleGUI_) 160 { 161 delete this->ccToggleGUI_; 162 this->ccToggleGUI_ = 0; 163 } 164 165 masterInputState_->setHandler(0); 166 InputManager::getInstance().requestDestroyState("master"); 167 delete this->masterKeyBinder_; 175 168 176 169 delete this->guiManager_; 177 178 170 delete this->console_; 179 180 //inputManager_->getMasterInputState()->removeKeyHandler(this->masterKeyBinder_);181 delete this->masterKeyBinder_;182 delete this->inputManager_;183 171 184 172 Loader::unload(this->debugOverlay_); 185 173 delete this->debugOverlay_; 186 174 187 // unload all compositors 188 Ogre::CompositorManager::getSingleton().removeAll(); 189 190 // destroy render window 191 RenderSystem* renderer = this->ogreRoot_->getRenderSystem(); 192 renderer->destroyRenderWindow("Orxonox"); 193 194 /*** CODE SNIPPET, UNUSED ***/ 195 // Does the opposite of initialise() 196 //ogreRoot_->shutdown(); 197 // Remove all resources and resource groups 198 //StringVector groups = ResourceGroupManager::getSingleton().getResourceGroups(); 199 //for (StringVector::iterator it = groups.begin(); it != groups.end(); ++it) 200 //{ 201 // ResourceGroupManager::getSingleton().destroyResourceGroup(*it); 202 //} 203 204 //ParticleSystemManager::getSingleton().removeAllTemplates(); 205 206 // Shutdown the render system 207 //this->ogreRoot_->setRenderSystem(0); 208 209 delete this->ogreRoot_; 210 211 // delete the ogre log and the logManager (since we have created it). 212 this->ogreLogger_->getDefaultLog()->removeListener(this); 213 this->ogreLogger_->destroyLog(Ogre::LogManager::getSingleton().getDefaultLog()); 214 delete this->ogreLogger_; 215 216 delete graphicsEngine_; 217 218 Core::setShowsGraphics(false); 175 delete this->inputManager_; 176 this->inputManager_ = 0; 177 178 delete graphicsManager_; 179 180 GameMode::setShowsGraphics(false); 181 } 182 183 /** 184 @brief 185 Toggles the visibility of the current GUI 186 187 This function just executes a Lua function in the main script of the GUI by accessing the GUIManager. 188 For more details on this function check out the Lua code. 189 */ 190 void GSGraphics::toggleGUI() 191 { 192 GUIManager::getInstance().executeCode("toggleGUI()"); 219 193 } 220 194 … … 227 201 need the time. So we shouldn't run into problems. 228 202 */ 229 void GSGraphics::ticked(const Clock& time) 230 { 203 void GSGraphics::update(const Clock& time) 204 { 205 if (this->getActivity().topState) 206 { 207 // This state can not 'survive' on its own. 208 // Load a user interface therefore 209 Game::getInstance().requestState("mainMenu"); 210 } 211 231 212 uint64_t timeBeforeTick = time.getRealMicroseconds(); 232 213 233 float dt = time.getDeltaTime(); 234 235 this->inputManager_->tick(dt); 236 // tick console 237 this->console_->tick(dt); 238 this->tickChild(time); 239 240 if (this->bWindowEventListenerUpdateRequired_) 241 { 242 // Update all WindowEventListeners for the case a new one was created. 243 this->windowResized(this->renderWindow_); 244 this->bWindowEventListenerUpdateRequired_ = false; 245 } 214 this->inputManager_->update(time); // tick console 215 this->console_->update(time); 216 this->guiManager_->update(time); 246 217 247 218 uint64_t timeAfterTick = time.getRealMicroseconds(); 248 219 249 // Also add our tick time to the list in GSRoot 250 this->getParent()->addTickTime(timeAfterTick - timeBeforeTick); 251 252 // Update statistics overlay. Note that the values only change periodically in GSRoot. 253 GraphicsEngine::getInstance().setAverageFramesPerSecond(this->getParent()->getAvgFPS()); 254 GraphicsEngine::getInstance().setAverageTickTime(this->getParent()->getAvgTickTime()); 255 256 // don't forget to call _fireFrameStarted in ogre to make sure 257 // everything goes smoothly 258 Ogre::FrameEvent evt; 259 evt.timeSinceLastFrame = dt; 260 evt.timeSinceLastEvent = dt; // note: same time, but shouldn't matter anyway 261 ogreRoot_->_fireFrameStarted(evt); 262 263 // Pump messages in all registered RenderWindows 264 // This calls the WindowEventListener objects. 265 Ogre::WindowEventUtilities::messagePump(); 266 // make sure the window stays active even when not focused 267 // (probably only necessary on windows) 268 this->renderWindow_->setActive(true); 269 270 // render 271 ogreRoot_->_updateAllRenderTargets(); 272 273 // again, just to be sure ogre works fine 274 ogreRoot_->_fireFrameEnded(evt); // note: uses the same time as _fireFrameStarted 275 } 276 277 /** 278 @brief 279 Creates the Ogre Root object and sets up the ogre log. 280 */ 281 void GSGraphics::setupOgre() 282 { 283 COUT(3) << "Setting up Ogre..." << std::endl; 284 285 if (ogreConfigFile_ == "") 286 { 287 COUT(2) << "Warning: Ogre config file set to \"\". Defaulting to config.cfg" << std::endl; 288 ModifyConfigValue(ogreConfigFile_, tset, "config.cfg"); 289 } 290 if (ogreLogFile_ == "") 291 { 292 COUT(2) << "Warning: Ogre log file set to \"\". Defaulting to ogre.log" << std::endl; 293 ModifyConfigValue(ogreLogFile_, tset, "ogre.log"); 294 } 295 296 boost::filesystem::path ogreConfigFilepath(Core::getConfigPath() / this->ogreConfigFile_); 297 boost::filesystem::path ogreLogFilepath(Core::getLogPath() / this->ogreLogFile_); 298 299 // create a new logManager 300 // Ogre::Root will detect that we've already created a Log 301 ogreLogger_ = new Ogre::LogManager(); 302 COUT(4) << "Ogre LogManager created" << std::endl; 303 304 // create our own log that we can listen to 305 Ogre::Log *myLog; 306 myLog = ogreLogger_->createLog(ogreLogFilepath.string(), true, false, false); 307 COUT(4) << "Ogre Log created" << std::endl; 308 309 myLog->setLogDetail(Ogre::LL_BOREME); 310 myLog->addListener(this); 311 312 COUT(4) << "Creating Ogre Root..." << std::endl; 313 314 // check for config file existence because Ogre displays (caught) exceptions if not 315 if (!boost::filesystem::exists(ogreConfigFilepath)) 316 { 317 // create a zero sized file 318 std::ofstream creator; 319 creator.open(ogreConfigFilepath.string().c_str()); 320 creator.close(); 321 } 322 323 // Leave plugins file empty. We're going to do that part manually later 324 ogreRoot_ = new Ogre::Root("", ogreConfigFilepath.string(), ogreLogFilepath.string()); 325 326 COUT(3) << "Ogre set up done." << std::endl; 327 } 328 329 void GSGraphics::loadOgrePlugins() 330 { 331 // just to make sure the next statement doesn't segfault 332 if (ogrePluginsFolder_ == "") 333 ogrePluginsFolder_ = "."; 334 335 boost::filesystem::path folder(ogrePluginsFolder_); 336 // Do some SubString magic to get the comma separated list of plugins 337 SubString plugins(ogrePlugins_, ",", " ", false, 92, false, 34, false, 40, 41, false, '\0'); 338 // Use backslash paths on Windows! file_string() already does that though. 339 for (unsigned int i = 0; i < plugins.size(); ++i) 340 ogreRoot_->loadPlugin((folder / plugins[i]).file_string()); 341 } 342 343 void GSGraphics::declareResources() 344 { 345 CCOUT(4) << "Declaring Resources" << std::endl; 346 //TODO: Specify layout of data file and maybe use xml-loader 347 //TODO: Work with ressource groups (should be generated by a special loader) 348 349 if (resourceFile_ == "") 350 { 351 COUT(2) << "Warning: Ogre resource file set to \"\". Defaulting to resources.cfg" << std::endl; 352 ModifyConfigValue(resourceFile_, tset, "resources.cfg"); 353 } 354 355 // Load resource paths from data file using configfile ressource type 356 Ogre::ConfigFile cf; 357 try 358 { 359 cf.load((Core::getMediaPath() / resourceFile_).string()); 360 } 361 catch (...) 362 { 363 //COUT(1) << ex.getFullDescription() << std::endl; 364 COUT(0) << "Have you forgotten to set the data path in orxnox.ini?" << std::endl; 365 throw; 366 } 367 368 // Go through all sections & settings in the file 369 Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator(); 370 371 std::string secName, typeName, archName; 372 while (seci.hasMoreElements()) 373 { 374 try 375 { 376 secName = seci.peekNextKey(); 377 Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext(); 378 Ogre::ConfigFile::SettingsMultiMap::iterator i; 379 for (i = settings->begin(); i != settings->end(); ++i) 380 { 381 typeName = i->first; // for instance "FileSystem" or "Zip" 382 archName = i->second; // name (and location) of archive 383 384 Ogre::ResourceGroupManager::getSingleton().addResourceLocation( 385 (Core::getMediaPath() / archName).string(), typeName, secName); 386 } 387 } 388 catch (Ogre::Exception& ex) 389 { 390 COUT(1) << ex.getFullDescription() << std::endl; 391 } 392 } 393 } 394 395 void GSGraphics::loadRenderer() 396 { 397 CCOUT(4) << "Configuring Renderer" << std::endl; 398 399 if (!ogreRoot_->restoreConfig()) 400 if (!ogreRoot_->showConfigDialog()) 401 ThrowException(InitialisationFailed, "Could not show Ogre configuration dialogue."); 402 403 CCOUT(4) << "Creating render window" << std::endl; 404 405 this->renderWindow_ = ogreRoot_->initialise(true, "Orxonox"); 406 407 Ogre::WindowEventUtilities::addWindowEventListener(this->renderWindow_, this); 408 409 Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(0); 410 411 // create a full screen default viewport 412 this->viewport_ = this->renderWindow_->addViewport(0, 0); 413 414 if (this->graphicsEngine_) 415 this->graphicsEngine_->setViewport(this->viewport_); 416 } 417 418 void GSGraphics::initialiseResources() 419 { 420 CCOUT(4) << "Initialising resources" << std::endl; 421 //TODO: Do NOT load all the groups, why are we doing that? And do we really do that? initialise != load... 422 //try 423 //{ 424 Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups(); 425 /*Ogre::StringVector str = Ogre::ResourceGroupManager::getSingleton().getResourceGroups(); 426 for (unsigned int i = 0; i < str.size(); i++) 427 { 428 Ogre::ResourceGroupManager::getSingleton().loadResourceGroup(str[i]); 429 }*/ 430 //} 431 //catch (...) 432 //{ 433 // CCOUT(2) << "Error: There was a serious error when initialising the resources." << std::endl; 434 // throw; 435 //} 436 } 437 438 /** 439 @brief 440 Method called by the LogListener interface from Ogre. 441 We use it to capture Ogre log messages and handle it ourselves. 442 @param message 443 The message to be logged 444 @param lml 445 The message level the log is using 446 @param maskDebug 447 If we are printing to the console or not 448 @param logName 449 The name of this log (so you can have several listeners 450 for different logs, and identify them) 451 */ 452 void GSGraphics::messageLogged(const std::string& message, 453 Ogre::LogMessageLevel lml, bool maskDebug, const std::string& logName) 454 { 455 int orxonoxLevel; 456 switch (lml) 457 { 458 case Ogre::LML_TRIVIAL: 459 orxonoxLevel = this->ogreLogLevelTrivial_; 460 break; 461 case Ogre::LML_NORMAL: 462 orxonoxLevel = this->ogreLogLevelNormal_; 463 break; 464 case Ogre::LML_CRITICAL: 465 orxonoxLevel = this->ogreLogLevelCritical_; 466 break; 467 default: 468 orxonoxLevel = 0; 469 } 470 OutputHandler::getOutStream().setOutputLevel(orxonoxLevel) 471 << "Ogre: " << message << std::endl; 472 } 473 474 /** 475 @brief 476 Window has moved. 477 @param rw 478 The render window it occured in 479 */ 480 void GSGraphics::windowMoved(Ogre::RenderWindow *rw) 481 { 482 for (ObjectList<orxonox::WindowEventListener>::iterator it = ObjectList<orxonox::WindowEventListener>::begin(); it; ++it) 483 it->windowMoved(); 220 // Also add our tick time 221 Game::getInstance().addTickTime(timeAfterTick - timeBeforeTick); 222 223 // Render 224 this->graphicsManager_->update(time); 484 225 } 485 226 … … 490 231 The render window it occured in 491 232 @note 492 Graphics Enginehas a render window stored itself. This is the same233 GraphicsManager has a render window stored itself. This is the same 493 234 as rw. But we have to be careful when using multiple render windows! 494 235 */ 495 void GSGraphics::windowResized(Ogre::RenderWindow *rw) 496 { 497 for (ObjectList<orxonox::WindowEventListener>::iterator it = ObjectList<orxonox::WindowEventListener>::begin(); it; ++it) 498 it->windowResized(this->renderWindow_->getWidth(), this->renderWindow_->getHeight()); 499 236 void GSGraphics::windowResized(unsigned int newWidth, unsigned int newHeight) 237 { 500 238 // OIS needs this under linux even if we only use relative input measurement. 501 239 if (this->inputManager_) 502 this->inputManager_->setWindowExtents( renderWindow_->getWidth(), renderWindow_->getHeight());240 this->inputManager_->setWindowExtents(newWidth, newHeight); 503 241 } 504 242 … … 509 247 The render window it occured in 510 248 */ 511 void GSGraphics::windowFocusChange(Ogre::RenderWindow *rw) 512 { 513 for (ObjectList<orxonox::WindowEventListener>::iterator it = ObjectList<orxonox::WindowEventListener>::begin(); it; ++it) 514 it->windowFocusChanged(); 515 249 void GSGraphics::windowFocusChanged() 250 { 516 251 // instruct InputManager to clear the buffers (core library so we cannot use the interface) 517 252 if (this->inputManager_) … … 519 254 } 520 255 521 /**522 @brief523 Window was closed.524 @param rw525 The render window it occured in526 */527 void GSGraphics::windowClosed(Ogre::RenderWindow *rw)528 {529 this->requestState("root");530 }531 532 void GSGraphics::printScreen()533 {534 if (this->renderWindow_)535 {536 this->renderWindow_->writeContentsToTimestampedFile("shot_", ".jpg");537 }538 }539 256 } -
code/trunk/src/orxonox/gamestates/GSGraphics.h
r2797 r2896 23 23 * Reto Grieder 24 24 * Co-authors: 25 * ...25 * Benjamin Knecht (documentation) 26 26 * 27 27 */ 28 29 /** 30 @file 31 @brief Declaration of the Graphics GameState class. 32 */ 28 33 29 34 #ifndef _GSGraphics_H__ … … 31 36 32 37 #include "OrxonoxPrereqs.h" 33 #include <OgrePrerequisites.h>34 #ifndef NOMINMAX35 # define NOMINMAX // required to stop windows.h screwing up std::min definition36 #endif37 #include <OgreWindowEventUtilities.h>38 38 #include "core/GameState.h" 39 #include "core/OrxonoxClass.h" 40 #include "GSRoot.h" 39 #include "tools/WindowEventListener.h" 41 40 42 41 namespace orxonox 43 42 { 44 class _OrxonoxExport GSGraphics : public GameState<GSRoot>, public OrxonoxClass, 45 public Ogre::WindowEventListener, public Ogre::LogListener 43 /** 44 @class GSGraphics 45 @brief 46 Game state used when displaying graphics of any kind 47 48 This game state is only left out if we start a dedicated server where no graphics are present. 49 */ 50 class _OrxonoxExport GSGraphics : public GameState, public WindowEventListener 46 51 { 47 friend class ClassIdentifier<GSGraphics>;48 49 52 public: 50 GSGraphics( );53 GSGraphics(const std::string& name); 51 54 ~GSGraphics(); 52 53 Ogre::Root* getOgreRoot() { return this->ogreRoot_ ; }54 Ogre::Viewport* getViewport() { return this->viewport_ ; }55 GUIManager* getGUIManager() { return this->guiManager_; }56 57 private: // functions58 void enter();59 void leave();60 void ticked(const Clock& time);61 62 55 void setConfigValues(); 63 56 64 void setupOgre(); 65 void loadOgrePlugins(); 66 void declareResources(); 67 void loadRenderer(); 68 void initialiseResources(); 57 void activate(); 58 void deactivate(); 59 void update(const Clock& time); 69 60 70 // console commands 71 void printScreen(); 61 void toggleGUI(); 72 62 73 // event from Ogre::LogListener 74 void messageLogged(const std::string& message, Ogre::LogMessageLevel lml, 75 bool maskDebug, const std::string& logName); 76 77 // window events from Ogre::WindowEventListener 78 void windowMoved (Ogre::RenderWindow* rw); 79 void windowResized (Ogre::RenderWindow* rw); 80 void windowFocusChange (Ogre::RenderWindow* rw); 81 void windowClosed (Ogre::RenderWindow* rw); 82 83 void requestWindowEventListenerUpdate() { this->bWindowEventListenerUpdateRequired_ = true; } 84 85 private: // variables 86 Ogre::RenderWindow* renderWindow_; //!< the current render window 87 Ogre::Viewport* viewport_; //!< default full size viewport 88 bool bWindowEventListenerUpdateRequired_; //!< True if a new WindowEventListener was created but not yet updated. 63 private: 64 // Window events from WindowEventListener 65 void windowResized(unsigned int newWidth, unsigned int newHeight); 66 void windowFocusChanged(); 89 67 90 68 // managed singletons 91 InputManager* inputManager_; 69 InputManager* inputManager_; //!< Reference to input management 92 70 InGameConsole* console_; 93 GUIManager* guiManager_; 94 Ogre::Root* ogreRoot_; //!< Ogre's root 95 Ogre::LogManager* ogreLogger_; 96 GraphicsEngine* graphicsEngine_; //!< Interface to Ogre 71 GUIManager* guiManager_; //!< Interface to GUI 72 GraphicsManager* graphicsManager_; //!< Interface to Ogre 97 73 98 KeyBinder* masterKeyBinder_; 74 KeyBinder* masterKeyBinder_; //!< Key binder for master key bindings 75 SimpleInputState* masterInputState_; //!< Special input state for master input 99 76 XMLFile* debugOverlay_; 100 101 // config values 102 std::string resourceFile_; //!< resources file name 103 std::string ogreConfigFile_; //!< ogre config file name 104 std::string ogrePluginsFolder_; //!< Folder where the Ogre plugins are located 105 std::string ogrePlugins_; //!< Comma separated list of all plugins to load 106 std::string ogreLogFile_; //!< log file name for Ogre log messages 107 int ogreLogLevelTrivial_; //!< Corresponding Orxonx debug level for LL_TRIVIAL 108 int ogreLogLevelNormal_; //!< Corresponding Orxonx debug level for LL_NORMAL 109 int ogreLogLevelCritical_; //!< Corresponding Orxonx debug level for LL_CRITICAL 110 111 // console commands 112 ConsoleCommand* ccPrintScreen_; 77 ConsoleCommand* ccToggleGUI_; //!< Console command to toggle GUI 113 78 }; 114 79 } -
code/trunk/src/orxonox/gamestates/GSIOConsole.cc
r2087 r2896 36 36 37 37 #include "core/ConsoleCommand.h" 38 #include "core/Game.h" 38 39 39 40 namespace orxonox 40 41 { 41 GSIOConsole::GSIOConsole() 42 : GameState<GSRoot>("ioConsole") 42 AddGameState(GSIOConsole, "ioConsole"); 43 44 GSIOConsole::GSIOConsole(const std::string& name) 45 : GameState(name) 43 46 { 44 47 } … … 48 51 } 49 52 50 void GSIOConsole:: enter()53 void GSIOConsole::activate() 51 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 } 52 61 } 53 62 54 void GSIOConsole:: leave()63 void GSIOConsole::deactivate() 55 64 { 65 if (this->ccLoadMenu_) 66 { 67 delete this->ccLoadMenu_; 68 this->ccLoadMenu_ = 0; 69 } 56 70 } 57 71 58 void GSIOConsole:: ticked(const Clock& time)72 void GSIOConsole::update(const Clock& time) 59 73 { 74 std::cout << ">"; 60 75 std::string command; 61 76 std::getline(std::cin, command); 62 77 CommandExecutor::execute(command, true); 63 64 tickChild(time); 78 } 79 80 void GSIOConsole::loadMenu() 81 { 82 Game::getInstance().popState(); 83 Game::getInstance().requestStates("graphics, mainMenu"); 65 84 } 66 85 } -
code/trunk/src/orxonox/gamestates/GSIOConsole.h
r1755 r2896 31 31 32 32 #include "OrxonoxPrereqs.h" 33 #include <OgrePrerequisites.h>34 33 #include "core/GameState.h" 35 #include "GSRoot.h"36 34 37 35 namespace orxonox 38 36 { 39 class _OrxonoxExport GSIOConsole : public GameState <GSRoot>37 class _OrxonoxExport GSIOConsole : public GameState 40 38 { 41 39 public: 42 GSIOConsole( );40 GSIOConsole(const std::string& name); 43 41 ~GSIOConsole(); 44 42 43 void activate(); 44 void deactivate(); 45 void update(const Clock& time); 46 45 47 private: 46 void enter(); 47 void leave(); 48 void ticked(const Clock& time); 48 void loadMenu(); 49 50 // console commands 51 ConsoleCommand* ccLoadMenu_; 49 52 }; 50 53 } -
code/trunk/src/orxonox/gamestates/GSLevel.cc
r2826 r2896 24 24 * Co-authors: 25 25 * Fabian 'x3n' Landau 26 * Benjamin Knecht 26 27 * 27 28 */ … … 39 40 #include "core/CommandLine.h" 40 41 #include "core/ConfigValueIncludes.h" 42 #include "core/Core.h" 41 43 #include "core/CoreIncludes.h" 42 #include "core/Core.h" 44 #include "core/Game.h" 45 #include "core/GameMode.h" 43 46 #include "objects/Tickable.h" 44 47 #include "objects/Radar.h" 45 48 #include "CameraManager.h" 49 #include "GraphicsManager.h" 46 50 #include "LevelManager.h" 47 51 #include "PlayerManager.h" 52 #include "gui/GUIManager.h" 48 53 49 54 namespace orxonox 50 55 { 56 AddGameState(GSLevel, "level"); 57 51 58 SetCommandLineArgument(level, "presentation_dm.oxw").shortcut("l"); 52 53 GSLevel::GSLevel() 54 // : GameState<GSGraphics>(name) 55 : keyBinder_(0) 56 , inputState_(0) 59 SetConsoleCommand(GSLevel, showIngameGUI, true); 60 61 GSLevel::GSLevel(const std::string& name) 62 : GameState(name) 63 , keyBinder_(0) 64 , gameInputState_(0) 65 , guiMouseOnlyInputState_(0) 66 , guiKeysOnlyInputState_(0) 57 67 , radar_(0) 58 68 , startFile_(0) … … 64 74 this->ccKeybind_ = 0; 65 75 this->ccTkeybind_ = 0; 66 76 } 77 78 GSLevel::~GSLevel() 79 { 80 } 81 82 void GSLevel::setConfigValues() 83 { 84 SetConfigValue(keyDetectorCallbackCode_, "KeybindBindingStringKeyName="); 85 } 86 87 void GSLevel::activate() 88 { 67 89 setConfigValues(); 68 } 69 70 GSLevel::~GSLevel() 71 { 72 } 73 74 void GSLevel::setConfigValues() 75 { 76 SetConfigValue(keyDetectorCallbackCode_, "KeybindBindingStringKeyName="); 77 } 78 79 void GSLevel::enter(Ogre::Viewport* viewport) 80 { 81 if (Core::showsGraphics()) 82 { 83 inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("game", 20); 90 91 if (GameMode::showsGraphics()) 92 { 93 gameInputState_ = InputManager::getInstance().createInputState<SimpleInputState>("game"); 84 94 keyBinder_ = new KeyBinder(); 85 95 keyBinder_->loadBindings("keybindings.ini"); 86 inputState_->setHandler(keyBinder_); 96 gameInputState_->setHandler(keyBinder_); 97 98 guiMouseOnlyInputState_ = InputManager::getInstance().createInputState<SimpleInputState>("guiMouseOnly"); 99 guiMouseOnlyInputState_->setMouseHandler(GUIManager::getInstancePtr()); 100 101 guiKeysOnlyInputState_ = InputManager::getInstance().createInputState<SimpleInputState>("guiKeysOnly"); 102 guiKeysOnlyInputState_->setKeyHandler(GUIManager::getInstancePtr()); 87 103 88 104 // create the global CameraManager 89 assert(viewport); 90 this->cameraManager_ = new CameraManager(viewport); 105 this->cameraManager_ = new CameraManager(GraphicsManager::getInstance().getViewport()); 91 106 92 107 // Start the Radar … … 96 111 this->playerManager_ = new PlayerManager(); 97 112 98 if ( Core::isMaster())113 if (GameMode::isMaster()) 99 114 { 100 115 // create the global LevelManager … … 104 119 } 105 120 106 if (Core::showsGraphics()) 107 { 108 // TODO: insert slomo console command with 109 // .accessLevel(AccessLevel::Offline).defaultValue(0, 1.0).axisParamIndex(0).isAxisRelative(false); 110 121 if (GameMode::showsGraphics()) 122 { 111 123 // keybind console command 112 124 FunctorMember<GSLevel>* functor1 = createFunctor(&GSLevel::keybind); … … 126 138 } 127 139 128 void GSLevel::leave() 140 void GSLevel::showIngameGUI(bool show) 141 { 142 if (show) 143 { 144 GUIManager::getInstancePtr()->showGUI("inGameTest"); 145 GUIManager::getInstancePtr()->executeCode("showCursor()"); 146 InputManager::getInstance().requestEnterState("guiMouseOnly"); 147 } 148 else 149 { 150 GUIManager::getInstancePtr()->executeCode("hideGUI(\"inGameTest\")"); 151 GUIManager::getInstancePtr()->executeCode("hideCursor()"); 152 InputManager::getInstance().requestLeaveState("guiMouseOnly"); 153 } 154 } 155 156 void GSLevel::deactivate() 129 157 { 130 158 // destroy console commands … … 139 167 this->ccTkeybind_ = 0; 140 168 } 169 141 170 142 171 // this call will delete every BaseObject! … … 146 175 //Loader::close(); 147 176 148 if ( Core::showsGraphics())177 if (GameMode::showsGraphics()) 149 178 InputManager::getInstance().requestLeaveState("game"); 150 179 151 if ( Core::isMaster())180 if (GameMode::isMaster()) 152 181 this->unloadLevel(); 153 182 … … 176 205 } 177 206 178 if (Core::showsGraphics()) 179 { 180 inputState_->setHandler(0); 207 if (GameMode::showsGraphics()) 208 { 209 gameInputState_->setHandler(0); 210 guiMouseOnlyInputState_->setHandler(0); 211 guiKeysOnlyInputState_->setHandler(0); 181 212 InputManager::getInstance().requestDestroyState("game"); 182 213 if (this->keyBinder_) … … 188 219 } 189 220 190 void GSLevel:: ticked(const Clock& time)191 { 192 // Commented by 1337: Temporarily moved to GSGraphics.221 void GSLevel::update(const Clock& time) 222 { 223 // Note: Temporarily moved to GSGraphics. 193 224 //// Call the scene objects 194 225 //for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it) … … 233 264 Command string that can be executed by the CommandExecutor 234 265 OR: Internal string "KeybindBindingStringKeyName=" used for the second call to identify 235 the key/button/axis that has been activated. This is configured above in enter().266 the key/button/axis that has been activated. This is configured above in activate(). 236 267 */ 237 268 void GSLevel::keybindInternal(const std::string& command, bool bTemporary) 238 269 { 239 if ( Core::showsGraphics())270 if (GameMode::showsGraphics()) 240 271 { 241 272 static std::string bindingString = ""; -
code/trunk/src/orxonox/gamestates/GSLevel.h
r2790 r2896 23 23 * Reto Grieder 24 24 * Co-authors: 25 * ...25 * Benjamin Knecht 26 26 * 27 27 */ … … 31 31 32 32 #include "OrxonoxPrereqs.h" 33 #include <OgrePrerequisites.h>34 33 #include "core/OrxonoxClass.h" 34 #include "core/GameState.h" 35 35 36 36 namespace orxonox 37 37 { 38 class _OrxonoxExport GSLevel : public OrxonoxClass38 class _OrxonoxExport GSLevel : public GameState, public OrxonoxClass 39 39 { 40 friend class ClassIdentifier<GSLevel>;41 40 public: 42 GSLevel( );41 GSLevel(const std::string& name); 43 42 ~GSLevel(); 44 45 // was private before (is public now because of console command in GSStandalone)46 43 void setConfigValues(); 47 44 45 void activate(); 46 void deactivate(); 47 void update(const Clock& time); 48 49 static void showIngameGUI(bool show); 50 48 51 protected: 49 void enter(Ogre::Viewport* viewport);50 void leave();51 void ticked(const Clock& time);52 53 52 void loadLevel(); 54 53 void unloadLevel(); … … 59 58 void keybindInternal(const std::string& command, bool bTemporary); 60 59 61 KeyBinder* keyBinder_; //!< tool that loads and manages the input bindings 62 SimpleInputState* inputState_; 63 Radar* radar_; //!< represents the Radar (not the HUD part) 64 XMLFile* startFile_; //!< current hard coded default level 65 CameraManager* cameraManager_; 66 LevelManager* levelManager_; 67 PlayerManager* playerManager_; 60 KeyBinder* keyBinder_; //!< tool that loads and manages the input bindings 61 SimpleInputState* gameInputState_; //!< input state for normal ingame playing 62 SimpleInputState* guiMouseOnlyInputState_; //!< input state if we only need the mouse to use the GUI 63 SimpleInputState* guiKeysOnlyInputState_; //!< input state if we only need the keys to use the GUI 64 Radar* radar_; //!< represents the Radar (not the HUD part) 65 XMLFile* startFile_; //!< current hard coded default level 66 CameraManager* cameraManager_; //!< camera manager for this level 67 LevelManager* levelManager_; //!< global level manager 68 PlayerManager* playerManager_; //!< player manager for this level 68 69 69 70 //##### ConfigValues ##### … … 73 74 ConsoleCommand* ccKeybind_; 74 75 ConsoleCommand* ccTkeybind_; 75 76 76 }; 77 77 } -
code/trunk/src/orxonox/gamestates/GSRoot.cc
r2797 r2896 32 32 #include "util/Exception.h" 33 33 #include "util/Debug.h" 34 #include "core/C ore.h"35 #include "core/ Factory.h"36 #include "core/ ConfigValueIncludes.h"37 #include "core/Co reIncludes.h"34 #include "core/Clock.h" 35 #include "core/Game.h" 36 #include "core/GameMode.h" 37 #include "core/CommandLine.h" 38 38 #include "core/ConsoleCommand.h" 39 #include "core/CommandLine.h" 40 #include "core/Shell.h" 41 #include "core/TclBind.h" 42 #include "core/TclThreadManager.h" 43 #include "core/LuaBind.h" 39 #include "tools/TimeFactorListener.h" 44 40 #include "tools/Timer.h" 45 41 #include "objects/Tickable.h" 46 42 47 #ifdef ORXONOX_PLATFORM_WINDOWS48 # ifndef WIN32_LEAN_AND_MEAN49 # define WIN32_LEAN_AND_MEAN50 # endif51 # ifndef NOMINMAX52 # define NOMINMAX // required to stop windows.h screwing up std::min definition53 # endif54 # include "windows.h"55 #endif56 57 43 namespace orxonox 58 44 { 59 SetCommandLineArgument(limitToCPU, 1).information("0: off | #cpu"); 60 61 GSRoot::GSRoot() 62 : RootGameState("root") 45 AddGameState(GSRoot, "root"); 46 SetCommandLineSwitch(console); 47 // Shortcuts for easy direct loading 48 SetCommandLineSwitch(server); 49 SetCommandLineSwitch(client); 50 SetCommandLineSwitch(dedicated); 51 SetCommandLineSwitch(standalone); 52 53 GSRoot::GSRoot(const std::string& name) 54 : GameState(name) 63 55 , timeFactor_(1.0f) 64 56 , bPaused_(false) 65 57 , timeFactorPauseBackup_(1.0f) 66 , tclBind_(0) 67 , tclThreadManager_(0) 68 , shell_(0) 69 { 70 RegisterRootObject(GSRoot); 71 setConfigValues(); 72 58 { 73 59 this->ccSetTimeFactor_ = 0; 74 60 this->ccPause_ = 0; … … 79 65 } 80 66 81 void GSRoot::setConfigValues() 82 { 83 SetConfigValue(statisticsRefreshCycle_, 250000) 84 .description("Sets the time in microseconds interval at which average fps, etc. get updated."); 85 SetConfigValue(statisticsAvgLength_, 1000000) 86 .description("Sets the time in microseconds interval at which average fps, etc. gets calculated."); 87 } 88 89 void GSRoot::enter() 90 { 91 // creates the class hierarchy for all classes with factories 92 Factory::createClassHierarchy(); 93 67 void GSRoot::activate() 68 { 94 69 // reset game speed to normal 95 timeFactor_ = 1.0f; 96 97 // reset frame counter 98 this->statisticsStartTime_ = 0; 99 this->statisticsTickTimes_.clear(); 100 this->periodTickTime_ = 0; 101 this->avgFPS_ = 0.0f; 102 this->avgTickTime_ = 0.0f; 103 104 // Create the lua interface 105 this->luaBind_ = new LuaBind(); 106 107 // initialise TCL 108 this->tclBind_ = new TclBind(Core::getMediaPathString()); 109 this->tclThreadManager_ = new TclThreadManager(tclBind_->getTclInterpreter()); 110 111 // create a shell 112 this->shell_ = new Shell(); 113 114 // limit the main thread to the first core so that QueryPerformanceCounter doesn't jump 115 // do this after ogre has initialised. Somehow Ogre changes the settings again (not through 116 // the timer though). 117 int limitToCPU = CommandLine::getValue("limitToCPU"); 118 if (limitToCPU > 0) 119 setThreadAffinity((unsigned int)(limitToCPU - 1)); 120 121 { 122 // add console commands 123 FunctorMember<GSRoot>* functor = createFunctor(&GSRoot::exitGame); 124 functor->setObject(this); 125 this->ccExit_ = createConsoleCommand(functor, "exit"); 126 CommandExecutor::addConsoleCommandShortcut(this->ccExit_); 127 } 128 129 { 130 // add console commands 131 FunctorMember01<GameStateBase, const std::string&>* functor = createFunctor(&GameStateBase::requestState); 132 functor->setObject(this); 133 this->ccSelectGameState_ = createConsoleCommand(functor, "selectGameState"); 134 CommandExecutor::addConsoleCommandShortcut(this->ccSelectGameState_); 135 } 70 this->timeFactor_ = 1.0f; 136 71 137 72 { … … 150 85 CommandExecutor::addConsoleCommandShortcut(this->ccPause_).accessLevel(AccessLevel::Offline); 151 86 } 152 } 153 154 void GSRoot::leave() 155 { 156 // destroy console commands 157 delete this->ccExit_; 158 delete this->ccSelectGameState_; 159 160 delete this->shell_; 161 delete this->tclThreadManager_; 162 delete this->tclBind_; 163 164 delete this->luaBind_; 165 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, client, level"); 103 loadLevel = true; 104 } 105 if (CommandLine::getValue("dedicated").getBool()) 106 { 107 Game::getInstance().requestStates("dedicated, level"); 108 loadLevel = true; 109 } 110 111 // Determine where to start otherwise 112 if (!loadLevel && !CommandLine::getValue("console").getBool()) 113 { 114 // Also load graphics 115 Game::getInstance().requestState("graphics"); 116 } 117 } 118 119 void GSRoot::deactivate() 120 { 166 121 if (this->ccSetTimeFactor_) 167 122 { … … 177 132 } 178 133 179 void GSRoot::ticked(const Clock& time) 180 { 134 void GSRoot::update(const Clock& time) 135 { 136 if (this->getActivity().topState) 137 { 138 // This state can not 'survive' on its own. 139 // Load a user interface therefore 140 Game::getInstance().requestState("ioConsole"); 141 } 142 181 143 uint64_t timeBeforeTick = time.getRealMicroseconds(); 182 183 TclThreadManager::getInstance().tick(time.getDeltaTime());184 144 185 145 for (ObjectList<TimerBase>::iterator it = ObjectList<TimerBase>::begin(); it; ++it) … … 200 160 uint64_t timeAfterTick = time.getRealMicroseconds(); 201 161 202 // STATISTICS 203 assert(timeAfterTick - timeBeforeTick >= 0 ); 204 statisticsTickInfo tickInfo = {timeAfterTick, timeAfterTick - timeBeforeTick}; 205 statisticsTickTimes_.push_back(tickInfo); 206 assert(statisticsTickTimes_.back().tickLength==tickInfo.tickLength); 207 this->periodTickTime_ += tickInfo.tickLength; 208 209 // Ticks GSGraphics or GSDedicated 210 this->tickChild(time); 211 212 if (timeAfterTick > statisticsStartTime_ + statisticsRefreshCycle_) 213 { 214 std::list<statisticsTickInfo>::iterator it = this->statisticsTickTimes_.begin(); 215 assert(it != this->statisticsTickTimes_.end()); 216 int64_t lastTime = timeAfterTick - statisticsAvgLength_; 217 if ((int64_t)it->tickTime < lastTime) 218 { 219 do 220 { 221 assert(this->periodTickTime_ > it->tickLength); 222 this->periodTickTime_ -= it->tickLength; 223 ++it; 224 assert(it != this->statisticsTickTimes_.end()); 225 } while ((int64_t)it->tickTime < lastTime); 226 this->statisticsTickTimes_.erase(this->statisticsTickTimes_.begin(), it); 227 } 228 229 uint32_t framesPerPeriod = this->statisticsTickTimes_.size(); 230 this->avgFPS_ = (float)framesPerPeriod / (timeAfterTick - this->statisticsTickTimes_.front().tickTime) * 1000000.0; 231 this->avgTickTime_ = (float)this->periodTickTime_ / framesPerPeriod / 1000.0; 232 233 statisticsStartTime_ = timeAfterTick; 234 } 235 236 } 237 238 /** 239 @note 240 The code of this function has been copied and adjusted from OGRE, an open source graphics engine. 241 (Object-oriented Graphics Rendering Engine) 242 For the latest info, see http://www.ogre3d.org/ 243 244 Copyright (c) 2000-2008 Torus Knot Software Ltd 245 246 OGRE is licensed under the LGPL. For more info, see OGRE license. 247 */ 248 void GSRoot::setThreadAffinity(unsigned int limitToCPU) 249 { 250 #ifdef ORXONOX_PLATFORM_WINDOWS 251 // Get the current process core mask 252 DWORD procMask; 253 DWORD sysMask; 254 # if _MSC_VER >= 1400 && defined (_M_X64) 255 GetProcessAffinityMask(GetCurrentProcess(), (PDWORD_PTR)&procMask, (PDWORD_PTR)&sysMask); 256 # else 257 GetProcessAffinityMask(GetCurrentProcess(), &procMask, &sysMask); 258 # endif 259 260 // If procMask is 0, consider there is only one core available 261 // (using 0 as procMask will cause an infinite loop below) 262 if (procMask == 0) 263 procMask = 1; 264 265 // if the core specified with limitToCPU is not available, take the lowest one 266 if (!(procMask & (1 << limitToCPU))) 267 limitToCPU = 0; 268 269 // Find the lowest core that this process uses and limitToCPU suggests 270 DWORD threadMask = 1; 271 while ((threadMask & procMask) == 0 || (threadMask < (1u << limitToCPU))) 272 threadMask <<= 1; 273 274 // Set affinity to the first core 275 SetThreadAffinityMask(GetCurrentThread(), threadMask); 276 #endif 162 // Also add our tick time 163 Game::getInstance().addTickTime(timeAfterTick - timeBeforeTick); 277 164 } 278 165 … … 283 170 void GSRoot::setTimeFactor(float factor) 284 171 { 285 if ( Core::isMaster())172 if (GameMode::isMaster()) 286 173 { 287 174 if (!this->bPaused_) … … 301 188 void GSRoot::pause() 302 189 { 303 if ( Core::isMaster())190 if (GameMode::isMaster()) 304 191 { 305 192 if (!this->bPaused_) … … 316 203 } 317 204 } 318 319 ////////////////////////320 // TimeFactorListener //321 ////////////////////////322 float TimeFactorListener::timefactor_s = 1.0f;323 324 TimeFactorListener::TimeFactorListener()325 {326 RegisterRootObject(TimeFactorListener);327 }328 205 } -
code/trunk/src/orxonox/gamestates/GSRoot.h
r2710 r2896 31 31 32 32 #include "OrxonoxPrereqs.h" 33 34 #include <list> 35 #include <OgreLog.h> 36 #include "core/RootGameState.h" 33 #include "core/GameState.h" 37 34 #include "core/OrxonoxClass.h" 38 35 39 36 namespace orxonox 40 37 { 41 class _OrxonoxExport GSRoot : public RootGameState, public OrxonoxClass38 class _OrxonoxExport GSRoot : public GameState 42 39 { 43 friend class ClassIdentifier<GSRoot>;44 45 40 public: 46 struct statisticsTickInfo 47 { 48 uint64_t tickTime; 49 uint32_t tickLength; 50 }; 51 52 public: 53 GSRoot(); 41 GSRoot(const std::string& name); 54 42 ~GSRoot(); 55 43 56 void exitGame() 57 { requestState("root"); } 44 void activate(); 45 void deactivate(); 46 void update(const Clock& time); 58 47 59 48 // this has to be public because proteced triggers a bug in msvc … … 63 52 float getTimeFactor() { return this->timeFactor_; } 64 53 65 float getAvgTickTime() { return this->avgTickTime_; }66 float getAvgFPS() { return this->avgFPS_; }67 68 inline void addTickTime(uint32_t length)69 { assert(!this->statisticsTickTimes_.empty()); this->statisticsTickTimes_.back().tickLength += length;70 this->periodTickTime_+=length; }71 72 54 private: 73 void enter();74 void leave();75 void ticked(const Clock& time);76 77 void setConfigValues();78 void setThreadAffinity(unsigned int limitToCPU);79 80 55 float timeFactor_; //!< A factor that sets the gamespeed. 1 is normal. 81 56 bool bPaused_; 82 57 float timeFactorPauseBackup_; 83 TclBind* tclBind_;84 TclThreadManager* tclThreadManager_;85 Shell* shell_;86 LuaBind* luaBind_;87 88 // variables for time statistics89 uint64_t statisticsStartTime_;90 std::list<statisticsTickInfo>91 statisticsTickTimes_;92 uint32_t periodTickTime_;93 float avgFPS_;94 float avgTickTime_;95 96 // config values97 unsigned int statisticsRefreshCycle_;98 unsigned int statisticsAvgLength_;99 58 100 59 // console commands 101 ConsoleCommand* ccExit_;102 ConsoleCommand* ccSelectGameState_;103 60 ConsoleCommand* ccSetTimeFactor_; 104 61 ConsoleCommand* ccPause_; 105 };106 107 class _OrxonoxExport TimeFactorListener : virtual public OrxonoxClass108 {109 friend class GSRoot;110 111 public:112 TimeFactorListener();113 virtual ~TimeFactorListener() {}114 115 protected:116 virtual void changedTimeFactor(float factor_new, float factor_old) {}117 inline float getTimeFactor() const118 { return TimeFactorListener::timefactor_s; }119 120 private:121 static float timefactor_s;122 62 }; 123 63 } -
code/trunk/src/orxonox/gamestates/GSServer.cc
r2171 r2896 31 31 32 32 #include "core/CommandLine.h" 33 #include "core/Core.h" 33 #include "core/Game.h" 34 #include "core/GameMode.h" 34 35 #include "network/Server.h" 35 36 36 37 namespace orxonox 37 38 { 39 AddGameState(GSServer, "server"); 40 38 41 SetCommandLineArgument(port, 55556).shortcut("p").information("0-65535"); 39 42 40 GSServer::GSServer( )41 : GameState <GSGraphics>("server")43 GSServer::GSServer(const std::string& name) 44 : GameState(name) 42 45 , server_(0) 43 46 { … … 48 51 } 49 52 50 void GSServer:: enter()53 void GSServer::activate() 51 54 { 52 Core::setHasServer(true);55 GameMode::setHasServer(true); 53 56 54 57 this->server_ = new Server(CommandLine::getValue("port")); 55 58 COUT(0) << "Loading scene in server mode" << std::endl; 56 59 57 GSLevel::enter(this->getParent()->getViewport());58 59 60 server_->open(); 60 61 } 61 62 62 void GSServer:: leave()63 void GSServer::deactivate() 63 64 { 64 GSLevel::leave();65 66 65 this->server_->close(); 67 66 delete this->server_; 68 67 69 Core::setHasServer(false);68 GameMode::setHasServer(false); 70 69 } 71 70 72 void GSServer:: ticked(const Clock& time)71 void GSServer::update(const Clock& time) 73 72 { 74 GSLevel::ticked(time); 75 server_->tick(time.getDeltaTime()); 76 this->tickChild(time); 73 server_->update(time); 77 74 } 78 75 } -
code/trunk/src/orxonox/gamestates/GSServer.h
r2171 r2896 31 31 32 32 #include "OrxonoxPrereqs.h" 33 #include "core/GameState.h" 33 34 #include "network/NetworkPrereqs.h" 34 #include "GSLevel.h"35 #include "GSGraphics.h"36 35 37 36 namespace orxonox 38 37 { 39 class _OrxonoxExport GSServer : public GameState <GSGraphics>, public GSLevel38 class _OrxonoxExport GSServer : public GameState 40 39 { 41 40 public: 42 GSServer( );41 GSServer(const std::string& name); 43 42 ~GSServer(); 44 43 44 void activate(); 45 void deactivate(); 46 void update(const Clock& time); 47 45 48 private: 46 void enter(); 47 void leave(); 48 void ticked(const Clock& time); 49 50 Server* server_; 49 Server* server_; 51 50 }; 52 51 } -
code/trunk/src/orxonox/gamestates/GSStandalone.cc
r2790 r2896 32 32 #include <OgreViewport.h> 33 33 #include <OgreCamera.h> 34 #include "core/Core.h" 34 #include "core/Game.h" 35 #include "core/GameMode.h" 35 36 #include "core/ConsoleCommand.h" 36 37 #include "gui/GUIManager.h" 38 #include "GraphicsManager.h" 37 39 38 40 namespace orxonox 39 41 { 40 SetConsoleCommand(GSStandalone, showGUI, true).setAsInputCommand();42 AddGameState(GSStandalone, "standalone"); 41 43 42 bool GSStandalone::guiShowing_s = false; 43 44 GSStandalone::GSStandalone() 45 : GameState<GSGraphics>("standalone") 44 GSStandalone::GSStandalone(const std::string& name) 45 : GameState(name) 46 46 { 47 47 } … … 51 51 } 52 52 53 void GSStandalone::showGUI() 53 54 void GSStandalone::activate() 54 55 { 55 G SStandalone::guiShowing_s = true;56 GameMode::setIsStandalone(true); 56 57 } 57 58 58 void GSStandalone:: enter()59 void GSStandalone::deactivate() 59 60 { 60 Core::setIsStandalone(true); 61 62 GSLevel::enter(this->getParent()->getViewport()); 63 64 guiManager_ = getParent()->getGUIManager(); 65 // not sure if necessary 66 // guiManager_->loadScene("IngameMenu"); 61 GameMode::setIsStandalone(false); 67 62 } 68 63 69 void GSStandalone:: leave()64 void GSStandalone::update(const Clock& time) 70 65 { 71 GSLevel::leave();72 73 Core::setIsStandalone(false);74 }75 76 void GSStandalone::ticked(const Clock& time)77 {78 if (guiShowing_s)79 {80 guiManager_->showGUI("IngameMenu", this->getParent()->getViewport()->getCamera()->getSceneManager());81 }82 else83 {84 if (guiManager_)85 guiManager_->hideGUI();86 }87 // tick CEGUI88 guiManager_->tick(time.getDeltaTime());89 90 GSLevel::ticked(time);91 this->tickChild(time);92 66 } 93 67 } -
code/trunk/src/orxonox/gamestates/GSStandalone.h
r2790 r2896 31 31 32 32 #include "OrxonoxPrereqs.h" 33 #include "GSLevel.h" 34 #include "GSGraphics.h" 33 #include "core/GameState.h" 35 34 36 35 namespace orxonox 37 36 { 38 class _OrxonoxExport GSStandalone : public GameState <GSGraphics>, public GSLevel37 class _OrxonoxExport GSStandalone : public GameState 39 38 { 40 39 public: 41 GSStandalone( );40 GSStandalone(const std::string& name); 42 41 ~GSStandalone(); 43 static void showGUI(); 42 43 void activate(); 44 void deactivate(); 45 void update(const Clock& time); 44 46 45 47 private: 46 void enter();47 void leave();48 void ticked(const Clock& time);49 50 GUIManager* guiManager_;51 static bool guiShowing_s;52 48 }; 53 49 } -
code/trunk/src/orxonox/gui/GUIManager.cc
r2790 r2896 22 22 * Author: 23 23 * Reto Grieder 24 * Benjamin Knecht 24 25 * Co-authors: 25 * ...26 * 26 27 * 27 28 */ … … 36 37 #include "GUIManager.h" 37 38 38 #include <boost/filesystem .hpp>39 #include <boost/filesystem/path.hpp> 39 40 #include <OgreRenderWindow.h> 40 #include <OgreRoot.h>41 41 #include <CEGUI.h> 42 42 #include <CEGUIDefaultLogger.h> … … 50 50 51 51 #include "util/Exception.h" 52 #include "core/input/InputManager.h"53 #include "core/input/SimpleInputState.h"54 52 #include "core/ConsoleCommand.h" 55 53 #include "core/Core.h" 54 #include "core/Clock.h" 56 55 #include "ToluaBindCore.h" 57 56 #include "ToluaBindOrxonox.h" … … 63 62 namespace orxonox 64 63 { 65 SetConsoleCommandShortcut(GUIManager, showGUI_s).keybindMode(KeybindMode::OnPress);66 67 64 GUIManager* GUIManager::singletonRef_s = 0; 68 65 69 66 GUIManager::GUIManager() 70 //: emptySceneManager_(0) 71 : backgroundSceneManager_(0) 72 //, emptyCamera_(0) 73 , backgroundCamera_(0) 74 //, viewport_(0) 75 , renderWindow_(0) 67 : renderWindow_(0) 76 68 , guiRenderer_(0) 77 69 , resourceProvider_(0) … … 84 76 } 85 77 78 /** 79 @brief 80 Deconstructor of the GUIManager 81 82 Basically shuts down CEGUI and destroys the Lua engine and afterwards the interface to the Ogre engine. 83 */ 86 84 GUIManager::~GUIManager() 87 85 { 88 if (backgroundCamera_)89 backgroundSceneManager_->destroyCamera(backgroundCamera_);90 91 if (backgroundSceneManager_)92 {93 // We have to make sure the SceneManager is not anymore referenced.94 // For the case that the target SceneManager was yet another one, it95 // wouldn't matter anyway since this is the destructor.96 guiRenderer_->setTargetSceneManager(0);97 Ogre::Root::getSingleton().destroySceneManager(backgroundSceneManager_);98 }99 100 InputManager::getInstance().requestDestroyState("gui");101 102 86 if (guiSystem_) 103 87 delete guiSystem_; … … 110 94 lua_pushnil(luaState_); 111 95 lua_setglobal(luaState_, "Core"); 112 // TODO: deleting the script module fails an assertion.113 // However there is not much we can do about it since it occurs too when114 // we don't open Core or Orxonox. Might be a CEGUI issue.115 // The memory leak is not a problem anyway..116 96 delete scriptModule_; 117 97 } … … 123 103 } 124 104 105 /** 106 @brief 107 Initialises the GUIManager by starting up CEGUI 108 @param renderWindow 109 Ogre's render window. Without this, the GUI cannot be displayed. 110 @return true if success, otherwise false 111 112 Before this call the GUIManager won't do anything, but can be accessed. 113 114 Creates the interface to Ogre, sets up the CEGUI renderer and the Lua script module together with the Lua engine. 115 The log is set up and connected to the CEGUILogger. 116 After Lua setup tolua++-elements are linked to Lua-state to give Lua access to C++-code. 117 Finally initial Lua code is executed (maybe we can do this with the CEGUI startup script automatically). 118 */ 125 119 bool GUIManager::initialise(Ogre::RenderWindow* renderWindow) 126 120 { … … 135 129 renderWindow_ = renderWindow; 136 130 137 // Full screen viewport with Z order = 0 (top most). Don't yet feed a camera (so nothing gets rendered)138 //this->viewport_ = renderWindow_->addViewport(0, 3);139 //this->viewport_->setOverlaysEnabled(false);140 //this->viewport_->setShadowsEnabled(false);141 //this->viewport_->setSkiesEnabled(false);142 //this->viewport_->setClearEveryFrame(false);143 144 131 // Note: No SceneManager specified yet 145 this->guiRenderer_ = new OgreCEGUIRenderer(renderWindow_, Ogre::RENDER_QUEUE_ MAIN, true, 3000);132 this->guiRenderer_ = new OgreCEGUIRenderer(renderWindow_, Ogre::RENDER_QUEUE_OVERLAY, true, 3000); 146 133 this->resourceProvider_ = guiRenderer_->createResourceProvider(); 147 134 this->resourceProvider_->setDefaultResourceGroup("GUI"); … … 166 153 tolua_Orxonox_open(this->scriptModule_->getLuaState()); 167 154 168 // register us as input handler 169 SimpleInputState* state = InputManager::getInstance().createInputState<SimpleInputState>("gui", 30); 170 state->setHandler(this); 171 state->setJoyStickHandler(&InputManager::EMPTY_HANDLER); 172 173 // load the background scene 174 //loadScenes(); 175 //CEGUI::KeyEventArgs e; 176 //e.codepoint 155 // initialise the basic lua code 156 loadLuaCode(); 177 157 } 178 158 catch (CEGUI::Exception& ex) … … 192 172 } 193 173 194 void GUIManager::loadScene(const std::string& name) 195 { 196 if (name.compare("IngameMenu") == 0) 197 { 198 try 199 { 200 /*this->scriptModule_ = new LuaScriptModule(); 201 this->luaState_ = this->scriptModule_->getLuaState(); 202 this->guiSystem_ = new System(this->guiRenderer_, this->resourceProvider_, 0, this->scriptModule_); 203 tolua_Core_open(this->scriptModule_->getLuaState()); 204 tolua_Orxonox_open(this->scriptModule_->getLuaState()); 205 */ 206 this->scriptModule_->executeScriptFile("ingameGUI.lua", "GUI"); 207 } 208 catch (CEGUI::Exception& ex) 209 { 210 #if CEGUI_VERSION_MINOR < 6 211 throw GeneralException(ex.getMessage().c_str()); 212 #else 213 throw GeneralException(ex.getMessage().c_str(), ex.getLine(), 214 ex.getFileName().c_str(), ex.getName().c_str()); 215 #endif 216 } 217 } 218 else 219 { 220 loadScenes(); 221 } 222 } 223 224 void GUIManager::loadScenes() 225 { 226 // first of all, we need to have our own SceneManager for the GUI. The reason 227 // is that we might have multiple viewports when in play mode (e.g. the view of 228 // a camera fixed at the back of the ship). That forces us to create our own 229 // full screen viewport that is on top of all the others, but doesn't clear the 230 // port before rendering, so everything from the GUI gets on top eventually. 231 // But in order to realise that, we also need a SceneManager with an empty scene, 232 // because the SceneManager is responsible for the render queue. 233 //this->emptySceneManager_ = Ogre::Root::getSingleton() 234 // .createSceneManager(Ogre::ST_GENERIC, "GUI/EmptySceneManager"); 235 236 // we also need a camera or we won't see anything at all. 237 // The camera settings don't matter at all for an empty scene since the GUI 238 // gets rendered on top of the screen rather than into the scene. 239 //this->emptyCamera_ = this->emptySceneManager_->createCamera("GUI/EmptyCamera"); 240 241 // Create another SceneManager that enables to display some 3D 242 // scene in the background of the main menu. 243 this->backgroundSceneManager_ = Ogre::Root::getSingleton() 244 .createSceneManager(Ogre::ST_GENERIC, "GUI/BackgroundSceneManager"); 245 this->backgroundCamera_ = backgroundSceneManager_->createCamera("GUI/BackgroundCamera"); 246 247 // TODO: create something 3D 174 /** 175 @brief 176 Calls main Lua script 177 @todo 178 Replace loadGUI.lua with loadGUI_2.lua after merging this back to trunk. 179 However CEGUI is able to execute a startup script. We could maybe put this call in this startup code. 180 181 This function calls the main Lua script for our GUI. 182 183 Additionally we set the datapath variable in Lua. This is needed so Lua can access the data used for the GUI. 184 */ 185 void GUIManager::loadLuaCode() 186 { 248 187 try 249 188 { 250 this->scriptModule_->executeScriptFile("loadGUI.lua", "GUI"); 189 // call main Lua script 190 this->scriptModule_->executeScriptFile("loadGUI_2.lua", "GUI"); 191 // set datapath for GUI data 192 lua_pushfstring(this->scriptModule_->getLuaState(), Core::getMediaPathString().c_str()); 193 lua_setglobal(this->scriptModule_->getLuaState(), "datapath"); 251 194 } 252 195 catch (CEGUI::Exception& ex) … … 261 204 } 262 205 263 void GUIManager::showGUI(const std::string& name, Ogre::SceneManager* sceneManager)// bool showBackground) 206 /** 207 @brief 208 used to tick the GUI 209 @param time 210 clock which provides time value for the GUI System 211 212 Ticking the GUI means updating it with a certain regularity. 213 The elapsed time since the last call is given in the time value provided by the clock. 214 This time value is then used to provide a fluent animation of the GUI. 215 */ 216 void GUIManager::update(const Clock& time) 217 { 218 assert(guiSystem_); 219 guiSystem_->injectTimePulse(time.getDeltaTime()); 220 } 221 222 /** 223 @brief 224 Executes Lua code 225 @param str 226 reference to string object holding the Lua code which is to be executed 227 228 This function gives total access to the GUI. You can execute ANY Lua code here. 229 */ 230 void GUIManager::executeCode(const std::string& str) 231 { 232 try 233 { 234 this->scriptModule_->executeString(str); 235 } 236 catch (CEGUI::Exception& ex) 237 { 238 COUT(2) << "CEGUI Error: \"" << ex.getMessage() << "\" while executing code \"" << str << "\"" << std::endl; 239 } 240 } 241 242 /** 243 @brief 244 Tells the GUIManager which SceneManager to use 245 @param camera 246 The current camera on which the GUI should be displayed on. 247 248 In fact the GUIManager needs the SceneManager and not the Camera to display the GUI. 249 This means the GUI is not bound to a camera but rather to the SceneManager. 250 Hidding the GUI when needed can therefore not be solved by just NOT setting the current camera. 251 */ 252 void GUIManager::setCamera(Ogre::Camera* camera) 253 { 254 this->guiRenderer_->setTargetSceneManager(camera->getSceneManager()); 255 } 256 257 /** 258 @brief 259 Displays specified GUI on screen 260 @param name 261 The name of the GUI 262 263 The function executes the Lua function with the same name in case the GUIManager is ready. 264 For more details check out loadGUI_2.lua where the function presides. 265 */ 266 void GUIManager::showGUI(const std::string& name) 264 267 { 265 268 if (state_ != Uninitialised) 266 269 { 267 if (state_ == OnDisplay) 268 hideGUI(); 269 270 COUT(3) << "Loading GUI " << name << std::endl; 270 //COUT(3) << "Loading GUI " << name << std::endl; 271 271 try 272 272 { 273 COUT (0) << "************* sceneManager: " << sceneManager << std::endl; 274 if (!sceneManager) 275 { 276 // currently, only an image is loaded. We could do 3D, see loadBackground. 277 //this->viewport_->setClearEveryFrame(true); 278 this->guiRenderer_->setTargetSceneManager(this->backgroundSceneManager_); 279 //this->viewport_->setCamera(this->backgroundCamera_); 280 281 lua_pushboolean(this->scriptModule_->getLuaState(), true); 282 lua_setglobal(this->scriptModule_->getLuaState(), "showBackground"); 283 } 284 else 285 { 286 //this->viewport_->setClearEveryFrame(false); 287 this->guiRenderer_->setTargetSceneManager(sceneManager); 288 //this->viewport_->setCamera(this->emptyCamera_); 289 290 lua_pushboolean(this->scriptModule_->getLuaState(), false); 291 lua_setglobal(this->scriptModule_->getLuaState(), "showBackground"); 292 } 293 294 this->scriptModule_->executeScriptGlobal("showMainMenu"); 295 296 InputManager::getInstance().requestEnterState("gui"); 297 298 this->state_ = OnDisplay; 273 this->scriptModule_->executeString(std::string("showGUI(\"") + name + "\")"); 299 274 } 300 275 catch (CEGUI::Exception& ex) … … 313 288 } 314 289 315 void GUIManager::hideGUI() 316 { 317 if (this->state_ != OnDisplay) 318 return; 319 //this->viewport_->setCamera(0); 320 // has no effect since you cannot assign 0 as SceneManager 321 //this->guiRenderer_->setTargetSceneManager(0); 322 this->state_ = Ready; 323 InputManager::getInstance().requestLeaveState("gui"); 324 } 325 290 /** 291 @brief 292 Function receiving a mouse button pressed event. 293 @param id 294 ID of the mouse button which got pressed 295 296 This function is inherited by MouseHandler and injects the event into CEGUI. 297 It is for CEGUI to process the event. 298 */ 326 299 void GUIManager::mouseButtonPressed(MouseButtonCode::ByEnum id) 327 300 { … … 337 310 } 338 311 312 /** 313 @brief 314 Function receiving a mouse button released event. 315 @param id 316 ID of the mouse button which got released 317 318 This function is inherited by MouseHandler and injects the event into CEGUI. 319 It is for CEGUI to process the event. 320 */ 339 321 void GUIManager::mouseButtonReleased(MouseButtonCode::ByEnum id) 340 322 { … … 350 332 } 351 333 352 334 /** 335 @brief 336 converts mouse event code to CEGUI event code 337 @param button 338 code of the mouse button as we use it in Orxonox 339 @return 340 code of the mouse button as it is used by CEGUI 341 342 Simple convertion from mouse event code in Orxonox to the one used in CEGUI. 343 */ 353 344 inline CEGUI::MouseButton GUIManager::convertButton(MouseButtonCode::ByEnum button) 354 345 { -
code/trunk/src/orxonox/gui/GUIManager.h
r2790 r2896 23 23 * Reto Grieder 24 24 * Co-authors: 25 * ...25 * Benjamin Knecht 26 26 * 27 27 */ … … 49 49 { 50 50 /** 51 @class GUIManager 51 52 @brief 52 Provides a simple interface to CEGUI with tolua methods and console commands 53 Provides a simple interface to CEGUI with tolua methods and console commands. It also acts as a key and mouse handler. 54 55 The GUIManager is a singleton and can be called anywhere when access on the GUI is needed. 56 Creation of the GUIManager is therefore not possible and the cunstructor is private. 57 58 Since the GUI needs user input, the GUIManager implements the functions needed to act as a key and/or mouse handler. 59 Those input events are then injected into CEGUI in Lua. 53 60 */ 54 61 class _OrxonoxExport GUIManager … … 59 66 // tolua_end 60 67 public: 68 /** 69 @enum State 70 The current state of the GUIManager. There should maybe be more (or we can omit this totally). 71 */ 61 72 enum State 62 73 { 63 Uninitialised, 64 Ready, 65 OnDisplay 74 Uninitialised, //!< Initial state of the GUIManager 75 Ready, //!< State after initialisation if ready 76 OnDisplay //!< State if GUI is displayed 66 77 }; 67 78 … … 70 81 71 82 bool initialise(Ogre::RenderWindow* renderWindow); 72 void loadScene(const std::string& name);73 void tick(float dt)74 {75 assert(guiSystem_);76 guiSystem_->injectTimePulse(dt);77 }78 void showGUI(const std::string& name, Ogre::SceneManager* sceneManager);// bool showBackground); // tolua_export79 void hideGUI(); // tolua_export80 83 81 Ogre::Camera* getCamera() { return this->backgroundCamera_; }84 void update(const Clock& time); 82 85 83 static void showGUI_s(const std::string& name, Ogre::SceneManager* sceneManager)//bool showBackground)84 {85 getInstance().showGUI(name, sceneManager); 86 }86 void showGUI(const std::string& name); 87 void executeCode(const std::string& str); 88 89 void setCamera(Ogre::Camera* camera); 87 90 88 91 static GUIManager& getInstance() { assert(singletonRef_s); return *singletonRef_s; } // tolua_export … … 90 93 91 94 private: 92 GUIManager(const GUIManager& instance); 95 GUIManager(const GUIManager& instance); //!< private constructor (this is a singleton class) 93 96 97 void loadLuaCode(); 98 99 // keyHandler functions 94 100 void keyPressed (const KeyEvent& evt) 95 { guiSystem_->injectKeyDown(evt.key); guiSystem_->injectChar(evt.text); }101 { guiSystem_->injectKeyDown(evt.key); guiSystem_->injectChar(evt.text); } 96 102 void keyReleased(const KeyEvent& evt) 97 { guiSystem_->injectKeyUp(evt.key); } 98 void keyHeld (const KeyEvent& evt) 99 { } 103 { guiSystem_->injectKeyUp(evt.key); } 104 void keyHeld (const KeyEvent& evt) { } 100 105 106 // mouseHandler functions 101 107 void mouseButtonPressed (MouseButtonCode::ByEnum id); 102 108 void mouseButtonReleased(MouseButtonCode::ByEnum id); 103 void mouseButtonHeld (MouseButtonCode::ByEnum id) 104 { } 109 void mouseButtonHeld (MouseButtonCode::ByEnum id) { } 105 110 void mouseMoved (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize) 106 { guiSystem_->injectMouseMove(rel.x, rel.y); }111 { guiSystem_->injectMouseMove(rel.x, rel.y); } 107 112 void mouseScrolled (int abs, int rel) 108 { guiSystem_->injectMouseWheelChange(rel);}113 { guiSystem_->injectMouseWheelChange(rel);} 109 114 110 void tickInput(float dt) { } 111 void tickKey(float dt) { } 112 void tickMouse(float dt) { } 113 114 void loadScenes(); 115 116 //Ogre::SceneManager* emptySceneManager_; 117 Ogre::SceneManager* backgroundSceneManager_; 118 //Ogre::Camera* emptyCamera_; 119 Ogre::Camera* backgroundCamera_; 120 //Ogre::Viewport* viewport_; 121 Ogre::RenderWindow* renderWindow_; 122 CEGUI::OgreCEGUIRenderer* guiRenderer_; 123 CEGUI::ResourceProvider* resourceProvider_; 124 CEGUI::LuaScriptModule* scriptModule_; 125 CEGUI::DefaultLogger* ceguiLogger_; 126 CEGUI::System* guiSystem_; 127 CEGUI::Imageset* backgroundImage_; 128 lua_State* luaState_; 129 130 State state_; 115 void updateInput(float dt) { } 116 void updateKey (float dt) { } 117 void updateMouse(float dt) { } 131 118 132 119 static CEGUI::MouseButton convertButton(MouseButtonCode::ByEnum button); 133 120 134 static GUIManager* singletonRef_s; 121 Ogre::RenderWindow* renderWindow_; //!< Ogre's render window to give CEGUI access to it 122 CEGUI::OgreCEGUIRenderer* guiRenderer_; //!< CEGUI's interface to the Ogre Engine 123 CEGUI::ResourceProvider* resourceProvider_; //!< CEGUI's resource provider 124 CEGUI::LuaScriptModule* scriptModule_; //!< CEGUI's script module to use Lua 125 CEGUI::DefaultLogger* ceguiLogger_; //!< CEGUI's logger to be able to log CEGUI errors in our log 126 CEGUI::System* guiSystem_; //!< CEGUI's main system 127 lua_State* luaState_; //!< Lua state, access point to the Lua engine 128 129 State state_; //!< reflects state of the GUIManager 130 131 static GUIManager* singletonRef_s; //!< Singleton reference to GUIManager 135 132 }; // tolua_export 136 133 } // tolua_export -
code/trunk/src/orxonox/objects/EventTarget.cc
r2662 r2896 66 66 void EventTarget::addAsEvent(BaseObject* object) 67 67 { 68 if (object != (BaseObject*)this)68 if (object != static_cast<BaseObject*>(this)) 69 69 object->addEvent(this, ""); 70 70 } -
code/trunk/src/orxonox/objects/Level.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/orxonox/objects/Level.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/orxonox/objects/Radar.cc
r2662 r2896 144 144 for (ObjectList<RadarViewable>::iterator it = ObjectList<RadarViewable>::begin(); it; ++it) 145 145 { 146 if (*it == (RadarViewable*)this->owner_)146 if (*it == static_cast<RadarViewable*>(this)->owner_) 147 147 continue; 148 148 -
code/trunk/src/orxonox/objects/Scene.cc
r2662 r2896 41 41 42 42 #include "core/CoreIncludes.h" 43 #include "core/ Core.h"43 #include "core/GameMode.h" 44 44 #include "core/XMLPort.h" 45 45 #include "tools/BulletConversions.h" … … 57 57 this->bShadows_ = true; 58 58 59 if ( Core::showsGraphics())59 if (GameMode::showsGraphics()) 60 60 { 61 61 if (Ogre::Root::getSingletonPtr()) … … 99 99 Ogre::Root::getSingleton().destroySceneManager(this->sceneManager_); 100 100 } 101 else if (! Core::showsGraphics())101 else if (!GameMode::showsGraphics()) 102 102 { 103 103 delete this->sceneManager_; … … 227 227 void Scene::tick(float dt) 228 228 { 229 if (! Core::showsGraphics())229 if (!GameMode::showsGraphics()) 230 230 { 231 231 // We need to update the scene nodes if we don't render … … 256 256 void Scene::setSkybox(const std::string& skybox) 257 257 { 258 if ( Core::showsGraphics() && this->sceneManager_)258 if (GameMode::showsGraphics() && this->sceneManager_) 259 259 this->sceneManager_->setSkyBox(true, skybox); 260 260 … … 264 264 void Scene::setAmbientLight(const ColourValue& colour) 265 265 { 266 if ( Core::showsGraphics() && this->sceneManager_)266 if (GameMode::showsGraphics() && this->sceneManager_) 267 267 this->sceneManager_->setAmbientLight(colour); 268 268 … … 272 272 void Scene::setShadow(bool bShadow) 273 273 { 274 if ( Core::showsGraphics() && this->sceneManager_)274 if (GameMode::showsGraphics() && this->sceneManager_) 275 275 { 276 276 if (bShadow) -
code/trunk/src/orxonox/objects/collisionshapes
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/orxonox/objects/controllers/AIController.cc
r2662 r2896 30 30 #include "AIController.h" 31 31 32 #include "core/ Core.h"32 #include "core/GameMode.h" 33 33 #include "core/CoreIncludes.h" 34 34 #include "core/Executor.h" … … 45 45 RegisterObject(AIController); 46 46 47 if ( Core::isMaster())47 if (GameMode::isMaster()) 48 48 this->actionTimer_.setTimer(ACTION_INTERVAL, true, this, createExecutor(createFunctor(&AIController::action))); 49 49 } -
code/trunk/src/orxonox/objects/gametypes/Gametype.cc
r2890 r2896 36 36 #include "core/ConfigValueIncludes.h" 37 37 #include "core/Template.h" 38 #include "core/ Core.h"38 #include "core/GameMode.h" 39 39 #include "overlays/OverlayGroup.h" 40 40 #include "objects/infos/PlayerInfo.h" … … 65 65 66 66 // load the corresponding score board 67 if ( Core::showsGraphics() && this->scoreboardTemplate_ != "")67 if (GameMode::showsGraphics() && this->scoreboardTemplate_ != "") 68 68 { 69 69 this->scoreboard_ = new OverlayGroup(this); -
code/trunk/src/orxonox/objects/infos/Bot.cc
r2662 r2896 30 30 #include "Bot.h" 31 31 32 #include "core/ Core.h"32 #include "core/GameMode.h" 33 33 #include "core/CoreIncludes.h" 34 34 #include "core/ConfigValueIncludes.h" … … 46 46 47 47 this->bHumanPlayer_ = false; 48 this->bLocalPlayer_ = Core::isMaster();48 this->bLocalPlayer_ = GameMode::isMaster(); 49 49 this->bSetUnreadyAfterSpawn_ = false; 50 50 this->setReadyToSpawn(true); -
code/trunk/src/orxonox/objects/infos/HumanPlayer.cc
r2890 r2896 30 30 #include "HumanPlayer.h" 31 31 32 #include "core/ Core.h"32 #include "core/GameMode.h" 33 33 #include "core/CoreIncludes.h" 34 34 #include "core/ConfigValueIncludes.h" … … 47 47 RegisterObject(HumanPlayer); 48 48 49 this->server_initialized_ = Core::isMaster();49 this->server_initialized_ = GameMode::isMaster(); 50 50 this->client_initialized_ = false; 51 51 … … 93 93 this->synchronize_nick_ = this->nick_; 94 94 95 if ( Core::isMaster())95 if (GameMode::isMaster()) 96 96 this->setName(this->nick_); 97 97 } … … 116 116 this->client_initialized_ = true; 117 117 118 if (! Core::isMaster())118 if (!GameMode::isMaster()) 119 119 this->setObjectMode(objectDirection::bidirectional); 120 120 else -
code/trunk/src/orxonox/objects/items/MultiStateEngine.cc
r2809 r2896 30 30 #include "MultiStateEngine.h" 31 31 32 #include "core/ Core.h"32 #include "core/GameMode.h" 33 33 #include "core/CoreIncludes.h" 34 34 #include "core/XMLPort.h" … … 123 123 } 124 124 125 if ( Core::isMaster())125 if (GameMode::isMaster()) 126 126 { 127 127 for (std::list<WorldEntity*>::const_iterator it = this->activeEffects_.begin(); it != this->activeEffects_.end(); ++it) -
code/trunk/src/orxonox/objects/pickup/PickupSpawner.cc
r2662 r2896 89 89 ExecutorMember<BaseObject>* executor = createExecutor(createFunctor(&BaseObject::setActive)); 90 90 executor->setDefaultValues(true); 91 RespawnTimer_.setTimer(this->respawntimer_, false, (BaseObject*)this, executor);91 RespawnTimer_.setTimer(this->respawntimer_, false, this, executor); 92 92 COUT(0) << "TIMER SET" << std::endl; 93 93 } -
code/trunk/src/orxonox/objects/pickup/Usable.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/orxonox/objects/quest/AddQuest.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/orxonox/objects/quest/AddQuest.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/orxonox/objects/quest/AddQuestHint.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/orxonox/objects/quest/AddQuestHint.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/orxonox/objects/quest/AddReward.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/orxonox/objects/quest/AddReward.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/orxonox/objects/quest/ChangeQuestStatus.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/orxonox/objects/quest/ChangeQuestStatus.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/orxonox/objects/quest/CompleteQuest.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/orxonox/objects/quest/CompleteQuest.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/orxonox/objects/quest/FailQuest.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/orxonox/objects/quest/FailQuest.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/orxonox/objects/quest/GlobalQuest.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/orxonox/objects/quest/GlobalQuest.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/orxonox/objects/quest/LocalQuest.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/orxonox/objects/quest/LocalQuest.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/orxonox/objects/quest/Quest.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/orxonox/objects/quest/Quest.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/orxonox/objects/quest/QuestDescription.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/orxonox/objects/quest/QuestDescription.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/orxonox/objects/quest/QuestEffect.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/orxonox/objects/quest/QuestEffect.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/orxonox/objects/quest/QuestHint.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/orxonox/objects/quest/QuestHint.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/orxonox/objects/quest/QuestItem.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/orxonox/objects/quest/QuestItem.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/orxonox/objects/quest/QuestManager.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/orxonox/objects/quest/QuestManager.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/orxonox/objects/quest/Rewardable.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/orxonox/objects/quest/Rewardable.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/orxonox/objects/weaponSystem/WeaponSystem.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/orxonox/objects/weaponSystem/WeaponSystem.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/orxonox/objects/weaponSystem/projectiles/BillboardProjectile.cc
r2662 r2896 32 32 #include <OgreBillboardSet.h> 33 33 34 #include "core/ Core.h"34 #include "core/GameMode.h" 35 35 #include "core/CoreIncludes.h" 36 36 #include "objects/Scene.h" … … 44 44 RegisterObject(BillboardProjectile); 45 45 46 if ( Core::showsGraphics())46 if (GameMode::showsGraphics()) 47 47 { 48 48 assert(this->getScene()->getSceneManager()); // getScene() was already checked by WorldEntity … … 56 56 BillboardProjectile::~BillboardProjectile() 57 57 { 58 if (this->isInitialized() && Core::showsGraphics() && this->billboard_.getBillboardSet())58 if (this->isInitialized() && GameMode::showsGraphics() && this->billboard_.getBillboardSet()) 59 59 this->detachOgreObject(this->billboard_.getBillboardSet()); 60 60 } -
code/trunk/src/orxonox/objects/weaponSystem/projectiles/ParticleProjectile.cc
r2662 r2896 33 33 #include <OgreParticleEmitter.h> 34 34 35 #include "core/ Core.h"35 #include "core/GameMode.h" 36 36 #include "core/CoreIncludes.h" 37 37 #include "core/ConfigValueIncludes.h" … … 46 46 RegisterObject(ParticleProjectile); 47 47 48 if ( Core::showsGraphics())48 if (GameMode::showsGraphics()) 49 49 { 50 50 this->particles_ = new ParticleInterface(this->getScene()->getSceneManager(), "Orxonox/shot3_small", LODParticle::normal); -
code/trunk/src/orxonox/objects/weaponSystem/projectiles/Projectile.cc
r2809 r2896 41 41 #include "objects/worldentities/ParticleSpawner.h" 42 42 #include "objects/collisionshapes/SphereCollisionShape.h" 43 #include "core/ Core.h"43 #include "core/GameMode.h" 44 44 45 45 namespace orxonox … … 55 55 // Get notification about collisions 56 56 57 if ( Core::isMaster())57 if (GameMode::isMaster()) 58 58 { 59 59 this->enableCollisionCallback(); … … 93 93 void Projectile::destroyObject() 94 94 { 95 if ( Core::isMaster())95 if (GameMode::isMaster()) 96 96 delete this; 97 97 } … … 99 99 bool Projectile::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint) 100 100 { 101 if (!this->bDestroy_ && Core::isMaster())101 if (!this->bDestroy_ && GameMode::isMaster()) 102 102 { 103 103 this->bDestroy_ = true; -
code/trunk/src/orxonox/objects/worldentities/Backlight.cc
- Property svn:mergeinfo changed
/code/branches/gui/src/orxonox/objects/worldentities/Backlight.cc (added) merged: 2848
r2893 r2896 33 33 #include <OgreSceneManager.h> 34 34 35 #include "core/ Core.h"35 #include "core/GameMode.h" 36 36 #include "core/CoreIncludes.h" 37 37 #include "core/Executor.h" … … 58 58 this->tickcount_ = 0; 59 59 60 if ( Core::showsGraphics())60 if (GameMode::showsGraphics()) 61 61 { 62 62 if (!this->getScene()) - Property svn:mergeinfo changed
-
code/trunk/src/orxonox/objects/worldentities/Backlight.h
- Property svn:mergeinfo changed
/code/branches/gui/src/orxonox/objects/worldentities/Backlight.h (added) merged: 2843
r2893 r2896 32 32 #include "OrxonoxPrereqs.h" 33 33 #include "FadingBillboard.h" 34 #include " gamestates/GSRoot.h"34 #include "tools/TimeFactorListener.h" 35 35 36 36 namespace orxonox - Property svn:mergeinfo changed
-
code/trunk/src/orxonox/objects/worldentities/Billboard.cc
r2662 r2896 34 34 #include "core/CoreIncludes.h" 35 35 #include "core/XMLPort.h" 36 #include "core/ Core.h"36 #include "core/GameMode.h" 37 37 #include "objects/Scene.h" 38 38 … … 81 81 if (!this->billboard_.getBillboardSet()) 82 82 { 83 if (this->getScene() && Core::showsGraphics())83 if (this->getScene() && GameMode::showsGraphics()) 84 84 { 85 85 this->billboard_.setBillboardSet(this->getScene()->getSceneManager(), this->material_, this->colour_, 1); … … 98 98 { 99 99 /* 100 if (this->getScene() && Core::showsGraphics() && (this->material_ != ""))100 if (this->getScene() && GameMode::showsGraphics() && (this->material_ != "")) 101 101 { 102 102 this->billboard_.setBillboardSet(this->getScene()->getSceneManager(), this->material_, this->colour_, 1); -
code/trunk/src/orxonox/objects/worldentities/BlinkingBillboard.cc
r2662 r2896 30 30 #include "BlinkingBillboard.h" 31 31 32 #include "core/ Core.h"32 #include "core/GameMode.h" 33 33 #include "core/CoreIncludes.h" 34 34 #include "core/XMLPort.h" … … 77 77 SUPER(BlinkingBillboard, tick, dt); 78 78 79 if ( Core::isMaster() && this->isActive())79 if (GameMode::isMaster() && this->isActive()) 80 80 { 81 81 this->time_ += dt; -
code/trunk/src/orxonox/objects/worldentities/Camera.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/orxonox/objects/worldentities/Camera.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/orxonox/objects/worldentities/ControllableEntity.cc
r2851 r2896 34 34 #include "core/CoreIncludes.h" 35 35 #include "core/ConfigValueIncludes.h" 36 #include "core/ Core.h"36 #include "core/GameMode.h" 37 37 #include "core/XMLPort.h" 38 38 #include "core/Template.h" … … 245 245 this->startLocalHumanControl(); 246 246 247 if (! Core::isMaster())247 if (!GameMode::isMaster()) 248 248 { 249 249 this->client_overwrite_ = this->server_overwrite_; … … 357 357 if (!this->isDynamic()) 358 358 { 359 if ( Core::isMaster())359 if (GameMode::isMaster()) 360 360 { 361 361 this->server_position_ = this->getPosition(); … … 472 472 void ControllableEntity::setPosition(const Vector3& position) 473 473 { 474 if ( Core::isMaster())474 if (GameMode::isMaster()) 475 475 { 476 476 MobileEntity::setPosition(position); … … 487 487 void ControllableEntity::setOrientation(const Quaternion& orientation) 488 488 { 489 if ( Core::isMaster())489 if (GameMode::isMaster()) 490 490 { 491 491 MobileEntity::setOrientation(orientation); … … 502 502 void ControllableEntity::setVelocity(const Vector3& velocity) 503 503 { 504 if ( Core::isMaster())504 if (GameMode::isMaster()) 505 505 { 506 506 MobileEntity::setVelocity(velocity); … … 517 517 void ControllableEntity::setAngularVelocity(const Vector3& velocity) 518 518 { 519 if ( Core::isMaster())519 if (GameMode::isMaster()) 520 520 { 521 521 MobileEntity::setAngularVelocity(velocity); … … 533 533 { 534 534 MobileEntity::setWorldTransform(worldTrans); 535 if ( Core::isMaster())535 if (GameMode::isMaster()) 536 536 { 537 537 this->server_position_ = this->getPosition(); -
code/trunk/src/orxonox/objects/worldentities/ExplosionChunk.cc
r2759 r2896 32 32 #include <OgreParticleSystem.h> 33 33 34 #include "core/ Core.h"34 #include "core/GameMode.h" 35 35 #include "core/CoreIncludes.h" 36 36 #include "core/Executor.h" … … 47 47 RegisterObject(ExplosionChunk); 48 48 49 if ( Core::showsGraphics() && ( !this->getScene() || !this->getScene()->getSceneManager() ) )49 if ( GameMode::showsGraphics() && ( !this->getScene() || !this->getScene()->getSceneManager() ) ) 50 50 ThrowException(AbortLoading, "Can't create ExplosionChunk, no scene or no scene manager given."); 51 51 … … 53 53 this->LOD_ = LODParticle::normal; 54 54 55 if ( Core::showsGraphics() )55 if ( GameMode::showsGraphics() ) 56 56 { 57 57 try … … 75 75 } 76 76 77 if ( Core::isMaster())77 if (GameMode::isMaster()) 78 78 { 79 79 Vector3 velocity(rnd(-1, 1), rnd(-1, 1), rnd(-1, 1)); … … 132 132 this->smoke_->setEnabled(false); 133 133 134 if ( Core::isMaster())134 if (GameMode::isMaster()) 135 135 { 136 136 this->bStop_ = true; … … 148 148 static const unsigned int CHANGES_PER_SECOND = 5; 149 149 150 if ( Core::isMaster() && rnd() < dt*CHANGES_PER_SECOND)150 if (GameMode::isMaster() && rnd() < dt*CHANGES_PER_SECOND) 151 151 { 152 152 float length = this->getVelocity().length(); -
code/trunk/src/orxonox/objects/worldentities/Light.cc
r2662 r2896 37 37 #include "util/String.h" 38 38 #include "util/Exception.h" 39 #include "core/ Core.h"39 #include "core/GameMode.h" 40 40 #include "core/CoreIncludes.h" 41 41 #include "core/XMLPort.h" … … 57 57 this->spotlightRange_ = Vector3(40.0f, 30.0f, 1.0f); 58 58 59 if ( Core::showsGraphics())59 if (GameMode::showsGraphics()) 60 60 { 61 61 if (!this->getScene()) -
code/trunk/src/orxonox/objects/worldentities/MobileEntity.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/orxonox/objects/worldentities/MobileEntity.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/orxonox/objects/worldentities/Model.cc
r2662 r2896 31 31 #include <OgreEntity.h> 32 32 #include "Model.h" 33 #include "core/GameMode.h" 33 34 #include "core/CoreIncludes.h" 34 35 #include "core/XMLPort.h" … … 70 71 void Model::changedMesh() 71 72 { 72 if ( Core::showsGraphics())73 if (GameMode::showsGraphics()) 73 74 { 74 75 if (this->mesh_.getEntity()) -
code/trunk/src/orxonox/objects/worldentities/MovableEntity.cc
r2662 r2896 34 34 #include "core/XMLPort.h" 35 35 #include "core/Executor.h" 36 #include "core/ Core.h"36 #include "core/GameMode.h" 37 37 38 38 namespace orxonox … … 89 89 void MovableEntity::resynchronize() 90 90 { 91 if ( Core::isMaster() && !this->continuousResynchroTimer_)91 if (GameMode::isMaster() && !this->continuousResynchroTimer_) 92 92 { 93 93 // Resynchronise every few seconds because we only work with velocities (no positions) -
code/trunk/src/orxonox/objects/worldentities/ParticleEmitter.cc
r2662 r2896 39 39 #include "tools/ParticleInterface.h" 40 40 #include "util/Exception.h" 41 #include "core/GameMode.h" 41 42 #include "core/CoreIncludes.h" 42 43 #include "core/XMLPort.h" … … 51 52 RegisterObject(ParticleEmitter); 52 53 53 if ( Core::showsGraphics() && (!this->getScene() || !this->getScene()->getSceneManager()))54 if (GameMode::showsGraphics() && (!this->getScene() || !this->getScene()->getSceneManager())) 54 55 ThrowException(AbortLoading, "Can't create ParticleEmitter, no scene or no scene manager given."); 55 56 … … 107 108 } 108 109 109 if ( Core::showsGraphics() && this->getScene() && this->getScene()->getSceneManager())110 if (GameMode::showsGraphics() && this->getScene() && this->getScene()->getSceneManager()) 110 111 { 111 112 try -
code/trunk/src/orxonox/objects/worldentities/ParticleSpawner.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/orxonox/objects/worldentities/ParticleSpawner.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/orxonox/objects/worldentities/Planet.cc
r2710 r2896 42 42 #include "CameraManager.h" 43 43 #include "Camera.h" 44 #include "Graphics Engine.h"44 #include "GraphicsManager.h" 45 45 46 46 namespace orxonox -
code/trunk/src/orxonox/objects/worldentities/PongBall.cc
r2885 r2896 31 31 32 32 #include "core/CoreIncludes.h" 33 #include "core/GameMode.h" 33 34 #include "objects/worldentities/PongBat.h" 34 35 #include "objects/gametypes/Gametype.h" … … 53 54 SUPER(PongBall, tick, dt); 54 55 55 if ( Core::isMaster())56 if (GameMode::isMaster()) 56 57 { 57 58 Vector3 position = this->getPosition(); -
code/trunk/src/orxonox/objects/worldentities/StaticEntity.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/orxonox/objects/worldentities/StaticEntity.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/orxonox/objects/worldentities/pawns/Pawn.cc
r2893 r2896 30 30 #include "Pawn.h" 31 31 32 #include "core/ Core.h"32 #include "core/GameMode.h" 33 33 #include "core/CoreIncludes.h" 34 34 #include "core/XMLPort.h" … … 63 63 this->getPickUp().setPlayer(this); 64 64 65 if ( Core::isMaster())65 if (GameMode::isMaster()) 66 66 { 67 67 this->weaponSystem_ = new WeaponSystem(this); … … 211 211 this->getPlayer()->stopControl(this); 212 212 213 if ( Core::isMaster())213 if (GameMode::isMaster()) 214 214 this->deatheffect(); 215 215 } … … 260 260 { 261 261 this->setHealth(this->initialHealth_); 262 if ( Core::isMaster())262 if (GameMode::isMaster()) 263 263 this->spawneffect(); 264 264 } -
code/trunk/src/orxonox/objects/worldentities/pawns/Spectator.cc
r2662 r2896 34 34 #include "core/CoreIncludes.h" 35 35 #include "core/ConfigValueIncludes.h" 36 #include "core/ Core.h"36 #include "core/GameMode.h" 37 37 #include "objects/worldentities/Model.h" 38 38 #include "objects/Scene.h" … … 63 63 this->setDestroyWhenPlayerLeft(true); 64 64 65 if ( Core::showsGraphics())65 if (GameMode::showsGraphics()) 66 66 { 67 67 this->greetingFlare_ = new BillboardSet(); … … 206 206 this->bGreeting_ = !this->bGreeting_; 207 207 208 if ( Core::isMaster())208 if (GameMode::isMaster()) 209 209 { 210 210 this->bGreetingFlareVisible_ = this->bGreeting_; -
code/trunk/src/orxonox/objects/worldentities/triggers/DistanceTrigger.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/orxonox/objects/worldentities/triggers/DistanceTrigger.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/orxonox/objects/worldentities/triggers/Trigger.cc
- Property svn:mergeinfo changed
/code/branches/gui/src/orxonox/objects/worldentities/triggers/Trigger.cc (added) merged: 2848
r2893 r2896 36 36 #include "core/ConsoleCommand.h" 37 37 #include "core/XMLPort.h" 38 #include "core/ Core.h"38 #include "core/GameMode.h" 39 39 #include "objects/Scene.h" 40 40 … … 67 67 // this->bUpdating_ = false; 68 68 69 if (this->getScene() && Core::showsGraphics())69 if (this->getScene() && GameMode::showsGraphics()) 70 70 { 71 71 this->debugBillboard_.setBillboardSet(this->getScene()->getSceneManager(), "Examples/Flare", ColourValue(1.0, 0.0, 0.0), 1); - Property svn:mergeinfo changed
-
code/trunk/src/orxonox/objects/worldentities/triggers/Trigger.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/orxonox/overlays/OrxonoxOverlay.cc
r2662 r2896 39 39 #include <OgreOverlayManager.h> 40 40 #include <OgrePanelOverlayElement.h> 41 #include <OgreRenderWindow.h> 42 41 43 #include "util/Convert.h" 42 44 #include "util/Exception.h" 43 45 #include "util/String.h" 44 #include "core/ Core.h"46 #include "core/GameMode.h" 45 47 #include "core/CoreIncludes.h" 46 48 #include "core/XMLPort.h" 47 49 #include "core/ConsoleCommand.h" 50 #include "GraphicsManager.h" 48 51 49 52 namespace orxonox … … 64 67 this->group_ = 0; 65 68 66 if (! Core::showsGraphics())69 if (!GameMode::showsGraphics()) 67 70 ThrowException(NoGraphics, "Can't create OrxonoxOverlay, graphics engine not initialized"); 68 71 … … 77 80 this->overlay_->add2D(this->background_); 78 81 79 // We'll have to set the aspect ratio to a default value first.80 // GSGraphics gets informed about our construction here and can update us in the next tick.81 this->windowAspectRatio_ = 1.0;82 // Get aspect ratio from the render window. Later on, we get informed automatically 83 Ogre::RenderWindow* defaultWindow = GraphicsManager::getInstance().getRenderWindow(); 84 this->windowAspectRatio_ = (float)defaultWindow->getWidth() / defaultWindow->getHeight(); 82 85 this->sizeCorrectionChanged(); 83 86 … … 175 178 /** 176 179 @brief 177 Called by the Graphics Enginewhenever the window size changes.180 Called by the GraphicsManager whenever the window size changes. 178 181 Calculates the aspect ratio only. 179 182 */ 180 void OrxonoxOverlay::windowResized( int newWidth,int newHeight)183 void OrxonoxOverlay::windowResized(unsigned int newWidth, unsigned int newHeight) 181 184 { 182 185 this->windowAspectRatio_ = newWidth/(float)newHeight; -
code/trunk/src/orxonox/overlays/OrxonoxOverlay.h
r2890 r2896 200 200 201 201 private: 202 void windowResized( int newWidth,int newHeight);202 void windowResized(unsigned int newWidth, unsigned int newHeight); 203 203 204 204 static unsigned int hudOverlayCounter_s; //!< Static counter for hud elements -
code/trunk/src/orxonox/overlays/console/InGameConsole.cc
r2087 r2896 42 42 #include "util/Convert.h" 43 43 #include "util/Debug.h" 44 #include "core/Clock.h" 44 45 #include "core/CoreIncludes.h" 45 46 #include "core/ConfigValueIncludes.h" … … 172 173 { 173 174 // create the corresponding input state 174 inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("console", 40);175 inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("console", false, false, InputStatePriority::Console); 175 176 inputState_->setKeyHandler(Shell::getInstance().getInputBuffer()); 176 177 bHidesAllInputChanged(); … … 347 348 @brief Used to control the actual scrolling and the cursor. 348 349 */ 349 void InGameConsole:: tick(float dt)350 void InGameConsole::update(const Clock& time) 350 351 { 351 352 if (this->scroll_ != 0) … … 358 359 // enlarge oldTop a little bit so that this exponential function 359 360 // reaches 0 before infinite time has passed... 360 float deltaScroll = (oldTop - 0.01) * dt* this->scrollSpeed_;361 float deltaScroll = (oldTop - 0.01) * time.getDeltaTime() * this->scrollSpeed_; 361 362 if (oldTop - deltaScroll >= 0) 362 363 { … … 373 374 // scrolling up 374 375 // note: +0.01 for the same reason as when scrolling down 375 float deltaScroll = (1.2 * this->relativeHeight + 0.01 + oldTop) * dt* this->scrollSpeed_;376 float deltaScroll = (1.2 * this->relativeHeight + 0.01 + oldTop) * time.getDeltaTime() * this->scrollSpeed_; 376 377 if (oldTop - deltaScroll <= -1.2 * this->relativeHeight) 377 378 { … … 388 389 if (this->bActive_) 389 390 { 390 this->cursor_ += dt;391 this->cursor_ += time.getDeltaTime(); 391 392 if (this->cursor_ >= this->blinkTime) 392 393 { … … 409 410 @brief Resizes the console elements. Call if window size changes. 410 411 */ 411 void InGameConsole::windowResized( int newWidth,int newHeight)412 void InGameConsole::windowResized(unsigned int newWidth, unsigned int newHeight) 412 413 { 413 414 this->windowW_ = newWidth; -
code/trunk/src/orxonox/overlays/console/InGameConsole.h
r2087 r2896 53 53 void setConfigValues(); 54 54 55 v irtual void tick(float dt);55 void update(const Clock& time); 56 56 57 57 static InGameConsole& getInstance() { assert(singletonRef_s); return *singletonRef_s; } … … 81 81 void print(const std::string& text, int index, bool alwaysShift = false); 82 82 83 void windowResized( int newWidth,int newHeight);83 void windowResized(unsigned int newWidth, unsigned int newHeight); 84 84 85 85 // config value related -
code/trunk/src/orxonox/overlays/debug/DebugFPSText.cc
r2662 r2896 30 30 #include "DebugFPSText.h" 31 31 #include <OgreTextAreaOverlayElement.h> 32 #include "util/Convert.h" 32 33 #include "core/CoreIncludes.h" 33 #include "GraphicsEngine.h" 34 #include "util/Convert.h" 34 #include "core/Game.h" 35 35 36 36 namespace orxonox … … 51 51 SUPER(DebugFPSText, tick, dt); 52 52 53 float fps = G raphicsEngine::getInstance().getAverageFramesPerSecond();53 float fps = Game::getInstance().getAvgFPS(); 54 54 this->setCaption(convertToString(fps)); 55 55 } -
code/trunk/src/orxonox/overlays/debug/DebugRTRText.cc
r2662 r2896 32 32 #include "core/CoreIncludes.h" 33 33 #include "util/Convert.h" 34 #include " GraphicsEngine.h"34 #include "core/Game.h" 35 35 36 36 namespace orxonox … … 51 51 SUPER(DebugRTRText, tick, dt); 52 52 53 float rtr = G raphicsEngine::getInstance().getAverageTickTime();53 float rtr = Game::getInstance().getAvgTickTime(); 54 54 this->setCaption(convertToString(rtr)); 55 55 } -
code/trunk/src/orxonox/overlays/hud/HUDRadar.cc
r2662 r2896 94 94 void HUDRadar::displayObject(RadarViewable* object, bool bIsMarked) 95 95 { 96 if (object == (RadarViewable*)this->owner_)96 if (object == static_cast<RadarViewable*>(this->owner_)) 97 97 return; 98 98 -
code/trunk/src/orxonox/tools/BillboardSet.cc
r2662 r2896 37 37 #include <OgreBillboard.h> 38 38 39 #include "core/ Core.h"39 #include "core/GameMode.h" 40 40 #include "util/Convert.h" 41 41 #include "util/String.h" … … 72 72 try 73 73 { 74 if ( Core::showsGraphics())74 if (GameMode::showsGraphics()) 75 75 { 76 76 this->billboardSet_ = scenemanager->createBillboardSet("Billboard" + convertToString(BillboardSet::billboardSetCounter_s++), count); … … 95 95 try 96 96 { 97 if ( Core::showsGraphics())97 if (GameMode::showsGraphics()) 98 98 { 99 99 this->billboardSet_ = scenemanager->createBillboardSet("Billboard" + convertToString(BillboardSet::billboardSetCounter_s++), count); -
code/trunk/src/orxonox/tools/CMakeLists.txt
r2710 r2896 5 5 Shader.cc 6 6 TextureGenerator.cc 7 TimeFactorListener.cc 7 8 Timer.cc 8 9 WindowEventListener.cc -
code/trunk/src/orxonox/tools/Mesh.cc
r2870 r2896 35 35 #include <cassert> 36 36 37 #include "core/ Core.h"37 #include "core/GameMode.h" 38 38 #include "util/Convert.h" 39 39 #include "util/String.h" … … 64 64 this->scenemanager_->destroyEntity(this->entity_); 65 65 66 if ( Core::showsGraphics())66 if (GameMode::showsGraphics()) 67 67 { 68 68 try -
code/trunk/src/orxonox/tools/ParticleInterface.cc
r2662 r2896 40 40 #include <cassert> 41 41 42 #include "Graphics Engine.h"43 #include "core/ Core.h"42 #include "GraphicsManager.h" 43 #include "core/GameMode.h" 44 44 #include "core/CoreIncludes.h" 45 45 #include "util/Convert.h" … … 64 64 this->speedFactor_ = 1.0f; 65 65 66 if ( Core::showsGraphics())66 if (GameMode::showsGraphics()) 67 67 { 68 68 try … … 178 178 { 179 179 this->detaillevel_ = level; 180 if (G raphicsEngine::getInstancePtr())181 this->detailLevelChanged(Graphics Engine::getInstance().getDetailLevelParticle());180 if (GameMode::showsGraphics()) 181 this->detailLevelChanged(GraphicsManager::getInstance().getDetailLevelParticle()); 182 182 } 183 183 -
code/trunk/src/orxonox/tools/ParticleInterface.h
r2662 r2896 37 37 #include "core/OrxonoxClass.h" 38 38 #include "util/Math.h" 39 #include " gamestates/GSRoot.h"39 #include "tools/TimeFactorListener.h" 40 40 41 41 #define getAllEmitters() \ -
code/trunk/src/orxonox/tools/Shader.cc
r2662 r2896 36 36 #include <OgrePlugin.h> 37 37 38 #include "core/ Core.h"38 #include "core/GameMode.h" 39 39 #include "core/CoreIncludes.h" 40 40 #include "core/Executor.h" 41 #include "Graphics Engine.h"41 #include "GraphicsManager.h" 42 42 #include "util/Exception.h" 43 43 … … 59 59 this->compositorInstance_ = 0; 60 60 this->bVisible_ = true; 61 this->bLoadCompositor_ = Core::showsGraphics() && GraphicsEngine::getInstancePtr();61 this->bLoadCompositor_ = GameMode::showsGraphics(); 62 62 this->bViewportInitialized_ = false; 63 63 this->compositor_ = ""; … … 86 86 if (this->bLoadCompositor_ && this->compositorInstance_) 87 87 { 88 Ogre::Viewport* viewport = Graphics Engine::getInstance().getViewport();88 Ogre::Viewport* viewport = GraphicsManager::getInstance().getViewport(); 89 89 assert(viewport); 90 90 Ogre::CompositorManager::getSingleton().removeCompositor(viewport, this->compositor_); … … 114 114 if (this->bLoadCompositor_) 115 115 { 116 Ogre::Viewport* viewport = Graphics Engine::getInstance().getViewport();116 Ogre::Viewport* viewport = GraphicsManager::getInstance().getViewport(); 117 117 assert(viewport); 118 118 if (this->oldcompositor_ != "") … … 246 246 Shader::ParameterPointer* Shader::getParameterPointer(const std::string& material, size_t technique, size_t pass, const std::string& parameter) 247 247 { 248 if (! Core::showsGraphics() || !Shader::bLoadedCgPlugin_s)248 if (!GameMode::showsGraphics() || !Shader::bLoadedCgPlugin_s) 249 249 return 0; 250 250 -
code/trunk/src/orxonox/tools/Timer.h
r2662 r2896 64 64 #include "core/Executor.h" 65 65 #include "core/OrxonoxClass.h" 66 #include " gamestates/GSRoot.h"66 #include "tools/TimeFactorListener.h" 67 67 68 68 namespace orxonox -
code/trunk/src/orxonox/tools/WindowEventListener.h
r2662 r2896 49 49 50 50 /** Window has resized */ 51 virtual void windowResized( int newWidth,int newHeight) { }51 virtual void windowResized(unsigned int newWidth, unsigned int newHeight) { } 52 52 53 53 /** Window has lost/gained focus */
Note: See TracChangeset
for help on using the changeset viewer.