Changeset 2993 for code/trunk/src
- Timestamp:
- May 20, 2009, 12:23:51 AM (16 years ago)
- Location:
- code/trunk/src/orxonox
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/orxonox/objects/quest/QuestManager.cc
r2963 r2993 38 38 #include "core/ConsoleCommand.h" 39 39 #include "core/input/InputManager.h" 40 #include "util/Convert.h"41 40 42 41 #include "util/Exception.h" 43 42 #include "gui/GUIManager.h" 43 #include "objects/infos/PlayerInfo.h" 44 44 #include "Quest.h" 45 45 #include "QuestHint.h" … … 49 49 //! Pointer to the current (and single) instance of this class. 50 50 /*static*/ QuestManager* QuestManager::singletonRef_s = NULL; 51 /*static*/ bool QuestManager::GUIOpen = false;52 53 SetConsoleCommand(QuestManager, toggleQuestGUI, true);54 51 55 52 /** … … 220 217 } 221 218 219 /** 220 @brief 221 222 @param name 223 @return 224 */ 222 225 QuestContainer* QuestManager::getQuestTree(std::string & name) 223 226 { … … 227 230 if(gui == NULL) 228 231 { 229 COUT(1) << " Something BAD happened." << std::endl;232 COUT(1) << "Error: No GUIOverlay with the given name '" << name << "' present." << std::endl; 230 233 return NULL; 231 234 } 232 COUT(1) << player << std::endl; 233 ConverterExplicit<BaseObject, PlayerInfo>::convert(player, *(gui->getOwner())); 235 BaseObject* obj = gui->getOwner(); 236 if(obj == NULL) 237 { 238 COUT(1) << "Error: GUIOverlay has no owner. " << std::endl; 239 return NULL; 240 } 241 player = dynamic_cast<PlayerInfo*>(obj); 234 242 235 243 QuestContainer* root = NULL; 236 244 QuestContainer* current = NULL; 237 245 238 std::list<Quest*>* pRootQuests = new std::list<Quest*>(); 239 std::list<Quest*> rootQuests = *pRootQuests; 240 getRootQuests(player, rootQuests); 241 242 for(std::list<Quest*>::iterator it = rootQuests.begin(); it != rootQuests.end(); it++) 243 { 244 Quest* quest = *it; 245 246 QuestContainer* container = new QuestContainer; 247 248 container->description = quest->getDescription(); 249 addHints(container, quest, player); 250 addSubQuests(container, quest, player); 246 std::list<Quest*>* rootQuests = new std::list<Quest*>(); 247 getRootQuests(player, *rootQuests); 248 249 for(std::list<Quest*>::iterator it = rootQuests->begin(); it != rootQuests->end(); it++) 250 { 251 QuestContainer* container = addSubQuest(*it, player); 251 252 252 253 if(root == NULL) … … 265 266 current->next = NULL; 266 267 267 delete pRootQuests;268 delete rootQuests; 268 269 269 270 return root; 270 271 } 271 272 273 /** 274 @brief 275 276 @param player 277 @param list 278 @return 279 */ 272 280 void QuestManager::getRootQuests(const PlayerInfo* player, std::list<Quest*> & list) 273 281 { … … 282 290 } 283 291 284 void QuestManager::addSubQuests(QuestContainer* container, Quest* quest, const PlayerInfo* player) 285 { 292 /** 293 @brief 294 295 @param quest 296 @param player 297 @return 298 */ 299 QuestContainer* QuestManager::addSubQuest(Quest* quest, const PlayerInfo* player) 300 { 301 if(quest == NULL) 302 return NULL; 303 304 QuestContainer* container = new QuestContainer; 305 container->description = quest->getDescription(); 306 container->hint = addHints(quest, player); 307 308 if(quest->isActive(player)) 309 { 310 container->status = "active"; 311 } 312 else if(quest->isCompleted(player)) 313 { 314 container->status = "completed"; 315 } 316 else if(quest->isFailed(player)) 317 { 318 container->status = "failed"; 319 } 320 else 321 { 322 container->status = ""; 323 COUT(1) << "An error occured. A Quest of un-specified status wanted to be displayed." << std::endl; 324 } 325 326 std::list<Quest*> quests = quest->getSubQuestList(); 286 327 QuestContainer* current = NULL; 287 328 QuestContainer* first = NULL; 288 289 std::list<Quest*> quests = quest->getSubQuestList();290 329 for(std::list<Quest*>::iterator it = quests.begin(); it != quests.end(); it++) 291 330 { … … 293 332 if(!subQuest->isInactive(player)) 294 333 { 295 QuestContainer* subQuestContainer = new QuestContainer; 296 297 subQuestContainer->description = subQuest->getDescription(); 298 addHints(subQuestContainer, subQuest, player); 299 addSubQuests(subQuestContainer, subQuest, player); 334 QuestContainer* subContainer = addSubQuest(subQuest, player); 300 335 301 336 if(first == NULL) 302 337 { 303 first = sub QuestContainer;338 first = subContainer; 304 339 } 305 340 else 306 341 { 307 current->next = sub QuestContainer;342 current->next = subContainer; 308 343 } 309 344 310 current = subQuestContainer; 311 } 312 } 313 345 current = subContainer; 346 } 347 } 314 348 if(current != NULL) 315 349 current->next = NULL; 316 350 container->subQuests = first; 317 351 318 } 319 320 void QuestManager::addHints(QuestContainer* container, Quest* quest, const PlayerInfo* player) 352 return container; 353 } 354 355 /** 356 @brief 357 358 @param quest 359 @param player 360 @return 361 */ 362 HintContainer* QuestManager::addHints(Quest* quest, const PlayerInfo* player) 321 363 { 322 364 HintContainer* current = NULL; … … 346 388 if(current != NULL) 347 389 current->next = NULL; 348 container->hint = first; 349 } 350 351 /*static*/ void QuestManager::toggleQuestGUI(void) 352 { 353 if (!QuestManager::GUIOpen) 354 { 355 GUIManager::getInstancePtr()->showGUI("QuestGUI"); 356 GUIManager::getInstancePtr()->executeCode("showCursor()"); 357 InputManager::getInstance().requestEnterState("guiMouseOnly"); 358 GUIManager::getInstancePtr()->executeCode("loadQuestsList()"); 359 GUIOpen = true; 360 } 361 else 362 { 363 GUIManager::getInstancePtr()->executeCode("hideGUI(\"QuestGUI\")"); 364 GUIManager::getInstancePtr()->executeCode("hideCursor()"); 365 InputManager::getInstance().requestLeaveState("guiMouseOnly"); 366 GUIOpen = false; 367 } 390 return first; 368 391 } 369 392 -
code/trunk/src/orxonox/objects/quest/QuestManager.h
r2963 r2993 55 55 { 56 56 const QuestDescription* description; 57 std::string status; 57 58 HintContainer* hint; 58 59 QuestContainer* subQuests; … … 93 94 QuestContainer* getQuestTree(std::string & name); // tolua_export 94 95 95 static void toggleQuestGUI(void); //!< Opens the GUI.96 97 96 private: 98 97 static QuestManager* singletonRef_s; 99 static bool GUIOpen;100 98 101 99 std::map<std::string, Quest*> questMap_; //!< All Quests registered by their id's. … … 103 101 104 102 void getRootQuests(const PlayerInfo* player, std::list<Quest*> & list); 105 void addHints(QuestContainer* container,Quest* quest, const PlayerInfo* player);106 void addSubQuests(QuestContainer* container,Quest* quest, const PlayerInfo* player);103 HintContainer* addHints(Quest* quest, const PlayerInfo* player); 104 QuestContainer* addSubQuest(Quest* quest, const PlayerInfo* player); 107 105 108 106 }; // tolua_export -
code/trunk/src/orxonox/overlays/OrxonoxOverlay.cc
r2896 r2993 57 57 SetConsoleCommand(OrxonoxOverlay, scaleOverlay, false).accessLevel(AccessLevel::User); 58 58 SetConsoleCommand(OrxonoxOverlay, scrollOverlay, false).accessLevel(AccessLevel::User); 59 SetConsoleCommand(OrxonoxOverlay, toggleVisibility, false).accessLevel(AccessLevel::User); 59 60 SetConsoleCommand(OrxonoxOverlay, rotateOverlay, false).accessLevel(AccessLevel::User); 60 61 … … 311 312 /** 312 313 @brief 314 Toggles the visibility of an Overlay by it's name. 315 @param name 316 The name of the overlay defined BaseObject::setName() (usually done with the "name" 317 attribute in the xml file). 318 */ 319 /*static*/ void OrxonoxOverlay::toggleVisibility(const std::string& name) 320 { 321 std::map<std::string, OrxonoxOverlay*>::const_iterator it = overlays_s.find(name); 322 if (it != overlays_s.end()) 323 { 324 OrxonoxOverlay* overlay= (*it).second; 325 if(overlay->isVisible()) 326 overlay->hide(); 327 else 328 overlay->show(); 329 } 330 } 331 332 /** 333 @brief 313 334 Scrolls an overlay by its name. 314 335 @param name -
code/trunk/src/orxonox/overlays/OrxonoxOverlay.h
r2896 r2993 149 149 //! ConsoleCommand: Accesses the overlay by its name and scrolls it. 150 150 static void scrollOverlay(const std::string& name, const Vector2& scroll); 151 static void toggleVisibility(const std::string& name); 151 152 //! ConsoleCommand: Accesses the overlay by its name and rotates it. 152 153 static void rotateOverlay(const std::string& name, const Degree& angle);
Note: See TracChangeset
for help on using the changeset viewer.