Changeset 2963 for code/trunk
- Timestamp:
- May 10, 2009, 11:41:48 PM (16 years ago)
- Location:
- code/trunk/src/orxonox
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/orxonox/CMakeLists.txt
r2896 r2963 35 35 36 36 GENERATE_SOURCE_GROUPS(${ORXONOX_FILES}) 37 GENERATE_TOLUA_BINDINGS(Orxonox ORXONOX_FILES INPUTFILES gui/GUIManager.h )37 GENERATE_TOLUA_BINDINGS(Orxonox ORXONOX_FILES INPUTFILES gui/GUIManager.h objects/quest/QuestManager.h objects/quest/QuestDescription.h) 38 38 39 39 # Not using precompiled header files: Avoid dependencies -
code/trunk/src/orxonox/gui/GUIManager.cc
r2957 r2963 242 242 /** 243 243 @brief 244 Registers a GUIOverlay with the GUIManager so that the GUIOverlay can be accessed by it's name through the GUIManager. 245 @param name 246 The name of the GUI. 247 @param overlay 248 A pointer to the GUIOverlay of the GUI. 249 @return 250 Returns false if the Overlay was already present. 251 */ 252 bool GUIManager::registerOverlay(std::string name, GUIOverlay* overlay) 253 { 254 return (this->guiOverlays_.insert(std::pair<std::string, GUIOverlay*>(name, overlay))).second; 255 } 256 257 /** 258 @brief 259 Get the GUIOverlay of the GUI with the given name. 260 @param name 261 The name of the GUI. 262 @return 263 Returns a pointer to the GUIOverlay. 264 */ 265 GUIOverlay* GUIManager::getOverlay(std::string name) 266 { 267 return (this->guiOverlays_.find(name))->second; 268 } 269 270 /** 271 @brief 244 272 Tells the GUIManager which SceneManager to use 245 273 @param camera -
code/trunk/src/orxonox/objects/quest/Quest.cc
r2911 r2963 197 197 /** 198 198 @brief 199 Returns the parentquest of the Quest.200 @return201 Returns a pointer to the parentquest of the Quest.202 */203 const Quest* Quest::getParentQuest(void)204 {205 return this->parentQuest_;206 }207 208 /**209 @brief210 199 Returns the subquest at the given index. 211 200 @param -
code/trunk/src/orxonox/objects/quest/Quest.h
r2911 r2963 118 118 virtual bool isCompletable(const PlayerInfo* player) const = 0; //!< Checks whether the Quest can be completed. 119 119 120 const Quest* getParentQuest(void); //!< Returns the parentquest of the Quest.121 120 const Quest* getSubQuest(unsigned int index) const; //!<Returns the subquest at the given index. 122 121 const QuestHint* getHint(unsigned int index) const; //!< Returns the QuestHint at the given index. -
code/trunk/src/orxonox/objects/quest/QuestDescription.h
r2911 r2963 42 42 #include "core/XMLPort.h" 43 43 44 // tolua_begin 44 45 namespace orxonox 45 46 { … … 55 56 Damian 'Mozork' Frick 56 57 */ 57 class _OrxonoxExport QuestDescription : public BaseObject 58 { 58 class _OrxonoxExport QuestDescription 59 // tolua_end 60 : public BaseObject 61 { // tolua_export 59 62 public: 60 63 QuestDescription(BaseObject* creator); … … 63 66 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a QuestDescription object through XML. 64 67 68 // tolua_begin 65 69 /** 66 70 @brief Returns the title. … … 76 80 inline const std::string & getDescription(void) const 77 81 { return this->description_; } 82 // tolua_end 78 83 79 84 /** … … 155 160 { this->completeMessage_ = message; } 156 161 157 }; 162 }; // tolua_export 158 163 159 } 164 } // tolua_export 160 165 161 166 #endif /* _QuestDescription_H__ */ -
code/trunk/src/orxonox/objects/quest/QuestManager.cc
r2911 r2963 36 36 37 37 #include "core/CoreIncludes.h" 38 #include "core/ConsoleCommand.h" 39 #include "core/input/InputManager.h" 40 #include "util/Convert.h" 38 41 39 42 #include "util/Exception.h" 43 #include "gui/GUIManager.h" 40 44 #include "Quest.h" 41 45 #include "QuestHint.h" … … 44 48 { 45 49 //! Pointer to the current (and single) instance of this class. 46 QuestManager* QuestManager::singletonRef_s = NULL; 50 /*static*/ QuestManager* QuestManager::singletonRef_s = NULL; 51 /*static*/ bool QuestManager::GUIOpen = false; 52 53 SetConsoleCommand(QuestManager, toggleQuestGUI, true); 47 54 48 55 /** … … 213 220 } 214 221 222 QuestContainer* QuestManager::getQuestTree(std::string & name) 223 { 224 GUIOverlay* gui = GUIManager::getInstance().getOverlay(name); 225 226 PlayerInfo* player; 227 if(gui == NULL) 228 { 229 COUT(1) << "Something BAD happened." << std::endl; 230 return NULL; 231 } 232 COUT(1) << player << std::endl; 233 ConverterExplicit<BaseObject, PlayerInfo>::convert(player, *(gui->getOwner())); 234 235 QuestContainer* root = NULL; 236 QuestContainer* current = NULL; 237 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); 251 252 if(root == NULL) 253 { 254 root = container; 255 } 256 else 257 { 258 current->next = container; 259 } 260 261 current = container; 262 263 } 264 if(current != NULL) 265 current->next = NULL; 266 267 delete pRootQuests; 268 269 return root; 270 } 271 272 void QuestManager::getRootQuests(const PlayerInfo* player, std::list<Quest*> & list) 273 { 274 for(std::map<std::string, Quest*>::iterator it=this->questMap_.begin(); it!=this->questMap_.end(); it++) 275 { 276 Quest* quest = (*it).second; 277 if(quest->getParentQuest() == NULL && !quest->isInactive(player)) 278 { 279 list.push_back(quest); 280 } 281 } 282 } 283 284 void QuestManager::addSubQuests(QuestContainer* container, Quest* quest, const PlayerInfo* player) 285 { 286 QuestContainer* current = NULL; 287 QuestContainer* first = NULL; 288 289 std::list<Quest*> quests = quest->getSubQuestList(); 290 for(std::list<Quest*>::iterator it = quests.begin(); it != quests.end(); it++) 291 { 292 Quest* subQuest = *it; 293 if(!subQuest->isInactive(player)) 294 { 295 QuestContainer* subQuestContainer = new QuestContainer; 296 297 subQuestContainer->description = subQuest->getDescription(); 298 addHints(subQuestContainer, subQuest, player); 299 addSubQuests(subQuestContainer, subQuest, player); 300 301 if(first == NULL) 302 { 303 first = subQuestContainer; 304 } 305 else 306 { 307 current->next = subQuestContainer; 308 } 309 310 current = subQuestContainer; 311 } 312 } 313 314 if(current != NULL) 315 current->next = NULL; 316 container->subQuests = first; 317 318 } 319 320 void QuestManager::addHints(QuestContainer* container, Quest* quest, const PlayerInfo* player) 321 { 322 HintContainer* current = NULL; 323 HintContainer* first = NULL; 324 325 std::list<QuestHint*> hints = quest->getHintsList(); 326 for(std::list<QuestHint*>::iterator it = hints.begin(); it != hints.end(); it++) 327 { 328 if((*it)->isActive(player)) 329 { 330 HintContainer* hint = new HintContainer; 331 hint->description = (*it)->getDescription(); 332 333 if(first == NULL) 334 { 335 first = hint; 336 } 337 else 338 { 339 current->next = hint; 340 } 341 342 current = hint; 343 } 344 } 345 346 if(current != NULL) 347 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 } 368 } 369 215 370 216 371 } -
code/trunk/src/orxonox/objects/quest/QuestManager.h
r2960 r2963 38 38 39 39 #include <map> 40 #include <list> 40 41 #include <string> 41 42 42 43 #include "core/OrxonoxClass.h" 43 44 #include "orxonox/objects/infos/PlayerInfo.h" 45 #include "overlays/GUIOverlay.h" 44 46 45 47 // tolua_begin 46 48 namespace orxonox 47 49 { 48 // tolua_end49 50 50 struct RootQuest 51 struct QuestContainer; 52 struct HintContainer; 53 54 struct QuestContainer 51 55 { 52 Quest* quest; 53 RootQuest* next; 56 const QuestDescription* description; 57 HintContainer* hint; 58 QuestContainer* subQuests; 59 QuestContainer* next; 54 60 }; 55 61 56 // tolua_begin 62 struct HintContainer 63 { 64 const QuestDescription* description; 65 HintContainer* next; 66 }; 67 57 68 /** 58 69 @brief … … 80 91 QuestHint* findHint(const std::string & hintId); //!< Returns the QuestHint with the input id. 81 92 82 RootQuest* getQuests(const PlayerInfo & player);93 QuestContainer* getQuestTree(std::string & name); // tolua_export 83 94 84 95 static void toggleQuestGUI(void); //!< Opens the GUI. … … 91 102 std::map<std::string, QuestHint*> hintMap_; //!< All QuestHints registered by their id's. 92 103 104 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); 107 93 108 }; // tolua_export 94 109 -
code/trunk/src/orxonox/overlays/GUIOverlay.cc
r2959 r2963 53 53 54 54 XMLPortParam(GUIOverlay, "guiname", setGUIName, getGUIName, xmlElement, mode); 55 56 GUIManager::getInstancePtr()->registerOverlay(this->guiName_, this); 55 57 } 56 58
Note: See TracChangeset
for help on using the changeset viewer.