Changeset 2908 for code/branches/questsystem5/src/orxonox
- Timestamp:
- Apr 8, 2009, 12:58:47 AM (16 years ago)
- Location:
- code/branches/questsystem5
- Files:
-
- 4 added
- 30 deleted
- 151 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/questsystem5
- Property svn:mergeinfo changed
-
code/branches/questsystem5/src/orxonox/CMakeLists.txt
r2907 r2908 20 20 SET_SOURCE_FILES(ORXONOX_SRC_FILES 21 21 CameraManager.cc 22 Graphics Manager.cc22 GraphicsEngine.cc 23 23 LevelManager.cc 24 24 Main.cc -
code/branches/questsystem5/src/orxonox/CameraManager.cc
- Property svn:mergeinfo changed
/code/branches/gui/src/orxonox/CameraManager.cc removed /code/branches/miniprojects/src/orxonox/CameraManager.cc removed /code/branches/weaponsystem/src/orxonox/CameraManager.cc removed
r2907 r2908 35 35 #include <OgreResource.h> 36 36 37 #include "core/ GameMode.h"37 #include "core/Core.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"44 43 45 44 namespace orxonox … … 75 74 void CameraManager::requestFocus(Camera* camera) 76 75 { 77 if (! GameMode::showsGraphics())76 if (!Core::showsGraphics()) 78 77 return; 79 78 … … 100 99 void CameraManager::releaseFocus(Camera* camera) 101 100 { 102 if (! GameMode::showsGraphics())101 if (!Core::showsGraphics()) 103 102 return; 104 103 … … 142 141 143 142 this->viewport_->setCamera(camera); 144 GUIManager::getInstance().setCamera(camera);145 143 146 144 // reactivate all visible compositors - Property svn:mergeinfo changed
-
code/branches/questsystem5/src/orxonox/CameraManager.h
- Property svn:mergeinfo changed
/code/branches/gui/src/orxonox/CameraManager.h removed /code/branches/miniprojects/src/orxonox/CameraManager.h removed /code/branches/weaponsystem/src/orxonox/CameraManager.h removed
- Property svn:mergeinfo changed
-
code/branches/questsystem5/src/orxonox/Main.cc
r2907 r2908 27 27 * 28 28 */ 29 30 /**31 @mainpage Orxonox Documentation32 */33 29 34 30 /** … … 38 34 39 35 #include "OrxonoxStableHeaders.h" 36 37 #include <exception> 38 #include <cassert> 39 40 40 #include "OrxonoxConfig.h" 41 #include "util/Debug.h" 42 #include "util/SignalHandler.h" 43 #include "core/ConfigFileManager.h" 44 #include "core/CommandLine.h" 45 #include "core/CommandExecutor.h" 46 #include "core/Identifier.h" 47 #include "core/Core.h" 48 #include "core/Language.h" 41 49 42 #include "util/Debug.h" 43 #include "core/Identifier.h" 44 #include "core/Game.h" 50 #include "gamestates/GSRoot.h" 51 #include "gamestates/GSGraphics.h" 52 #include "gamestates/GSStandalone.h" 53 #include "gamestates/GSServer.h" 54 #include "gamestates/GSClient.h" 55 #include "gamestates/GSDedicated.h" 56 #include "gamestates/GSGUI.h" 57 #include "gamestates/GSIOConsole.h" 45 58 46 /* 47 @brief 48 Main method. Game starts here (except for static initialisations). 49 */ 59 #ifdef ORXONOX_PLATFORM_APPLE 60 #include <CoreFoundation/CoreFoundation.h> 61 62 // This function will locate the path to our application on OS X, 63 // unlike windows you can not rely on the curent working directory 64 // for locating your configuration files and resources. 65 std::string macBundlePath() 66 { 67 char path[1024]; 68 CFBundleRef mainBundle = CFBundleGetMainBundle(); 69 assert(mainBundle); 70 71 CFURLRef mainBundleURL = CFBundleCopyBundleURL(mainBundle); 72 assert(mainBundleURL); 73 74 CFStringRef cfStringRef = CFURLCopyFileSystemPath( mainBundleURL, kCFURLPOSIXPathStyle); 75 assert(cfStringRef); 76 77 CFStringGetCString(cfStringRef, path, 1024, kCFStringEncodingASCII); 78 79 CFRelease(mainBundleURL); 80 CFRelease(cfStringRef); 81 82 return std::string(path); 83 } 84 #endif 85 86 87 SetCommandLineArgument(settingsFile, "orxonox.ini"); 88 SetCommandLineArgument(configFileDirectory, ""); 89 50 90 int main(int argc, char** argv) 51 91 { 92 using namespace orxonox; 93 94 // Parse command line arguments 95 try 52 96 { 53 orxonox::Game orxonox(argc, argv); 97 CommandLine::parseAll(argc, argv); 98 } 99 catch (ArgumentException& ex) 100 { 101 COUT(1) << ex.what() << std::endl; 102 COUT(0) << "Usage:" << std::endl << "orxonox " << CommandLine::getUsageInformation() << std::endl; 103 } 54 104 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 ); 105 // Do this after parsing the command line to allow customisation 106 Core::postMainInitialisation(); 69 107 70 orxonox.run(); 71 } // orxonox gets destroyed right here! 108 // create a signal handler (only active for linux) 109 SignalHandler signalHandler; 110 signalHandler.doCatch(argv[0], Core::getLogPathString() + "orxonox_crash.log"); 111 112 // Create the ConfigFileManager before creating the GameStates in order to have 113 // setConfigValues() in the constructor (required). 114 ConfigFileManager* configFileManager = new ConfigFileManager(); 115 configFileManager->setFilename(ConfigFileType::Settings, CommandLine::getValue("settingsFile").getString()); 116 // create the Core settings to configure the output level 117 Language* language = new Language(); 118 Core* core = new Core(); 119 120 // put GameStates in its own scope so we can destroy the identifiers at the end of main(). 121 { 122 // create the gamestates 123 GSRoot root; 124 GSGraphics graphics; 125 GSStandalone standalone; 126 GSServer server; 127 GSClient client; 128 GSDedicated dedicated; 129 GSGUI gui; 130 GSIOConsole ioConsole; 131 132 // make the hierarchy 133 root.addChild(&graphics); 134 graphics.addChild(&standalone); 135 graphics.addChild(&server); 136 graphics.addChild(&client); 137 graphics.addChild(&gui); 138 root.addChild(&ioConsole); 139 root.addChild(&dedicated); 140 141 // Here happens the game 142 root.start(); 143 } 144 145 // destroy singletons 146 delete core; 147 delete language; 148 delete configFileManager; 72 149 73 150 // Clean up class hierarchy stuff (identifiers, xmlport, configvalue, consolecommand) 74 // Needs to be done after Game destructor because of ~OrxonoxClass 75 orxonox::Identifier::destroyAllIdentifiers(); 151 Identifier::destroyAllIdentifiers(); 152 // destroy command line arguments 153 CommandLine::destroyAllArguments(); 154 // Also delete external console command that don't belong to an Identifier 155 CommandExecutor::destroyExternalCommands(); 76 156 77 157 return 0; -
code/branches/questsystem5/src/orxonox/OrxonoxPrereqs.h
r2907 r2908 77 77 namespace MunitionType 78 78 { 79 80 81 79 82 enum Enum 80 83 { laserGunMunition }; … … 94 97 95 98 96 class GraphicsManager; 97 class OgreWindowEventListener; 99 class GraphicsEngine; 98 100 class Settings; 99 101 … … 101 103 class Radar; 102 104 class RadarListener; 103 104 class Teamcolourable;105 105 106 106 class CameraManager; … … 150 150 class ParticleSpawner; 151 151 152 class PongCenterpoint;153 class PongBall;154 class PongBat;155 156 152 class Camera; 157 153 class CameraPosition; 158 154 class SpawnPoint; 159 class TeamSpawnPoint;160 155 161 156 class Spectator; … … 181 176 class LaserGun; 182 177 class LaserGunMunition; 183 class FusionMunition;184 178 185 179 class EventListener; … … 192 186 class AIController; 193 187 class ScriptController; 194 class PongAI;195 188 196 189 class Info; … … 198 191 class HumanPlayer; 199 192 class Bot; 200 class PongBot;201 193 class GametypeInfo; 202 194 203 195 class Gametype; 204 class Deathmatch;205 class TeamDeathmatch;206 class Pong;207 196 208 197 class Scores; … … 250 239 //gui 251 240 class GUIManager; 241 242 // game states 243 class GSRoot; 244 class GSGraphics; 245 class GSIO; 246 class GSIOConsole; 247 class GSLevel; 248 class GSStandalone; 249 class GSServer; 250 class GSClient; 251 class GSGUI; 252 252 } 253 253 -
code/branches/questsystem5/src/orxonox/PlayerManager.cc
r2907 r2908 31 31 32 32 #include "LevelManager.h" 33 #include "core/ GameMode.h"33 #include "core/Core.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 ( GameMode::isMaster())60 if (Core::isMaster()) 61 61 { 62 62 COUT(3) << "client connected" << std::endl; … … 77 77 void PlayerManager::clientDisconnected(unsigned int clientID) 78 78 { 79 if ( GameMode::isMaster())79 if (Core::isMaster()) 80 80 { 81 81 COUT(3) << "client disconnected" << std::endl; … … 97 97 PlayerInfo* PlayerManager::getClient(unsigned int clientID) const 98 98 { 99 if ( GameMode::isMaster())99 if (Core::isMaster()) 100 100 { 101 101 std::map<unsigned int, PlayerInfo*>::const_iterator it = this->clients_.find(clientID); -
code/branches/questsystem5/src/orxonox/gamestates/CMakeLists.txt
r2907 r2908 1 1 ADD_SOURCE_FILES(ORXONOX_SRC_FILES 2 GSDedicated.cc 2 3 GSClient.cc 3 GSDedicated.cc4 4 GSGraphics.cc 5 GSGUI.cc 5 6 GSIOConsole.cc 6 7 GSLevel.cc 7 GSMainMenu.cc8 8 GSRoot.cc 9 9 GSServer.cc -
code/branches/questsystem5/src/orxonox/gamestates/GSClient.cc
r2907 r2908 31 31 32 32 #include "core/input/InputManager.h" 33 #include "core/Clock.h"34 33 #include "core/CommandLine.h" 35 #include "core/Game.h" 36 #include "core/GameMode.h" 34 #include "core/Core.h" 37 35 #include "network/Client.h" 38 36 39 37 namespace orxonox 40 38 { 41 AddGameState(GSClient, "client");42 43 39 SetCommandLineArgument(ip, "127.0.0.1").information("#.#.#.#"); 44 40 45 GSClient::GSClient( const std::string& name)46 : GameState (name)41 GSClient::GSClient() 42 : GameState<GSGraphics>("client") 47 43 , client_(0) 48 44 { … … 53 49 } 54 50 55 void GSClient:: activate()51 void GSClient::enter() 56 52 { 57 GameMode::setIsClient(true);53 Core::setIsClient(true); 58 54 59 55 this->client_ = new Client(CommandLine::getValue("ip").getString(), CommandLine::getValue("port")); … … 62 58 ThrowException(InitialisationFailed, "Could not establish connection with server."); 63 59 64 client_->update(Game::getInstance().getGameClock()); 60 GSLevel::enter(this->getParent()->getViewport()); 61 62 client_->tick(0); 65 63 } 66 64 67 void GSClient:: deactivate()65 void GSClient::leave() 68 66 { 67 GSLevel::leave(); 68 69 69 client_->closeConnection(); 70 70 … … 72 72 delete this->client_; 73 73 74 GameMode::setIsClient(false);74 Core::setIsClient(false); 75 75 } 76 76 77 void GSClient:: update(const Clock& time)77 void GSClient::ticked(const Clock& time) 78 78 { 79 client_->update(time); 79 GSLevel::ticked(time); 80 client_->tick(time.getDeltaTime()); 81 82 this->tickChild(time); 80 83 } 81 84 } -
code/branches/questsystem5/src/orxonox/gamestates/GSClient.h
r2907 r2908 31 31 32 32 #include "OrxonoxPrereqs.h" 33 #include "core/GameState.h"34 33 #include "network/NetworkPrereqs.h" 34 #include "GSLevel.h" 35 #include "GSGraphics.h" 35 36 36 37 namespace orxonox 37 38 { 38 class _OrxonoxExport GSClient : public GameState 39 class _OrxonoxExport GSClient : public GameState<GSGraphics>, public GSLevel 39 40 { 40 41 public: 41 GSClient( const std::string& name);42 GSClient(); 42 43 ~GSClient(); 43 44 44 void activate();45 void deactivate();46 void update(const Clock& time);47 45 48 46 private: 47 void enter(); 48 void leave(); 49 void ticked(const Clock& time); 50 49 51 Client* client_; 50 52 }; -
code/branches/questsystem5/src/orxonox/gamestates/GSDedicated.cc
r2907 r2908 30 30 #include "GSDedicated.h" 31 31 32 #include "core/Clock.h"33 32 #include "core/CommandLine.h" 34 #include "core/Game.h" 35 #include "core/GameMode.h" 33 #include "core/Core.h" 36 34 #include "core/Iterator.h" 37 35 #include "network/Server.h" … … 41 39 namespace orxonox 42 40 { 43 AddGameState(GSDedicated, "dedicated"); 44 45 GSDedicated::GSDedicated(const std::string& name) 46 : GameState(name) 41 GSDedicated::GSDedicated() 42 : GameState<GSRoot>("dedicated") 47 43 , server_(0) 48 44 , timeSinceLastUpdate_(0) … … 54 50 } 55 51 56 void GSDedicated:: activate()52 void GSDedicated::enter() 57 53 { 58 GameMode::setHasServer(true);54 Core::setHasServer(true); 59 55 60 56 this->server_ = new Server(CommandLine::getValue("port")); 61 57 COUT(0) << "Loading scene in server mode" << std::endl; 62 58 59 GSLevel::enter(0); 60 63 61 server_->open(); 64 62 } 65 63 66 void GSDedicated:: deactivate()64 void GSDedicated::leave() 67 65 { 66 GSLevel::leave(); 67 68 68 this->server_->close(); 69 69 delete this->server_; 70 70 71 GameMode::setHasServer(false);71 Core::setHasServer(false); 72 72 } 73 73 74 void GSDedicated:: update(const Clock& time)74 void GSDedicated::ticked(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 server_->update(time); 84 GSLevel::ticked(time); 85 server_->tick(time.getDeltaTime()); 86 this->tickChild(time); 85 87 } 86 88 else -
code/branches/questsystem5/src/orxonox/gamestates/GSDedicated.h
r2907 r2908 31 31 32 32 #include "OrxonoxPrereqs.h" 33 #include "core/GameState.h"34 33 #include "network/NetworkPrereqs.h" 34 #include "GSLevel.h" 35 #include "GSRoot.h" 35 36 36 37 namespace orxonox 37 38 { 38 class _OrxonoxExport GSDedicated : public GameState 39 class _OrxonoxExport GSDedicated : public GameState<GSRoot>, public GSLevel 39 40 { 40 41 public: 41 GSDedicated( const std::string& name);42 GSDedicated(); 42 43 ~GSDedicated(); 43 44 44 void activate(); 45 void deactivate(); 46 void update(const Clock& time); 45 private: 46 void enter(); 47 void leave(); 48 void ticked(const Clock& time); 47 49 48 private: 49 Server* server_; 50 float timeSinceLastUpdate_; 50 Server* server_; 51 float timeSinceLastUpdate_; 51 52 }; 52 53 } -
code/branches/questsystem5/src/orxonox/gamestates/GSGraphics.cc
r2907 r2908 23 23 * Reto Grieder 24 24 * Co-authors: 25 * Benjamin Knecht 26 * 27 */ 28 29 /** 30 @file 31 @brief Implementation of Graphics GameState class. 25 * ... 26 * 32 27 */ 33 28 … … 35 30 #include "GSGraphics.h" 36 31 32 #include <fstream> 37 33 #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> 38 41 #include <OgreRenderWindow.h> 39 42 #include <OgreRenderSystem.h> 43 #include <OgreTextureManager.h> 44 #include <OgreViewport.h> 45 #include <OgreWindowEventUtilities.h> 46 47 #include "SpecialConfig.h" 40 48 #include "util/Debug.h" 49 #include "util/Exception.h" 50 #include "util/String.h" 51 #include "util/SubString.h" 52 #include "core/ConsoleCommand.h" 41 53 #include "core/ConfigValueIncludes.h" 42 #include "core/Clock.h" 43 #include "core/ConsoleCommand.h" 54 #include "core/CoreIncludes.h" 44 55 #include "core/Core.h" 45 #include "core/CoreIncludes.h"46 #include "core/Game.h"47 #include "core/GameMode.h"48 56 #include "core/input/InputManager.h" 49 57 #include "core/input/KeyBinder.h" 50 #include "core/input/ SimpleInputState.h"58 #include "core/input/ExtendedInputState.h" 51 59 #include "core/Loader.h" 52 60 #include "core/XMLFile.h" 53 61 #include "overlays/console/InGameConsole.h" 54 62 #include "gui/GUIManager.h" 55 #include "GraphicsManager.h" 63 #include "tools/WindowEventListener.h" 64 65 // for compatibility 66 #include "GraphicsEngine.h" 56 67 57 68 namespace orxonox 58 69 { 59 AddGameState(GSGraphics, "graphics"); 60 61 GSGraphics::GSGraphics(const std::string& name) 62 : GameState(name) 70 GSGraphics::GSGraphics() 71 : GameState<GSRoot>("graphics") 72 , renderWindow_(0) 73 , viewport_(0) 74 , bWindowEventListenerUpdateRequired_(false) 63 75 , inputManager_(0) 64 76 , console_(0) 65 77 , guiManager_(0) 66 , graphicsManager_(0) 78 , ogreRoot_(0) 79 , ogreLogger_(0) 80 , graphicsEngine_(0) 67 81 , masterKeyBinder_(0) 68 , masterInputState_(0)69 82 , debugOverlay_(0) 70 83 { 71 84 RegisterRootObject(GSGraphics); 85 setConfigValues(); 72 86 } 73 87 … … 76 90 } 77 91 78 /**79 @brief80 this function does nothing81 82 Indeed. Here goes nothing.83 */84 92 void GSGraphics::setConfigValues() 85 93 { 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 106 setConfigValues(); 107 108 // initialise graphics manager. Doesn't load the render window yet! 109 this->graphicsManager_ = new GraphicsManager(); 110 this->graphicsManager_->initialise(); 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); 111 135 112 136 // load debug overlay … … 115 139 Loader::open(debugOverlay_); 116 140 141 // Calls the InputManager which sets up the input devices. 117 142 // The render window width and height are used to set up the mouse movement. 143 inputManager_ = new InputManager(); 118 144 size_t windowHnd = 0; 119 Ogre::RenderWindow* renderWindow = GraphicsManager::getInstance().getRenderWindow(); 120 renderWindow->getCustomAttribute("WINDOW", &windowHnd); 121 122 // Calls the InputManager which sets up the input devices. 123 inputManager_ = new InputManager(); 124 inputManager_->initialise(windowHnd, renderWindow->getWidth(), renderWindow->getHeight(), true); 125 126 // load master key bindings 127 masterInputState_ = InputManager::getInstance().createInputState<SimpleInputState>("master", true); 145 this->renderWindow_->getCustomAttribute("WINDOW", &windowHnd); 146 inputManager_->initialise(windowHnd, renderWindow_->getWidth(), renderWindow_->getHeight(), true); 147 // Configure master input state with a KeyBinder 128 148 masterKeyBinder_ = new KeyBinder(); 129 149 masterKeyBinder_->loadBindings("masterKeybindings.ini"); 130 masterInputState_->setKeyHandler(masterKeyBinder_);150 inputManager_->getMasterInputState()->addKeyHandler(masterKeyBinder_); 131 151 132 152 // Load the InGameConsole 133 153 console_ = new InGameConsole(); 134 console_->initialise( renderWindow->getWidth(), renderWindow->getHeight());154 console_->initialise(this->renderWindow_->getWidth(), this->renderWindow_->getHeight()); 135 155 136 156 // load the CEGUI interface 137 157 guiManager_ = new GUIManager(); 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"); 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); 175 176 delete this->guiManager_; 177 178 delete this->console_; 179 180 //inputManager_->getMasterInputState()->removeKeyHandler(this->masterKeyBinder_); 167 181 delete this->masterKeyBinder_; 168 169 delete this->guiManager_; 170 delete this->console_; 182 delete this->inputManager_; 171 183 172 184 Loader::unload(this->debugOverlay_); 173 185 delete this->debugOverlay_; 174 186 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()"); 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); 193 219 } 194 220 … … 201 227 need the time. So we shouldn't run into problems. 202 228 */ 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 229 void GSGraphics::ticked(const Clock& time) 230 { 212 231 uint64_t timeBeforeTick = time.getRealMicroseconds(); 213 232 214 this->inputManager_->update(time); // tick console 215 this->console_->update(time); 216 this->guiManager_->update(time); 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 } 217 246 218 247 uint64_t timeAfterTick = time.getRealMicroseconds(); 219 248 220 // Also add our tick time 221 Game::getInstance().addTickTime(timeAfterTick - timeBeforeTick); 222 223 // Render 224 this->graphicsManager_->update(time); 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(); 225 484 } 226 485 … … 231 490 The render window it occured in 232 491 @note 233 Graphics Managerhas a render window stored itself. This is the same492 GraphicsEngine has a render window stored itself. This is the same 234 493 as rw. But we have to be careful when using multiple render windows! 235 494 */ 236 void GSGraphics::windowResized(unsigned int newWidth, unsigned int newHeight) 237 { 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 238 500 // OIS needs this under linux even if we only use relative input measurement. 239 501 if (this->inputManager_) 240 this->inputManager_->setWindowExtents( newWidth, newHeight);502 this->inputManager_->setWindowExtents(renderWindow_->getWidth(), renderWindow_->getHeight()); 241 503 } 242 504 … … 247 509 The render window it occured in 248 510 */ 249 void GSGraphics::windowFocusChanged() 250 { 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 251 516 // instruct InputManager to clear the buffers (core library so we cannot use the interface) 252 517 if (this->inputManager_) … … 254 519 } 255 520 521 /** 522 @brief 523 Window was closed. 524 @param rw 525 The render window it occured in 526 */ 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 } 256 539 } -
code/branches/questsystem5/src/orxonox/gamestates/GSGraphics.h
r2907 r2908 23 23 * Reto Grieder 24 24 * Co-authors: 25 * Benjamin Knecht (documentation)25 * ... 26 26 * 27 27 */ 28 29 /**30 @file31 @brief Declaration of the Graphics GameState class.32 */33 28 34 29 #ifndef _GSGraphics_H__ … … 36 31 37 32 #include "OrxonoxPrereqs.h" 33 #include <OgrePrerequisites.h> 34 #define NOMINMAX // required to stop windows.h screwing up std::min definition 35 #include <OgreWindowEventUtilities.h> 38 36 #include "core/GameState.h" 39 #include "tools/WindowEventListener.h" 37 #include "core/OrxonoxClass.h" 38 #include "GSRoot.h" 40 39 41 40 namespace orxonox 42 41 { 43 /**44 @class GSGraphics45 @brief46 Game state used when displaying graphics of any kind42 class _OrxonoxExport GSGraphics : public GameState<GSRoot>, public OrxonoxClass, 43 public Ogre::WindowEventListener, public Ogre::LogListener 44 { 45 friend class ClassIdentifier<GSGraphics>; 47 46 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 WindowEventListener51 {52 47 public: 53 GSGraphics( const std::string& name);48 GSGraphics(); 54 49 ~GSGraphics(); 50 51 Ogre::Root* getOgreRoot() { return this->ogreRoot_ ; } 52 Ogre::Viewport* getViewport() { return this->viewport_ ; } 53 GUIManager* getGUIManager() { return this->guiManager_; } 54 55 private: // functions 56 void enter(); 57 void leave(); 58 void ticked(const Clock& time); 59 55 60 void setConfigValues(); 56 61 57 void activate(); 58 void deactivate(); 59 void update(const Clock& time); 62 void setupOgre(); 63 void loadOgrePlugins(); 64 void declareResources(); 65 void loadRenderer(); 66 void initialiseResources(); 60 67 61 void toggleGUI(); 68 // console commands 69 void printScreen(); 62 70 63 private: 64 // Window events from WindowEventListener 65 void windowResized(unsigned int newWidth, unsigned int newHeight); 66 void windowFocusChanged(); 71 // event from Ogre::LogListener 72 void messageLogged(const std::string& message, Ogre::LogMessageLevel lml, 73 bool maskDebug, const std::string& logName); 74 75 // window events from Ogre::WindowEventListener 76 void windowMoved (Ogre::RenderWindow* rw); 77 void windowResized (Ogre::RenderWindow* rw); 78 void windowFocusChange (Ogre::RenderWindow* rw); 79 void windowClosed (Ogre::RenderWindow* rw); 80 81 void requestWindowEventListenerUpdate() { this->bWindowEventListenerUpdateRequired_ = true; } 82 83 private: // variables 84 Ogre::RenderWindow* renderWindow_; //!< the current render window 85 Ogre::Viewport* viewport_; //!< default full size viewport 86 bool bWindowEventListenerUpdateRequired_; //!< True if a new WindowEventListener was created but not yet updated. 67 87 68 88 // managed singletons 69 InputManager* inputManager_; //!< Reference to input management89 InputManager* inputManager_; 70 90 InGameConsole* console_; 71 GUIManager* guiManager_; //!< Interface to GUI 72 GraphicsManager* graphicsManager_; //!< Interface to Ogre 91 GUIManager* guiManager_; 92 Ogre::Root* ogreRoot_; //!< Ogre's root 93 Ogre::LogManager* ogreLogger_; 94 GraphicsEngine* graphicsEngine_; //!< Interface to Ogre 73 95 74 KeyBinder* masterKeyBinder_; //!< Key binder for master key bindings 75 SimpleInputState* masterInputState_; //!< Special input state for master input 96 KeyBinder* masterKeyBinder_; 76 97 XMLFile* debugOverlay_; 77 ConsoleCommand* ccToggleGUI_; //!< Console command to toggle GUI 98 99 // config values 100 std::string resourceFile_; //!< resources file name 101 std::string ogreConfigFile_; //!< ogre config file name 102 std::string ogrePluginsFolder_; //!< Folder where the Ogre plugins are located 103 std::string ogrePlugins_; //!< Comma separated list of all plugins to load 104 std::string ogreLogFile_; //!< log file name for Ogre log messages 105 int ogreLogLevelTrivial_; //!< Corresponding Orxonx debug level for LL_TRIVIAL 106 int ogreLogLevelNormal_; //!< Corresponding Orxonx debug level for LL_NORMAL 107 int ogreLogLevelCritical_; //!< Corresponding Orxonx debug level for LL_CRITICAL 108 109 // console commands 110 ConsoleCommand* ccPrintScreen_; 78 111 }; 79 112 } -
code/branches/questsystem5/src/orxonox/gamestates/GSIOConsole.cc
r2907 r2908 36 36 37 37 #include "core/ConsoleCommand.h" 38 #include "core/Game.h"39 38 40 39 namespace orxonox 41 40 { 42 AddGameState(GSIOConsole, "ioConsole"); 43 44 GSIOConsole::GSIOConsole(const std::string& name) 45 : GameState(name) 41 GSIOConsole::GSIOConsole() 42 : GameState<GSRoot>("ioConsole") 46 43 { 47 44 } … … 51 48 } 52 49 53 void GSIOConsole:: activate()50 void GSIOConsole::enter() 54 51 { 55 {56 FunctorMember<GSIOConsole>* functor = createFunctor(&GSIOConsole::loadMenu);57 functor->setObject(this);58 this->ccLoadMenu_ = createConsoleCommand(functor, "loadMenu");59 CommandExecutor::addConsoleCommandShortcut(this->ccLoadMenu_);60 }61 52 } 62 53 63 void GSIOConsole:: deactivate()54 void GSIOConsole::leave() 64 55 { 65 if (this->ccLoadMenu_)66 {67 delete this->ccLoadMenu_;68 this->ccLoadMenu_ = 0;69 }70 56 } 71 57 72 void GSIOConsole:: update(const Clock& time)58 void GSIOConsole::ticked(const Clock& time) 73 59 { 74 std::cout << ">";75 60 std::string command; 76 61 std::getline(std::cin, command); 77 62 CommandExecutor::execute(command, true); 78 } 79 80 void GSIOConsole::loadMenu() 81 { 82 Game::getInstance().popState(); 83 Game::getInstance().requestStates("graphics, mainMenu"); 63 64 tickChild(time); 84 65 } 85 66 } -
code/branches/questsystem5/src/orxonox/gamestates/GSIOConsole.h
r2907 r2908 31 31 32 32 #include "OrxonoxPrereqs.h" 33 #include <OgrePrerequisites.h> 33 34 #include "core/GameState.h" 35 #include "GSRoot.h" 34 36 35 37 namespace orxonox 36 38 { 37 class _OrxonoxExport GSIOConsole : public GameState 39 class _OrxonoxExport GSIOConsole : public GameState<GSRoot> 38 40 { 39 41 public: 40 GSIOConsole( const std::string& name);42 GSIOConsole(); 41 43 ~GSIOConsole(); 42 44 43 void activate();44 void deactivate();45 void update(const Clock& time);46 47 45 private: 48 void loadMenu(); 49 50 // console commands 51 ConsoleCommand* ccLoadMenu_; 46 void enter(); 47 void leave(); 48 void ticked(const Clock& time); 52 49 }; 53 50 } -
code/branches/questsystem5/src/orxonox/gamestates/GSLevel.cc
r2907 r2908 24 24 * Co-authors: 25 25 * Fabian 'x3n' Landau 26 * Benjamin Knecht27 26 * 28 27 */ … … 40 39 #include "core/CommandLine.h" 41 40 #include "core/ConfigValueIncludes.h" 41 #include "core/CoreIncludes.h" 42 42 #include "core/Core.h" 43 #include "core/CoreIncludes.h"44 #include "core/Game.h"45 #include "core/GameMode.h"46 43 #include "objects/Tickable.h" 47 44 #include "objects/Radar.h" 48 45 #include "CameraManager.h" 49 #include "GraphicsManager.h"50 46 #include "LevelManager.h" 51 47 #include "PlayerManager.h" 52 #include "orxonox/objects/quest/QuestManager.h" 53 #include "orxonox/overlays/notifications/NotificationManager.h" 54 #include "gui/GUIManager.h" 48 #include "objects/quest/QuestManager.h" 49 #include "overlays/notifications/NotificationManager.h" 55 50 56 51 namespace orxonox 57 52 { 58 AddGameState(GSLevel, "level"); 59 60 SetCommandLineArgument(level, "presentation_dm.oxw").shortcut("l"); 61 SetConsoleCommand(GSLevel, showIngameGUI, true); 62 63 GSLevel::GSLevel(const std::string& name) 64 : GameState(name) 65 , keyBinder_(0) 66 , gameInputState_(0) 67 , guiMouseOnlyInputState_(0) 68 , guiKeysOnlyInputState_(0) 53 SetCommandLineArgument(level, "presentation.oxw").shortcut("l"); 54 55 GSLevel::GSLevel() 56 // : GameState<GSGraphics>(name) 57 : keyBinder_(0) 58 , inputState_(0) 69 59 , radar_(0) 70 60 , startFile_(0) … … 76 66 this->ccKeybind_ = 0; 77 67 this->ccTkeybind_ = 0; 68 69 setConfigValues(); 78 70 } 79 71 … … 87 79 } 88 80 89 void GSLevel::activate() 90 { 91 setConfigValues(); 92 93 if (GameMode::showsGraphics()) 94 { 95 gameInputState_ = InputManager::getInstance().createInputState<SimpleInputState>("game"); 81 void GSLevel::enter(Ogre::Viewport* viewport) 82 { 83 if (Core::showsGraphics()) 84 { 85 inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("game", 20); 96 86 keyBinder_ = new KeyBinder(); 97 87 keyBinder_->loadBindings("keybindings.ini"); 98 gameInputState_->setHandler(keyBinder_); 99 100 guiMouseOnlyInputState_ = InputManager::getInstance().createInputState<SimpleInputState>("guiMouseOnly"); 101 guiMouseOnlyInputState_->setMouseHandler(GUIManager::getInstancePtr()); 102 103 guiKeysOnlyInputState_ = InputManager::getInstance().createInputState<SimpleInputState>("guiKeysOnly"); 104 guiKeysOnlyInputState_->setKeyHandler(GUIManager::getInstancePtr()); 88 inputState_->setHandler(keyBinder_); 105 89 106 90 // create the global CameraManager 107 this->cameraManager_ = new CameraManager(GraphicsManager::getInstance().getViewport()); 91 assert(viewport); 92 this->cameraManager_ = new CameraManager(viewport); 108 93 109 94 // Start the Radar … … 117 102 this->notificationManager_ = new NotificationManager(); 118 103 119 if ( GameMode::isMaster())104 if (Core::isMaster()) 120 105 { 121 106 // create the global LevelManager … … 125 110 } 126 111 127 if (GameMode::showsGraphics()) 128 { 112 if (Core::showsGraphics()) 113 { 114 // TODO: insert slomo console command with 115 // .accessLevel(AccessLevel::Offline).defaultValue(0, 1.0).axisParamIndex(0).isAxisRelative(false); 116 129 117 // keybind console command 130 118 FunctorMember<GSLevel>* functor1 = createFunctor(&GSLevel::keybind); … … 144 132 } 145 133 146 void GSLevel::showIngameGUI(bool show) 147 { 148 if (show) 149 { 150 GUIManager::getInstancePtr()->showGUI("inGameTest"); 151 GUIManager::getInstancePtr()->executeCode("showCursor()"); 152 InputManager::getInstance().requestEnterState("guiMouseOnly"); 153 } 154 else 155 { 156 GUIManager::getInstancePtr()->executeCode("hideGUI(\"inGameTest\")"); 157 GUIManager::getInstancePtr()->executeCode("hideCursor()"); 158 InputManager::getInstance().requestLeaveState("guiMouseOnly"); 159 } 160 } 161 162 void GSLevel::deactivate() 134 void GSLevel::leave() 163 135 { 164 136 // destroy console commands … … 173 145 this->ccTkeybind_ = 0; 174 146 } 175 176 147 177 148 // this call will delete every BaseObject! … … 181 152 //Loader::close(); 182 153 183 if ( GameMode::showsGraphics())154 if (Core::showsGraphics()) 184 155 InputManager::getInstance().requestLeaveState("game"); 185 156 186 if ( GameMode::isMaster())157 if (Core::isMaster()) 187 158 this->unloadLevel(); 188 159 … … 223 194 } 224 195 225 if (GameMode::showsGraphics()) 226 { 227 gameInputState_->setHandler(0); 228 guiMouseOnlyInputState_->setHandler(0); 229 guiKeysOnlyInputState_->setHandler(0); 196 if (Core::showsGraphics()) 197 { 198 inputState_->setHandler(0); 230 199 InputManager::getInstance().requestDestroyState("game"); 231 200 if (this->keyBinder_) … … 237 206 } 238 207 239 void GSLevel:: update(const Clock& time)240 { 241 // Note: Temporarily moved to GSGraphics.208 void GSLevel::ticked(const Clock& time) 209 { 210 // Commented by 1337: Temporarily moved to GSGraphics. 242 211 //// Call the scene objects 243 212 //for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it) … … 282 251 Command string that can be executed by the CommandExecutor 283 252 OR: Internal string "KeybindBindingStringKeyName=" used for the second call to identify 284 the key/button/axis that has been activated. This is configured above in activate().253 the key/button/axis that has been activated. This is configured above in enter(). 285 254 */ 286 255 void GSLevel::keybindInternal(const std::string& command, bool bTemporary) 287 256 { 288 if ( GameMode::showsGraphics())257 if (Core::showsGraphics()) 289 258 { 290 259 static std::string bindingString = ""; -
code/branches/questsystem5/src/orxonox/gamestates/GSLevel.h
r2907 r2908 23 23 * Reto Grieder 24 24 * Co-authors: 25 * Benjamin Knecht25 * ... 26 26 * 27 27 */ … … 31 31 32 32 #include "OrxonoxPrereqs.h" 33 #include <OgrePrerequisites.h> 33 34 #include "core/OrxonoxClass.h" 34 #include "core/GameState.h"35 35 36 36 namespace orxonox 37 37 { 38 class _OrxonoxExport GSLevel : public GameState, publicOrxonoxClass38 class _OrxonoxExport GSLevel : public OrxonoxClass 39 39 { 40 friend class ClassIdentifier<GSLevel>; 40 41 public: 41 GSLevel( const std::string& name);42 GSLevel(); 42 43 ~GSLevel(); 43 void setConfigValues();44 45 void activate();46 void deactivate();47 void update(const Clock& time);48 49 static void showIngameGUI(bool show);50 44 51 45 protected: 46 void enter(Ogre::Viewport* viewport); 47 void leave(); 48 void ticked(const Clock& time); 49 52 50 void loadLevel(); 53 51 void unloadLevel(); … … 58 56 void keybindInternal(const std::string& command, bool bTemporary); 59 57 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 69 QuestManager* questManager_; //!< quest manager for this level 70 NotificationManager* notificationManager_; //!< notification manager for this level 58 KeyBinder* keyBinder_; //!< tool that loads and manages the input bindings 59 SimpleInputState* inputState_; 60 Radar* radar_; //!< represents the Radar (not the HUD part) 61 XMLFile* startFile_; //!< current hard coded default level 62 CameraManager* cameraManager_; 63 LevelManager* levelManager_; 64 PlayerManager* playerManager_; 65 QuestManager* questManager_; 66 NotificationManager* notificationManager_; 71 67 72 68 //##### ConfigValues ##### … … 76 72 ConsoleCommand* ccKeybind_; 77 73 ConsoleCommand* ccTkeybind_; 74 75 private: 76 void setConfigValues(); 77 78 78 }; 79 79 } -
code/branches/questsystem5/src/orxonox/gamestates/GSRoot.cc
r2907 r2908 32 32 #include "util/Exception.h" 33 33 #include "util/Debug.h" 34 #include "core/Clock.h" 35 #include "core/Game.h" 36 #include "core/GameMode.h" 34 #include "core/Core.h" 35 #include "core/Factory.h" 36 #include "core/ConfigValueIncludes.h" 37 #include "core/CoreIncludes.h" 38 #include "core/ConsoleCommand.h" 37 39 #include "core/CommandLine.h" 38 #include "core/ConsoleCommand.h" 39 #include "tools/TimeFactorListener.h" 40 #include "core/Shell.h" 41 #include "core/TclBind.h" 42 #include "core/TclThreadManager.h" 43 #include "core/LuaBind.h" 40 44 #include "tools/Timer.h" 41 45 #include "objects/Tickable.h" 42 46 47 #ifdef ORXONOX_PLATFORM_WINDOWS 48 # ifndef WIN32_LEAN_AND_MEAN 49 # define WIN32_LEAN_AND_MEAN 50 # endif 51 # define NOMINMAX // required to stop windows.h screwing up std::min definition 52 # include "windows.h" 53 #endif 54 43 55 namespace orxonox 44 56 { 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) 57 SetCommandLineArgument(limitToCPU, 1).information("0: off | #cpu"); 58 59 GSRoot::GSRoot() 60 : RootGameState("root") 55 61 , timeFactor_(1.0f) 56 62 , bPaused_(false) 57 63 , timeFactorPauseBackup_(1.0f) 58 { 64 , tclBind_(0) 65 , tclThreadManager_(0) 66 , shell_(0) 67 { 68 RegisterRootObject(GSRoot); 69 setConfigValues(); 70 59 71 this->ccSetTimeFactor_ = 0; 60 72 this->ccPause_ = 0; … … 65 77 } 66 78 67 void GSRoot::activate() 68 { 79 void GSRoot::setConfigValues() 80 { 81 SetConfigValue(statisticsRefreshCycle_, 250000) 82 .description("Sets the time in microseconds interval at which average fps, etc. get updated."); 83 SetConfigValue(statisticsAvgLength_, 1000000) 84 .description("Sets the time in microseconds interval at which average fps, etc. gets calculated."); 85 } 86 87 void GSRoot::enter() 88 { 89 // creates the class hierarchy for all classes with factories 90 Factory::createClassHierarchy(); 91 69 92 // reset game speed to normal 70 this->timeFactor_ = 1.0f; 93 timeFactor_ = 1.0f; 94 95 // reset frame counter 96 this->statisticsStartTime_ = 0; 97 this->statisticsTickTimes_.clear(); 98 this->periodTickTime_ = 0; 99 this->avgFPS_ = 0.0f; 100 this->avgTickTime_ = 0.0f; 101 102 // Create the lua interface 103 this->luaBind_ = new LuaBind(); 104 105 // initialise TCL 106 this->tclBind_ = new TclBind(Core::getMediaPathString()); 107 this->tclThreadManager_ = new TclThreadManager(tclBind_->getTclInterpreter()); 108 109 // create a shell 110 this->shell_ = new Shell(); 111 112 // limit the main thread to the first core so that QueryPerformanceCounter doesn't jump 113 // do this after ogre has initialised. Somehow Ogre changes the settings again (not through 114 // the timer though). 115 int limitToCPU = CommandLine::getValue("limitToCPU"); 116 if (limitToCPU > 0) 117 setThreadAffinity((unsigned int)(limitToCPU - 1)); 118 119 { 120 // add console commands 121 FunctorMember<GSRoot>* functor = createFunctor(&GSRoot::exitGame); 122 functor->setObject(this); 123 this->ccExit_ = createConsoleCommand(functor, "exit"); 124 CommandExecutor::addConsoleCommandShortcut(this->ccExit_); 125 } 126 127 { 128 // add console commands 129 FunctorMember01<GameStateBase, const std::string&>* functor = createFunctor(&GameStateBase::requestState); 130 functor->setObject(this); 131 this->ccSelectGameState_ = createConsoleCommand(functor, "selectGameState"); 132 CommandExecutor::addConsoleCommandShortcut(this->ccSelectGameState_); 133 } 71 134 72 135 { … … 85 148 CommandExecutor::addConsoleCommandShortcut(this->ccPause_).accessLevel(AccessLevel::Offline); 86 149 } 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 { 150 } 151 152 void GSRoot::leave() 153 { 154 // destroy console commands 155 delete this->ccExit_; 156 delete this->ccSelectGameState_; 157 158 delete this->shell_; 159 delete this->tclThreadManager_; 160 delete this->tclBind_; 161 162 delete this->luaBind_; 163 121 164 if (this->ccSetTimeFactor_) 122 165 { … … 132 175 } 133 176 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 177 void GSRoot::ticked(const Clock& time) 178 { 143 179 uint64_t timeBeforeTick = time.getRealMicroseconds(); 180 181 TclThreadManager::getInstance().tick(time.getDeltaTime()); 144 182 145 183 for (ObjectList<TimerBase>::iterator it = ObjectList<TimerBase>::begin(); it; ++it) … … 160 198 uint64_t timeAfterTick = time.getRealMicroseconds(); 161 199 162 // Also add our tick time 163 Game::getInstance().addTickTime(timeAfterTick - timeBeforeTick); 200 // STATISTICS 201 assert(timeAfterTick - timeBeforeTick >= 0 ); 202 statisticsTickInfo tickInfo = {timeAfterTick, timeAfterTick - timeBeforeTick}; 203 statisticsTickTimes_.push_back(tickInfo); 204 assert(statisticsTickTimes_.back().tickLength==tickInfo.tickLength); 205 this->periodTickTime_ += tickInfo.tickLength; 206 207 // Ticks GSGraphics or GSDedicated 208 this->tickChild(time); 209 210 if (timeAfterTick > statisticsStartTime_ + statisticsRefreshCycle_) 211 { 212 std::list<statisticsTickInfo>::iterator it = this->statisticsTickTimes_.begin(); 213 assert(it != this->statisticsTickTimes_.end()); 214 int64_t lastTime = timeAfterTick - statisticsAvgLength_; 215 if ((int64_t)it->tickTime < lastTime) 216 { 217 do 218 { 219 assert(this->periodTickTime_ > it->tickLength); 220 this->periodTickTime_ -= it->tickLength; 221 ++it; 222 assert(it != this->statisticsTickTimes_.end()); 223 } while ((int64_t)it->tickTime < lastTime); 224 this->statisticsTickTimes_.erase(this->statisticsTickTimes_.begin(), it); 225 } 226 227 uint32_t framesPerPeriod = this->statisticsTickTimes_.size(); 228 this->avgFPS_ = (float)framesPerPeriod / (timeAfterTick - this->statisticsTickTimes_.front().tickTime) * 1000000.0; 229 this->avgTickTime_ = (float)this->periodTickTime_ / framesPerPeriod / 1000.0; 230 231 statisticsStartTime_ = timeAfterTick; 232 } 233 234 } 235 236 /** 237 @note 238 The code of this function has been copied and adjusted from OGRE, an open source graphics engine. 239 (Object-oriented Graphics Rendering Engine) 240 For the latest info, see http://www.ogre3d.org/ 241 242 Copyright (c) 2000-2008 Torus Knot Software Ltd 243 244 OGRE is licensed under the LGPL. For more info, see OGRE license. 245 */ 246 void GSRoot::setThreadAffinity(unsigned int limitToCPU) 247 { 248 #ifdef ORXONOX_PLATFORM_WINDOWS 249 // Get the current process core mask 250 DWORD procMask; 251 DWORD sysMask; 252 # if _MSC_VER >= 1400 && defined (_M_X64) 253 GetProcessAffinityMask(GetCurrentProcess(), (PDWORD_PTR)&procMask, (PDWORD_PTR)&sysMask); 254 # else 255 GetProcessAffinityMask(GetCurrentProcess(), &procMask, &sysMask); 256 # endif 257 258 // If procMask is 0, consider there is only one core available 259 // (using 0 as procMask will cause an infinite loop below) 260 if (procMask == 0) 261 procMask = 1; 262 263 // if the core specified with limitToCPU is not available, take the lowest one 264 if (!(procMask & (1 << limitToCPU))) 265 limitToCPU = 0; 266 267 // Find the lowest core that this process uses and limitToCPU suggests 268 DWORD threadMask = 1; 269 while ((threadMask & procMask) == 0 || (threadMask < (1u << limitToCPU))) 270 threadMask <<= 1; 271 272 // Set affinity to the first core 273 SetThreadAffinityMask(GetCurrentThread(), threadMask); 274 #endif 164 275 } 165 276 … … 170 281 void GSRoot::setTimeFactor(float factor) 171 282 { 172 if ( GameMode::isMaster())283 if (Core::isMaster()) 173 284 { 174 285 if (!this->bPaused_) … … 188 299 void GSRoot::pause() 189 300 { 190 if ( GameMode::isMaster())301 if (Core::isMaster()) 191 302 { 192 303 if (!this->bPaused_) … … 203 314 } 204 315 } 316 317 //////////////////////// 318 // TimeFactorListener // 319 //////////////////////// 320 float TimeFactorListener::timefactor_s = 1.0f; 321 322 TimeFactorListener::TimeFactorListener() 323 { 324 RegisterRootObject(TimeFactorListener); 325 } 205 326 } -
code/branches/questsystem5/src/orxonox/gamestates/GSRoot.h
r2907 r2908 31 31 32 32 #include "OrxonoxPrereqs.h" 33 #include "core/GameState.h" 33 34 #include <list> 35 #include <OgreLog.h> 36 #include "core/RootGameState.h" 34 37 #include "core/OrxonoxClass.h" 35 38 36 39 namespace orxonox 37 40 { 38 class _OrxonoxExport GSRoot : public GameState41 class _OrxonoxExport GSRoot : public RootGameState, public OrxonoxClass 39 42 { 43 friend class ClassIdentifier<GSRoot>; 44 40 45 public: 41 GSRoot(const std::string& name); 46 struct statisticsTickInfo 47 { 48 uint64_t tickTime; 49 uint32_t tickLength; 50 }; 51 52 public: 53 GSRoot(); 42 54 ~GSRoot(); 43 55 44 void activate(); 45 void deactivate(); 46 void update(const Clock& time); 56 void exitGame() 57 { requestState("root"); } 47 58 48 59 // this has to be public because proteced triggers a bug in msvc … … 52 63 float getTimeFactor() { return this->timeFactor_; } 53 64 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 54 72 private: 73 void enter(); 74 void leave(); 75 void ticked(const Clock& time); 76 77 void setConfigValues(); 78 void setThreadAffinity(unsigned int limitToCPU); 79 55 80 float timeFactor_; //!< A factor that sets the gamespeed. 1 is normal. 56 81 bool bPaused_; 57 82 float timeFactorPauseBackup_; 83 TclBind* tclBind_; 84 TclThreadManager* tclThreadManager_; 85 Shell* shell_; 86 LuaBind* luaBind_; 87 88 // variables for time statistics 89 uint64_t statisticsStartTime_; 90 std::list<statisticsTickInfo> 91 statisticsTickTimes_; 92 uint32_t periodTickTime_; 93 float avgFPS_; 94 float avgTickTime_; 95 96 // config values 97 unsigned int statisticsRefreshCycle_; 98 unsigned int statisticsAvgLength_; 58 99 59 100 // console commands 101 ConsoleCommand* ccExit_; 102 ConsoleCommand* ccSelectGameState_; 60 103 ConsoleCommand* ccSetTimeFactor_; 61 104 ConsoleCommand* ccPause_; 105 }; 106 107 class _OrxonoxExport TimeFactorListener : virtual public OrxonoxClass 108 { 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() const 118 { return TimeFactorListener::timefactor_s; } 119 120 private: 121 static float timefactor_s; 62 122 }; 63 123 } -
code/branches/questsystem5/src/orxonox/gamestates/GSServer.cc
r2907 r2908 31 31 32 32 #include "core/CommandLine.h" 33 #include "core/Game.h" 34 #include "core/GameMode.h" 33 #include "core/Core.h" 35 34 #include "network/Server.h" 36 35 37 36 namespace orxonox 38 37 { 39 AddGameState(GSServer, "server");40 41 38 SetCommandLineArgument(port, 55556).shortcut("p").information("0-65535"); 42 39 43 GSServer::GSServer( const std::string& name)44 : GameState (name)40 GSServer::GSServer() 41 : GameState<GSGraphics>("server") 45 42 , server_(0) 46 43 { … … 51 48 } 52 49 53 void GSServer:: activate()50 void GSServer::enter() 54 51 { 55 GameMode::setHasServer(true);52 Core::setHasServer(true); 56 53 57 54 this->server_ = new Server(CommandLine::getValue("port")); 58 55 COUT(0) << "Loading scene in server mode" << std::endl; 59 56 57 GSLevel::enter(this->getParent()->getViewport()); 58 60 59 server_->open(); 61 60 } 62 61 63 void GSServer:: deactivate()62 void GSServer::leave() 64 63 { 64 GSLevel::leave(); 65 65 66 this->server_->close(); 66 67 delete this->server_; 67 68 68 GameMode::setHasServer(false);69 Core::setHasServer(false); 69 70 } 70 71 71 void GSServer:: update(const Clock& time)72 void GSServer::ticked(const Clock& time) 72 73 { 73 server_->update(time); 74 GSLevel::ticked(time); 75 server_->tick(time.getDeltaTime()); 76 this->tickChild(time); 74 77 } 75 78 } -
code/branches/questsystem5/src/orxonox/gamestates/GSServer.h
r2907 r2908 31 31 32 32 #include "OrxonoxPrereqs.h" 33 #include "core/GameState.h"34 33 #include "network/NetworkPrereqs.h" 34 #include "GSLevel.h" 35 #include "GSGraphics.h" 35 36 36 37 namespace orxonox 37 38 { 38 class _OrxonoxExport GSServer : public GameState 39 class _OrxonoxExport GSServer : public GameState<GSGraphics>, public GSLevel 39 40 { 40 41 public: 41 GSServer( const std::string& name);42 GSServer(); 42 43 ~GSServer(); 43 44 44 void activate(); 45 void deactivate(); 46 void update(const Clock& time); 45 private: 46 void enter(); 47 void leave(); 48 void ticked(const Clock& time); 47 49 48 private: 49 Server* server_; 50 Server* server_; 50 51 }; 51 52 } -
code/branches/questsystem5/src/orxonox/gamestates/GSStandalone.cc
r2907 r2908 30 30 #include "GSStandalone.h" 31 31 32 #include <OgreViewport.h> 33 #include <OgreCamera.h> 34 #include "core/Game.h" 35 #include "core/GameMode.h" 36 #include "core/ConsoleCommand.h" 37 #include "gui/GUIManager.h" 38 #include "GraphicsManager.h" 32 #include "core/Core.h" 39 33 40 34 namespace orxonox 41 35 { 42 AddGameState(GSStandalone, "standalone"); 43 44 GSStandalone::GSStandalone(const std::string& name) 45 : GameState(name) 36 GSStandalone::GSStandalone() 37 : GameState<GSGraphics>("standalone") 46 38 { 47 39 } … … 51 43 } 52 44 45 void GSStandalone::enter() 46 { 47 Core::setIsStandalone(true); 53 48 54 void GSStandalone::activate() 55 { 56 GameMode::setIsStandalone(true); 49 GSLevel::enter(this->getParent()->getViewport()); 57 50 } 58 51 59 void GSStandalone:: deactivate()52 void GSStandalone::leave() 60 53 { 61 GameMode::setIsStandalone(false); 54 GSLevel::leave(); 55 56 Core::setIsStandalone(false); 62 57 } 63 58 64 void GSStandalone:: update(const Clock& time)59 void GSStandalone::ticked(const Clock& time) 65 60 { 61 GSLevel::ticked(time); 62 this->tickChild(time); 66 63 } 67 64 } -
code/branches/questsystem5/src/orxonox/gamestates/GSStandalone.h
r2907 r2908 31 31 32 32 #include "OrxonoxPrereqs.h" 33 #include "core/GameState.h" 33 #include "GSLevel.h" 34 #include "GSGraphics.h" 34 35 35 36 namespace orxonox 36 37 { 37 class _OrxonoxExport GSStandalone : public GameState 38 class _OrxonoxExport GSStandalone : public GameState<GSGraphics>, public GSLevel 38 39 { 39 40 public: 40 GSStandalone( const std::string& name);41 GSStandalone(); 41 42 ~GSStandalone(); 42 43 43 void activate();44 void deactivate();45 void update(const Clock& time);46 47 44 private: 45 void enter(); 46 void leave(); 47 void ticked(const Clock& time); 48 48 }; 49 49 } -
code/branches/questsystem5/src/orxonox/gui/GUIManager.cc
r2907 r2908 22 22 * Author: 23 23 * Reto Grieder 24 * Benjamin Knecht25 24 * Co-authors: 26 * 25 * ... 27 26 * 28 27 */ … … 37 36 #include "GUIManager.h" 38 37 39 #include <boost/filesystem /path.hpp>38 #include <boost/filesystem.hpp> 40 39 #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" 52 54 #include "core/ConsoleCommand.h" 53 55 #include "core/Core.h" 54 #include "core/Clock.h"55 56 #include "ToluaBindCore.h" 56 57 #include "ToluaBindOrxonox.h" … … 62 63 namespace orxonox 63 64 { 65 SetConsoleCommandShortcut(GUIManager, showGUI_s).keybindMode(KeybindMode::OnPress); 66 64 67 GUIManager* GUIManager::singletonRef_s = 0; 65 68 66 69 GUIManager::GUIManager() 67 : renderWindow_(0) 70 //: emptySceneManager_(0) 71 : backgroundSceneManager_(0) 72 //, emptyCamera_(0) 73 , backgroundCamera_(0) 74 //, viewport_(0) 75 , renderWindow_(0) 68 76 , guiRenderer_(0) 69 77 , resourceProvider_(0) … … 76 84 } 77 85 78 /**79 @brief80 Deconstructor of the GUIManager81 82 Basically shuts down CEGUI and destroys the Lua engine and afterwards the interface to the Ogre engine.83 */84 86 GUIManager::~GUIManager() 85 87 { 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, it 95 // 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 86 102 if (guiSystem_) 87 103 delete guiSystem_; … … 94 110 lua_pushnil(luaState_); 95 111 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 when 114 // we don't open Core or Orxonox. Might be a CEGUI issue. 115 // The memory leak is not a problem anyway.. 96 116 delete scriptModule_; 97 117 } … … 103 123 } 104 124 105 /**106 @brief107 Initialises the GUIManager by starting up CEGUI108 @param renderWindow109 Ogre's render window. Without this, the GUI cannot be displayed.110 @return true if success, otherwise false111 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 */119 125 bool GUIManager::initialise(Ogre::RenderWindow* renderWindow) 120 126 { … … 129 135 renderWindow_ = renderWindow; 130 136 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 131 144 // Note: No SceneManager specified yet 132 this->guiRenderer_ = new OgreCEGUIRenderer(renderWindow_, Ogre::RENDER_QUEUE_ OVERLAY, true, 3000);145 this->guiRenderer_ = new OgreCEGUIRenderer(renderWindow_, Ogre::RENDER_QUEUE_MAIN, true, 3000); 133 146 this->resourceProvider_ = guiRenderer_->createResourceProvider(); 134 147 this->resourceProvider_->setDefaultResourceGroup("GUI"); … … 153 166 tolua_Orxonox_open(this->scriptModule_->getLuaState()); 154 167 155 // initialise the basic lua code 156 loadLuaCode(); 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 157 177 } 158 178 catch (CEGUI::Exception& ex) … … 172 192 } 173 193 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 { 194 void GUIManager::loadScenes() 195 { 196 // first of all, we need to have our own SceneManager for the GUI. The reason 197 // is that we might have multiple viewports when in play mode (e.g. the view of 198 // a camera fixed at the back of the ship). That forces us to create our own 199 // full screen viewport that is on top of all the others, but doesn't clear the 200 // port before rendering, so everything from the GUI gets on top eventually. 201 // But in order to realise that, we also need a SceneManager with an empty scene, 202 // because the SceneManager is responsible for the render queue. 203 //this->emptySceneManager_ = Ogre::Root::getSingleton() 204 // .createSceneManager(Ogre::ST_GENERIC, "GUI/EmptySceneManager"); 205 206 // we also need a camera or we won't see anything at all. 207 // The camera settings don't matter at all for an empty scene since the GUI 208 // gets rendered on top of the screen rather than into the scene. 209 //this->emptyCamera_ = this->emptySceneManager_->createCamera("GUI/EmptyCamera"); 210 211 // Create another SceneManager that enables to display some 3D 212 // scene in the background of the main menu. 213 this->backgroundSceneManager_ = Ogre::Root::getSingleton() 214 .createSceneManager(Ogre::ST_GENERIC, "GUI/BackgroundSceneManager"); 215 this->backgroundCamera_ = backgroundSceneManager_->createCamera("GUI/BackgroundCamera"); 216 217 // TODO: create something 3D 187 218 try 188 219 { 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"); 220 this->scriptModule_->executeScriptFile("loadGUI.lua", "GUI"); 194 221 } 195 222 catch (CEGUI::Exception& ex) … … 204 231 } 205 232 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) 233 void GUIManager::showGUI(const std::string& name, Ogre::SceneManager* sceneManager)// bool showBackground) 267 234 { 268 235 if (state_ != Uninitialised) 269 236 { 270 //COUT(3) << "Loading GUI " << name << std::endl; 237 if (state_ == OnDisplay) 238 hideGUI(); 239 240 COUT(3) << "Loading GUI " << name << std::endl; 271 241 try 272 242 { 273 this->scriptModule_->executeString(std::string("showGUI(\"") + name + "\")"); 243 if (!sceneManager) 244 { 245 // currently, only an image is loaded. We could do 3D, see loadBackground. 246 //this->viewport_->setClearEveryFrame(true); 247 this->guiRenderer_->setTargetSceneManager(this->backgroundSceneManager_); 248 //this->viewport_->setCamera(this->backgroundCamera_); 249 250 lua_pushboolean(this->scriptModule_->getLuaState(), true); 251 lua_setglobal(this->scriptModule_->getLuaState(), "showBackground"); 252 } 253 else 254 { 255 //this->viewport_->setClearEveryFrame(false); 256 this->guiRenderer_->setTargetSceneManager(sceneManager); 257 //this->viewport_->setCamera(this->emptyCamera_); 258 259 lua_pushboolean(this->scriptModule_->getLuaState(), false); 260 lua_setglobal(this->scriptModule_->getLuaState(), "showBackground"); 261 } 262 263 this->scriptModule_->executeScriptGlobal("showMainMenu"); 264 265 InputManager::getInstance().requestEnterState("gui"); 266 267 this->state_ = OnDisplay; 274 268 } 275 269 catch (CEGUI::Exception& ex) … … 288 282 } 289 283 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 */ 284 void GUIManager::hideGUI() 285 { 286 if (this->state_ != OnDisplay) 287 return; 288 //this->viewport_->setCamera(0); 289 this->guiRenderer_->setTargetSceneManager(0); 290 this->state_ = Ready; 291 InputManager::getInstance().requestLeaveState("gui"); 292 } 293 299 294 void GUIManager::mouseButtonPressed(MouseButtonCode::ByEnum id) 300 295 { … … 310 305 } 311 306 312 /**313 @brief314 Function receiving a mouse button released event.315 @param id316 ID of the mouse button which got released317 318 This function is inherited by MouseHandler and injects the event into CEGUI.319 It is for CEGUI to process the event.320 */321 307 void GUIManager::mouseButtonReleased(MouseButtonCode::ByEnum id) 322 308 { … … 332 318 } 333 319 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 */ 320 344 321 inline CEGUI::MouseButton GUIManager::convertButton(MouseButtonCode::ByEnum button) 345 322 { -
code/branches/questsystem5/src/orxonox/gui/GUIManager.h
r2907 r2908 23 23 * Reto Grieder 24 24 * Co-authors: 25 * Benjamin Knecht25 * ... 26 26 * 27 27 */ … … 49 49 { 50 50 /** 51 @class GUIManager52 51 @brief 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. 52 Provides a simple interface to CEGUI with tolua methods and console commands 60 53 */ 61 54 class _OrxonoxExport GUIManager … … 66 59 // tolua_end 67 60 public: 68 /**69 @enum State70 The current state of the GUIManager. There should maybe be more (or we can omit this totally).71 */72 61 enum State 73 62 { 74 Uninitialised, //!< Initial state of the GUIManager75 Ready, //!< State after initialisation if ready76 OnDisplay //!< State if GUI is displayed63 Uninitialised, 64 Ready, 65 OnDisplay 77 66 }; 78 67 … … 81 70 82 71 bool initialise(Ogre::RenderWindow* renderWindow); 72 void tick(float dt) 73 { 74 assert(guiSystem_); 75 guiSystem_->injectTimePulse(dt); 76 } 77 void showGUI(const std::string& name, Ogre::SceneManager* sceneManager);// bool showBackground); // tolua_export 78 void hideGUI(); // tolua_export 83 79 84 void update(const Clock& time);80 Ogre::Camera* getCamera() { return this->backgroundCamera_; } 85 81 86 void showGUI(const std::string& name);87 void executeCode(const std::string& str);88 89 void setCamera(Ogre::Camera* camera);82 static void showGUI_s(const std::string& name, Ogre::SceneManager* sceneManager)//bool showBackground) 83 { 84 getInstance().showGUI(name, sceneManager); 85 } 90 86 91 87 static GUIManager& getInstance() { assert(singletonRef_s); return *singletonRef_s; } // tolua_export … … 93 89 94 90 private: 95 GUIManager(const GUIManager& instance); //!< private constructor (this is a singleton class)91 GUIManager(const GUIManager& instance); 96 92 97 void loadLuaCode(); 93 void keyPressed (const KeyEvent& evt) 94 { guiSystem_->injectKeyDown(evt.key); guiSystem_->injectChar(evt.text); } 95 void keyReleased(const KeyEvent& evt) 96 { guiSystem_->injectKeyUp(evt.key); } 97 void keyHeld (const KeyEvent& evt) 98 { } 98 99 99 // keyHandler functions100 void keyPressed (const KeyEvent& evt)101 { guiSystem_->injectKeyDown(evt.key); guiSystem_->injectChar(evt.text); }102 void keyReleased(const KeyEvent& evt)103 { guiSystem_->injectKeyUp(evt.key); }104 void keyHeld (const KeyEvent& evt) { }105 106 // mouseHandler functions107 100 void mouseButtonPressed (MouseButtonCode::ByEnum id); 108 101 void mouseButtonReleased(MouseButtonCode::ByEnum id); 109 void mouseButtonHeld (MouseButtonCode::ByEnum id) { } 102 void mouseButtonHeld (MouseButtonCode::ByEnum id) 103 { } 110 104 void mouseMoved (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize) 111 105 { guiSystem_->injectMouseMove(rel.x, rel.y); } 112 106 void mouseScrolled (int abs, int rel) 113 107 { guiSystem_->injectMouseWheelChange(rel);} 114 108 115 void updateInput(float dt) { } 116 void updateKey (float dt) { } 117 void updateMouse(float dt) { } 109 void tickInput(float dt) { } 110 void tickKey(float dt) { } 111 void tickMouse(float dt) { } 112 113 void loadScenes(); 114 115 //Ogre::SceneManager* emptySceneManager_; 116 Ogre::SceneManager* backgroundSceneManager_; 117 //Ogre::Camera* emptyCamera_; 118 Ogre::Camera* backgroundCamera_; 119 //Ogre::Viewport* viewport_; 120 Ogre::RenderWindow* renderWindow_; 121 CEGUI::OgreCEGUIRenderer* guiRenderer_; 122 CEGUI::ResourceProvider* resourceProvider_; 123 CEGUI::LuaScriptModule* scriptModule_; 124 CEGUI::DefaultLogger* ceguiLogger_; 125 CEGUI::System* guiSystem_; 126 CEGUI::Imageset* backgroundImage_; 127 lua_State* luaState_; 128 129 State state_; 118 130 119 131 static CEGUI::MouseButton convertButton(MouseButtonCode::ByEnum button); 120 132 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 133 static GUIManager* singletonRef_s; 132 134 }; // tolua_export 133 135 } // tolua_export -
code/branches/questsystem5/src/orxonox/objects/CMakeLists.txt
r2907 r2908 8 8 RadarListener.cc 9 9 RadarViewable.cc 10 Teamcolourable.cc11 10 Tickable.cc 12 11 Test.cc -
code/branches/questsystem5/src/orxonox/objects/EventTarget.cc
r2907 r2908 66 66 void EventTarget::addAsEvent(BaseObject* object) 67 67 { 68 if (object != static_cast<BaseObject*>(this))68 if (object != (BaseObject*)this) 69 69 object->addEvent(this, ""); 70 70 } -
code/branches/questsystem5/src/orxonox/objects/Level.cc
- Property svn:mergeinfo changed
/code/branches/gui/src/orxonox/objects/Level.cc removed /code/branches/miniprojects/src/orxonox/objects/Level.cc removed /code/branches/weaponsystem/src/orxonox/objects/Level.cc removed
r2907 r2908 105 105 { 106 106 Identifier* identifier = ClassByString(gametype); 107 108 if (!identifier || !identifier->isA(Class(Gametype))) 107 if (identifier && identifier->isA(Class(Gametype))) 109 108 { 110 COUT(0) << "Error: \"" << gametype << "\" is not a valid gametype." << std::endl;111 identifier = Class(Gametype);112 this->gametype_ = "Gametype";113 }114 else115 109 this->gametype_ = gametype; 116 110 117 std::cout << "Load Gametype: " << this->gametype_ << std::endl; 111 Gametype* rootgametype = dynamic_cast<Gametype*>(identifier->fabricate(this)); 112 this->setGametype(rootgametype); 118 113 119 Gametype* rootgametype = dynamic_cast<Gametype*>(identifier->fabricate(this));120 this->setGametype(rootgametype);114 for (std::list<BaseObject*>::iterator it = this->objects_.begin(); it != this->objects_.end(); ++it) 115 (*it)->setGametype(rootgametype); 121 116 122 std::cout << "root gametype: " << rootgametype->getIdentifier()->getName() << std::endl; 123 124 for (std::list<BaseObject*>::iterator it = this->objects_.begin(); it != this->objects_.end(); ++it) 125 (*it)->setGametype(rootgametype); 126 127 if (LevelManager::getInstancePtr()) 128 LevelManager::getInstance().requestActivity(this); 117 if (LevelManager::getInstancePtr()) 118 LevelManager::getInstance().requestActivity(this); 119 } 129 120 } 130 121 - Property svn:mergeinfo changed
-
code/branches/questsystem5/src/orxonox/objects/Level.h
- Property svn:mergeinfo changed
/code/branches/gui/src/orxonox/objects/Level.h removed /code/branches/miniprojects/src/orxonox/objects/Level.h removed /code/branches/weaponsystem/src/orxonox/objects/Level.h removed
- Property svn:mergeinfo changed
-
code/branches/questsystem5/src/orxonox/objects/Radar.cc
r2907 r2908 144 144 for (ObjectList<RadarViewable>::iterator it = ObjectList<RadarViewable>::begin(); it; ++it) 145 145 { 146 if (*it == static_cast<RadarViewable*>(this)->owner_)146 if (*it == (RadarViewable*)this->owner_) 147 147 continue; 148 148 -
code/branches/questsystem5/src/orxonox/objects/Scene.cc
r2907 r2908 41 41 42 42 #include "core/CoreIncludes.h" 43 #include "core/ GameMode.h"43 #include "core/Core.h" 44 44 #include "core/XMLPort.h" 45 45 #include "tools/BulletConversions.h" … … 57 57 this->bShadows_ = true; 58 58 59 if ( GameMode::showsGraphics())59 if (Core::showsGraphics()) 60 60 { 61 61 if (Ogre::Root::getSingletonPtr()) … … 99 99 Ogre::Root::getSingleton().destroySceneManager(this->sceneManager_); 100 100 } 101 else if (! GameMode::showsGraphics())101 else if (!Core::showsGraphics()) 102 102 { 103 103 delete this->sceneManager_; … … 227 227 void Scene::tick(float dt) 228 228 { 229 if (! GameMode::showsGraphics())229 if (!Core::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 ( GameMode::showsGraphics() && this->sceneManager_)258 if (Core::showsGraphics() && this->sceneManager_) 259 259 this->sceneManager_->setSkyBox(true, skybox); 260 260 … … 264 264 void Scene::setAmbientLight(const ColourValue& colour) 265 265 { 266 if ( GameMode::showsGraphics() && this->sceneManager_)266 if (Core::showsGraphics() && this->sceneManager_) 267 267 this->sceneManager_->setAmbientLight(colour); 268 268 … … 272 272 void Scene::setShadow(bool bShadow) 273 273 { 274 if ( GameMode::showsGraphics() && this->sceneManager_)274 if (Core::showsGraphics() && this->sceneManager_) 275 275 { 276 276 if (bShadow) -
code/branches/questsystem5/src/orxonox/objects/collisionshapes
- Property svn:mergeinfo changed
/code/branches/miniprojects/src/orxonox/objects/collisionshapes removed /code/branches/weaponsystem/src/orxonox/objects/collisionshapes removed
- Property svn:mergeinfo changed
-
code/branches/questsystem5/src/orxonox/objects/controllers/AIController.cc
r2907 r2908 30 30 #include "AIController.h" 31 31 32 #include "core/ GameMode.h"32 #include "core/Core.h" 33 33 #include "core/CoreIncludes.h" 34 34 #include "core/Executor.h" … … 45 45 RegisterObject(AIController); 46 46 47 if ( GameMode::isMaster())47 if (Core::isMaster()) 48 48 this->actionTimer_.setTimer(ACTION_INTERVAL, true, this, createExecutor(createFunctor(&AIController::action))); 49 49 } -
code/branches/questsystem5/src/orxonox/objects/controllers/CMakeLists.txt
r2907 r2908 5 5 AIController.cc 6 6 ScriptController.cc 7 PongAI.cc8 7 ) -
code/branches/questsystem5/src/orxonox/objects/controllers/Controller.cc
r2907 r2908 43 43 this->player_ = 0; 44 44 this->controllableEntity_ = 0; 45 this->hud_ = 0; 46 this->bUpdateHUD_ = false; 45 47 } 46 48 47 49 Controller::~Controller() 48 50 { 51 if (this->isInitialized() && this->hud_) 52 delete this->hud_; 53 } 54 55 void Controller::changedControllableEntity() 56 { 57 if (this->bUpdateHUD_) 58 { 59 this->updateHUD(); 60 this->bUpdateHUD_ = false; 61 } 62 63 if (this->hud_) 64 this->hud_->setOwner(this->getControllableEntity()); 65 } 66 67 void Controller::updateHUD() 68 { 69 if (this->hud_) 70 { 71 delete this->hud_; 72 this->hud_ = 0; 73 } 74 75 if (this->hudtemplate_ != "") 76 { 77 this->hud_ = new OverlayGroup(this); 78 this->hud_->addTemplate(this->hudtemplate_); 79 this->hud_->setOwner(this->getControllableEntity()); 80 } 49 81 } 50 82 } -
code/branches/questsystem5/src/orxonox/objects/controllers/Controller.h
r2907 r2908 57 57 inline ControllableEntity* getControllableEntity() const 58 58 { return this->controllableEntity_; } 59 virtual void changedControllableEntity() {} 59 virtual void changedControllableEntity(); 60 61 inline void setHUDTemplate(const std::string& name) 62 { 63 if (name != this->hudtemplate_) 64 { 65 this->hudtemplate_ = name; 66 if (this->controllableEntity_) 67 this->updateHUD(); 68 else 69 this->bUpdateHUD_ = true; 70 } 71 } 72 inline const std::string& getHUDTemplate() const 73 { return this->hudtemplate_; } 74 75 inline OverlayGroup* getHUD() const 76 { return this->hud_; } 60 77 61 78 protected: 79 void updateHUD(); 80 62 81 PlayerInfo* player_; 63 82 ControllableEntity* controllableEntity_; 83 std::string hudtemplate_; 84 OverlayGroup* hud_; 85 bool bUpdateHUD_; 64 86 }; 65 87 } -
code/branches/questsystem5/src/orxonox/objects/controllers/HumanController.cc
r2907 r2908 35 35 #include "objects/worldentities/pawns/Pawn.h" 36 36 #include "objects/gametypes/Gametype.h" 37 #include "objects/infos/PlayerInfo.h"38 37 39 38 namespace orxonox … … 158 157 if (pawn) 159 158 pawn->kill(); 160 else if (HumanController::localController_s->player_)161 HumanController::localController_s->player_->stopControl(HumanController::localController_s->controllableEntity_);162 159 } 163 160 } -
code/branches/questsystem5/src/orxonox/objects/gametypes/CMakeLists.txt
r2907 r2908 1 1 ADD_SOURCE_FILES(ORXONOX_SRC_FILES 2 2 Gametype.cc 3 Deathmatch.cc4 TeamDeathmatch.cc5 Pong.cc6 3 ) -
code/branches/questsystem5/src/orxonox/objects/gametypes/Gametype.cc
r2907 r2908 36 36 #include "core/ConfigValueIncludes.h" 37 37 #include "core/Template.h" 38 #include "core/ GameMode.h"38 #include "core/Core.h" 39 39 #include "overlays/OverlayGroup.h" 40 40 #include "objects/infos/PlayerInfo.h" … … 44 44 #include "objects/worldentities/Camera.h" 45 45 46 #include "network/Host.h" 47 46 48 namespace orxonox 47 49 { … … 64 66 this->setConfigValues(); 65 67 68 this->addBots(this->numberOfBots_); 69 66 70 // load the corresponding score board 67 if ( GameMode::showsGraphics() && this->scoreboardTemplate_ != "")71 if (Core::showsGraphics() && this->scoreboardTemplate_ != "") 68 72 { 69 73 this->scoreboard_ = new OverlayGroup(this); … … 101 105 void Gametype::start() 102 106 { 103 this->addBots(this->numberOfBots_); 104 107 COUT(0) << "game started" << std::endl; 105 108 this->gtinfo_.bStarted_ = true; 106 109 … … 110 113 void Gametype::end() 111 114 { 115 COUT(0) << "game ended" << std::endl; 112 116 this->gtinfo_.bEnded_ = true; 113 117 } … … 116 120 { 117 121 this->players_[player].state_ = PlayerState::Joined; 118 } 119 120 bool Gametype::playerLeft(PlayerInfo* player) 122 123 std::string message = player->getName() + " entered the game"; 124 COUT(0) << message << std::endl; 125 Host::Broadcast(message); 126 } 127 128 void Gametype::playerLeft(PlayerInfo* player) 121 129 { 122 130 std::map<PlayerInfo*, Player>::iterator it = this->players_.find(player); … … 124 132 { 125 133 this->players_.erase(it); 126 return true; 127 } 128 return false; 134 135 std::string message = player->getName() + " left the game"; 136 COUT(0) << message << std::endl; 137 Host::Broadcast(message); 138 } 129 139 } 130 140 … … 137 147 } 138 148 139 boolGametype::playerChangedName(PlayerInfo* player)149 void Gametype::playerChangedName(PlayerInfo* player) 140 150 { 141 151 if (this->players_.find(player) != this->players_.end()) … … 143 153 if (player->getName() != player->getOldName()) 144 154 { 145 return true; 146 } 147 } 148 return false; 155 std::string message = player->getOldName() + " changed name to " + player->getName(); 156 COUT(0) << message << std::endl; 157 Host::Broadcast(message); 158 } 159 } 149 160 } 150 161 … … 157 168 } 158 169 159 void Gametype::playerPreSpawn(PlayerInfo* player)160 {161 }162 163 void Gametype::playerPostSpawn(PlayerInfo* player)164 {165 }166 167 void Gametype::playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn)168 {169 }170 171 void Gametype::playerStopsControllingPawn(PlayerInfo* player, Pawn* pawn)172 {173 }174 175 bool Gametype::allowPawnHit(Pawn* victim, Pawn* originator)176 {177 return true;178 }179 180 bool Gametype::allowPawnDamage(Pawn* victim, Pawn* originator)181 {182 return true;183 }184 185 bool Gametype::allowPawnDeath(Pawn* victim, Pawn* originator)186 {187 return true;188 }189 190 170 void Gametype::pawnKilled(Pawn* victim, Pawn* killer) 191 171 { 172 if (victim && victim->getPlayer()) 173 { 174 std::string message; 175 if (killer) 176 { 177 if (killer->getPlayer()) 178 message = victim->getPlayer()->getName() + " was killed by " + killer->getPlayer()->getName(); 179 else 180 message = victim->getPlayer()->getName() + " was killed"; 181 } 182 else 183 message = victim->getPlayer()->getName() + " died"; 184 185 COUT(0) << message << std::endl; 186 Host::Broadcast(message); 187 } 188 192 189 if (victim && victim->getPlayer()) 193 190 { … … 201 198 if (killer) 202 199 { 203 std::map<PlayerInfo*, Player>::iterator it = this->players_.find(killer->getPlayer()); 204 if (it != this->players_.end()) 205 it->second.frags_++; 200 std::map<PlayerInfo*, Player>::iterator itKiller = this->players_.find(killer->getPlayer()); 201 if (itKiller != this->players_.end()) 202 { 203 this->playerScored(itKiller->second); 204 } 205 else 206 COUT(2) << "Warning: Killing Pawn was not in the playerlist" << std::endl; 206 207 } 207 208 … … 224 225 } 225 226 226 void Gametype::playerScored(PlayerInfo* player) 227 { 228 std::map<PlayerInfo*, Player>::iterator it = this->players_.find(player); 229 if (it != this->players_.end()) 230 it->second.frags_++; 231 } 232 233 int Gametype::getScore(PlayerInfo* player) const 234 { 235 std::map<PlayerInfo*, Player>::const_iterator it = this->players_.find(player); 236 if (it != this->players_.end()) 237 return it->second.frags_; 238 else 239 return 0; 227 void Gametype::playerScored(Player& player) 228 { 229 player.frags_++; 240 230 } 241 231 … … 346 336 if (spawnpoint) 347 337 { 348 this->playerPreSpawn(player);349 338 player->startControl(spawnpoint->spawn()); 350 339 this->players_[player].state_ = PlayerState::Alive; 351 this->playerPostSpawn(player);352 340 } 353 341 else … … 361 349 { 362 350 for (unsigned int i = 0; i < amount; ++i) 363 this->botclass_.fabricate(this);351 new Bot(this); 364 352 } 365 353 -
code/branches/questsystem5/src/orxonox/objects/gametypes/Gametype.h
r2907 r2908 84 84 virtual void end(); 85 85 virtual void playerEntered(PlayerInfo* player); 86 virtual boolplayerLeft(PlayerInfo* player);86 virtual void playerLeft(PlayerInfo* player); 87 87 virtual void playerSwitched(PlayerInfo* player, Gametype* newgametype); 88 88 virtual void playerSwitchedBack(PlayerInfo* player, Gametype* oldgametype); 89 virtual boolplayerChangedName(PlayerInfo* player);89 virtual void playerChangedName(PlayerInfo* player); 90 90 91 virtual void playerScored(PlayerInfo* player); 92 93 virtual bool allowPawnHit(Pawn* victim, Pawn* originator = 0); 94 virtual bool allowPawnDamage(Pawn* victim, Pawn* originator = 0); 95 virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = 0); 91 virtual void playerScored(Player& player); 96 92 97 93 virtual void pawnKilled(Pawn* victim, Pawn* killer = 0); 98 94 virtual void pawnPreSpawn(Pawn* pawn); 99 95 virtual void pawnPostSpawn(Pawn* pawn); 100 virtual void playerPreSpawn(PlayerInfo* player);101 virtual void playerPostSpawn(PlayerInfo* player);102 103 virtual void playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn);104 virtual void playerStopsControllingPawn(PlayerInfo* player, Pawn* pawn);105 96 106 97 inline const std::map<PlayerInfo*, Player>& getPlayers() const 107 98 { return this->players_; } 108 109 int getScore(PlayerInfo* player) const;110 99 111 100 inline void registerSpawnPoint(SpawnPoint* spawnpoint) … … 117 106 { return this->gtinfo_.startCountdown_; } 118 107 119 inline void setHUDTemplate(const std::string& name)120 { this->gtinfo_.hudtemplate_ = name; }121 inline const std::string& getHUDTemplate() const122 { return this->gtinfo_.hudtemplate_; }123 124 108 void addBots(unsigned int amount); 125 109 void killBots(unsigned int amount = 0); … … 128 112 { return this->players_.size(); } 129 113 130 pr otected:114 private: 131 115 virtual SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const; 132 116 133 virtual void assignDefaultPawnsIfNeeded(); 134 virtual void checkStart(); 135 virtual void spawnPlayer(PlayerInfo* player); 136 virtual void spawnPlayersIfRequested(); 137 virtual void spawnDeadPlayersIfRequested(); 117 void addPlayer(PlayerInfo* player); 118 void removePlayer(PlayerInfo* player); 119 120 void assignDefaultPawnsIfNeeded(); 121 void checkStart(); 122 void spawnPlayer(PlayerInfo* player); 123 void spawnPlayersIfRequested(); 124 void spawnDeadPlayersIfRequested(); 138 125 139 126 GametypeInfo gtinfo_; … … 144 131 float initialStartCountdown_; 145 132 unsigned int numberOfBots_; 146 SubclassIdentifier<Bot> botclass_;147 133 148 134 std::map<PlayerInfo*, Player> players_; -
code/branches/questsystem5/src/orxonox/objects/infos/Bot.cc
r2907 r2908 30 30 #include "Bot.h" 31 31 32 #include "core/ GameMode.h"32 #include "core/Core.h" 33 33 #include "core/CoreIncludes.h" 34 34 #include "core/ConfigValueIncludes.h" … … 46 46 47 47 this->bHumanPlayer_ = false; 48 this->bLocalPlayer_ = GameMode::isMaster();48 this->bLocalPlayer_ = Core::isMaster(); 49 49 this->bSetUnreadyAfterSpawn_ = false; 50 50 this->setReadyToSpawn(true); -
code/branches/questsystem5/src/orxonox/objects/infos/CMakeLists.txt
r2907 r2908 1 1 ADD_SOURCE_FILES(ORXONOX_SRC_FILES 2 2 Bot.cc 3 PongBot.cc4 3 Info.cc 5 4 PlayerInfo.cc -
code/branches/questsystem5/src/orxonox/objects/infos/GametypeInfo.cc
r2907 r2908 58 58 registerVariable(this->startCountdown_, variableDirection::toclient); 59 59 registerVariable(this->bStartCountdownRunning_, variableDirection::toclient); 60 registerVariable(this->hudtemplate_, variableDirection::toclient);61 60 } 62 61 } -
code/branches/questsystem5/src/orxonox/objects/infos/GametypeInfo.h
r2907 r2908 56 56 { return this->startCountdown_; } 57 57 58 inline const std::string& getHUDTemplate() const59 { return this->hudtemplate_; }60 61 58 private: 62 59 bool bStarted_; … … 64 61 bool bStartCountdownRunning_; 65 62 float startCountdown_; 66 std::string hudtemplate_;67 63 }; 68 64 } -
code/branches/questsystem5/src/orxonox/objects/infos/HumanPlayer.cc
r2907 r2908 30 30 #include "HumanPlayer.h" 31 31 32 #include "core/ GameMode.h"32 #include "core/Core.h" 33 33 #include "core/CoreIncludes.h" 34 34 #include "core/ConfigValueIncludes.h" … … 47 47 RegisterObject(HumanPlayer); 48 48 49 this->server_initialized_ = GameMode::isMaster();49 this->server_initialized_ = Core::isMaster(); 50 50 this->client_initialized_ = false; 51 51 52 52 this->bHumanPlayer_ = true; 53 53 this->defaultController_ = Class(HumanController); 54 55 this->humanHud_ = 0;56 this->gametypeHud_ = 0;57 54 58 55 this->setConfigValues(); … … 62 59 HumanPlayer::~HumanPlayer() 63 60 { 64 if (this->BaseObject::isInitialized())65 {66 if (this->humanHud_)67 delete this->humanHud_;68 69 if (this->gametypeHud_)70 delete this->gametypeHud_;71 }72 61 } 73 62 … … 93 82 this->synchronize_nick_ = this->nick_; 94 83 95 if ( GameMode::isMaster())84 if (Core::isMaster()) 96 85 this->setName(this->nick_); 97 86 } … … 100 89 void HumanPlayer::configvaluecallback_changedHUDTemplate() 101 90 { 102 this-> setHumanHUDTemplate(this->hudtemplate_);91 this->changedController(); 103 92 } 104 93 … … 116 105 this->client_initialized_ = true; 117 106 118 if (! GameMode::isMaster())107 if (!Core::isMaster()) 119 108 this->setObjectMode(objectDirection::bidirectional); 120 109 else … … 122 111 123 112 this->createController(); 124 this->updateHumanHUD();125 113 } 126 114 } … … 158 146 } 159 147 160 void HumanPlayer::changed Gametype()148 void HumanPlayer::changedController() 161 149 { 162 PlayerInfo::changedGametype(); 150 if (this->getController()) 151 { 152 this->getController()->setHUDTemplate(this->hudtemplate_); 163 153 164 if (this->isInitialized() && this->isLocalPlayer()) 165 if (this->getGametype()->getHUDTemplate() != "") 166 this->setGametypeHUDTemplate(this->getGametype()->getHUDTemplate()); 167 } 168 169 void HumanPlayer::changedControllableEntity() 170 { 171 PlayerInfo::changedControllableEntity(); 172 173 if (this->humanHud_) 174 this->humanHud_->setOwner(this->getControllableEntity()); 175 } 176 177 void HumanPlayer::updateHumanHUD() 178 { 179 if (this->humanHud_) 180 { 181 delete this->humanHud_; 182 this->humanHud_ = 0; 183 } 184 185 if (this->isLocalPlayer() && this->humanHudTemplate_ != "") 186 { 187 this->humanHud_ = new OverlayGroup(this); 188 this->humanHud_->addTemplate(this->humanHudTemplate_); 189 this->humanHud_->setOwner(this->getControllableEntity()); 190 } 191 } 192 193 void HumanPlayer::updateGametypeHUD() 194 { 195 if (this->gametypeHud_) 196 { 197 delete this->gametypeHud_; 198 this->gametypeHud_ = 0; 199 } 200 201 if (this->isLocalPlayer() && this->gametypeHudTemplate_ != "") 202 { 203 this->gametypeHud_ = new OverlayGroup(this); 204 this->gametypeHud_->addTemplate(this->gametypeHudTemplate_); 205 this->gametypeHud_->setOwner(this->getGametype()); 154 if (this->getController() && this->getController()->getHUD()) 155 this->getController()->getHUD()->setOwner(this->getControllableEntity()); 206 156 } 207 157 } -
code/branches/questsystem5/src/orxonox/objects/infos/HumanPlayer.h
r2907 r2908 51 51 void setClientID(unsigned int clientID); 52 52 53 virtual void changedGametype(); 54 virtual void changedControllableEntity(); 55 56 inline void setHumanHUDTemplate(const std::string& name) 57 { 58 if (name != this->humanHudTemplate_) 59 { 60 this->humanHudTemplate_ = name; 61 this->updateHumanHUD(); 62 } 63 } 64 inline const std::string& getHumanHUDTemplate() const 65 { return this->humanHudTemplate_; } 66 inline OverlayGroup* getHumanHUD() const 67 { return this->humanHud_; } 68 69 inline void setGametypeHUDTemplate(const std::string& name) 70 { 71 if (name != this->gametypeHudTemplate_) 72 { 73 this->gametypeHudTemplate_ = name; 74 this->updateGametypeHUD(); 75 } 76 } 77 inline const std::string& getGametypeHUDTemplate() const 78 { return this->gametypeHudTemplate_; } 79 inline OverlayGroup* getGametypeHUD() const 80 { return this->gametypeHud_; } 53 virtual void changedController(); 81 54 82 55 protected: … … 88 61 void networkcallback_client_initialized(); 89 62 90 void updateHumanHUD();91 void updateGametypeHUD();92 93 63 std::string nick_; 94 64 std::string synchronize_nick_; … … 96 66 bool server_initialized_; 97 67 bool client_initialized_; 98 99 std::string humanHudTemplate_;100 OverlayGroup* humanHud_;101 std::string gametypeHudTemplate_;102 OverlayGroup* gametypeHud_;103 68 }; 104 69 } -
code/branches/questsystem5/src/orxonox/objects/infos/PlayerInfo.cc
r2907 r2908 110 110 void PlayerInfo::createController() 111 111 { 112 if (this->controller_)113 {114 delete this->controller_;115 this->controller_ = 0;116 }117 112 this->controller_ = this->defaultController_.fabricate(this); 118 113 assert(this->controller_); … … 146 141 if (this->controller_) 147 142 this->controller_->setControllableEntity(entity); 148 149 this->changedControllableEntity();150 143 } 151 144 … … 162 155 if (callback) 163 156 entity->removePlayer(); 164 165 this->changedControllableEntity();166 157 } 167 158 } -
code/branches/questsystem5/src/orxonox/objects/infos/PlayerInfo.h
r2907 r2908 49 49 virtual void changedGametype(); 50 50 51 virtual void changedController() {}52 virtual void changedControllableEntity() {}53 54 51 inline bool isHumanPlayer() const 55 52 { return this->bHumanPlayer_; } … … 76 73 inline Controller* getController() const 77 74 { return this->controller_; } 75 virtual void changedController() {} 78 76 79 77 protected: -
code/branches/questsystem5/src/orxonox/objects/items/MultiStateEngine.cc
r2907 r2908 30 30 #include "MultiStateEngine.h" 31 31 32 #include "core/ GameMode.h"32 #include "core/Core.h" 33 33 #include "core/CoreIncludes.h" 34 34 #include "core/XMLPort.h" … … 123 123 } 124 124 125 if ( GameMode::isMaster())125 if (Core::isMaster()) 126 126 { 127 127 for (std::list<WorldEntity*>::const_iterator it = this->activeEffects_.begin(); it != this->activeEffects_.end(); ++it) -
code/branches/questsystem5/src/orxonox/objects/pickup/PickupSpawner.cc
r2907 r2908 89 89 ExecutorMember<BaseObject>* executor = createExecutor(createFunctor(&BaseObject::setActive)); 90 90 executor->setDefaultValues(true); 91 RespawnTimer_.setTimer(this->respawntimer_, false, this, executor);91 RespawnTimer_.setTimer(this->respawntimer_, false, (BaseObject*)this, executor); 92 92 COUT(0) << "TIMER SET" << std::endl; 93 93 } -
code/branches/questsystem5/src/orxonox/objects/pickup/Usable.h
- Property svn:mergeinfo changed
-
code/branches/questsystem5/src/orxonox/objects/quest/AddQuest.cc
- Property svn:mergeinfo changed
r2907 r2908 42 42 #include "orxonox/objects/infos/PlayerInfo.h" 43 43 #include "QuestManager.h" 44 #include "QuestDescription.h" 44 #include "QuestDescription.h"; 45 45 #include "Quest.h" 46 46 -
code/branches/questsystem5/src/orxonox/objects/quest/AddQuest.h
- Property svn:mergeinfo changed
-
code/branches/questsystem5/src/orxonox/objects/quest/AddQuestHint.cc
- Property svn:mergeinfo changed
-
code/branches/questsystem5/src/orxonox/objects/quest/AddQuestHint.h
- Property svn:mergeinfo changed
-
code/branches/questsystem5/src/orxonox/objects/quest/AddReward.cc
- Property svn:mergeinfo changed
-
code/branches/questsystem5/src/orxonox/objects/quest/AddReward.h
- Property svn:mergeinfo changed
-
code/branches/questsystem5/src/orxonox/objects/quest/ChangeQuestStatus.cc
-
code/branches/questsystem5/src/orxonox/objects/quest/ChangeQuestStatus.h
-
code/branches/questsystem5/src/orxonox/objects/quest/CompleteQuest.cc
- Property svn:mergeinfo changed
-
code/branches/questsystem5/src/orxonox/objects/quest/CompleteQuest.h
- Property svn:mergeinfo changed
-
code/branches/questsystem5/src/orxonox/objects/quest/FailQuest.cc
- Property svn:mergeinfo changed
-
code/branches/questsystem5/src/orxonox/objects/quest/FailQuest.h
- Property svn:mergeinfo changed
-
code/branches/questsystem5/src/orxonox/objects/quest/GlobalQuest.cc
- Property svn:mergeinfo changed
-
code/branches/questsystem5/src/orxonox/objects/quest/GlobalQuest.h
- Property svn:mergeinfo changed
-
code/branches/questsystem5/src/orxonox/objects/quest/LocalQuest.cc
- Property svn:mergeinfo changed
-
code/branches/questsystem5/src/orxonox/objects/quest/LocalQuest.h
- Property svn:mergeinfo changed
-
code/branches/questsystem5/src/orxonox/objects/quest/Quest.cc
- Property svn:mergeinfo changed
/code/branches/gui/src/orxonox/objects/quest/Quest.cc removed /code/branches/miniprojects/src/orxonox/objects/quest/Quest.cc removed /code/branches/weaponsystem/src/orxonox/objects/quest/Quest.cc removed
- Property svn:mergeinfo changed
-
code/branches/questsystem5/src/orxonox/objects/quest/Quest.h
- Property svn:mergeinfo changed
/code/branches/gui/src/orxonox/objects/quest/Quest.h removed /code/branches/miniprojects/src/orxonox/objects/quest/Quest.h removed /code/branches/weaponsystem/src/orxonox/objects/quest/Quest.h removed
- Property svn:mergeinfo changed
-
code/branches/questsystem5/src/orxonox/objects/quest/QuestDescription.cc
-
code/branches/questsystem5/src/orxonox/objects/quest/QuestDescription.h
-
code/branches/questsystem5/src/orxonox/objects/quest/QuestEffect.cc
- Property svn:mergeinfo changed
-
code/branches/questsystem5/src/orxonox/objects/quest/QuestEffect.h
- Property svn:mergeinfo changed
-
code/branches/questsystem5/src/orxonox/objects/quest/QuestHint.cc
- Property svn:mergeinfo changed
-
code/branches/questsystem5/src/orxonox/objects/quest/QuestHint.h
- Property svn:mergeinfo changed
-
code/branches/questsystem5/src/orxonox/objects/quest/QuestItem.cc
- Property svn:mergeinfo changed
-
code/branches/questsystem5/src/orxonox/objects/quest/QuestItem.h
- Property svn:mergeinfo changed
-
code/branches/questsystem5/src/orxonox/objects/quest/QuestManager.cc
- Property svn:mergeinfo changed
-
code/branches/questsystem5/src/orxonox/objects/quest/QuestManager.h
- Property svn:mergeinfo changed
-
code/branches/questsystem5/src/orxonox/objects/quest/Rewardable.cc
- Property svn:mergeinfo changed
-
code/branches/questsystem5/src/orxonox/objects/quest/Rewardable.h
- Property svn:mergeinfo changed
-
code/branches/questsystem5/src/orxonox/objects/weaponSystem/Munition.cc
r2907 r2908 105 105 void Munition::fillBullets() 106 106 { 107 //COUT(0) << "Munition::fillBullets maxBullets_=" << this->maxBullets_ << std::endl; 107 108 this->bullets_ = this->maxBullets_; 108 109 } -
code/branches/questsystem5/src/orxonox/objects/weaponSystem/Weapon.cc
r2907 r2908 42 42 { 43 43 RegisterObject(Weapon); 44 45 44 this->bulletReadyToShoot_ = true; 46 45 this->magazineReadyToShoot_ = true; 47 46 this->parentWeaponSystem_ = 0; 48 47 this->attachedToWeaponSlot_ = 0; 48 this->munition_ = 0; 49 49 this->bulletLoadingTime_ = 0; 50 50 this->magazineLoadingTime_ = 0; 51 51 this->bReloading_ = false; 52 this->bulletAmount_= 0; 53 this->magazineAmount_ = 0; 54 this->munition_ = 0; 55 this->unlimitedMunition_ = false; 52 56 53 this->setObjectMode(0x0); 57 54 } … … 68 65 XMLPortParam(Weapon, "bulletLoadingTime", setBulletLoadingTime, getBulletLoadingTime, xmlelement, mode); 69 66 XMLPortParam(Weapon, "magazineLoadingTime", setMagazineLoadingTime, getMagazineLoadingTime, xmlelement, mode); 70 XMLPortParam(Weapon, "bullets", setBulletAmount, getBulletAmount, xmlelement, mode);71 XMLPortParam(Weapon, "magazines", setMagazineAmount, getMagazineAmount, xmlelement, mode);72 XMLPortParam(Weapon, "unlimitedMunition", setUnlimitedMunition, getUnlimitedMunition, xmlelement, mode);73 67 } 74 68 … … 79 73 } 80 74 81 void Weapon::setMunition()82 {83 this->munition_->setMaxBullets(this->bulletAmount_);84 this->munition_->setMaxMagazines(this->magazineAmount_);85 }86 75 87 76 void Weapon::fire() 88 77 { 78 //COUT(0) << "LaserGun::fire, this=" << this << std::endl; 89 79 if ( this->bulletReadyToShoot_ && this->magazineReadyToShoot_ && !this->bReloading_) 90 80 { 81 //COUT(0) << "LaserGun::fire - ready to shoot" << std::endl; 82 //COUT(0) << "LaserGun::fire - bullets" << this->munition_->bullets() << std::endl; 91 83 this->bulletReadyToShoot_ = false; 92 if ( this-> unlimitedMunition_== true)84 if ( this->munition_->bullets() > 0) 93 85 { 94 86 //shoot 95 this-> reloadBullet();87 this->takeBullets(); 96 88 this->createProjectile(); 89 } 90 //if there are no bullets, but magazines 91 else if ( this->munition_->magazines() > 0 && this->munition_->bullets() == 0 ) 92 { 93 //COUT(0) << "LaserGun::fire - no bullets" << std::endl; 94 this->takeMagazines(); 97 95 } 98 96 else 99 97 { 100 if ( this->munition_->bullets() > 0) 101 { 102 //shoot and reload 103 this->takeBullets(); 104 this->reloadBullet(); 105 this->createProjectile(); 106 } 107 //if there are no bullets, but magazines 108 else if ( this->munition_->magazines() > 0 && this->munition_->bullets() == 0 ) 109 { 110 //reload magazine 111 this->takeMagazines(); 112 this->reloadMagazine(); 113 } 114 else 115 { 116 //no magazines 117 } 98 //COUT(0) << "LaserGun::fire - no magazines" << std::endl; 99 //actions 118 100 } 119 101 } 120 102 else 121 103 { 122 //weapon not reloaded 104 //COUT(0) << "LaserGun::fire - weapon not reloaded - bullets remaining:" << this->munition_->bullets() << std::endl; 105 //actions 123 106 } 124 107 … … 126 109 127 110 128 //weapon reloading129 111 void Weapon::bulletTimer(float bulletLoadingTime) 130 112 { 113 //COUT(0) << "Weapon::bulletTimer started" << std::endl; 131 114 this->bReloading_ = true; 132 115 this->bulletReloadTimer_.setTimer( bulletLoadingTime , false , this , createExecutor(createFunctor(&Weapon::bulletReloaded))); … … 134 117 void Weapon::magazineTimer(float magazineLoadingTime) 135 118 { 119 //COUT(0) << "Weapon::magazineTimer started" << std::endl; 136 120 this->bReloading_ = true; 137 121 this->magazineReloadTimer_.setTimer( magazineLoadingTime , false , this , createExecutor(createFunctor(&Weapon::magazineReloaded))); … … 148 132 this->bReloading_ = false; 149 133 this->munition_->fillBullets(); 134 this->magazineReadyToShoot_ = true; 135 this->bulletReadyToShoot_ = true; 150 136 } 151 152 137 153 138 154 139 void Weapon::attachNeededMunition(std::string munitionName) 155 140 { 156 /* if munition type already exists attach it, else create a new one of this type and attach it to the weapon and to the WeaponSystem 157 */141 //COUT(0) << "Weapon::attachNeededMunition, parentWeaponSystem=" << this->parentWeaponSystem_ << std::endl; 142 //if munition type already exists attach it, else create a new one of this type and attach it to the weapon and to the WeaponSystem 158 143 if (this->parentWeaponSystem_) 159 144 { 160 //getMunitionType returns 0 if there is no such munitionType 145 //COUT(0) << "Weapon::attachNeededMunition " << munitionName << std::endl; 161 146 Munition* munition = this->parentWeaponSystem_->getMunitionType(munitionName); 162 147 if ( munition ) 163 {164 148 this->munition_ = munition; 165 this->setMunition();166 }167 149 else 168 150 { 169 //create new munition with identifier because there is no such munitionType 151 //create new munition with identifier 152 //COUT(0) << "Weapon::attachNeededMunition, create new Munition of Type " << munitionName << std::endl; 170 153 this->munitionIdentifier_ = ClassByString(munitionName); 171 154 this->munition_ = this->munitionIdentifier_.fabricate(this); 172 155 this->parentWeaponSystem_->setNewMunition(munitionName, this->munition_); 173 this->setMunition();174 156 } 175 157 } … … 177 159 178 160 179 Munition * Weapon::getAttachedMunition(std::string munitionType) 180 { 181 this->munition_ = this->parentWeaponSystem_->getMunitionType(munitionType); 182 return this->munition_; 183 } 161 /*get and set functions 162 * 163 */ 184 164 185 186 //these function are defined in the weapon classes187 void Weapon::takeBullets() { };188 void Weapon::createProjectile() { };189 void Weapon::takeMagazines() { };190 void Weapon::reloadBullet() { };191 void Weapon::reloadMagazine() { };192 193 194 //get and set functions for XMLPort195 165 void Weapon::setMunitionType(std::string munitionType) 196 166 { this->munitionType_ = munitionType; } … … 211 181 { return this->magazineLoadingTime_; } 212 182 213 void Weapon::setBulletAmount(unsigned int amount)214 { this->bulletAmount_ = amount; }215 183 216 const unsigned int Weapon::getBulletAmount() 217 { return this->bulletAmount_; } 184 Munition * Weapon::getAttachedMunition(std::string munitionType) 185 { 186 //COUT(0) << "Weapon::getAttachedMunition, parentWeaponSystem_="<< this->parentWeaponSystem_ << std::endl; 187 this->munition_ = this->parentWeaponSystem_->getMunitionType(munitionType); 188 //COUT(0) << "Weapon::getAttachedMunition, munition_="<< this->munition_ << std::endl; 189 return this->munition_; 190 } 218 191 219 void Weapon::setMagazineAmount(unsigned int amount) 220 { this->magazineAmount_ = amount; } 221 222 const unsigned int Weapon::getMagazineAmount() 223 { return this->magazineAmount_; } 224 225 void Weapon::setUnlimitedMunition(bool unlimitedMunition) 226 { this->unlimitedMunition_ = unlimitedMunition; } 227 228 const bool Weapon::getUnlimitedMunition() 229 { return this->unlimitedMunition_; } 192 void Weapon::takeBullets() { }; 193 void Weapon::createProjectile() { }; 194 void Weapon::takeMagazines() { }; 230 195 231 196 } -
code/branches/questsystem5/src/orxonox/objects/weaponSystem/Weapon.h
r2907 r2908 62 62 void magazineReloaded(); 63 63 64 //XMLPort functions65 64 virtual void setMunitionType(std::string munitionType); 66 65 virtual const std::string getMunitionType(); … … 69 68 virtual void setMagazineLoadingTime(float loadingTime); 70 69 virtual const float getMagazineLoadingTime(); 71 virtual void setBulletAmount(unsigned int amount);72 virtual const unsigned int getBulletAmount();73 virtual void setMagazineAmount(unsigned int amount);74 virtual const unsigned int getMagazineAmount();75 virtual void setUnlimitedMunition(bool unlimitedMunition);76 virtual const bool getUnlimitedMunition();77 70 78 //weapon actions79 71 virtual void takeBullets(); 80 72 virtual void takeMagazines(); 81 73 virtual void createProjectile(); 82 virtual void reloadBullet();83 virtual void reloadMagazine();84 74 85 //manually set or reset86 virtual void setWeapon();87 virtual void setMunition();88 89 75 inline void setParentWeaponSystem(WeaponSystem *parentWeaponSystem) 90 76 { this->parentWeaponSystem_=parentWeaponSystem; }; … … 97 83 { return this->attachedToWeaponSlot_; } 98 84 85 virtual void setWeapon(); 99 86 100 87 private: … … 104 91 bool bulletReadyToShoot_; 105 92 bool magazineReadyToShoot_; 106 bool unlimitedMunition_;107 93 float bulletLoadingTime_; 108 94 float magazineLoadingTime_; 109 unsigned int bulletAmount_;110 unsigned int magazineAmount_;111 95 std::string munitionType_; 112 96 -
code/branches/questsystem5/src/orxonox/objects/weaponSystem/WeaponPack.cc
r2907 r2908 63 63 for (int i=0; i < (int) this->weapons_.size(); i++) 64 64 { 65 //COUT(0) << "WeaponPack::fire (attached from WeaponSet) from Weapon: "<< i << std::endl; 65 66 this->weapons_[i]->getAttachedToWeaponSlot()->fire(); 66 67 } … … 82 83 void WeaponPack::setFireMode(unsigned int firemode) 83 84 { 85 //COUT(0) << "WeaponPack::setFireMode " << std::endl; 84 86 this->firemode_ = firemode; 85 87 } … … 92 94 void WeaponPack::addWeapon(Weapon * weapon) 93 95 { 96 //COUT(0) << "WeaponPack::addWeapon:" << weapon << " munition " << weapon->getMunitionType() << std::endl; 94 97 this->weapons_.push_back(weapon); 95 98 } … … 114 117 { 115 118 this->weapons_[i]->attachNeededMunition(weapons_[i]->getMunitionType()); 119 //hack! 116 120 this->weapons_[i]->setWeapon(); 117 121 } -
code/branches/questsystem5/src/orxonox/objects/weaponSystem/WeaponPack.h
r2907 r2908 59 59 const Weapon * getWeapon(unsigned int index); 60 60 61 //functions with effect to all weapons of the weaponPack62 61 //functions needed for creating Pointer to the right objects (-->Pawn.cc) 63 62 void setParentWeaponSystemToAllWeapons(WeaponSystem * weaponSystem); -
code/branches/questsystem5/src/orxonox/objects/weaponSystem/WeaponSet.cc
r2907 r2908 56 56 void WeaponSet::attachWeaponPack(WeaponPack *wPack) 57 57 { 58 //COUT(0) << "WeaponSet::attachWeaponPack" << std::endl; 59 //COUT(0) << "........ parentWeaponSystem_=" << this->parentWeaponSystem_ << std::endl; 60 //COUT(0) << "........ this->parentWeaponSystem_->getWeaponSlotSize()" << this->parentWeaponSystem_->getWeaponSlotSize() << std::endl; 61 //COUT(0) << "........ wPack->getSize()" << wPack->getSize() << std::endl; 58 62 if ( this->parentWeaponSystem_->getWeaponSlotSize()>0 && wPack->getSize()>0 && ( wPack->getSize() <= this->parentWeaponSystem_->getWeaponSlotSize() ) ) 59 63 { 64 //COUT(0) << "WeaponSet::attachWeaponPack after if" << std::endl; 60 65 this->attachedWeaponPack_ = wPack; 61 66 int wPackWeapon = 0; //WeaponCounter for Attaching 62 63 67 //should be possible to choose which slot to use 64 //attach every weapon of the weaponPack to a weaponSlot65 68 for ( int i=0; i < wPack->getSize() ; i++ ) 66 69 { 67 70 //at the moment this function only works for one weaponPack in the entire WeaponSystem... 68 //it also takes the first free weaponSlot...69 71 if ( this->parentWeaponSystem_->getWeaponSlotPointer(i)->getAttachedWeapon() == 0 && this->parentWeaponSystem_->getWeaponSlotPointer(i) != 0) //if slot not full 70 72 { 73 //COUT(0) << "WeaponSet::attachWeaponPack attaching Weapon" << std::endl; 71 74 this->setWeaponSlots_.push_back( this->parentWeaponSystem_->getWeaponSlotPointer(i) ); 72 75 this->parentWeaponSystem_->getWeaponSlotPointer(i)->attachWeapon( wPack->getWeaponPointer(wPackWeapon) ); … … 80 83 if ( this->parentWeaponSystem_->getWeaponSlotPointer(k)->getAttachedWeapon() == 0 ) 81 84 { 85 //COUT(0) << "WeaponSet::attachWeaponPack mode 2 k="<< k << std::endl; 82 86 this->setWeaponSlots_.push_back( this->parentWeaponSystem_->getWeaponSlotPointer(k) ); 83 87 this->parentWeaponSystem_->getWeaponSlotPointer(k)->attachWeapon( wPack->getWeaponPointer(wPackWeapon) ); … … 95 99 { 96 100 //fires all WeaponSlots available for this weaponSet attached from the WeaponPack 101 //COUT(0) << "WeaponSet::fire from Pack: " << this->attachedWeaponPack_ << std::endl; 97 102 if (this->attachedWeaponPack_) 98 103 this->attachedWeaponPack_->fire(); -
code/branches/questsystem5/src/orxonox/objects/weaponSystem/WeaponSystem.cc
- Property svn:mergeinfo changed
r2907 r2908 38 38 39 39 40 /* WeaponSystem 40 /* WEAPONSYSTEM 41 * creates the WeaponSystem and the ability to use weapons and munition 42 * loads the weapon the whole weaponSystem setting from an xml file 41 43 * 42 * www.orxonox.net/wiki/WeaponSystem43 44 */ 44 45 … … 51 52 RegisterObject(WeaponSystem); 52 53 54 this->activeWeaponSet_ = 0; 53 55 this->parentPawn_ = 0; 54 56 } … … 82 84 } 83 85 84 85 //returns the Pointer to the munitionType, if this munitionType doesn't exist returns 0, see Weapon::attachNeededMunition 86 //returns the Pointer to the munitionType 86 87 Munition * WeaponSystem::getMunitionType(std::string munitionType) 87 88 { 89 //COUT(0) << "WeaponSystem::getMunitionType " << munitionType << std::endl; 88 90 std::map<std::string, Munition *>::const_iterator it = this->munitionSet_.find(munitionType); 89 91 if (it != this->munitionSet_.end()) … … 94 96 95 97 98 /* 99 //the first weaponSet is at n=0 100 void WeaponSystem::setActiveWeaponSet(unsigned int n) 101 { 102 if (n < this->weaponSets_.size()) 103 this->activeWeaponSet_ = this->weaponSets_[n]; 104 else 105 this->activeWeaponSet_ = this->weaponSets_[0]; 106 } 107 */ 108 109 96 110 //n is the n'th weaponSet, starting with zero 97 //SpaceShip.cc only needs to have the keybinding to a specific Set-number n (=firemode) 98 //in future this could be well defined and not only for 3 different WeaponModes 111 //SpaceShip.cc only needs to have the keybinding to a specific Set-number n 99 112 void WeaponSystem::fire(WeaponMode::Enum n) 100 113 { … … 112 125 break; 113 126 } 127 //COUT(0) << "WeaponSystem::fire" << std::endl; 114 128 if (set < (int)this->weaponSets_.size()) 129 //COUT(0) << "WeaponSystem::fire - after if" << std::endl; 115 130 this->weaponSets_[set]->fire(); 116 131 } -
code/branches/questsystem5/src/orxonox/objects/weaponSystem/WeaponSystem.h
- Property svn:mergeinfo changed
r2907 r2908 53 53 //void fire(); 54 54 void fire(WeaponMode::Enum fireMode); 55 //void setActiveWeaponSet(unsigned int n); 55 56 void attachWeaponPack(WeaponPack * wPack, unsigned int firemode); 56 57 WeaponSet * getWeaponSetPointer(unsigned int n); … … 58 59 WeaponPack * getWeaponPackPointer(unsigned int n); 59 60 void setNewMunition(std::string munitionType, Munition * munitionToAdd); 60 void setNewSharedMunition(std::string munitionType, Munition * munitionToAdd);61 61 Munition * getMunitionType(std::string munitionType); 62 62 … … 74 74 std::vector<WeaponPack *> weaponPacks_; 75 75 std::map<std::string, Munition *> munitionSet_; 76 WeaponSet *activeWeaponSet_; 76 77 Pawn *parentPawn_; 77 78 }; -
code/branches/questsystem5/src/orxonox/objects/weaponSystem/munitions/CMakeLists.txt
r2907 r2908 1 1 ADD_SOURCE_FILES(ORXONOX_SRC_FILES 2 2 LaserGunMunition.cc 3 FusionMunition.cc4 3 ) -
code/branches/questsystem5/src/orxonox/objects/weaponSystem/munitions/LaserGunMunition.cc
r2907 r2908 43 43 RegisterObject(LaserGunMunition); 44 44 45 //default if not defined in XML46 45 this->maxBullets_ = 40; 47 46 this->maxMagazines_ = 100; -
code/branches/questsystem5/src/orxonox/objects/weaponSystem/projectiles/BillboardProjectile.cc
r2907 r2908 32 32 #include <OgreBillboardSet.h> 33 33 34 #include "core/ GameMode.h"34 #include "core/Core.h" 35 35 #include "core/CoreIncludes.h" 36 36 #include "objects/Scene.h" … … 44 44 RegisterObject(BillboardProjectile); 45 45 46 if ( GameMode::showsGraphics())46 if (Core::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() && GameMode::showsGraphics() && this->billboard_.getBillboardSet())58 if (this->isInitialized() && Core::showsGraphics() && this->billboard_.getBillboardSet()) 59 59 this->detachOgreObject(this->billboard_.getBillboardSet()); 60 60 } -
code/branches/questsystem5/src/orxonox/objects/weaponSystem/projectiles/ParticleProjectile.cc
r2907 r2908 33 33 #include <OgreParticleEmitter.h> 34 34 35 #include "core/ GameMode.h"35 #include "core/Core.h" 36 36 #include "core/CoreIncludes.h" 37 37 #include "core/ConfigValueIncludes.h" … … 46 46 RegisterObject(ParticleProjectile); 47 47 48 if ( GameMode::showsGraphics())48 if (Core::showsGraphics()) 49 49 { 50 50 this->particles_ = new ParticleInterface(this->getScene()->getSceneManager(), "Orxonox/shot3_small", LODParticle::normal); -
code/branches/questsystem5/src/orxonox/objects/weaponSystem/projectiles/Projectile.cc
r2907 r2908 41 41 #include "objects/worldentities/ParticleSpawner.h" 42 42 #include "objects/collisionshapes/SphereCollisionShape.h" 43 #include "core/ GameMode.h"43 #include "core/Core.h" 44 44 45 45 namespace orxonox … … 55 55 // Get notification about collisions 56 56 57 if ( GameMode::isMaster())57 if (Core::isMaster()) 58 58 { 59 59 this->enableCollisionCallback(); … … 93 93 void Projectile::destroyObject() 94 94 { 95 if ( GameMode::isMaster())95 if (Core::isMaster()) 96 96 delete this; 97 97 } … … 99 99 bool Projectile::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint) 100 100 { 101 if (!this->bDestroy_ && GameMode::isMaster())101 if (!this->bDestroy_ && Core::isMaster()) 102 102 { 103 103 this->bDestroy_ = true; -
code/branches/questsystem5/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc
r2907 r2908 53 53 } 54 54 55 void LaserGun::reloadBullet()56 {57 this->bulletTimer(this->bulletLoadingTime_);58 }59 60 void LaserGun::reloadMagazine()61 {62 this->magazineTimer(this->magazineLoadingTime_);63 }64 65 55 void LaserGun::takeBullets() 66 56 { 57 //COUT(0) << "LaserGun::takeBullets" << std::endl; 67 58 this->munition_->removeBullets(1); 59 this->bulletTimer(this->bulletLoadingTime_); 68 60 } 69 61 … … 71 63 { 72 64 this->munition_->removeMagazines(1); 65 this->magazineTimer(this->magazineLoadingTime_); 73 66 } 74 67 75 68 void LaserGun::createProjectile() 76 69 { 70 //COUT(0) << "LaserGun::createProjectile" << std::endl; 77 71 BillboardProjectile* projectile = new ParticleProjectile(this); 78 72 projectile->setOrientation(this->getWorldOrientation()); -
code/branches/questsystem5/src/orxonox/objects/weaponSystem/weapons/LaserGun.h
r2907 r2908 51 51 virtual void takeMagazines(); 52 52 virtual void createProjectile(); 53 virtual void reloadBullet();54 virtual void reloadMagazine();55 53 56 54 private: -
code/branches/questsystem5/src/orxonox/objects/worldentities/Backlight.cc
- Property svn:mergeinfo changed
r2907 r2908 33 33 #include <OgreSceneManager.h> 34 34 35 #include "core/ GameMode.h"35 #include "core/Core.h" 36 36 #include "core/CoreIncludes.h" 37 37 #include "core/Executor.h" … … 58 58 this->tickcount_ = 0; 59 59 60 if ( GameMode::showsGraphics())60 if (Core::showsGraphics()) 61 61 { 62 62 if (!this->getScene()) -
code/branches/questsystem5/src/orxonox/objects/worldentities/Backlight.h
- Property svn:mergeinfo changed
r2907 r2908 32 32 #include "OrxonoxPrereqs.h" 33 33 #include "FadingBillboard.h" 34 #include " tools/TimeFactorListener.h"34 #include "gamestates/GSRoot.h" 35 35 36 36 namespace orxonox -
code/branches/questsystem5/src/orxonox/objects/worldentities/Billboard.cc
r2907 r2908 34 34 #include "core/CoreIncludes.h" 35 35 #include "core/XMLPort.h" 36 #include "core/ GameMode.h"36 #include "core/Core.h" 37 37 #include "objects/Scene.h" 38 38 … … 81 81 if (!this->billboard_.getBillboardSet()) 82 82 { 83 if (this->getScene() && GameMode::showsGraphics())83 if (this->getScene() && Core::showsGraphics()) 84 84 { 85 85 this->billboard_.setBillboardSet(this->getScene()->getSceneManager(), this->material_, this->colour_, 1); … … 98 98 { 99 99 /* 100 if (this->getScene() && GameMode::showsGraphics() && (this->material_ != ""))100 if (this->getScene() && Core::showsGraphics() && (this->material_ != "")) 101 101 { 102 102 this->billboard_.setBillboardSet(this->getScene()->getSceneManager(), this->material_, this->colour_, 1); -
code/branches/questsystem5/src/orxonox/objects/worldentities/Billboard.h
r2907 r2908 34 34 #include "util/Math.h" 35 35 #include "tools/BillboardSet.h" 36 #include "objects/Teamcolourable.h"37 36 38 37 namespace orxonox 39 38 { 40 class _OrxonoxExport Billboard : public StaticEntity , public Teamcolourable39 class _OrxonoxExport Billboard : public StaticEntity 41 40 { 42 41 public: … … 62 61 { return this->colour_; } 63 62 64 virtual void setTeamColour(const ColourValue& colour)65 { this->setColour(colour); }66 67 63 protected: 68 64 inline BillboardSet& getBillboardSet() -
code/branches/questsystem5/src/orxonox/objects/worldentities/BlinkingBillboard.cc
r2907 r2908 30 30 #include "BlinkingBillboard.h" 31 31 32 #include "core/ GameMode.h"32 #include "core/Core.h" 33 33 #include "core/CoreIncludes.h" 34 34 #include "core/XMLPort.h" … … 77 77 SUPER(BlinkingBillboard, tick, dt); 78 78 79 if ( GameMode::isMaster() && this->isActive())79 if (Core::isMaster() && this->isActive()) 80 80 { 81 81 this->time_ += dt; -
code/branches/questsystem5/src/orxonox/objects/worldentities/CMakeLists.txt
r2907 r2908 19 19 Planet.cc 20 20 SpawnPoint.cc 21 TeamSpawnPoint.cc22 PongCenterpoint.cc23 PongBall.cc24 PongBat.cc25 21 ) 26 22 -
code/branches/questsystem5/src/orxonox/objects/worldentities/Camera.cc
- Property svn:mergeinfo changed
-
code/branches/questsystem5/src/orxonox/objects/worldentities/Camera.h
- Property svn:mergeinfo changed
-
code/branches/questsystem5/src/orxonox/objects/worldentities/CameraPosition.cc
r2907 r2908 44 44 this->bDrag_ = false; 45 45 this->bAllowMouseLook_ = false; 46 this->bAbsolute_ = false;47 46 48 47 this->setObjectMode(0x0); … … 59 58 XMLPortParam(CameraPosition, "drag", setDrag, getDrag, xmlelement, mode).defaultValues(false); 60 59 XMLPortParam(CameraPosition, "mouselook", setAllowMouseLook, getAllowMouseLook, xmlelement, mode).defaultValues(false); 61 XMLPortParam(CameraPosition, "absolute", setIsAbsolute, getIsAbsolute, xmlelement, mode).defaultValues(false);62 60 } 63 61 -
code/branches/questsystem5/src/orxonox/objects/worldentities/CameraPosition.h
r2907 r2908 54 54 { return this->bAllowMouseLook_; } 55 55 56 inline void setIsAbsolute(bool bAbsolute)57 { this->bAbsolute_ = bAbsolute; }58 inline bool getIsAbsolute() const59 { return this->bAbsolute_; }60 61 56 void attachCamera(Camera* camera); 62 57 … … 64 59 bool bDrag_; 65 60 bool bAllowMouseLook_; 66 bool bAbsolute_;67 61 }; 68 62 } -
code/branches/questsystem5/src/orxonox/objects/worldentities/ControllableEntity.cc
r2907 r2908 34 34 #include "core/CoreIncludes.h" 35 35 #include "core/ConfigValueIncludes.h" 36 #include "core/ GameMode.h"36 #include "core/Core.h" 37 37 #include "core/XMLPort.h" 38 38 #include "core/Template.h" … … 144 144 void ControllableEntity::addCameraPosition(CameraPosition* position) 145 145 { 146 if (!position->getIsAbsolute()) 147 { 148 if (position->getAllowMouseLook()) 149 position->attachToNode(this->cameraPositionRootNode_); 150 else 151 this->attach(position); 152 } 146 if (position->getAllowMouseLook()) 147 position->attachToNode(this->cameraPositionRootNode_); 153 148 else 154 { 155 WorldEntity* parent = this->getParent(); 156 if (parent) 157 parent->attach(position); 158 } 149 this->attach(position); 159 150 this->cameraPositions_.push_back(position); 160 151 } … … 245 236 this->startLocalHumanControl(); 246 237 247 if (! GameMode::isMaster())238 if (!Core::isMaster()) 248 239 { 249 240 this->client_overwrite_ = this->server_overwrite_; … … 251 242 } 252 243 } 253 254 this->changedPlayer();255 244 } 256 245 … … 265 254 this->bHasHumanController_ = false; 266 255 this->setObjectMode(objectDirection::toclient); 267 268 this->changedPlayer();269 256 270 257 if (this->bDestroyWhenPlayerLeft_) … … 335 322 } 336 323 337 void ControllableEntity::parentChanged()338 {339 WorldEntity::parentChanged();340 341 WorldEntity* parent = this->getParent();342 if (parent)343 {344 for (std::list<CameraPosition*>::iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)345 if ((*it)->getIsAbsolute())346 parent->attach((*it));347 }348 }349 350 324 void ControllableEntity::tick(float dt) 351 325 { … … 357 331 if (!this->isDynamic()) 358 332 { 359 if ( GameMode::isMaster())333 if (Core::isMaster()) 360 334 { 361 335 this->server_position_ = this->getPosition(); … … 472 446 void ControllableEntity::setPosition(const Vector3& position) 473 447 { 474 if ( GameMode::isMaster())448 if (Core::isMaster()) 475 449 { 476 450 MobileEntity::setPosition(position); … … 487 461 void ControllableEntity::setOrientation(const Quaternion& orientation) 488 462 { 489 if ( GameMode::isMaster())463 if (Core::isMaster()) 490 464 { 491 465 MobileEntity::setOrientation(orientation); … … 502 476 void ControllableEntity::setVelocity(const Vector3& velocity) 503 477 { 504 if ( GameMode::isMaster())478 if (Core::isMaster()) 505 479 { 506 480 MobileEntity::setVelocity(velocity); … … 517 491 void ControllableEntity::setAngularVelocity(const Vector3& velocity) 518 492 { 519 if ( GameMode::isMaster())493 if (Core::isMaster()) 520 494 { 521 495 MobileEntity::setAngularVelocity(velocity); … … 533 507 { 534 508 MobileEntity::setWorldTransform(worldTrans); 535 if ( GameMode::isMaster())509 if (Core::isMaster()) 536 510 { 537 511 this->server_position_ = this->getPosition(); -
code/branches/questsystem5/src/orxonox/objects/worldentities/ControllableEntity.h
r2907 r2908 49 49 50 50 virtual void changedGametype(); 51 virtual void changedPlayer() {}52 51 53 52 virtual void setPlayer(PlayerInfo* player); … … 137 136 virtual void startLocalHumanControl(); 138 137 virtual void stopLocalHumanControl(); 139 virtual void parentChanged();140 138 141 139 inline void setHudTemplate(const std::string& name) -
code/branches/questsystem5/src/orxonox/objects/worldentities/ExplosionChunk.cc
r2907 r2908 32 32 #include <OgreParticleSystem.h> 33 33 34 #include "core/ GameMode.h"34 #include "core/Core.h" 35 35 #include "core/CoreIncludes.h" 36 36 #include "core/Executor.h" … … 47 47 RegisterObject(ExplosionChunk); 48 48 49 if ( GameMode::showsGraphics() && ( !this->getScene() || !this->getScene()->getSceneManager() ) )49 if ( Core::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 ( GameMode::showsGraphics() )55 if ( Core::showsGraphics() ) 56 56 { 57 57 try … … 75 75 } 76 76 77 if ( GameMode::isMaster())77 if (Core::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 ( GameMode::isMaster())134 if (Core::isMaster()) 135 135 { 136 136 this->bStop_ = true; … … 148 148 static const unsigned int CHANGES_PER_SECOND = 5; 149 149 150 if ( GameMode::isMaster() && rnd() < dt*CHANGES_PER_SECOND)150 if (Core::isMaster() && rnd() < dt*CHANGES_PER_SECOND) 151 151 { 152 152 float length = this->getVelocity().length(); -
code/branches/questsystem5/src/orxonox/objects/worldentities/Light.cc
r2907 r2908 37 37 #include "util/String.h" 38 38 #include "util/Exception.h" 39 #include "core/ GameMode.h"39 #include "core/Core.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 ( GameMode::showsGraphics())59 if (Core::showsGraphics()) 60 60 { 61 61 if (!this->getScene()) -
code/branches/questsystem5/src/orxonox/objects/worldentities/Light.h
r2907 r2908 37 37 38 38 #include "util/Math.h" 39 #include "objects/Teamcolourable.h"40 39 41 40 namespace orxonox 42 41 { 43 class _OrxonoxExport Light : public StaticEntity , public Teamcolourable42 class _OrxonoxExport Light : public StaticEntity 44 43 { 45 44 public: … … 69 68 inline const ColourValue& getSpecularColour() const 70 69 { return this->specular_; } 71 72 virtual void setTeamColour(const ColourValue& colour)73 { this->setDiffuseColour(colour); this->setSpecularColour(colour); }74 70 75 71 /** -
code/branches/questsystem5/src/orxonox/objects/worldentities/MobileEntity.cc
- Property svn:mergeinfo changed
r2907 r2908 182 182 // We use a dynamic body. So we translate our node accordingly. 183 183 this->node_->setPosition(Vector3(worldTrans.getOrigin().x(), worldTrans.getOrigin().y(), worldTrans.getOrigin().z())); 184 btQuaternion temp(worldTrans.getRotation()); 185 this->node_->setOrientation(Quaternion(temp.w(), temp.x(), temp.y(), temp.z())); 184 this->node_->setOrientation(Quaternion(worldTrans.getRotation().w(), worldTrans.getRotation().x(), worldTrans.getRotation().y(), worldTrans.getRotation().z())); 186 185 this->linearVelocity_.x = this->physicalBody_->getLinearVelocity().x(); 187 186 this->linearVelocity_.y = this->physicalBody_->getLinearVelocity().y(); -
code/branches/questsystem5/src/orxonox/objects/worldentities/MobileEntity.h
- Property svn:mergeinfo changed
-
code/branches/questsystem5/src/orxonox/objects/worldentities/Model.cc
r2907 r2908 31 31 #include <OgreEntity.h> 32 32 #include "Model.h" 33 #include "core/GameMode.h"34 33 #include "core/CoreIncludes.h" 35 34 #include "core/XMLPort.h" … … 71 70 void Model::changedMesh() 72 71 { 73 if ( GameMode::showsGraphics())72 if (Core::showsGraphics()) 74 73 { 75 74 if (this->mesh_.getEntity()) -
code/branches/questsystem5/src/orxonox/objects/worldentities/MovableEntity.cc
r2907 r2908 34 34 #include "core/XMLPort.h" 35 35 #include "core/Executor.h" 36 #include "core/ GameMode.h"36 #include "core/Core.h" 37 37 38 38 namespace orxonox … … 89 89 void MovableEntity::resynchronize() 90 90 { 91 if ( GameMode::isMaster() && !this->continuousResynchroTimer_)91 if (Core::isMaster() && !this->continuousResynchroTimer_) 92 92 { 93 93 // Resynchronise every few seconds because we only work with velocities (no positions) -
code/branches/questsystem5/src/orxonox/objects/worldentities/ParticleEmitter.cc
r2907 r2908 39 39 #include "tools/ParticleInterface.h" 40 40 #include "util/Exception.h" 41 #include "core/GameMode.h"42 41 #include "core/CoreIncludes.h" 43 42 #include "core/XMLPort.h" … … 52 51 RegisterObject(ParticleEmitter); 53 52 54 if ( GameMode::showsGraphics() && (!this->getScene() || !this->getScene()->getSceneManager()))53 if (Core::showsGraphics() && (!this->getScene() || !this->getScene()->getSceneManager())) 55 54 ThrowException(AbortLoading, "Can't create ParticleEmitter, no scene or no scene manager given."); 56 55 … … 108 107 } 109 108 110 if ( GameMode::showsGraphics() && this->getScene() && this->getScene()->getSceneManager())109 if (Core::showsGraphics() && this->getScene() && this->getScene()->getSceneManager()) 111 110 { 112 111 try -
code/branches/questsystem5/src/orxonox/objects/worldentities/ParticleSpawner.cc
-
code/branches/questsystem5/src/orxonox/objects/worldentities/ParticleSpawner.h
-
code/branches/questsystem5/src/orxonox/objects/worldentities/Planet.cc
r2907 r2908 42 42 #include "CameraManager.h" 43 43 #include "Camera.h" 44 #include "Graphics Manager.h"44 #include "GraphicsEngine.h" 45 45 46 46 namespace orxonox -
code/branches/questsystem5/src/orxonox/objects/worldentities/StaticEntity.cc
-
code/branches/questsystem5/src/orxonox/objects/worldentities/StaticEntity.h
-
code/branches/questsystem5/src/orxonox/objects/worldentities/WorldEntity.cc
r2907 r2908 181 181 182 182 // Attach to parent if necessary 183 registerVariable(this->parentID_, variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity:: networkcallback_parentChanged));183 registerVariable(this->parentID_, variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::parentChanged)); 184 184 } 185 185 … … 188 188 Network function that object this instance to its correct parent. 189 189 */ 190 void WorldEntity:: networkcallback_parentChanged()190 void WorldEntity::parentChanged() 191 191 { 192 192 if (this->parentID_ != OBJECTID_UNKNOWN) … … 362 362 this->parentID_ = newParent->getObjectID(); 363 363 364 this->parentChanged();365 366 364 // apply transform to collision shape 367 365 this->collisionShape_->setPosition(this->getPosition()); 368 366 this->collisionShape_->setOrientation(this->getOrientation()); 369 367 // TODO: Scale 370 368 371 369 return true; 372 370 } … … 408 406 this->parent_ = 0; 409 407 this->parentID_ = OBJECTID_UNKNOWN; 410 411 this->parentChanged();412 408 413 409 // reset orientation of the collisionShape (cannot be set within a WE usually) … … 492 488 493 489 // Note: These functions are placed in WorldEntity.h as inline functions for the release build. 494 #ifndef NDEBUG490 #ifndef _NDEBUG 495 491 const Vector3& WorldEntity::getPosition() const 496 492 { … … 660 656 case TransformSpace::World: 661 657 ogreRelativeTo = Ogre::Node::TS_WORLD; break; 662 default: OrxAssert(false, "Faulty TransformSpace::Enum assigned.");663 658 } 664 659 this->node_->setDirection(direction, ogreRelativeTo, localDirectionVector); … … 760 755 { 761 756 case Dynamic: 762 this->physicalBody_->setCollisionFlags(this->physicalBody_->getCollisionFlags() & ! btCollisionObject::CF_STATIC_OBJECT & !btCollisionObject::CF_KINEMATIC_OBJECT);757 this->physicalBody_->setCollisionFlags(this->physicalBody_->getCollisionFlags() & !(btCollisionObject::CF_STATIC_OBJECT | btCollisionObject::CF_KINEMATIC_OBJECT)); 763 758 break; 764 759 case Kinematic: -
code/branches/questsystem5/src/orxonox/objects/worldentities/WorldEntity.h
r2907 r2908 33 33 #include "OrxonoxPrereqs.h" 34 34 35 #ifdef NDEBUG35 #ifdef _NDEBUG 36 36 #include <OgreSceneNode.h> 37 37 #else … … 176 176 177 177 protected: 178 virtual void parentChanged() {}179 180 178 Ogre::SceneNode* node_; 181 179 … … 193 191 194 192 // network callbacks 195 void networkcallback_parentChanged();193 void parentChanged(); 196 194 inline void scaleChanged() 197 195 { this->setScale3D(this->getScale3D()); } … … 271 269 @brief 272 270 Sets how much reaction is applied in a collision. 273 271 274 272 Consider two equal spheres colliding with equal velocities: 275 273 Restitution 1 means that both spheres simply reverse their velocity (no loss of energy) … … 421 419 422 420 // Inline heavily used functions for release builds. In debug, we better avoid including OgreSceneNode here. 423 #ifdef NDEBUG421 #ifdef _NDEBUG 424 422 inline const Vector3& WorldEntity::getPosition() const 425 423 { return this->node_->getPosition(); } 426 424 inline const Quaternion& WorldEntity::getOrientation() const 427 { return this->node_->get Orientation(); }425 { return this->node_->getrOrientation(); } 428 426 inline const Vector3& WorldEntity::getScale3D(void) const 429 427 { return this->node_->getScale(); } -
code/branches/questsystem5/src/orxonox/objects/worldentities/pawns/Pawn.cc
r2907 r2908 30 30 #include "Pawn.h" 31 31 32 #include "core/ GameMode.h"32 #include "core/Core.h" 33 33 #include "core/CoreIncludes.h" 34 34 #include "core/XMLPort.h" … … 63 63 this->getPickUp().setPlayer(this); 64 64 65 if ( GameMode::isMaster())65 if (Core::isMaster()) 66 66 { 67 67 this->weaponSystem_ = new WeaponSystem(this); … … 133 133 } 134 134 135 void Pawn::setPlayer(PlayerInfo* player)136 {137 ControllableEntity::setPlayer(player);138 139 if (this->getGametype())140 this->getGametype()->playerStartsControllingPawn(player, this);141 }142 143 void Pawn::removePlayer()144 {145 if (this->getGametype())146 this->getGametype()->playerStopsControllingPawn(this->getPlayer(), this);147 148 ControllableEntity::removePlayer();149 }150 151 135 void Pawn::setHealth(float health) 152 136 { … … 156 140 void Pawn::damage(float damage, Pawn* originator) 157 141 { 158 if (this->getGametype() && this->getGametype()->allowPawnDamage(this, originator)) 159 { 160 this->setHealth(this->health_ - damage); 161 this->lastHitOriginator_ = originator; 162 163 // play damage effect 164 } 142 this->setHealth(this->health_ - damage); 143 this->lastHitOriginator_ = originator; 144 145 // play damage effect 165 146 } 166 147 167 148 void Pawn::hit(Pawn* originator, const Vector3& force, float damage) 168 149 { 169 if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator)) 170 { 171 this->damage(damage, originator); 172 this->setVelocity(this->getVelocity() + force); 173 174 // play hit effect 175 } 150 this->damage(damage, originator); 151 this->setVelocity(this->getVelocity() + force); 152 153 // play hit effect 176 154 } 177 155 … … 198 176 void Pawn::death() 199 177 { 200 if (this->getGametype() && this->getGametype()->allowPawnDeath(this, this->lastHitOriginator_)) 201 { 202 // Set bAlive_ to false and wait for PawnManager to do the destruction 203 this->bAlive_ = false; 204 205 this->setDestroyWhenPlayerLeft(false); 206 207 if (this->getGametype()) 208 this->getGametype()->pawnKilled(this, this->lastHitOriginator_); 209 210 if (this->getPlayer()) 211 this->getPlayer()->stopControl(this); 212 213 if (GameMode::isMaster()) 214 this->deatheffect(); 215 } 216 else 217 this->setHealth(1); 178 // Set bAlive_ to false and wait for PawnManager to do the destruction 179 this->bAlive_ = false; 180 181 this->setDestroyWhenPlayerLeft(false); 182 183 if (this->getGametype()) 184 this->getGametype()->pawnKilled(this, this->lastHitOriginator_); 185 186 if (this->getPlayer()) 187 this->getPlayer()->stopControl(this); 188 189 if (Core::isMaster()) 190 this->deatheffect(); 218 191 } 219 192 … … 249 222 ExplosionChunk* chunk = new ExplosionChunk(this->getCreator()); 250 223 chunk->setPosition(this->getPosition()); 224 251 225 } 252 226 } … … 260 234 { 261 235 this->setHealth(this->initialHealth_); 262 if ( GameMode::isMaster())236 if (Core::isMaster()) 263 237 this->spawneffect(); 264 238 } … … 269 243 } 270 244 271 272 /* WeaponSystem:273 * functions load Slot, Set, Pack from XML and make sure all parent-pointers are set.274 * with setWeaponPack you can not just load a Pack from XML but if a Pack already exists anywhere, you can attach it.275 * --> e.g. Pickup-Items276 */277 245 void Pawn::setWeaponSlot(WeaponSlot * wSlot) 278 246 { -
code/branches/questsystem5/src/orxonox/objects/worldentities/pawns/Pawn.h
r2907 r2908 47 47 virtual void tick(float dt); 48 48 void registerVariables(); 49 50 virtual void setPlayer(PlayerInfo* player);51 virtual void removePlayer();52 49 53 50 inline bool isAlive() const -
code/branches/questsystem5/src/orxonox/objects/worldentities/pawns/Spectator.cc
r2907 r2908 34 34 #include "core/CoreIncludes.h" 35 35 #include "core/ConfigValueIncludes.h" 36 #include "core/ GameMode.h"36 #include "core/Core.h" 37 37 #include "objects/worldentities/Model.h" 38 38 #include "objects/Scene.h" … … 63 63 this->setDestroyWhenPlayerLeft(true); 64 64 65 if ( GameMode::showsGraphics())65 if (Core::showsGraphics()) 66 66 { 67 67 this->greetingFlare_ = new BillboardSet(); … … 206 206 this->bGreeting_ = !this->bGreeting_; 207 207 208 if ( GameMode::isMaster())208 if (Core::isMaster()) 209 209 { 210 210 this->bGreetingFlareVisible_ = this->bGreeting_; -
code/branches/questsystem5/src/orxonox/objects/worldentities/triggers/DistanceTrigger.cc
- Property svn:mergeinfo changed
-
code/branches/questsystem5/src/orxonox/objects/worldentities/triggers/DistanceTrigger.h
- Property svn:mergeinfo changed
-
code/branches/questsystem5/src/orxonox/objects/worldentities/triggers/Trigger.cc
- Property svn:mergeinfo changed
r2907 r2908 36 36 #include "core/ConsoleCommand.h" 37 37 #include "core/XMLPort.h" 38 #include "core/ GameMode.h"38 #include "core/Core.h" 39 39 #include "objects/Scene.h" 40 40 … … 67 67 // this->bUpdating_ = false; 68 68 69 if (this->getScene() && GameMode::showsGraphics())69 if (this->getScene() && Core::showsGraphics()) 70 70 { 71 71 this->debugBillboard_.setBillboardSet(this->getScene()->getSceneManager(), "Examples/Flare", ColourValue(1.0, 0.0, 0.0), 1); -
code/branches/questsystem5/src/orxonox/objects/worldentities/triggers/Trigger.h
-
code/branches/questsystem5/src/orxonox/overlays/OrxonoxOverlay.cc
r2907 r2908 39 39 #include <OgreOverlayManager.h> 40 40 #include <OgrePanelOverlayElement.h> 41 #include <OgreRenderWindow.h>42 43 41 #include "util/Convert.h" 44 42 #include "util/Exception.h" 45 43 #include "util/String.h" 46 #include "core/ GameMode.h"44 #include "core/Core.h" 47 45 #include "core/CoreIncludes.h" 48 46 #include "core/XMLPort.h" 49 47 #include "core/ConsoleCommand.h" 50 #include "GraphicsManager.h"51 48 52 49 namespace orxonox … … 67 64 this->group_ = 0; 68 65 69 if (! GameMode::showsGraphics())66 if (!Core::showsGraphics()) 70 67 ThrowException(NoGraphics, "Can't create OrxonoxOverlay, graphics engine not initialized"); 71 68 … … 80 77 this->overlay_->add2D(this->background_); 81 78 82 // Get aspect ratio from the render window. Later on, we get informed automatically83 Ogre::RenderWindow* defaultWindow = GraphicsManager::getInstance().getRenderWindow();84 this->windowAspectRatio_ = (float)defaultWindow->getWidth() / defaultWindow->getHeight();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; 85 82 this->sizeCorrectionChanged(); 86 83 … … 178 175 /** 179 176 @brief 180 Called by the Graphics Managerwhenever the window size changes.177 Called by the GraphicsEngine whenever the window size changes. 181 178 Calculates the aspect ratio only. 182 179 */ 183 void OrxonoxOverlay::windowResized( unsigned int newWidth, unsignedint newHeight)180 void OrxonoxOverlay::windowResized(int newWidth, int newHeight) 184 181 { 185 182 this->windowAspectRatio_ = newWidth/(float)newHeight; -
code/branches/questsystem5/src/orxonox/overlays/OrxonoxOverlay.h
r2907 r2908 154 154 virtual void changedVisibility(); 155 155 156 inline void setOwner( BaseObject* owner)156 inline void setOwner(ControllableEntity* owner) 157 157 { 158 158 if (this->owner_ != owner) … … 162 162 } 163 163 } 164 inline BaseObject* getOwner() const164 inline ControllableEntity* getOwner() const 165 165 { return this->owner_; } 166 166 virtual void changedOwner() {} … … 200 200 201 201 private: 202 void windowResized( unsigned int newWidth, unsignedint newHeight);202 void windowResized(int newWidth, int newHeight); 203 203 204 204 static unsigned int hudOverlayCounter_s; //!< Static counter for hud elements … … 206 206 We could also use the ObjectList, but that doesn't guarantee XMLPort(.) was called and is slower. */ 207 207 static std::map<std::string, OrxonoxOverlay*> overlays_s; 208 BaseObject* owner_;208 ControllableEntity* owner_; 209 209 OverlayGroup* group_; 210 210 }; -
code/branches/questsystem5/src/orxonox/overlays/OverlayGroup.cc
r2907 r2908 63 63 OverlayGroup::~OverlayGroup() 64 64 { 65 for (std:: set<OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)66 delete (*it);65 for (std::map<std::string, OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it) 66 delete it->second; 67 67 } 68 68 … … 83 83 } 84 84 85 //! Scales every element in the set.85 //! Scales every element in the map. 86 86 void OverlayGroup::setScale(const Vector2& scale) 87 87 { 88 for (std:: set<OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)89 (*it) ->scale(scale / this->scale_);88 for (std::map<std::string, OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it) 89 (*it).second->scale(scale / this->scale_); 90 90 this->scale_ = scale; 91 91 } 92 92 93 //! Scrolls every element in the set.93 //! Scrolls every element in the map. 94 94 void OverlayGroup::setScroll(const Vector2& scroll) 95 95 { 96 for (std:: set<OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)97 (*it) ->scroll(scroll - this->scroll_);96 for (std::map<std::string, OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it) 97 (*it).second->scroll(scroll - this->scroll_); 98 98 this->scroll_ = scroll; 99 99 } … … 101 101 /** 102 102 @brief 103 Adds an element to the set(used when loading with XMLPort).103 Adds an element to the map (used when loading with XMLPort). 104 104 @remarks 105 105 The names of the OrxonoxOverlays have to be unique! … … 107 107 void OverlayGroup::addElement(OrxonoxOverlay* element) 108 108 { 109 hudElements_.insert(element); 110 element->setVisible(this->isVisible()); 111 if (this->owner_) 112 element->setOwner(this->owner_); 113 } 114 115 /** 109 this->insertElement(element, element->getName()); 110 } 111 112 /** 113 @brief 114 Adds an element to the map. 115 @param element 116 The element to be added. 117 @param name 118 The name of the element. 119 @remarks 120 The names of the OrxonoxOverlays have to be unique! 121 */ 122 void OverlayGroup::insertElement(OrxonoxOverlay* element, const std::string & name) 123 { 124 element->setName(name); 125 if (hudElements_.find(name) != hudElements_.end()) 126 { 127 COUT(1) << "Ambiguous names encountered while load the HUD overlays" << std::endl; 128 } 129 else 130 { 131 hudElements_[name] = element; 132 element->setVisible(this->isVisible()); 133 if (this->owner_) 134 element->setOwner(this->owner_); 135 } 136 } 137 138 /** 116 139 @brief 117 140 Removes an element from the map. 118 @param element119 The element that is to beremoved.141 @param name 142 The name of the element that is removed. 120 143 @return 121 144 Returns true if there was such an element to remove, false if not. 122 145 */ 123 bool OverlayGroup::removeElement( OrxonoxOverlay* element)124 { 125 if(this->hudElements_.erase( element) == 0)146 bool OverlayGroup::removeElement(const std::string & name) 147 { 148 if(this->hudElements_.erase(name) == 0) 126 149 return false; 127 150 return true; … … 133 156 if (index < this->hudElements_.size()) 134 157 { 135 std:: set<OrxonoxOverlay*>::const_iterator it = hudElements_.begin();158 std::map<std::string, OrxonoxOverlay*>::const_iterator it = hudElements_.begin(); 136 159 for (unsigned int i = 0; i != index; ++it, ++i) 137 160 ; 138 return (*it) ;161 return (*it).second; 139 162 } 140 163 else … … 145 168 void OverlayGroup::changedVisibility() 146 169 { 147 for (std:: set<OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)148 (*it) ->setVisible(this->isVisible());149 } 150 151 void OverlayGroup::setOwner( BaseObject* owner)170 for (std::map<std::string, OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it) 171 (*it).second->setVisible(this->isVisible()); 172 } 173 174 void OverlayGroup::setOwner(ControllableEntity* owner) 152 175 { 153 176 this->owner_ = owner; 154 177 155 for (std:: set<OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)156 (*it) ->setOwner(owner);178 for (std::map<std::string, OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it) 179 (*it).second->setOwner(owner); 157 180 } 158 181 -
code/branches/questsystem5/src/orxonox/overlays/OverlayGroup.h
r2907 r2908 37 37 #include "OrxonoxPrereqs.h" 38 38 39 #include <set> 40 #include <string> 39 #include <map> 41 40 #include <OgrePrerequisites.h> 42 41 #include "core/BaseObject.h" … … 65 64 static void scrollGroup(const std::string& name, const Vector2& scroll); 66 65 67 inline const std:: set<OrxonoxOverlay*>& getOverlays() const66 inline const std::map<std::string, OrxonoxOverlay*>& getOverlays() const 68 67 { return this->hudElements_; } 69 68 70 69 void changedVisibility(); 71 70 72 void setOwner( BaseObject* owner);73 inline BaseObject* getOwner() const71 void setOwner(ControllableEntity* owner); 72 inline ControllableEntity* getOwner() const 74 73 { return this->owner_; } 75 74 … … 87 86 88 87 void addElement(OrxonoxOverlay* element); 89 bool removeElement(OrxonoxOverlay* element); 88 void insertElement(OrxonoxOverlay* element, const std::string & name); 89 bool removeElement(const std::string & name); 90 90 OrxonoxOverlay* getElement(unsigned int index); 91 91 92 92 private: 93 std:: set<OrxonoxOverlay*> hudElements_; //!< Contains all the OrxonoxOverlays of the this group.94 Vector2 scale_; //!< Current scale (independent of the elements).95 Vector2 scroll_; //!< Current scrolling offset.96 BaseObject* owner_;//!< The owner of this OverlayGroup93 std::map<std::string, OrxonoxOverlay*> hudElements_; //!< Contains all the OrxonoxOverlays of the this group. 94 Vector2 scale_; //!< Current scale (independent of the elements). 95 Vector2 scroll_; //!< Current scrolling offset. 96 ControllableEntity* owner_; //!< The owner of this OverlayGroup 97 97 }; 98 98 } -
code/branches/questsystem5/src/orxonox/overlays/console/InGameConsole.cc
r2907 r2908 42 42 #include "util/Convert.h" 43 43 #include "util/Debug.h" 44 #include "core/Clock.h"45 44 #include "core/CoreIncludes.h" 46 45 #include "core/ConfigValueIncludes.h" … … 173 172 { 174 173 // create the corresponding input state 175 inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("console", false, false, InputStatePriority::Console);174 inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("console", 40); 176 175 inputState_->setKeyHandler(Shell::getInstance().getInputBuffer()); 177 176 bHidesAllInputChanged(); … … 348 347 @brief Used to control the actual scrolling and the cursor. 349 348 */ 350 void InGameConsole:: update(const Clock& time)349 void InGameConsole::tick(float dt) 351 350 { 352 351 if (this->scroll_ != 0) … … 359 358 // enlarge oldTop a little bit so that this exponential function 360 359 // reaches 0 before infinite time has passed... 361 float deltaScroll = (oldTop - 0.01) * time.getDeltaTime()* this->scrollSpeed_;360 float deltaScroll = (oldTop - 0.01) * dt * this->scrollSpeed_; 362 361 if (oldTop - deltaScroll >= 0) 363 362 { … … 374 373 // scrolling up 375 374 // note: +0.01 for the same reason as when scrolling down 376 float deltaScroll = (1.2 * this->relativeHeight + 0.01 + oldTop) * time.getDeltaTime()* this->scrollSpeed_;375 float deltaScroll = (1.2 * this->relativeHeight + 0.01 + oldTop) * dt * this->scrollSpeed_; 377 376 if (oldTop - deltaScroll <= -1.2 * this->relativeHeight) 378 377 { … … 389 388 if (this->bActive_) 390 389 { 391 this->cursor_ += time.getDeltaTime();390 this->cursor_ += dt; 392 391 if (this->cursor_ >= this->blinkTime) 393 392 { … … 410 409 @brief Resizes the console elements. Call if window size changes. 411 410 */ 412 void InGameConsole::windowResized( unsigned int newWidth, unsignedint newHeight)411 void InGameConsole::windowResized(int newWidth, int newHeight) 413 412 { 414 413 this->windowW_ = newWidth; -
code/branches/questsystem5/src/orxonox/overlays/console/InGameConsole.h
r2907 r2908 53 53 void setConfigValues(); 54 54 55 v oid update(const Clock& time);55 virtual void tick(float dt); 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( unsigned int newWidth, unsignedint newHeight);83 void windowResized(int newWidth, int newHeight); 84 84 85 85 // config value related -
code/branches/questsystem5/src/orxonox/overlays/debug/DebugFPSText.cc
r2907 r2908 30 30 #include "DebugFPSText.h" 31 31 #include <OgreTextAreaOverlayElement.h> 32 #include "core/CoreIncludes.h" 33 #include "GraphicsEngine.h" 32 34 #include "util/Convert.h" 33 #include "core/CoreIncludes.h"34 #include "core/Game.h"35 35 36 36 namespace orxonox … … 51 51 SUPER(DebugFPSText, tick, dt); 52 52 53 float fps = G ame::getInstance().getAvgFPS();53 float fps = GraphicsEngine::getInstance().getAverageFramesPerSecond(); 54 54 this->setCaption(convertToString(fps)); 55 55 } -
code/branches/questsystem5/src/orxonox/overlays/debug/DebugRTRText.cc
r2907 r2908 32 32 #include "core/CoreIncludes.h" 33 33 #include "util/Convert.h" 34 #include " core/Game.h"34 #include "GraphicsEngine.h" 35 35 36 36 namespace orxonox … … 51 51 SUPER(DebugRTRText, tick, dt); 52 52 53 float rtr = G ame::getInstance().getAvgTickTime();53 float rtr = GraphicsEngine::getInstance().getAverageTickTime(); 54 54 this->setCaption(convertToString(rtr)); 55 55 } -
code/branches/questsystem5/src/orxonox/overlays/hud/CMakeLists.txt
r2907 r2908 7 7 ChatOverlay.cc 8 8 GametypeStatus.cc 9 PongScore.cc10 9 ) -
code/branches/questsystem5/src/orxonox/overlays/hud/HUDRadar.cc
r2907 r2908 94 94 void HUDRadar::displayObject(RadarViewable* object, bool bIsMarked) 95 95 { 96 if (object == static_cast<RadarViewable*>(this->owner_))96 if (object == (RadarViewable*)this->owner_) 97 97 return; 98 98 -
code/branches/questsystem5/src/orxonox/overlays/notifications/NotificationQueue.cc
r2907 r2908 410 410 this->containers_.insert(container); 411 411 this->overlays_[notification] = container; 412 this-> addElement(container->overlay);412 this->insertElement(container->overlay, container->name); 413 413 this->size_= this->size_+1; 414 414 … … 429 429 return false; 430 430 431 this->removeElement(container-> overlay);431 this->removeElement(container->name); 432 432 this->containers_.erase(container); 433 433 this->overlays_.erase(container->notification); -
code/branches/questsystem5/src/orxonox/pch/havepch/OrxonoxStableHeaders.h
r2907 r2908 45 45 # define WIN32_LEAN_AND_MEAN 46 46 #endif 47 #ifndef NOMINMAX 48 # define NOMINMAX // required to stop windows.h screwing up std::min definition 49 #endif 47 #define NOMINMAX // required to stop windows.h screwing up std::min definition 50 48 #include <Ogre.h> 51 49 #include <CEGUI.h> -
code/branches/questsystem5/src/orxonox/tools/BillboardSet.cc
r2907 r2908 37 37 #include <OgreBillboard.h> 38 38 39 #include "core/ GameMode.h"39 #include "core/Core.h" 40 40 #include "util/Convert.h" 41 41 #include "util/String.h" … … 72 72 try 73 73 { 74 if ( GameMode::showsGraphics())74 if (Core::showsGraphics()) 75 75 { 76 76 this->billboardSet_ = scenemanager->createBillboardSet("Billboard" + convertToString(BillboardSet::billboardSetCounter_s++), count); … … 95 95 try 96 96 { 97 if ( GameMode::showsGraphics())97 if (Core::showsGraphics()) 98 98 { 99 99 this->billboardSet_ = scenemanager->createBillboardSet("Billboard" + convertToString(BillboardSet::billboardSetCounter_s++), count); -
code/branches/questsystem5/src/orxonox/tools/CMakeLists.txt
r2907 r2908 5 5 Shader.cc 6 6 TextureGenerator.cc 7 TimeFactorListener.cc8 7 Timer.cc 9 8 WindowEventListener.cc -
code/branches/questsystem5/src/orxonox/tools/Mesh.cc
r2907 r2908 35 35 #include <cassert> 36 36 37 #include "core/ GameMode.h"37 #include "core/Core.h" 38 38 #include "util/Convert.h" 39 39 #include "util/String.h" … … 64 64 this->scenemanager_->destroyEntity(this->entity_); 65 65 66 if ( GameMode::showsGraphics())66 if (Core::showsGraphics()) 67 67 { 68 68 try … … 70 70 this->entity_ = this->scenemanager_->createEntity("Mesh" + convertToString(Mesh::meshCounter_s++), meshsource); 71 71 this->entity_->setCastShadows(this->bCastShadows_); 72 73 this->entity_->setNormaliseNormals(true);74 /*75 Excerpt from Ogre forum:76 "Note that the above is only for the fixed function pipeline.77 If/when you get into shaders, you'll need to manually normalize() the normal inside the vertex or pixel shader."78 79 I don't know exactly what this means, but I put this here if there will be problems with shaders.80 */81 72 } 82 73 catch (...) -
code/branches/questsystem5/src/orxonox/tools/ParticleInterface.cc
r2907 r2908 40 40 #include <cassert> 41 41 42 #include "Graphics Manager.h"43 #include "core/ GameMode.h"42 #include "GraphicsEngine.h" 43 #include "core/Core.h" 44 44 #include "core/CoreIncludes.h" 45 45 #include "util/Convert.h" … … 64 64 this->speedFactor_ = 1.0f; 65 65 66 if ( GameMode::showsGraphics())66 if (Core::showsGraphics()) 67 67 { 68 68 try … … 178 178 { 179 179 this->detaillevel_ = level; 180 if (G ameMode::showsGraphics())181 this->detailLevelChanged(Graphics Manager::getInstance().getDetailLevelParticle());180 if (GraphicsEngine::getInstancePtr()) 181 this->detailLevelChanged(GraphicsEngine::getInstance().getDetailLevelParticle()); 182 182 } 183 183 -
code/branches/questsystem5/src/orxonox/tools/ParticleInterface.h
r2907 r2908 37 37 #include "core/OrxonoxClass.h" 38 38 #include "util/Math.h" 39 #include " tools/TimeFactorListener.h"39 #include "gamestates/GSRoot.h" 40 40 41 41 #define getAllEmitters() \ -
code/branches/questsystem5/src/orxonox/tools/Shader.cc
r2907 r2908 36 36 #include <OgrePlugin.h> 37 37 38 #include "core/ GameMode.h"38 #include "core/Core.h" 39 39 #include "core/CoreIncludes.h" 40 40 #include "core/Executor.h" 41 #include "Graphics Manager.h"41 #include "GraphicsEngine.h" 42 42 #include "util/Exception.h" 43 43 … … 59 59 this->compositorInstance_ = 0; 60 60 this->bVisible_ = true; 61 this->bLoadCompositor_ = GameMode::showsGraphics();61 this->bLoadCompositor_ = Core::showsGraphics() && GraphicsEngine::getInstancePtr(); 62 62 this->bViewportInitialized_ = false; 63 63 this->compositor_ = ""; … … 86 86 if (this->bLoadCompositor_ && this->compositorInstance_) 87 87 { 88 Ogre::Viewport* viewport = Graphics Manager::getInstance().getViewport();88 Ogre::Viewport* viewport = GraphicsEngine::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 Manager::getInstance().getViewport();116 Ogre::Viewport* viewport = GraphicsEngine::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 (! GameMode::showsGraphics() || !Shader::bLoadedCgPlugin_s)248 if (!Core::showsGraphics() || !Shader::bLoadedCgPlugin_s) 249 249 return 0; 250 250 -
code/branches/questsystem5/src/orxonox/tools/Timer.h
r2907 r2908 64 64 #include "core/Executor.h" 65 65 #include "core/OrxonoxClass.h" 66 #include " tools/TimeFactorListener.h"66 #include "gamestates/GSRoot.h" 67 67 68 68 namespace orxonox -
code/branches/questsystem5/src/orxonox/tools/WindowEventListener.h
r2907 r2908 49 49 50 50 /** Window has resized */ 51 virtual void windowResized( unsigned int newWidth, unsignedint newHeight) { }51 virtual void windowResized(int newWidth, int newHeight) { } 52 52 53 53 /** Window has lost/gained focus */
Note: See TracChangeset
for help on using the changeset viewer.