Changeset 7163 for code/trunk/src/modules/questsystem
- Timestamp:
- Aug 11, 2010, 8:55:13 AM (14 years ago)
- Location:
- code/trunk
- Files:
-
- 4 deleted
- 33 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/modules/questsystem/AddQuest.cc
r5781 r7163 68 68 SUPER(AddQuest, XMLPort, xmlelement, mode); 69 69 70 COUT( 3) << "New AddQuest, with target Quest {" << this->getQuestId() << "}, created." << std::endl;70 COUT(4) << "New AddQuest, with target Quest {" << this->getQuestId() << "}, created." << std::endl; 71 71 } 72 72 … … 87 87 } 88 88 89 COUT( 3) << "AddQuest on player: " << player << " ." << std::endl;89 COUT(5) << "AddQuest on player: " << player << " ." << std::endl; 90 90 91 91 try … … 103 103 } 104 104 105 COUT( 3) << "Quest {" << this->getQuestId() << "} successfully added to player: " << player << " ." << std::endl;105 COUT(4) << "Quest {" << this->getQuestId() << "} successfully added to player: " << player << " ." << std::endl; 106 106 return true; 107 107 } -
code/trunk/src/modules/questsystem/AddQuestHint.cc
r6417 r7163 72 72 XMLPortParam(AddQuestHint, "hintId", setHintId, getHintId, xmlelement, mode); 73 73 74 COUT( 3) << "New AddQuestHint, with target QuestHint {" << this->getHintId() << "}, created." << std::endl;74 COUT(4) << "New AddQuestHint, with target QuestHint {" << this->getHintId() << "}, created." << std::endl; 75 75 } 76 76 … … 85 85 bool AddQuestHint::setHintId(const std::string & id) 86 86 { 87 if( !QuestItem::isId(id))87 if(id.compare(BLANKSTRING) == 0) 88 88 { 89 89 COUT(2) << "Invalid id. QuestItem id {" << id << "} could not be set." << std::endl; … … 111 111 } 112 112 113 COUT( 3) << "AddQuestHint on player: " << player << " ." << std::endl;113 COUT(5) << "AddQuestHint on player: " << player << " ." << std::endl; 114 114 115 115 try … … 127 127 } 128 128 129 COUT( 3) << "QuestHint {" << this->getHintId() << "} successfully added to player: " << player << " ." << std::endl;129 COUT(4) << "QuestHint {" << this->getHintId() << "} successfully added to player: " << player << " ." << std::endl; 130 130 return true; 131 131 -
code/trunk/src/modules/questsystem/AddReward.cc
r6417 r7163 68 68 XMLPortObject(AddReward, Rewardable, "", addRewardable, getRewardables, xmlelement, mode); 69 69 70 COUT( 3) << "New AddReward, with " << this->rewards_.size() << " Rewardables created." << std::endl;70 COUT(4) << "New AddReward, with " << this->rewards_.size() << " Rewardables created." << std::endl; 71 71 } 72 72 … … 103 103 bool AddReward::invoke(PlayerInfo* player) 104 104 { 105 COUT( 3) << "AddReward on player: " << player << " ." << std::endl;105 COUT(5) << "AddReward on player: " << player << " ." << std::endl; 106 106 107 107 bool check = true; … … 111 111 } 112 112 113 COUT( 3) << "Rewardable successfully added to player." << player << " ." << std::endl;113 COUT(4) << "Rewardable successfully added to player." << player << " ." << std::endl; 114 114 115 115 return check; -
code/trunk/src/modules/questsystem/CMakeLists.txt
r6800 r7163 12 12 QuestEffect.cc 13 13 QuestEffectBeacon.cc 14 QuestGUINode.cc15 QuestGUI.cc16 14 QuestHint.cc 17 15 QuestItem.cc … … 28 26 TOLUA_FILES 29 27 QuestManager.h 30 DEFINE_SYMBOL 31 "QUESTSYSTEM_SHARED_BUILD" 28 QuestDescription.h 29 Quest.h 30 QuestHint.h 32 31 PCH_FILE 33 32 QuestsystemPrecompiledHeaders.h -
code/trunk/src/modules/questsystem/ChangeQuestStatus.cc
r6417 r7163 78 78 bool ChangeQuestStatus::setQuestId(const std::string & id) 79 79 { 80 if( !QuestItem::isId(id))80 if(id.compare(BLANKSTRING) == 0) 81 81 { 82 82 COUT(2) << "Invalid id. QuestItem id {" << id << "} could not be set." << std::endl; -
code/trunk/src/modules/questsystem/CompleteQuest.cc
r6417 r7163 68 68 SUPER(CompleteQuest, XMLPort, xmlelement, mode); 69 69 70 COUT( 3) << "New CompleteQuest, with target Quest {" << this->getQuestId() << "}, created." << std::endl;70 COUT(4) << "New CompleteQuest, with target Quest {" << this->getQuestId() << "}, created." << std::endl; 71 71 } 72 72 … … 87 87 } 88 88 89 COUT( 3) << "CompleteQuest on player: " << player << " ." << std::endl;89 COUT(5) << "CompleteQuest on player: " << player << " ." << std::endl; 90 90 91 91 Quest* quest; … … 105 105 } 106 106 107 COUT( 3) << "Quest {" << quest->getId() << "} successfully completed by player: " << player << " ." << std::endl;107 COUT(4) << "Quest {" << quest->getId() << "} successfully completed by player: " << player << " ." << std::endl; 108 108 return true; 109 109 } -
code/trunk/src/modules/questsystem/FailQuest.cc
r6417 r7163 68 68 SUPER(FailQuest, XMLPort, xmlelement, mode); 69 69 70 COUT( 3) << "New FailQUest, with target Quest {" << this->getQuestId() << "}, created." << std::endl;70 COUT(4) << "New FailQUest, with target Quest {" << this->getQuestId() << "}, created." << std::endl; 71 71 } 72 72 … … 87 87 } 88 88 89 COUT( 3) << "FailQuest on player: " << player << " ." << std::endl;89 COUT(4) << "FailQuest on player: " << player << " ." << std::endl; 90 90 91 91 Quest* quest; … … 104 104 } 105 105 106 COUT( 3) << "Quest {" << quest->getId() << "} failed by player: " << player << " ." << std::endl;106 COUT(4) << "Quest {" << quest->getId() << "} failed by player: " << player << " ." << std::endl; 107 107 return true; 108 108 } -
code/trunk/src/modules/questsystem/GlobalQuest.cc
r6417 r7163 70 70 XMLPortObject(GlobalQuest, QuestEffect, "reward-effects", addRewardEffect, getRewardEffects, xmlelement, mode); 71 71 72 COUT( 3) << "New GlobalQuest {" << this->getId() << "} created." << std::endl;72 COUT(4) << "New GlobalQuest {" << this->getId() << "} created." << std::endl; 73 73 } 74 74 … … 253 253 this->rewards_.push_back(effect); //!< Add the QuestEffect to the list. 254 254 255 COUT( 3) << "Reward effect was added to Quest {" << this->getId() << "}." << std::endl;255 COUT(4) << "Reward effect was added to Quest {" << this->getId() << "}." << std::endl; 256 256 return true; 257 257 } -
code/trunk/src/modules/questsystem/LocalQuest.cc
r6417 r7163 68 68 SUPER(LocalQuest, XMLPort, xmlelement, mode); 69 69 70 COUT( 3) << "New LocalQuest {" << this->getId() << "} created." << std::endl;70 COUT(4) << "New LocalQuest {" << this->getId() << "} created." << std::endl; 71 71 } 72 72 -
code/trunk/src/modules/questsystem/Quest.cc
r6417 r7163 61 61 Quest::~Quest() 62 62 { 63 63 if(this->isRegistered()) 64 QuestManager::getInstance().unregisterQuest(this); 64 65 } 65 66 … … 98 99 this->parentQuest_ = quest; 99 100 100 COUT( 3) << "Parent Quest {" << quest->getId() << "} was added to Quest {" << this->getId() << "}." << std::endl;101 COUT(4) << "Parent Quest {" << quest->getId() << "} was added to Quest {" << this->getId() << "}." << std::endl; 101 102 return true; 102 103 } … … 121 122 this->subQuests_.push_back(quest); //!< Adds the Quest to the end of the list of subquests. 122 123 123 COUT( 3) << "Sub Quest {" << quest->getId() << "} was added to Quest {" << this->getId() << "}." << std::endl;124 COUT(4) << "Sub Quest {" << quest->getId() << "} was added to Quest {" << this->getId() << "}." << std::endl; 124 125 return true; 125 126 } … … 145 146 this->hints_.push_back(hint); //!< Adds the QuestHint to the end of the list of QuestHints. 146 147 147 COUT( 3) << "QuestHint {" << hint->getId() << "} was added to Quest {" << this->getId() << "}." << std::endl;148 COUT(4) << "QuestHint {" << hint->getId() << "} was added to Quest {" << this->getId() << "}." << std::endl; 148 149 return true; 149 150 } … … 167 168 this->failEffects_.push_back(effect); //!< Adds the QuestEffect to the end of the list of fail QuestEffects. 168 169 169 COUT( 3) << "A FailEffect was added to Quest {" << this->getId() << "}." << std::endl;170 COUT(4) << "A FailEffect was added to Quest {" << this->getId() << "}." << std::endl; 170 171 return true; 171 172 } … … 189 190 this->completeEffects_.push_back(effect); //!< Adds the QuestEffect to the end of the list of complete QuestEffects. 190 191 191 COUT( 3) << "A CompleteEffect was added to Quest {" << this->getId() << "}." << std::endl;192 COUT(4) << "A CompleteEffect was added to Quest {" << this->getId() << "}." << std::endl; 192 193 return true; 193 194 } -
code/trunk/src/modules/questsystem/Quest.h
r5781 r7163 41 41 #include "QuestItem.h" 42 42 43 namespace orxonox 44 { 43 namespace orxonox // tolua_export 44 { // tolua_export 45 45 namespace QuestStatus 46 46 { … … 67 67 Damian 'Mozork' Frick 68 68 */ 69 class _QuestsystemExport Quest : public QuestItem 70 { 69 class _QuestsystemExport Quest // tolua_export 70 : public QuestItem 71 { // tolua_export 71 72 public: 72 73 Quest(BaseObject* creator); … … 97 98 98 99 bool isInactive(const PlayerInfo* player) const; //!< Returns true if the quest status for the specific player is 'inactive'. 99 bool isActive(const PlayerInfo* player) const;//!< Returns true if the quest status for the specific player is 'active'.100 bool isFailed(const PlayerInfo* player) const;//!< Returns true if the quest status for the specific player is 'failed'.101 bool isCompleted(const PlayerInfo* player) const;//!< Returns true if the quest status for the specific player is 'completed'.100 bool isActive(const orxonox::PlayerInfo* player) const; // tolua_export //!< Returns true if the quest status for the specific player is 'active'. 101 bool isFailed(const orxonox::PlayerInfo* player) const; // tolua_export //!< Returns true if the quest status for the specific player is 'failed'. 102 bool isCompleted(const orxonox::PlayerInfo* player) const; // tolua_export //!< Returns true if the quest status for the specific player is 'completed'. 102 103 103 104 bool start(PlayerInfo* player); //!< Sets a Quest to active. … … 151 152 bool addCompleteEffect(QuestEffect* effect); //!< Adds an QuestEffect to the list of complete QuestEffects. 152 153 153 }; 154 }; // tolua_export 154 155 155 } 156 } // tolua_export 156 157 157 158 #endif /* _Quest_H__ */ -
code/trunk/src/modules/questsystem/QuestDescription.cc
r6417 r7163 74 74 XMLPortParam(QuestDescription, "completeMessage", setCompleteMessage, getCompleteMessage, xmlelement, mode); 75 75 76 COUT( 3) << "New QuestDescription with title '" << this->getTitle() << "' created." << std::endl;76 COUT(4) << "New QuestDescription with title '" << this->getTitle() << "' created." << std::endl; 77 77 } 78 78 … … 89 89 Make sure the messages meet the conditions. 90 90 */ 91 bool QuestDescription::notificationHelper(const std::string & item, const std::string & status) const91 bool QuestDescription::notificationHelper(const std::string & item, const std::string & status) 92 92 { 93 93 std::string message; … … 122 122 } 123 123 124 QuestNotification* notification = new QuestNotification( message);124 QuestNotification* notification = new QuestNotification(this, message); 125 125 notification->send(); 126 126 return true; -
code/trunk/src/modules/questsystem/QuestDescription.h
r5781 r7163 83 83 @return Returns a string containing the fail message of the QuestDescription. 84 84 */ 85 inline const std::string & getFailMessage(void) const85 inline const std::string & getFailMessage(void) 86 86 { return this->failMessage_; } 87 87 … … 90 90 @return Returns a string containing the complete message of the QuestDescription. 91 91 */ 92 inline const std::string & getCompleteMessage(void) const92 inline const std::string & getCompleteMessage(void) 93 93 { return this->completeMessage_; } 94 94 … … 97 97 @return Returns true if successful. 98 98 */ 99 inline bool sendAddHintNotification(void) const99 inline bool sendAddHintNotification(void) 100 100 { return notificationHelper("hint", ""); } 101 101 … … 104 104 @return Returns true if successful. 105 105 */ 106 inline bool sendAddQuestNotification(void) const106 inline bool sendAddQuestNotification(void) 107 107 { return notificationHelper("quest", "start"); } 108 108 … … 111 111 @return Returns true if successful. 112 112 */ 113 inline bool sendFailQuestNotification(void) const113 inline bool sendFailQuestNotification(void) 114 114 { return notificationHelper("quest", "fail"); } 115 115 … … 118 118 @return Returns true if successful. 119 119 */ 120 inline bool sendCompleteQuestNotification(void) const120 inline bool sendCompleteQuestNotification(void) 121 121 { return notificationHelper("quest", "complete"); } 122 122 … … 127 127 std::string completeMessage_; //!< The message displayed when the Quest is completed. 128 128 129 bool notificationHelper(const std::string & item, const std::string & status) const; //!< Helper for sending QuestDescriptions as Notifications.129 bool notificationHelper(const std::string & item, const std::string & status); //!< Helper for sending QuestDescriptions as Notifications. 130 130 131 131 /** -
code/trunk/src/modules/questsystem/QuestEffectBeacon.cc
r6906 r7163 78 78 XMLPortEventSink(QuestEffectBeacon, BaseObject, "execute", execute, xmlelement, mode); //TODO: Change BaseObject to MultiTrigger as soon as MultiTrigger is the base of all triggers. 79 79 80 COUT( 3) << "New QuestEffectBeacon created." << std::endl;80 COUT(4) << "New QuestEffectBeacon created." << std::endl; 81 81 } 82 82 … … 112 112 MultiTriggerContainer* mTrigger = orxonox_cast<MultiTriggerContainer*>(trigger); 113 113 Pawn* pawn = NULL; 114 114 115 115 //! If the trigger is neither a Playertrigger nor a MultiTrigger (i.e. a MultitriggerContainer) we can do anything with it. 116 116 if(pTrigger == NULL && mTrigger == NULL) 117 117 return false; 118 119 // If the trigger is a PlayerTrigger. 118 119 // If the trigger is a PlayerTrigger. 120 120 if(pTrigger != NULL) 121 121 { … … 125 125 pawn = pTrigger->getTriggeringPlayer(); 126 126 } 127 127 128 128 // If the trigger is a MultiTrigger (i.e. a MultiTriggerContainer) 129 129 if(mTrigger != NULL) … … 134 134 if(pawn == NULL) 135 135 { 136 COUT( 2) << "The QuestEffectBeacon was triggered by an entity other than a Pawn." << std::endl;136 COUT(4) << "The QuestEffectBeacon was triggered by an entity other than a Pawn. (" << trigger->getIdentifier()->getName() << ")" << std::endl; 137 137 return false; 138 138 } … … 147 147 } 148 148 149 COUT( 3) << "QuestEffectBeacon executed on player: " << player << " ." << std::endl;149 COUT(4) << "QuestEffectBeacon executed on player: " << player << " ." << std::endl; 150 150 151 151 bool check = QuestEffect::invokeEffects(player, this->effects_); //!< Invoke the QuestEffects on the PlayerInfo. … … 249 249 this->effects_.push_back(effect); 250 250 251 COUT( 3) << "A QuestEffect was added to a QuestEffectBeacon." << std::endl;251 COUT(4) << "A QuestEffect was added to a QuestEffectBeacon." << std::endl; 252 252 return true; 253 253 } -
code/trunk/src/modules/questsystem/QuestHint.cc
r6417 r7163 59 59 QuestHint::~QuestHint() 60 60 { 61 61 if(this->isRegistered()) 62 QuestManager::getInstance().unregisterHint(this); 62 63 } 63 64 … … 72 73 QuestManager::getInstance().registerHint(this); //!< Registers the QuestHint with the QuestManager. 73 74 74 COUT( 3) << "New QuestHint {" << this->getId() << "} created." << std::endl;75 COUT(4) << "New QuestHint {" << this->getId() << "} created." << std::endl; 75 76 } 76 77 … … 125 126 else 126 127 { 127 COUT( 2) << "An already active questHint was trying to get activated." << std::endl;128 COUT(4) << "An already active questHint was trying to get activated." << std::endl; 128 129 return false; 129 130 } 130 131 } 131 132 132 COUT( 2) << "A hint of a non-active quest was trying to get activated." << std::endl;133 COUT(4) << "A hint of a non-active quest was trying to get activated." << std::endl; 133 134 return false; 134 135 } -
code/trunk/src/modules/questsystem/QuestHint.h
r5781 r7163 40 40 #include "QuestItem.h" 41 41 42 namespace orxonox 43 { 42 namespace orxonox // tolua_export 43 { // tolua_export 44 44 namespace QuestHintStatus 45 45 { … … 66 66 Damian 'Mozork' Frick 67 67 */ 68 class _QuestsystemExport QuestHint : public QuestItem 69 { 68 class _QuestsystemExport QuestHint // tolua_export 69 : public QuestItem 70 { // tolua_export 70 71 71 72 public: … … 91 92 std::map<const PlayerInfo*, QuestHintStatus::Value> playerStatus_; //!< List of the states for each player, with the Player-pointer as key. 92 93 93 }; 94 }; // tolua_export 94 95 95 } 96 } // tolua_export 96 97 97 98 #endif /* _QuestHint_H__ */ -
code/trunk/src/modules/questsystem/QuestItem.cc
r6417 r7163 40 40 namespace orxonox 41 41 { 42 43 CreateUnloadableFactory(QuestItem); 44 42 45 /** 43 46 @brief … … 46 49 QuestItem::QuestItem(BaseObject* creator) : BaseObject(creator) 47 50 { 51 this->registered_ = false; 52 48 53 RegisterObject(QuestItem); 49 54 } … … 79 84 void QuestItem::setId(const std::string & id) 80 85 { 81 if( !isId(id)) //!< Checks whether the id is a valid id.86 if(id.compare(BLANKSTRING) == 0) //!< Checks whether the id is a valid id. 82 87 { 83 88 COUT(2) << "Invalid id. QuestItem id {" << id << "} could not be set." << std::endl; … … 88 93 } 89 94 90 /**91 @brief92 Checks whether an input id is of the required form.93 @param id94 The id to be checked.95 @return96 Returns true if the string is likely to be of the required form.97 */98 /*static*/ bool QuestItem::isId(const std::string & id)99 {100 return id.size() >= 32;101 }102 103 95 } -
code/trunk/src/modules/questsystem/QuestItem.h
r5781 r7163 41 41 #include <string> 42 42 #include "core/BaseObject.h" 43 #include "QuestManager.h" 43 44 44 45 namespace orxonox … … 71 72 @return Returns a pointer to the QuestDescription object of the QuestItem. 72 73 */ 73 inline constQuestDescription* getDescription(void) const74 inline QuestDescription* getDescription(void) const 74 75 { return this->description_; } 75 76 76 static bool isId(const std::string & id); //!< Checks whether a given id is valid. 77 /** 78 @brief Check whether the QuestItem is registered with the QuestManager. 79 @return Returns true if the QuestItem is registered with the QuestManager. 80 */ 81 inline bool isRegistered(void) 82 { return this->registered_; } 83 /** 84 @brief Set the QuestItem as being registered with the QuestManager. 85 */ 86 inline void setRegistered(void) 87 { this->registered_ = true; } 77 88 78 89 protected: … … 90 101 QuestDescription* description_; //!< The QuestDescription of the QuestItem. 91 102 103 bool registered_; 104 92 105 }; 93 106 -
code/trunk/src/modules/questsystem/QuestListener.cc
r6417 r7163 74 74 XMLPortParam(QuestListener, "mode", setMode, getMode, xmlelement, mode); 75 75 76 this->quest_->addListener(this); //!< Adds the QuestListener to the Quests list of listeners. 77 78 COUT(3) << "QuestListener created for quest: {" << this->quest_->getId() << "} with mode '" << this->getMode() << "'." << std::endl; 76 if(this->quest_ != NULL) 77 this->quest_->addListener(this); //!< Adds the QuestListener to the Quests list of listeners. 78 79 COUT(4) << "QuestListener created for quest: {" << this->quest_->getId() << "} with mode '" << this->getMode() << "'." << std::endl; 79 80 } 80 81 -
code/trunk/src/modules/questsystem/QuestManager.cc
r6536 r7163 74 74 QuestManager::~QuestManager() 75 75 { 76 for(std::map<PlayerInfo*, QuestGUI*>::iterator it = this->questGUIs_.begin(); it != this->questGUIs_.end(); it++) 77 { 78 it->second->destroy(); 79 } 80 this->questGUIs_.clear(); 76 81 77 } 82 78 … … 114 110 if(result.second) //!< If inserting was a success. 115 111 { 116 COUT(3) << "Quest with questId {" << quest->getId() << "} successfully inserted." << std::endl; 112 quest->setRegistered(); 113 COUT(4) << "Quest with questId {" << quest->getId() << "} successfully inserted." << std::endl; 117 114 return true; 118 115 } … … 122 119 return false; 123 120 } 121 } 122 123 /** 124 @brief 125 Unregisters a Quest in the QuestManager. 126 */ 127 bool QuestManager::unregisterQuest(Quest* quest) 128 { 129 return this->questMap_.erase(quest->getId()) == 1; 124 130 } 125 131 … … 146 152 if(result.second) //!< If inserting was a success. 147 153 { 148 COUT(3) << "QuestHint with hintId {" << hint->getId() << "} successfully inserted." << std::endl; 154 hint->setRegistered(); 155 COUT(4) << "QuestHint with hintId {" << hint->getId() << "} successfully inserted." << std::endl; 149 156 return true; 150 157 } … … 154 161 return false; 155 162 } 163 } 164 165 /** 166 @brief 167 Unregisters a QuestHint in the QuestManager. 168 */ 169 bool QuestManager::unregisterHint(QuestHint* hint) 170 { 171 return this->hintMap_.erase(hint->getId()) == 1; 156 172 } 157 173 … … 169 185 Quest* QuestManager::findQuest(const std::string & questId) 170 186 { 171 if( !QuestItem::isId(questId)) //!< Check vor validity of the given id.187 if(questId.compare(BLANKSTRING) == 1) //!< Check vor validity of the given id. 172 188 { 173 189 ThrowException(Argument, "Invalid questId."); … … 203 219 QuestHint* QuestManager::findHint(const std::string & hintId) 204 220 { 205 if( !QuestItem::isId(hintId)) //!< Check vor validity of the given id.221 if(hintId.compare(BLANKSTRING) == 1) //!< Check vor validity of the given id. 206 222 { 207 223 ThrowException(Argument, "Invalid hintId."); … … 224 240 } 225 241 226 /** 227 @brief 228 Retreive the main window for the GUI. 229 This is for the use in the lua script tu start the QuestGUI. 230 @param guiName 231 The name of the GUI. 232 @return 233 Returns a CEGUI Window. 234 */ 235 CEGUI::Window* QuestManager::getQuestGUI(const std::string & guiName) 236 { 237 PlayerInfo* player = this->retrievePlayer(guiName); 238 239 if(this->questGUIs_.find(player) == this->questGUIs_.end()) //!< Create a new GUI, if there is none, yet. 240 this->questGUIs_[player] = new QuestGUI(player); 241 242 return this->questGUIs_[player]->getGUI(); 242 int QuestManager::getNumParentQuests(PlayerInfo* player) 243 { 244 int numQuests = 0; 245 for(std::map<std::string, Quest*>::iterator it = this->questMap_.begin(); it != this->questMap_.end(); it++) 246 { 247 if(it->second->getParentQuest() == NULL && !it->second->isInactive(player)) 248 numQuests++; 249 } 250 return numQuests; 251 } 252 253 Quest* QuestManager::getParentQuest(PlayerInfo* player, int index) 254 { 255 for(std::map<std::string, Quest*>::iterator it = this->questMap_.begin(); it != this->questMap_.end(); it++) 256 { 257 if(it->second->getParentQuest() == NULL && !it->second->isInactive(player) && index-- == 0) 258 return it->second; 259 } 260 return NULL; 261 } 262 263 int QuestManager::getNumSubQuests(Quest* quest, PlayerInfo* player) 264 { 265 std::list<Quest*> quests = quest->getSubQuestList(); 266 int numQuests = 0; 267 for(std::list<Quest*>::iterator it = quests.begin(); it != quests.end(); it++) 268 { 269 if(!(*it)->isInactive(player)) 270 numQuests++; 271 } 272 return numQuests; 273 } 274 275 Quest* QuestManager::getSubQuest(Quest* quest, PlayerInfo* player, int index) 276 { 277 std::list<Quest*> quests = quest->getSubQuestList(); 278 for(std::list<Quest*>::iterator it = quests.begin(); it != quests.end(); it++) 279 { 280 if(!(*it)->isInactive(player) && index-- == 0) 281 return *it; 282 } 283 return NULL; 284 } 285 286 int QuestManager::getNumHints(Quest* quest, PlayerInfo* player) 287 { 288 std::list<QuestHint*> hints = quest->getHintsList(); 289 int numHints = 0; 290 for(std::list<QuestHint*>::iterator it = hints.begin(); it != hints.end(); it++) 291 { 292 if((*it)->isActive(player)) 293 numHints++; 294 } 295 return numHints; 296 } 297 298 QuestHint* QuestManager::getHints(Quest* quest, PlayerInfo* player, int index) 299 { 300 std::list<QuestHint*> hints = quest->getHintsList(); 301 for(std::list<QuestHint*>::iterator it = hints.begin(); it != hints.end(); it++) 302 { 303 if((*it)->isActive(player) && index-- == 0) 304 return *it; 305 } 306 return NULL; 307 } 308 309 QuestDescription* QuestManager::getDescription(Quest* item) 310 { 311 return item->getDescription(); 312 } 313 314 QuestDescription* QuestManager::getDescription(QuestHint* item) 315 { 316 return item->getDescription(); 243 317 } 244 318 -
code/trunk/src/modules/questsystem/QuestManager.h
r6536 r7163 36 36 37 37 #include "questsystem/QuestsystemPrereqs.h" 38 #include <CEGUIForwardRefs.h>39 38 40 39 #include <list> … … 44 43 #include "util/Singleton.h" 45 44 #include "core/OrxonoxClass.h" 46 47 #include "QuestGUI.h"48 45 49 46 // tolua_begin … … 63 60 64 61 friend class Singleton<QuestManager>; 65 friend class QuestGUI;66 62 67 63 public: … … 72 68 static QuestManager& getInstance() { return Singleton<QuestManager>::getInstance(); } // tolua_export 73 69 74 //! Retrieve the main window for the GUI. 75 CEGUI::Window* getQuestGUI(const std::string & guiName); // tolua_export 70 // tolua_begin 71 int getNumParentQuests(orxonox::PlayerInfo* player); 72 Quest* getParentQuest(orxonox::PlayerInfo* player, int index); 73 74 int getNumSubQuests(Quest* quest, orxonox::PlayerInfo* player); 75 Quest* getSubQuest(Quest* quest, orxonox::PlayerInfo* player, int index); 76 77 int getNumHints(Quest* quest, orxonox::PlayerInfo* player); 78 QuestHint* getHints(Quest* quest, orxonox::PlayerInfo* player, int index); 79 80 QuestDescription* getDescription(Quest* item); 81 QuestDescription* getDescription(QuestHint* item); 82 // tolua_end 76 83 77 84 bool registerQuest(Quest* quest); //!< Registers a Quest in the QuestManager. 78 bool registerHint(QuestHint* quest); //!< Registers a QuestHint in the QuestManager. 85 bool unregisterQuest(Quest* quest); //!< Unregisters a Quest in the QuestManager. 86 bool registerHint(QuestHint* hint); //!< Registers a QuestHint in the QuestManager. 87 bool unregisterHint(QuestHint* hint); //!< Unregisters a QuestHint in the QuestManager. 79 88 80 89 Quest* findQuest(const std::string & questId); //!< Returns the Quest with the input id. … … 91 100 std::map<std::string, QuestHint*> hintMap_; //!< All QuestHints registered by their id's. 92 101 93 std::map<PlayerInfo*, QuestGUI*> questGUIs_; //!< All GUI's registered by the players.94 95 102 }; // tolua_export 96 103 -
code/trunk/src/modules/questsystem/QuestNotification.cc
r6417 r7163 32 32 namespace orxonox { 33 33 34 const std::string QuestNotification::SENDER("questsystem");34 /*static*/ const std::string QuestNotification::SENDER("questsystem"); 35 35 36 CreateUnloadableFactory(QuestNotification); 37 38 /** 39 @brief 40 Default Constructor. Creates a useless QuestNotification. 41 */ 36 42 QuestNotification::QuestNotification(BaseObject* creator) : Notification(creator) 37 43 { 38 this->initialize();44 RegisterObject(QuestNotification); 39 45 } 40 46 41 QuestNotification::QuestNotification(const std::string & message) : Notification(message) 47 /** 48 @brief 49 Creates a QuestNotification with the input message. 50 @param message 51 The message to be sent. 52 */ 53 QuestNotification::QuestNotification(BaseObject* creator, const std::string & message) : Notification(creator, message) 42 54 { 43 this->initialize();55 RegisterObject(QuestNotification); 44 56 } 45 57 58 /** 59 @brief 60 Destructor. 61 */ 46 62 QuestNotification::~QuestNotification() 47 63 { … … 49 65 } 50 66 67 /** 68 @brief 69 Send the QuestNotification. 70 @return 71 Returns true if successful. 72 */ 51 73 bool QuestNotification::send(void) 52 74 { … … 54 76 } 55 77 56 void QuestNotification::initialize(void)57 {58 RegisterObject(QuestNotification);59 }60 61 78 62 79 } -
code/trunk/src/modules/questsystem/QuestNotification.h
- Property svn:executable deleted
r5781 r7163 39 39 /** 40 40 @brief 41 41 The QuestNotification is a special Notification that has the single property that it is only sent by the questsystem. 42 42 @author 43 43 Damian 'Mozork' Frick … … 46 46 { 47 47 public: 48 QuestNotification(BaseObject* creator); 49 QuestNotification( const std::string & message);50 virtual ~QuestNotification(); 48 QuestNotification(BaseObject* creator); //!< Default Constructor. 49 QuestNotification(BaseObject* creator, const std::string & message); //!< Constructor. 50 virtual ~QuestNotification(); //!< Destructor. 51 51 52 bool send(void); 52 bool send(void); //!< Send the QuestNotification. 53 53 54 54 private: 55 static const std::string SENDER; 56 57 void initialize(void); 55 static const std::string SENDER; //!< A string identifying the questsystem as the sender. 58 56 59 57 }; -
code/trunk/src/modules/questsystem/QuestsystemPrereqs.h
r5929 r7163 43 43 //----------------------------------------------------------------------- 44 44 45 #if defined(ORXONOX_PLATFORM_WINDOWS) && !defined( ORXONOX_STATIC_BUILD)45 #if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(QUESTSYSTEM_STATIC_BUILD) 46 46 # ifdef QUESTSYSTEM_SHARED_BUILD 47 47 # define _QuestsystemExport __declspec(dllexport) … … 77 77 class QuestEffect; 78 78 class QuestEffectBeacon; 79 class QuestGUI;80 class QuestGUINode;81 79 class QuestHint; 82 80 class QuestItem; -
code/trunk/src/modules/questsystem/notifications/Notification.cc
r6417 r7163 40 40 { 41 41 42 CreateUnloadableFactory(Notification); 43 42 44 /** 43 45 @brief … … 56 58 The message of the Notification. 57 59 */ 58 Notification::Notification( const std::string & message) : BaseObject(NULL)60 Notification::Notification(BaseObject* creator, const std::string & message) : BaseObject(creator) 59 61 { 60 62 this->message_ = message; … … 67 69 Notification::~Notification() 68 70 { 71 69 72 } 70 73 -
code/trunk/src/modules/questsystem/notifications/Notification.h
r5781 r7163 53 53 public: 54 54 Notification(BaseObject* creator); 55 Notification( const std::string & message);55 Notification(BaseObject* creator, const std::string & message); 56 56 virtual ~Notification(); 57 57 -
code/trunk/src/modules/questsystem/notifications/NotificationManager.cc
r6417 r7163 66 66 NotificationManager::~NotificationManager() 67 67 { 68 68 69 } 69 70 … … 101 102 this->notificationLists_[it->second]->insert(std::pair<std::time_t,Notification*>(time,notification)); //!< Insert the Notification in the Notifications list of the current NotificationListener. 102 103 it->first->update(notification, time); //!< Update the listener. 104 std::map<Notification*, unsigned int>::iterator counterIt = this->listenerCounter_.find(notification); 105 if(counterIt == this->listenerCounter_.end()) 106 this->listenerCounter_[notification] = 1; 107 else 108 this->listenerCounter_[notification] = counterIt->second + 1; 103 109 } 104 110 } 105 111 106 COUT( 3) << "Notification registered with the NotificationManager." << std::endl;112 COUT(4) << "Notification registered with the NotificationManager." << std::endl; 107 113 108 114 return true; 115 } 116 117 /** 118 @brief 119 Unregisters a Notification within the NotificationManager. 120 @param notification 121 A pointer to the Notification to be unregistered. 122 @param listener 123 A pointer to the NotificationListener the Notification is unregistered for. 124 */ 125 void NotificationManager::unregisterNotification(Notification* notification, NotificationListener* listener) 126 { 127 assert(notification); 128 assert(listener); 129 130 // If the Notification was removed from the list of Notifications of the input NotificationListener, the counter for the Notification of the number of NotificationListeners it is present in is decremented. 131 if(this->removeNotification(notification, *(this->notificationLists_.find(this->listenerList_.find(listener)->second)->second))) 132 this->listenerCounter_[notification] = this->listenerCounter_[notification] - 1; 133 134 // If the Notification is no longer present in any of the NotificationListeners it can be removed from the map of all Notifications and be destroyed. 135 if(this->listenerCounter_[notification] == (unsigned int) 0) 136 { 137 this->removeNotification(notification, this->allNotificationsList_); 138 this->listenerCounter_.erase(notification); 139 notification->destroy(); 140 } 141 142 COUT(4) << "Notification unregistered with the NotificationManager." << std::endl; 143 } 144 145 /** 146 @brief 147 Helper method that removes an input notification form an input map. 148 @param notification 149 A pointer to the notification to be removed. 150 @param map 151 The map the notification should be removed from. 152 @return 153 Returns true if successful. 154 */ 155 bool NotificationManager::removeNotification(Notification* notification, std::multimap<std::time_t, Notification*>& map) 156 { 157 // Iterates through all items in the map until the Notification is found. 158 //TODO: Do more efficiently? 159 for(std::multimap<std::time_t, Notification*>::iterator it = map.begin(); it != map.end(); it++) 160 { 161 if(it->second == notification) 162 { 163 map.erase(it); 164 return true; 165 } 166 } 167 return false; 109 168 } 110 169 … … 130 189 { 131 190 this->notificationLists_[index] = &this->allNotificationsList_; 132 COUT( 3) << "NotificationListener registered with the NotificationManager." << std::endl;191 COUT(4) << "NotificationListener registered with the NotificationManager." << std::endl; 133 192 return true; 134 193 } … … 142 201 if(set.find(it->second->getSender()) != set.end()) //!< Checks whether the overlay has the sender of the current notification as target. 143 202 { 144 map.insert(std::pair<std::time_t,Notification*>(it->first, it->second)); 203 map.insert(std::pair<std::time_t, Notification*>(it->first, it->second)); 204 std::map<Notification*, unsigned int>::iterator counterIt = this->listenerCounter_.find(it->second); 205 if(counterIt == this->listenerCounter_.end()) 206 this->listenerCounter_[it->second] = 1; 207 else 208 this->listenerCounter_[it->second] = counterIt->second + 1; 145 209 } 146 210 } … … 148 212 listener->update(); //!< Update the listener. 149 213 150 COUT( 3) << "NotificationListener registered with the NotificationManager." << std::endl;214 COUT(4) << "NotificationListener registered with the NotificationManager." << std::endl; 151 215 152 216 return true; 217 } 218 219 /** 220 @brief 221 Unregisters a NotificationListener withing the NotificationManager. 222 */ 223 void NotificationManager::unregisterListener(NotificationListener* listener) 224 { 225 assert(listener); 226 227 int identifier = this->listenerList_.find(listener)->second; 228 std::multimap<std::time_t, Notification*>* map = this->notificationLists_.find(identifier)->second; 229 230 // Make sure all Notifications are removed. 231 std::multimap<std::time_t, Notification*>::iterator it = map->begin(); 232 while(it != map->end()) 233 { 234 this->unregisterNotification(it->second, listener); 235 it = map->begin(); 236 } 237 238 this->listenerList_.erase(listener); 239 this->notificationLists_.erase(identifier); 240 241 // If the map is not the map of all notifications, delete it. 242 if(map != &this->allNotificationsList_) 243 delete map; 244 245 COUT(4) << "NotificationListener unregistered with the NotificationManager." << std::endl; 153 246 } 154 247 -
code/trunk/src/modules/questsystem/notifications/NotificationManager.h
r5929 r7163 60 60 virtual ~NotificationManager(); 61 61 62 static const std::string ALL; 63 static const std::string NONE; 62 static const std::string ALL; //!< Static string to indicate a sender that sends to all NotificationListeners. 63 static const std::string NONE; //!< Static string to indicare a sender that sends to no specific NotificationListener. 64 64 65 65 bool registerNotification(Notification* notification); //!< Registers a Notification within the NotificationManager. 66 void unregisterNotification(Notification* notification, NotificationListener* listener); //!< Unregisters a Notification within the NotificationManager. 66 67 bool registerListener(NotificationListener* listener); //!< Registers a NotificationListener within the NotificationManager. 68 void unregisterListener(NotificationListener* listener); //!< Unregisters a NotificationListener withing the NotificationManager. 67 69 68 70 bool getNotifications(NotificationListener* listener, std::multimap<std::time_t,Notification*>* map, const std::time_t & timeFrameStart, const std::time_t & timeFrameEnd); //!< Returns the Notifications for a specific NotificationListener in a specified timeframe. … … 90 92 static NotificationManager* singletonPtr_s; 91 93 92 int highestIndex_; //!< This variable holds the highest index (resp. key) in notificationLists_s, to secure that 94 int highestIndex_; //!< This variable holds the highest index (resp. key) in notificationLists_s, to secure that no key appears twice. 93 95 94 std::multimap<std::time_t,Notification*> allNotificationsList_; //!< Container where all notifications are stored (together with their respecive timestamps).96 std::multimap<std::time_t,Notification*> allNotificationsList_; //!< Container where all notifications are stored. 95 97 std::map<NotificationListener*,int> listenerList_; //!< Container where all NotificationListeners are stored with a number as identifier. 96 98 std::map<int,std::multimap<std::time_t,Notification*>*> notificationLists_; //!< Container where all Notifications, for each identifier (associated with a NotificationListener), are stored. 99 std::map<Notification*, unsigned int> listenerCounter_; //!< A container to store the number of NotificationListeners a Notification is registered with. 97 100 101 bool removeNotification(Notification* notification, std::multimap<std::time_t, Notification*>& map); //!< Helper method that removes an input notification form an input map. 98 102 99 103 }; -
code/trunk/src/modules/questsystem/notifications/NotificationOverlay.cc
- Property svn:executable deleted
-
code/trunk/src/modules/questsystem/notifications/NotificationOverlay.h
- Property svn:executable deleted
-
code/trunk/src/modules/questsystem/notifications/NotificationQueue.cc
r6502 r7163 34 34 #include "NotificationQueue.h" 35 35 36 #include <sstream> 37 36 #include "util/Convert.h" 38 37 #include "core/CoreIncludes.h" 39 38 #include "core/XMLPort.h" … … 56 55 NotificationQueue::NotificationQueue(BaseObject* creator) : OverlayGroup(creator) 57 56 { 57 this->registered_ = false; 58 58 59 RegisterObject(NotificationQueue); 59 60 this->initialize(); … … 68 69 this->targets_.clear(); 69 70 this->clear(); 71 72 if(this->registered_) 73 NotificationManager::getInstance().unregisterListener(this); 70 74 } 71 75 … … 81 85 82 86 NotificationManager::getInstance().registerListener(this); 87 this->registered_ = true; 83 88 } 84 89 … … 118 123 XMLPortParam(NotificationQueue, "position", setPosition, getPosition, xmlElement, mode); 119 124 120 COUT(3) << "NotificationQueue created." << std::endl;125 COUT(3) << "NotificationQueue '" << this->getName() << "' created." << std::endl; 121 126 } 122 127 … … 173 178 delete notifications; 174 179 175 COUT( 3) << "NotificationQueueupdated." << std::endl;180 COUT(4) << "NotificationQueue '" << this->getName() << "' updated." << std::endl; 176 181 } 177 182 … … 196 201 } 197 202 198 COUT( 3) << "NotificationQueueupdated. A new Notifications has been added." << std::endl;203 COUT(4) << "NotificationQueue '" << this->getName() << "' updated. A new Notifications has been added." << std::endl; 199 204 } 200 205 … … 397 402 std::string timeString = std::ctime(&time); 398 403 timeString.erase(timeString.length()-1); 399 std::ostringstream stream; 400 stream << reinterpret_cast<unsigned long>(notification); 401 const std::string& addressString = stream.str(); 404 const std::string& addressString = multi_cast<std::string>(reinterpret_cast<unsigned long>(notification)); 402 405 container->name = "NotificationOverlay(" + timeString + ")&" + addressString; 403 406 … … 422 425 if(this->size_ == 0) //!< You cannot remove anything if the queue is empty. 423 426 return false; 427 428 // Unregister the NotificationQueue with the NotificationManager. 429 NotificationManager::getInstance().unregisterNotification(container->notification, this); 424 430 425 431 this->removeElement(container->overlay); … … 443 449 { 444 450 this->removeContainer(*it); 445 it = this->containers_.begin(); //TODO: Needed?451 it = this->containers_.begin(); 446 452 } 447 453 } -
code/trunk/src/modules/questsystem/notifications/NotificationQueue.h
r5781 r7163 71 71 72 72 Creating a NotificationQueue through XML goes as follows: 73 Be aware that the NotificationQueue must be inside the <Level></Level> tags or bad things will happen. 73 74 <NotificationQueue 74 75 name = "SuperQueue" //Name of your OverlayQueue. … … 185 186 NotificationOverlayContainer timeLimit_; //!< Helper object to check against to determine whether Notifications have expired. 186 187 188 bool registered_; //!< Helper variable to remember whether the NotificationQueue is registered already. 189 187 190 void initialize(void); //!< Initializes the object. 188 191 void setDefaults(void); //!< Helper method to set the default values.
Note: See TracChangeset
for help on using the changeset viewer.