Changeset 5617
- Timestamp:
- Aug 11, 2009, 12:27:38 AM (15 years ago)
- Location:
- code/branches/libraries/src/orxonox
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/libraries/src/orxonox/objects/quest/QuestManager.cc
r3370 r5617 38 38 39 39 #include "objects/infos/PlayerInfo.h" 40 #include "objects/infos/PlayerInfo.h"41 #include "overlays/GUIOverlay.h"42 40 #include "Quest.h" 43 41 #include "QuestHint.h" … … 203 201 /** 204 202 @brief 205 203 206 204 @param name 207 205 @return … … 209 207 QuestContainer* QuestManager::getQuestTree(std::string & name) 210 208 { 211 GUIOverlay* gui = NULL; 212 for (ObjectList<GUIOverlay>::iterator it = ObjectList<GUIOverlay>::begin(); it != ObjectList<GUIOverlay>::end(); ++it) 213 if (it->getGUIName() == name) 214 gui = *it; 215 216 PlayerInfo* player; 217 if(gui == NULL) 218 { 219 COUT(1) << "Error: No GUIOverlay with the given name '" << name << "' present." << std::endl; 209 PlayerInfo* player = this->players_[name]; 210 if(player == NULL) 211 { 212 COUT(1) << "Error: GUIOverlay with name '" << name << "' has no player." << std::endl; 220 213 return NULL; 221 214 } 222 BaseObject* obj = gui->getOwner(); 223 if(obj == NULL) 224 { 225 COUT(1) << "Error: GUIOverlay has no owner. " << std::endl; 226 return NULL; 227 } 228 player = orxonox_cast<PlayerInfo*>(obj); 229 215 230 216 QuestContainer* root = NULL; 231 217 QuestContainer* current = NULL; 232 218 233 219 std::list<Quest*>* rootQuests = new std::list<Quest*>(); 234 220 getRootQuests(player, *rootQuests); 235 221 236 222 for(std::list<Quest*>::iterator it = rootQuests->begin(); it != rootQuests->end(); it++) 237 223 { … … 246 232 current->next = container; 247 233 } 248 234 249 235 current = container; 250 236 … … 260 246 /** 261 247 @brief 262 248 263 249 @param player 264 250 @param list … … 279 265 /** 280 266 @brief 281 267 282 268 @param quest 283 269 @param player … … 310 296 COUT(1) << "An error occurred. A Quest of un-specified status wanted to be displayed." << std::endl; 311 297 } 312 298 313 299 std::list<Quest*> quests = quest->getSubQuestList(); 314 300 QuestContainer* current = NULL; … … 329 315 current->next = subContainer; 330 316 } 331 317 332 318 current = subContainer; 333 319 } … … 336 322 current->next = NULL; 337 323 container->subQuests = first; 338 324 339 325 return container; 340 326 } … … 342 328 /** 343 329 @brief 344 330 345 331 @param quest 346 332 @param player … … 368 354 current->next = hint; 369 355 } 370 356 371 357 current = hint; 372 358 } -
code/branches/libraries/src/orxonox/objects/quest/QuestManager.h
r3370 r5617 92 92 QuestContainer* getQuestTree(std::string & name); // tolua_export 93 93 94 inline void setPlayer(const std::string& guiname, PlayerInfo* player) 95 { this->players_[guiname] = player; } 96 inline PlayerInfo* getPlayer(const std::string& guiname) const 97 { std::map<std::string, PlayerInfo*>::const_iterator it = this->players_.find(guiname); return (it != this->players_.end()) ? it->second : 0; } 98 94 99 private: 95 100 static QuestManager* singletonPtr_s; … … 97 102 std::map<std::string, Quest*> questMap_; //!< All Quests registered by their id's. 98 103 std::map<std::string, QuestHint*> hintMap_; //!< All QuestHints registered by their id's. 104 std::map<std::string, PlayerInfo*> players_; //!< Stores the player (owner) for each gui 99 105 100 106 void getRootQuests(const PlayerInfo* player, std::list<Quest*> & list); -
code/branches/libraries/src/orxonox/overlays/GUIOverlay.cc
r3370 r5617 36 36 #include "core/GUIManager.h" 37 37 #include "core/XMLPort.h" 38 #include "objects/quest/QuestManager.h" 39 #include "objects/infos/PlayerInfo.h" 38 40 39 41 namespace orxonox … … 79 81 } 80 82 83 void GUIOverlay::setGUIName(const std::string& name) 84 { 85 this->guiName_ = name; 86 QuestManager::getInstance().setPlayer(name, orxonox_cast<PlayerInfo*>(this->getOwner())); 87 } 81 88 } -
code/branches/libraries/src/orxonox/overlays/GUIOverlay.h
r3196 r5617 46 46 virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode); 47 47 48 inline void setGUIName(const std::string& name) { this->guiName_ = name; }48 void setGUIName(const std::string& name); 49 49 inline const std::string& getGUIName() const { return this->guiName_; } 50 50
Note: See TracChangeset
for help on using the changeset viewer.