Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 8, 2009, 12:58:47 AM (15 years ago)
Author:
dafrick
Message:

Reverted to revision 2906 (because I'm too stupid to merge correctly, 2nd try will follow shortly. ;))

Location:
code/branches/questsystem5
Files:
4 added
30 deleted
151 edited

Legend:

Unmodified
Added
Removed
  • code/branches/questsystem5

  • code/branches/questsystem5/src/orxonox/CMakeLists.txt

    r2907 r2908  
    2020SET_SOURCE_FILES(ORXONOX_SRC_FILES
    2121  CameraManager.cc
    22   GraphicsManager.cc
     22  GraphicsEngine.cc
    2323  LevelManager.cc
    2424  Main.cc
  • code/branches/questsystem5/src/orxonox/CameraManager.cc

    r2907 r2908  
    3535#include <OgreResource.h>
    3636
    37 #include "core/GameMode.h"
     37#include "core/Core.h"
    3838#include "core/Iterator.h"
    3939#include "objects/worldentities/Camera.h"
     
    4141#include "tools/Shader.h"
    4242#include "util/String.h"
    43 #include "gui/GUIManager.h"
    4443
    4544namespace orxonox
     
    7574    void CameraManager::requestFocus(Camera* camera)
    7675    {
    77         if (!GameMode::showsGraphics())
     76        if (!Core::showsGraphics())
    7877            return;
    7978
     
    10099    void CameraManager::releaseFocus(Camera* camera)
    101100    {
    102         if (!GameMode::showsGraphics())
     101        if (!Core::showsGraphics())
    103102            return;
    104103
     
    142141
    143142        this->viewport_->setCamera(camera);
    144         GUIManager::getInstance().setCamera(camera);
    145143
    146144        // reactivate all visible compositors
  • code/branches/questsystem5/src/orxonox/CameraManager.h

  • code/branches/questsystem5/src/orxonox/Main.cc

    r2907 r2908  
    2727 *
    2828 */
    29  
    30  /**
    31  @mainpage Orxonox Documentation
    32  */
    3329
    3430 /**
     
    3834
    3935#include "OrxonoxStableHeaders.h"
     36
     37#include <exception>
     38#include <cassert>
     39
    4040#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"
    4149
    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"
    4558
    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
     87SetCommandLineArgument(settingsFile, "orxonox.ini");
     88SetCommandLineArgument(configFileDirectory, "");
     89
    5090int main(int argc, char** argv)
    5191{
     92    using namespace orxonox;
     93
     94    // Parse command line arguments
     95    try
    5296    {
    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    }
    54104
    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();
    69107
    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;
    72149
    73150    // 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();
    76156
    77157    return 0;
  • code/branches/questsystem5/src/orxonox/OrxonoxPrereqs.h

    r2907 r2908  
    7777    namespace MunitionType
    7878    {
     79
     80
     81
    7982        enum Enum
    8083        { laserGunMunition };
     
    9497
    9598
    96     class GraphicsManager;
    97     class OgreWindowEventListener;
     99    class GraphicsEngine;
    98100    class Settings;
    99101
     
    101103    class Radar;
    102104    class RadarListener;
    103 
    104     class Teamcolourable;
    105105
    106106    class CameraManager;
     
    150150    class ParticleSpawner;
    151151
    152     class PongCenterpoint;
    153     class PongBall;
    154     class PongBat;
    155 
    156152    class Camera;
    157153    class CameraPosition;
    158154    class SpawnPoint;
    159     class TeamSpawnPoint;
    160155
    161156    class Spectator;
     
    181176    class LaserGun;
    182177    class LaserGunMunition;
    183     class FusionMunition;
    184178
    185179    class EventListener;
     
    192186    class AIController;
    193187    class ScriptController;
    194     class PongAI;
    195188
    196189    class Info;
     
    198191    class HumanPlayer;
    199192    class Bot;
    200     class PongBot;
    201193    class GametypeInfo;
    202194
    203195    class Gametype;
    204     class Deathmatch;
    205     class TeamDeathmatch;
    206     class Pong;
    207196
    208197    class Scores;
     
    250239    //gui
    251240    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;
    252252}
    253253
  • code/branches/questsystem5/src/orxonox/PlayerManager.cc

    r2907 r2908  
    3131
    3232#include "LevelManager.h"
    33 #include "core/GameMode.h"
     33#include "core/Core.h"
    3434#include "core/CoreIncludes.h"
    3535#include "objects/Level.h"
     
    5858    void PlayerManager::clientConnected(unsigned int clientID)
    5959    {
    60         if (GameMode::isMaster())
     60        if (Core::isMaster())
    6161        {
    6262            COUT(3) << "client connected" << std::endl;
     
    7777    void PlayerManager::clientDisconnected(unsigned int clientID)
    7878    {
    79         if (GameMode::isMaster())
     79        if (Core::isMaster())
    8080        {
    8181            COUT(3) << "client disconnected" << std::endl;
     
    9797    PlayerInfo* PlayerManager::getClient(unsigned int clientID) const
    9898    {
    99         if (GameMode::isMaster())
     99        if (Core::isMaster())
    100100        {
    101101            std::map<unsigned int, PlayerInfo*>::const_iterator it = this->clients_.find(clientID);
  • code/branches/questsystem5/src/orxonox/gamestates/CMakeLists.txt

    r2907 r2908  
    11ADD_SOURCE_FILES(ORXONOX_SRC_FILES
     2  GSDedicated.cc
    23  GSClient.cc
    3   GSDedicated.cc
    44  GSGraphics.cc
     5  GSGUI.cc
    56  GSIOConsole.cc
    67  GSLevel.cc
    7   GSMainMenu.cc
    88  GSRoot.cc
    99  GSServer.cc
  • code/branches/questsystem5/src/orxonox/gamestates/GSClient.cc

    r2907 r2908  
    3131
    3232#include "core/input/InputManager.h"
    33 #include "core/Clock.h"
    3433#include "core/CommandLine.h"
    35 #include "core/Game.h"
    36 #include "core/GameMode.h"
     34#include "core/Core.h"
    3735#include "network/Client.h"
    3836
    3937namespace orxonox
    4038{
    41     AddGameState(GSClient, "client");
    42 
    4339    SetCommandLineArgument(ip, "127.0.0.1").information("#.#.#.#");
    4440
    45     GSClient::GSClient(const std::string& name)
    46         : GameState(name)
     41    GSClient::GSClient()
     42        : GameState<GSGraphics>("client")
    4743        , client_(0)
    4844    {
     
    5349    }
    5450
    55     void GSClient::activate()
     51    void GSClient::enter()
    5652    {
    57         GameMode::setIsClient(true);
     53        Core::setIsClient(true);
    5854
    5955        this->client_ = new Client(CommandLine::getValue("ip").getString(), CommandLine::getValue("port"));
     
    6258            ThrowException(InitialisationFailed, "Could not establish connection with server.");
    6359
    64         client_->update(Game::getInstance().getGameClock());
     60        GSLevel::enter(this->getParent()->getViewport());
     61
     62        client_->tick(0);
    6563    }
    6664
    67     void GSClient::deactivate()
     65    void GSClient::leave()
    6866    {
     67        GSLevel::leave();
     68
    6969        client_->closeConnection();
    7070
     
    7272        delete this->client_;
    7373
    74         GameMode::setIsClient(false);
     74        Core::setIsClient(false);
    7575    }
    7676
    77     void GSClient::update(const Clock& time)
     77    void GSClient::ticked(const Clock& time)
    7878    {
    79         client_->update(time);
     79        GSLevel::ticked(time);
     80        client_->tick(time.getDeltaTime());
     81
     82        this->tickChild(time);
    8083    }
    8184}
  • code/branches/questsystem5/src/orxonox/gamestates/GSClient.h

    r2907 r2908  
    3131
    3232#include "OrxonoxPrereqs.h"
    33 #include "core/GameState.h"
    3433#include "network/NetworkPrereqs.h"
     34#include "GSLevel.h"
     35#include "GSGraphics.h"
    3536
    3637namespace orxonox
    3738{
    38     class _OrxonoxExport GSClient : public GameState
     39    class _OrxonoxExport GSClient : public GameState<GSGraphics>, public GSLevel
    3940    {
    4041    public:
    41         GSClient(const std::string& name);
     42        GSClient();
    4243        ~GSClient();
    4344
    44         void activate();
    45         void deactivate();
    46         void update(const Clock& time);
    4745
    4846    private:
     47        void enter();
     48        void leave();
     49        void ticked(const Clock& time);
     50
    4951        Client* client_;
    5052    };
  • code/branches/questsystem5/src/orxonox/gamestates/GSDedicated.cc

    r2907 r2908  
    3030#include "GSDedicated.h"
    3131
    32 #include "core/Clock.h"
    3332#include "core/CommandLine.h"
    34 #include "core/Game.h"
    35 #include "core/GameMode.h"
     33#include "core/Core.h"
    3634#include "core/Iterator.h"
    3735#include "network/Server.h"
     
    4139namespace orxonox
    4240{
    43     AddGameState(GSDedicated, "dedicated");
    44 
    45     GSDedicated::GSDedicated(const std::string& name)
    46         : GameState(name)
     41    GSDedicated::GSDedicated()
     42        : GameState<GSRoot>("dedicated")
    4743        , server_(0)
    4844        , timeSinceLastUpdate_(0)
     
    5450    }
    5551
    56     void GSDedicated::activate()
     52    void GSDedicated::enter()
    5753    {
    58         GameMode::setHasServer(true);
     54        Core::setHasServer(true);
    5955
    6056        this->server_ = new Server(CommandLine::getValue("port"));
    6157        COUT(0) << "Loading scene in server mode" << std::endl;
    6258
     59        GSLevel::enter(0);
     60
    6361        server_->open();
    6462    }
    6563
    66     void GSDedicated::deactivate()
     64    void GSDedicated::leave()
    6765    {
     66        GSLevel::leave();
     67
    6868        this->server_->close();
    6969        delete this->server_;
    7070
    71         GameMode::setHasServer(false);
     71        Core::setHasServer(false);
    7272    }
    7373
    74     void GSDedicated::update(const Clock& time)
     74    void GSDedicated::ticked(const Clock& time)
    7575    {
    7676//        static float startTime = time.getSecondsPrecise();
     
    8282//            COUT(0) << "estimated ticks/sec: " << nrOfTicks/(time.getSecondsPrecise()-startTime) << endl;
    8383            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);
    8587        }
    8688        else
  • code/branches/questsystem5/src/orxonox/gamestates/GSDedicated.h

    r2907 r2908  
    3131
    3232#include "OrxonoxPrereqs.h"
    33 #include "core/GameState.h"
    3433#include "network/NetworkPrereqs.h"
     34#include "GSLevel.h"
     35#include "GSRoot.h"
    3536
    3637namespace orxonox
    3738{
    38     class _OrxonoxExport GSDedicated : public GameState
     39    class _OrxonoxExport GSDedicated : public GameState<GSRoot>, public GSLevel
    3940    {
    4041    public:
    41         GSDedicated(const std::string& name);
     42        GSDedicated();
    4243        ~GSDedicated();
    4344
    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);
    4749
    48     private:
    49         Server* server_;
    50         float   timeSinceLastUpdate_;
     50        Server*      server_;
     51        float        timeSinceLastUpdate_;
    5152    };
    5253}
  • code/branches/questsystem5/src/orxonox/gamestates/GSGraphics.cc

    r2907 r2908  
    2323 *      Reto Grieder
    2424 *   Co-authors:
    25  *      Benjamin Knecht
    26  *
    27  */
    28 
    29 /**
    30     @file
    31     @brief Implementation of Graphics GameState class.
     25 *      ...
     26 *
    3227 */
    3328
     
    3530#include "GSGraphics.h"
    3631
     32#include <fstream>
    3733#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>
    3841#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"
    4048#include "util/Debug.h"
     49#include "util/Exception.h"
     50#include "util/String.h"
     51#include "util/SubString.h"
     52#include "core/ConsoleCommand.h"
    4153#include "core/ConfigValueIncludes.h"
    42 #include "core/Clock.h"
    43 #include "core/ConsoleCommand.h"
     54#include "core/CoreIncludes.h"
    4455#include "core/Core.h"
    45 #include "core/CoreIncludes.h"
    46 #include "core/Game.h"
    47 #include "core/GameMode.h"
    4856#include "core/input/InputManager.h"
    4957#include "core/input/KeyBinder.h"
    50 #include "core/input/SimpleInputState.h"
     58#include "core/input/ExtendedInputState.h"
    5159#include "core/Loader.h"
    5260#include "core/XMLFile.h"
    5361#include "overlays/console/InGameConsole.h"
    5462#include "gui/GUIManager.h"
    55 #include "GraphicsManager.h"
     63#include "tools/WindowEventListener.h"
     64
     65// for compatibility
     66#include "GraphicsEngine.h"
    5667
    5768namespace orxonox
    5869{
    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)
    6375        , inputManager_(0)
    6476        , console_(0)
    6577        , guiManager_(0)
    66         , graphicsManager_(0)
     78        , ogreRoot_(0)
     79        , ogreLogger_(0)
     80        , graphicsEngine_(0)
    6781        , masterKeyBinder_(0)
    68         , masterInputState_(0)
    6982        , debugOverlay_(0)
    7083    {
    7184        RegisterRootObject(GSGraphics);
     85        setConfigValues();
    7286    }
    7387
     
    7690    }
    7791
    78     /**
    79     @brief
    80         this function does nothing
    81 
    82         Indeed. Here goes nothing.
    83     */
    8492    void GSGraphics::setConfigValues()
    8593    {
    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);
    111135
    112136        // load debug overlay
     
    115139        Loader::open(debugOverlay_);
    116140
     141        // Calls the InputManager which sets up the input devices.
    117142        // The render window width and height are used to set up the mouse movement.
     143        inputManager_ = new InputManager();
    118144        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
    128148        masterKeyBinder_ = new KeyBinder();
    129149        masterKeyBinder_->loadBindings("masterKeybindings.ini");
    130         masterInputState_->setKeyHandler(masterKeyBinder_);
     150        inputManager_->getMasterInputState()->addKeyHandler(masterKeyBinder_);
    131151
    132152        // Load the InGameConsole
    133153        console_ = new InGameConsole();
    134         console_->initialise(renderWindow->getWidth(), renderWindow->getHeight());
     154        console_->initialise(this->renderWindow_->getWidth(), this->renderWindow_->getHeight());
    135155
    136156        // load the CEGUI interface
    137157        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_);
    167181        delete this->masterKeyBinder_;
    168 
    169         delete this->guiManager_;
    170         delete this->console_;
     182        delete this->inputManager_;
    171183
    172184        Loader::unload(this->debugOverlay_);
    173185        delete this->debugOverlay_;
    174186
    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);
    193219    }
    194220
     
    201227        need the time. So we shouldn't run into problems.
    202228    */
    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    {
    212231        uint64_t timeBeforeTick = time.getRealMicroseconds();
    213232
    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        }
    217246
    218247        uint64_t timeAfterTick = time.getRealMicroseconds();
    219248
    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();
    225484    }
    226485
     
    231490        The render window it occured in
    232491    @note
    233         GraphicsManager has a render window stored itself. This is the same
     492        GraphicsEngine has a render window stored itself. This is the same
    234493        as rw. But we have to be careful when using multiple render windows!
    235494    */
    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
    238500        // OIS needs this under linux even if we only use relative input measurement.
    239501        if (this->inputManager_)
    240             this->inputManager_->setWindowExtents(newWidth, newHeight);
     502            this->inputManager_->setWindowExtents(renderWindow_->getWidth(), renderWindow_->getHeight());
    241503    }
    242504
     
    247509        The render window it occured in
    248510    */
    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
    251516        // instruct InputManager to clear the buffers (core library so we cannot use the interface)
    252517        if (this->inputManager_)
     
    254519    }
    255520
     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    }
    256539}
  • code/branches/questsystem5/src/orxonox/gamestates/GSGraphics.h

    r2907 r2908  
    2323 *      Reto Grieder
    2424 *   Co-authors:
    25  *      Benjamin Knecht (documentation)
     25 *      ...
    2626 *
    2727 */
    28 
    29  /**
    30     @file
    31     @brief Declaration of the Graphics GameState class.
    32   */
    3328
    3429#ifndef _GSGraphics_H__
     
    3631
    3732#include "OrxonoxPrereqs.h"
     33#include <OgrePrerequisites.h>
     34#define NOMINMAX // required to stop windows.h screwing up std::min definition
     35#include <OgreWindowEventUtilities.h>
    3836#include "core/GameState.h"
    39 #include "tools/WindowEventListener.h"
     37#include "core/OrxonoxClass.h"
     38#include "GSRoot.h"
    4039
    4140namespace orxonox
    4241{
    43     /**
    44     @class GSGraphics
    45     @brief
    46         Game state used when displaying graphics of any kind
     42    class _OrxonoxExport GSGraphics : public GameState<GSRoot>, public OrxonoxClass,
     43                                      public Ogre::WindowEventListener, public Ogre::LogListener
     44    {
     45        friend class ClassIdentifier<GSGraphics>;
    4746
    48         This game state is only left out if we start a dedicated server where no graphics are present.
    49     */
    50     class _OrxonoxExport GSGraphics : public GameState, public WindowEventListener
    51     {
    5247    public:
    53         GSGraphics(const std::string& name);
     48        GSGraphics();
    5449        ~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
    5560        void setConfigValues();
    5661
    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();
    6067
    61         void toggleGUI();
     68        // console commands
     69        void printScreen();
    6270
    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.
    6787
    6888        // managed singletons
    69         InputManager*         inputManager_;        //!< Reference to input management
     89        InputManager*         inputManager_;
    7090        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
    7395
    74         KeyBinder*            masterKeyBinder_;     //!< Key binder for master key bindings
    75         SimpleInputState*     masterInputState_;    //!< Special input state for master input
     96        KeyBinder*            masterKeyBinder_;
    7697        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_;
    78111    };
    79112}
  • code/branches/questsystem5/src/orxonox/gamestates/GSIOConsole.cc

    r2907 r2908  
    3636
    3737#include "core/ConsoleCommand.h"
    38 #include "core/Game.h"
    3938
    4039namespace orxonox
    4140{
    42     AddGameState(GSIOConsole, "ioConsole");
    43 
    44     GSIOConsole::GSIOConsole(const std::string& name)
    45         : GameState(name)
     41    GSIOConsole::GSIOConsole()
     42        : GameState<GSRoot>("ioConsole")
    4643    {
    4744    }
     
    5148    }
    5249
    53     void GSIOConsole::activate()
     50    void GSIOConsole::enter()
    5451    {
    55         {
    56             FunctorMember<GSIOConsole>* functor = createFunctor(&GSIOConsole::loadMenu);
    57             functor->setObject(this);
    58             this->ccLoadMenu_ = createConsoleCommand(functor, "loadMenu");
    59             CommandExecutor::addConsoleCommandShortcut(this->ccLoadMenu_);
    60         }
    6152    }
    6253
    63     void GSIOConsole::deactivate()
     54    void GSIOConsole::leave()
    6455    {
    65         if (this->ccLoadMenu_)
    66         {
    67             delete this->ccLoadMenu_;
    68             this->ccLoadMenu_ = 0;
    69         }
    7056    }
    7157
    72     void GSIOConsole::update(const Clock& time)
     58    void GSIOConsole::ticked(const Clock& time)
    7359    {
    74         std::cout << ">";
    7560        std::string command;
    7661        std::getline(std::cin, command);
    7762        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);
    8465    }
    8566}
  • code/branches/questsystem5/src/orxonox/gamestates/GSIOConsole.h

    r2907 r2908  
    3131
    3232#include "OrxonoxPrereqs.h"
     33#include <OgrePrerequisites.h>
    3334#include "core/GameState.h"
     35#include "GSRoot.h"
    3436
    3537namespace orxonox
    3638{
    37     class _OrxonoxExport GSIOConsole : public GameState
     39    class _OrxonoxExport GSIOConsole : public GameState<GSRoot>
    3840    {
    3941    public:
    40         GSIOConsole(const std::string& name);
     42        GSIOConsole();
    4143        ~GSIOConsole();
    4244
    43         void activate();
    44         void deactivate();
    45         void update(const Clock& time);
    46 
    4745    private:
    48         void loadMenu();
    49 
    50         // console commands
    51         ConsoleCommand* ccLoadMenu_;
     46        void enter();
     47        void leave();
     48        void ticked(const Clock& time);
    5249    };
    5350}
  • code/branches/questsystem5/src/orxonox/gamestates/GSLevel.cc

    r2907 r2908  
    2424 *   Co-authors:
    2525 *      Fabian 'x3n' Landau
    26  *      Benjamin Knecht
    2726 *
    2827 */
     
    4039#include "core/CommandLine.h"
    4140#include "core/ConfigValueIncludes.h"
     41#include "core/CoreIncludes.h"
    4242#include "core/Core.h"
    43 #include "core/CoreIncludes.h"
    44 #include "core/Game.h"
    45 #include "core/GameMode.h"
    4643#include "objects/Tickable.h"
    4744#include "objects/Radar.h"
    4845#include "CameraManager.h"
    49 #include "GraphicsManager.h"
    5046#include "LevelManager.h"
    5147#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"
    5550
    5651namespace orxonox
    5752{
    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)
    6959        , radar_(0)
    7060        , startFile_(0)
     
    7666        this->ccKeybind_ = 0;
    7767        this->ccTkeybind_ = 0;
     68
     69        setConfigValues();
    7870    }
    7971
     
    8779    }
    8880
    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);
    9686            keyBinder_ = new KeyBinder();
    9787            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_);
    10589
    10690            // create the global CameraManager
    107             this->cameraManager_ = new CameraManager(GraphicsManager::getInstance().getViewport());
     91            assert(viewport);
     92            this->cameraManager_ = new CameraManager(viewport);
    10893
    10994            // Start the Radar
     
    117102        this->notificationManager_ = new NotificationManager();
    118103
    119         if (GameMode::isMaster())
     104        if (Core::isMaster())
    120105        {
    121106            // create the global LevelManager
     
    125110        }
    126111
    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
    129117            // keybind console command
    130118            FunctorMember<GSLevel>* functor1 = createFunctor(&GSLevel::keybind);
     
    144132    }
    145133
    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()
    163135    {
    164136        // destroy console commands
     
    173145            this->ccTkeybind_ = 0;
    174146        }
    175 
    176147
    177148        // this call will delete every BaseObject!
     
    181152        //Loader::close();
    182153
    183         if (GameMode::showsGraphics())
     154        if (Core::showsGraphics())
    184155            InputManager::getInstance().requestLeaveState("game");
    185156
    186         if (GameMode::isMaster())
     157        if (Core::isMaster())
    187158            this->unloadLevel();
    188159
     
    223194        }
    224195
    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);
    230199            InputManager::getInstance().requestDestroyState("game");
    231200            if (this->keyBinder_)
     
    237206    }
    238207
    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.
    242211        //// Call the scene objects
    243212        //for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it)
     
    282251        Command string that can be executed by the CommandExecutor
    283252        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().
    285254    */
    286255    void GSLevel::keybindInternal(const std::string& command, bool bTemporary)
    287256    {
    288         if (GameMode::showsGraphics())
     257        if (Core::showsGraphics())
    289258        {
    290259            static std::string bindingString = "";
  • code/branches/questsystem5/src/orxonox/gamestates/GSLevel.h

    r2907 r2908  
    2323 *      Reto Grieder
    2424 *   Co-authors:
    25  *      Benjamin Knecht
     25 *      ...
    2626 *
    2727 */
     
    3131
    3232#include "OrxonoxPrereqs.h"
     33#include <OgrePrerequisites.h>
    3334#include "core/OrxonoxClass.h"
    34 #include "core/GameState.h"
    3535
    3636namespace orxonox
    3737{
    38     class _OrxonoxExport GSLevel : public GameState, public OrxonoxClass
     38    class _OrxonoxExport GSLevel : public OrxonoxClass
    3939    {
     40        friend class ClassIdentifier<GSLevel>;
    4041    public:
    41         GSLevel(const std::string& name);
     42        GSLevel();
    4243        ~GSLevel();
    43         void setConfigValues();
    44 
    45         void activate();
    46         void deactivate();
    47         void update(const Clock& time);
    48 
    49         static void showIngameGUI(bool show);
    5044
    5145    protected:
     46        void enter(Ogre::Viewport* viewport);
     47        void leave();
     48        void ticked(const Clock& time);
     49
    5250        void loadLevel();
    5351        void unloadLevel();
     
    5856        void keybindInternal(const std::string& command, bool bTemporary);
    5957
    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_;
    7167
    7268        //##### ConfigValues #####
     
    7672        ConsoleCommand*       ccKeybind_;
    7773        ConsoleCommand*       ccTkeybind_;
     74
     75    private:
     76        void setConfigValues();
     77
    7878    };
    7979}
  • code/branches/questsystem5/src/orxonox/gamestates/GSRoot.cc

    r2907 r2908  
    3232#include "util/Exception.h"
    3333#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"
    3739#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"
    4044#include "tools/Timer.h"
    4145#include "objects/Tickable.h"
    4246
     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
    4355namespace orxonox
    4456{
    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")
    5561        , timeFactor_(1.0f)
    5662        , bPaused_(false)
    5763        , timeFactorPauseBackup_(1.0f)
    58     {
     64        , tclBind_(0)
     65        , tclThreadManager_(0)
     66        , shell_(0)
     67    {
     68        RegisterRootObject(GSRoot);
     69        setConfigValues();
     70
    5971        this->ccSetTimeFactor_ = 0;
    6072        this->ccPause_ = 0;
     
    6577    }
    6678
    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
    6992        // 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        }
    71134
    72135        {
     
    85148            CommandExecutor::addConsoleCommandShortcut(this->ccPause_).accessLevel(AccessLevel::Offline);
    86149        }
    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
    121164        if (this->ccSetTimeFactor_)
    122165        {
     
    132175    }
    133176
    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    {
    143179        uint64_t timeBeforeTick = time.getRealMicroseconds();
     180
     181        TclThreadManager::getInstance().tick(time.getDeltaTime());
    144182
    145183        for (ObjectList<TimerBase>::iterator it = ObjectList<TimerBase>::begin(); it; ++it)
     
    160198        uint64_t timeAfterTick = time.getRealMicroseconds();
    161199
    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
    164275    }
    165276
     
    170281    void GSRoot::setTimeFactor(float factor)
    171282    {
    172         if (GameMode::isMaster())
     283        if (Core::isMaster())
    173284        {
    174285            if (!this->bPaused_)
     
    188299    void GSRoot::pause()
    189300    {
    190         if (GameMode::isMaster())
     301        if (Core::isMaster())
    191302        {
    192303            if (!this->bPaused_)
     
    203314        }
    204315    }
     316
     317    ////////////////////////
     318    // TimeFactorListener //
     319    ////////////////////////
     320    float TimeFactorListener::timefactor_s = 1.0f;
     321
     322    TimeFactorListener::TimeFactorListener()
     323    {
     324        RegisterRootObject(TimeFactorListener);
     325    }
    205326}
  • code/branches/questsystem5/src/orxonox/gamestates/GSRoot.h

    r2907 r2908  
    3131
    3232#include "OrxonoxPrereqs.h"
    33 #include "core/GameState.h"
     33
     34#include <list>
     35#include <OgreLog.h>
     36#include "core/RootGameState.h"
    3437#include "core/OrxonoxClass.h"
    3538
    3639namespace orxonox
    3740{
    38     class _OrxonoxExport GSRoot : public GameState
     41    class _OrxonoxExport GSRoot : public RootGameState, public OrxonoxClass
    3942    {
     43        friend class ClassIdentifier<GSRoot>;
     44
    4045    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();
    4254        ~GSRoot();
    4355
    44         void activate();
    45         void deactivate();
    46         void update(const Clock& time);
     56        void exitGame()
     57        { requestState("root"); }
    4758
    4859        // this has to be public because proteced triggers a bug in msvc
     
    5263        float getTimeFactor() { return this->timeFactor_; }
    5364
     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
    5472    private:
     73        void enter();
     74        void leave();
     75        void ticked(const Clock& time);
     76
     77        void setConfigValues();
     78        void setThreadAffinity(unsigned int limitToCPU);
     79
    5580        float                 timeFactor_;       //!< A factor that sets the gamespeed. 1 is normal.
    5681        bool                  bPaused_;
    5782        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_;
    5899
    59100        // console commands
     101        ConsoleCommand*       ccExit_;
     102        ConsoleCommand*       ccSelectGameState_;
    60103        ConsoleCommand*       ccSetTimeFactor_;
    61104        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;
    62122    };
    63123}
  • code/branches/questsystem5/src/orxonox/gamestates/GSServer.cc

    r2907 r2908  
    3131
    3232#include "core/CommandLine.h"
    33 #include "core/Game.h"
    34 #include "core/GameMode.h"
     33#include "core/Core.h"
    3534#include "network/Server.h"
    3635
    3736namespace orxonox
    3837{
    39     AddGameState(GSServer, "server");
    40 
    4138    SetCommandLineArgument(port, 55556).shortcut("p").information("0-65535");
    4239
    43     GSServer::GSServer(const std::string& name)
    44         : GameState(name)
     40    GSServer::GSServer()
     41        : GameState<GSGraphics>("server")
    4542        , server_(0)
    4643    {
     
    5148    }
    5249
    53     void GSServer::activate()
     50    void GSServer::enter()
    5451    {
    55         GameMode::setHasServer(true);
     52        Core::setHasServer(true);
    5653
    5754        this->server_ = new Server(CommandLine::getValue("port"));
    5855        COUT(0) << "Loading scene in server mode" << std::endl;
    5956
     57        GSLevel::enter(this->getParent()->getViewport());
     58
    6059        server_->open();
    6160    }
    6261
    63     void GSServer::deactivate()
     62    void GSServer::leave()
    6463    {
     64        GSLevel::leave();
     65
    6566        this->server_->close();
    6667        delete this->server_;
    6768
    68         GameMode::setHasServer(false);
     69        Core::setHasServer(false);
    6970    }
    7071
    71     void GSServer::update(const Clock& time)
     72    void GSServer::ticked(const Clock& time)
    7273    {
    73         server_->update(time);
     74        GSLevel::ticked(time);
     75        server_->tick(time.getDeltaTime());
     76        this->tickChild(time);
    7477    }
    7578}
  • code/branches/questsystem5/src/orxonox/gamestates/GSServer.h

    r2907 r2908  
    3131
    3232#include "OrxonoxPrereqs.h"
    33 #include "core/GameState.h"
    3433#include "network/NetworkPrereqs.h"
     34#include "GSLevel.h"
     35#include "GSGraphics.h"
    3536
    3637namespace orxonox
    3738{
    38     class _OrxonoxExport GSServer : public GameState
     39    class _OrxonoxExport GSServer : public GameState<GSGraphics>, public GSLevel
    3940    {
    4041    public:
    41         GSServer(const std::string& name);
     42        GSServer();
    4243        ~GSServer();
    4344
    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);
    4749
    48     private:
    49         Server* server_;
     50        Server*      server_;
    5051    };
    5152}
  • code/branches/questsystem5/src/orxonox/gamestates/GSStandalone.cc

    r2907 r2908  
    3030#include "GSStandalone.h"
    3131
    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"
    3933
    4034namespace orxonox
    4135{
    42     AddGameState(GSStandalone, "standalone");
    43 
    44     GSStandalone::GSStandalone(const std::string& name)
    45         : GameState(name)
     36    GSStandalone::GSStandalone()
     37        : GameState<GSGraphics>("standalone")
    4638    {
    4739    }
     
    5143    }
    5244
     45    void GSStandalone::enter()
     46    {
     47        Core::setIsStandalone(true);
    5348
    54     void GSStandalone::activate()
    55     {
    56         GameMode::setIsStandalone(true);
     49        GSLevel::enter(this->getParent()->getViewport());
    5750    }
    5851
    59     void GSStandalone::deactivate()
     52    void GSStandalone::leave()
    6053    {
    61         GameMode::setIsStandalone(false);
     54        GSLevel::leave();
     55
     56        Core::setIsStandalone(false);
    6257    }
    6358
    64     void GSStandalone::update(const Clock& time)
     59    void GSStandalone::ticked(const Clock& time)
    6560    {
     61        GSLevel::ticked(time);
     62        this->tickChild(time);
    6663    }
    6764}
  • code/branches/questsystem5/src/orxonox/gamestates/GSStandalone.h

    r2907 r2908  
    3131
    3232#include "OrxonoxPrereqs.h"
    33 #include "core/GameState.h"
     33#include "GSLevel.h"
     34#include "GSGraphics.h"
    3435
    3536namespace orxonox
    3637{
    37     class _OrxonoxExport GSStandalone : public GameState
     38    class _OrxonoxExport GSStandalone : public GameState<GSGraphics>, public GSLevel
    3839    {
    3940    public:
    40         GSStandalone(const std::string& name);
     41        GSStandalone();
    4142        ~GSStandalone();
    4243
    43         void activate();
    44         void deactivate();
    45         void update(const Clock& time);
    46 
    4744    private:
     45        void enter();
     46        void leave();
     47        void ticked(const Clock& time);
    4848    };
    4949}
  • code/branches/questsystem5/src/orxonox/gui/GUIManager.cc

    r2907 r2908  
    2222 *   Author:
    2323 *      Reto Grieder
    24  *      Benjamin Knecht
    2524 *   Co-authors:
    26  *
     25 *      ...
    2726 *
    2827 */
     
    3736#include "GUIManager.h"
    3837
    39 #include <boost/filesystem/path.hpp>
     38#include <boost/filesystem.hpp>
    4039#include <OgreRenderWindow.h>
     40#include <OgreRoot.h>
    4141#include <CEGUI.h>
    4242#include <CEGUIDefaultLogger.h>
     
    5050
    5151#include "util/Exception.h"
     52#include "core/input/InputManager.h"
     53#include "core/input/SimpleInputState.h"
    5254#include "core/ConsoleCommand.h"
    5355#include "core/Core.h"
    54 #include "core/Clock.h"
    5556#include "ToluaBindCore.h"
    5657#include "ToluaBindOrxonox.h"
     
    6263namespace orxonox
    6364{
     65    SetConsoleCommandShortcut(GUIManager, showGUI_s).keybindMode(KeybindMode::OnPress);
     66
    6467    GUIManager* GUIManager::singletonRef_s = 0;
    6568
    6669    GUIManager::GUIManager()
    67         : renderWindow_(0)
     70        //: emptySceneManager_(0)
     71        : backgroundSceneManager_(0)
     72        //, emptyCamera_(0)
     73        , backgroundCamera_(0)
     74        //, viewport_(0)
     75        , renderWindow_(0)
    6876        , guiRenderer_(0)
    6977        , resourceProvider_(0)
     
    7684    }
    7785
    78     /**
    79     @brief
    80         Deconstructor of the GUIManager
    81 
    82         Basically shuts down CEGUI and destroys the Lua engine and afterwards the interface to the Ogre engine.
    83     */
    8486    GUIManager::~GUIManager()
    8587    {
     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
    86102        if (guiSystem_)
    87103            delete guiSystem_;
     
    94110                lua_pushnil(luaState_);
    95111                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..
    96116            delete scriptModule_;
    97117        }
     
    103123    }
    104124
    105     /**
    106     @brief
    107         Initialises the GUIManager by starting up CEGUI
    108     @param renderWindow
    109         Ogre's render window. Without this, the GUI cannot be displayed.
    110     @return true if success, otherwise false
    111 
    112         Before this call the GUIManager won't do anything, but can be accessed.
    113 
    114         Creates the interface to Ogre, sets up the CEGUI renderer and the Lua script module together with the Lua engine.
    115         The log is set up and connected to the CEGUILogger.
    116         After Lua setup tolua++-elements are linked to Lua-state to give Lua access to C++-code.
    117         Finally initial Lua code is executed (maybe we can do this with the CEGUI startup script automatically).
    118     */
    119125    bool GUIManager::initialise(Ogre::RenderWindow* renderWindow)
    120126    {
     
    129135                renderWindow_ = renderWindow;
    130136
     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
    131144                // 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);
    133146                this->resourceProvider_ = guiRenderer_->createResourceProvider();
    134147                this->resourceProvider_->setDefaultResourceGroup("GUI");
     
    153166                tolua_Orxonox_open(this->scriptModule_->getLuaState());
    154167
    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
    157177            }
    158178            catch (CEGUI::Exception& ex)
     
    172192    }
    173193
    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
    187218        try
    188219        {
    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");
    194221        }
    195222        catch (CEGUI::Exception& ex)
     
    204231    }
    205232
    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)
    267234    {
    268235        if (state_ != Uninitialised)
    269236        {
    270             //COUT(3) << "Loading GUI " << name << std::endl;
     237            if (state_ == OnDisplay)
     238                hideGUI();
     239
     240            COUT(3) << "Loading GUI " << name << std::endl;
    271241            try
    272242            {
    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;
    274268            }
    275269            catch (CEGUI::Exception& ex)
     
    288282    }
    289283
    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
    299294    void GUIManager::mouseButtonPressed(MouseButtonCode::ByEnum id)
    300295    {
     
    310305    }
    311306
    312     /**
    313     @brief
    314         Function receiving a mouse button released event.
    315     @param id
    316         ID of the mouse button which got released
    317 
    318         This function is inherited by MouseHandler and injects the event into CEGUI.
    319         It is for CEGUI to process the event.
    320     */
    321307    void GUIManager::mouseButtonReleased(MouseButtonCode::ByEnum id)
    322308    {
     
    332318    }
    333319
    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
    344321    inline CEGUI::MouseButton GUIManager::convertButton(MouseButtonCode::ByEnum button)
    345322    {
  • code/branches/questsystem5/src/orxonox/gui/GUIManager.h

    r2907 r2908  
    2323 *      Reto Grieder
    2424 *   Co-authors:
    25  *      Benjamin Knecht
     25 *      ...
    2626 *
    2727 */
     
    4949{
    5050    /**
    51     @class GUIManager
    5251    @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
    6053    */
    6154    class _OrxonoxExport GUIManager
     
    6659// tolua_end
    6760    public:
    68         /**
    69         @enum State
    70             The current state of the GUIManager. There should maybe be more (or we can omit this totally).
    71         */
    7261        enum State
    7362        {
    74             Uninitialised,  //!< Initial state of the GUIManager
    75             Ready,          //!< State after initialisation if ready
    76             OnDisplay       //!< State if GUI is displayed
     63            Uninitialised,
     64            Ready,
     65            OnDisplay
    7766        };
    7867
     
    8170
    8271        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
    8379
    84         void update(const Clock& time);
     80        Ogre::Camera* getCamera() { return this->backgroundCamera_; }
    8581
    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        }
    9086
    9187        static GUIManager& getInstance()    { assert(singletonRef_s); return *singletonRef_s; } // tolua_export
     
    9389
    9490    private:
    95         GUIManager(const GUIManager& instance);                 //!< private constructor (this is a singleton class)
     91        GUIManager(const GUIManager& instance);
    9692
    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        { }
    9899
    99         // keyHandler functions
    100         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 functions
    107100        void mouseButtonPressed (MouseButtonCode::ByEnum id);
    108101        void mouseButtonReleased(MouseButtonCode::ByEnum id);
    109         void mouseButtonHeld    (MouseButtonCode::ByEnum id) { }
     102        void mouseButtonHeld    (MouseButtonCode::ByEnum id)
     103        { }
    110104        void mouseMoved         (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize)
    111             { guiSystem_->injectMouseMove(rel.x, rel.y); }
     105        { guiSystem_->injectMouseMove(rel.x, rel.y); }
    112106        void mouseScrolled      (int abs, int rel)
    113             { guiSystem_->injectMouseWheelChange(rel);}
     107        { guiSystem_->injectMouseWheelChange(rel);}
    114108
    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_;
    118130
    119131        static CEGUI::MouseButton convertButton(MouseButtonCode::ByEnum button);
    120132
    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;
    132134    }; // tolua_export
    133135} // tolua_export
  • code/branches/questsystem5/src/orxonox/objects/CMakeLists.txt

    r2907 r2908  
    88  RadarListener.cc
    99  RadarViewable.cc
    10   Teamcolourable.cc
    1110  Tickable.cc
    1211  Test.cc
  • code/branches/questsystem5/src/orxonox/objects/EventTarget.cc

    r2907 r2908  
    6666    void EventTarget::addAsEvent(BaseObject* object)
    6767    {
    68         if (object != static_cast<BaseObject*>(this))
     68        if (object != (BaseObject*)this)
    6969            object->addEvent(this, "");
    7070    }
  • code/branches/questsystem5/src/orxonox/objects/Level.cc

    r2907 r2908  
    105105    {
    106106        Identifier* identifier = ClassByString(gametype);
    107 
    108         if (!identifier || !identifier->isA(Class(Gametype)))
     107        if (identifier && identifier->isA(Class(Gametype)))
    109108        {
    110             COUT(0) << "Error: \"" << gametype << "\" is not a valid gametype." << std::endl;
    111             identifier = Class(Gametype);
    112             this->gametype_ = "Gametype";
    113         }
    114         else
    115109            this->gametype_ = gametype;
    116110
    117 std::cout << "Load Gametype: " << this->gametype_ << std::endl;
     111            Gametype* rootgametype = dynamic_cast<Gametype*>(identifier->fabricate(this));
     112            this->setGametype(rootgametype);
    118113
    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);
    121116
    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        }
    129120    }
    130121
  • code/branches/questsystem5/src/orxonox/objects/Level.h

  • code/branches/questsystem5/src/orxonox/objects/Radar.cc

    r2907 r2908  
    144144            for (ObjectList<RadarViewable>::iterator it = ObjectList<RadarViewable>::begin(); it; ++it)
    145145            {
    146                 if (*it == static_cast<RadarViewable*>(this)->owner_)
     146                if (*it == (RadarViewable*)this->owner_)
    147147                    continue;
    148148
  • code/branches/questsystem5/src/orxonox/objects/Scene.cc

    r2907 r2908  
    4141
    4242#include "core/CoreIncludes.h"
    43 #include "core/GameMode.h"
     43#include "core/Core.h"
    4444#include "core/XMLPort.h"
    4545#include "tools/BulletConversions.h"
     
    5757        this->bShadows_ = true;
    5858
    59         if (GameMode::showsGraphics())
     59        if (Core::showsGraphics())
    6060        {
    6161            if (Ogre::Root::getSingletonPtr())
     
    9999                Ogre::Root::getSingleton().destroySceneManager(this->sceneManager_);
    100100            }
    101             else if (!GameMode::showsGraphics())
     101            else if (!Core::showsGraphics())
    102102            {
    103103                delete this->sceneManager_;
     
    227227    void Scene::tick(float dt)
    228228    {
    229         if (!GameMode::showsGraphics())
     229        if (!Core::showsGraphics())
    230230        {
    231231            // We need to update the scene nodes if we don't render
     
    256256    void Scene::setSkybox(const std::string& skybox)
    257257    {
    258         if (GameMode::showsGraphics() && this->sceneManager_)
     258        if (Core::showsGraphics() && this->sceneManager_)
    259259            this->sceneManager_->setSkyBox(true, skybox);
    260260
     
    264264    void Scene::setAmbientLight(const ColourValue& colour)
    265265    {
    266         if (GameMode::showsGraphics() && this->sceneManager_)
     266        if (Core::showsGraphics() && this->sceneManager_)
    267267            this->sceneManager_->setAmbientLight(colour);
    268268
     
    272272    void Scene::setShadow(bool bShadow)
    273273    {
    274         if (GameMode::showsGraphics() && this->sceneManager_)
     274        if (Core::showsGraphics() && this->sceneManager_)
    275275        {
    276276            if (bShadow)
  • code/branches/questsystem5/src/orxonox/objects/collisionshapes

  • code/branches/questsystem5/src/orxonox/objects/controllers/AIController.cc

    r2907 r2908  
    3030#include "AIController.h"
    3131
    32 #include "core/GameMode.h"
     32#include "core/Core.h"
    3333#include "core/CoreIncludes.h"
    3434#include "core/Executor.h"
     
    4545        RegisterObject(AIController);
    4646
    47         if (GameMode::isMaster())
     47        if (Core::isMaster())
    4848            this->actionTimer_.setTimer(ACTION_INTERVAL, true, this, createExecutor(createFunctor(&AIController::action)));
    4949    }
  • code/branches/questsystem5/src/orxonox/objects/controllers/CMakeLists.txt

    r2907 r2908  
    55  AIController.cc
    66  ScriptController.cc
    7   PongAI.cc
    87)
  • code/branches/questsystem5/src/orxonox/objects/controllers/Controller.cc

    r2907 r2908  
    4343        this->player_ = 0;
    4444        this->controllableEntity_ = 0;
     45        this->hud_ = 0;
     46        this->bUpdateHUD_ = false;
    4547    }
    4648
    4749    Controller::~Controller()
    4850    {
     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        }
    4981    }
    5082}
  • code/branches/questsystem5/src/orxonox/objects/controllers/Controller.h

    r2907 r2908  
    5757            inline ControllableEntity* getControllableEntity() const
    5858                { 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_; }
    6077
    6178        protected:
     79            void updateHUD();
     80
    6281            PlayerInfo* player_;
    6382            ControllableEntity* controllableEntity_;
     83            std::string hudtemplate_;
     84            OverlayGroup* hud_;
     85            bool bUpdateHUD_;
    6486    };
    6587}
  • code/branches/questsystem5/src/orxonox/objects/controllers/HumanController.cc

    r2907 r2908  
    3535#include "objects/worldentities/pawns/Pawn.h"
    3636#include "objects/gametypes/Gametype.h"
    37 #include "objects/infos/PlayerInfo.h"
    3837
    3938namespace orxonox
     
    158157            if (pawn)
    159158                pawn->kill();
    160             else if (HumanController::localController_s->player_)
    161                 HumanController::localController_s->player_->stopControl(HumanController::localController_s->controllableEntity_);
    162159        }
    163160    }
  • code/branches/questsystem5/src/orxonox/objects/gametypes/CMakeLists.txt

    r2907 r2908  
    11ADD_SOURCE_FILES(ORXONOX_SRC_FILES
    22  Gametype.cc
    3   Deathmatch.cc
    4   TeamDeathmatch.cc
    5   Pong.cc
    63)
  • code/branches/questsystem5/src/orxonox/objects/gametypes/Gametype.cc

    r2907 r2908  
    3636#include "core/ConfigValueIncludes.h"
    3737#include "core/Template.h"
    38 #include "core/GameMode.h"
     38#include "core/Core.h"
    3939#include "overlays/OverlayGroup.h"
    4040#include "objects/infos/PlayerInfo.h"
     
    4444#include "objects/worldentities/Camera.h"
    4545
     46#include "network/Host.h"
     47
    4648namespace orxonox
    4749{
     
    6466        this->setConfigValues();
    6567
     68        this->addBots(this->numberOfBots_);
     69
    6670        // load the corresponding score board
    67         if (GameMode::showsGraphics() && this->scoreboardTemplate_ != "")
     71        if (Core::showsGraphics() && this->scoreboardTemplate_ != "")
    6872        {
    6973            this->scoreboard_ = new OverlayGroup(this);
     
    101105    void Gametype::start()
    102106    {
    103         this->addBots(this->numberOfBots_);
    104 
     107        COUT(0) << "game started" << std::endl;
    105108        this->gtinfo_.bStarted_ = true;
    106109
     
    110113    void Gametype::end()
    111114    {
     115        COUT(0) << "game ended" << std::endl;
    112116        this->gtinfo_.bEnded_ = true;
    113117    }
     
    116120    {
    117121        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)
    121129    {
    122130        std::map<PlayerInfo*, Player>::iterator it = this->players_.find(player);
     
    124132        {
    125133            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        }
    129139    }
    130140
     
    137147    }
    138148
    139     bool Gametype::playerChangedName(PlayerInfo* player)
     149    void Gametype::playerChangedName(PlayerInfo* player)
    140150    {
    141151        if (this->players_.find(player) != this->players_.end())
     
    143153            if (player->getName() != player->getOldName())
    144154            {
    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        }
    149160    }
    150161
     
    157168    }
    158169
    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 
    190170    void Gametype::pawnKilled(Pawn* victim, Pawn* killer)
    191171    {
     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
    192189        if (victim && victim->getPlayer())
    193190        {
     
    201198                if (killer)
    202199                {
    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;
    206207                }
    207208
     
    224225    }
    225226
    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_++;
    240230    }
    241231
     
    346336        if (spawnpoint)
    347337        {
    348             this->playerPreSpawn(player);
    349338            player->startControl(spawnpoint->spawn());
    350339            this->players_[player].state_ = PlayerState::Alive;
    351             this->playerPostSpawn(player);
    352340        }
    353341        else
     
    361349    {
    362350        for (unsigned int i = 0; i < amount; ++i)
    363             this->botclass_.fabricate(this);
     351            new Bot(this);
    364352    }
    365353
  • code/branches/questsystem5/src/orxonox/objects/gametypes/Gametype.h

    r2907 r2908  
    8484            virtual void end();
    8585            virtual void playerEntered(PlayerInfo* player);
    86             virtual bool playerLeft(PlayerInfo* player);
     86            virtual void playerLeft(PlayerInfo* player);
    8787            virtual void playerSwitched(PlayerInfo* player, Gametype* newgametype);
    8888            virtual void playerSwitchedBack(PlayerInfo* player, Gametype* oldgametype);
    89             virtual bool playerChangedName(PlayerInfo* player);
     89            virtual void playerChangedName(PlayerInfo* player);
    9090
    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);
    9692
    9793            virtual void pawnKilled(Pawn* victim, Pawn* killer = 0);
    9894            virtual void pawnPreSpawn(Pawn* pawn);
    9995            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);
    10596
    10697            inline const std::map<PlayerInfo*, Player>& getPlayers() const
    10798                { return this->players_; }
    108 
    109             int getScore(PlayerInfo* player) const;
    11099
    111100            inline void registerSpawnPoint(SpawnPoint* spawnpoint)
     
    117106                { return this->gtinfo_.startCountdown_; }
    118107
    119             inline void setHUDTemplate(const std::string& name)
    120                 { this->gtinfo_.hudtemplate_ = name; }
    121             inline const std::string& getHUDTemplate() const
    122                 { return this->gtinfo_.hudtemplate_; }
    123 
    124108            void addBots(unsigned int amount);
    125109            void killBots(unsigned int amount = 0);
     
    128112                { return this->players_.size(); }
    129113
    130         protected:
     114        private:
    131115            virtual SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const;
    132116
    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();
    138125
    139126            GametypeInfo gtinfo_;
     
    144131            float initialStartCountdown_;
    145132            unsigned int numberOfBots_;
    146             SubclassIdentifier<Bot> botclass_;
    147133
    148134            std::map<PlayerInfo*, Player> players_;
  • code/branches/questsystem5/src/orxonox/objects/infos/Bot.cc

    r2907 r2908  
    3030#include "Bot.h"
    3131
    32 #include "core/GameMode.h"
     32#include "core/Core.h"
    3333#include "core/CoreIncludes.h"
    3434#include "core/ConfigValueIncludes.h"
     
    4646
    4747        this->bHumanPlayer_ = false;
    48         this->bLocalPlayer_ = GameMode::isMaster();
     48        this->bLocalPlayer_ = Core::isMaster();
    4949        this->bSetUnreadyAfterSpawn_ = false;
    5050        this->setReadyToSpawn(true);
  • code/branches/questsystem5/src/orxonox/objects/infos/CMakeLists.txt

    r2907 r2908  
    11ADD_SOURCE_FILES(ORXONOX_SRC_FILES
    22  Bot.cc
    3   PongBot.cc
    43  Info.cc
    54  PlayerInfo.cc
  • code/branches/questsystem5/src/orxonox/objects/infos/GametypeInfo.cc

    r2907 r2908  
    5858        registerVariable(this->startCountdown_,         variableDirection::toclient);
    5959        registerVariable(this->bStartCountdownRunning_, variableDirection::toclient);
    60         registerVariable(this->hudtemplate_,            variableDirection::toclient);
    6160    }
    6261}
  • code/branches/questsystem5/src/orxonox/objects/infos/GametypeInfo.h

    r2907 r2908  
    5656                { return this->startCountdown_; }
    5757
    58             inline const std::string& getHUDTemplate() const
    59                 { return this->hudtemplate_; }
    60 
    6158        private:
    6259            bool bStarted_;
     
    6461            bool bStartCountdownRunning_;
    6562            float startCountdown_;
    66             std::string hudtemplate_;
    6763    };
    6864}
  • code/branches/questsystem5/src/orxonox/objects/infos/HumanPlayer.cc

    r2907 r2908  
    3030#include "HumanPlayer.h"
    3131
    32 #include "core/GameMode.h"
     32#include "core/Core.h"
    3333#include "core/CoreIncludes.h"
    3434#include "core/ConfigValueIncludes.h"
     
    4747        RegisterObject(HumanPlayer);
    4848
    49         this->server_initialized_ = GameMode::isMaster();
     49        this->server_initialized_ = Core::isMaster();
    5050        this->client_initialized_ = false;
    5151
    5252        this->bHumanPlayer_ = true;
    5353        this->defaultController_ = Class(HumanController);
    54 
    55         this->humanHud_ = 0;
    56         this->gametypeHud_ = 0;
    5754
    5855        this->setConfigValues();
     
    6259    HumanPlayer::~HumanPlayer()
    6360    {
    64         if (this->BaseObject::isInitialized())
    65         {
    66             if (this->humanHud_)
    67                 delete this->humanHud_;
    68 
    69             if (this->gametypeHud_)
    70                 delete this->gametypeHud_;
    71         }
    7261    }
    7362
     
    9382            this->synchronize_nick_ = this->nick_;
    9483
    95             if (GameMode::isMaster())
     84            if (Core::isMaster())
    9685                this->setName(this->nick_);
    9786        }
     
    10089    void HumanPlayer::configvaluecallback_changedHUDTemplate()
    10190    {
    102         this->setHumanHUDTemplate(this->hudtemplate_);
     91        this->changedController();
    10392    }
    10493
     
    116105            this->client_initialized_ = true;
    117106
    118             if (!GameMode::isMaster())
     107            if (!Core::isMaster())
    119108                this->setObjectMode(objectDirection::bidirectional);
    120109            else
     
    122111
    123112            this->createController();
    124             this->updateHumanHUD();
    125113        }
    126114    }
     
    158146    }
    159147
    160     void HumanPlayer::changedGametype()
     148    void HumanPlayer::changedController()
    161149    {
    162         PlayerInfo::changedGametype();
     150        if (this->getController())
     151        {
     152            this->getController()->setHUDTemplate(this->hudtemplate_);
    163153
    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());
    206156        }
    207157    }
  • code/branches/questsystem5/src/orxonox/objects/infos/HumanPlayer.h

    r2907 r2908  
    5151            void setClientID(unsigned int clientID);
    5252
    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();
    8154
    8255        protected:
     
    8861            void networkcallback_client_initialized();
    8962
    90             void updateHumanHUD();
    91             void updateGametypeHUD();
    92 
    9363            std::string nick_;
    9464            std::string synchronize_nick_;
     
    9666            bool server_initialized_;
    9767            bool client_initialized_;
    98 
    99             std::string humanHudTemplate_;
    100             OverlayGroup* humanHud_;
    101             std::string gametypeHudTemplate_;
    102             OverlayGroup* gametypeHud_;
    10368    };
    10469}
  • code/branches/questsystem5/src/orxonox/objects/infos/PlayerInfo.cc

    r2907 r2908  
    110110    void PlayerInfo::createController()
    111111    {
    112         if (this->controller_)
    113         {
    114             delete this->controller_;
    115             this->controller_ = 0;
    116         }
    117112        this->controller_ = this->defaultController_.fabricate(this);
    118113        assert(this->controller_);
     
    146141        if (this->controller_)
    147142            this->controller_->setControllableEntity(entity);
    148 
    149         this->changedControllableEntity();
    150143    }
    151144
     
    162155            if (callback)
    163156                entity->removePlayer();
    164 
    165             this->changedControllableEntity();
    166157        }
    167158    }
  • code/branches/questsystem5/src/orxonox/objects/infos/PlayerInfo.h

    r2907 r2908  
    4949            virtual void changedGametype();
    5050
    51             virtual void changedController() {}
    52             virtual void changedControllableEntity() {}
    53 
    5451            inline bool isHumanPlayer() const
    5552                { return this->bHumanPlayer_; }
     
    7673            inline Controller* getController() const
    7774                { return this->controller_; }
     75            virtual void changedController() {}
    7876
    7977        protected:
  • code/branches/questsystem5/src/orxonox/objects/items/MultiStateEngine.cc

    r2907 r2908  
    3030#include "MultiStateEngine.h"
    3131
    32 #include "core/GameMode.h"
     32#include "core/Core.h"
    3333#include "core/CoreIncludes.h"
    3434#include "core/XMLPort.h"
     
    123123            }
    124124
    125             if (GameMode::isMaster())
     125            if (Core::isMaster())
    126126            {
    127127                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  
    8989                ExecutorMember<BaseObject>* executor = createExecutor(createFunctor(&BaseObject::setActive));
    9090                executor->setDefaultValues(true);
    91                 RespawnTimer_.setTimer(this->respawntimer_, false, this, executor);
     91                RespawnTimer_.setTimer(this->respawntimer_, false, (BaseObject*)this, executor);
    9292                COUT(0) << "TIMER SET" << std::endl;
    9393        }
  • code/branches/questsystem5/src/orxonox/objects/pickup/Usable.h

  • code/branches/questsystem5/src/orxonox/objects/quest/AddQuest.cc

    r2907 r2908  
    4242#include "orxonox/objects/infos/PlayerInfo.h"
    4343#include "QuestManager.h"
    44 #include "QuestDescription.h"
     44#include "QuestDescription.h";
    4545#include "Quest.h"
    4646
  • code/branches/questsystem5/src/orxonox/objects/quest/AddQuest.h

  • code/branches/questsystem5/src/orxonox/objects/quest/AddQuestHint.cc

  • code/branches/questsystem5/src/orxonox/objects/quest/AddQuestHint.h

  • code/branches/questsystem5/src/orxonox/objects/quest/AddReward.cc

  • code/branches/questsystem5/src/orxonox/objects/quest/AddReward.h

  • 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

  • code/branches/questsystem5/src/orxonox/objects/quest/CompleteQuest.h

  • code/branches/questsystem5/src/orxonox/objects/quest/FailQuest.cc

  • code/branches/questsystem5/src/orxonox/objects/quest/FailQuest.h

  • code/branches/questsystem5/src/orxonox/objects/quest/GlobalQuest.cc

  • code/branches/questsystem5/src/orxonox/objects/quest/GlobalQuest.h

  • code/branches/questsystem5/src/orxonox/objects/quest/LocalQuest.cc

  • code/branches/questsystem5/src/orxonox/objects/quest/LocalQuest.h

  • code/branches/questsystem5/src/orxonox/objects/quest/Quest.cc

  • code/branches/questsystem5/src/orxonox/objects/quest/Quest.h

  • 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

  • code/branches/questsystem5/src/orxonox/objects/quest/QuestEffect.h

  • code/branches/questsystem5/src/orxonox/objects/quest/QuestHint.cc

  • code/branches/questsystem5/src/orxonox/objects/quest/QuestHint.h

  • code/branches/questsystem5/src/orxonox/objects/quest/QuestItem.cc

  • code/branches/questsystem5/src/orxonox/objects/quest/QuestItem.h

  • code/branches/questsystem5/src/orxonox/objects/quest/QuestManager.cc

  • code/branches/questsystem5/src/orxonox/objects/quest/QuestManager.h

  • code/branches/questsystem5/src/orxonox/objects/quest/Rewardable.cc

  • code/branches/questsystem5/src/orxonox/objects/quest/Rewardable.h

  • code/branches/questsystem5/src/orxonox/objects/weaponSystem/Munition.cc

    r2907 r2908  
    105105    void Munition::fillBullets()
    106106    {
     107//COUT(0) << "Munition::fillBullets maxBullets_=" << this->maxBullets_ << std::endl;
    107108        this->bullets_ = this->maxBullets_;
    108109    }
  • code/branches/questsystem5/src/orxonox/objects/weaponSystem/Weapon.cc

    r2907 r2908  
    4242    {
    4343        RegisterObject(Weapon);
    44 
    4544        this->bulletReadyToShoot_ = true;
    4645        this->magazineReadyToShoot_ = true;
    4746        this->parentWeaponSystem_ = 0;
    4847        this->attachedToWeaponSlot_ = 0;
     48        this->munition_ = 0;
    4949        this->bulletLoadingTime_ = 0;
    5050        this->magazineLoadingTime_ = 0;
    5151        this->bReloading_ = false;
    52         this->bulletAmount_= 0;
    53         this->magazineAmount_ = 0;
    54         this->munition_ = 0;
    55         this->unlimitedMunition_ = false;
     52
    5653        this->setObjectMode(0x0);
    5754    }
     
    6865        XMLPortParam(Weapon, "bulletLoadingTime", setBulletLoadingTime, getBulletLoadingTime, xmlelement, mode);
    6966        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);
    7367    }
    7468
     
    7973    }
    8074
    81     void Weapon::setMunition()
    82     {
    83         this->munition_->setMaxBullets(this->bulletAmount_);
    84         this->munition_->setMaxMagazines(this->magazineAmount_);
    85     }
    8675
    8776    void Weapon::fire()
    8877    {
     78//COUT(0) << "LaserGun::fire, this=" << this << std::endl;
    8979        if ( this->bulletReadyToShoot_ && this->magazineReadyToShoot_ && !this->bReloading_)
    9080        {
     81//COUT(0) << "LaserGun::fire - ready to shoot" << std::endl;
     82//COUT(0) << "LaserGun::fire - bullets" << this->munition_->bullets() << std::endl;
    9183            this->bulletReadyToShoot_ = false;
    92             if ( this->unlimitedMunition_== true )
     84            if ( this->munition_->bullets() > 0)
    9385            {
    9486                //shoot
    95                 this->reloadBullet();
     87                this->takeBullets();
    9688                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();
    9795            }
    9896            else
    9997            {
    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
    118100            }
    119101        }
    120102        else
    121103        {
    122             //weapon not reloaded
     104//COUT(0) << "LaserGun::fire - weapon not reloaded - bullets remaining:" << this->munition_->bullets() << std::endl;
     105            //actions
    123106        }
    124107
     
    126109
    127110
    128     //weapon reloading
    129111    void Weapon::bulletTimer(float bulletLoadingTime)
    130112    {
     113//COUT(0) << "Weapon::bulletTimer started" << std::endl;
    131114        this->bReloading_ = true;
    132115        this->bulletReloadTimer_.setTimer( bulletLoadingTime , false , this , createExecutor(createFunctor(&Weapon::bulletReloaded)));
     
    134117    void Weapon::magazineTimer(float magazineLoadingTime)
    135118    {
     119//COUT(0) << "Weapon::magazineTimer started" << std::endl;
    136120        this->bReloading_ = true;
    137121        this->magazineReloadTimer_.setTimer( magazineLoadingTime , false , this , createExecutor(createFunctor(&Weapon::magazineReloaded)));
     
    148132        this->bReloading_ = false;
    149133        this->munition_->fillBullets();
     134        this->magazineReadyToShoot_ = true;
     135        this->bulletReadyToShoot_ = true;
    150136    }
    151 
    152137
    153138
    154139    void Weapon::attachNeededMunition(std::string munitionName)
    155140    {
    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
    158143        if (this->parentWeaponSystem_)
    159144        {
    160             //getMunitionType returns 0 if there is no such munitionType
     145//COUT(0) << "Weapon::attachNeededMunition " << munitionName << std::endl;
    161146            Munition* munition = this->parentWeaponSystem_->getMunitionType(munitionName);
    162147            if ( munition )
    163             {
    164148                this->munition_ = munition;
    165                 this->setMunition();
    166             }
    167149            else
    168150            {
    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;
    170153                this->munitionIdentifier_ = ClassByString(munitionName);
    171154                this->munition_ = this->munitionIdentifier_.fabricate(this);
    172155                this->parentWeaponSystem_->setNewMunition(munitionName, this->munition_);
    173                 this->setMunition();
    174156            }
    175157        }
     
    177159
    178160
    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     */
    184164
    185 
    186     //these function are defined in the weapon classes
    187     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 XMLPort
    195165    void Weapon::setMunitionType(std::string munitionType)
    196166    {   this->munitionType_ = munitionType; }
     
    211181    {   return this->magazineLoadingTime_;  }
    212182
    213     void Weapon::setBulletAmount(unsigned int amount)
    214     {   this->bulletAmount_ = amount; }
    215183
    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    }
    218191
    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() { };
    230195
    231196}
  • code/branches/questsystem5/src/orxonox/objects/weaponSystem/Weapon.h

    r2907 r2908  
    6262            void magazineReloaded();
    6363
    64             //XMLPort functions
    6564            virtual void setMunitionType(std::string munitionType);
    6665            virtual const std::string getMunitionType();
     
    6968            virtual void setMagazineLoadingTime(float loadingTime);
    7069            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();
    7770
    78             //weapon actions
    7971            virtual void takeBullets();
    8072            virtual void takeMagazines();
    8173            virtual void createProjectile();
    82             virtual void reloadBullet();
    83             virtual void reloadMagazine();
    8474
    85             //manually set or reset
    86             virtual void setWeapon();
    87             virtual void setMunition();
    88            
    8975            inline void setParentWeaponSystem(WeaponSystem *parentWeaponSystem)
    9076                { this->parentWeaponSystem_=parentWeaponSystem; };
     
    9783                { return this->attachedToWeaponSlot_; }
    9884
     85            virtual void setWeapon();
    9986
    10087        private:
     
    10491            bool bulletReadyToShoot_;
    10592            bool magazineReadyToShoot_;
    106             bool unlimitedMunition_;
    10793            float bulletLoadingTime_;
    10894            float magazineLoadingTime_;
    109             unsigned int bulletAmount_;
    110             unsigned int magazineAmount_;
    11195            std::string munitionType_;
    11296
  • code/branches/questsystem5/src/orxonox/objects/weaponSystem/WeaponPack.cc

    r2907 r2908  
    6363        for (int i=0; i < (int) this->weapons_.size(); i++)
    6464        {
     65//COUT(0) << "WeaponPack::fire (attached from WeaponSet)  from Weapon: "<< i << std::endl;
    6566            this->weapons_[i]->getAttachedToWeaponSlot()->fire();
    6667        }
     
    8283    void WeaponPack::setFireMode(unsigned int firemode)
    8384    {
     85//COUT(0) << "WeaponPack::setFireMode " << std::endl;
    8486        this->firemode_ = firemode;
    8587    }
     
    9294    void WeaponPack::addWeapon(Weapon * weapon)
    9395    {
     96//COUT(0) << "WeaponPack::addWeapon:" << weapon << "   munition " << weapon->getMunitionType() << std::endl;
    9497        this->weapons_.push_back(weapon);
    9598    }
     
    114117        {
    115118            this->weapons_[i]->attachNeededMunition(weapons_[i]->getMunitionType());
     119            //hack!
    116120            this->weapons_[i]->setWeapon();
    117121        }
  • code/branches/questsystem5/src/orxonox/objects/weaponSystem/WeaponPack.h

    r2907 r2908  
    5959            const Weapon * getWeapon(unsigned int index);
    6060
    61             //functions with effect to all weapons of the weaponPack
    6261            //functions needed for creating Pointer to the right objects (-->Pawn.cc)
    6362            void setParentWeaponSystemToAllWeapons(WeaponSystem * weaponSystem);
  • code/branches/questsystem5/src/orxonox/objects/weaponSystem/WeaponSet.cc

    r2907 r2908  
    5656    void WeaponSet::attachWeaponPack(WeaponPack *wPack)
    5757    {
     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;
    5862        if ( this->parentWeaponSystem_->getWeaponSlotSize()>0 && wPack->getSize()>0 && ( wPack->getSize() <= this->parentWeaponSystem_->getWeaponSlotSize() ) )
    5963        {
     64//COUT(0) << "WeaponSet::attachWeaponPack after if" << std::endl;
    6065            this->attachedWeaponPack_ = wPack;
    6166            int wPackWeapon = 0;    //WeaponCounter for Attaching
    62            
    6367            //should be possible to choose which slot to use
    64             //attach every weapon of the weaponPack to a weaponSlot
    6568            for (  int i=0; i < wPack->getSize() ; i++  )
    6669            {
    6770                //at the moment this function only works for one weaponPack in the entire WeaponSystem...
    68                 //it also takes the first free weaponSlot...
    6971                if ( this->parentWeaponSystem_->getWeaponSlotPointer(i)->getAttachedWeapon() == 0 && this->parentWeaponSystem_->getWeaponSlotPointer(i) != 0) //if slot not full
    7072                {
     73//COUT(0) << "WeaponSet::attachWeaponPack attaching Weapon" << std::endl;
    7174                    this->setWeaponSlots_.push_back( this->parentWeaponSystem_->getWeaponSlotPointer(i) );
    7275                    this->parentWeaponSystem_->getWeaponSlotPointer(i)->attachWeapon( wPack->getWeaponPointer(wPackWeapon) );
     
    8083                        if ( this->parentWeaponSystem_->getWeaponSlotPointer(k)->getAttachedWeapon() == 0 )
    8184                        {
     85//COUT(0) << "WeaponSet::attachWeaponPack mode 2 k="<< k << std::endl;
    8286                            this->setWeaponSlots_.push_back( this->parentWeaponSystem_->getWeaponSlotPointer(k) );
    8387                            this->parentWeaponSystem_->getWeaponSlotPointer(k)->attachWeapon( wPack->getWeaponPointer(wPackWeapon) );
     
    9599    {
    96100        //fires all WeaponSlots available for this weaponSet attached from the WeaponPack
     101//COUT(0) << "WeaponSet::fire from Pack: " << this->attachedWeaponPack_ << std::endl;
    97102        if (this->attachedWeaponPack_)
    98103            this->attachedWeaponPack_->fire();
  • code/branches/questsystem5/src/orxonox/objects/weaponSystem/WeaponSystem.cc

    r2907 r2908  
    3838
    3939
    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
    4143 *
    42  *  www.orxonox.net/wiki/WeaponSystem
    4344 */
    4445
     
    5152        RegisterObject(WeaponSystem);
    5253
     54        this->activeWeaponSet_ = 0;
    5355        this->parentPawn_ = 0;
    5456    }
     
    8284    }
    8385
    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
    8687    Munition * WeaponSystem::getMunitionType(std::string munitionType)
    8788    {
     89//COUT(0) << "WeaponSystem::getMunitionType " << munitionType << std::endl;
    8890        std::map<std::string, Munition *>::const_iterator it = this->munitionSet_.find(munitionType);
    8991        if (it != this->munitionSet_.end())
     
    9496
    9597
     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
    96110    //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
    99112    void WeaponSystem::fire(WeaponMode::Enum n)
    100113    {
     
    112125                break;
    113126        }
     127//COUT(0) << "WeaponSystem::fire" << std::endl;
    114128        if (set < (int)this->weaponSets_.size())
     129//COUT(0) << "WeaponSystem::fire - after if" << std::endl;
    115130            this->weaponSets_[set]->fire();
    116131    }
  • code/branches/questsystem5/src/orxonox/objects/weaponSystem/WeaponSystem.h

    r2907 r2908  
    5353            //void fire();
    5454            void fire(WeaponMode::Enum fireMode);
     55            //void setActiveWeaponSet(unsigned int n);
    5556            void attachWeaponPack(WeaponPack * wPack, unsigned int firemode);
    5657            WeaponSet * getWeaponSetPointer(unsigned int n);
     
    5859            WeaponPack * getWeaponPackPointer(unsigned int n);
    5960            void setNewMunition(std::string munitionType, Munition * munitionToAdd);
    60             void setNewSharedMunition(std::string munitionType, Munition * munitionToAdd);
    6161            Munition * getMunitionType(std::string munitionType);
    6262
     
    7474            std::vector<WeaponPack *> weaponPacks_;
    7575            std::map<std::string, Munition *> munitionSet_;
     76            WeaponSet *activeWeaponSet_;
    7677            Pawn *parentPawn_;
    7778    };
  • code/branches/questsystem5/src/orxonox/objects/weaponSystem/munitions/CMakeLists.txt

    r2907 r2908  
    11ADD_SOURCE_FILES(ORXONOX_SRC_FILES
    22  LaserGunMunition.cc
    3   FusionMunition.cc
    43)
  • code/branches/questsystem5/src/orxonox/objects/weaponSystem/munitions/LaserGunMunition.cc

    r2907 r2908  
    4343        RegisterObject(LaserGunMunition);
    4444
    45         //default if not defined in XML
    4645        this->maxBullets_ = 40;
    4746        this->maxMagazines_ = 100;
  • code/branches/questsystem5/src/orxonox/objects/weaponSystem/projectiles/BillboardProjectile.cc

    r2907 r2908  
    3232#include <OgreBillboardSet.h>
    3333
    34 #include "core/GameMode.h"
     34#include "core/Core.h"
    3535#include "core/CoreIncludes.h"
    3636#include "objects/Scene.h"
     
    4444        RegisterObject(BillboardProjectile);
    4545
    46         if (GameMode::showsGraphics())
     46        if (Core::showsGraphics())
    4747        {
    4848            assert(this->getScene()->getSceneManager()); // getScene() was already checked by WorldEntity
     
    5656    BillboardProjectile::~BillboardProjectile()
    5757    {
    58         if (this->isInitialized() && GameMode::showsGraphics() && this->billboard_.getBillboardSet())
     58        if (this->isInitialized() && Core::showsGraphics() && this->billboard_.getBillboardSet())
    5959            this->detachOgreObject(this->billboard_.getBillboardSet());
    6060    }
  • code/branches/questsystem5/src/orxonox/objects/weaponSystem/projectiles/ParticleProjectile.cc

    r2907 r2908  
    3333#include <OgreParticleEmitter.h>
    3434
    35 #include "core/GameMode.h"
     35#include "core/Core.h"
    3636#include "core/CoreIncludes.h"
    3737#include "core/ConfigValueIncludes.h"
     
    4646        RegisterObject(ParticleProjectile);
    4747
    48         if (GameMode::showsGraphics())
     48        if (Core::showsGraphics())
    4949        {
    5050            this->particles_ = new ParticleInterface(this->getScene()->getSceneManager(), "Orxonox/shot3_small", LODParticle::normal);
  • code/branches/questsystem5/src/orxonox/objects/weaponSystem/projectiles/Projectile.cc

    r2907 r2908  
    4141#include "objects/worldentities/ParticleSpawner.h"
    4242#include "objects/collisionshapes/SphereCollisionShape.h"
    43 #include "core/GameMode.h"
     43#include "core/Core.h"
    4444
    4545namespace orxonox
     
    5555        // Get notification about collisions
    5656
    57         if (GameMode::isMaster())
     57        if (Core::isMaster())
    5858        {
    5959            this->enableCollisionCallback();
     
    9393    void Projectile::destroyObject()
    9494    {
    95         if (GameMode::isMaster())
     95        if (Core::isMaster())
    9696            delete this;
    9797    }
     
    9999    bool Projectile::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)
    100100    {
    101         if (!this->bDestroy_ && GameMode::isMaster())
     101        if (!this->bDestroy_ && Core::isMaster())
    102102        {
    103103            this->bDestroy_ = true;
  • code/branches/questsystem5/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc

    r2907 r2908  
    5353    }
    5454
    55     void LaserGun::reloadBullet()
    56     {
    57         this->bulletTimer(this->bulletLoadingTime_);
    58     }
    59 
    60     void LaserGun::reloadMagazine()
    61     {
    62         this->magazineTimer(this->magazineLoadingTime_);
    63     }
    64 
    6555    void LaserGun::takeBullets()
    6656    {
     57//COUT(0) << "LaserGun::takeBullets" << std::endl;
    6758        this->munition_->removeBullets(1);
     59        this->bulletTimer(this->bulletLoadingTime_);
    6860    }
    6961
     
    7163    {
    7264        this->munition_->removeMagazines(1);
     65        this->magazineTimer(this->magazineLoadingTime_);
    7366    }
    7467
    7568    void LaserGun::createProjectile()
    7669    {
     70//COUT(0) << "LaserGun::createProjectile" << std::endl;
    7771        BillboardProjectile* projectile = new ParticleProjectile(this);
    7872        projectile->setOrientation(this->getWorldOrientation());
  • code/branches/questsystem5/src/orxonox/objects/weaponSystem/weapons/LaserGun.h

    r2907 r2908  
    5151            virtual void takeMagazines();
    5252            virtual void createProjectile();
    53             virtual void reloadBullet();
    54             virtual void reloadMagazine();
    5553
    5654        private:
  • code/branches/questsystem5/src/orxonox/objects/worldentities/Backlight.cc

    r2907 r2908  
    3333#include <OgreSceneManager.h>
    3434
    35 #include "core/GameMode.h"
     35#include "core/Core.h"
    3636#include "core/CoreIncludes.h"
    3737#include "core/Executor.h"
     
    5858        this->tickcount_ = 0;
    5959
    60         if (GameMode::showsGraphics())
     60        if (Core::showsGraphics())
    6161        {
    6262            if (!this->getScene())
  • code/branches/questsystem5/src/orxonox/objects/worldentities/Backlight.h

    r2907 r2908  
    3232#include "OrxonoxPrereqs.h"
    3333#include "FadingBillboard.h"
    34 #include "tools/TimeFactorListener.h"
     34#include "gamestates/GSRoot.h"
    3535
    3636namespace orxonox
  • code/branches/questsystem5/src/orxonox/objects/worldentities/Billboard.cc

    r2907 r2908  
    3434#include "core/CoreIncludes.h"
    3535#include "core/XMLPort.h"
    36 #include "core/GameMode.h"
     36#include "core/Core.h"
    3737#include "objects/Scene.h"
    3838
     
    8181        if (!this->billboard_.getBillboardSet())
    8282        {
    83             if (this->getScene() && GameMode::showsGraphics())
     83            if (this->getScene() && Core::showsGraphics())
    8484            {
    8585                this->billboard_.setBillboardSet(this->getScene()->getSceneManager(), this->material_, this->colour_, 1);
     
    9898        {
    9999/*
    100             if (this->getScene() && GameMode::showsGraphics() && (this->material_ != ""))
     100            if (this->getScene() && Core::showsGraphics() && (this->material_ != ""))
    101101            {
    102102                this->billboard_.setBillboardSet(this->getScene()->getSceneManager(), this->material_, this->colour_, 1);
  • code/branches/questsystem5/src/orxonox/objects/worldentities/Billboard.h

    r2907 r2908  
    3434#include "util/Math.h"
    3535#include "tools/BillboardSet.h"
    36 #include "objects/Teamcolourable.h"
    3736
    3837namespace orxonox
    3938{
    40     class _OrxonoxExport Billboard : public StaticEntity, public Teamcolourable
     39    class _OrxonoxExport Billboard : public StaticEntity
    4140    {
    4241        public:
     
    6261                { return this->colour_; }
    6362
    64             virtual void setTeamColour(const ColourValue& colour)
    65                 { this->setColour(colour); }
    66 
    6763        protected:
    6864            inline BillboardSet& getBillboardSet()
  • code/branches/questsystem5/src/orxonox/objects/worldentities/BlinkingBillboard.cc

    r2907 r2908  
    3030#include "BlinkingBillboard.h"
    3131
    32 #include "core/GameMode.h"
     32#include "core/Core.h"
    3333#include "core/CoreIncludes.h"
    3434#include "core/XMLPort.h"
     
    7777        SUPER(BlinkingBillboard, tick, dt);
    7878
    79         if (GameMode::isMaster() && this->isActive())
     79        if (Core::isMaster() && this->isActive())
    8080        {
    8181            this->time_ += dt;
  • code/branches/questsystem5/src/orxonox/objects/worldentities/CMakeLists.txt

    r2907 r2908  
    1919  Planet.cc
    2020  SpawnPoint.cc
    21   TeamSpawnPoint.cc
    22   PongCenterpoint.cc
    23   PongBall.cc
    24   PongBat.cc
    2521)
    2622
  • code/branches/questsystem5/src/orxonox/objects/worldentities/Camera.cc

  • code/branches/questsystem5/src/orxonox/objects/worldentities/Camera.h

  • code/branches/questsystem5/src/orxonox/objects/worldentities/CameraPosition.cc

    r2907 r2908  
    4444        this->bDrag_ = false;
    4545        this->bAllowMouseLook_ = false;
    46         this->bAbsolute_ = false;
    4746
    4847        this->setObjectMode(0x0);
     
    5958        XMLPortParam(CameraPosition, "drag", setDrag, getDrag, xmlelement, mode).defaultValues(false);
    6059        XMLPortParam(CameraPosition, "mouselook", setAllowMouseLook, getAllowMouseLook, xmlelement, mode).defaultValues(false);
    61         XMLPortParam(CameraPosition, "absolute", setIsAbsolute, getIsAbsolute, xmlelement, mode).defaultValues(false);
    6260    }
    6361
  • code/branches/questsystem5/src/orxonox/objects/worldentities/CameraPosition.h

    r2907 r2908  
    5454                { return this->bAllowMouseLook_; }
    5555
    56             inline void setIsAbsolute(bool bAbsolute)
    57                 { this->bAbsolute_ = bAbsolute; }
    58             inline bool getIsAbsolute() const
    59                 { return this->bAbsolute_; }
    60 
    6156            void attachCamera(Camera* camera);
    6257
     
    6459            bool bDrag_;
    6560            bool bAllowMouseLook_;
    66             bool bAbsolute_;
    6761    };
    6862}
  • code/branches/questsystem5/src/orxonox/objects/worldentities/ControllableEntity.cc

    r2907 r2908  
    3434#include "core/CoreIncludes.h"
    3535#include "core/ConfigValueIncludes.h"
    36 #include "core/GameMode.h"
     36#include "core/Core.h"
    3737#include "core/XMLPort.h"
    3838#include "core/Template.h"
     
    144144    void ControllableEntity::addCameraPosition(CameraPosition* position)
    145145    {
    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_);
    153148        else
    154         {
    155             WorldEntity* parent = this->getParent();
    156             if (parent)
    157                 parent->attach(position);
    158         }
     149            this->attach(position);
    159150        this->cameraPositions_.push_back(position);
    160151    }
     
    245236            this->startLocalHumanControl();
    246237
    247             if (!GameMode::isMaster())
     238            if (!Core::isMaster())
    248239            {
    249240                this->client_overwrite_ = this->server_overwrite_;
     
    251242            }
    252243        }
    253 
    254         this->changedPlayer();
    255244    }
    256245
     
    265254        this->bHasHumanController_ = false;
    266255        this->setObjectMode(objectDirection::toclient);
    267 
    268         this->changedPlayer();
    269256
    270257        if (this->bDestroyWhenPlayerLeft_)
     
    335322    }
    336323
    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 
    350324    void ControllableEntity::tick(float dt)
    351325    {
     
    357331            if (!this->isDynamic())
    358332            {
    359                 if (GameMode::isMaster())
     333                if (Core::isMaster())
    360334                {
    361335                    this->server_position_ = this->getPosition();
     
    472446    void ControllableEntity::setPosition(const Vector3& position)
    473447    {
    474         if (GameMode::isMaster())
     448        if (Core::isMaster())
    475449        {
    476450            MobileEntity::setPosition(position);
     
    487461    void ControllableEntity::setOrientation(const Quaternion& orientation)
    488462    {
    489         if (GameMode::isMaster())
     463        if (Core::isMaster())
    490464        {
    491465            MobileEntity::setOrientation(orientation);
     
    502476    void ControllableEntity::setVelocity(const Vector3& velocity)
    503477    {
    504         if (GameMode::isMaster())
     478        if (Core::isMaster())
    505479        {
    506480            MobileEntity::setVelocity(velocity);
     
    517491    void ControllableEntity::setAngularVelocity(const Vector3& velocity)
    518492    {
    519         if (GameMode::isMaster())
     493        if (Core::isMaster())
    520494        {
    521495            MobileEntity::setAngularVelocity(velocity);
     
    533507    {
    534508        MobileEntity::setWorldTransform(worldTrans);
    535         if (GameMode::isMaster())
     509        if (Core::isMaster())
    536510        {
    537511            this->server_position_ = this->getPosition();
  • code/branches/questsystem5/src/orxonox/objects/worldentities/ControllableEntity.h

    r2907 r2908  
    4949
    5050            virtual void changedGametype();
    51             virtual void changedPlayer() {}
    5251
    5352            virtual void setPlayer(PlayerInfo* player);
     
    137136            virtual void startLocalHumanControl();
    138137            virtual void stopLocalHumanControl();
    139             virtual void parentChanged();
    140138
    141139            inline void setHudTemplate(const std::string& name)
  • code/branches/questsystem5/src/orxonox/objects/worldentities/ExplosionChunk.cc

    r2907 r2908  
    3232#include <OgreParticleSystem.h>
    3333
    34 #include "core/GameMode.h"
     34#include "core/Core.h"
    3535#include "core/CoreIncludes.h"
    3636#include "core/Executor.h"
     
    4747        RegisterObject(ExplosionChunk);
    4848
    49         if ( GameMode::showsGraphics() && ( !this->getScene() || !this->getScene()->getSceneManager() ) )
     49        if ( Core::showsGraphics() && ( !this->getScene() || !this->getScene()->getSceneManager() ) )
    5050            ThrowException(AbortLoading, "Can't create ExplosionChunk, no scene or no scene manager given.");
    5151
     
    5353        this->LOD_ = LODParticle::normal;
    5454
    55         if ( GameMode::showsGraphics() )
     55        if ( Core::showsGraphics() )
    5656        {
    5757            try
     
    7575        }
    7676
    77         if (GameMode::isMaster())
     77        if (Core::isMaster())
    7878        {
    7979            Vector3 velocity(rnd(-1, 1), rnd(-1, 1), rnd(-1, 1));
     
    132132            this->smoke_->setEnabled(false);
    133133
    134         if (GameMode::isMaster())
     134        if (Core::isMaster())
    135135        {
    136136            this->bStop_ = true;
     
    148148        static const unsigned int CHANGES_PER_SECOND = 5;
    149149
    150         if (GameMode::isMaster() && rnd() < dt*CHANGES_PER_SECOND)
     150        if (Core::isMaster() && rnd() < dt*CHANGES_PER_SECOND)
    151151        {
    152152            float length = this->getVelocity().length();
  • code/branches/questsystem5/src/orxonox/objects/worldentities/Light.cc

    r2907 r2908  
    3737#include "util/String.h"
    3838#include "util/Exception.h"
    39 #include "core/GameMode.h"
     39#include "core/Core.h"
    4040#include "core/CoreIncludes.h"
    4141#include "core/XMLPort.h"
     
    5757        this->spotlightRange_ = Vector3(40.0f, 30.0f, 1.0f);
    5858
    59         if (GameMode::showsGraphics())
     59        if (Core::showsGraphics())
    6060        {
    6161            if (!this->getScene())
  • code/branches/questsystem5/src/orxonox/objects/worldentities/Light.h

    r2907 r2908  
    3737
    3838#include "util/Math.h"
    39 #include "objects/Teamcolourable.h"
    4039
    4140namespace orxonox
    4241{
    43     class _OrxonoxExport Light : public StaticEntity, public Teamcolourable
     42    class _OrxonoxExport Light : public StaticEntity
    4443    {
    4544        public:
     
    6968            inline const ColourValue& getSpecularColour() const
    7069                { return this->specular_; }
    71 
    72             virtual void setTeamColour(const ColourValue& colour)
    73                 { this->setDiffuseColour(colour); this->setSpecularColour(colour); }
    7470
    7571            /**
  • code/branches/questsystem5/src/orxonox/objects/worldentities/MobileEntity.cc

    r2907 r2908  
    182182        // We use a dynamic body. So we translate our node accordingly.
    183183        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()));
    186185        this->linearVelocity_.x = this->physicalBody_->getLinearVelocity().x();
    187186        this->linearVelocity_.y = this->physicalBody_->getLinearVelocity().y();
  • code/branches/questsystem5/src/orxonox/objects/worldentities/MobileEntity.h

  • code/branches/questsystem5/src/orxonox/objects/worldentities/Model.cc

    r2907 r2908  
    3131#include <OgreEntity.h>
    3232#include "Model.h"
    33 #include "core/GameMode.h"
    3433#include "core/CoreIncludes.h"
    3534#include "core/XMLPort.h"
     
    7170    void Model::changedMesh()
    7271    {
    73         if (GameMode::showsGraphics())
     72        if (Core::showsGraphics())
    7473        {
    7574            if (this->mesh_.getEntity())
  • code/branches/questsystem5/src/orxonox/objects/worldentities/MovableEntity.cc

    r2907 r2908  
    3434#include "core/XMLPort.h"
    3535#include "core/Executor.h"
    36 #include "core/GameMode.h"
     36#include "core/Core.h"
    3737
    3838namespace orxonox
     
    8989    void MovableEntity::resynchronize()
    9090    {
    91         if (GameMode::isMaster() && !this->continuousResynchroTimer_)
     91        if (Core::isMaster() && !this->continuousResynchroTimer_)
    9292        {
    9393            // Resynchronise every few seconds because we only work with velocities (no positions)
  • code/branches/questsystem5/src/orxonox/objects/worldentities/ParticleEmitter.cc

    r2907 r2908  
    3939#include "tools/ParticleInterface.h"
    4040#include "util/Exception.h"
    41 #include "core/GameMode.h"
    4241#include "core/CoreIncludes.h"
    4342#include "core/XMLPort.h"
     
    5251        RegisterObject(ParticleEmitter);
    5352
    54         if (GameMode::showsGraphics() && (!this->getScene() || !this->getScene()->getSceneManager()))
     53        if (Core::showsGraphics() && (!this->getScene() || !this->getScene()->getSceneManager()))
    5554            ThrowException(AbortLoading, "Can't create ParticleEmitter, no scene or no scene manager given.");
    5655
     
    108107        }
    109108
    110         if (GameMode::showsGraphics() && this->getScene() && this->getScene()->getSceneManager())
     109        if (Core::showsGraphics() && this->getScene() && this->getScene()->getSceneManager())
    111110        {
    112111            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  
    4242#include "CameraManager.h"
    4343#include "Camera.h"
    44 #include "GraphicsManager.h"
     44#include "GraphicsEngine.h"
    4545
    4646namespace 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  
    181181
    182182        // 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));
    184184    }
    185185
     
    188188        Network function that object this instance to its correct parent.
    189189    */
    190     void WorldEntity::networkcallback_parentChanged()
     190    void WorldEntity::parentChanged()
    191191    {
    192192        if (this->parentID_ != OBJECTID_UNKNOWN)
     
    362362        this->parentID_ = newParent->getObjectID();
    363363
    364         this->parentChanged();
    365 
    366364        // apply transform to collision shape
    367365        this->collisionShape_->setPosition(this->getPosition());
    368366        this->collisionShape_->setOrientation(this->getOrientation());
    369367        // TODO: Scale
    370 
     368       
    371369        return true;
    372370    }
     
    408406        this->parent_ = 0;
    409407        this->parentID_ = OBJECTID_UNKNOWN;
    410 
    411         this->parentChanged();
    412408
    413409        // reset orientation of the collisionShape (cannot be set within a WE usually)
     
    492488
    493489    // Note: These functions are placed in WorldEntity.h as inline functions for the release build.
    494 #ifndef NDEBUG
     490#ifndef _NDEBUG
    495491    const Vector3& WorldEntity::getPosition() const
    496492    {
     
    660656        case TransformSpace::World:
    661657            ogreRelativeTo = Ogre::Node::TS_WORLD; break;
    662         default: OrxAssert(false, "Faulty TransformSpace::Enum assigned.");
    663658        }
    664659        this->node_->setDirection(direction, ogreRelativeTo, localDirectionVector);
     
    760755        {
    761756        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));
    763758            break;
    764759        case Kinematic:
  • code/branches/questsystem5/src/orxonox/objects/worldentities/WorldEntity.h

    r2907 r2908  
    3333#include "OrxonoxPrereqs.h"
    3434
    35 #ifdef NDEBUG
     35#ifdef _NDEBUG
    3636#include <OgreSceneNode.h>
    3737#else
     
    176176
    177177        protected:
    178             virtual void parentChanged() {}
    179 
    180178            Ogre::SceneNode* node_;
    181179
     
    193191
    194192            // network callbacks
    195             void networkcallback_parentChanged();
     193            void parentChanged();
    196194            inline void scaleChanged()
    197195                { this->setScale3D(this->getScale3D()); }
     
    271269            @brief
    272270                Sets how much reaction is applied in a collision.
    273 
     271               
    274272                Consider two equal spheres colliding with equal velocities:
    275273                Restitution 1 means that both spheres simply reverse their velocity (no loss of energy)
     
    421419
    422420    // Inline heavily used functions for release builds. In debug, we better avoid including OgreSceneNode here.
    423 #ifdef NDEBUG
     421#ifdef _NDEBUG
    424422    inline const Vector3& WorldEntity::getPosition() const
    425423        { return this->node_->getPosition(); }
    426424    inline const Quaternion& WorldEntity::getOrientation() const
    427         { return this->node_->getOrientation(); }
     425        { return this->node_->getrOrientation(); }
    428426    inline const Vector3& WorldEntity::getScale3D(void) const
    429427        { return this->node_->getScale(); }
  • code/branches/questsystem5/src/orxonox/objects/worldentities/pawns/Pawn.cc

    r2907 r2908  
    3030#include "Pawn.h"
    3131
    32 #include "core/GameMode.h"
     32#include "core/Core.h"
    3333#include "core/CoreIncludes.h"
    3434#include "core/XMLPort.h"
     
    6363        this->getPickUp().setPlayer(this);
    6464
    65         if (GameMode::isMaster())
     65        if (Core::isMaster())
    6666        {
    6767            this->weaponSystem_ = new WeaponSystem(this);
     
    133133    }
    134134
    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 
    151135    void Pawn::setHealth(float health)
    152136    {
     
    156140    void Pawn::damage(float damage, Pawn* originator)
    157141    {
    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
    165146    }
    166147
    167148    void Pawn::hit(Pawn* originator, const Vector3& force, float damage)
    168149    {
    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
    176154    }
    177155
     
    198176    void Pawn::death()
    199177    {
    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();
    218191    }
    219192
     
    249222            ExplosionChunk* chunk = new ExplosionChunk(this->getCreator());
    250223            chunk->setPosition(this->getPosition());
     224
    251225        }
    252226    }
     
    260234    {
    261235        this->setHealth(this->initialHealth_);
    262         if (GameMode::isMaster())
     236        if (Core::isMaster())
    263237            this->spawneffect();
    264238    }
     
    269243    }
    270244
    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-Items
    276     */
    277245    void Pawn::setWeaponSlot(WeaponSlot * wSlot)
    278246    {
  • code/branches/questsystem5/src/orxonox/objects/worldentities/pawns/Pawn.h

    r2907 r2908  
    4747            virtual void tick(float dt);
    4848            void registerVariables();
    49 
    50             virtual void setPlayer(PlayerInfo* player);
    51             virtual void removePlayer();
    5249
    5350            inline bool isAlive() const
  • code/branches/questsystem5/src/orxonox/objects/worldentities/pawns/Spectator.cc

    r2907 r2908  
    3434#include "core/CoreIncludes.h"
    3535#include "core/ConfigValueIncludes.h"
    36 #include "core/GameMode.h"
     36#include "core/Core.h"
    3737#include "objects/worldentities/Model.h"
    3838#include "objects/Scene.h"
     
    6363        this->setDestroyWhenPlayerLeft(true);
    6464
    65         if (GameMode::showsGraphics())
     65        if (Core::showsGraphics())
    6666        {
    6767            this->greetingFlare_ = new BillboardSet();
     
    206206        this->bGreeting_ = !this->bGreeting_;
    207207
    208         if (GameMode::isMaster())
     208        if (Core::isMaster())
    209209        {
    210210            this->bGreetingFlareVisible_ = this->bGreeting_;
  • code/branches/questsystem5/src/orxonox/objects/worldentities/triggers/DistanceTrigger.cc

  • code/branches/questsystem5/src/orxonox/objects/worldentities/triggers/DistanceTrigger.h

  • code/branches/questsystem5/src/orxonox/objects/worldentities/triggers/Trigger.cc

    r2907 r2908  
    3636#include "core/ConsoleCommand.h"
    3737#include "core/XMLPort.h"
    38 #include "core/GameMode.h"
     38#include "core/Core.h"
    3939#include "objects/Scene.h"
    4040
     
    6767//    this->bUpdating_ = false;
    6868
    69     if (this->getScene() && GameMode::showsGraphics())
     69    if (this->getScene() && Core::showsGraphics())
    7070    {
    7171      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  
    3939#include <OgreOverlayManager.h>
    4040#include <OgrePanelOverlayElement.h>
    41 #include <OgreRenderWindow.h>
    42 
    4341#include "util/Convert.h"
    4442#include "util/Exception.h"
    4543#include "util/String.h"
    46 #include "core/GameMode.h"
     44#include "core/Core.h"
    4745#include "core/CoreIncludes.h"
    4846#include "core/XMLPort.h"
    4947#include "core/ConsoleCommand.h"
    50 #include "GraphicsManager.h"
    5148
    5249namespace orxonox
     
    6764        this->group_ = 0;
    6865
    69         if (!GameMode::showsGraphics())
     66        if (!Core::showsGraphics())
    7067            ThrowException(NoGraphics, "Can't create OrxonoxOverlay, graphics engine not initialized");
    7168
     
    8077        this->overlay_->add2D(this->background_);
    8178
    82         // Get aspect ratio from the render window. Later on, we get informed automatically
    83         Ogre::RenderWindow* defaultWindow = GraphicsManager::getInstance().getRenderWindow();
    84         this->windowAspectRatio_ = (float)defaultWindow->getWidth() / defaultWindow->getHeight();
     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;
    8582        this->sizeCorrectionChanged();
    8683
     
    178175    /**
    179176    @brief
    180         Called by the GraphicsManager whenever the window size changes.
     177        Called by the GraphicsEngine whenever the window size changes.
    181178        Calculates the aspect ratio only.
    182179    */
    183     void OrxonoxOverlay::windowResized(unsigned int newWidth, unsigned int newHeight)
     180    void OrxonoxOverlay::windowResized(int newWidth, int newHeight)
    184181    {
    185182        this->windowAspectRatio_ = newWidth/(float)newHeight;
  • code/branches/questsystem5/src/orxonox/overlays/OrxonoxOverlay.h

    r2907 r2908  
    154154        virtual void changedVisibility();
    155155
    156         inline void setOwner(BaseObject* owner)
     156        inline void setOwner(ControllableEntity* owner)
    157157        {
    158158            if (this->owner_ != owner)
     
    162162            }
    163163        }
    164         inline BaseObject* getOwner() const
     164        inline ControllableEntity* getOwner() const
    165165            { return this->owner_; }
    166166        virtual void changedOwner() {}
     
    200200
    201201    private:
    202         void windowResized(unsigned int newWidth, unsigned int newHeight);
     202        void windowResized(int newWidth, int newHeight);
    203203
    204204        static unsigned int hudOverlayCounter_s;   //!< Static counter for hud elements
     
    206206            We could also use the ObjectList, but that doesn't guarantee XMLPort(.) was called and is slower. */
    207207        static std::map<std::string, OrxonoxOverlay*> overlays_s;
    208         BaseObject* owner_;
     208        ControllableEntity* owner_;
    209209        OverlayGroup* group_;
    210210  };
  • code/branches/questsystem5/src/orxonox/overlays/OverlayGroup.cc

    r2907 r2908  
    6363    OverlayGroup::~OverlayGroup()
    6464    {
    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;
    6767    }
    6868
     
    8383    }
    8484
    85     //! Scales every element in the set.
     85    //! Scales every element in the map.
    8686    void OverlayGroup::setScale(const Vector2& scale)
    8787    {
    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_);
    9090        this->scale_ = scale;
    9191    }
    9292
    93     //! Scrolls every element in the set.
     93    //! Scrolls every element in the map.
    9494    void OverlayGroup::setScroll(const Vector2& scroll)
    9595    {
    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_);
    9898        this->scroll_ = scroll;
    9999    }
     
    101101    /**
    102102    @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).
    104104    @remarks
    105105        The names of the OrxonoxOverlays have to be unique!
     
    107107    void OverlayGroup::addElement(OrxonoxOverlay* element)
    108108    {
    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        /**
    116139    @brief
    117140        Removes an element from the map.
    118     @param element
    119         The element that is to be removed.
     141    @param name
     142        The name of the element that is removed.
    120143    @return
    121144        Returns true if there was such an element to remove, false if not.
    122145    */
    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)
    126149            return false;
    127150        return true;
     
    133156        if (index < this->hudElements_.size())
    134157        {
    135             std::set<OrxonoxOverlay*>::const_iterator it = hudElements_.begin();
     158            std::map<std::string, OrxonoxOverlay*>::const_iterator it = hudElements_.begin();
    136159            for (unsigned int i = 0; i != index; ++it, ++i)
    137160                ;
    138             return (*it);
     161            return (*it).second;
    139162        }
    140163        else
     
    145168    void OverlayGroup::changedVisibility()
    146169    {
    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)
    152175    {
    153176        this->owner_ = owner;
    154177
    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);
    157180    }
    158181
  • code/branches/questsystem5/src/orxonox/overlays/OverlayGroup.h

    r2907 r2908  
    3737#include "OrxonoxPrereqs.h"
    3838
    39 #include <set>
    40 #include <string>
     39#include <map>
    4140#include <OgrePrerequisites.h>
    4241#include "core/BaseObject.h"
     
    6564        static void scrollGroup(const std::string& name, const Vector2& scroll);
    6665
    67         inline const std::set<OrxonoxOverlay*>& getOverlays() const
     66        inline const std::map<std::string, OrxonoxOverlay*>& getOverlays() const
    6867            { return this->hudElements_; }
    6968
    7069        void changedVisibility();
    7170
    72         void setOwner(BaseObject* owner);
    73         inline BaseObject* getOwner() const
     71        void setOwner(ControllableEntity* owner);
     72        inline ControllableEntity* getOwner() const
    7473            { return this->owner_; }
    7574
     
    8786
    8887        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);
    9090        OrxonoxOverlay* getElement(unsigned int index);
    9191
    9292    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 OverlayGroup
     93        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
    9797    };
    9898}
  • code/branches/questsystem5/src/orxonox/overlays/console/InGameConsole.cc

    r2907 r2908  
    4242#include "util/Convert.h"
    4343#include "util/Debug.h"
    44 #include "core/Clock.h"
    4544#include "core/CoreIncludes.h"
    4645#include "core/ConfigValueIncludes.h"
     
    173172    {
    174173        // create the corresponding input state
    175         inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("console", false, false, InputStatePriority::Console);
     174        inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("console", 40);
    176175        inputState_->setKeyHandler(Shell::getInstance().getInputBuffer());
    177176        bHidesAllInputChanged();
     
    348347        @brief Used to control the actual scrolling and the cursor.
    349348    */
    350     void InGameConsole::update(const Clock& time)
     349    void InGameConsole::tick(float dt)
    351350    {
    352351        if (this->scroll_ != 0)
     
    359358                // enlarge oldTop a little bit so that this exponential function
    360359                // 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_;
    362361                if (oldTop - deltaScroll >= 0)
    363362                {
     
    374373                // scrolling up
    375374                // 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_;
    377376                if (oldTop - deltaScroll <= -1.2 * this->relativeHeight)
    378377                {
     
    389388        if (this->bActive_)
    390389        {
    391             this->cursor_ += time.getDeltaTime();
     390            this->cursor_ += dt;
    392391            if (this->cursor_ >= this->blinkTime)
    393392            {
     
    410409        @brief Resizes the console elements. Call if window size changes.
    411410    */
    412     void InGameConsole::windowResized(unsigned int newWidth, unsigned int newHeight)
     411    void InGameConsole::windowResized(int newWidth, int newHeight)
    413412    {
    414413        this->windowW_ = newWidth;
  • code/branches/questsystem5/src/orxonox/overlays/console/InGameConsole.h

    r2907 r2908  
    5353        void setConfigValues();
    5454
    55         void update(const Clock& time);
     55        virtual void tick(float dt);
    5656
    5757        static InGameConsole& getInstance() { assert(singletonRef_s); return *singletonRef_s; }
     
    8181        void print(const std::string& text, int index, bool alwaysShift = false);
    8282
    83         void windowResized(unsigned int newWidth, unsigned int newHeight);
     83        void windowResized(int newWidth, int newHeight);
    8484
    8585        // config value related
  • code/branches/questsystem5/src/orxonox/overlays/debug/DebugFPSText.cc

    r2907 r2908  
    3030#include "DebugFPSText.h"
    3131#include <OgreTextAreaOverlayElement.h>
     32#include "core/CoreIncludes.h"
     33#include "GraphicsEngine.h"
    3234#include "util/Convert.h"
    33 #include "core/CoreIncludes.h"
    34 #include "core/Game.h"
    3535
    3636namespace orxonox
     
    5151        SUPER(DebugFPSText, tick, dt);
    5252
    53         float fps = Game::getInstance().getAvgFPS();
     53        float fps = GraphicsEngine::getInstance().getAverageFramesPerSecond();
    5454        this->setCaption(convertToString(fps));
    5555    }
  • code/branches/questsystem5/src/orxonox/overlays/debug/DebugRTRText.cc

    r2907 r2908  
    3232#include "core/CoreIncludes.h"
    3333#include "util/Convert.h"
    34 #include "core/Game.h"
     34#include "GraphicsEngine.h"
    3535
    3636namespace orxonox
     
    5151        SUPER(DebugRTRText, tick, dt);
    5252
    53         float rtr = Game::getInstance().getAvgTickTime();
     53        float rtr = GraphicsEngine::getInstance().getAverageTickTime();
    5454        this->setCaption(convertToString(rtr));
    5555    }
  • code/branches/questsystem5/src/orxonox/overlays/hud/CMakeLists.txt

    r2907 r2908  
    77  ChatOverlay.cc
    88  GametypeStatus.cc
    9   PongScore.cc
    109)
  • code/branches/questsystem5/src/orxonox/overlays/hud/HUDRadar.cc

    r2907 r2908  
    9494    void HUDRadar::displayObject(RadarViewable* object, bool bIsMarked)
    9595    {
    96         if (object == static_cast<RadarViewable*>(this->owner_))
     96        if (object == (RadarViewable*)this->owner_)
    9797            return;
    9898
  • code/branches/questsystem5/src/orxonox/overlays/notifications/NotificationQueue.cc

    r2907 r2908  
    410410        this->containers_.insert(container);
    411411        this->overlays_[notification] = container;
    412         this->addElement(container->overlay);
     412        this->insertElement(container->overlay, container->name);
    413413        this->size_= this->size_+1;
    414414
     
    429429            return false;
    430430       
    431         this->removeElement(container->overlay);
     431        this->removeElement(container->name);
    432432        this->containers_.erase(container);
    433433        this->overlays_.erase(container->notification);
  • code/branches/questsystem5/src/orxonox/pch/havepch/OrxonoxStableHeaders.h

    r2907 r2908  
    4545#  define WIN32_LEAN_AND_MEAN
    4646#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
    5048#include <Ogre.h>
    5149#include <CEGUI.h>
  • code/branches/questsystem5/src/orxonox/tools/BillboardSet.cc

    r2907 r2908  
    3737#include <OgreBillboard.h>
    3838
    39 #include "core/GameMode.h"
     39#include "core/Core.h"
    4040#include "util/Convert.h"
    4141#include "util/String.h"
     
    7272        try
    7373        {
    74             if (GameMode::showsGraphics())
     74            if (Core::showsGraphics())
    7575            {
    7676                this->billboardSet_ = scenemanager->createBillboardSet("Billboard" + convertToString(BillboardSet::billboardSetCounter_s++), count);
     
    9595        try
    9696        {
    97             if (GameMode::showsGraphics())
     97            if (Core::showsGraphics())
    9898            {
    9999                this->billboardSet_ = scenemanager->createBillboardSet("Billboard" + convertToString(BillboardSet::billboardSetCounter_s++), count);
  • code/branches/questsystem5/src/orxonox/tools/CMakeLists.txt

    r2907 r2908  
    55  Shader.cc
    66  TextureGenerator.cc
    7   TimeFactorListener.cc
    87  Timer.cc
    98  WindowEventListener.cc
  • code/branches/questsystem5/src/orxonox/tools/Mesh.cc

    r2907 r2908  
    3535#include <cassert>
    3636
    37 #include "core/GameMode.h"
     37#include "core/Core.h"
    3838#include "util/Convert.h"
    3939#include "util/String.h"
     
    6464            this->scenemanager_->destroyEntity(this->entity_);
    6565
    66         if (GameMode::showsGraphics())
     66        if (Core::showsGraphics())
    6767        {
    6868            try
     
    7070                this->entity_ = this->scenemanager_->createEntity("Mesh" + convertToString(Mesh::meshCounter_s++), meshsource);
    7171                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                 */
    8172            }
    8273            catch (...)
  • code/branches/questsystem5/src/orxonox/tools/ParticleInterface.cc

    r2907 r2908  
    4040#include <cassert>
    4141
    42 #include "GraphicsManager.h"
    43 #include "core/GameMode.h"
     42#include "GraphicsEngine.h"
     43#include "core/Core.h"
    4444#include "core/CoreIncludes.h"
    4545#include "util/Convert.h"
     
    6464        this->speedFactor_ = 1.0f;
    6565
    66         if (GameMode::showsGraphics())
     66        if (Core::showsGraphics())
    6767        {
    6868            try
     
    178178    {
    179179        this->detaillevel_ = level;
    180         if (GameMode::showsGraphics())
    181             this->detailLevelChanged(GraphicsManager::getInstance().getDetailLevelParticle());
     180        if (GraphicsEngine::getInstancePtr())
     181            this->detailLevelChanged(GraphicsEngine::getInstance().getDetailLevelParticle());
    182182    }
    183183
  • code/branches/questsystem5/src/orxonox/tools/ParticleInterface.h

    r2907 r2908  
    3737#include "core/OrxonoxClass.h"
    3838#include "util/Math.h"
    39 #include "tools/TimeFactorListener.h"
     39#include "gamestates/GSRoot.h"
    4040
    4141#define getAllEmitters() \
  • code/branches/questsystem5/src/orxonox/tools/Shader.cc

    r2907 r2908  
    3636#include <OgrePlugin.h>
    3737
    38 #include "core/GameMode.h"
     38#include "core/Core.h"
    3939#include "core/CoreIncludes.h"
    4040#include "core/Executor.h"
    41 #include "GraphicsManager.h"
     41#include "GraphicsEngine.h"
    4242#include "util/Exception.h"
    4343
     
    5959        this->compositorInstance_ = 0;
    6060        this->bVisible_ = true;
    61         this->bLoadCompositor_ = GameMode::showsGraphics();
     61        this->bLoadCompositor_ = Core::showsGraphics() && GraphicsEngine::getInstancePtr();
    6262        this->bViewportInitialized_ = false;
    6363        this->compositor_ = "";
     
    8686        if (this->bLoadCompositor_ && this->compositorInstance_)
    8787        {
    88             Ogre::Viewport* viewport = GraphicsManager::getInstance().getViewport();
     88            Ogre::Viewport* viewport = GraphicsEngine::getInstance().getViewport();
    8989            assert(viewport);
    9090            Ogre::CompositorManager::getSingleton().removeCompositor(viewport, this->compositor_);
     
    114114        if (this->bLoadCompositor_)
    115115        {
    116             Ogre::Viewport* viewport = GraphicsManager::getInstance().getViewport();
     116            Ogre::Viewport* viewport = GraphicsEngine::getInstance().getViewport();
    117117            assert(viewport);
    118118            if (this->oldcompositor_ != "")
     
    246246    Shader::ParameterPointer* Shader::getParameterPointer(const std::string& material, size_t technique, size_t pass, const std::string& parameter)
    247247    {
    248         if (!GameMode::showsGraphics() || !Shader::bLoadedCgPlugin_s)
     248        if (!Core::showsGraphics() || !Shader::bLoadedCgPlugin_s)
    249249            return 0;
    250250
  • code/branches/questsystem5/src/orxonox/tools/Timer.h

    r2907 r2908  
    6464#include "core/Executor.h"
    6565#include "core/OrxonoxClass.h"
    66 #include "tools/TimeFactorListener.h"
     66#include "gamestates/GSRoot.h"
    6767
    6868namespace orxonox
  • code/branches/questsystem5/src/orxonox/tools/WindowEventListener.h

    r2907 r2908  
    4949
    5050            /** Window has resized */
    51             virtual void windowResized(unsigned int newWidth, unsigned int newHeight) { }
     51            virtual void windowResized(int newWidth, int newHeight) { }
    5252
    5353            /** Window has lost/gained focus */
Note: See TracChangeset for help on using the changeset viewer.