Changeset 2910 for code/trunk/src/orxonox/objects
- Timestamp:
- Apr 8, 2009, 1:36:05 AM (16 years ago)
- Location:
- code/trunk/src/orxonox/objects/quest
- Files:
-
- 2 deleted
- 35 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/orxonox/objects/quest/AddQuest.cc
r2909 r2910 28 28 29 29 /** 30 @file AddQuest.cc30 @file 31 31 @brief Implementation of the AddQuest class. 32 32 */ … … 42 42 #include "orxonox/objects/infos/PlayerInfo.h" 43 43 #include "QuestManager.h" 44 #include "QuestDescription.h"45 44 #include "Quest.h" 46 45 … … 97 96 try 98 97 { 99 Quest* quest = QuestManager:: getInstance().findQuest(this->getQuestId());98 Quest* quest = QuestManager::findQuest(this->getQuestId()); 100 99 if(quest == NULL || !quest->start(player)) 101 100 { -
code/trunk/src/orxonox/objects/quest/AddQuest.h
r2909 r2910 28 28 29 29 /** 30 @file AddQuest.h30 @file 31 31 @brief Definition of the AddQuest class. 32 32 */ -
code/trunk/src/orxonox/objects/quest/AddQuestHint.cc
r2909 r2910 28 28 29 29 /** 30 @file AddQuestHint.cc30 @file 31 31 @brief Implementation of the AddQuestHint class. 32 32 */ … … 117 117 try 118 118 { 119 QuestHint* hint = QuestManager:: getInstance().findHint(this->hintId_);119 QuestHint* hint = QuestManager::findHint(this->hintId_); 120 120 if(hint == NULL || !hint->setActive(player)) 121 121 { -
code/trunk/src/orxonox/objects/quest/AddQuestHint.h
r2909 r2910 28 28 29 29 /** 30 @file AddQuestHint.h30 @file 31 31 @brief Definition of the AddQuestHint class. 32 32 */ -
code/trunk/src/orxonox/objects/quest/AddReward.cc
r2909 r2910 28 28 29 29 /** 30 @file AddReward.cc30 @file 31 31 @brief Implementation of the AddReward class. 32 32 */ -
code/trunk/src/orxonox/objects/quest/AddReward.h
r2909 r2910 28 28 29 29 /** 30 @file AddReward.h30 @file 31 31 @brief Definition of the AddReward class. 32 32 */ -
code/trunk/src/orxonox/objects/quest/CMakeLists.txt
r2909 r2910 16 16 QuestListener.cc 17 17 QuestManager.cc 18 QuestNotification.cc19 18 Rewardable.cc 20 19 ) -
code/trunk/src/orxonox/objects/quest/ChangeQuestStatus.cc
r2909 r2910 28 28 29 29 /** 30 @file ChangeQuestStatus.cc30 @file 31 31 @brief Implementation of the ChangeQuestStatus class. 32 32 */ -
code/trunk/src/orxonox/objects/quest/ChangeQuestStatus.h
r2909 r2910 28 28 29 29 /** 30 @file ChangeQuestStatus.h30 @file 31 31 @brief Definition of the ChangeQuestStatus class. 32 32 */ -
code/trunk/src/orxonox/objects/quest/CompleteQuest.cc
r2909 r2910 28 28 29 29 /** 30 @file CompleteQuest.cc30 @file 31 31 @brief Implementation of the CompleteQuest class. 32 32 */ … … 96 96 try 97 97 { 98 quest = QuestManager:: getInstance().findQuest(this->getQuestId());98 quest = QuestManager::findQuest(this->getQuestId()); 99 99 if(quest == NULL || !quest->complete(player)) 100 100 { -
code/trunk/src/orxonox/objects/quest/CompleteQuest.h
r2909 r2910 28 28 29 29 /** 30 @file CompleteQuest.h30 @file 31 31 @brief Definition of the CompleteQuest class. 32 32 */ -
code/trunk/src/orxonox/objects/quest/FailQuest.cc
r2909 r2910 28 28 29 29 /** 30 @file FailQuest.cc30 @file 31 31 @brief Implementation of the FailQuest class. 32 32 */ … … 95 95 try 96 96 { 97 quest = QuestManager:: getInstance().findQuest(this->getQuestId());97 quest = QuestManager::findQuest(this->getQuestId()); 98 98 if(quest == NULL || !quest->fail(player)) 99 99 { -
code/trunk/src/orxonox/objects/quest/FailQuest.h
r2909 r2910 28 28 29 29 /** 30 @file FailQuest.h30 @file 31 31 @brief Definition of the FailQuest class. 32 32 */ -
code/trunk/src/orxonox/objects/quest/GlobalQuest.cc
r2909 r2910 28 28 29 29 /** 30 @file GlobalQuest.cc30 @file 31 31 @brief Implementation of the GlobalQuest class. 32 32 */ -
code/trunk/src/orxonox/objects/quest/GlobalQuest.h
r2909 r2910 28 28 29 29 /** 30 @file GlobalQuest.h30 @file 31 31 @brief Definition of the GlobalQuest class. 32 32 */ -
code/trunk/src/orxonox/objects/quest/LocalQuest.cc
r2909 r2910 28 28 29 29 /** 30 @file LocalQuest.cc30 @file 31 31 @brief Implementation of the LocalQuest class. 32 32 */ -
code/trunk/src/orxonox/objects/quest/LocalQuest.h
r2909 r2910 28 28 29 29 /** 30 @file LocalQuest.h30 @file 31 31 @brief Definition of the LocalQuest class. 32 32 */ -
code/trunk/src/orxonox/objects/quest/Quest.cc
r2909 r2910 28 28 29 29 /** 30 @file Quest.cc30 @file 31 31 @brief Implementation of the Quest class. 32 32 */ … … 79 79 XMLPortObject(Quest, QuestEffect, "complete-effects", addCompleteEffect, getCompleteEffect, xmlelement, mode); 80 80 81 QuestManager:: getInstance().registerQuest(this); //!<Registers the Quest with the QuestManager.81 QuestManager::registerQuest(this); //!<Registers the Quest with the QuestManager. 82 82 } 83 83 -
code/trunk/src/orxonox/objects/quest/Quest.h
r2909 r2910 28 28 29 29 /** 30 @file Quest.h30 @file 31 31 @brief Definition of the Quest class. 32 32 The Quest is the parent class of LocalQuest and GlobalQuest. -
code/trunk/src/orxonox/objects/quest/QuestDescription.cc
r2909 r2910 28 28 29 29 /** 30 @file QuestDescription.cc30 @file 31 31 @brief Implementation of the QuestDescription class. 32 32 */ … … 37 37 38 38 #include "core/CoreIncludes.h" 39 #include " QuestNotification.h"39 #include "orxonox/overlays/notifications/Notification.h" 40 40 41 41 namespace orxonox … … 89 89 @return 90 90 Returns true if successful. 91 @todo92 Make sure the messages meet the conditions.93 91 */ 94 92 bool QuestDescription::notificationHelper(const std::string & item, const std::string & status) const 95 93 { 96 94 std::string message = ""; 95 std::string title = ""; 97 96 if(item == "hint") 98 97 { 99 message = "You received a hint: '" + this->title_ + "'"; 98 title = "You received a hint: '" + this->title_ + "'"; 99 message = this->description_; 100 100 } 101 101 else if(item == "quest") … … 103 103 if(status == "start") 104 104 { 105 message = "You received a new quest: '" + this->title_ + "'"; 105 title = "You received a new quest: '" + this->title_ + "'"; 106 message = this->description_; 106 107 } 107 108 else if(status == "fail") 108 109 { 109 message = "You failed the quest: '" + this->title_ + "'"; 110 title = "You failed the quest: '" + this->title_ + "'"; 111 message = this->failMessage_; 110 112 } 111 113 else if(status == "complete") 112 114 { 113 message = "You successfully completed the quest: '" + this->title_ + "'"; 115 title = "You successfully completed the quest: '" + this->title_ + "'"; 116 message = this->completeMessage_; 114 117 } 115 118 else … … 125 128 } 126 129 127 QuestNotification* notification = new QuestNotification(message);130 Notification* notification = new Notification(0, message, title, 30); 128 131 notification->send(); 129 132 return true; -
code/trunk/src/orxonox/objects/quest/QuestDescription.h
r2909 r2910 28 28 29 29 /** 30 @file QuestDescription.h30 @file 31 31 @brief Definition of the QuestDescription class. 32 32 */ -
code/trunk/src/orxonox/objects/quest/QuestEffect.cc
r2909 r2910 28 28 29 29 /** 30 @file QuestEffect.cc30 @file 31 31 @brief Implementation of the QuestEffect class. 32 32 */ -
code/trunk/src/orxonox/objects/quest/QuestEffect.h
r2909 r2910 28 28 29 29 /** 30 @file QuestEffect.h30 @file 31 31 @brief Definition of the QuestEffect class. 32 32 */ -
code/trunk/src/orxonox/objects/quest/QuestEffectBeacon.cc
r2909 r2910 28 28 29 29 /** 30 @file QuestEffectBeacon.cc30 @file 31 31 @brief Implementation of the QuestEffectBeacon class. 32 32 */ -
code/trunk/src/orxonox/objects/quest/QuestEffectBeacon.h
r2909 r2910 28 28 29 29 /** 30 @file QuestEffectBeacon.h30 @file 31 31 @brief Definition of the QuestEffectBeacon class. 32 32 */ -
code/trunk/src/orxonox/objects/quest/QuestHint.cc
r2909 r2910 28 28 29 29 /** 30 @file QuestHint.cc30 @file 31 31 @brief Implementation of the QuestHint class. 32 32 */ … … 73 73 SUPER(QuestHint, XMLPort, xmlelement, mode); 74 74 75 QuestManager:: getInstance().registerHint(this); //!< Registers the QuestHint with the QuestManager.75 QuestManager::registerHint(this); //!< Registers the QuestHint with the QuestManager. 76 76 77 77 COUT(3) << "New QuestHint {" << this->getId() << "} created." << std::endl; -
code/trunk/src/orxonox/objects/quest/QuestHint.h
r2909 r2910 28 28 29 29 /** 30 @file QuestHint.h30 @file 31 31 @brief Definition of the QuestHint class. 32 32 */ -
code/trunk/src/orxonox/objects/quest/QuestItem.cc
r2909 r2910 28 28 29 29 /** 30 @file QuestItem.cc30 @file 31 31 @brief Implementation of the QuestItem class. 32 32 */ -
code/trunk/src/orxonox/objects/quest/QuestItem.h
r2909 r2910 28 28 29 29 /** 30 @file QuestItem.h30 @file 31 31 @brief Definition of the QuestItem class. 32 32 The QuestItem is the parent class of Quest and QuestHint. -
code/trunk/src/orxonox/objects/quest/QuestListener.cc
r2909 r2910 28 28 29 29 /** 30 @file QuestListener.cc30 @file 31 31 @brief Implementation of the QuestListener class. 32 32 */ … … 112 112 bool QuestListener::setQuestId(const std::string & id) 113 113 { 114 this->quest_ = QuestManager:: getInstance().findQuest(id); //!< Find the Quest corresponding to the given questId.114 this->quest_ = QuestManager::findQuest(id); //!< Find the Quest corresponding to the given questId. 115 115 116 116 if(this->quest_ == NULL) //!< If there is no such Quest. -
code/trunk/src/orxonox/objects/quest/QuestListener.h
r2909 r2910 28 28 29 29 /** 30 @file QuestListener.h30 @file 31 31 @brief Definition of the QuestListener class. 32 32 */ -
code/trunk/src/orxonox/objects/quest/QuestManager.cc
r2909 r2910 28 28 29 29 /** 30 @file QuestManager.cc30 @file 31 31 @brief Implementation of the QuestManager class. 32 32 */ … … 43 43 namespace orxonox 44 44 { 45 //! Pointer to the current (and single) instance of this class. 46 QuestManager* QuestManager::singletonRef_s = NULL; 45 //! All Quests registered by their id's. 46 std::map<std::string, Quest*> QuestManager::questMap_s; 47 //! All QuestHints registered by their id's. 48 std::map<std::string, QuestHint*> QuestManager::hintMap_s; 47 49 48 50 /** 49 51 @brief 50 52 Constructor. Registers the object. 51 @todo 52 Is inheriting from BaseObject proper? 53 */ 54 QuestManager::QuestManager() 55 { 56 RegisterRootObject(QuestManager); 57 58 assert(singletonRef_s == 0); 59 singletonRef_s = this; 53 */ 54 QuestManager::QuestManager(BaseObject* creator) : BaseObject(creator) 55 { 56 RegisterObject(QuestManager); 60 57 } 61 58 … … 67 64 { 68 65 69 }70 71 /**72 @brief73 Returns a reference to the current (and single) instance of the QuestManager, and creates one if there isn't one to begin with.74 @return75 Returns a reference to the single instance of the Quest Manager.76 */77 /*static*/ QuestManager & QuestManager::getInstance()78 {79 assert(singletonRef_s);80 return *singletonRef_s;81 66 } 82 67 … … 90 75 Returns true if successful, false if not. 91 76 */ 92 bool QuestManager::registerQuest(Quest* quest)77 /*static*/ bool QuestManager::registerQuest(Quest* quest) 93 78 { 94 79 if(quest == NULL) //!< Doh! Just as if there were actual quests behind NULL-pointers. … … 99 84 100 85 std::pair<std::map<std::string, Quest*>::iterator,bool> result; 101 result = this->questMap_.insert( std::pair<std::string,Quest*>(quest->getId(),quest) ); //!< Inserting the Quest.86 result = questMap_s.insert( std::pair<std::string,Quest*>(quest->getId(),quest) ); //!< Inserting the Quest. 102 87 103 88 if(result.second) //!< If inserting was a success. … … 122 107 Returns true if successful, false if not. 123 108 */ 124 bool QuestManager::registerHint(QuestHint* hint)109 /*static*/ bool QuestManager::registerHint(QuestHint* hint) 125 110 { 126 111 if(hint == NULL) //!< Still not liking NULL-pointers. … … 131 116 132 117 std::pair<std::map<std::string, QuestHint*>::iterator,bool> result; 133 result = this->hintMap_.insert ( std::pair<std::string,QuestHint*>(hint->getId(),hint) ); //!< Inserting the QuestHSint.118 result = hintMap_s.insert ( std::pair<std::string,QuestHint*>(hint->getId(),hint) ); //!< Inserting the QuestHSint. 134 119 135 120 if(result.second) //!< If inserting was a success. … … 156 141 Throws an exception if the given questId is invalid. 157 142 */ 158 Quest* QuestManager::findQuest(const std::string & questId)143 /*static*/ Quest* QuestManager::findQuest(const std::string & questId) 159 144 { 160 145 if(!QuestItem::isId(questId)) //!< Check vor validity of the given id. … … 164 149 165 150 Quest* quest; 166 std::map<std::string, Quest*>::iterator it = this->questMap_.find(questId);167 if (it != this->questMap_.end()) //!< If the Quest is registered.151 std::map<std::string, Quest*>::iterator it = questMap_s.find(questId); 152 if (it != questMap_s.end()) //!< If the Quest is registered. 168 153 { 169 154 quest = it->second; … … 190 175 Throws an exception if the given hintId is invalid. 191 176 */ 192 QuestHint* QuestManager::findHint(const std::string & hintId)177 /*static*/ QuestHint* QuestManager::findHint(const std::string & hintId) 193 178 { 194 179 if(!QuestItem::isId(hintId)) //!< Check vor validity of the given id. … … 198 183 199 184 QuestHint* hint; 200 std::map<std::string, QuestHint*>::iterator it = this->hintMap_.find(hintId);201 if (it != this->hintMap_.end()) //!< If the QuestHint is registered.185 std::map<std::string, QuestHint*>::iterator it = hintMap_s.find(hintId); 186 if (it != hintMap_s.end()) //!< If the QuestHint is registered. 202 187 { 203 188 hint = it->second; -
code/trunk/src/orxonox/objects/quest/QuestManager.h
r2909 r2910 28 28 29 29 /** 30 @file QuestManager.h30 @file 31 31 @brief Definition of the QuestManager class. 32 32 */ … … 40 40 #include <string> 41 41 42 #include "core/ OrxonoxClass.h"42 #include "core/BaseObject.h" 43 43 44 44 namespace orxonox … … 46 46 /** 47 47 @brief 48 Is a Singletonand manages Quests, by registering every Quest/QuestHint (through registerX()) and making them globally accessable (through findX()).48 Is a static class and manages Quests, by registering every Quest/QuestHint (through registerX()) and making them globally accessable (through findX()). 49 49 Quests (and QuestHints) are registered in the QuestManager with their id, and can be accessed in the same way. 50 50 @author 51 51 Damian 'Mozork' Frick 52 52 */ 53 class _OrxonoxExport QuestManager : public OrxonoxClass53 class _OrxonoxExport QuestManager : public BaseObject 54 54 { 55 55 56 public: 56 QuestManager( );57 QuestManager(BaseObject* creator); 57 58 virtual ~QuestManager(); 58 59 59 static QuestManager& getInstance(); //!< Returns a reference to the single instance of the Quest Manager. 60 static bool registerQuest(Quest* quest); //!< Registers a Quest in the QuestManager. 61 static bool registerHint(QuestHint* quest); //!< Registers a QuestHint in the QuestManager. 60 62 61 bool registerQuest(Quest* quest); //!< Registers a Quest in the QuestManager. 62 bool registerHint(QuestHint* quest); //!< Registers a QuestHint in the QuestManager. 63 64 Quest* findQuest(const std::string & questId); //!< Returns the Quest with the input id. 65 QuestHint* findHint(const std::string & hintId); //!< Returns the QuestHint with the input id. 63 static Quest* findQuest(const std::string & questId); //!< Returns the Quest with the input id. 64 static QuestHint* findHint(const std::string & hintId); //!< Returns the QuestHint with the input id. 66 65 67 66 private: 68 static QuestManager* singletonRef_s; 69 70 std::map<std::string, Quest*> questMap_; //!< All Quests registered by their id's. 71 std::map<std::string, QuestHint*> hintMap_; //!< All QuestHints registered by their id's. 67 static std::map<std::string, Quest*> questMap_s; //!< All Quests registered by their id's. 68 static std::map<std::string, QuestHint*> hintMap_s; //!< All QuestHints registered by their id's. 72 69 73 70 }; -
code/trunk/src/orxonox/objects/quest/Rewardable.cc
r2909 r2910 28 28 29 29 /** 30 @file Rewardable.cc30 @file 31 31 @brief Implementation of the Rewardable class. 32 32 */ -
code/trunk/src/orxonox/objects/quest/Rewardable.h
r2909 r2910 28 28 29 29 /** 30 @file Rewardable.h30 @file 31 31 @brief Definition of the Rewardable class. 32 32 */
Note: See TracChangeset
for help on using the changeset viewer.