Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 19, 2008, 2:24:33 PM (16 years ago)
Author:
rgrieder
Message:

Moved all showsGraphics, hasServer, etc. functions from Settings class to Core class.
This was necessary to avoid circular dependencies.

Location:
code/branches/objecthierarchy/src
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchy/src/core/Core.cc

    r1762 r1949  
    3737#include "CoreIncludes.h"
    3838#include "ConfigValueIncludes.h"
    39 //#include "input/InputManager.h"
    40 //#include "TclThreadManager.h"
    4139
    4240namespace orxonox
    4341{
     42    bool Core::bShowsGraphics_s = false;
     43    bool Core::bHasServer_s     = false;
     44    bool Core::bIsClient_s      = false;
     45    bool Core::bIsStandalone_s  = false;
     46    bool Core::bIsMaster_s      = false;
     47
    4448    /**
    4549        @brief Constructor: Registers the object and sets the config-values.
     
    205209        ResetConfigValue(language_);
    206210    }
    207 
    208     ///**
    209     //    @brief Ticks every core class in a specified sequence. Has to be called
    210     //           every Orxonox tick!
    211     //    @param dt Delta Time
    212     //*/
    213     //void Core::tick(float dt)
    214     //{
    215     //    TclThreadManager::getInstance().tick(dt);
    216     //    InputManager::getInstance().tick(dt);
    217     //}
    218211}
  • code/branches/objecthierarchy/src/core/Core.h

    r1755 r1949  
    6060            static void resetLanguage();
    6161
    62             //static void tick(float dt);
     62            // fast access global variables.
     63            static bool showsGraphics() { return bShowsGraphics_s; }
     64            static bool hasServer()     { return bHasServer_s; }
     65            static bool isClient()      { return bIsClient_s; }
     66            static bool isStandalone()  { return bIsStandalone_s; }
     67            static bool isMaster()      { return bIsMaster_s; }
     68            static void setShowsGraphics(bool val) { bShowsGraphics_s = val; updateIsMaster(); }
     69            static void setHasServer    (bool val) { bHasServer_s     = val; updateIsMaster(); }
     70            static void setIsClient     (bool val) { bIsClient_s      = val; updateIsMaster(); }
     71            static void setIsStandalone (bool val) { bIsStandalone_s  = val; updateIsMaster(); }
     72            static void updateIsMaster  ()         { bIsMaster_s      = (bHasServer_s || bIsStandalone_s); }
    6373
    6474        private:
     
    7484            int softDebugLevelShell_;                       //!< The debug level for the ingame shell
    7585            std::string language_;                          //!< The language
     86
     87            static bool bShowsGraphics_s;                   //!< global variable that tells whether to show graphics
     88            static bool bHasServer_s;                       //!< global variable that tells whether this is a server
     89            static bool bIsClient_s;
     90            static bool bIsStandalone_s;
     91            static bool bIsMaster_s;
    7692    };
    7793}
  • code/branches/objecthierarchy/src/network/ClientConnectionListener.cc

    r1939 r1949  
    11#include "ClientConnectionListener.h"
    22#include "core/CoreIncludes.h"
    3 #include "Settings.h"
     3#include "core/Core.h"
    44
    55namespace network{
     
    1111
    1212  void ClientConnectionListener::getConnectedClients(){
    13     if(orxonox::Settings::showsGraphics())
     13    if(orxonox::Core::showsGraphics())
    1414      this->clientConnected(0); //server client id
    1515    ClientInformation *client = ClientInformation::getBegin();
  • code/branches/objecthierarchy/src/orxonox/Settings.cc

    r1940 r1949  
    4949    */
    5050    Settings::Settings()
    51         : bShowsGraphics_(false)
    52         , bHasServer_(false)
    53         , bIsClient_(false)
    54         , bIsStandalone_(false)
    55         , bIsMaster_(false)
    5651    {
    5752        RegisterRootObject(Settings);
  • code/branches/objecthierarchy/src/orxonox/Settings.h

    r1940 r1949  
    5050        friend class ClassIdentifier<Settings>;
    5151        friend class GSRoot;
    52         friend class GSGraphics;
    53         friend class GSServer;
    54         friend class GSClient;
    55         friend class GSDedicated;
    56         friend class GSStandalone;
    5752
    5853    public:
     
    6257        { assert(singletonRef_s); singletonRef_s->_tsetDataPath(path); }
    6358
    64         // an alternative to a global game mode variable
    65         static bool showsGraphics() { assert(singletonRef_s); return singletonRef_s->bShowsGraphics_; }
    66         static bool hasServer()     { assert(singletonRef_s); return singletonRef_s->bHasServer_; }
    67         static bool isClient()      { assert(singletonRef_s); return singletonRef_s->bIsClient_; }
    68         static bool isStandalone()  { assert(singletonRef_s); return singletonRef_s->bIsStandalone_; }
    69         static bool isMaster()      { assert(singletonRef_s); return singletonRef_s->bIsMaster_; }
    70 
    7159    private:
    72         // GSRoot has access to these
    73         static void setShowsGraphics(bool val) { assert(singletonRef_s); singletonRef_s->bShowsGraphics_ = val; singletonRef_s->updateIsMaster(); }
    74         static void setHasServer    (bool val) { assert(singletonRef_s); singletonRef_s->bHasServer_     = val; singletonRef_s->updateIsMaster(); }
    75         static void setIsClient     (bool val) { assert(singletonRef_s); singletonRef_s->bIsClient_      = val; singletonRef_s->updateIsMaster(); }
    76         static void setIsStandalone (bool val) { assert(singletonRef_s); singletonRef_s->bIsStandalone_  = val; singletonRef_s->updateIsMaster(); }
    77         static void updateIsMaster  ()         { assert(singletonRef_s); singletonRef_s->bIsMaster_ = (singletonRef_s->bHasServer_ || singletonRef_s->bIsStandalone_); }
    78 
    7960        Settings();
    8061        Settings(const Settings& instance);
     
    8768        void setConfigValues();
    8869
    89         bool bShowsGraphics_;                                  //!< global variable that tells whether to show graphics
    90         bool bHasServer_;                                      //!< global variable that tells whether this is a server
    91         bool bIsClient_;
    92         bool bIsStandalone_;
    93         bool bIsMaster_;
    94 
    9570        std::string dataPath_;                                 //!< Path to the game data
    9671
  • code/branches/objecthierarchy/src/orxonox/gamestates/GSClient.cc

    r1940 r1949  
    3232#include "core/input/InputManager.h"
    3333#include "core/CommandLine.h"
     34#include "core/Core.h"
    3435#include "network/Client.h"
    35 #include "Settings.h"
    3636
    3737namespace orxonox
     
    5151    void GSClient::enter()
    5252    {
    53         Settings::_getInstance().setIsClient(true);
     53        Core::setIsClient(true);
    5454
    5555        GSLevel::enter();
     
    8181        GSLevel::leave();
    8282
    83         Settings::_getInstance().setIsClient(false);
     83        Core::setIsClient(false);
    8484    }
    8585
  • code/branches/objecthierarchy/src/orxonox/gamestates/GSDedicated.cc

    r1940 r1949  
    3535#include "core/CommandLine.h"
    3636#include "core/Loader.h"
     37#include "core/Core.h"
    3738#include "network/Server.h"
    3839#include "objects/Tickable.h"
     40#include "Settings.h"
    3941#include "GraphicsEngine.h"
    40 #include "Settings.h"
    4142
    4243namespace orxonox
     
    5758    void GSDedicated::enter()
    5859    {
    59         Settings::_getInstance().setHasServer(true);
     60        Core::setHasServer(true);
    6061
    6162        // create Ogre SceneManager for the level
     
    9798        Ogre::Root::getSingleton().destroySceneManager(this->sceneManager_);
    9899
    99         Settings::_getInstance().setHasServer(false);
     100        Core::setHasServer(false);
    100101    }
    101102
  • code/branches/objecthierarchy/src/orxonox/gamestates/GSGraphics.cc

    r1940 r1949  
    4747#include "core/ConfigValueIncludes.h"
    4848#include "core/CoreIncludes.h"
     49#include "core/Core.h"
    4950#include "core/input/InputManager.h"
    5051#include "core/input/KeyBinder.h"
     
    101102    void GSGraphics::enter()
    102103    {
    103         Settings::_getInstance().setShowsGraphics(true);
     104        Core::setShowsGraphics(true);
    104105
    105106        // initialise graphics engine. Doesn't load the render window yet!
     
    196197        delete graphicsEngine_;
    197198
    198         Settings::_getInstance().setShowsGraphics(false);
     199        Core::setShowsGraphics(false);
    199200    }
    200201
  • code/branches/objecthierarchy/src/orxonox/gamestates/GSLevel.cc

    r1942 r1949  
    4444#include "objects/Radar.h"
    4545//#include "tools/ParticleInterface.h"
     46#include "GraphicsEngine.h"
    4647#include "Settings.h"
    47 #include "GraphicsEngine.h"
    4848
    4949namespace orxonox
  • code/branches/objecthierarchy/src/orxonox/gamestates/GSServer.cc

    r1940 r1949  
    3333#include "core/input/InputManager.h"
    3434#include "core/CommandLine.h"
     35#include "core/Core.h"
    3536#include "network/Server.h"
    36 #include "Settings.h"
    3737
    3838namespace orxonox
     
    5252    void GSServer::enter()
    5353    {
    54         Settings::_getInstance().setHasServer(true);
     54        Core::setHasServer(true);
    5555
    5656        GSLevel::enter();
     
    8686        GSLevel::leave();
    8787
    88         Settings::_getInstance().setHasServer(false);
     88        Core::setHasServer(false);
    8989    }
    9090
  • code/branches/objecthierarchy/src/orxonox/gamestates/GSStandalone.cc

    r1940 r1949  
    3232#include "core/input/InputManager.h"
    3333#include "core/ConsoleCommand.h"
    34 #include "Settings.h"
     34#include "core/Core.h"
    3535
    3636namespace orxonox
     
    5959        InputManager::getInstance().requestEnterState("game");
    6060
    61         Settings::_getInstance().setIsStandalone(true);
     61        Core::setIsStandalone(true);
    6262    }
    6363
     
    7272        GSLevel::leave();
    7373
    74         Settings::_getInstance().setIsStandalone(false);
     74        Core::setIsStandalone(false);
    7575    }
    7676
  • code/branches/objecthierarchy/src/orxonox/objects/infos/LevelInfo.cc

    r1947 r1949  
    3434#include "core/CoreIncludes.h"
    3535#include "core/XMLPort.h"
     36#include "core/Core.h"
    3637
    37 #include "Settings.h"
    3838#include "GraphicsEngine.h"
    3939
     
    7272    void LevelInfo::setSkybox(const std::string& skybox)
    7373    {
    74         if (Settings::showsGraphics())
     74        if (Core::showsGraphics())
    7575            if (GraphicsEngine::getInstance().getLevelSceneManager())
    7676                GraphicsEngine::getInstance().getLevelSceneManager()->setSkyBox(true, skybox);
     
    8181    void LevelInfo::setAmbientLight(const ColourValue& colour)
    8282    {
    83         if (Settings::showsGraphics())
     83        if (Core::showsGraphics())
    8484            GraphicsEngine::getInstance().getLevelSceneManager()->setAmbientLight(colour);
    8585
  • code/branches/objecthierarchy/src/orxonox/objects/infos/PlayerInfo.cc

    r1947 r1949  
    3535#include "core/ConfigValueIncludes.h"
    3636#include "core/XMLPort.h"
     37#include "core/Core.h"
    3738
    3839#include "network/Host.h"
    3940
    40 #include "Settings.h"
    4141#include "GraphicsEngine.h"
    4242#include "objects/gametypes/Gametype.h"
     
    5151
    5252        this->ping_ = -1;
    53         this->bLocalPlayer_ = Settings::isStandalone();
     53        this->bLocalPlayer_ = Core::isStandalone();
    5454        this->bLocalPlayer_ = false;
    5555        this->bHumanPlayer_ = false;
     
    7878    {
    7979std::cout << "# PI(" << this->getObjectID() << "): checkName: " << this->bLocalPlayer_ << std::endl;
    80         if (this->bLocalPlayer_ && Settings::isMaster())
     80        if (this->bLocalPlayer_ && Core::isMaster())
    8181            this->setName(this->playerName_);
    8282    }
     
    114114//std::cout << "# PI(" << this->getObjectID() << "): checkClientID(): name: " << this->getName() << std::endl;
    115115
    116             if (Settings::isClient())
     116            if (Core::isClient())
    117117            {
    118118std::cout << "# PI(" << this->getObjectID() << "): checkClientID(): we're on a client: set object mode to bidirectional" << std::endl;
     
    134134    {
    135135std::cout << "# PI(" << this->getObjectID() << "): finishedSetup(): " << this->bFinishedSetup_ << std::endl;
    136         if (Settings::isClient())
     136        if (Core::isClient())
    137137        {
    138138std::cout << "# PI(" << this->getObjectID() << "): finishedSetup(): we're a client: finish setup" << std::endl;
  • code/branches/objecthierarchy/src/orxonox/tools/Mesh.cc

    r1755 r1949  
    3232#include <sstream>
    3333#include <OgreSceneManager.h>
     34#include "core/Core.h"
    3435#include "GraphicsEngine.h"
    35 #include "Settings.h"
    3636
    3737namespace orxonox
     
    4848        std::ostringstream name;
    4949        name << (Mesh::meshCounter_s++);
    50         if (Settings::showsGraphics())
     50        if (Core::showsGraphics())
    5151            this->entity_ = GraphicsEngine::getInstance().getLevelSceneManager()->createEntity("Mesh" + name.str(), file);
    5252    }
     
    5454    Mesh::~Mesh()
    5555    {
    56         if (this->entity_ && Settings::showsGraphics())
     56        if (this->entity_ && Core::showsGraphics())
    5757            GraphicsEngine::getInstance().getLevelSceneManager()->destroyEntity(this->entity_);
    5858    }
Note: See TracChangeset for help on using the changeset viewer.