- Timestamp:
- Oct 25, 2008, 8:19:40 PM (16 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy/src/orxonox/objects/infos/Level.cc
r2010 r2012 28 28 29 29 #include "OrxonoxStableHeaders.h" 30 #include "Level Info.h"30 #include "Level.h" 31 31 32 32 #include <OgreSceneManager.h> … … 49 49 namespace orxonox 50 50 { 51 SetConsoleCommand(Level Info, listPlayers, true);52 53 CreateFactory(Level Info);54 55 Level Info::LevelInfo()56 { 57 RegisterObject(Level Info);51 SetConsoleCommand(Level, listPlayers, true); 52 53 CreateFactory(Level); 54 55 Level::Level() 56 { 57 RegisterObject(Level); 58 58 59 59 this->rootGametype_ = 0; … … 71 71 // test test test 72 72 73 COUT(0) << "created Level Info" << std::endl;74 } 75 76 Level Info* LevelInfo::getActiveLevelInfo()77 { 78 for (ObjectList<Level Info>::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) 79 79 if (it->isActive()) 80 80 return (*it); … … 83 83 } 84 84 85 PlayerInfo* Level Info::getClient(unsigned int clientID)86 { 87 Level Info* levelinfo = LevelInfo::getActiveLevelInfo();88 89 if (level info)90 { 91 std::map<unsigned int, PlayerInfo*>::const_iterator it = level info->clients_.find(clientID);92 if (it != level info->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()) 93 93 return it->second; 94 94 } … … 102 102 } 103 103 104 void Level Info::listPlayers()105 { 106 Level Info* levelinfo = LevelInfo::getActiveLevelInfo();107 108 if (level info->getGametype())109 { 110 for (std::set<PlayerInfo*>::const_iterator it = level info->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) 111 111 COUT(0) << "ID: " << (*it)->getClientID() << ", Name: " << (*it)->getName() << std::endl; 112 112 } … … 118 118 } 119 119 120 void Level Info::clientConnected(unsigned int clientID)120 void Level::clientConnected(unsigned int clientID) 121 121 { 122 122 COUT(0) << "client connected" << std::endl; … … 132 132 } 133 133 134 void Level Info::clientDisconnected(unsigned int clientID)134 void Level::clientDisconnected(unsigned int clientID) 135 135 { 136 136 COUT(0) << "client disconnected" << std::endl; … … 144 144 } 145 145 146 void Level Info::XMLPort(Element& xmlelement, XMLPort::Mode mode)147 { 148 SUPER(Level Info, XMLPort, xmlelement, mode);149 150 XMLPortParam(Level Info, "description", setDescription, getDescription, xmlelement, mode);151 XMLPortParam(Level Info, "gametype", setGametypeString, getGametypeString, xmlelement, mode).defaultValues("Gametype");152 XMLPortParam(Level Info, "skybox", setSkybox, getSkybox, xmlelement, mode);153 XMLPortParam(Level Info, "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)); 154 154 155 155 this->xmlfile_ = this->getFilename(); 156 156 } 157 157 158 void Level Info::registerVariables()159 { 160 REGISTERSTRING(this->xmlfile_, network::direction::toclient, new network::NetworkCallback<Level Info>(this, &LevelInfo::applyXMLFile));161 REGISTERSTRING(this->name_, network::direction::toclient, new network::NetworkCallback<Level Info>(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)); 162 162 REGISTERSTRING(this->description_, network::direction::toclient); 163 REGISTERSTRING(this->skybox_, network::direction::toclient, new network::NetworkCallback<Level Info>(this, &LevelInfo::applySkybox));164 REGISTERDATA(this->ambientLight_, network::direction::toclient, new network::NetworkCallback<Level Info>(this, &LevelInfo::applyAmbientLight));165 } 166 167 void Level Info::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() 168 168 { 169 169 COUT(0) << "Loading level \"" << this->xmlfile_ << "\"..." << std::endl; … … 178 178 } 179 179 180 void Level Info::setSkybox(const std::string& skybox)180 void Level::setSkybox(const std::string& skybox) 181 181 { 182 182 if (Core::showsGraphics()) … … 187 187 } 188 188 189 void Level Info::setAmbientLight(const ColourValue& colour)189 void Level::setAmbientLight(const ColourValue& colour) 190 190 { 191 191 if (Core::showsGraphics()) … … 195 195 } 196 196 197 void Level Info::setGametypeString(const std::string& gametype)197 void Level::setGametypeString(const std::string& gametype) 198 198 { 199 199 Identifier* identifier = ClassByString(gametype);
Note: See TracChangeset
for help on using the changeset viewer.