Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2896


Ignore:
Timestamp:
Apr 6, 2009, 1:59:00 AM (15 years ago)
Author:
landauf
Message:

Merged gui branch back to trunk.

I did 2 small changes in IngameManager.cc on line 777 and 888 (yes, really), because const_reverse_iterator strangely doesn't work on MinGW.

Location:
code/trunk
Files:
6 deleted
185 edited
10 copied

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/bin/client1.bat.in

    r2893 r2896  
    11title @PROJECT_NAME@
    22path @ORXONOX_RUNTIME_LIBRARY_DIRECTORY_WINDOWS@;%path%
    3 @CURRENT_RUNTIME_DIR_WINDOWS@\@ORXONOX_EXECUTABLE_NAME@ --state client --directory client1
     3@CURRENT_RUNTIME_DIR_WINDOWS@\@ORXONOX_EXECUTABLE_NAME@ --client --writingPathSuffix client1
    44pause
  • code/trunk/bin/client1.in

    r2730 r2896  
    22# convenience script for starting orxonox on Linux
    33
    4 exec @CURRENT_RUNTIME_DIR@/@ORXONOX_EXECUTABLE_NAME@ --state client --directory client1 $@
     4exec @CURRENT_RUNTIME_DIR@/@ORXONOX_EXECUTABLE_NAME@ --client --writingPathSuffix client1 $@
  • code/trunk/bin/client2.bat.in

    r2893 r2896  
    11title @PROJECT_NAME@
    22path @ORXONOX_RUNTIME_LIBRARY_DIRECTORY_WINDOWS@;%path%
    3 @CURRENT_RUNTIME_DIR_WINDOWS@\@ORXONOX_EXECUTABLE_NAME@ --state client --directory client2
     3@CURRENT_RUNTIME_DIR_WINDOWS@\@ORXONOX_EXECUTABLE_NAME@ --client --writingPathSuffix client2
    44pause
  • code/trunk/bin/client2.in

    r2730 r2896  
    22# convenience script for starting orxonox on Linux
    33
    4 exec @CURRENT_RUNTIME_DIR@/@ORXONOX_EXECUTABLE_NAME@ --state client --directory client2 $@
     4exec @CURRENT_RUNTIME_DIR@/@ORXONOX_EXECUTABLE_NAME@ --client --writingPathSuffix client2 $@
  • code/trunk/bin/dedicated.bat.in

    r2893 r2896  
    11title @PROJECT_NAME@
    22path @ORXONOX_RUNTIME_LIBRARY_DIRECTORY_WINDOWS@;%path%
    3 @CURRENT_RUNTIME_DIR_WINDOWS@\@ORXONOX_EXECUTABLE_NAME@ --state dedicated --directory dedicated
     3@CURRENT_RUNTIME_DIR_WINDOWS@\@ORXONOX_EXECUTABLE_NAME@ --dedicated --writingPathSuffix dedicated
    44pause
  • code/trunk/bin/dedicated.in

    r2730 r2896  
    22# convenience script for starting orxonox on Linux
    33
    4 exec @CURRENT_RUNTIME_DIR@/@ORXONOX_EXECUTABLE_NAME@ --state dedicated --directory dedicated $@
     4exec @CURRENT_RUNTIME_DIR@/@ORXONOX_EXECUTABLE_NAME@ --dedicated --writingPathSuffix dedicated $@
  • code/trunk/bin/run.bat.in

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/bin/server.bat.in

    r2893 r2896  
    11title @PROJECT_NAME@
    22path @ORXONOX_RUNTIME_LIBRARY_DIRECTORY_WINDOWS@;%path%
    3 @CURRENT_RUNTIME_DIR_WINDOWS@\@ORXONOX_EXECUTABLE_NAME@ --state server --directory server
     3@CURRENT_RUNTIME_DIR_WINDOWS@\@ORXONOX_EXECUTABLE_NAME@ --server --writingPathSuffix server
    44pause
  • code/trunk/bin/server.in

    r2730 r2896  
    22# convenience script for starting orxonox on Linux
    33
    4 exec @CURRENT_RUNTIME_DIR@/@ORXONOX_EXECUTABLE_NAME@ --state server --directory server $@
     4exec @CURRENT_RUNTIME_DIR@/@ORXONOX_EXECUTABLE_NAME@ --server --writingPathSuffix server $@
  • code/trunk/bin/standalone.bat.in

    r2762 r2896  
    11title @PROJECT_NAME@
    22path @ORXONOX_RUNTIME_LIBRARY_DIRECTORY_WINDOWS@;%path%
    3 @CURRENT_RUNTIME_DIR_WINDOWS@\@ORXONOX_EXECUTABLE_NAME@ --state standalone --directory standalone
     3@CURRENT_RUNTIME_DIR_WINDOWS@\@ORXONOX_EXECUTABLE_NAME@ --standalone --writingPathSuffix standalone
    44pause
  • code/trunk/bin/standalone.in

    r2762 r2896  
    22# convenience script for starting orxonox on Linux
    33
    4 exec @CURRENT_RUNTIME_DIR@/@ORXONOX_EXECUTABLE_NAME@ --state standalone --directory standalone $@
     4exec @CURRENT_RUNTIME_DIR@/@ORXONOX_EXECUTABLE_NAME@ --standalone --writingPathSuffix standalone $@
  • code/trunk/cmake/BuildConfig.cmake

    r2748 r2896  
    9090################ Compiler Config ################
    9191
    92 OPTION(EXTRA_COMPILER_WARNINGS "Enable some extra warnings (heavily pollutes the output)")
     92OPTION(EXTRA_COMPILER_WARNINGS "Enable some extra warnings (heavily pollutes the output)" FALSE)
    9393
    9494INCLUDE(FlagUtilities)
  • code/trunk/cmake/BuildConfigGCC.cmake

    r2868 r2896  
    6363ADD_COMPILER_FLAGS("-Wno-sign-compare" GCC_NO_SYSTEM_HEADER_SUPPORT CACHE)
    6464
     65# For newer GCC (4.3 and above), don't display hundreds of annoying deprecated
     66# messages. Other versions don't seem to show any such warnings at all.
     67ADD_COMPILER_FLAGS("-Wno-deprecated" CXX)
     68
    6569# Increase warning level if requested
    6670IF(EXTRA_COMPILER_WARNINGS)
  • code/trunk/cmake/FindDirectX.cmake

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/cmake/LibraryConfigTardis.cmake

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/core/CMakeLists.txt

    r2710 r2896  
    2424  Core.cc
    2525  Event.cc
     26  Game.cc
     27  GameMode.cc
    2628  GameState.cc
    2729  Language.cc
     
    2931  ObjectListBase.cc
    3032  OrxonoxClass.cc
    31   RootGameState.cc
    3233
    3334  # command
  • code/trunk/src/core/Clock.h

    r2171 r2896  
    4545    class _CoreExport Clock
    4646    {
    47         friend class RootGameState;
    48 
    4947    public:
    5048        Clock();
    5149        ~Clock();
     50
     51        void capture();
    5252
    5353        unsigned long long getMicroseconds()   const { return tickTime_; }
     
    6363    private:
    6464        Clock(const Clock& instance);
    65         void capture();
    6665
    6766        Ogre::Timer*       timer_;
  • code/trunk/src/core/ConfigFileManager.cc

    r2759 r2896  
    190190        this->bUpdated_ = true;
    191191
    192         return this->entries_.insert(this->entries_.end(), (ConfigFileEntry*)(new ConfigFileEntryValue(name, fallback, bString)));
     192        return this->entries_.insert(this->entries_.end(), static_cast<ConfigFileEntry*>(new ConfigFileEntryValue(name, fallback, bString)));
    193193    }
    194194
     
    207207
    208208        if (index == 0)
    209             return this->entries_.insert(this->entries_.end(), (ConfigFileEntry*)(new ConfigFileEntryVectorValue(name, index, fallback, bString)));
    210         else
    211             return this->entries_.insert(++this->getEntryIterator(name, index - 1, "", bString), (ConfigFileEntry*)(new ConfigFileEntryVectorValue(name, index, fallback, bString)));
     209            return this->entries_.insert(this->entries_.end(), static_cast<ConfigFileEntry*>(new ConfigFileEntryVectorValue(name, index, fallback, bString)));
     210        else
     211            return this->entries_.insert(++this->getEntryIterator(name, index - 1, "", bString), static_cast<ConfigFileEntry*>(new ConfigFileEntryVectorValue(name, index, fallback, bString)));
    212212    }
    213213
  • code/trunk/src/core/Core.cc

    r2759 r2896  
    2222 *   Author:
    2323 *      Fabian 'x3n' Landau
     24 *      Reto Grieder
    2425 *   Co-authors:
    25  *      Reto Grieder
     26 *      ...
    2627 *
    2728 */
     
    4142
    4243#ifdef ORXONOX_PLATFORM_WINDOWS
     44#  ifndef WIN32_LEAN_AND_MEAN
     45#    define WIN32_LEAN_AND_MEAN
     46#  endif
    4347#  include <windows.h>
    4448#elif defined(ORXONOX_PLATFORM_APPLE)
     
    5155
    5256#include "SpecialConfig.h"
     57#include "util/Debug.h"
    5358#include "util/Exception.h"
     59#include "util/SignalHandler.h"
     60#include "Clock.h"
     61#include "CommandExecutor.h"
     62#include "CommandLine.h"
     63#include "ConfigFileManager.h"
     64#include "ConfigValueIncludes.h"
     65#include "CoreIncludes.h"
     66#include "Factory.h"
     67#include "Identifier.h"
    5468#include "Language.h"
    55 #include "CoreIncludes.h"
    56 #include "ConfigValueIncludes.h"
    5769#include "LuaBind.h"
    58 #include "CommandLine.h"
     70#include "Shell.h"
     71#include "TclBind.h"
     72#include "TclThreadManager.h"
    5973
    6074namespace orxonox
     
    6781    static boost::filesystem::path logPath_g;                   //!< Path to the log file folder
    6882
    69     bool Core::bShowsGraphics_s = false;
    70     bool Core::bHasServer_s     = false;
    71     bool Core::bIsClient_s      = false;
    72     bool Core::bIsStandalone_s  = false;
    73     bool Core::bIsMaster_s      = false;
    74 
    75     bool Core::isDevBuild_s     = false;
    7683    Core* Core::singletonRef_s  = 0;
    7784
    7885    SetCommandLineArgument(mediaPath, "").information("PATH");
    79     SetCommandLineArgument(directory, "").information("DIR");
    80 
    81     /**
    82         @brief Constructor: Registers the object and sets the config-values.
    83         @param A reference to a global variable, used to avoid an infinite recursion in getSoftDebugLevel()
    84     */
     86    SetCommandLineArgument(writingPathSuffix, "").information("DIR");
     87    SetCommandLineArgument(settingsFile, "orxonox.ini");
     88    SetCommandLineArgument(limitToCPU, 0).information("0: off | #cpu");
     89
    8590    Core::Core()
    8691    {
     
    8994        assert(Core::singletonRef_s == 0);
    9095        Core::singletonRef_s = this;
    91 
    92         this->bInitializeRandomNumberGenerator_ = false;
    93         this->setConfigValues();
     96    }
     97
     98    void Core::initialise(int argc, char** argv)
     99    {
     100        // Parse command line arguments fist
     101        try
     102        {
     103            CommandLine::parseAll(argc, argv);
     104        }
     105        catch (ArgumentException& ex)
     106        {
     107            COUT(1) << ex.what() << std::endl;
     108            COUT(0) << "Usage:" << std::endl << "orxonox " << CommandLine::getUsageInformation() << std::endl;
     109        }
     110
     111        // limit the main thread to the first core so that QueryPerformanceCounter doesn't jump
     112        // do this after ogre has initialised. Somehow Ogre changes the settings again (not through
     113        // the timer though).
     114        int limitToCPU = CommandLine::getValue("limitToCPU");
     115        if (limitToCPU > 0)
     116            setThreadAffinity((unsigned int)limitToCPU);
     117
     118        // Determine and set the location of the executable
     119        setExecutablePath();
     120
     121        // Determine whether we have an installed or a binary dir run
     122        // The latter occurs when simply running from the build directory
     123        checkDevBuild();
     124
     125        // Make sure the directories we write in exist or else make them
     126        createDirectories();
     127
     128        // create a signal handler (only active for linux)
     129        // This call is placed as soon as possible, but after the directories are set
     130        this->signalHandler_ = new SignalHandler();
     131        this->signalHandler_->doCatch(executablePath_g.string(), Core::getLogPathString() + "orxonox_crash.log");
    94132
    95133        // Set the correct log path. Before this call, /tmp (Unix) or %TEMP% was used
    96134        OutputHandler::getOutStream().setLogPath(Core::getLogPathString());
    97135
     136        // Manage ini files and set the default settings file (usually orxonox.ini)
     137        this->configFileManager_ = new ConfigFileManager();
     138        this->configFileManager_->setFilename(ConfigFileType::Settings,
     139            CommandLine::getValue("settingsFile").getString());
     140
     141        this->languageInstance_ = new Language();
     142
     143        // Do this soon after the ConfigFileManager has been created to open up the
     144        // possibility to configure everything below here
     145        this->setConfigValues();
     146
    98147        // Possible media path override by the command line
    99148        if (!CommandLine::getArgument("mediaPath")->hasDefaultValue())
     
    102151            Core::tsetMediaPath(CommandLine::getValue("mediaPath"));
    103152        }
     153
     154        // Create the lua interface
     155        this->luaBind_ = new LuaBind();
     156
     157        // initialise Tcl
     158        this->tclBind_ = new TclBind(Core::getMediaPathString());
     159        this->tclThreadManager_ = new TclThreadManager(tclBind_->getTclInterpreter());
     160
     161        // create a shell
     162        this->shell_ = new Shell();
     163
     164        // creates the class hierarchy for all classes with factories
     165        Factory::createClassHierarchy();
     166       
     167        this->loaded_ = true;
    104168    }
    105169
     
    109173    Core::~Core()
    110174    {
     175        this->loaded_ = false;
     176
     177        delete this->shell_;
     178        delete this->tclThreadManager_;
     179        delete this->tclBind_;
     180        delete this->luaBind_;
     181        delete this->languageInstance_;
     182        delete this->configFileManager_;
     183        delete this->signalHandler_;
     184
     185        // Destroy command line arguments
     186        CommandLine::destroyAllArguments();
     187        // Also delete external console command that don't belong to an Identifier
     188        CommandExecutor::destroyExternalCommands();
     189
    111190        assert(Core::singletonRef_s);
    112191        Core::singletonRef_s = 0;
     
    292371    }
    293372
    294     /**
    295     @brief
    296         Performs the rather lower level operations just after
    297         int main() has been called.
    298     @remarks
    299         This gets called AFTER pre-main stuff like AddFactory,
    300         SetConsoleCommand, etc.
    301     */
    302     /*static*/ void Core::postMainInitialisation()
    303     {
    304         // set location of the executable
    305         Core::setExecutablePath();
    306 
    307         // Determine whether we have an installed or a binary dir run
    308         // The latter occurs when simply running from the build directory
    309         Core::checkDevBuild();
    310 
    311         // Make sure the directories we write in exist or else make them
    312         Core::createDirectories();
     373
     374    /**
     375    @note
     376        The code of this function has been copied and adjusted from OGRE, an open source graphics engine.
     377            (Object-oriented Graphics Rendering Engine)
     378        For the latest info, see http://www.ogre3d.org/
     379
     380        Copyright (c) 2000-2008 Torus Knot Software Ltd
     381
     382        OGRE is licensed under the LGPL. For more info, see OGRE license.
     383    */
     384    void Core::setThreadAffinity(int limitToCPU)
     385    {
     386        if (limitToCPU <= 0)
     387            return;
     388
     389#ifdef ORXONOX_PLATFORM_WINDOWS
     390        unsigned int coreNr = limitToCPU - 1;
     391        // Get the current process core mask
     392        DWORD procMask;
     393        DWORD sysMask;
     394#  if _MSC_VER >= 1400 && defined (_M_X64)
     395        GetProcessAffinityMask(GetCurrentProcess(), (PDWORD_PTR)&procMask, (PDWORD_PTR)&sysMask);
     396#  else
     397        GetProcessAffinityMask(GetCurrentProcess(), &procMask, &sysMask);
     398#  endif
     399
     400        // If procMask is 0, consider there is only one core available
     401        // (using 0 as procMask will cause an infinite loop below)
     402        if (procMask == 0)
     403            procMask = 1;
     404
     405        // if the core specified with coreNr is not available, take the lowest one
     406        if (!(procMask & (1 << coreNr)))
     407            coreNr = 0;
     408
     409        // Find the lowest core that this process uses and coreNr suggests
     410        DWORD threadMask = 1;
     411        while ((threadMask & procMask) == 0 || (threadMask < (1u << coreNr)))
     412            threadMask <<= 1;
     413
     414        // Set affinity to the first core
     415        SetThreadAffinityMask(GetCurrentThread(), threadMask);
     416#endif
    313417    }
    314418
     
    317421        Compares the executable path with the working directory
    318422    */
    319     /*static*/ void Core::setExecutablePath()
     423    void Core::setExecutablePath()
    320424    {
    321425#ifdef ORXONOX_PLATFORM_WINDOWS
     
    369473        don't write the logs and config files to ~/.orxonox
    370474    */
    371     /*static*/ void Core::checkDevBuild()
     475    void Core::checkDevBuild()
    372476    {
    373477        if (boost::filesystem::exists(executablePath_g / "orxonox_dev_build.keep_me"))
    374478        {
    375479            COUT(1) << "Running from the build tree." << std::endl;
    376             Core::isDevBuild_s = true;
     480            Core::isDevBuild_ = true;
    377481            mediaPath_g  = ORXONOX_MEDIA_DEV_PATH;
    378482            configPath_g = ORXONOX_CONFIG_DEV_PATH;
     
    385489            boost::filesystem::path relativeExecutablePath(ORXONOX_RUNTIME_INSTALL_PATH);
    386490            rootPath_g = executablePath_g;
    387             while (!boost::filesystem::equivalent(rootPath_g / relativeExecutablePath, executablePath_g) || rootPath_g.empty())
     491            while (!boost::filesystem::equivalent(rootPath_g / relativeExecutablePath, executablePath_g) && !rootPath_g.empty())
    388492                rootPath_g = rootPath_g.branch_path();
    389493            if (rootPath_g.empty())
     
    416520
    417521        // Option to put all the config and log files in a separate folder
    418         if (!CommandLine::getArgument("directory")->hasDefaultValue())
    419         {
    420             std::string directory(CommandLine::getValue("directory").getString());
     522        if (!CommandLine::getArgument("writingPathSuffix")->hasDefaultValue())
     523        {
     524            std::string directory(CommandLine::getValue("writingPathSuffix").getString());
    421525            configPath_g = configPath_g / directory;
    422526            logPath_g    = logPath_g    / directory;
     
    429533        if necessary. Otherwise me might have problems opening those files.
    430534    */
    431     /*static*/ void Core::createDirectories()
     535    void Core::createDirectories()
    432536    {
    433537        std::vector<std::pair<boost::filesystem::path, std::string> > directories;
     
    451555        }
    452556    }
     557
     558    void Core::update(const Clock& time)
     559    {
     560        this->tclThreadManager_->update(time);
     561    }
    453562}
  • code/trunk/src/core/Core.h

    r2759 r2896  
    2222 *   Author:
    2323 *      Fabian 'x3n' Landau
     24 *      Reto Grieder
    2425 *   Co-authors:
    25  *      Reto Grieder
     26 *      ...
    2627 *
    2728 */
     
    4445#include "util/OutputHandler.h"
    4546
    46 // Only allow main to access postMainInitialisation, so we need a forward declaration
    47 int main(int, char**);
    4847// boost::filesystem header has quite a large tail, use forward declaration
    4948namespace boost { namespace filesystem
     
    5958    class _CoreExport Core : public OrxonoxClass
    6059    {
    61         friend int ::main(int, char**); // sets isDevBuild_s
    62 
    6360        public:
    6461            Core();
    6562            ~Core();
     63
     64            void initialise(int argc, char** argv);
    6665            void setConfigValues();
     66
     67            void update(const Clock& time);
    6768
    6869            static Core& getInstance() { assert(Core::singletonRef_s); return *Core::singletonRef_s; }
     
    7273            static const std::string& getLanguage();
    7374            static void  resetLanguage();
    74 
    75             static bool isDevBuild() { return Core::isDevBuild_s; }
    7675
    7776            static void tsetMediaPath(const std::string& path)
     
    8483            static std::string getLogPathString();
    8584
    86             // fast access global variables.
    87             static bool showsGraphics() { return bShowsGraphics_s; }
    88             static bool hasServer()     { return bHasServer_s; }
    89             static bool isClient()      { return bIsClient_s; }
    90             static bool isStandalone()  { return bIsStandalone_s; }
    91             static bool isMaster()      { return bIsMaster_s; }
    92             static void setShowsGraphics(bool val) { bShowsGraphics_s = val; updateIsMaster(); }
    93             static void setHasServer    (bool val) { bHasServer_s     = val; updateIsMaster(); }
    94             static void setIsClient     (bool val) { bIsClient_s      = val; updateIsMaster(); }
    95             static void setIsStandalone (bool val) { bIsStandalone_s  = val; updateIsMaster(); }
    96             static void updateIsMaster  ()         { bIsMaster_s      = (bHasServer_s || bIsStandalone_s); }
    97 
    9885        private:
    9986            Core(const Core&);
     87
     88            void checkDevBuild();
     89            void setExecutablePath();
     90            void createDirectories();
     91            void setThreadAffinity(int limitToCPU);
     92
    10093            void resetLanguageIntern();
    10194            void initializeRandomNumberGenerator();
     
    10598            void _tsetMediaPath(const std::string& path);
    10699
    107             static void postMainInitialisation();
    108             static void checkDevBuild();
    109             static void setExecutablePath();
    110             static void createDirectories();
     100            // Singletons
     101            ConfigFileManager*    configFileManager_;
     102            Language*             languageInstance_;
     103            LuaBind*              luaBind_;
     104            Shell*                shell_;
     105            SignalHandler*        signalHandler_;
     106            TclBind*              tclBind_;
     107            TclThreadManager*     tclThreadManager_;
    111108
    112109            int softDebugLevel_;                            //!< The debug level
     
    117114            bool bInitializeRandomNumberGenerator_;         //!< If true, srand(time(0)) is called
    118115            std::string mediaPathString_;                   //!< Path to the data/media file folder as string
    119 
    120             static bool bShowsGraphics_s;                   //!< global variable that tells whether to show graphics
    121             static bool bHasServer_s;                       //!< global variable that tells whether this is a server
    122             static bool bIsClient_s;
    123             static bool bIsStandalone_s;
    124             static bool bIsMaster_s;
    125 
    126             static bool isDevBuild_s;                       //!< True for builds in the build directory (not installed)
     116            bool isDevBuild_;                               //!< True for builds in the build directory (not installed)
     117            bool loaded_;                                   //!< Only true if constructor was interrupted
    127118
    128119            static Core* singletonRef_s;
  • code/trunk/src/core/CorePrereqs.h

    r2710 r2896  
    166166
    167167  // game states
    168   class GameStateBase;
    169   template <class ParentType>
     168  class Game;
    170169  class GameState;
    171   class RootGameState;
     170  struct GameStateTreeNode;
    172171
    173172  // input
  • code/trunk/src/core/GameState.cc

    r1764 r2896  
    3030@file
    3131@brief
    32     Implementation of GameStateBase class.
     32    Implementation of GameState class.
    3333*/
    3434
    3535#include "GameState.h"
     36#include <cassert>
    3637#include "util/Debug.h"
    3738#include "util/Exception.h"
     39#include "Clock.h"
    3840
    3941namespace orxonox
     
    4345        Constructor only initialises variables and sets the name permanently.
    4446    */
    45     GameStateBase::GameStateBase(const std::string& name)
     47    GameState::GameState(const std::string& name)
    4648        : name_(name)
    47         //, parent_(0)
    48         , activeChild_(0)
    49         //, bPausegetParent()(false)
     49        , parent_(0)
    5050    {
    51         Operations temp = {false, false, false, false, false};
    52         this->operation_ = temp;
     51        this->activity_.activating   = false;
     52        this->activity_.active       = false;
     53        this->activity_.deactivating = false;
     54        this->activity_.suspended    = false;
     55        this->activity_.topState     = false;
     56        this->activity_.updating     = false;
    5357    }
    5458
     
    5761        Destructor only checks that we don't delete an active state.
    5862    */
    59     GameStateBase::~GameStateBase()
     63    GameState::~GameState()
    6064    {
    61         OrxAssert(this->operation_.active == false, "Deleting an active GameState is a very bad idea..");
     65        OrxAssert(this->activity_.active == false, "Deleting an active GameState is a very bad idea..");
    6266    }
    6367
     
    6973        The state to be added.
    7074    */
    71     void GameStateBase::addChild(GameStateBase* state)
     75    void GameState::addChild(GameState* state)
    7276    {
    73         if (!state)
    74             return;
    75         // check if the state/tree to be added has states in it that already exist in this tree.
    76         for (std::map<std::string, GameStateBase*>::const_iterator it = state->allChildren_.begin();
    77             it != state->allChildren_.end(); ++it)
     77        assert(state != NULL);
     78
     79        std::map<std::string, GameState*>::const_iterator it = this->children_.find(state->getName());
     80        if (it == this->children_.end())
    7881        {
    79             if (this->getState(it->second->getName()))
    80             {
    81                 ThrowException(GameState, "Cannot add a GameState to the hierarchy twice.");
    82                 return;
    83             }
     82            this->children_[state->getName()] = state;
     83            // mark us as parent
     84            state->setParent(this);
    8485        }
    85         if (this->getState(state->name_))
     86        else
    8687        {
    87             ThrowException(GameState, "Cannot add a GameState to the hierarchy twice.");
    88             return;
     88            ThrowException(GameState, "Cannot add two children with the same name");
    8989        }
    90         // Make sure we don't add a tree that already has an active state.
    91         if (state->getCurrentState())
    92         {
    93             ThrowException(GameState, "Cannot merge a tree that is already active.");
    94             return;
    95         }
    96 
    97         // merge the child's children into this tree
    98         for (std::map<std::string, GameStateBase*>::const_iterator it = state->allChildren_.begin();
    99             it != state->allChildren_.end(); ++it)
    100             this->grandchildAdded(state, it->second);
    101         // merge 'state' into this tree
    102         this->grandchildAdded(state, state);
    103 
    104         // mark us as parent
    105         state->setParent(this);
    10690    }
    10791
     
    11397        GameState by instance pointer
    11498    */
    115     void GameStateBase::removeChild(GameStateBase* state)
     99    void GameState::removeChild(GameState* state)
    116100    {
    117         std::map<GameStateBase*, GameStateBase*>::iterator it = this->grandchildrenToChildren_.find(state);
    118         if (it != this->grandchildrenToChildren_.end())
    119         {
    120             if (state->isInSubtree(getCurrentState()))
    121             {
    122                 ThrowException(GameState, "Cannot remove an active game state child '"
    123                     + state->getName() + "' from '" + name_ + "'.");
    124                 //COUT(2) << "Warning: Cannot remove an active game state child '" << state->getName()
    125                 //    << "' from '" << name_ << "'." << std::endl;
    126             }
    127             else
    128             {
    129                 for (std::map<GameStateBase*, GameStateBase*>::const_iterator it = state->grandchildrenToChildren_.begin();
    130                     it != state->grandchildrenToChildren_.end(); ++it)
    131                     this->grandchildRemoved(it->first);
    132                 this->grandchildRemoved(state);
    133             }
    134         }
     101        assert(state != NULL);
     102
     103        std::map<std::string, GameState*>::iterator it = this->children_.find(state->getName());
     104        if (it != this->children_.end())
     105            this->children_.erase(it);
    135106        else
    136107        {
    137108            ThrowException(GameState, "Game state '" + name_ + "' doesn't have a child named '"
    138109                + state->getName() + "'.");
    139             //COUT(2) << "Warning: Game state '" << name_ << "' doesn't have a child named '"
    140             //    << state->getName() << "'. Removal skipped." << std::endl;
    141110        }
    142111    }
    143112
    144     /**
    145     @brief
    146         Removes a child by name. This splits the tree in two parts,
    147         each of them functional on its own.
    148     @param state
    149         GameState by name
    150     */
    151 
    152     void GameStateBase::removeChild(const std::string& name)
     113    void GameState::activateInternal()
    153114    {
    154         GameStateBase* state = getState(name);
    155         if (state)
    156         {
    157             removeChild(state);
    158         }
    159         else
    160         {
    161             ThrowException(GameState, "GameState '" + name + "' doesn't exist.");
    162             //COUT(2) << "Warning: GameState '" << name << "' doesn't exist." << std::endl;
    163         }
     115        this->activity_.activating = true;
     116        this->activate();
     117        this->activity_.activating = false;
     118        this->activity_.active = true;
    164119    }
    165120
    166     /**
    167     @brief
    168         Tells a state that one of its children has added a child. This is necessary
    169         to fill the internal maps correctly.
    170     @param child
    171         The child who notices this state.
    172     @param grandchild
    173         The child that has been added.
    174     */
    175     inline void GameStateBase::grandchildAdded(GameStateBase* child, GameStateBase* grandchild)
     121    void GameState::deactivateInternal()
    176122    {
    177         // fill the two maps correctly.
    178         this->allChildren_[grandchild->getName()] = grandchild;
    179         this->grandchildrenToChildren_[grandchild] = child;
    180         if (this->getParent())
    181             this->getParent()->grandchildAdded(this, grandchild);
     123        this->activity_.active = false;
     124        this->activity_.deactivating = true;
     125        this->activate();
     126        this->activity_.deactivating = false;
     127        this->activity_.suspended = false;
     128        this->activity_.updating = false;
    182129    }
    183130
    184     /**
    185     @brief
    186         Tells a state that one of its children has removed a child. This is necessary
    187         to fill the internal maps correctly.
    188     @param child
    189         The child who notices this state.
    190     @param grandchild
    191         The child that has been removed.
    192     */
    193     inline void GameStateBase::grandchildRemoved(GameStateBase* grandchild)
     131    void GameState::updateInternal(const Clock& time)
    194132    {
    195         // adjust the two maps correctly.
    196         this->allChildren_.erase(grandchild->getName());
    197         this->grandchildrenToChildren_.erase(grandchild);
    198         if (this->getParent())
    199             this->getParent()->grandchildRemoved(grandchild);
    200     }
    201 
    202     /**
    203     @brief
    204         Checks whether a specific game states exists in the hierarchy.
    205     @remarks
    206         Remember that the every node has a map with all its child nodes.
    207     */
    208     GameStateBase* GameStateBase::getState(const std::string& name)
    209     {
    210         if (this->getParent())
    211             return this->getParent()->getState(name);
    212         else
    213         {
    214             // The map only contains children, so check ourself first
    215             if (name == this->name_)
    216                 return this;
    217             // Search in the map. If there is no entry, we can be sure the state doesn't exist.
    218             std::map<std::string, GameStateBase*>::const_iterator it = this->allChildren_.find(name);
    219             return (it!= this->allChildren_.end() ? it->second : 0);
    220         }
    221     }
    222 
    223     /**
    224     @brief
    225         Returns the root node of the tree.
    226     */
    227     GameStateBase* GameStateBase::getRoot()
    228     {
    229         if (this->getParent())
    230             return this->getParent()->getRoot();
    231         else
    232             return this;
    233     }
    234 
    235     /**
    236     @brief
    237         Returns the current active state.
    238     @remarks
    239         Remember that the current active state is the one that does not
    240         have active children itself. Many states can be active at once.
    241     */
    242     GameStateBase* GameStateBase::getCurrentState()
    243     {
    244         if (this->operation_.active)
    245         {
    246             if (this->activeChild_)
    247                 return this->activeChild_->getCurrentState();
    248             else
    249                 return this;
    250         }
    251         else
    252         {
    253             if (this->getParent())
    254                 return this->getParent()->getCurrentState();
    255             else
    256                 return 0;
    257         }
    258     }
    259 
    260     /**
    261     @brief
    262         Determines whether 'state' is in this subtree, including this node.
    263     */
    264     bool GameStateBase::isInSubtree(GameStateBase* state) const
    265     {
    266         return (grandchildrenToChildren_.find(state) != grandchildrenToChildren_.end()
    267                 || state == this);
    268     }
    269 
    270     /**
    271     @brief
    272         Makes a state transition according to the state tree. You can choose any state
    273         in the tree to do the call. The function finds the current state on its own.
    274     @param state
    275         The state to be entered, has to exist in the tree.
    276     */
    277     void GameStateBase::requestState(const std::string& name)
    278     {
    279         assert(getRoot());
    280         getRoot()->requestState(name);
    281     }
    282 
    283     /**
    284     @brief
    285         Internal method that actually makes the state transition. Since it is internal,
    286         the method can assume certain things to be granted (like 'this' is always active).
    287     */
    288     void GameStateBase::makeTransition(GameStateBase* source, GameStateBase* destination)
    289     {
    290         if (source == this->getParent())
    291         {
    292             // call is from the parent
    293             this->activate();
    294         }
    295         else if (source == 0)
    296         {
    297             // call was just started by root
    298             // don't do anyting yet
    299         }
    300         else
    301         {
    302             // call is from a child
    303             this->activeChild_ = 0;
    304         }
    305 
    306         if (destination == this)
    307             return;
    308 
    309         // Check for 'destination' in the children map first
    310         std::map<GameStateBase*, GameStateBase*>::const_iterator it
    311             = this->grandchildrenToChildren_.find(destination);
    312         if (it != this->grandchildrenToChildren_.end())
    313         {
    314             // child state. Don't use 'state', might be a grandchild!
    315             this->activeChild_ = it->second;
    316             it->second->makeTransition(this, destination);
    317         }
    318         else
    319         {
    320             // parent. We can be sure of this.
    321             assert(this->getParent() != 0);
    322 
    323             this->deactivate();
    324             this->getParent()->makeTransition(this, destination);
    325         }
    326     }
    327 
    328     /**
    329     @brief
    330         Activates the state. Only sets bActive_ to true and notifies the parent.
    331     */
    332     void GameStateBase::activate()
    333     {
    334         this->operation_.active = true;
    335         this->operation_.entering = true;
    336         this->enter();
    337         this->operation_.entering = false;
    338     }
    339 
    340     /**
    341         Activates the state. Only sets bActive_ to false and notifies the parent.
    342     */
    343     void GameStateBase::deactivate()
    344     {
    345         this->operation_.leaving = true;
    346         this->leave();
    347         this->operation_.leaving = false;
    348         this->operation_.active = false;
    349     }
    350 
    351     /**
    352     @brief
    353         Update method that calls ticked() with enclosed bRunning_ = true
    354         If there was a state transition request within ticked() then this
    355         method will transition in the end.
    356     @param dt Delta time
    357     @note
    358         This method is not virtual! You cannot override it therefore.
    359     */
    360     void GameStateBase::tick(const Clock& time)
    361     {
    362         this->operation_.running = true;
    363         this->ticked(time);
    364         this->operation_.running = false;
     133        this->activity_.updating = true;
     134        this->update(time);
     135        this->activity_.updating = false;
    365136    }
    366137}
  • code/trunk/src/core/GameState.h

    r1755 r2896  
    3939
    4040#include <string>
    41 #include <vector>
    4241#include <map>
    43 #include <cassert>
    44 #include "Clock.h"
     42#include "CorePrereqs.h"
    4543
    4644namespace orxonox
     
    6058        Then Bar stores Foo in map by its name. The other one then maps Foo to Foofoo.
    6159    */
    62     class _CoreExport GameStateBase
     60    class _CoreExport GameState
    6361    {
    64         friend class RootGameState;
    65         template <class ParentType>
    66         friend class GameState;
     62        friend class Game;
    6763
    6864    public:
     
    7167            Gives information about what the GameState is currently doing
    7268        */
    73         struct Operations
     69        struct State
    7470        {
    75             unsigned active    : 1;
    76             unsigned entering  : 1;
    77             unsigned leaving   : 1;
    78             unsigned running   : 1;
    79             unsigned suspended : 1;
     71            unsigned active       : 1;
     72            unsigned activating   : 1;
     73            unsigned deactivating : 1;
     74            unsigned updating     : 1;
     75            unsigned suspended    : 1;
     76            unsigned topState     : 1;
    8077        };
    8178
    8279    public:
    83         virtual ~GameStateBase();
     80        GameState(const std::string& name);
     81        virtual ~GameState();
    8482
    8583        const std::string& getName() const { return name_; }
    86         const Operations getOperation() const { return this->operation_; }
    87         bool isInSubtree(GameStateBase* state) const;
     84        State getActivity() const    { return this->activity_; }
     85        GameState* getParent() const       { return this->parent_; }
    8886
    89         GameStateBase* getState(const std::string& name);
    90         GameStateBase* getRoot();
    91         //! Returns the currently active game state
    92         virtual GameStateBase* getCurrentState();
    93 
    94         virtual void requestState(const std::string& name);
    95 
    96         void addChild(GameStateBase* state);
    97         void removeChild(GameStateBase* state);
    98         void removeChild(const std::string& name);
     87        void addChild(GameState* state);
     88        void removeChild(GameState* state);
    9989
    10090    protected:
    101         virtual void enter() = 0;
    102         virtual void leave() = 0;
    103         virtual void ticked(const Clock& time) = 0;
    104 
    105         GameStateBase* getActiveChild() { return this->activeChild_; }
    106 
    107         void tickChild(const Clock& time) { if (this->getActiveChild()) this->getActiveChild()->tick(time); }
    108 
    109         virtual GameStateBase* getParent() const = 0;
    110         virtual void setParent(GameStateBase* state) = 0;
     91        virtual void activate() = 0;
     92        virtual void deactivate() = 0;
     93        virtual void update(const Clock& time) = 0;
    11194
    11295    private:
    113         // Making the constructor private ensures that game states
    114         // are always derivates of GameState<T>. Note the friend declaration above.
    115         GameStateBase(const std::string& name);
    116 
    117         //! Performs a transition to 'destination'
    118         virtual void makeTransition(GameStateBase* source, GameStateBase* destination);
    119 
    120         void grandchildAdded(GameStateBase* child, GameStateBase* grandchild);
    121         void grandchildRemoved(GameStateBase* grandchild);
    122 
    123         void tick(const Clock& time);
    124         void activate();
    125         void deactivate();
     96        void setParent(GameState* state) { this->parent_ = state; }
     97        void setActivity(State activity);
     98        void activateInternal();
     99        void deactivateInternal();
     100        void updateInternal(const Clock& time);
    126101
    127102        const std::string                        name_;
    128         Operations                               operation_;
    129         GameStateBase*                           activeChild_;
    130         //bool                                     bPauseParent_;
    131         std::map<std::string, GameStateBase*>    allChildren_;
    132         std::map<GameStateBase*, GameStateBase*> grandchildrenToChildren_;
    133     };
    134 
    135 
    136     template <class ParentType>
    137     class GameState : public GameStateBase
    138     {
    139     public:
    140         GameState(const std::string& name)
    141             : GameStateBase(name)
    142             , parent_(0)
    143         { }
    144         virtual ~GameState() { }
    145 
    146         ParentType* getParent() const
    147             { return parent_; }
    148 
    149     protected:
    150         void setParent(GameStateBase* state)
    151         {
    152             assert(dynamic_cast<ParentType*>(state) != 0);
    153             this->parent_ = dynamic_cast<ParentType*>(state);
    154         }
    155 
    156     private:
    157         ParentType* parent_;
     103        State                                    activity_;
     104        GameState*                               parent_;
     105        std::map<std::string, GameState*>        children_;
    158106    };
    159107}
  • code/trunk/src/core/Iterator.h

    r2784 r2896  
    181181                    this->list_->unregisterIterator(this);
    182182
    183                 this->element_ = (other.element_) ? (ObjectListBaseElement*)other.element_ : 0;
     183                this->element_ = (other.element_) ? static_cast<ObjectListBaseElement*>(other.element_) : 0;
    184184                this->list_ = ClassIdentifier<O>::getIdentifier()->getObjects();
    185185                this->list_->registerIterator(this);
  • code/trunk/src/core/LuaBind.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/core/LuaBind.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/core/ObjectListBase.h

    r2784 r2896  
    7171    {
    7272        public:
    73             ObjectListElement(T* object) : ObjectListBaseElement((OrxonoxClass*)object), object_(object) {}
     73            ObjectListElement(T* object) : ObjectListBaseElement(static_cast<OrxonoxClass*>(object)), object_(object) {}
    7474            T* object_;              //!< The object
    7575    };
  • code/trunk/src/core/TclThreadManager.cc

    r1792 r2896  
    3535#include <OgreTimer.h>
    3636
     37#include "Clock.h"
    3738#include "CoreIncludes.h"
    3839#include "ConsoleCommand.h"
     
    598599    }
    599600
    600     void TclThreadManager::tick(float dt)
     601    void TclThreadManager::update(const Clock& time)
    601602    {
    602603        {
     
    633634            boost::try_mutex::scoped_lock interpreter_lock(this->orxonoxInterpreterBundle_.interpreterMutex_);
    634635#endif
    635             unsigned long maxtime = (unsigned long)(dt * 1000000 * TCLTHREADMANAGER_MAX_CPU_USAGE);
     636            unsigned long maxtime = (unsigned long)(time.getDeltaTime() * 1000000 * TCLTHREADMANAGER_MAX_CPU_USAGE);
    636637            Ogre::Timer timer;
    637638            while (!this->queueIsEmpty())
  • code/trunk/src/core/TclThreadManager.h

    r2710 r2896  
    9090            void debug(const std::string& error);
    9191
    92             virtual void tick(float dt);
     92            void update(const Clock& time);
    9393
    9494            std::list<unsigned int> getThreadList() const;
  • code/trunk/src/core/Template.cc

    r2893 r2896  
    6565        if (element)
    6666        {
    67             TiXmlElement* tixmlelement = dynamic_cast<TiXmlElement*>(element->GetTiXmlPointer());
     67            TiXmlElement* tixmlelement = static_cast<TiXmlElement*>(element->GetTiXmlPointer());
    6868            if (tixmlelement)
    6969                this->setXMLElement(*tixmlelement);
     
    138138        COUT(4) << object->getLoaderIndentation() << " aplying Template \"" << this->getName() << "\"..." << std::endl;
    139139
    140         Element temp = ((TiXmlElement*)&this->getXMLElement());
     140        Element temp = &const_cast<TiXmlElement&>(this->getXMLElement());
    141141
    142142        if (this->bLoadDefaults_)
  • code/trunk/src/core/Template.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/core/XMLFile.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/core/XMLIncludes.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/core/XMLPort.h

    r2710 r2896  
    556556                                                try
    557557                                                {
    558                                                     COUT(4) << ((BaseObject*)object)->getLoaderIndentation() << "fabricating " << child->Value() << "..." << std::endl;
     558                                                    COUT(4) << object->getLoaderIndentation() << "fabricating " << child->Value() << "..." << std::endl;
    559559
    560560                                                    BaseObject* newObject = identifier->fabricate((BaseObject*)object);
    561561                                                    assert(newObject);
    562                                                     newObject->setLoaderIndentation(((BaseObject*)object)->getLoaderIndentation() + "  ");
     562                                                    newObject->setLoaderIndentation(object->getLoaderIndentation() + "  ");
    563563
    564564                                                    O* castedObject = dynamic_cast<O*>(newObject);
     
    568568                                                    {
    569569                                                        newObject->XMLPort(*child, XMLPort::LoadObject);
    570                                                         COUT(4) << ((BaseObject*)object)->getLoaderIndentation() << "assigning " << child->Value() << " (objectname " << newObject->getName() << ") to " << this->identifier_->getName() << " (objectname " << ((BaseObject*)object)->getName() << ")" << std::endl;
     570                                                        COUT(4) << object->getLoaderIndentation() << "assigning " << child->Value() << " (objectname " << newObject->getName() << ") to " << this->identifier_->getName() << " (objectname " << ((BaseObject*)object)->getName() << ")" << std::endl;
    571571                                                    }
    572572                                                    else
    573573                                                    {
    574                                                         COUT(4) << ((BaseObject*)object)->getLoaderIndentation() << "assigning " << child->Value() << " (object not yet loaded) to " << this->identifier_->getName() << " (objectname " << ((BaseObject*)object)->getName() << ")" << std::endl;
     574                                                        COUT(4) << object->getLoaderIndentation() << "assigning " << child->Value() << " (object not yet loaded) to " << this->identifier_->getName() << " (objectname " << ((BaseObject*)object)->getName() << ")" << std::endl;
    575575                                                    }
    576576
    577                                                     COUT(5) << ((BaseObject*)object)->getLoaderIndentation();
     577                                                    COUT(5) << object->getLoaderIndentation();
    578578                                                    (*this->loadexecutor_)(object, castedObject);
    579579
     
    581581                                                        newObject->XMLPort(*child, XMLPort::LoadObject);
    582582
    583                                                     COUT(5) << ((BaseObject*)object)->getLoaderIndentation() << "...fabricated " << child->Value() << " (objectname " << newObject->getName() << ")." << std::endl;
     583                                                    COUT(5) << object->getLoaderIndentation() << "...fabricated " << child->Value() << " (objectname " << newObject->getName() << ")." << std::endl;
    584584                                                }
    585585                                                catch (AbortLoadingException& ex)
     
    601601                                        else
    602602                                        {
    603                                             COUT(2) << ((BaseObject*)object)->getLoaderIndentation() << "Warning: '" << child->Value() << "' is not loadable." << std::endl;
     603                                            COUT(2) << object->getLoaderIndentation() << "Warning: '" << child->Value() << "' is not loadable." << std::endl;
    604604                                        }
    605605                                    }
    606606                                    else
    607607                                    {
    608                                         COUT(2) << ((BaseObject*)object)->getLoaderIndentation() << "Warning: '" << child->Value() << "' is not a '" << Class(O)->getName() << "'." << std::endl;
     608                                        COUT(2) << object->getLoaderIndentation() << "Warning: '" << child->Value() << "' is not a '" << Class(O)->getName() << "'." << std::endl;
    609609                                    }
    610610                                }
     
    626626                    {
    627627                        COUT(1) << std::endl;
    628                         COUT(1) << "An error occurred in XMLPort.h while loading a '" << Class(O)->getName() << "' in '" << this->sectionname_ << "' of '" << this->identifier_->getName() << "' (objectname: " << ((BaseObject*)object)->getName() << ") in " << object->getFilename() << ":" << std::endl;
     628                        COUT(1) << "An error occurred in XMLPort.h while loading a '" << Class(O)->getName() << "' in '" << this->sectionname_ << "' of '" << this->identifier_->getName() << "' (objectname: " << object->getName() << ") in " << object->getFilename() << ":" << std::endl;
    629629                        COUT(1) << ex.what() << std::endl;
    630630                    }
  • code/trunk/src/core/input/CalibratorCallback.h

    r1755 r2896  
    5252        void keyHeld    (const KeyEvent& evt) { }
    5353
    54         void tickInput(float dt) { }
     54        void updateInput(float dt) { }
    5555    };
    5656}
  • code/trunk/src/core/input/ExtendedInputState.cc

    r2773 r2896  
    402402    }
    403403
    404     void ExtendedInputState::tickInput(float dt)
     404    void ExtendedInputState::updateInput(float dt)
    405405    {
    406406        for (unsigned int i = 0; i < allHandlers_.size(); ++i)
    407407        {
    408             allHandlers_[i]->tickInput(dt);
    409         }
    410     }
    411 
    412     void ExtendedInputState::tickInput(float dt, unsigned int device)
     408            allHandlers_[i]->updateInput(dt);
     409        }
     410    }
     411
     412    void ExtendedInputState::updateInput(float dt, unsigned int device)
    413413    {
    414414        switch (device)
     
    416416        case Keyboard:
    417417            for (unsigned int i = 0; i < keyHandlers_.size(); ++i)
    418                 keyHandlers_[i]->tickKey(dt);
     418                keyHandlers_[i]->updateKey(dt);
    419419            break;
    420420
    421421        case Mouse:
    422422            for (unsigned int i = 0; i < mouseHandlers_.size(); ++i)
    423                 mouseHandlers_[i]->tickMouse(dt);
     423                mouseHandlers_[i]->updateMouse(dt);
    424424            break;
    425425
    426426        default: // joy sticks
    427427            for (unsigned int i = 0; i < joyStickHandlers_[device - 2].size(); ++i)
    428                 joyStickHandlers_[device - 2][i]->tickJoyStick(dt, device - 2);
     428                joyStickHandlers_[device - 2][i]->updateJoyStick(dt, device - 2);
    429429            break;
    430430        }
  • code/trunk/src/core/input/ExtendedInputState.h

    r1887 r2896  
    6868        ~ExtendedInputState() { }
    6969
    70         void tickInput(float dt);
    71         void tickInput(float dt, unsigned int device);
     70        void updateInput(float dt);
     71        void updateInput(float dt, unsigned int device);
    7272
    7373        void keyPressed (const KeyEvent& evt);
  • code/trunk/src/core/input/InputBuffer.cc

    r2662 r2896  
    224224
    225225    /**
    226         @brief This tick() function is called by the InputManager if the InputBuffer is active.
     226        @brief This update() function is called by the InputManager if the InputBuffer is active.
    227227        @param dt Delta time
    228228    */
    229     void InputBuffer::tickInput(float dt)
     229    void InputBuffer::updateInput(float dt)
    230230    {
    231231        timeSinceKeyPressed_ += dt;
  • code/trunk/src/core/input/InputBuffer.h

    r2662 r2896  
    127127                for (std::list<BaseInputBufferListenerTuple*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); )
    128128                {
    129                     InputBufferListenerTuple<T>* refListener = dynamic_cast<InputBufferListenerTuple<T>*>(*it);
     129                    InputBufferListenerTuple<T>* refListener = static_cast<InputBufferListenerTuple<T>*>(*it);
    130130                    if (refListener && refListener->listener_ == listener)
    131131                        this->listeners_.erase(it++);
     
    171171            void processKey (const KeyEvent &e);
    172172
    173             void tickInput(float dt);
    174             void tickKey(float dt) { }
     173            void updateInput(float dt);
     174            void updateKey(float dt) { }
    175175
    176176            std::string buffer_;
  • code/trunk/src/core/input/InputInterfaces.h

    r2662 r2896  
    474474    public:
    475475        virtual ~InputHandler() { }
    476         virtual void tickInput(float dt) = 0;
     476        virtual void updateInput(float dt) = 0;
    477477    };
    478478
     
    488488        virtual void keyReleased(const KeyEvent& evt) = 0;
    489489        virtual void keyHeld    (const KeyEvent& evt) = 0;
    490         virtual void tickKey    (float dt) = 0;
     490        virtual void updateKey    (float dt) = 0;
    491491    };
    492492
     
    504504        virtual void mouseMoved         (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize) = 0;
    505505        virtual void mouseScrolled      (int abs, int rel)     = 0;
    506         virtual void tickMouse          (float dt) = 0;
     506        virtual void updateMouse          (float dt) = 0;
    507507    };
    508508
     
    520520        virtual void joyStickButtonHeld    (unsigned int joyStickID, JoyStickButtonCode::ByEnum id) = 0;
    521521        virtual void joyStickAxisMoved     (unsigned int joyStickID, unsigned int axis, float value) = 0;
    522         virtual void tickJoyStick          (float dt, unsigned int joyStick) = 0;
     522        virtual void updateJoyStick          (float dt, unsigned int joyStick) = 0;
    523523    };
    524524
     
    531531        virtual ~EmptyHandler() { }
    532532
    533         void tickInput(float dt) { }
    534         void tickJoyStick(float dt, unsigned int joyStick) { }
    535         void tickMouse(float dt) { }
    536         void tickKey(float dt) { }
     533        void updateInput(float dt) { }
     534        void updateJoyStick(float dt, unsigned int joyStick) { }
     535        void updateMouse(float dt) { }
     536        void updateKey(float dt) { }
    537537
    538538        void keyPressed (const KeyEvent& evt) { }
  • code/trunk/src/core/input/InputManager.cc

    r2662 r2896  
    4343
    4444#include "util/Exception.h"
     45#include "core/Clock.h"
    4546#include "core/CoreIncludes.h"
    4647#include "core/ConfigValueIncludes.h"
     
    108109        , internalState_(Uninitialised)
    109110        , stateEmpty_(0)
    110         , stateMaster_(0)
    111111        , keyDetector_(0)
    112112        , calibratorCallbackBuffer_(0)
     
    173173            //paramList.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_NONEXCLUSIVE")));
    174174            //paramList.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_FOREGROUND")));
    175 #if defined OIS_LINUX_PLATFORM
     175#if defined ORXONOX_PLATFORM_LINUX
    176176            paramList.insert(std::make_pair(std::string("XAutoRepeatOn"), std::string("true")));
    177177            paramList.insert(std::make_pair(std::string("x11_mouse_grab"), "true"));
     
    218218
    219219            // Lowest priority empty InputState
    220             stateEmpty_ = createInputState<SimpleInputState>("empty", -1);
     220            stateEmpty_ = createInputState<SimpleInputState>("empty", false, false, InputStatePriority::Empty);
    221221            stateEmpty_->setHandler(&EMPTY_HANDLER);
    222222            activeStates_[stateEmpty_->getPriority()] = stateEmpty_;
    223223
    224             // Always active master InputState
    225             stateMaster_ = new ExtendedInputState();
    226             stateMaster_->setName("master");
    227             stateMaster_->setNumOfJoySticks(joySticksSize_);
    228 
    229224            // KeyDetector to evaluate a pressed key's name
    230             SimpleInputState* detector = createInputState<SimpleInputState>("detector", 101);
     225            SimpleInputState* detector = createInputState<SimpleInputState>("detector", false, false, InputStatePriority::Detector);
    231226            keyDetector_ = new KeyDetector();
    232227            detector->setHandler(keyDetector_);
    233228
    234229            // Joy stick calibration helper callback
    235             SimpleInputState* calibrator = createInputState<SimpleInputState>("calibrator", 100);
     230            SimpleInputState* calibrator = createInputState<SimpleInputState>("calibrator", false, false, InputStatePriority::Calibrator);
    236231            calibrator->setHandler(&EMPTY_HANDLER);
    237232            calibratorCallbackBuffer_ = new InputBuffer();
     
    424419
    425420        // state management
    426         activeStatesTop_.resize(devicesNum_);
     421        activeStatesTriggered_.resize(devicesNum_);
    427422
    428423        // inform all states
    429         for (std::map<int, InputState*>::const_iterator it = inputStatesByPriority_.begin();
    430             it != inputStatesByPriority_.end(); ++it)
     424        for (std::map<std::string, InputState*>::const_iterator it = inputStatesByName_.begin();
     425            it != inputStatesByName_.end(); ++it)
    431426        {
    432427            it->second->setNumOfJoySticks(joySticksSize_);
    433428        }
    434         // inform master state
    435         if (stateMaster_)
    436             this->stateMaster_->setNumOfJoySticks(joySticksSize_);
    437429
    438430        // inform all JoyStick Device Number Listeners
     
    454446        }
    455447    }
    456    
     448
    457449    void InputManager::_startCalibration()
    458450    {
     
    549541                // destroy the empty InputState
    550542                _destroyState(this->stateEmpty_);
    551                 // destroy the master input state. This might trigger a memory leak
    552                 // because the user has forgotten to destroy the KeyBinder or any Handler!
    553                 delete stateMaster_;
    554543
    555544                // destroy all user InputStates
    556                 while (inputStatesByPriority_.size() > 0)
    557                     _destroyState((*inputStatesByPriority_.rbegin()).second);
     545                while (inputStatesByName_.size() > 0)
     546                    _destroyState((*inputStatesByName_.rbegin()).second);
    558547
    559548                // destroy the devices
     
    639628            _updateActiveStates();
    640629        }
    641         inputStatesByPriority_.erase(state->getPriority());
    642630        inputStatesByName_.erase(state->getName());
    643631        delete state;
     
    670658    @brief
    671659        Public interface. Only reloads immediately if the call stack doesn't
    672         include the tick() method.
     660        include the update() method.
    673661    @param joyStickSupport
    674662        Whether or not to initialise joy sticks as well.
     
    742730    @brief
    743731        Updates the states and the InputState situation.
    744     @param dt
    745         Delta time
    746     */
    747     void InputManager::tick(float dt)
     732    @param time
     733        Clock holding the current time.
     734    */
     735    void InputManager::update(const Clock& time)
    748736    {
    749737        if (internalState_ == Uninitialised)
     
    759747        if (!stateLeaveRequests_.empty())
    760748        {
    761             for (std::set<InputState*>::reverse_iterator rit = stateLeaveRequests_.rbegin();
    762                 rit != stateLeaveRequests_.rend(); ++rit)
    763             {
    764                 (*rit)->onLeave();
     749            for (std::set<InputState*>::iterator it = stateLeaveRequests_.begin();
     750                it != stateLeaveRequests_.end(); ++it)
     751            {
     752                (*it)->onLeave();
    765753                // just to be sure that the state actually is registered
    766                 assert(inputStatesByName_.find((*rit)->getName()) != inputStatesByName_.end());
    767 
    768                 activeStates_.erase((*rit)->getPriority());
     754                assert(inputStatesByName_.find((*it)->getName()) != inputStatesByName_.end());
     755
     756                activeStates_.erase((*it)->getPriority());
     757                if ((*it)->getPriority() < InputStatePriority::HighPriority)
     758                    (*it)->setPriority(0);
    769759                _updateActiveStates();
    770760            }
     
    775765        if (!stateEnterRequests_.empty())
    776766        {
    777             for (std::set<InputState*>::reverse_iterator rit = stateEnterRequests_.rbegin();
    778                 rit != stateEnterRequests_.rend(); ++rit)
     767            for (std::set<InputState*>::const_iterator it = stateEnterRequests_.begin();
     768                it != stateEnterRequests_.end(); ++it)
    779769            {
    780770                // just to be sure that the state actually is registered
    781                 assert(inputStatesByName_.find((*rit)->getName()) != inputStatesByName_.end());
    782 
    783                 activeStates_[(*rit)->getPriority()] = (*rit);
     771                assert(inputStatesByName_.find((*it)->getName()) != inputStatesByName_.end());
     772
     773                if ((*it)->getPriority() == 0)
     774                {
     775                    // Get smallest possible priority between 1 and maxStateStackSize_s
     776#if defined( __MINGW32__ ) // Avoid the strange mingw-stl bug with const_reverse_iterator
     777                    for(std::map<int, InputState*>::reverse_iterator rit = activeStates_.rbegin();
     778                        rit != activeStates_.rend(); ++rit)
     779#else
     780                    for(std::map<int, InputState*>::const_reverse_iterator rit = activeStates_.rbegin();
     781                        rit != activeStates_.rend(); ++rit)
     782#endif
     783                    {
     784                        if (rit->first < InputStatePriority::HighPriority)
     785                        {
     786                            (*it)->setPriority(rit->first + 1);
     787                            break;
     788                        }
     789                    }
     790                    // In case no normal handler was on the stack
     791                    if ((*it)->getPriority() == 0)
     792                        (*it)->setPriority(1);
     793                }
     794                activeStates_[(*it)->getPriority()] = (*it);
    784795                _updateActiveStates();
    785                 (*rit)->onEnter();
     796                (*it)->onEnter();
    786797            }
    787798            stateEnterRequests_.clear();
     
    791802        if (!stateDestroyRequests_.empty())
    792803        {
    793             for (std::set<InputState*>::reverse_iterator rit = stateDestroyRequests_.rbegin();
    794                 rit != stateDestroyRequests_.rend(); ++rit)
    795             {
    796                 _destroyState((*rit));
     804            for (std::set<InputState*>::iterator it = stateDestroyRequests_.begin();
     805                it != stateDestroyRequests_.end(); ++it)
     806            {
     807                _destroyState((*it));
    797808            }
    798809            stateDestroyRequests_.clear();
     
    812823            _updateActiveStates();
    813824
    814         // mark that we capture and distribute input
     825        // mark that we now start capturing and distributing input
    815826        internalState_ |= Ticking;
    816827
     
    829840            {
    830841                KeyEvent kEvt(keysDown_[iKey], keyboardModifiers_);
    831                 activeStatesTop_[Keyboard]->keyHeld(kEvt);
    832                 stateMaster_->keyHeld(kEvt);
     842
     843                for (unsigned int iState = 0; iState < activeStatesTriggered_[Keyboard].size(); ++iState)
     844                    activeStatesTriggered_[Keyboard][iState]->keyHeld(kEvt);
    833845            }
    834846
     
    836848            for (unsigned int iButton = 0; iButton < mouseButtonsDown_.size(); iButton++)
    837849            {
    838                 activeStatesTop_[Mouse]->mouseButtonHeld(mouseButtonsDown_[iButton]);
    839                 stateMaster_->mouseButtonHeld(mouseButtonsDown_[iButton]);
     850                for (unsigned int iState = 0; iState < activeStatesTriggered_[Mouse].size(); ++iState)
     851                    activeStatesTriggered_[Mouse][iState]->mouseButtonHeld(mouseButtonsDown_[iButton]);
    840852            }
    841853
     
    844856                for (unsigned int iButton   = 0; iButton   < joyStickButtonsDown_[iJoyStick].size(); iButton++)
    845857                {
    846                     activeStatesTop_[JoyStick0 + iJoyStick]
    847                         ->joyStickButtonHeld(iJoyStick, joyStickButtonsDown_[iJoyStick][iButton]);
    848                     stateMaster_->joyStickButtonHeld(iJoyStick, joyStickButtonsDown_[iJoyStick][iButton]);
     858                    for (unsigned int iState = 0; iState < activeStatesTriggered_[JoyStick0 + iJoyStick].size(); ++iState)
     859                        activeStatesTriggered_[JoyStick0 + iJoyStick][iState]->joyStickButtonHeld(iJoyStick, joyStickButtonsDown_[iJoyStick][iButton]);
    849860                }
    850861
    851             // tick the handlers for each active handler
     862            // update the handlers for each active handler
    852863            for (unsigned int i = 0; i < devicesNum_; ++i)
    853864            {
    854                 activeStatesTop_[i]->tickInput(dt, i);
    855                 if (stateMaster_->isInputDeviceEnabled(i))
    856                     stateMaster_->tickInput(dt, i);
    857             }
    858 
    859             // tick the handler with a general tick afterwards
     865                for (unsigned int iState = 0; iState < activeStatesTriggered_[i].size(); ++iState)
     866                    activeStatesTriggered_[i][iState]->updateInput(time.getDeltaTime(), i);
     867            }
     868
     869            // update the handler with a general tick afterwards
    860870            for (unsigned int i = 0; i < activeStatesTicked_.size(); ++i)
    861                 activeStatesTicked_[i]->tickInput(dt);
    862             stateMaster_->tickInput(dt);
     871                activeStatesTicked_[i]->updateInput(time.getDeltaTime());
    863872        }
    864873
     
    869878    @brief
    870879        Updates the currently active states (according to activeStates_) for each device.
    871         Also, a list of all active states (no duplicates!) is compiled for the general tick.
     880        Also, a list of all active states (no duplicates!) is compiled for the general update().
    872881    */
    873882    void InputManager::_updateActiveStates()
    874883    {
    875         for (std::map<int, InputState*>::const_iterator it = activeStates_.begin(); it != activeStates_.end(); ++it)
    876             for (unsigned int i = 0; i < devicesNum_; ++i)
    877                 if (it->second->isInputDeviceEnabled(i))
    878                     activeStatesTop_[i] = it->second;
     884        for (unsigned int i = 0; i < devicesNum_; ++i)
     885        {
     886            bool occupied = false;
     887            activeStatesTriggered_[i].clear();
     888#if defined( __MINGW32__ ) // Avoid the strange mingw-stl bug with const_reverse_iterator
     889            for (std::map<int, InputState*>::reverse_iterator rit = activeStates_.rbegin(); rit != activeStates_.rend(); ++rit)
     890            {
     891#else
     892            for (std::map<int, InputState*>::const_reverse_iterator rit = activeStates_.rbegin(); rit != activeStates_.rend(); ++rit)
     893            {
     894#endif
     895                if (rit->second->isInputDeviceEnabled(i) && (!occupied || rit->second->bAlwaysGetsInput_))
     896                {
     897                    activeStatesTriggered_[i].push_back(rit->second);
     898                    if (!rit->second->bTransparent_)
     899                        occupied = true;
     900                }
     901            }
     902        }
    879903
    880904        // update tickables (every state will only appear once)
     
    882906        std::set<InputState*> tempSet;
    883907        for (unsigned int i = 0; i < devicesNum_; ++i)
    884             tempSet.insert(activeStatesTop_[i]);
    885 
    886         // copy the content of the set back to the actual vector
     908            for (unsigned int iState = 0; iState < activeStatesTriggered_[i].size(); ++iState)
     909                tempSet.insert(activeStatesTriggered_[i][iState]);
     910
     911        // copy the content of the std::set back to the actual vector
    887912        activeStatesTicked_.clear();
    888913        for (std::set<InputState*>::const_iterator it = tempSet.begin();it != tempSet.end(); ++it)
     
    942967
    943968        KeyEvent kEvt(e, keyboardModifiers_);
    944         activeStatesTop_[Keyboard]->keyPressed(kEvt);
    945         stateMaster_->keyPressed(kEvt);
     969        for (unsigned int iState = 0; iState < activeStatesTriggered_[Keyboard].size(); ++iState)
     970            activeStatesTriggered_[Keyboard][iState]->keyPressed(kEvt);
    946971
    947972        return true;
     
    9751000
    9761001        KeyEvent kEvt(e, keyboardModifiers_);
    977         activeStatesTop_[Keyboard]->keyReleased(kEvt);
    978         stateMaster_->keyReleased(kEvt);
     1002        for (unsigned int iState = 0; iState < activeStatesTriggered_[Keyboard].size(); ++iState)
     1003            activeStatesTriggered_[Keyboard][iState]->keyReleased(kEvt);
    9791004
    9801005        return true;
     
    9981023            IntVector2 rel(e.state.X.rel, e.state.Y.rel);
    9991024            IntVector2 clippingSize(e.state.width, e.state.height);
    1000             activeStatesTop_[Mouse]->mouseMoved(abs, rel, clippingSize);
    1001             stateMaster_->mouseMoved(abs, rel, clippingSize);
     1025            for (unsigned int iState = 0; iState < activeStatesTriggered_[Mouse].size(); ++iState)
     1026                activeStatesTriggered_[Mouse][iState]->mouseMoved(abs, rel, clippingSize);
    10021027        }
    10031028
     
    10051030        if (e.state.Z.rel != 0)
    10061031        {
    1007             activeStatesTop_[Mouse]->mouseScrolled(e.state.Z.abs, e.state.Z.rel);
    1008             stateMaster_->mouseScrolled(e.state.Z.abs, e.state.Z.rel);
     1032            for (unsigned int iState = 0; iState < activeStatesTriggered_[Mouse].size(); ++iState)
     1033                activeStatesTriggered_[Mouse][iState]->mouseScrolled(e.state.Z.abs, e.state.Z.rel);
    10091034        }
    10101035
     
    10291054            mouseButtonsDown_.push_back((MouseButtonCode::ByEnum)id);
    10301055
    1031         activeStatesTop_[Mouse]->mouseButtonPressed((MouseButtonCode::ByEnum)id);
    1032         stateMaster_->mouseButtonPressed((MouseButtonCode::ByEnum)id);
     1056        for (unsigned int iState = 0; iState < activeStatesTriggered_[Mouse].size(); ++iState)
     1057            activeStatesTriggered_[Mouse][iState]->mouseButtonPressed((MouseButtonCode::ByEnum)id);
    10331058
    10341059        return true;
     
    10551080        }
    10561081
    1057         activeStatesTop_[Mouse]->mouseButtonReleased((MouseButtonCode::ByEnum)id);
    1058         stateMaster_->mouseButtonReleased((MouseButtonCode::ByEnum)id);
     1082        for (unsigned int iState = 0; iState < activeStatesTriggered_[Mouse].size(); ++iState)
     1083            activeStatesTriggered_[Mouse][iState]->mouseButtonReleased((MouseButtonCode::ByEnum)id);
    10591084
    10601085        return true;
     
    10921117            buttonsDown.push_back((JoyStickButtonCode::ByEnum)button);
    10931118
    1094         activeStatesTop_[2 + iJoyStick]->joyStickButtonPressed(iJoyStick, (JoyStickButtonCode::ByEnum)button);
    1095         stateMaster_->joyStickButtonPressed(iJoyStick, (JoyStickButtonCode::ByEnum)button);
     1119        for (unsigned int iState = 0; iState < activeStatesTriggered_[2 + iJoyStick].size(); ++iState)
     1120            activeStatesTriggered_[2 + iJoyStick][iState]->joyStickButtonPressed(iJoyStick, (JoyStickButtonCode::ByEnum)button);
    10961121
    10971122        return true;
     
    11131138        }
    11141139
    1115         activeStatesTop_[2 + iJoyStick]->joyStickButtonReleased(iJoyStick, (JoyStickButtonCode::ByEnum)button);
    1116         stateMaster_->joyStickButtonReleased(iJoyStick, (JoyStickButtonCode::ByEnum)button);
     1140        for (unsigned int iState = 0; iState < activeStatesTriggered_[2 + iJoyStick].size(); ++iState)
     1141            activeStatesTriggered_[2 + iJoyStick][iState]->joyStickButtonReleased(iJoyStick, (JoyStickButtonCode::ByEnum)button);
    11171142
    11181143        return true;
     
    11411166                fValue *= joyStickCalibrations_[iJoyStick].negativeCoeff[axis];
    11421167
    1143             activeStatesTop_[2 + iJoyStick]->joyStickAxisMoved(iJoyStick, axis, fValue);
    1144             stateMaster_->joyStickAxisMoved(iJoyStick, axis, fValue);
     1168            for (unsigned int iState = 0; iState < activeStatesTriggered_[2 + iJoyStick].size(); ++iState)
     1169                activeStatesTriggered_[2 + iJoyStick][iState]->joyStickAxisMoved(iJoyStick, axis, fValue);
    11451170        }
    11461171    }
     
    12451270        Unique name of the handler.
    12461271    @param priority
    1247         Unique integer number. Higher means more prioritised.
     1272        Determines which InputState gets the input. Higher is better.
     1273        Use 0 to handle it implicitely by the order of activation.
     1274        Otherwise numbers larger than maxStateStackSize_s have to be used!
    12481275    @return
    12491276        True if added, false if name or priority already existed.
    12501277    */
    1251     bool InputManager::_configureInputState(InputState* state, const std::string& name, int priority)
     1278    bool InputManager::_configureInputState(InputState* state, const std::string& name, bool bAlwaysGetsInput, bool bTransparent, int priority)
    12521279    {
    12531280        if (name == "")
     
    12571284        if (inputStatesByName_.find(name) == inputStatesByName_.end())
    12581285        {
    1259             if (inputStatesByPriority_.find(priority)
    1260                 == inputStatesByPriority_.end())
    1261             {
    1262                 inputStatesByName_[name] = state;
    1263                 inputStatesByPriority_[priority] = state;
    1264                 state->setNumOfJoySticks(numberOfJoySticks());
    1265                 state->setName(name);
     1286            if (priority >= InputStatePriority::HighPriority || priority == InputStatePriority::Empty)
     1287            {
     1288                // Make sure we don't add two high priority states with the same priority
     1289                for (std::map<std::string, InputState*>::const_iterator it = this->inputStatesByName_.begin();
     1290                    it != this->inputStatesByName_.end(); ++it)
     1291                {
     1292                    if (it->second->getPriority() == priority)
     1293                    {
     1294                        COUT(2) << "Warning: Could not add an InputState with the same priority '"
     1295                            << priority << "' != 0." << std::endl;
     1296                        return false;
     1297                    }
     1298                }
     1299            }
     1300            inputStatesByName_[name] = state;
     1301            state->setNumOfJoySticks(numberOfJoySticks());
     1302            state->setName(name);
     1303            state->bAlwaysGetsInput_ = bAlwaysGetsInput;
     1304            state->bTransparent_ = bTransparent;
     1305            if (priority >= InputStatePriority::HighPriority || priority == InputStatePriority::Empty)
    12661306                state->setPriority(priority);
    1267                 return true;
    1268             }
    1269             else
    1270             {
    1271                 COUT(2) << "Warning: Could not add an InputState with the same priority '"
    1272                     << priority << "'." << std::endl;
    1273                 return false;
    1274             }
     1307            return true;
    12751308        }
    12761309        else
     
    12901323    @remarks
    12911324        You can't remove the internal states "empty", "calibrator" and "detector".
    1292         The removal process is being postponed if InputManager::tick() is currently running.
     1325        The removal process is being postponed if InputManager::update() is currently running.
    12931326    */
    12941327    bool InputManager::requestDestroyState(const std::string& name)
     
    13711404                {
    13721405                    // not scheduled for destruction
    1373                     // set prevents a state being added multiple times
     1406                    // prevents a state being added multiple times
    13741407                    stateEnterRequests_.insert(it->second);
    13751408                    return true;
     
    13901423    bool InputManager::requestLeaveState(const std::string& name)
    13911424    {
     1425        if (name == "empty")
     1426        {
     1427            COUT(2) << "InputManager: Leaving the empty state is not allowed!" << std::endl;
     1428            return false;
     1429        }
    13921430        // get pointer from the map with all stored handlers
    13931431        std::map<std::string, InputState*>::const_iterator it = inputStatesByName_.find(name);
  • code/trunk/src/core/input/InputManager.h

    r2662 r2896  
    4343#include <stack>
    4444#include "util/Math.h"
     45#include "util/OrxEnum.h"
    4546#include "core/OrxonoxClass.h"
    4647#include "InputInterfaces.h"
     
    7475        float positiveCoeff[24];
    7576        float negativeCoeff[24];
     77    };
     78
     79    struct InputStatePriority : OrxEnum<InputStatePriority>
     80    {
     81        OrxEnumConstructors(InputStatePriority);
     82
     83        static const int Empty        = -1;
     84        static const int Dynamic      = 0;
     85
     86        static const int HighPriority = 1000;
     87        static const int Console      = HighPriority + 0;
     88        static const int Calibrator   = HighPriority + 1;
     89        static const int Detector     = HighPriority + 2;
    7690    };
    7791
     
    116130
    117131        template <class T>
    118         T* createInputState(const std::string& name, int priority);
     132        T* createInputState(const std::string& name, bool bAlwaysGetsInput = false, bool bTransparent = false, InputStatePriority priority = InputStatePriority::Dynamic);
    119133
    120134        InputState* getState       (const std::string& name);
    121135        InputState* getCurrentState();
    122         ExtendedInputState* getMasterInputState() { return this->stateMaster_; }
    123136        bool requestDestroyState   (const std::string& name);
    124137        bool requestEnterState     (const std::string& name);
    125138        bool requestLeaveState     (const std::string& name);
    126139
    127         void tick(float dt);
     140        void update(const Clock& time);
    128141
    129142        static InputManager& getInstance()    { assert(singletonRef_s); return *singletonRef_s; }
     
    165178
    166179        void _updateActiveStates();
    167         bool _configureInputState(InputState* state, const std::string& name, int priority);
     180        bool _configureInputState(InputState* state, const std::string& name, bool bAlwaysGetsInput, bool bTransparent, int priority);
    168181
    169182        // input events
     
    197210        // some internally handled states and handlers
    198211        SimpleInputState*                   stateEmpty_;
    199         ExtendedInputState*                 stateMaster_;          //!< Always active master input state
    200212        KeyDetector*                        keyDetector_;          //!< KeyDetector instance
    201213        InputBuffer*                        calibratorCallbackBuffer_;
    202214
    203215        std::map<std::string, InputState*>  inputStatesByName_;
    204         std::map<int, InputState*>          inputStatesByPriority_;
    205216
    206217        std::set<InputState*>               stateEnterRequests_;   //!< Request to enter a new state
     
    209220
    210221        std::map<int, InputState*>          activeStates_;
    211         std::vector<InputState*>            activeStatesTop_;      //!< Current input states for joy stick events.
    212         std::vector<InputState*>            activeStatesTicked_;   //!< Current input states for joy stick events.
     222        std::vector<std::vector<InputState*> > activeStatesTriggered_;
     223        std::vector<InputState*>            activeStatesTicked_;
    213224
    214225        // joystick calibration
     
    249260    */
    250261    template <class T>
    251     T* InputManager::createInputState(const std::string& name, int priority)
     262    T* InputManager::createInputState(const std::string& name, bool bAlwaysGetsInput, bool bTransparent, InputStatePriority priority)
    252263    {
    253264        T* state = new T;
    254         if (_configureInputState(state, name, priority))
     265        if (_configureInputState(state, name, bAlwaysGetsInput, bTransparent, priority))
    255266            return state;
    256267        else
  • code/trunk/src/core/input/InputState.h

    r1887 r2896  
    7171        virtual void unRegisterOnLeave()                      { executorOnLeave_ = 0; }
    7272
    73         virtual void tickInput(float dt, unsigned int device) = 0;
    74         virtual void tickInput(float dt) = 0;
     73        virtual void updateInput(float dt, unsigned int device) = 0;
     74        virtual void updateInput(float dt) = 0;
    7575
    7676        virtual void keyPressed (const KeyEvent& evt) = 0;
     
    9090
    9191    protected:
    92         InputState() : bHandlersChanged_(false), priority_(0), executorOnEnter_(0), executorOnLeave_(0) { }
     92        InputState()
     93            : bHandlersChanged_(false)
     94            , priority_(0)
     95            , bAlwaysGetsInput_(false)
     96            , bTransparent_(false)
     97            , executorOnEnter_(0)
     98            , executorOnLeave_(0)
     99        { }
    93100        virtual ~InputState() { }
    94101
     
    114121        int                                         priority_;
    115122        std::vector<bool>                           bInputDeviceEnabled_;
     123        bool                                        bAlwaysGetsInput_;
     124        bool                                        bTransparent_;
    116125
    117126        Executor*                                   executorOnEnter_;
  • code/trunk/src/core/input/KeyBinder.cc

    r2713 r2896  
    4242#include "core/CoreIncludes.h"
    4343#include "core/ConfigFileManager.h"
    44 #include "core/Core.h"
    4544#include "InputCommands.h"
    4645#include "InputManager.h"
     
    309308    }
    310309
    311     void KeyBinder::tickMouse(float dt)
     310    void KeyBinder::updateMouse(float dt)
    312311    {
    313312        if (bDeriveMouseInput_)
     
    349348            // Why dividing relative value by dt? The reason lies in the simple fact, that when you
    350349            // press a button that has relative movement, that value has to be multiplied by dt to be
    351             // frame rate independent. This can easily (and only) be done in tickInput(float).
     350            // frame rate independent. This can easily (and only) be done in updateInput(float).
    352351            // Hence we need to divide by dt here for the mouse to compensate, because the relative
    353352            // move movements have nothing to do with dt.
     
    362361    }
    363362
    364     void KeyBinder::tickJoyStick(float dt, unsigned int joyStick)
     363    void KeyBinder::updateJoyStick(float dt, unsigned int joyStick)
    365364    {
    366365        for (unsigned int i = 0; i < JoyStickAxisCode::numberOfAxes * 2; i++)
  • code/trunk/src/core/input/KeyBinder.h

    r2710 r2896  
    6868
    6969    protected: // functions
    70         void tickInput(float dt);
    71         void tickKey(float dt) { }
    72         void tickMouse(float dt);
    73         void tickJoyStick(float dt, unsigned int joyStick);
     70        void updateInput(float dt);
     71        void updateKey(float dt) { }
     72        void updateMouse(float dt);
     73        void updateJoyStick(float dt, unsigned int joyStick);
    7474        // internal
    7575        void tickHalfAxis(HalfAxis& halfAxis);
     
    134134        @brief
    135135            Commands that have additional parameters (axes) are executed at the end of
    136             the tick() so that all values can be buffered for single execution.
     136            update() so that all values can be buffered for single execution.
    137137        */
    138138        std::vector<BufferedParamCommand*> paramCommandBuffer_;
     
    200200    { joyStickButtons_[joyStickID][id].execute(KeybindMode::OnHold); }
    201201
    202     inline void KeyBinder::tickInput(float dt)
     202    inline void KeyBinder::updateInput(float dt)
    203203    {
    204204        // execute all buffered bindings (additional parameter)
  • code/trunk/src/core/input/SimpleInputState.h

    r1887 r2896  
    5959        ~SimpleInputState() { }
    6060
    61         void tickInput(float dt);
    62         void tickInput(float dt, unsigned int device);
     61        void updateInput(float dt);
     62        void updateInput(float dt, unsigned int device);
    6363
    6464        void keyPressed (const KeyEvent& evt);
     
    8787    };
    8888
    89     inline void SimpleInputState::tickInput(float dt)
     89    inline void SimpleInputState::updateInput(float dt)
    9090    {
    9191        for (unsigned int i = 0; i < allHandlers_.size(); ++i)
    9292        {
    93             allHandlers_[i]->tickInput(dt);
     93            allHandlers_[i]->updateInput(dt);
    9494        }
    9595    }
    9696
    97     inline void SimpleInputState::tickInput(float dt, unsigned int device)
     97    inline void SimpleInputState::updateInput(float dt, unsigned int device)
    9898    {
    9999        switch (device)
     
    101101        case InputDevice::Keyboard:
    102102            if (keyHandler_)
    103                 keyHandler_->tickKey(dt);
     103                keyHandler_->updateKey(dt);
    104104            break;
    105105
    106106        case InputDevice::Mouse:
    107107            if (mouseHandler_)
    108                 mouseHandler_->tickMouse(dt);
     108                mouseHandler_->updateMouse(dt);
    109109            break;
    110110
    111111        default: // joy sticks
    112112            if (joyStickHandler_[device - 2])
    113                 joyStickHandler_[device - 2]->tickJoyStick(dt, device - 2);
     113                joyStickHandler_[device - 2]->updateJoyStick(dt, device - 2);
    114114            break;
    115115        }
  • code/trunk/src/cpptcl/cpptcl.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/cpptcl/cpptcl.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/network/ChatListener.cc

    r2171 r2896  
    3030
    3131#include "core/CoreIncludes.h"
    32 #include "core/Core.h"
    3332
    3433namespace orxonox
  • code/trunk/src/network/Client.cc

    r2773 r2896  
    4545#include "Host.h"
    4646#include "synchronisable/Synchronisable.h"
     47#include "core/Clock.h"
    4748#include "core/CoreIncludes.h"
    4849#include "packet/Packet.h"
     
    138139   * @param time
    139140   */
    140   void Client::tick(float time){
     141  void Client::update(const Clock& time){
    141142//     COUT(3) << ".";
    142143    if(client_connection.isConnected() && isSynched_){
  • code/trunk/src/network/Client.h

    r2773 r2896  
    7676    //bool sendChat(packet::Chat *chat);
    7777
    78     void tick(float time);
     78    void update(const Clock& time);
    7979
    8080  private:
  • code/trunk/src/network/ClientConnectionListener.cc

    r2171 r2896  
     1/*
     2 *   ORXONOX - the hottest 3D action shooter ever to exist
     3 *                    > www.orxonox.net <
     4 *
     5 *
     6 *   License notice:
     7 *
     8 *   This program is free software; you can redistribute it and/or
     9 *   modify it under the terms of the GNU General Public License
     10 *   as published by the Free Software Foundation; either version 2
     11 *   of the License, or (at your option) any later version.
     12 *
     13 *   This program is distributed in the hope that it will be useful,
     14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16 *   GNU General Public License for more details.
     17 *
     18 *   You should have received a copy of the GNU General Public License
     19 *   along with this program; if not, write to the Free Software
     20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
     21 *
     22 *   Author:
     23 *      Oliver Scheuss
     24 *   Co-authors:
     25 *      ...
     26 *
     27 */
     28
    129#include "ClientConnectionListener.h"
    230#include "core/CoreIncludes.h"
    3 #include "core/Core.h"
     31#include "core/GameMode.h"
    432
    533namespace orxonox{
     
    1139
    1240  void ClientConnectionListener::getConnectedClients(){
    13     if(Core::showsGraphics())
     41    if(GameMode::showsGraphics())
    1442      this->clientConnected(0); //server client id
    1543    ClientInformation *client = ClientInformation::getBegin();
  • code/trunk/src/network/ConnectionManager.cc

    r2773 r2896  
    4848#include <boost/thread/recursive_mutex.hpp>
    4949
     50#include "util/Debug.h"
    5051#include "util/Math.h"
    5152#include "util/Sleep.h"
  • code/trunk/src/network/Server.cc

    r2773 r2896  
    5151#include "ClientInformation.h"
    5252#include "util/Sleep.h"
     53#include "core/Clock.h"
    5354#include "core/ConsoleCommand.h"
    5455#include "core/CoreIncludes.h"
     
    149150  * @param time time since last tick
    150151  */
    151   void Server::tick(float time) {
     152  void Server::update(const Clock& time) {
    152153    processQueue();
    153154    //this steers our network frequency
    154     timeSinceLastUpdate_+=time;
     155    timeSinceLastUpdate_+=time.getDeltaTime();
    155156    if(timeSinceLastUpdate_>=NETWORK_PERIOD){
    156157      timeSinceLastUpdate_ -= static_cast<unsigned int>( timeSinceLastUpdate_ / NETWORK_PERIOD ) * NETWORK_PERIOD;
  • code/trunk/src/network/Server.h

    r2662 r2896  
    5353  const int CLIENTID_SERVER = 0;
    5454  const unsigned int NETWORK_FREQUENCY = 25;
    55   const float NETWORK_PERIOD = 1./NETWORK_FREQUENCY;
     55  const float NETWORK_PERIOD = 1.f/NETWORK_FREQUENCY;
    5656
    5757  /**
     
    7171    bool processChat(const std::string& message, unsigned int playerID);
    7272    bool queuePacket(ENetPacket *packet, int clientID);
    73     void tick(float time);
     73    void update(const Clock& time);
    7474    unsigned int getPing(unsigned int clientID);
    7575    double getPacketLoss(unsigned int clientID);
  • code/trunk/src/network/TrafficControl.cc

    r2662 r2896  
    3030
    3131#include "synchronisable/Synchronisable.h"
     32#include "core/CoreIncludes.h"
    3233#include "core/ConfigValueIncludes.h"
    3334
  • code/trunk/src/network/packet/Gamestate.cc

    r2773 r2896  
    3434#include "../synchronisable/Synchronisable.h"
    3535#include "../TrafficControl.h"
    36 #include "core/Core.h"
     36#include "core/GameMode.h"
    3737#include "core/CoreIncludes.h"
    3838#include "core/Iterator.h"
     
    162162    if(!s)
    163163    {
    164       if (!Core::isMaster())
     164      if (!GameMode::isMaster())
    165165      {
    166166        Synchronisable::fabricate(mem, mode);
  • code/trunk/src/network/packet/Gamestate.h

    r2759 r2896  
    3535#include "Packet.h"
    3636#include "network/TrafficControl.h"
    37 #include "core/CoreIncludes.h"
     37#include <string.h>
    3838#include <map>
    3939#include <list>
     40#include <cassert>
    4041#ifndef NDEBUG
    4142#include "util/CRC32.h"
  • code/trunk/src/network/synchronisable/NetworkCallback.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/network/synchronisable/Synchronisable.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/network/synchronisable/Synchronisable.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/network/synchronisable/SynchronisableVariable.cc

    r2710 r2896  
    3030#include <cstring>
    3131#include "util/Math.h"
     32#include "core/GameMode.h"
    3233
    3334
     
    3637uint8_t SynchronisableVariableBase::state_ = 0;
    3738
     39/*static*/ void SynchronisableVariableBase::setState()
     40{
     41  if ( state_ == 0x0 )
     42  {
     43    state_ = GameMode::isMaster() ? 0x1 : 0x2;  // set the appropriate mode here
     44  }
     45}
    3846
    3947
  • code/trunk/src/network/synchronisable/SynchronisableVariable.h

    r2710 r2896  
    3535#include <string>
    3636#include <cassert>
    37 #include "core/Core.h"
    38 #include "core/CoreIncludes.h"
     37#include "util/Math.h"
    3938#include "network/synchronisable/NetworkCallback.h"
    4039#include "network/synchronisable/NetworkCallbackManager.h"
     
    6362      virtual ~SynchronisableVariableBase() {}
    6463    protected:
     64      static void setState();
    6565      static uint8_t state_;
    6666  };
     
    110110      variable_( variable ), mode_( syncDirection ), callback_( cb )
    111111  {
    112     if ( state_ == 0x0 )
    113     {
    114       state_ = Core::isMaster() ? 0x1 : 0x2;  // set the appropriate mode here
    115     }
     112      setState();
    116113  }
    117114 
  • code/trunk/src/orxonox/CMakeLists.txt

    r2748 r2896  
    2020SET_SOURCE_FILES(ORXONOX_SRC_FILES
    2121  CameraManager.cc
    22   GraphicsEngine.cc
     22  GraphicsManager.cc
    2323  LevelManager.cc
    2424  Main.cc
  • code/trunk/src/orxonox/CameraManager.cc

    r2893 r2896  
    3535#include <OgreResource.h>
    3636
    37 #include "core/Core.h"
     37#include "core/GameMode.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"
    4344
    4445namespace orxonox
     
    7475    void CameraManager::requestFocus(Camera* camera)
    7576    {
    76         if (!Core::showsGraphics())
     77        if (!GameMode::showsGraphics())
    7778            return;
    7879
     
    99100    void CameraManager::releaseFocus(Camera* camera)
    100101    {
    101         if (!Core::showsGraphics())
     102        if (!GameMode::showsGraphics())
    102103            return;
    103104
     
    141142
    142143        this->viewport_->setCamera(camera);
     144        GUIManager::getInstance().setCamera(camera);
    143145
    144146        // reactivate all visible compositors
  • code/trunk/src/orxonox/CameraManager.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/Main.cc

    r2873 r2896  
    3838
    3939#include "OrxonoxStableHeaders.h"
     40#include "OrxonoxConfig.h"
    4041
    41 #include <exception>
    42 #include <cassert>
     42#include "util/Debug.h"
     43#include "core/Identifier.h"
     44#include "core/Game.h"
    4345
    44 #include "OrxonoxConfig.h"
    45 #include "util/Debug.h"
    46 #include "util/SignalHandler.h"
    47 #include "core/ConfigFileManager.h"
    48 #include "core/CommandLine.h"
    49 #include "core/CommandExecutor.h"
    50 #include "core/Identifier.h"
    51 #include "core/Core.h"
    52 #include "core/Language.h"
    53 
    54 #include "gamestates/GSRoot.h"
    55 #include "gamestates/GSGraphics.h"
    56 #include "gamestates/GSStandalone.h"
    57 #include "gamestates/GSServer.h"
    58 #include "gamestates/GSClient.h"
    59 #include "gamestates/GSDedicated.h"
    60 #include "gamestates/GSGUI.h"
    61 #include "gamestates/GSIOConsole.h"
    62 
    63 #ifdef ORXONOX_PLATFORM_APPLE
    64 #include <CoreFoundation/CoreFoundation.h>
    65 
    66 // This function will locate the path to our application on OS X,
    67 // unlike windows you can not rely on the curent working directory
    68 // for locating your configuration files and resources.
    69              std::string macBundlePath()
    70 {
    71     char path[1024];
    72     CFBundleRef mainBundle = CFBundleGetMainBundle();
    73     assert(mainBundle);
    74 
    75     CFURLRef mainBundleURL = CFBundleCopyBundleURL(mainBundle);
    76     assert(mainBundleURL);
    77 
    78     CFStringRef cfStringRef = CFURLCopyFileSystemPath( mainBundleURL, kCFURLPOSIXPathStyle);
    79     assert(cfStringRef);
    80 
    81     CFStringGetCString(cfStringRef, path, 1024, kCFStringEncodingASCII);
    82 
    83     CFRelease(mainBundleURL);
    84     CFRelease(cfStringRef);
    85 
    86     return std::string(path);
    87 }
    88 #endif
    89 
    90 
    91 SetCommandLineArgument(settingsFile, "orxonox.ini");
    92 SetCommandLineArgument(configFileDirectory, "");
    93 
     46/*
     47@brief
     48    Main method. Game starts here (except for static initialisations).
     49*/
    9450int main(int argc, char** argv)
    9551{
    96     using namespace orxonox;
     52    {
     53        orxonox::Game orxonox(argc, argv);
    9754
    98     // Parse command line arguments
    99     try
    100     {
    101         CommandLine::parseAll(argc, argv);
    102     }
    103     catch (ArgumentException& ex)
    104     {
    105         COUT(1) << ex.what() << std::endl;
    106         COUT(0) << "Usage:" << std::endl << "orxonox " << CommandLine::getUsageInformation() << std::endl;
    107     }
     55        orxonox.setStateHierarchy(
     56        "root"
     57        " graphics"
     58        "  mainMenu"
     59        "  standalone"
     60        "   level"
     61        "  server"
     62        "   level"
     63        "  client"
     64        "   level"
     65        " dedicated"
     66        "  level"
     67        " ioConsole"
     68        );
    10869
    109     // Do this after parsing the command line to allow customisation
    110     Core::postMainInitialisation();
    111 
    112     // create a signal handler (only active for linux)
    113     SignalHandler signalHandler;
    114     signalHandler.doCatch(argv[0], Core::getLogPathString() + "orxonox_crash.log");
    115 
    116     // Create the ConfigFileManager before creating the GameStates in order to have
    117     // setConfigValues() in the constructor (required).
    118     ConfigFileManager* configFileManager = new ConfigFileManager();
    119     configFileManager->setFilename(ConfigFileType::Settings, CommandLine::getValue("settingsFile").getString());
    120     // create the Core settings to configure the output level
    121     Language* language = new Language();
    122     Core*     core     = new Core();
    123 
    124     // put GameStates in its own scope so we can destroy the identifiers at the end of main().
    125     {
    126         // create the gamestates
    127         GSRoot root;
    128         GSGraphics graphics;
    129         GSStandalone standalone;
    130         GSServer server;
    131         GSClient client;
    132         GSDedicated dedicated;
    133         GSGUI gui;
    134         GSIOConsole ioConsole;
    135 
    136         // make the hierarchy
    137         root.addChild(&graphics);
    138         graphics.addChild(&standalone);
    139         graphics.addChild(&server);
    140         graphics.addChild(&client);
    141         graphics.addChild(&gui);
    142         root.addChild(&ioConsole);
    143         root.addChild(&dedicated);
    144 
    145         // Here happens the game
    146         root.start();
    147     }
    148 
    149     // destroy singletons
    150     delete core;
    151     delete language;
    152     delete configFileManager;
     70        orxonox.run();
     71    } // orxonox gets destroyed right here!
    15372
    15473    // Clean up class hierarchy stuff (identifiers, xmlport, configvalue, consolecommand)
    155     Identifier::destroyAllIdentifiers();
    156     // destroy command line arguments
    157     CommandLine::destroyAllArguments();
    158     // Also delete external console command that don't belong to an Identifier
    159     CommandExecutor::destroyExternalCommands();
     74    // Needs to be done after Game destructor because of ~OrxonoxClass
     75    orxonox::Identifier::destroyAllIdentifiers();
    16076
    16177    return 0;
  • code/trunk/src/orxonox/OrxonoxPrereqs.h

    r2893 r2896  
    7777    namespace MunitionType
    7878    {
    79 
    80 
    81 
    8279        enum Enum
    8380        { laserGunMunition };
     
    9794
    9895
    99     class GraphicsEngine;
     96    class GraphicsManager;
     97    class OgreWindowEventListener;
    10098    class Settings;
    10199
     
    250248    //gui
    251249    class GUIManager;
    252 
    253     // game states
    254     class GSRoot;
    255     class GSGraphics;
    256     class GSIO;
    257     class GSIOConsole;
    258     class GSLevel;
    259     class GSStandalone;
    260     class GSServer;
    261     class GSClient;
    262     class GSGUI;
    263250}
    264251
  • code/trunk/src/orxonox/PlayerManager.cc

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

    r2710 r2896  
    11ADD_SOURCE_FILES(ORXONOX_SRC_FILES
     2  GSClient.cc
    23  GSDedicated.cc
    3   GSClient.cc
    44  GSGraphics.cc
    5   GSGUI.cc
    65  GSIOConsole.cc
    76  GSLevel.cc
     7  GSMainMenu.cc
    88  GSRoot.cc
    99  GSServer.cc
  • code/trunk/src/orxonox/gamestates/GSClient.cc

    r2171 r2896  
    3131
    3232#include "core/input/InputManager.h"
     33#include "core/Clock.h"
    3334#include "core/CommandLine.h"
    34 #include "core/Core.h"
     35#include "core/Game.h"
     36#include "core/GameMode.h"
    3537#include "network/Client.h"
    3638
    3739namespace orxonox
    3840{
     41    AddGameState(GSClient, "client");
     42
    3943    SetCommandLineArgument(ip, "127.0.0.1").information("#.#.#.#");
    4044
    41     GSClient::GSClient()
    42         : GameState<GSGraphics>("client")
     45    GSClient::GSClient(const std::string& name)
     46        : GameState(name)
    4347        , client_(0)
    4448    {
     
    4953    }
    5054
    51     void GSClient::enter()
     55    void GSClient::activate()
    5256    {
    53         Core::setIsClient(true);
     57        GameMode::setIsClient(true);
    5458
    5559        this->client_ = new Client(CommandLine::getValue("ip").getString(), CommandLine::getValue("port"));
     
    5862            ThrowException(InitialisationFailed, "Could not establish connection with server.");
    5963
    60         GSLevel::enter(this->getParent()->getViewport());
    61 
    62         client_->tick(0);
     64        client_->update(Game::getInstance().getGameClock());
    6365    }
    6466
    65     void GSClient::leave()
     67    void GSClient::deactivate()
    6668    {
    67         GSLevel::leave();
    68 
    6969        client_->closeConnection();
    7070
     
    7272        delete this->client_;
    7373
    74         Core::setIsClient(false);
     74        GameMode::setIsClient(false);
    7575    }
    7676
    77     void GSClient::ticked(const Clock& time)
     77    void GSClient::update(const Clock& time)
    7878    {
    79         GSLevel::ticked(time);
    80         client_->tick(time.getDeltaTime());
    81 
    82         this->tickChild(time);
     79        client_->update(time);
    8380    }
    8481}
  • code/trunk/src/orxonox/gamestates/GSClient.h

    r2171 r2896  
    3131
    3232#include "OrxonoxPrereqs.h"
     33#include "core/GameState.h"
    3334#include "network/NetworkPrereqs.h"
    34 #include "GSLevel.h"
    35 #include "GSGraphics.h"
    3635
    3736namespace orxonox
    3837{
    39     class _OrxonoxExport GSClient : public GameState<GSGraphics>, public GSLevel
     38    class _OrxonoxExport GSClient : public GameState
    4039    {
    4140    public:
    42         GSClient();
     41        GSClient(const std::string& name);
    4342        ~GSClient();
    4443
     44        void activate();
     45        void deactivate();
     46        void update(const Clock& time);
    4547
    4648    private:
    47         void enter();
    48         void leave();
    49         void ticked(const Clock& time);
    50 
    5149        Client* client_;
    5250    };
  • code/trunk/src/orxonox/gamestates/GSDedicated.cc

    r2662 r2896  
    3030#include "GSDedicated.h"
    3131
     32#include "core/Clock.h"
    3233#include "core/CommandLine.h"
    33 #include "core/Core.h"
     34#include "core/Game.h"
     35#include "core/GameMode.h"
    3436#include "core/Iterator.h"
    3537#include "network/Server.h"
     
    3941namespace orxonox
    4042{
    41     GSDedicated::GSDedicated()
    42         : GameState<GSRoot>("dedicated")
     43    AddGameState(GSDedicated, "dedicated");
     44
     45    GSDedicated::GSDedicated(const std::string& name)
     46        : GameState(name)
    4347        , server_(0)
    4448        , timeSinceLastUpdate_(0)
     
    5054    }
    5155
    52     void GSDedicated::enter()
     56    void GSDedicated::activate()
    5357    {
    54         Core::setHasServer(true);
     58        GameMode::setHasServer(true);
    5559
    5660        this->server_ = new Server(CommandLine::getValue("port"));
    5761        COUT(0) << "Loading scene in server mode" << std::endl;
    5862
    59         GSLevel::enter(0);
    60 
    6163        server_->open();
    6264    }
    6365
    64     void GSDedicated::leave()
     66    void GSDedicated::deactivate()
    6567    {
    66         GSLevel::leave();
    67 
    6868        this->server_->close();
    6969        delete this->server_;
    7070
    71         Core::setHasServer(false);
     71        GameMode::setHasServer(false);
    7272    }
    7373
    74     void GSDedicated::ticked(const Clock& time)
     74    void GSDedicated::update(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             GSLevel::ticked(time);
    85             server_->tick(time.getDeltaTime());
    86             this->tickChild(time);
     84            server_->update(time);
    8785        }
    8886        else
  • code/trunk/src/orxonox/gamestates/GSDedicated.h

    r2662 r2896  
    3131
    3232#include "OrxonoxPrereqs.h"
     33#include "core/GameState.h"
    3334#include "network/NetworkPrereqs.h"
    34 #include "GSLevel.h"
    35 #include "GSRoot.h"
    3635
    3736namespace orxonox
    3837{
    39     class _OrxonoxExport GSDedicated : public GameState<GSRoot>, public GSLevel
     38    class _OrxonoxExport GSDedicated : public GameState
    4039    {
    4140    public:
    42         GSDedicated();
     41        GSDedicated(const std::string& name);
    4342        ~GSDedicated();
    4443
     44        void activate();
     45        void deactivate();
     46        void update(const Clock& time);
     47
    4548    private:
    46         void enter();
    47         void leave();
    48         void ticked(const Clock& time);
    49 
    50         Server*      server_;
    51         float        timeSinceLastUpdate_;
     49        Server* server_;
     50        float   timeSinceLastUpdate_;
    5251    };
    5352}
  • code/trunk/src/orxonox/gamestates/GSGraphics.cc

    r2759 r2896  
    2323 *      Reto Grieder
    2424 *   Co-authors:
    25  *      ...
    26  *
     25 *      Benjamin Knecht
     26 *
     27 */
     28
     29/**
     30    @file
     31    @brief Implementation of Graphics GameState class.
    2732 */
    2833
     
    3035#include "GSGraphics.h"
    3136
    32 #include <fstream>
    3337#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>
    4138#include <OgreRenderWindow.h>
    42 #include <OgreRenderSystem.h>
    43 #include <OgreTextureManager.h>
    44 #include <OgreViewport.h>
    45 #include <OgreWindowEventUtilities.h>
    46 
    47 #include "SpecialConfig.h"
     39
    4840#include "util/Debug.h"
    49 #include "util/Exception.h"
    50 #include "util/String.h"
    51 #include "util/SubString.h"
     41#include "core/ConfigValueIncludes.h"
     42#include "core/Clock.h"
    5243#include "core/ConsoleCommand.h"
    53 #include "core/ConfigValueIncludes.h"
     44#include "core/Core.h"
    5445#include "core/CoreIncludes.h"
    55 #include "core/Core.h"
     46#include "core/Game.h"
     47#include "core/GameMode.h"
    5648#include "core/input/InputManager.h"
    5749#include "core/input/KeyBinder.h"
    58 #include "core/input/ExtendedInputState.h"
     50#include "core/input/SimpleInputState.h"
    5951#include "core/Loader.h"
    6052#include "core/XMLFile.h"
    6153#include "overlays/console/InGameConsole.h"
    6254#include "gui/GUIManager.h"
    63 #include "tools/WindowEventListener.h"
    64 
    65 // for compatibility
    66 #include "GraphicsEngine.h"
     55#include "GraphicsManager.h"
    6756
    6857namespace orxonox
    6958{
    70     GSGraphics::GSGraphics()
    71         : GameState<GSRoot>("graphics")
    72         , renderWindow_(0)
    73         , viewport_(0)
    74         , bWindowEventListenerUpdateRequired_(false)
     59    AddGameState(GSGraphics, "graphics");
     60
     61    GSGraphics::GSGraphics(const std::string& name)
     62        : GameState(name)
    7563        , inputManager_(0)
    7664        , console_(0)
    7765        , guiManager_(0)
    78         , ogreRoot_(0)
    79         , ogreLogger_(0)
    80         , graphicsEngine_(0)
     66        , graphicsManager_(0)
    8167        , masterKeyBinder_(0)
     68        , masterInputState_(0)
    8269        , debugOverlay_(0)
    8370    {
    8471        RegisterRootObject(GSGraphics);
     72    }
     73
     74    GSGraphics::~GSGraphics()
     75    {
     76    }
     77
     78    /**
     79    @brief
     80        this function does nothing
     81
     82        Indeed. Here goes nothing.
     83    */
     84    void GSGraphics::setConfigValues()
     85    {
     86    }
     87
     88    /**
     89    @brief
     90        This function is called when we enter this game state.
     91
     92        Since graphics is very important for our game this function does quite a lot:
     93        \li starts graphics manager
     94        \li loads debug overlay
     95        \li manages render window
     96        \li creates input manager
     97        \li loads master key bindings
     98        \li loads ingame console
     99        \li loads GUI interface (GUIManager)
     100        \li creates console command to toggle GUI
     101    */
     102    void GSGraphics::activate()
     103    {
     104        GameMode::setShowsGraphics(true);
     105
    85106        setConfigValues();
    86     }
    87 
    88     GSGraphics::~GSGraphics()
    89     {
    90     }
    91 
    92     void GSGraphics::setConfigValues()
    93     {
    94         SetConfigValue(resourceFile_,    "resources.cfg")
    95             .description("Location of the resources file in the data path.");
    96         SetConfigValue(ogreConfigFile_,  "ogre.cfg")
    97             .description("Location of the Ogre config file");
    98         SetConfigValue(ogrePluginsFolder_, ORXONOX_OGRE_PLUGINS_FOLDER)
    99             .description("Folder where the Ogre plugins are located.");
    100         SetConfigValue(ogrePlugins_, ORXONOX_OGRE_PLUGINS)
    101             .description("Comma separated list of all plugins to load.");
    102         SetConfigValue(ogreLogFile_,     "ogre.log")
    103             .description("Logfile for messages from Ogre. Use \"\" to suppress log file creation.");
    104         SetConfigValue(ogreLogLevelTrivial_ , 5)
    105             .description("Corresponding orxonox debug level for ogre Trivial");
    106         SetConfigValue(ogreLogLevelNormal_  , 4)
    107             .description("Corresponding orxonox debug level for ogre Normal");
    108         SetConfigValue(ogreLogLevelCritical_, 2)
    109             .description("Corresponding orxonox debug level for ogre Critical");
    110     }
    111 
    112     void GSGraphics::enter()
    113     {
    114         Core::setShowsGraphics(true);
    115 
    116         // initialise graphics engine. Doesn't load the render window yet!
    117         graphicsEngine_ = new GraphicsEngine();
    118 
    119         // Ogre setup procedure
    120         setupOgre();
    121         // load all the required plugins for Ogre
    122         loadOgrePlugins();
    123         // read resource declaration file
    124         this->declareResources();
    125         // Reads ogre config and creates the render window
    126         this->loadRenderer();
    127 
    128         // TODO: Spread this so that this call only initialises things needed for the Console and GUI
    129         this->initialiseResources();
    130 
    131         // We want to get informed whenever an object of type WindowEventListener is created
    132         // in order to later update the window size.
    133         bWindowEventListenerUpdateRequired_ = false;
    134         RegisterConstructionCallback(GSGraphics, orxonox::WindowEventListener, requestWindowEventListenerUpdate);
     107
     108        // initialise graphics manager. Doesn't load the render window yet!
     109        this->graphicsManager_ = new GraphicsManager();
     110        this->graphicsManager_->initialise();
    135111
    136112        // load debug overlay
     
    139115        Loader::open(debugOverlay_);
    140116
     117        // The render window width and height are used to set up the mouse movement.
     118        size_t windowHnd = 0;
     119        Ogre::RenderWindow* renderWindow = GraphicsManager::getInstance().getRenderWindow();
     120        renderWindow->getCustomAttribute("WINDOW", &windowHnd);
     121
    141122        // Calls the InputManager which sets up the input devices.
    142         // The render window width and height are used to set up the mouse movement.
    143123        inputManager_ = new InputManager();
    144         size_t windowHnd = 0;
    145         this->renderWindow_->getCustomAttribute("WINDOW", &windowHnd);
    146         inputManager_->initialise(windowHnd, renderWindow_->getWidth(), renderWindow_->getHeight(), true);
    147         // Configure master input state with a KeyBinder
     124        inputManager_->initialise(windowHnd, renderWindow->getWidth(), renderWindow->getHeight(), true);
     125
     126        // load master key bindings
     127        masterInputState_ = InputManager::getInstance().createInputState<SimpleInputState>("master", true);
    148128        masterKeyBinder_ = new KeyBinder();
    149129        masterKeyBinder_->loadBindings("masterKeybindings.ini");
    150         inputManager_->getMasterInputState()->addKeyHandler(masterKeyBinder_);
     130        masterInputState_->setKeyHandler(masterKeyBinder_);
    151131
    152132        // Load the InGameConsole
    153133        console_ = new InGameConsole();
    154         console_->initialise(this->renderWindow_->getWidth(), this->renderWindow_->getHeight());
     134        console_->initialise(renderWindow->getWidth(), renderWindow->getHeight());
    155135
    156136        // load the CEGUI interface
    157137        guiManager_ = new GUIManager();
    158         guiManager_->initialise(this->renderWindow_);
    159 
    160         // add console commands
    161         FunctorMember<GSGraphics>* functor1 = createFunctor(&GSGraphics::printScreen);
    162         functor1->setObject(this);
    163         ccPrintScreen_ = createConsoleCommand(functor1, "printScreen");
    164         CommandExecutor::addConsoleCommandShortcut(ccPrintScreen_);
    165     }
    166 
    167     void GSGraphics::leave()
    168     {
    169         using namespace Ogre;
    170 
    171         delete this->ccPrintScreen_;
    172 
    173         // remove our WindowEventListener first to avoid bad calls after the window has been destroyed
    174         Ogre::WindowEventUtilities::removeWindowEventListener(this->renderWindow_, this);
     138        guiManager_->initialise(renderWindow);
     139
     140        // add console command to toggle GUI
     141        FunctorMember<GSGraphics>* functor = createFunctor(&GSGraphics::toggleGUI);
     142        functor->setObject(this);
     143        this->ccToggleGUI_ = createConsoleCommand(functor, "toggleGUI");
     144        CommandExecutor::addConsoleCommandShortcut(this->ccToggleGUI_);
     145
     146        // enable master input
     147        InputManager::getInstance().requestEnterState("master");
     148    }
     149
     150    /**
     151    @brief
     152        This function is called when the game state is left
     153
     154        Created references, input states and console commands are deleted.
     155    */
     156    void GSGraphics::deactivate()
     157    {
     158
     159        if (this->ccToggleGUI_)
     160        {
     161            delete this->ccToggleGUI_;
     162            this->ccToggleGUI_ = 0;
     163        }
     164
     165        masterInputState_->setHandler(0);
     166        InputManager::getInstance().requestDestroyState("master");
     167        delete this->masterKeyBinder_;
    175168
    176169        delete this->guiManager_;
    177 
    178170        delete this->console_;
    179 
    180         //inputManager_->getMasterInputState()->removeKeyHandler(this->masterKeyBinder_);
    181         delete this->masterKeyBinder_;
    182         delete this->inputManager_;
    183171
    184172        Loader::unload(this->debugOverlay_);
    185173        delete this->debugOverlay_;
    186174
    187         // unload all compositors
    188         Ogre::CompositorManager::getSingleton().removeAll();
    189 
    190         // destroy render window
    191         RenderSystem* renderer = this->ogreRoot_->getRenderSystem();
    192         renderer->destroyRenderWindow("Orxonox");
    193 
    194         /*** CODE SNIPPET, UNUSED ***/
    195         // Does the opposite of initialise()
    196         //ogreRoot_->shutdown();
    197         // Remove all resources and resource groups
    198         //StringVector groups = ResourceGroupManager::getSingleton().getResourceGroups();
    199         //for (StringVector::iterator it = groups.begin(); it != groups.end(); ++it)
    200         //{
    201         //    ResourceGroupManager::getSingleton().destroyResourceGroup(*it);
    202         //}
    203 
    204         //ParticleSystemManager::getSingleton().removeAllTemplates();
    205 
    206         // Shutdown the render system
    207         //this->ogreRoot_->setRenderSystem(0);
    208 
    209         delete this->ogreRoot_;
    210 
    211         // delete the ogre log and the logManager (since we have created it).
    212         this->ogreLogger_->getDefaultLog()->removeListener(this);
    213         this->ogreLogger_->destroyLog(Ogre::LogManager::getSingleton().getDefaultLog());
    214         delete this->ogreLogger_;
    215 
    216         delete graphicsEngine_;
    217 
    218         Core::setShowsGraphics(false);
     175        delete this->inputManager_;
     176        this->inputManager_ = 0;
     177
     178        delete graphicsManager_;
     179
     180        GameMode::setShowsGraphics(false);
     181    }
     182
     183    /**
     184    @brief
     185        Toggles the visibility of the current GUI
     186
     187        This function just executes a Lua function in the main script of the GUI by accessing the GUIManager.
     188        For more details on this function check out the Lua code.
     189    */
     190    void GSGraphics::toggleGUI()
     191    {
     192            GUIManager::getInstance().executeCode("toggleGUI()");
    219193    }
    220194
     
    227201        need the time. So we shouldn't run into problems.
    228202    */
    229     void GSGraphics::ticked(const Clock& time)
    230     {
     203    void GSGraphics::update(const Clock& time)
     204    {
     205        if (this->getActivity().topState)
     206        {
     207            // This state can not 'survive' on its own.
     208            // Load a user interface therefore
     209            Game::getInstance().requestState("mainMenu");
     210        }
     211
    231212        uint64_t timeBeforeTick = time.getRealMicroseconds();
    232213
    233         float dt = time.getDeltaTime();
    234 
    235         this->inputManager_->tick(dt);
    236         // tick console
    237         this->console_->tick(dt);
    238         this->tickChild(time);
    239 
    240         if (this->bWindowEventListenerUpdateRequired_)
    241         {
    242             // Update all WindowEventListeners for the case a new one was created.
    243             this->windowResized(this->renderWindow_);
    244             this->bWindowEventListenerUpdateRequired_ = false;
    245         }
     214        this->inputManager_->update(time);        // tick console
     215        this->console_->update(time);
     216        this->guiManager_->update(time);
    246217
    247218        uint64_t timeAfterTick = time.getRealMicroseconds();
    248219
    249         // Also add our tick time to the list in GSRoot
    250         this->getParent()->addTickTime(timeAfterTick - timeBeforeTick);
    251 
    252         // Update statistics overlay. Note that the values only change periodically in GSRoot.
    253         GraphicsEngine::getInstance().setAverageFramesPerSecond(this->getParent()->getAvgFPS());
    254         GraphicsEngine::getInstance().setAverageTickTime(this->getParent()->getAvgTickTime());
    255 
    256         // don't forget to call _fireFrameStarted in ogre to make sure
    257         // everything goes smoothly
    258         Ogre::FrameEvent evt;
    259         evt.timeSinceLastFrame = dt;
    260         evt.timeSinceLastEvent = dt; // note: same time, but shouldn't matter anyway
    261         ogreRoot_->_fireFrameStarted(evt);
    262 
    263         // Pump messages in all registered RenderWindows
    264         // This calls the WindowEventListener objects.
    265         Ogre::WindowEventUtilities::messagePump();
    266         // make sure the window stays active even when not focused
    267         // (probably only necessary on windows)
    268         this->renderWindow_->setActive(true);
    269 
    270         // render
    271         ogreRoot_->_updateAllRenderTargets();
    272 
    273         // again, just to be sure ogre works fine
    274         ogreRoot_->_fireFrameEnded(evt); // note: uses the same time as _fireFrameStarted
    275     }
    276 
    277     /**
    278     @brief
    279         Creates the Ogre Root object and sets up the ogre log.
    280     */
    281     void GSGraphics::setupOgre()
    282     {
    283         COUT(3) << "Setting up Ogre..." << std::endl;
    284 
    285         if (ogreConfigFile_ == "")
    286         {
    287             COUT(2) << "Warning: Ogre config file set to \"\". Defaulting to config.cfg" << std::endl;
    288             ModifyConfigValue(ogreConfigFile_, tset, "config.cfg");
    289         }
    290         if (ogreLogFile_ == "")
    291         {
    292             COUT(2) << "Warning: Ogre log file set to \"\". Defaulting to ogre.log" << std::endl;
    293             ModifyConfigValue(ogreLogFile_, tset, "ogre.log");
    294         }
    295 
    296         boost::filesystem::path ogreConfigFilepath(Core::getConfigPath() / this->ogreConfigFile_);
    297         boost::filesystem::path ogreLogFilepath(Core::getLogPath() / this->ogreLogFile_);
    298 
    299         // create a new logManager
    300         // Ogre::Root will detect that we've already created a Log
    301         ogreLogger_ = new Ogre::LogManager();
    302         COUT(4) << "Ogre LogManager created" << std::endl;
    303 
    304         // create our own log that we can listen to
    305         Ogre::Log *myLog;
    306         myLog = ogreLogger_->createLog(ogreLogFilepath.string(), true, false, false);
    307         COUT(4) << "Ogre Log created" << std::endl;
    308 
    309         myLog->setLogDetail(Ogre::LL_BOREME);
    310         myLog->addListener(this);
    311 
    312         COUT(4) << "Creating Ogre Root..." << std::endl;
    313 
    314         // check for config file existence because Ogre displays (caught) exceptions if not
    315         if (!boost::filesystem::exists(ogreConfigFilepath))
    316         {
    317             // create a zero sized file
    318             std::ofstream creator;
    319             creator.open(ogreConfigFilepath.string().c_str());
    320             creator.close();
    321         }
    322 
    323         // Leave plugins file empty. We're going to do that part manually later
    324         ogreRoot_ = new Ogre::Root("", ogreConfigFilepath.string(), ogreLogFilepath.string());
    325 
    326         COUT(3) << "Ogre set up done." << std::endl;
    327     }
    328 
    329     void GSGraphics::loadOgrePlugins()
    330     {
    331         // just to make sure the next statement doesn't segfault
    332         if (ogrePluginsFolder_ == "")
    333             ogrePluginsFolder_ = ".";
    334 
    335         boost::filesystem::path folder(ogrePluginsFolder_);
    336         // Do some SubString magic to get the comma separated list of plugins
    337         SubString plugins(ogrePlugins_, ",", " ", false, 92, false, 34, false, 40, 41, false, '\0');
    338         // Use backslash paths on Windows! file_string() already does that though.
    339         for (unsigned int i = 0; i < plugins.size(); ++i)
    340             ogreRoot_->loadPlugin((folder / plugins[i]).file_string());
    341     }
    342 
    343     void GSGraphics::declareResources()
    344     {
    345         CCOUT(4) << "Declaring Resources" << std::endl;
    346         //TODO: Specify layout of data file and maybe use xml-loader
    347         //TODO: Work with ressource groups (should be generated by a special loader)
    348 
    349         if (resourceFile_ == "")
    350         {
    351             COUT(2) << "Warning: Ogre resource file set to \"\". Defaulting to resources.cfg" << std::endl;
    352             ModifyConfigValue(resourceFile_, tset, "resources.cfg");
    353         }
    354 
    355         // Load resource paths from data file using configfile ressource type
    356         Ogre::ConfigFile cf;
    357         try
    358         {
    359             cf.load((Core::getMediaPath() / resourceFile_).string());
    360         }
    361         catch (...)
    362         {
    363             //COUT(1) << ex.getFullDescription() << std::endl;
    364             COUT(0) << "Have you forgotten to set the data path in orxnox.ini?" << std::endl;
    365             throw;
    366         }
    367 
    368         // Go through all sections & settings in the file
    369         Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();
    370 
    371         std::string secName, typeName, archName;
    372         while (seci.hasMoreElements())
    373         {
    374             try
    375             {
    376                 secName = seci.peekNextKey();
    377                 Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
    378                 Ogre::ConfigFile::SettingsMultiMap::iterator i;
    379                 for (i = settings->begin(); i != settings->end(); ++i)
    380                 {
    381                     typeName = i->first; // for instance "FileSystem" or "Zip"
    382                     archName = i->second; // name (and location) of archive
    383 
    384                     Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
    385                         (Core::getMediaPath() / archName).string(), typeName, secName);
    386                 }
    387             }
    388             catch (Ogre::Exception& ex)
    389             {
    390                 COUT(1) << ex.getFullDescription() << std::endl;
    391             }
    392         }
    393     }
    394 
    395     void GSGraphics::loadRenderer()
    396     {
    397         CCOUT(4) << "Configuring Renderer" << std::endl;
    398 
    399         if (!ogreRoot_->restoreConfig())
    400             if (!ogreRoot_->showConfigDialog())
    401                 ThrowException(InitialisationFailed, "Could not show Ogre configuration dialogue.");
    402 
    403         CCOUT(4) << "Creating render window" << std::endl;
    404 
    405         this->renderWindow_ = ogreRoot_->initialise(true, "Orxonox");
    406 
    407         Ogre::WindowEventUtilities::addWindowEventListener(this->renderWindow_, this);
    408 
    409         Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(0);
    410 
    411         // create a full screen default viewport
    412         this->viewport_ = this->renderWindow_->addViewport(0, 0);
    413 
    414         if (this->graphicsEngine_)
    415             this->graphicsEngine_->setViewport(this->viewport_);
    416     }
    417 
    418     void GSGraphics::initialiseResources()
    419     {
    420         CCOUT(4) << "Initialising resources" << std::endl;
    421         //TODO: Do NOT load all the groups, why are we doing that? And do we really do that? initialise != load...
    422         //try
    423         //{
    424             Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
    425             /*Ogre::StringVector str = Ogre::ResourceGroupManager::getSingleton().getResourceGroups();
    426             for (unsigned int i = 0; i < str.size(); i++)
    427             {
    428             Ogre::ResourceGroupManager::getSingleton().loadResourceGroup(str[i]);
    429             }*/
    430         //}
    431         //catch (...)
    432         //{
    433         //    CCOUT(2) << "Error: There was a serious error when initialising the resources." << std::endl;
    434         //    throw;
    435         //}
    436     }
    437 
    438     /**
    439     @brief
    440         Method called by the LogListener interface from Ogre.
    441         We use it to capture Ogre log messages and handle it ourselves.
    442     @param message
    443         The message to be logged
    444     @param lml
    445         The message level the log is using
    446     @param maskDebug
    447         If we are printing to the console or not
    448     @param logName
    449         The name of this log (so you can have several listeners
    450         for different logs, and identify them)
    451     */
    452     void GSGraphics::messageLogged(const std::string& message,
    453         Ogre::LogMessageLevel lml, bool maskDebug, const std::string& logName)
    454     {
    455         int orxonoxLevel;
    456         switch (lml)
    457         {
    458         case Ogre::LML_TRIVIAL:
    459             orxonoxLevel = this->ogreLogLevelTrivial_;
    460             break;
    461         case Ogre::LML_NORMAL:
    462             orxonoxLevel = this->ogreLogLevelNormal_;
    463             break;
    464         case Ogre::LML_CRITICAL:
    465             orxonoxLevel = this->ogreLogLevelCritical_;
    466             break;
    467         default:
    468             orxonoxLevel = 0;
    469         }
    470         OutputHandler::getOutStream().setOutputLevel(orxonoxLevel)
    471             << "Ogre: " << message << std::endl;
    472     }
    473 
    474     /**
    475     @brief
    476         Window has moved.
    477     @param rw
    478         The render window it occured in
    479     */
    480     void GSGraphics::windowMoved(Ogre::RenderWindow *rw)
    481     {
    482         for (ObjectList<orxonox::WindowEventListener>::iterator it = ObjectList<orxonox::WindowEventListener>::begin(); it; ++it)
    483             it->windowMoved();
     220        // Also add our tick time
     221        Game::getInstance().addTickTime(timeAfterTick - timeBeforeTick);
     222
     223        // Render
     224        this->graphicsManager_->update(time);
    484225    }
    485226
     
    490231        The render window it occured in
    491232    @note
    492         GraphicsEngine has a render window stored itself. This is the same
     233        GraphicsManager has a render window stored itself. This is the same
    493234        as rw. But we have to be careful when using multiple render windows!
    494235    */
    495     void GSGraphics::windowResized(Ogre::RenderWindow *rw)
    496     {
    497         for (ObjectList<orxonox::WindowEventListener>::iterator it = ObjectList<orxonox::WindowEventListener>::begin(); it; ++it)
    498             it->windowResized(this->renderWindow_->getWidth(), this->renderWindow_->getHeight());
    499 
     236    void GSGraphics::windowResized(unsigned int newWidth, unsigned int newHeight)
     237    {
    500238        // OIS needs this under linux even if we only use relative input measurement.
    501239        if (this->inputManager_)
    502             this->inputManager_->setWindowExtents(renderWindow_->getWidth(), renderWindow_->getHeight());
     240            this->inputManager_->setWindowExtents(newWidth, newHeight);
    503241    }
    504242
     
    509247        The render window it occured in
    510248    */
    511     void GSGraphics::windowFocusChange(Ogre::RenderWindow *rw)
    512     {
    513         for (ObjectList<orxonox::WindowEventListener>::iterator it = ObjectList<orxonox::WindowEventListener>::begin(); it; ++it)
    514             it->windowFocusChanged();
    515 
     249    void GSGraphics::windowFocusChanged()
     250    {
    516251        // instruct InputManager to clear the buffers (core library so we cannot use the interface)
    517252        if (this->inputManager_)
     
    519254    }
    520255
    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     }
    539256}
  • code/trunk/src/orxonox/gamestates/GSGraphics.h

    r2797 r2896  
    2323 *      Reto Grieder
    2424 *   Co-authors:
    25  *      ...
     25 *      Benjamin Knecht (documentation)
    2626 *
    2727 */
     28
     29 /**
     30    @file
     31    @brief Declaration of the Graphics GameState class.
     32  */
    2833
    2934#ifndef _GSGraphics_H__
     
    3136
    3237#include "OrxonoxPrereqs.h"
    33 #include <OgrePrerequisites.h>
    34 #ifndef NOMINMAX
    35 #  define NOMINMAX // required to stop windows.h screwing up std::min definition
    36 #endif
    37 #include <OgreWindowEventUtilities.h>
    3838#include "core/GameState.h"
    39 #include "core/OrxonoxClass.h"
    40 #include "GSRoot.h"
     39#include "tools/WindowEventListener.h"
    4140
    4241namespace orxonox
    4342{
    44     class _OrxonoxExport GSGraphics : public GameState<GSRoot>, public OrxonoxClass,
    45                                       public Ogre::WindowEventListener, public Ogre::LogListener
     43    /**
     44    @class GSGraphics
     45    @brief
     46        Game state used when displaying graphics of any kind
     47
     48        This game state is only left out if we start a dedicated server where no graphics are present.
     49    */
     50    class _OrxonoxExport GSGraphics : public GameState, public WindowEventListener
    4651    {
    47         friend class ClassIdentifier<GSGraphics>;
    48 
    4952    public:
    50         GSGraphics();
     53        GSGraphics(const std::string& name);
    5154        ~GSGraphics();
    52 
    53         Ogre::Root*     getOgreRoot()   { return this->ogreRoot_  ; }
    54         Ogre::Viewport* getViewport()   { return this->viewport_  ; }
    55         GUIManager*     getGUIManager() { return this->guiManager_; }
    56 
    57     private: // functions
    58         void enter();
    59         void leave();
    60         void ticked(const Clock& time);
    61 
    6255        void setConfigValues();
    6356
    64         void setupOgre();
    65         void loadOgrePlugins();
    66         void declareResources();
    67         void loadRenderer();
    68         void initialiseResources();
     57        void activate();
     58        void deactivate();
     59        void update(const Clock& time);
    6960
    70         // console commands
    71         void printScreen();
     61        void toggleGUI();
    7262
    73         // event from Ogre::LogListener
    74         void messageLogged(const std::string& message, Ogre::LogMessageLevel lml,
    75             bool maskDebug, const std::string& logName);
    76 
    77         // window events from Ogre::WindowEventListener
    78         void windowMoved       (Ogre::RenderWindow* rw);
    79         void windowResized     (Ogre::RenderWindow* rw);
    80         void windowFocusChange (Ogre::RenderWindow* rw);
    81         void windowClosed      (Ogre::RenderWindow* rw);
    82 
    83         void requestWindowEventListenerUpdate() { this->bWindowEventListenerUpdateRequired_ = true; }
    84 
    85     private: // variables
    86         Ogre::RenderWindow*   renderWindow_;          //!< the current render window
    87         Ogre::Viewport*       viewport_;              //!< default full size viewport
    88         bool bWindowEventListenerUpdateRequired_;     //!< True if a new WindowEventListener was created but not yet updated.
     63    private:
     64        // Window events from WindowEventListener
     65        void windowResized(unsigned int newWidth, unsigned int newHeight);
     66        void windowFocusChanged();
    8967
    9068        // managed singletons
    91         InputManager*         inputManager_;
     69        InputManager*         inputManager_;        //!< Reference to input management
    9270        InGameConsole*        console_;
    93         GUIManager*           guiManager_;
    94         Ogre::Root*           ogreRoot_;                  //!< Ogre's root
    95         Ogre::LogManager*     ogreLogger_;
    96         GraphicsEngine*       graphicsEngine_;   //!< Interface to Ogre
     71        GUIManager*           guiManager_;          //!< Interface to GUI
     72        GraphicsManager*      graphicsManager_;     //!< Interface to Ogre
    9773
    98         KeyBinder*            masterKeyBinder_;
     74        KeyBinder*            masterKeyBinder_;     //!< Key binder for master key bindings
     75        SimpleInputState*     masterInputState_;    //!< Special input state for master input
    9976        XMLFile*              debugOverlay_;
    100 
    101         // config values
    102         std::string           resourceFile_;             //!< resources file name
    103         std::string           ogreConfigFile_;           //!< ogre config file name
    104         std::string           ogrePluginsFolder_;        //!< Folder where the Ogre plugins are located
    105         std::string           ogrePlugins_;              //!< Comma separated list of all plugins to load
    106         std::string           ogreLogFile_;              //!< log file name for Ogre log messages
    107         int                   ogreLogLevelTrivial_;      //!< Corresponding Orxonx debug level for LL_TRIVIAL
    108         int                   ogreLogLevelNormal_;       //!< Corresponding Orxonx debug level for LL_NORMAL
    109         int                   ogreLogLevelCritical_;     //!< Corresponding Orxonx debug level for LL_CRITICAL
    110 
    111         // console commands
    112         ConsoleCommand*       ccPrintScreen_;
     77        ConsoleCommand*       ccToggleGUI_;         //!< Console command to toggle GUI
    11378    };
    11479}
  • code/trunk/src/orxonox/gamestates/GSIOConsole.cc

    r2087 r2896  
    3636
    3737#include "core/ConsoleCommand.h"
     38#include "core/Game.h"
    3839
    3940namespace orxonox
    4041{
    41     GSIOConsole::GSIOConsole()
    42         : GameState<GSRoot>("ioConsole")
     42    AddGameState(GSIOConsole, "ioConsole");
     43
     44    GSIOConsole::GSIOConsole(const std::string& name)
     45        : GameState(name)
    4346    {
    4447    }
     
    4851    }
    4952
    50     void GSIOConsole::enter()
     53    void GSIOConsole::activate()
    5154    {
     55        {
     56            FunctorMember<GSIOConsole>* functor = createFunctor(&GSIOConsole::loadMenu);
     57            functor->setObject(this);
     58            this->ccLoadMenu_ = createConsoleCommand(functor, "loadMenu");
     59            CommandExecutor::addConsoleCommandShortcut(this->ccLoadMenu_);
     60        }
    5261    }
    5362
    54     void GSIOConsole::leave()
     63    void GSIOConsole::deactivate()
    5564    {
     65        if (this->ccLoadMenu_)
     66        {
     67            delete this->ccLoadMenu_;
     68            this->ccLoadMenu_ = 0;
     69        }
    5670    }
    5771
    58     void GSIOConsole::ticked(const Clock& time)
     72    void GSIOConsole::update(const Clock& time)
    5973    {
     74        std::cout << ">";
    6075        std::string command;
    6176        std::getline(std::cin, command);
    6277        CommandExecutor::execute(command, true);
    63        
    64         tickChild(time);
     78    }
     79
     80    void GSIOConsole::loadMenu()
     81    {
     82        Game::getInstance().popState();
     83        Game::getInstance().requestStates("graphics, mainMenu");
    6584    }
    6685}
  • code/trunk/src/orxonox/gamestates/GSIOConsole.h

    r1755 r2896  
    3131
    3232#include "OrxonoxPrereqs.h"
    33 #include <OgrePrerequisites.h>
    3433#include "core/GameState.h"
    35 #include "GSRoot.h"
    3634
    3735namespace orxonox
    3836{
    39     class _OrxonoxExport GSIOConsole : public GameState<GSRoot>
     37    class _OrxonoxExport GSIOConsole : public GameState
    4038    {
    4139    public:
    42         GSIOConsole();
     40        GSIOConsole(const std::string& name);
    4341        ~GSIOConsole();
    4442
     43        void activate();
     44        void deactivate();
     45        void update(const Clock& time);
     46
    4547    private:
    46         void enter();
    47         void leave();
    48         void ticked(const Clock& time);
     48        void loadMenu();
     49
     50        // console commands
     51        ConsoleCommand* ccLoadMenu_;
    4952    };
    5053}
  • code/trunk/src/orxonox/gamestates/GSLevel.cc

    r2826 r2896  
    2424 *   Co-authors:
    2525 *      Fabian 'x3n' Landau
     26 *      Benjamin Knecht
    2627 *
    2728 */
     
    3940#include "core/CommandLine.h"
    4041#include "core/ConfigValueIncludes.h"
     42#include "core/Core.h"
    4143#include "core/CoreIncludes.h"
    42 #include "core/Core.h"
     44#include "core/Game.h"
     45#include "core/GameMode.h"
    4346#include "objects/Tickable.h"
    4447#include "objects/Radar.h"
    4548#include "CameraManager.h"
     49#include "GraphicsManager.h"
    4650#include "LevelManager.h"
    4751#include "PlayerManager.h"
     52#include "gui/GUIManager.h"
    4853
    4954namespace orxonox
    5055{
     56    AddGameState(GSLevel, "level");
     57
    5158    SetCommandLineArgument(level, "presentation_dm.oxw").shortcut("l");
    52 
    53     GSLevel::GSLevel()
    54 //        : GameState<GSGraphics>(name)
    55         : keyBinder_(0)
    56         , inputState_(0)
     59    SetConsoleCommand(GSLevel, showIngameGUI, true);
     60
     61    GSLevel::GSLevel(const std::string& name)
     62        : GameState(name)
     63        , keyBinder_(0)
     64        , gameInputState_(0)
     65        , guiMouseOnlyInputState_(0)
     66        , guiKeysOnlyInputState_(0)
    5767        , radar_(0)
    5868        , startFile_(0)
     
    6474        this->ccKeybind_ = 0;
    6575        this->ccTkeybind_ = 0;
    66 
     76    }
     77
     78    GSLevel::~GSLevel()
     79    {
     80    }
     81
     82    void GSLevel::setConfigValues()
     83    {
     84        SetConfigValue(keyDetectorCallbackCode_, "KeybindBindingStringKeyName=");
     85    }
     86
     87    void GSLevel::activate()
     88    {
    6789        setConfigValues();
    68     }
    69 
    70     GSLevel::~GSLevel()
    71     {
    72     }
    73 
    74     void GSLevel::setConfigValues()
    75     {
    76         SetConfigValue(keyDetectorCallbackCode_, "KeybindBindingStringKeyName=");
    77     }
    78 
    79     void GSLevel::enter(Ogre::Viewport* viewport)
    80     {
    81         if (Core::showsGraphics())
    82         {
    83             inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("game", 20);
     90
     91        if (GameMode::showsGraphics())
     92        {
     93            gameInputState_ = InputManager::getInstance().createInputState<SimpleInputState>("game");
    8494            keyBinder_ = new KeyBinder();
    8595            keyBinder_->loadBindings("keybindings.ini");
    86             inputState_->setHandler(keyBinder_);
     96            gameInputState_->setHandler(keyBinder_);
     97
     98            guiMouseOnlyInputState_ = InputManager::getInstance().createInputState<SimpleInputState>("guiMouseOnly");
     99            guiMouseOnlyInputState_->setMouseHandler(GUIManager::getInstancePtr());
     100
     101            guiKeysOnlyInputState_ = InputManager::getInstance().createInputState<SimpleInputState>("guiKeysOnly");
     102            guiKeysOnlyInputState_->setKeyHandler(GUIManager::getInstancePtr());
    87103
    88104            // create the global CameraManager
    89             assert(viewport);
    90             this->cameraManager_ = new CameraManager(viewport);
     105            this->cameraManager_ = new CameraManager(GraphicsManager::getInstance().getViewport());
    91106
    92107            // Start the Radar
     
    96111        this->playerManager_ = new PlayerManager();
    97112
    98         if (Core::isMaster())
     113        if (GameMode::isMaster())
    99114        {
    100115            // create the global LevelManager
     
    104119        }
    105120
    106         if (Core::showsGraphics())
    107         {
    108             // TODO: insert slomo console command with
    109             // .accessLevel(AccessLevel::Offline).defaultValue(0, 1.0).axisParamIndex(0).isAxisRelative(false);
    110 
     121        if (GameMode::showsGraphics())
     122        {
    111123            // keybind console command
    112124            FunctorMember<GSLevel>* functor1 = createFunctor(&GSLevel::keybind);
     
    126138    }
    127139
    128     void GSLevel::leave()
     140    void GSLevel::showIngameGUI(bool show)
     141    {
     142        if (show)
     143        {
     144            GUIManager::getInstancePtr()->showGUI("inGameTest");
     145            GUIManager::getInstancePtr()->executeCode("showCursor()");
     146            InputManager::getInstance().requestEnterState("guiMouseOnly");
     147        }
     148        else
     149        {
     150            GUIManager::getInstancePtr()->executeCode("hideGUI(\"inGameTest\")");
     151            GUIManager::getInstancePtr()->executeCode("hideCursor()");
     152            InputManager::getInstance().requestLeaveState("guiMouseOnly");
     153        }
     154    }
     155
     156    void GSLevel::deactivate()
    129157    {
    130158        // destroy console commands
     
    139167            this->ccTkeybind_ = 0;
    140168        }
     169
    141170
    142171        // this call will delete every BaseObject!
     
    146175        //Loader::close();
    147176
    148         if (Core::showsGraphics())
     177        if (GameMode::showsGraphics())
    149178            InputManager::getInstance().requestLeaveState("game");
    150179
    151         if (Core::isMaster())
     180        if (GameMode::isMaster())
    152181            this->unloadLevel();
    153182
     
    176205        }
    177206
    178         if (Core::showsGraphics())
    179         {
    180             inputState_->setHandler(0);
     207        if (GameMode::showsGraphics())
     208        {
     209            gameInputState_->setHandler(0);
     210            guiMouseOnlyInputState_->setHandler(0);
     211            guiKeysOnlyInputState_->setHandler(0);
    181212            InputManager::getInstance().requestDestroyState("game");
    182213            if (this->keyBinder_)
     
    188219    }
    189220
    190     void GSLevel::ticked(const Clock& time)
    191     {
    192         // Commented by 1337: Temporarily moved to GSGraphics.
     221    void GSLevel::update(const Clock& time)
     222    {
     223        // Note: Temporarily moved to GSGraphics.
    193224        //// Call the scene objects
    194225        //for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it)
     
    233264        Command string that can be executed by the CommandExecutor
    234265        OR: Internal string "KeybindBindingStringKeyName=" used for the second call to identify
    235         the key/button/axis that has been activated. This is configured above in enter().
     266        the key/button/axis that has been activated. This is configured above in activate().
    236267    */
    237268    void GSLevel::keybindInternal(const std::string& command, bool bTemporary)
    238269    {
    239         if (Core::showsGraphics())
     270        if (GameMode::showsGraphics())
    240271        {
    241272            static std::string bindingString = "";
  • code/trunk/src/orxonox/gamestates/GSLevel.h

    r2790 r2896  
    2323 *      Reto Grieder
    2424 *   Co-authors:
    25  *      ...
     25 *      Benjamin Knecht
    2626 *
    2727 */
     
    3131
    3232#include "OrxonoxPrereqs.h"
    33 #include <OgrePrerequisites.h>
    3433#include "core/OrxonoxClass.h"
     34#include "core/GameState.h"
    3535
    3636namespace orxonox
    3737{
    38     class _OrxonoxExport GSLevel : public OrxonoxClass
     38    class _OrxonoxExport GSLevel : public GameState, public OrxonoxClass
    3939    {
    40         friend class ClassIdentifier<GSLevel>;
    4140    public:
    42         GSLevel();
     41        GSLevel(const std::string& name);
    4342        ~GSLevel();
    44 
    45         // was private before (is public now because of console command in GSStandalone)
    4643        void setConfigValues();
    4744
     45        void activate();
     46        void deactivate();
     47        void update(const Clock& time);
     48
     49        static void showIngameGUI(bool show);
     50
    4851    protected:
    49         void enter(Ogre::Viewport* viewport);
    50         void leave();
    51         void ticked(const Clock& time);
    52 
    5352        void loadLevel();
    5453        void unloadLevel();
     
    5958        void keybindInternal(const std::string& command, bool bTemporary);
    6059
    61         KeyBinder*            keyBinder_;        //!< tool that loads and manages the input bindings
    62         SimpleInputState*     inputState_;
    63         Radar*                radar_;            //!< represents the Radar (not the HUD part)
    64         XMLFile*              startFile_;        //!< current hard coded default level
    65         CameraManager*        cameraManager_;
    66         LevelManager*         levelManager_;
    67         PlayerManager*        playerManager_;
     60        KeyBinder*            keyBinder_;               //!< tool that loads and manages the input bindings
     61        SimpleInputState*     gameInputState_;          //!< input state for normal ingame playing
     62        SimpleInputState*     guiMouseOnlyInputState_;  //!< input state if we only need the mouse to use the GUI
     63        SimpleInputState*     guiKeysOnlyInputState_;   //!< input state if we only need the keys to use the GUI
     64        Radar*                radar_;                   //!< represents the Radar (not the HUD part)
     65        XMLFile*              startFile_;               //!< current hard coded default level
     66        CameraManager*        cameraManager_;           //!< camera manager for this level
     67        LevelManager*         levelManager_;            //!< global level manager
     68        PlayerManager*        playerManager_;           //!< player manager for this level
    6869
    6970        //##### ConfigValues #####
     
    7374        ConsoleCommand*       ccKeybind_;
    7475        ConsoleCommand*       ccTkeybind_;
    75 
    7676    };
    7777}
  • code/trunk/src/orxonox/gamestates/GSRoot.cc

    r2797 r2896  
    3232#include "util/Exception.h"
    3333#include "util/Debug.h"
    34 #include "core/Core.h"
    35 #include "core/Factory.h"
    36 #include "core/ConfigValueIncludes.h"
    37 #include "core/CoreIncludes.h"
     34#include "core/Clock.h"
     35#include "core/Game.h"
     36#include "core/GameMode.h"
     37#include "core/CommandLine.h"
    3838#include "core/ConsoleCommand.h"
    39 #include "core/CommandLine.h"
    40 #include "core/Shell.h"
    41 #include "core/TclBind.h"
    42 #include "core/TclThreadManager.h"
    43 #include "core/LuaBind.h"
     39#include "tools/TimeFactorListener.h"
    4440#include "tools/Timer.h"
    4541#include "objects/Tickable.h"
    4642
    47 #ifdef ORXONOX_PLATFORM_WINDOWS
    48 #  ifndef WIN32_LEAN_AND_MEAN
    49 #    define WIN32_LEAN_AND_MEAN
    50 #  endif
    51 #  ifndef NOMINMAX
    52 #    define NOMINMAX // required to stop windows.h screwing up std::min definition
    53 #  endif
    54 #  include "windows.h"
    55 #endif
    56 
    5743namespace orxonox
    5844{
    59     SetCommandLineArgument(limitToCPU, 1).information("0: off | #cpu");
    60 
    61     GSRoot::GSRoot()
    62         : RootGameState("root")
     45    AddGameState(GSRoot, "root");
     46    SetCommandLineSwitch(console);
     47    // Shortcuts for easy direct loading
     48    SetCommandLineSwitch(server);
     49    SetCommandLineSwitch(client);
     50    SetCommandLineSwitch(dedicated);
     51    SetCommandLineSwitch(standalone);
     52
     53    GSRoot::GSRoot(const std::string& name)
     54        : GameState(name)
    6355        , timeFactor_(1.0f)
    6456        , bPaused_(false)
    6557        , timeFactorPauseBackup_(1.0f)
    66         , tclBind_(0)
    67         , tclThreadManager_(0)
    68         , shell_(0)
    69     {
    70         RegisterRootObject(GSRoot);
    71         setConfigValues();
    72 
     58    {
    7359        this->ccSetTimeFactor_ = 0;
    7460        this->ccPause_ = 0;
     
    7965    }
    8066
    81     void GSRoot::setConfigValues()
    82     {
    83         SetConfigValue(statisticsRefreshCycle_, 250000)
    84             .description("Sets the time in microseconds interval at which average fps, etc. get updated.");
    85         SetConfigValue(statisticsAvgLength_, 1000000)
    86             .description("Sets the time in microseconds interval at which average fps, etc. gets calculated.");
    87     }
    88 
    89     void GSRoot::enter()
    90     {
    91         // creates the class hierarchy for all classes with factories
    92         Factory::createClassHierarchy();
    93 
     67    void GSRoot::activate()
     68    {
    9469        // reset game speed to normal
    95         timeFactor_ = 1.0f;
    96 
    97         // reset frame counter
    98         this->statisticsStartTime_ = 0;
    99         this->statisticsTickTimes_.clear();
    100         this->periodTickTime_ = 0;
    101         this->avgFPS_ = 0.0f;
    102         this->avgTickTime_ = 0.0f;
    103 
    104         // Create the lua interface
    105         this->luaBind_ = new LuaBind();
    106 
    107         // initialise TCL
    108         this->tclBind_ = new TclBind(Core::getMediaPathString());
    109         this->tclThreadManager_ = new TclThreadManager(tclBind_->getTclInterpreter());
    110 
    111         // create a shell
    112         this->shell_ = new Shell();
    113 
    114         // limit the main thread to the first core so that QueryPerformanceCounter doesn't jump
    115         // do this after ogre has initialised. Somehow Ogre changes the settings again (not through
    116         // the timer though).
    117         int limitToCPU = CommandLine::getValue("limitToCPU");
    118         if (limitToCPU > 0)
    119             setThreadAffinity((unsigned int)(limitToCPU - 1));
    120 
    121         {
    122             // add console commands
    123             FunctorMember<GSRoot>* functor = createFunctor(&GSRoot::exitGame);
    124             functor->setObject(this);
    125             this->ccExit_ = createConsoleCommand(functor, "exit");
    126             CommandExecutor::addConsoleCommandShortcut(this->ccExit_);
    127         }
    128 
    129         {
    130             // add console commands
    131             FunctorMember01<GameStateBase, const std::string&>* functor = createFunctor(&GameStateBase::requestState);
    132             functor->setObject(this);
    133             this->ccSelectGameState_ = createConsoleCommand(functor, "selectGameState");
    134             CommandExecutor::addConsoleCommandShortcut(this->ccSelectGameState_);
    135         }
     70        this->timeFactor_ = 1.0f;
    13671
    13772        {
     
    15085            CommandExecutor::addConsoleCommandShortcut(this->ccPause_).accessLevel(AccessLevel::Offline);
    15186        }
    152     }
    153 
    154     void GSRoot::leave()
    155     {
    156         // destroy console commands
    157         delete this->ccExit_;
    158         delete this->ccSelectGameState_;
    159 
    160         delete this->shell_;
    161         delete this->tclThreadManager_;
    162         delete this->tclBind_;
    163 
    164         delete this->luaBind_;
    165 
     87
     88        // Load level directly?
     89        bool loadLevel = false;
     90        if (CommandLine::getValue("standalone").getBool())
     91        {
     92            Game::getInstance().requestStates("graphics, standalone, level");
     93            loadLevel = true;
     94        }
     95        if (CommandLine::getValue("server").getBool())
     96        {
     97            Game::getInstance().requestStates("graphics, server, level");
     98            loadLevel = true;
     99        }
     100        if (CommandLine::getValue("client").getBool())
     101        {
     102            Game::getInstance().requestStates("graphics, client, level");
     103            loadLevel = true;
     104        }
     105        if (CommandLine::getValue("dedicated").getBool())
     106        {
     107            Game::getInstance().requestStates("dedicated, level");
     108            loadLevel = true;
     109        }
     110       
     111        // Determine where to start otherwise
     112        if (!loadLevel && !CommandLine::getValue("console").getBool())
     113        {
     114            // Also load graphics
     115            Game::getInstance().requestState("graphics");
     116        }
     117    }
     118
     119    void GSRoot::deactivate()
     120    {
    166121        if (this->ccSetTimeFactor_)
    167122        {
     
    177132    }
    178133
    179     void GSRoot::ticked(const Clock& time)
    180     {
     134    void GSRoot::update(const Clock& time)
     135    {
     136        if (this->getActivity().topState)
     137        {
     138            // This state can not 'survive' on its own.
     139            // Load a user interface therefore
     140            Game::getInstance().requestState("ioConsole");
     141        }
     142
    181143        uint64_t timeBeforeTick = time.getRealMicroseconds();
    182 
    183         TclThreadManager::getInstance().tick(time.getDeltaTime());
    184144
    185145        for (ObjectList<TimerBase>::iterator it = ObjectList<TimerBase>::begin(); it; ++it)
     
    200160        uint64_t timeAfterTick = time.getRealMicroseconds();
    201161
    202         // STATISTICS
    203         assert(timeAfterTick - timeBeforeTick >= 0 );
    204         statisticsTickInfo tickInfo = {timeAfterTick, timeAfterTick - timeBeforeTick};
    205         statisticsTickTimes_.push_back(tickInfo);
    206         assert(statisticsTickTimes_.back().tickLength==tickInfo.tickLength);
    207         this->periodTickTime_ += tickInfo.tickLength;
    208 
    209         // Ticks GSGraphics or GSDedicated
    210         this->tickChild(time);
    211 
    212         if (timeAfterTick > statisticsStartTime_ + statisticsRefreshCycle_)
    213         {
    214             std::list<statisticsTickInfo>::iterator it = this->statisticsTickTimes_.begin();
    215             assert(it != this->statisticsTickTimes_.end());
    216             int64_t lastTime = timeAfterTick - statisticsAvgLength_;
    217             if ((int64_t)it->tickTime < lastTime)
    218             {
    219                 do
    220                 {
    221                     assert(this->periodTickTime_ > it->tickLength);
    222                     this->periodTickTime_ -= it->tickLength;
    223                     ++it;
    224                     assert(it != this->statisticsTickTimes_.end());
    225                 } while ((int64_t)it->tickTime < lastTime);
    226                 this->statisticsTickTimes_.erase(this->statisticsTickTimes_.begin(), it);
    227             }
    228 
    229             uint32_t framesPerPeriod = this->statisticsTickTimes_.size();
    230             this->avgFPS_ = (float)framesPerPeriod / (timeAfterTick - this->statisticsTickTimes_.front().tickTime) * 1000000.0;
    231             this->avgTickTime_ = (float)this->periodTickTime_ / framesPerPeriod / 1000.0;
    232 
    233             statisticsStartTime_ = timeAfterTick;
    234         }
    235 
    236     }
    237 
    238     /**
    239     @note
    240         The code of this function has been copied and adjusted from OGRE, an open source graphics engine.
    241             (Object-oriented Graphics Rendering Engine)
    242         For the latest info, see http://www.ogre3d.org/
    243 
    244         Copyright (c) 2000-2008 Torus Knot Software Ltd
    245 
    246         OGRE is licensed under the LGPL. For more info, see OGRE license.
    247     */
    248     void GSRoot::setThreadAffinity(unsigned int limitToCPU)
    249     {
    250 #ifdef ORXONOX_PLATFORM_WINDOWS
    251         // Get the current process core mask
    252         DWORD procMask;
    253         DWORD sysMask;
    254 #  if _MSC_VER >= 1400 && defined (_M_X64)
    255         GetProcessAffinityMask(GetCurrentProcess(), (PDWORD_PTR)&procMask, (PDWORD_PTR)&sysMask);
    256 #  else
    257         GetProcessAffinityMask(GetCurrentProcess(), &procMask, &sysMask);
    258 #  endif
    259 
    260         // If procMask is 0, consider there is only one core available
    261         // (using 0 as procMask will cause an infinite loop below)
    262         if (procMask == 0)
    263             procMask = 1;
    264 
    265         // if the core specified with limitToCPU is not available, take the lowest one
    266         if (!(procMask & (1 << limitToCPU)))
    267             limitToCPU = 0;
    268 
    269         // Find the lowest core that this process uses and limitToCPU suggests
    270         DWORD threadMask = 1;
    271         while ((threadMask & procMask) == 0 || (threadMask < (1u << limitToCPU)))
    272             threadMask <<= 1;
    273 
    274         // Set affinity to the first core
    275         SetThreadAffinityMask(GetCurrentThread(), threadMask);
    276 #endif
     162        // Also add our tick time
     163        Game::getInstance().addTickTime(timeAfterTick - timeBeforeTick);
    277164    }
    278165
     
    283170    void GSRoot::setTimeFactor(float factor)
    284171    {
    285         if (Core::isMaster())
     172        if (GameMode::isMaster())
    286173        {
    287174            if (!this->bPaused_)
     
    301188    void GSRoot::pause()
    302189    {
    303         if (Core::isMaster())
     190        if (GameMode::isMaster())
    304191        {
    305192            if (!this->bPaused_)
     
    316203        }
    317204    }
    318 
    319     ////////////////////////
    320     // TimeFactorListener //
    321     ////////////////////////
    322     float TimeFactorListener::timefactor_s = 1.0f;
    323 
    324     TimeFactorListener::TimeFactorListener()
    325     {
    326         RegisterRootObject(TimeFactorListener);
    327     }
    328205}
  • code/trunk/src/orxonox/gamestates/GSRoot.h

    r2710 r2896  
    3131
    3232#include "OrxonoxPrereqs.h"
    33 
    34 #include <list>
    35 #include <OgreLog.h>
    36 #include "core/RootGameState.h"
     33#include "core/GameState.h"
    3734#include "core/OrxonoxClass.h"
    3835
    3936namespace orxonox
    4037{
    41     class _OrxonoxExport GSRoot : public RootGameState, public OrxonoxClass
     38    class _OrxonoxExport GSRoot : public GameState
    4239    {
    43         friend class ClassIdentifier<GSRoot>;
    44 
    4540    public:
    46         struct statisticsTickInfo
    47         {
    48             uint64_t    tickTime;
    49             uint32_t    tickLength;
    50         };
    51    
    52     public:
    53         GSRoot();
     41        GSRoot(const std::string& name);
    5442        ~GSRoot();
    5543
    56         void exitGame()
    57         { requestState("root"); }
     44        void activate();
     45        void deactivate();
     46        void update(const Clock& time);
    5847
    5948        // this has to be public because proteced triggers a bug in msvc
     
    6352        float getTimeFactor() { return this->timeFactor_; }
    6453
    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 
    7254    private:
    73         void enter();
    74         void leave();
    75         void ticked(const Clock& time);
    76 
    77         void setConfigValues();
    78         void setThreadAffinity(unsigned int limitToCPU);
    79 
    8055        float                 timeFactor_;       //!< A factor that sets the gamespeed. 1 is normal.
    8156        bool                  bPaused_;
    8257        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_;
    9958
    10059        // console commands
    101         ConsoleCommand*       ccExit_;
    102         ConsoleCommand*       ccSelectGameState_;
    10360        ConsoleCommand*       ccSetTimeFactor_;
    10461        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;
    12262    };
    12363}
  • code/trunk/src/orxonox/gamestates/GSServer.cc

    r2171 r2896  
    3131
    3232#include "core/CommandLine.h"
    33 #include "core/Core.h"
     33#include "core/Game.h"
     34#include "core/GameMode.h"
    3435#include "network/Server.h"
    3536
    3637namespace orxonox
    3738{
     39    AddGameState(GSServer, "server");
     40
    3841    SetCommandLineArgument(port, 55556).shortcut("p").information("0-65535");
    3942
    40     GSServer::GSServer()
    41         : GameState<GSGraphics>("server")
     43    GSServer::GSServer(const std::string& name)
     44        : GameState(name)
    4245        , server_(0)
    4346    {
     
    4851    }
    4952
    50     void GSServer::enter()
     53    void GSServer::activate()
    5154    {
    52         Core::setHasServer(true);
     55        GameMode::setHasServer(true);
    5356
    5457        this->server_ = new Server(CommandLine::getValue("port"));
    5558        COUT(0) << "Loading scene in server mode" << std::endl;
    5659
    57         GSLevel::enter(this->getParent()->getViewport());
    58 
    5960        server_->open();
    6061    }
    6162
    62     void GSServer::leave()
     63    void GSServer::deactivate()
    6364    {
    64         GSLevel::leave();
    65 
    6665        this->server_->close();
    6766        delete this->server_;
    6867
    69         Core::setHasServer(false);
     68        GameMode::setHasServer(false);
    7069    }
    7170
    72     void GSServer::ticked(const Clock& time)
     71    void GSServer::update(const Clock& time)
    7372    {
    74         GSLevel::ticked(time);
    75         server_->tick(time.getDeltaTime());
    76         this->tickChild(time);
     73        server_->update(time);
    7774    }
    7875}
  • code/trunk/src/orxonox/gamestates/GSServer.h

    r2171 r2896  
    3131
    3232#include "OrxonoxPrereqs.h"
     33#include "core/GameState.h"
    3334#include "network/NetworkPrereqs.h"
    34 #include "GSLevel.h"
    35 #include "GSGraphics.h"
    3635
    3736namespace orxonox
    3837{
    39     class _OrxonoxExport GSServer : public GameState<GSGraphics>, public GSLevel
     38    class _OrxonoxExport GSServer : public GameState
    4039    {
    4140    public:
    42         GSServer();
     41        GSServer(const std::string& name);
    4342        ~GSServer();
    4443
     44        void activate();
     45        void deactivate();
     46        void update(const Clock& time);
     47
    4548    private:
    46         void enter();
    47         void leave();
    48         void ticked(const Clock& time);
    49 
    50         Server*      server_;
     49        Server* server_;
    5150    };
    5251}
  • code/trunk/src/orxonox/gamestates/GSStandalone.cc

    r2790 r2896  
    3232#include <OgreViewport.h>
    3333#include <OgreCamera.h>
    34 #include "core/Core.h"
     34#include "core/Game.h"
     35#include "core/GameMode.h"
    3536#include "core/ConsoleCommand.h"
    3637#include "gui/GUIManager.h"
     38#include "GraphicsManager.h"
    3739
    3840namespace orxonox
    3941{
    40     SetConsoleCommand(GSStandalone, showGUI, true).setAsInputCommand();
     42    AddGameState(GSStandalone, "standalone");
    4143
    42     bool GSStandalone::guiShowing_s = false;
    43 
    44     GSStandalone::GSStandalone()
    45         : GameState<GSGraphics>("standalone")
     44    GSStandalone::GSStandalone(const std::string& name)
     45        : GameState(name)
    4646    {
    4747    }
     
    5151    }
    5252
    53     void GSStandalone::showGUI()
     53
     54    void GSStandalone::activate()
    5455    {
    55         GSStandalone::guiShowing_s = true;
     56        GameMode::setIsStandalone(true);
    5657    }
    5758
    58     void GSStandalone::enter()
     59    void GSStandalone::deactivate()
    5960    {
    60         Core::setIsStandalone(true);
    61 
    62         GSLevel::enter(this->getParent()->getViewport());
    63 
    64         guiManager_ = getParent()->getGUIManager();
    65         // not sure if necessary
    66         // guiManager_->loadScene("IngameMenu");
     61        GameMode::setIsStandalone(false);
    6762    }
    6863
    69     void GSStandalone::leave()
     64    void GSStandalone::update(const Clock& time)
    7065    {
    71         GSLevel::leave();
    72 
    73         Core::setIsStandalone(false);
    74     }
    75 
    76     void GSStandalone::ticked(const Clock& time)
    77     {
    78         if (guiShowing_s)
    79         {
    80             guiManager_->showGUI("IngameMenu", this->getParent()->getViewport()->getCamera()->getSceneManager());
    81         }
    82         else
    83         {
    84             if (guiManager_)
    85                 guiManager_->hideGUI();
    86         }
    87         // tick CEGUI
    88         guiManager_->tick(time.getDeltaTime());
    89 
    90         GSLevel::ticked(time);
    91         this->tickChild(time);
    9266    }
    9367}
  • code/trunk/src/orxonox/gamestates/GSStandalone.h

    r2790 r2896  
    3131
    3232#include "OrxonoxPrereqs.h"
    33 #include "GSLevel.h"
    34 #include "GSGraphics.h"
     33#include "core/GameState.h"
    3534
    3635namespace orxonox
    3736{
    38     class _OrxonoxExport GSStandalone : public GameState<GSGraphics>, public GSLevel
     37    class _OrxonoxExport GSStandalone : public GameState
    3938    {
    4039    public:
    41         GSStandalone();
     40        GSStandalone(const std::string& name);
    4241        ~GSStandalone();
    43         static void showGUI();
     42
     43        void activate();
     44        void deactivate();
     45        void update(const Clock& time);
    4446
    4547    private:
    46         void enter();
    47         void leave();
    48         void ticked(const Clock& time);
    49 
    50         GUIManager*     guiManager_;
    51         static bool     guiShowing_s;
    5248    };
    5349}
  • code/trunk/src/orxonox/gui/GUIManager.cc

    r2790 r2896  
    2222 *   Author:
    2323 *      Reto Grieder
     24 *      Benjamin Knecht
    2425 *   Co-authors:
    25  *      ...
     26 *
    2627 *
    2728 */
     
    3637#include "GUIManager.h"
    3738
    38 #include <boost/filesystem.hpp>
     39#include <boost/filesystem/path.hpp>
    3940#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"
    5452#include "core/ConsoleCommand.h"
    5553#include "core/Core.h"
     54#include "core/Clock.h"
    5655#include "ToluaBindCore.h"
    5756#include "ToluaBindOrxonox.h"
     
    6362namespace orxonox
    6463{
    65     SetConsoleCommandShortcut(GUIManager, showGUI_s).keybindMode(KeybindMode::OnPress);
    66 
    6764    GUIManager* GUIManager::singletonRef_s = 0;
    6865
    6966    GUIManager::GUIManager()
    70         //: emptySceneManager_(0)
    71         : backgroundSceneManager_(0)
    72         //, emptyCamera_(0)
    73         , backgroundCamera_(0)
    74         //, viewport_(0)
    75         , renderWindow_(0)
     67        : renderWindow_(0)
    7668        , guiRenderer_(0)
    7769        , resourceProvider_(0)
     
    8476    }
    8577
     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    */
    8684    GUIManager::~GUIManager()
    8785    {
    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 
    10286        if (guiSystem_)
    10387            delete guiSystem_;
     
    11094                lua_pushnil(luaState_);
    11195                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..
    11696            delete scriptModule_;
    11797        }
     
    123103    }
    124104
     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    */
    125119    bool GUIManager::initialise(Ogre::RenderWindow* renderWindow)
    126120    {
     
    135129                renderWindow_ = renderWindow;
    136130
    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 
    144131                // Note: No SceneManager specified yet
    145                 this->guiRenderer_ = new OgreCEGUIRenderer(renderWindow_, Ogre::RENDER_QUEUE_MAIN, true, 3000);
     132                this->guiRenderer_ = new OgreCEGUIRenderer(renderWindow_, Ogre::RENDER_QUEUE_OVERLAY, true, 3000);
    146133                this->resourceProvider_ = guiRenderer_->createResourceProvider();
    147134                this->resourceProvider_->setDefaultResourceGroup("GUI");
     
    166153                tolua_Orxonox_open(this->scriptModule_->getLuaState());
    167154
    168                 // register us as input handler
    169                 SimpleInputState* state = InputManager::getInstance().createInputState<SimpleInputState>("gui", 30);
    170                 state->setHandler(this);
    171                 state->setJoyStickHandler(&InputManager::EMPTY_HANDLER);
    172 
    173                 // load the background scene
    174                 //loadScenes();
    175                 //CEGUI::KeyEventArgs e;
    176                 //e.codepoint
     155                // initialise the basic lua code
     156                loadLuaCode();
    177157            }
    178158            catch (CEGUI::Exception& ex)
     
    192172    }
    193173
    194     void GUIManager::loadScene(const std::string& name)
    195     {
    196         if (name.compare("IngameMenu") == 0)
    197         {
    198             try
    199             {
    200                 /*this->scriptModule_ = new LuaScriptModule();
    201                 this->luaState_ = this->scriptModule_->getLuaState();
    202                 this->guiSystem_ = new System(this->guiRenderer_, this->resourceProvider_, 0, this->scriptModule_);
    203                 tolua_Core_open(this->scriptModule_->getLuaState());
    204                 tolua_Orxonox_open(this->scriptModule_->getLuaState());
    205                 */
    206                 this->scriptModule_->executeScriptFile("ingameGUI.lua", "GUI");
    207             }
    208             catch (CEGUI::Exception& ex)
    209             {
    210 #if CEGUI_VERSION_MINOR < 6
    211                 throw GeneralException(ex.getMessage().c_str());
    212 #else
    213                 throw GeneralException(ex.getMessage().c_str(), ex.getLine(),
    214                                        ex.getFileName().c_str(), ex.getName().c_str());
    215 #endif
    216             }
    217         }
    218         else
    219         {
    220             loadScenes();
    221         }
    222     }
    223 
    224     void GUIManager::loadScenes()
    225     {
    226         // first of all, we need to have our own SceneManager for the GUI. The reason
    227         // is that we might have multiple viewports when in play mode (e.g. the view of
    228         // a camera fixed at the back of the ship). That forces us to create our own
    229         // full screen viewport that is on top of all the others, but doesn't clear the
    230         // port before rendering, so everything from the GUI gets on top eventually.
    231         // But in order to realise that, we also need a SceneManager with an empty scene,
    232         // because the SceneManager is responsible for the render queue.
    233         //this->emptySceneManager_ = Ogre::Root::getSingleton()
    234         //    .createSceneManager(Ogre::ST_GENERIC, "GUI/EmptySceneManager");
    235 
    236         // we also need a camera or we won't see anything at all.
    237         // The camera settings don't matter at all for an empty scene since the GUI
    238         // gets rendered on top of the screen rather than into the scene.
    239         //this->emptyCamera_ = this->emptySceneManager_->createCamera("GUI/EmptyCamera");
    240 
    241         // Create another SceneManager that enables to display some 3D
    242         // scene in the background of the main menu.
    243         this->backgroundSceneManager_ = Ogre::Root::getSingleton()
    244             .createSceneManager(Ogre::ST_GENERIC, "GUI/BackgroundSceneManager");
    245         this->backgroundCamera_ = backgroundSceneManager_->createCamera("GUI/BackgroundCamera");
    246 
    247         // TODO: create something 3D
     174    /**
     175    @brief
     176        Calls main Lua script
     177    @todo
     178        Replace loadGUI.lua with loadGUI_2.lua after merging this back to trunk.
     179        However CEGUI is able to execute a startup script. We could maybe put this call in this startup code.
     180
     181        This function calls the main Lua script for our GUI.
     182
     183        Additionally we set the datapath variable in Lua. This is needed so Lua can access the data used for the GUI.
     184    */
     185    void GUIManager::loadLuaCode()
     186    {
    248187        try
    249188        {
    250             this->scriptModule_->executeScriptFile("loadGUI.lua", "GUI");
     189            // call main Lua script
     190            this->scriptModule_->executeScriptFile("loadGUI_2.lua", "GUI");
     191            // set datapath for GUI data
     192            lua_pushfstring(this->scriptModule_->getLuaState(), Core::getMediaPathString().c_str());
     193            lua_setglobal(this->scriptModule_->getLuaState(), "datapath");
    251194        }
    252195        catch (CEGUI::Exception& ex)
     
    261204    }
    262205
    263     void GUIManager::showGUI(const std::string& name, Ogre::SceneManager* sceneManager)// bool showBackground)
     206    /**
     207    @brief
     208        used to tick the GUI
     209    @param time
     210        clock which provides time value for the GUI System
     211
     212        Ticking the GUI means updating it with a certain regularity.
     213        The elapsed time since the last call is given in the time value provided by the clock.
     214        This time value is then used to provide a fluent animation of the GUI.
     215    */
     216    void GUIManager::update(const Clock& time)
     217    {
     218        assert(guiSystem_);
     219        guiSystem_->injectTimePulse(time.getDeltaTime());
     220    }
     221
     222    /**
     223    @brief
     224        Executes Lua code
     225    @param str
     226        reference to string object holding the Lua code which is to be executed
     227
     228        This function gives total access to the GUI. You can execute ANY Lua code here.
     229    */
     230    void GUIManager::executeCode(const std::string& str)
     231    {
     232        try
     233        {
     234            this->scriptModule_->executeString(str);
     235        }
     236        catch (CEGUI::Exception& ex)
     237        {
     238            COUT(2) << "CEGUI Error: \"" << ex.getMessage() << "\" while executing code \"" << str << "\"" << std::endl;
     239        }
     240    }
     241
     242    /**
     243    @brief
     244        Tells the GUIManager which SceneManager to use
     245    @param camera
     246        The current camera on which the GUI should be displayed on.
     247
     248        In fact the GUIManager needs the SceneManager and not the Camera to display the GUI.
     249        This means the GUI is not bound to a camera but rather to the SceneManager.
     250        Hidding the GUI when needed can therefore not be solved by just NOT setting the current camera.
     251    */
     252    void GUIManager::setCamera(Ogre::Camera* camera)
     253    {
     254        this->guiRenderer_->setTargetSceneManager(camera->getSceneManager());
     255    }
     256
     257    /**
     258    @brief
     259        Displays specified GUI on screen
     260    @param name
     261        The name of the GUI
     262
     263        The function executes the Lua function with the same name in case the GUIManager is ready.
     264        For more details check out loadGUI_2.lua where the function presides.
     265    */
     266    void GUIManager::showGUI(const std::string& name)
    264267    {
    265268        if (state_ != Uninitialised)
    266269        {
    267             if (state_ == OnDisplay)
    268                 hideGUI();
    269 
    270             COUT(3) << "Loading GUI " << name << std::endl;
     270            //COUT(3) << "Loading GUI " << name << std::endl;
    271271            try
    272272            {
    273                 COUT (0) << "************* sceneManager: " << sceneManager << std::endl;
    274                 if (!sceneManager)
    275                 {
    276                     // currently, only an image is loaded. We could do 3D, see loadBackground.
    277                     //this->viewport_->setClearEveryFrame(true);
    278                     this->guiRenderer_->setTargetSceneManager(this->backgroundSceneManager_);
    279                     //this->viewport_->setCamera(this->backgroundCamera_);
    280 
    281                     lua_pushboolean(this->scriptModule_->getLuaState(), true);
    282                     lua_setglobal(this->scriptModule_->getLuaState(), "showBackground");
    283                 }
    284                 else
    285                 {
    286                     //this->viewport_->setClearEveryFrame(false);
    287                     this->guiRenderer_->setTargetSceneManager(sceneManager);
    288                     //this->viewport_->setCamera(this->emptyCamera_);
    289 
    290                     lua_pushboolean(this->scriptModule_->getLuaState(), false);
    291                     lua_setglobal(this->scriptModule_->getLuaState(), "showBackground");
    292                 }
    293 
    294                 this->scriptModule_->executeScriptGlobal("showMainMenu");
    295 
    296                 InputManager::getInstance().requestEnterState("gui");
    297 
    298                 this->state_ = OnDisplay;
     273                this->scriptModule_->executeString(std::string("showGUI(\"") + name + "\")");
    299274            }
    300275            catch (CEGUI::Exception& ex)
     
    313288    }
    314289
    315     void GUIManager::hideGUI()
    316     {
    317         if (this->state_ != OnDisplay)
    318             return;
    319         //this->viewport_->setCamera(0);
    320         // has no effect since you cannot assign 0 as SceneManager
    321         //this->guiRenderer_->setTargetSceneManager(0);
    322         this->state_ = Ready;
    323         InputManager::getInstance().requestLeaveState("gui");
    324     }
    325 
     290    /**
     291    @brief
     292        Function receiving a mouse button pressed event.
     293    @param id
     294        ID of the mouse button which got pressed
     295
     296        This function is inherited by MouseHandler and injects the event into CEGUI.
     297        It is for CEGUI to process the event.
     298    */
    326299    void GUIManager::mouseButtonPressed(MouseButtonCode::ByEnum id)
    327300    {
     
    337310    }
    338311
     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    */
    339321    void GUIManager::mouseButtonReleased(MouseButtonCode::ByEnum id)
    340322    {
     
    350332    }
    351333
    352 
     334    /**
     335    @brief
     336        converts mouse event code to CEGUI event code
     337    @param button
     338        code of the mouse button as we use it in Orxonox
     339    @return
     340        code of the mouse button as it is used by CEGUI
     341
     342        Simple convertion from mouse event code in Orxonox to the one used in CEGUI.
     343     */
    353344    inline CEGUI::MouseButton GUIManager::convertButton(MouseButtonCode::ByEnum button)
    354345    {
  • code/trunk/src/orxonox/gui/GUIManager.h

    r2790 r2896  
    2323 *      Reto Grieder
    2424 *   Co-authors:
    25  *      ...
     25 *      Benjamin Knecht
    2626 *
    2727 */
     
    4949{
    5050    /**
     51    @class GUIManager
    5152    @brief
    52         Provides a simple interface to CEGUI with tolua methods and console commands
     53        Provides a simple interface to CEGUI with tolua methods and console commands. It also acts as a key and mouse handler.
     54
     55        The GUIManager is a singleton and can be called anywhere when access on the GUI is needed.
     56        Creation of the GUIManager is therefore not possible and the cunstructor is private.
     57
     58        Since the GUI needs user input, the GUIManager implements the functions needed to act as a key and/or mouse handler.
     59        Those input events are then injected into CEGUI in Lua.
    5360    */
    5461    class _OrxonoxExport GUIManager
     
    5966// tolua_end
    6067    public:
     68        /**
     69        @enum State
     70            The current state of the GUIManager. There should maybe be more (or we can omit this totally).
     71        */
    6172        enum State
    6273        {
    63             Uninitialised,
    64             Ready,
    65             OnDisplay
     74            Uninitialised,  //!< Initial state of the GUIManager
     75            Ready,          //!< State after initialisation if ready
     76            OnDisplay       //!< State if GUI is displayed
    6677        };
    6778
     
    7081
    7182        bool initialise(Ogre::RenderWindow* renderWindow);
    72         void loadScene(const std::string& name);
    73         void tick(float dt)
    74         {
    75             assert(guiSystem_);
    76             guiSystem_->injectTimePulse(dt);
    77         }
    78         void showGUI(const std::string& name, Ogre::SceneManager* sceneManager);// bool showBackground); // tolua_export
    79         void hideGUI(); // tolua_export
    8083
    81         Ogre::Camera* getCamera() { return this->backgroundCamera_; }
     84        void update(const Clock& time);
    8285
    83         static void showGUI_s(const std::string& name, Ogre::SceneManager* sceneManager)//bool showBackground)
    84         {
    85             getInstance().showGUI(name, sceneManager);
    86         }
     86        void showGUI(const std::string& name);
     87        void executeCode(const std::string& str);
     88
     89        void setCamera(Ogre::Camera* camera);
    8790
    8891        static GUIManager& getInstance()    { assert(singletonRef_s); return *singletonRef_s; } // tolua_export
     
    9093
    9194    private:
    92         GUIManager(const GUIManager& instance);
     95        GUIManager(const GUIManager& instance);                 //!< private constructor (this is a singleton class)
    9396
     97        void loadLuaCode();
     98
     99        // keyHandler functions
    94100        void keyPressed (const KeyEvent& evt)
    95         { guiSystem_->injectKeyDown(evt.key); guiSystem_->injectChar(evt.text); }
     101            { guiSystem_->injectKeyDown(evt.key); guiSystem_->injectChar(evt.text); }
    96102        void keyReleased(const KeyEvent& evt)
    97         { guiSystem_->injectKeyUp(evt.key); }
    98         void keyHeld    (const KeyEvent& evt)
    99         { }
     103            { guiSystem_->injectKeyUp(evt.key); }
     104        void keyHeld    (const KeyEvent& evt) { }
    100105
     106        // mouseHandler functions
    101107        void mouseButtonPressed (MouseButtonCode::ByEnum id);
    102108        void mouseButtonReleased(MouseButtonCode::ByEnum id);
    103         void mouseButtonHeld    (MouseButtonCode::ByEnum id)
    104         { }
     109        void mouseButtonHeld    (MouseButtonCode::ByEnum id) { }
    105110        void mouseMoved         (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize)
    106         { guiSystem_->injectMouseMove(rel.x, rel.y); }
     111            { guiSystem_->injectMouseMove(rel.x, rel.y); }
    107112        void mouseScrolled      (int abs, int rel)
    108         { guiSystem_->injectMouseWheelChange(rel);}
     113            { guiSystem_->injectMouseWheelChange(rel);}
    109114
    110         void tickInput(float dt) { }
    111         void tickKey(float dt) { }
    112         void tickMouse(float dt) { }
    113 
    114         void loadScenes();
    115 
    116         //Ogre::SceneManager*       emptySceneManager_;
    117         Ogre::SceneManager*       backgroundSceneManager_;
    118         //Ogre::Camera*             emptyCamera_;
    119         Ogre::Camera*             backgroundCamera_;
    120         //Ogre::Viewport*           viewport_;
    121         Ogre::RenderWindow*       renderWindow_;
    122         CEGUI::OgreCEGUIRenderer* guiRenderer_;
    123         CEGUI::ResourceProvider*  resourceProvider_;
    124         CEGUI::LuaScriptModule*   scriptModule_;
    125         CEGUI::DefaultLogger*     ceguiLogger_;
    126         CEGUI::System*            guiSystem_;
    127         CEGUI::Imageset*          backgroundImage_;
    128         lua_State*                luaState_;
    129 
    130         State state_;
     115        void updateInput(float dt)  { }
     116        void updateKey  (float dt)  { }
     117        void updateMouse(float dt)  { }
    131118
    132119        static CEGUI::MouseButton convertButton(MouseButtonCode::ByEnum button);
    133120
    134         static GUIManager*        singletonRef_s;
     121        Ogre::RenderWindow*         renderWindow_;      //!< Ogre's render window to give CEGUI access to it
     122        CEGUI::OgreCEGUIRenderer*   guiRenderer_;       //!< CEGUI's interface to the Ogre Engine
     123        CEGUI::ResourceProvider*    resourceProvider_;  //!< CEGUI's resource provider
     124        CEGUI::LuaScriptModule*     scriptModule_;      //!< CEGUI's script module to use Lua
     125        CEGUI::DefaultLogger*       ceguiLogger_;       //!< CEGUI's logger to be able to log CEGUI errors in our log
     126        CEGUI::System*              guiSystem_;         //!< CEGUI's main system
     127        lua_State*                  luaState_;          //!< Lua state, access point to the Lua engine
     128
     129        State                       state_;             //!< reflects state of the GUIManager
     130
     131        static GUIManager*          singletonRef_s;     //!< Singleton reference to GUIManager
    135132    }; // tolua_export
    136133} // tolua_export
  • code/trunk/src/orxonox/objects/EventTarget.cc

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

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/objects/Level.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/objects/Radar.cc

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

    r2662 r2896  
    4141
    4242#include "core/CoreIncludes.h"
    43 #include "core/Core.h"
     43#include "core/GameMode.h"
    4444#include "core/XMLPort.h"
    4545#include "tools/BulletConversions.h"
     
    5757        this->bShadows_ = true;
    5858
    59         if (Core::showsGraphics())
     59        if (GameMode::showsGraphics())
    6060        {
    6161            if (Ogre::Root::getSingletonPtr())
     
    9999                Ogre::Root::getSingleton().destroySceneManager(this->sceneManager_);
    100100            }
    101             else if (!Core::showsGraphics())
     101            else if (!GameMode::showsGraphics())
    102102            {
    103103                delete this->sceneManager_;
     
    227227    void Scene::tick(float dt)
    228228    {
    229         if (!Core::showsGraphics())
     229        if (!GameMode::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 (Core::showsGraphics() && this->sceneManager_)
     258        if (GameMode::showsGraphics() && this->sceneManager_)
    259259            this->sceneManager_->setSkyBox(true, skybox);
    260260
     
    264264    void Scene::setAmbientLight(const ColourValue& colour)
    265265    {
    266         if (Core::showsGraphics() && this->sceneManager_)
     266        if (GameMode::showsGraphics() && this->sceneManager_)
    267267            this->sceneManager_->setAmbientLight(colour);
    268268
     
    272272    void Scene::setShadow(bool bShadow)
    273273    {
    274         if (Core::showsGraphics() && this->sceneManager_)
     274        if (GameMode::showsGraphics() && this->sceneManager_)
    275275        {
    276276            if (bShadow)
  • code/trunk/src/orxonox/objects/collisionshapes

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/objects/controllers/AIController.cc

    r2662 r2896  
    3030#include "AIController.h"
    3131
    32 #include "core/Core.h"
     32#include "core/GameMode.h"
    3333#include "core/CoreIncludes.h"
    3434#include "core/Executor.h"
     
    4545        RegisterObject(AIController);
    4646
    47         if (Core::isMaster())
     47        if (GameMode::isMaster())
    4848            this->actionTimer_.setTimer(ACTION_INTERVAL, true, this, createExecutor(createFunctor(&AIController::action)));
    4949    }
  • code/trunk/src/orxonox/objects/gametypes/Gametype.cc

    r2890 r2896  
    3636#include "core/ConfigValueIncludes.h"
    3737#include "core/Template.h"
    38 #include "core/Core.h"
     38#include "core/GameMode.h"
    3939#include "overlays/OverlayGroup.h"
    4040#include "objects/infos/PlayerInfo.h"
     
    6565
    6666        // load the corresponding score board
    67         if (Core::showsGraphics() && this->scoreboardTemplate_ != "")
     67        if (GameMode::showsGraphics() && this->scoreboardTemplate_ != "")
    6868        {
    6969            this->scoreboard_ = new OverlayGroup(this);
  • code/trunk/src/orxonox/objects/infos/Bot.cc

    r2662 r2896  
    3030#include "Bot.h"
    3131
    32 #include "core/Core.h"
     32#include "core/GameMode.h"
    3333#include "core/CoreIncludes.h"
    3434#include "core/ConfigValueIncludes.h"
     
    4646
    4747        this->bHumanPlayer_ = false;
    48         this->bLocalPlayer_ = Core::isMaster();
     48        this->bLocalPlayer_ = GameMode::isMaster();
    4949        this->bSetUnreadyAfterSpawn_ = false;
    5050        this->setReadyToSpawn(true);
  • code/trunk/src/orxonox/objects/infos/HumanPlayer.cc

    r2890 r2896  
    3030#include "HumanPlayer.h"
    3131
    32 #include "core/Core.h"
     32#include "core/GameMode.h"
    3333#include "core/CoreIncludes.h"
    3434#include "core/ConfigValueIncludes.h"
     
    4747        RegisterObject(HumanPlayer);
    4848
    49         this->server_initialized_ = Core::isMaster();
     49        this->server_initialized_ = GameMode::isMaster();
    5050        this->client_initialized_ = false;
    5151
     
    9393            this->synchronize_nick_ = this->nick_;
    9494
    95             if (Core::isMaster())
     95            if (GameMode::isMaster())
    9696                this->setName(this->nick_);
    9797        }
     
    116116            this->client_initialized_ = true;
    117117
    118             if (!Core::isMaster())
     118            if (!GameMode::isMaster())
    119119                this->setObjectMode(objectDirection::bidirectional);
    120120            else
  • code/trunk/src/orxonox/objects/items/MultiStateEngine.cc

    r2809 r2896  
    3030#include "MultiStateEngine.h"
    3131
    32 #include "core/Core.h"
     32#include "core/GameMode.h"
    3333#include "core/CoreIncludes.h"
    3434#include "core/XMLPort.h"
     
    123123            }
    124124
    125             if (Core::isMaster())
     125            if (GameMode::isMaster())
    126126            {
    127127                for (std::list<WorldEntity*>::const_iterator it = this->activeEffects_.begin(); it != this->activeEffects_.end(); ++it)
  • code/trunk/src/orxonox/objects/pickup/PickupSpawner.cc

    r2662 r2896  
    8989                ExecutorMember<BaseObject>* executor = createExecutor(createFunctor(&BaseObject::setActive));
    9090                executor->setDefaultValues(true);
    91                 RespawnTimer_.setTimer(this->respawntimer_, false, (BaseObject*)this, executor);
     91                RespawnTimer_.setTimer(this->respawntimer_, false, this, executor);
    9292                COUT(0) << "TIMER SET" << std::endl;
    9393        }
  • code/trunk/src/orxonox/objects/pickup/Usable.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/objects/quest/AddQuest.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/objects/quest/AddQuest.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/objects/quest/AddQuestHint.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/objects/quest/AddQuestHint.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/objects/quest/AddReward.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/objects/quest/AddReward.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/objects/quest/ChangeQuestStatus.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/objects/quest/ChangeQuestStatus.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/objects/quest/CompleteQuest.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/objects/quest/CompleteQuest.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/objects/quest/FailQuest.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/objects/quest/FailQuest.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/objects/quest/GlobalQuest.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/objects/quest/GlobalQuest.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/objects/quest/LocalQuest.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/objects/quest/LocalQuest.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/objects/quest/Quest.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/objects/quest/Quest.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/objects/quest/QuestDescription.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/objects/quest/QuestDescription.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/objects/quest/QuestEffect.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/objects/quest/QuestEffect.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/objects/quest/QuestHint.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/objects/quest/QuestHint.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/objects/quest/QuestItem.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/objects/quest/QuestItem.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/objects/quest/QuestManager.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/objects/quest/QuestManager.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/objects/quest/Rewardable.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/objects/quest/Rewardable.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/objects/weaponSystem/WeaponSystem.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/objects/weaponSystem/WeaponSystem.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/objects/weaponSystem/projectiles/BillboardProjectile.cc

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

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

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

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

    r2893 r2896  
    3232#include "OrxonoxPrereqs.h"
    3333#include "FadingBillboard.h"
    34 #include "gamestates/GSRoot.h"
     34#include "tools/TimeFactorListener.h"
    3535
    3636namespace orxonox
  • code/trunk/src/orxonox/objects/worldentities/Billboard.cc

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

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

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/objects/worldentities/Camera.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/objects/worldentities/ControllableEntity.cc

    r2851 r2896  
    3434#include "core/CoreIncludes.h"
    3535#include "core/ConfigValueIncludes.h"
    36 #include "core/Core.h"
     36#include "core/GameMode.h"
    3737#include "core/XMLPort.h"
    3838#include "core/Template.h"
     
    245245            this->startLocalHumanControl();
    246246
    247             if (!Core::isMaster())
     247            if (!GameMode::isMaster())
    248248            {
    249249                this->client_overwrite_ = this->server_overwrite_;
     
    357357            if (!this->isDynamic())
    358358            {
    359                 if (Core::isMaster())
     359                if (GameMode::isMaster())
    360360                {
    361361                    this->server_position_ = this->getPosition();
     
    472472    void ControllableEntity::setPosition(const Vector3& position)
    473473    {
    474         if (Core::isMaster())
     474        if (GameMode::isMaster())
    475475        {
    476476            MobileEntity::setPosition(position);
     
    487487    void ControllableEntity::setOrientation(const Quaternion& orientation)
    488488    {
    489         if (Core::isMaster())
     489        if (GameMode::isMaster())
    490490        {
    491491            MobileEntity::setOrientation(orientation);
     
    502502    void ControllableEntity::setVelocity(const Vector3& velocity)
    503503    {
    504         if (Core::isMaster())
     504        if (GameMode::isMaster())
    505505        {
    506506            MobileEntity::setVelocity(velocity);
     
    517517    void ControllableEntity::setAngularVelocity(const Vector3& velocity)
    518518    {
    519         if (Core::isMaster())
     519        if (GameMode::isMaster())
    520520        {
    521521            MobileEntity::setAngularVelocity(velocity);
     
    533533    {
    534534        MobileEntity::setWorldTransform(worldTrans);
    535         if (Core::isMaster())
     535        if (GameMode::isMaster())
    536536        {
    537537            this->server_position_ = this->getPosition();
  • code/trunk/src/orxonox/objects/worldentities/ExplosionChunk.cc

    r2759 r2896  
    3232#include <OgreParticleSystem.h>
    3333
    34 #include "core/Core.h"
     34#include "core/GameMode.h"
    3535#include "core/CoreIncludes.h"
    3636#include "core/Executor.h"
     
    4747        RegisterObject(ExplosionChunk);
    4848
    49         if ( Core::showsGraphics() && ( !this->getScene() || !this->getScene()->getSceneManager() ) )
     49        if ( GameMode::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 ( Core::showsGraphics() )
     55        if ( GameMode::showsGraphics() )
    5656        {
    5757            try
     
    7575        }
    7676
    77         if (Core::isMaster())
     77        if (GameMode::isMaster())
    7878        {
    7979            Vector3 velocity(rnd(-1, 1), rnd(-1, 1), rnd(-1, 1));
     
    132132            this->smoke_->setEnabled(false);
    133133
    134         if (Core::isMaster())
     134        if (GameMode::isMaster())
    135135        {
    136136            this->bStop_ = true;
     
    148148        static const unsigned int CHANGES_PER_SECOND = 5;
    149149
    150         if (Core::isMaster() && rnd() < dt*CHANGES_PER_SECOND)
     150        if (GameMode::isMaster() && rnd() < dt*CHANGES_PER_SECOND)
    151151        {
    152152            float length = this->getVelocity().length();
  • code/trunk/src/orxonox/objects/worldentities/Light.cc

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

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/objects/worldentities/MobileEntity.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/objects/worldentities/Model.cc

    r2662 r2896  
    3131#include <OgreEntity.h>
    3232#include "Model.h"
     33#include "core/GameMode.h"
    3334#include "core/CoreIncludes.h"
    3435#include "core/XMLPort.h"
     
    7071    void Model::changedMesh()
    7172    {
    72         if (Core::showsGraphics())
     73        if (GameMode::showsGraphics())
    7374        {
    7475            if (this->mesh_.getEntity())
  • code/trunk/src/orxonox/objects/worldentities/MovableEntity.cc

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

    r2662 r2896  
    3939#include "tools/ParticleInterface.h"
    4040#include "util/Exception.h"
     41#include "core/GameMode.h"
    4142#include "core/CoreIncludes.h"
    4243#include "core/XMLPort.h"
     
    5152        RegisterObject(ParticleEmitter);
    5253
    53         if (Core::showsGraphics() && (!this->getScene() || !this->getScene()->getSceneManager()))
     54        if (GameMode::showsGraphics() && (!this->getScene() || !this->getScene()->getSceneManager()))
    5455            ThrowException(AbortLoading, "Can't create ParticleEmitter, no scene or no scene manager given.");
    5556
     
    107108        }
    108109
    109         if (Core::showsGraphics() && this->getScene() && this->getScene()->getSceneManager())
     110        if (GameMode::showsGraphics() && this->getScene() && this->getScene()->getSceneManager())
    110111        {
    111112            try
  • code/trunk/src/orxonox/objects/worldentities/ParticleSpawner.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/objects/worldentities/ParticleSpawner.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/objects/worldentities/Planet.cc

    r2710 r2896  
    4242#include "CameraManager.h"
    4343#include "Camera.h"
    44 #include "GraphicsEngine.h"
     44#include "GraphicsManager.h"
    4545
    4646namespace orxonox
  • code/trunk/src/orxonox/objects/worldentities/PongBall.cc

    r2885 r2896  
    3131
    3232#include "core/CoreIncludes.h"
     33#include "core/GameMode.h"
    3334#include "objects/worldentities/PongBat.h"
    3435#include "objects/gametypes/Gametype.h"
     
    5354        SUPER(PongBall, tick, dt);
    5455
    55         if (Core::isMaster())
     56        if (GameMode::isMaster())
    5657        {
    5758            Vector3 position = this->getPosition();
  • code/trunk/src/orxonox/objects/worldentities/StaticEntity.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/objects/worldentities/StaticEntity.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/objects/worldentities/pawns/Pawn.cc

    r2893 r2896  
    3030#include "Pawn.h"
    3131
    32 #include "core/Core.h"
     32#include "core/GameMode.h"
    3333#include "core/CoreIncludes.h"
    3434#include "core/XMLPort.h"
     
    6363        this->getPickUp().setPlayer(this);
    6464
    65         if (Core::isMaster())
     65        if (GameMode::isMaster())
    6666        {
    6767            this->weaponSystem_ = new WeaponSystem(this);
     
    211211                this->getPlayer()->stopControl(this);
    212212
    213             if (Core::isMaster())
     213            if (GameMode::isMaster())
    214214                this->deatheffect();
    215215        }
     
    260260    {
    261261        this->setHealth(this->initialHealth_);
    262         if (Core::isMaster())
     262        if (GameMode::isMaster())
    263263            this->spawneffect();
    264264    }
  • code/trunk/src/orxonox/objects/worldentities/pawns/Spectator.cc

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

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/objects/worldentities/triggers/DistanceTrigger.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/objects/worldentities/triggers/Trigger.cc

    r2893 r2896  
    3636#include "core/ConsoleCommand.h"
    3737#include "core/XMLPort.h"
    38 #include "core/Core.h"
     38#include "core/GameMode.h"
    3939#include "objects/Scene.h"
    4040
     
    6767//    this->bUpdating_ = false;
    6868
    69     if (this->getScene() && Core::showsGraphics())
     69    if (this->getScene() && GameMode::showsGraphics())
    7070    {
    7171      this->debugBillboard_.setBillboardSet(this->getScene()->getSceneManager(), "Examples/Flare", ColourValue(1.0, 0.0, 0.0), 1);
  • code/trunk/src/orxonox/objects/worldentities/triggers/Trigger.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/overlays/OrxonoxOverlay.cc

    r2662 r2896  
    3939#include <OgreOverlayManager.h>
    4040#include <OgrePanelOverlayElement.h>
     41#include <OgreRenderWindow.h>
     42
    4143#include "util/Convert.h"
    4244#include "util/Exception.h"
    4345#include "util/String.h"
    44 #include "core/Core.h"
     46#include "core/GameMode.h"
    4547#include "core/CoreIncludes.h"
    4648#include "core/XMLPort.h"
    4749#include "core/ConsoleCommand.h"
     50#include "GraphicsManager.h"
    4851
    4952namespace orxonox
     
    6467        this->group_ = 0;
    6568
    66         if (!Core::showsGraphics())
     69        if (!GameMode::showsGraphics())
    6770            ThrowException(NoGraphics, "Can't create OrxonoxOverlay, graphics engine not initialized");
    6871
     
    7780        this->overlay_->add2D(this->background_);
    7881
    79         // We'll have to set the aspect ratio to a default value first.
    80         // GSGraphics gets informed about our construction here and can update us in the next tick.
    81         this->windowAspectRatio_ = 1.0;
     82        // Get aspect ratio from the render window. Later on, we get informed automatically
     83        Ogre::RenderWindow* defaultWindow = GraphicsManager::getInstance().getRenderWindow();
     84        this->windowAspectRatio_ = (float)defaultWindow->getWidth() / defaultWindow->getHeight();
    8285        this->sizeCorrectionChanged();
    8386
     
    175178    /**
    176179    @brief
    177         Called by the GraphicsEngine whenever the window size changes.
     180        Called by the GraphicsManager whenever the window size changes.
    178181        Calculates the aspect ratio only.
    179182    */
    180     void OrxonoxOverlay::windowResized(int newWidth, int newHeight)
     183    void OrxonoxOverlay::windowResized(unsigned int newWidth, unsigned int newHeight)
    181184    {
    182185        this->windowAspectRatio_ = newWidth/(float)newHeight;
  • code/trunk/src/orxonox/overlays/OrxonoxOverlay.h

    r2890 r2896  
    200200
    201201    private:
    202         void windowResized(int newWidth, int newHeight);
     202        void windowResized(unsigned int newWidth, unsigned int newHeight);
    203203
    204204        static unsigned int hudOverlayCounter_s;   //!< Static counter for hud elements
  • code/trunk/src/orxonox/overlays/console/InGameConsole.cc

    r2087 r2896  
    4242#include "util/Convert.h"
    4343#include "util/Debug.h"
     44#include "core/Clock.h"
    4445#include "core/CoreIncludes.h"
    4546#include "core/ConfigValueIncludes.h"
     
    172173    {
    173174        // create the corresponding input state
    174         inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("console", 40);
     175        inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("console", false, false, InputStatePriority::Console);
    175176        inputState_->setKeyHandler(Shell::getInstance().getInputBuffer());
    176177        bHidesAllInputChanged();
     
    347348        @brief Used to control the actual scrolling and the cursor.
    348349    */
    349     void InGameConsole::tick(float dt)
     350    void InGameConsole::update(const Clock& time)
    350351    {
    351352        if (this->scroll_ != 0)
     
    358359                // enlarge oldTop a little bit so that this exponential function
    359360                // reaches 0 before infinite time has passed...
    360                 float deltaScroll = (oldTop - 0.01) * dt * this->scrollSpeed_;
     361                float deltaScroll = (oldTop - 0.01) * time.getDeltaTime() * this->scrollSpeed_;
    361362                if (oldTop - deltaScroll >= 0)
    362363                {
     
    373374                // scrolling up
    374375                // note: +0.01 for the same reason as when scrolling down
    375                 float deltaScroll = (1.2 * this->relativeHeight + 0.01 + oldTop) * dt * this->scrollSpeed_;
     376                float deltaScroll = (1.2 * this->relativeHeight + 0.01 + oldTop) * time.getDeltaTime() * this->scrollSpeed_;
    376377                if (oldTop - deltaScroll <= -1.2 * this->relativeHeight)
    377378                {
     
    388389        if (this->bActive_)
    389390        {
    390             this->cursor_ += dt;
     391            this->cursor_ += time.getDeltaTime();
    391392            if (this->cursor_ >= this->blinkTime)
    392393            {
     
    409410        @brief Resizes the console elements. Call if window size changes.
    410411    */
    411     void InGameConsole::windowResized(int newWidth, int newHeight)
     412    void InGameConsole::windowResized(unsigned int newWidth, unsigned int newHeight)
    412413    {
    413414        this->windowW_ = newWidth;
  • code/trunk/src/orxonox/overlays/console/InGameConsole.h

    r2087 r2896  
    5353        void setConfigValues();
    5454
    55         virtual void tick(float dt);
     55        void update(const Clock& time);
    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(int newWidth, int newHeight);
     83        void windowResized(unsigned int newWidth, unsigned int newHeight);
    8484
    8585        // config value related
  • code/trunk/src/orxonox/overlays/debug/DebugFPSText.cc

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

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

    r2662 r2896  
    9494    void HUDRadar::displayObject(RadarViewable* object, bool bIsMarked)
    9595    {
    96         if (object == (RadarViewable*)this->owner_)
     96        if (object == static_cast<RadarViewable*>(this->owner_))
    9797            return;
    9898
  • code/trunk/src/orxonox/tools/BillboardSet.cc

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

    r2710 r2896  
    55  Shader.cc
    66  TextureGenerator.cc
     7  TimeFactorListener.cc
    78  Timer.cc
    89  WindowEventListener.cc
  • code/trunk/src/orxonox/tools/Mesh.cc

    r2870 r2896  
    3535#include <cassert>
    3636
    37 #include "core/Core.h"
     37#include "core/GameMode.h"
    3838#include "util/Convert.h"
    3939#include "util/String.h"
     
    6464            this->scenemanager_->destroyEntity(this->entity_);
    6565
    66         if (Core::showsGraphics())
     66        if (GameMode::showsGraphics())
    6767        {
    6868            try
  • code/trunk/src/orxonox/tools/ParticleInterface.cc

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

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

    r2662 r2896  
    3636#include <OgrePlugin.h>
    3737
    38 #include "core/Core.h"
     38#include "core/GameMode.h"
    3939#include "core/CoreIncludes.h"
    4040#include "core/Executor.h"
    41 #include "GraphicsEngine.h"
     41#include "GraphicsManager.h"
    4242#include "util/Exception.h"
    4343
     
    5959        this->compositorInstance_ = 0;
    6060        this->bVisible_ = true;
    61         this->bLoadCompositor_ = Core::showsGraphics() && GraphicsEngine::getInstancePtr();
     61        this->bLoadCompositor_ = GameMode::showsGraphics();
    6262        this->bViewportInitialized_ = false;
    6363        this->compositor_ = "";
     
    8686        if (this->bLoadCompositor_ && this->compositorInstance_)
    8787        {
    88             Ogre::Viewport* viewport = GraphicsEngine::getInstance().getViewport();
     88            Ogre::Viewport* viewport = GraphicsManager::getInstance().getViewport();
    8989            assert(viewport);
    9090            Ogre::CompositorManager::getSingleton().removeCompositor(viewport, this->compositor_);
     
    114114        if (this->bLoadCompositor_)
    115115        {
    116             Ogre::Viewport* viewport = GraphicsEngine::getInstance().getViewport();
     116            Ogre::Viewport* viewport = GraphicsManager::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 (!Core::showsGraphics() || !Shader::bLoadedCgPlugin_s)
     248        if (!GameMode::showsGraphics() || !Shader::bLoadedCgPlugin_s)
    249249            return 0;
    250250
  • code/trunk/src/orxonox/tools/Timer.h

    r2662 r2896  
    6464#include "core/Executor.h"
    6565#include "core/OrxonoxClass.h"
    66 #include "gamestates/GSRoot.h"
     66#include "tools/TimeFactorListener.h"
    6767
    6868namespace orxonox
  • code/trunk/src/orxonox/tools/WindowEventListener.h

    r2662 r2896  
    4949
    5050            /** Window has resized */
    51             virtual void windowResized(int newWidth, int newHeight) { }
     51            virtual void windowResized(unsigned int newWidth, unsigned int newHeight) { }
    5252
    5353            /** Window has lost/gained focus */
  • code/trunk/src/tolua/all-5.0.lua

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/tolua/all-5.1.lua

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/util

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/util/Exception.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/util/Exception.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/util/SignalHandler.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/util/SignalHandler.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
Note: See TracChangeset for help on using the changeset viewer.