Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 25, 2008, 8:19:40 PM (16 years ago)
Author:
landauf
Message:

renamed LevelInfo as Level

Location:
code/branches/objecthierarchy/src/orxonox
Files:
3 edited
2 moved

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchy/src/orxonox/CMakeLists.txt

    r1993 r2012  
    6969
    7070  objects/infos/Info.cc
    71   objects/infos/LevelInfo.cc
     71  objects/infos/Level.cc
    7272  objects/infos/PlayerInfo.cc
    7373
  • code/branches/objecthierarchy/src/orxonox/OrxonoxPrereqs.h

    r1993 r2012  
    9898
    9999    class Info;
    100     class LevelInfo;
     100    class Level;
    101101    class PlayerInfo;
    102102
  • code/branches/objecthierarchy/src/orxonox/objects/infos/Level.cc

    r2010 r2012  
    2828
    2929#include "OrxonoxStableHeaders.h"
    30 #include "LevelInfo.h"
     30#include "Level.h"
    3131
    3232#include <OgreSceneManager.h>
     
    4949namespace orxonox
    5050{
    51     SetConsoleCommand(LevelInfo, listPlayers, true);
    52 
    53     CreateFactory(LevelInfo);
    54 
    55     LevelInfo::LevelInfo()
    56     {
    57         RegisterObject(LevelInfo);
     51    SetConsoleCommand(Level, listPlayers, true);
     52
     53    CreateFactory(Level);
     54
     55    Level::Level()
     56    {
     57        RegisterObject(Level);
    5858
    5959        this->rootGametype_ = 0;
     
    7171        // test test test
    7272
    73         COUT(0) << "created LevelInfo" << std::endl;
    74     }
    75 
    76     LevelInfo* LevelInfo::getActiveLevelInfo()
    77     {
    78         for (ObjectList<LevelInfo>::iterator it = ObjectList<LevelInfo>::begin(); it != ObjectList<LevelInfo>::end(); ++it)
     73        COUT(0) << "created Level" << std::endl;
     74    }
     75
     76    Level* Level::getActiveLevel()
     77    {
     78        for (ObjectList<Level>::iterator it = ObjectList<Level>::begin(); it != ObjectList<Level>::end(); ++it)
    7979            if (it->isActive())
    8080                return (*it);
     
    8383    }
    8484
    85     PlayerInfo* LevelInfo::getClient(unsigned int clientID)
    86     {
    87         LevelInfo* levelinfo = LevelInfo::getActiveLevelInfo();
    88 
    89         if (levelinfo)
    90         {
    91             std::map<unsigned int, PlayerInfo*>::const_iterator it = levelinfo->clients_.find(clientID);
    92             if (it != levelinfo->clients_.end())
     85    PlayerInfo* Level::getClient(unsigned int clientID)
     86    {
     87        Level* level = Level::getActiveLevel();
     88
     89        if (level)
     90        {
     91            std::map<unsigned int, PlayerInfo*>::const_iterator it = level->clients_.find(clientID);
     92            if (it != level->clients_.end())
    9393                return it->second;
    9494        }
     
    102102    }
    103103
    104     void LevelInfo::listPlayers()
    105     {
    106         LevelInfo* levelinfo = LevelInfo::getActiveLevelInfo();
    107 
    108         if (levelinfo->getGametype())
    109         {
    110             for (std::set<PlayerInfo*>::const_iterator it = levelinfo->getGametype()->getPlayers().begin(); it != levelinfo->getGametype()->getPlayers().end(); ++it)
     104    void Level::listPlayers()
     105    {
     106        Level* level = Level::getActiveLevel();
     107
     108        if (level->getGametype())
     109        {
     110            for (std::set<PlayerInfo*>::const_iterator it = level->getGametype()->getPlayers().begin(); it != level->getGametype()->getPlayers().end(); ++it)
    111111                COUT(0) << "ID: " << (*it)->getClientID() << ", Name: " << (*it)->getName() << std::endl;
    112112        }
     
    118118    }
    119119
    120     void LevelInfo::clientConnected(unsigned int clientID)
     120    void Level::clientConnected(unsigned int clientID)
    121121    {
    122122        COUT(0) << "client connected" << std::endl;
     
    132132    }
    133133
    134     void LevelInfo::clientDisconnected(unsigned int clientID)
     134    void Level::clientDisconnected(unsigned int clientID)
    135135    {
    136136        COUT(0) << "client disconnected" << std::endl;
     
    144144    }
    145145
    146     void LevelInfo::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    147     {
    148         SUPER(LevelInfo, XMLPort, xmlelement, mode);
    149 
    150         XMLPortParam(LevelInfo, "description", setDescription, getDescription, xmlelement, mode);
    151         XMLPortParam(LevelInfo, "gametype", setGametypeString, getGametypeString, xmlelement, mode).defaultValues("Gametype");
    152         XMLPortParam(LevelInfo, "skybox", setSkybox, getSkybox, xmlelement, mode);
    153         XMLPortParam(LevelInfo, "ambientlight", setAmbientLight, getAmbientLight, xmlelement, mode).defaultValues(ColourValue(0.2, 0.2, 0.2, 1));
     146    void Level::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     147    {
     148        SUPER(Level, XMLPort, xmlelement, mode);
     149
     150        XMLPortParam(Level, "description", setDescription, getDescription, xmlelement, mode);
     151        XMLPortParam(Level, "gametype", setGametypeString, getGametypeString, xmlelement, mode).defaultValues("Gametype");
     152        XMLPortParam(Level, "skybox", setSkybox, getSkybox, xmlelement, mode);
     153        XMLPortParam(Level, "ambientlight", setAmbientLight, getAmbientLight, xmlelement, mode).defaultValues(ColourValue(0.2, 0.2, 0.2, 1));
    154154
    155155        this->xmlfile_ = this->getFilename();
    156156    }
    157157
    158     void LevelInfo::registerVariables()
    159     {
    160         REGISTERSTRING(this->xmlfile_,     network::direction::toclient, new network::NetworkCallback<LevelInfo>(this, &LevelInfo::applyXMLFile));
    161         REGISTERSTRING(this->name_,        network::direction::toclient, new network::NetworkCallback<LevelInfo>(this, &LevelInfo::changedName));
     158    void Level::registerVariables()
     159    {
     160        REGISTERSTRING(this->xmlfile_,     network::direction::toclient, new network::NetworkCallback<Level>(this, &Level::networkcallback_applyXMLFile));
     161        REGISTERSTRING(this->name_,        network::direction::toclient, new network::NetworkCallback<Level>(this, &Level::changedName));
    162162        REGISTERSTRING(this->description_, network::direction::toclient);
    163         REGISTERSTRING(this->skybox_,      network::direction::toclient, new network::NetworkCallback<LevelInfo>(this, &LevelInfo::applySkybox));
    164         REGISTERDATA(this->ambientLight_,  network::direction::toclient, new network::NetworkCallback<LevelInfo>(this, &LevelInfo::applyAmbientLight));
    165     }
    166 
    167     void LevelInfo::applyXMLFile()
     163        REGISTERSTRING(this->skybox_,      network::direction::toclient, new network::NetworkCallback<Level>(this, &Level::networkcallback_applySkybox));
     164        REGISTERDATA(this->ambientLight_,  network::direction::toclient, new network::NetworkCallback<Level>(this, &Level::networkcallback_applyAmbientLight));
     165    }
     166
     167    void Level::networkcallback_applyXMLFile()
    168168    {
    169169        COUT(0) << "Loading level \"" << this->xmlfile_ << "\"..." << std::endl;
     
    178178    }
    179179
    180     void LevelInfo::setSkybox(const std::string& skybox)
     180    void Level::setSkybox(const std::string& skybox)
    181181    {
    182182        if (Core::showsGraphics())
     
    187187    }
    188188
    189     void LevelInfo::setAmbientLight(const ColourValue& colour)
     189    void Level::setAmbientLight(const ColourValue& colour)
    190190    {
    191191        if (Core::showsGraphics())
     
    195195    }
    196196
    197     void LevelInfo::setGametypeString(const std::string& gametype)
     197    void Level::setGametypeString(const std::string& gametype)
    198198    {
    199199        Identifier* identifier = ClassByString(gametype);
  • code/branches/objecthierarchy/src/orxonox/objects/infos/Level.h

    r2010 r2012  
    2727 */
    2828
    29 #ifndef _LevelInfo_H__
    30 #define _LevelInfo_H__
     29#ifndef _Level_H__
     30#define _Level_H__
    3131
    3232#include "OrxonoxPrereqs.h"
     
    4141namespace orxonox
    4242{
    43     class _OrxonoxExport LevelInfo : public Info, public network::ClientConnectionListener
     43    class _OrxonoxExport Level : public Info, public network::ClientConnectionListener
    4444    {
    4545        public:
    46             LevelInfo();
    47             virtual ~LevelInfo() {}
     46            Level();
     47            virtual ~Level() {}
    4848
    4949            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     
    7272                { return this->rootGametype_; }
    7373
    74             static LevelInfo* getActiveLevelInfo();
     74            static Level* getActiveLevel();
    7575            static void listPlayers();
    7676            static PlayerInfo* getClient(unsigned int clientID);
     
    8080            virtual void clientDisconnected(unsigned int clientID);
    8181
    82             void applyXMLFile();
     82            void networkcallback_applyXMLFile();
    8383
    84             void applySkybox()
     84            void networkcallback_applySkybox()
    8585                { this->setSkybox(this->skybox_); }
    86             void applyAmbientLight()
     86            void networkcallback_applyAmbientLight()
    8787                { this->setAmbientLight(this->ambientLight_); }
    8888
     
    9898}
    9999
    100 #endif /* _LevelInfo_H__ */
     100#endif /* _Level_H__ */
  • code/branches/objecthierarchy/src/orxonox/overlays/hud/ChatOverlay.cc

    r2006 r2012  
    3939
    4040#include "GraphicsEngine.h"
    41 #include "objects/infos/LevelInfo.h"
     41#include "objects/infos/Level.h"
    4242#include "objects/infos/PlayerInfo.h"
    4343#include "overlays/console/InGameConsole.h"
     
    7676            std::string name = "unknown";
    7777
    78             PlayerInfo* player = LevelInfo::getClient(senderID);
     78            PlayerInfo* player = Level::getClient(senderID);
    7979            if (player)
    8080                name = player->getName();
Note: See TracChangeset for help on using the changeset viewer.