Changeset 6417 for code/trunk/src/modules/questsystem
- Timestamp:
- Dec 25, 2009, 10:23:58 PM (15 years ago)
- Location:
- code/trunk
- Files:
-
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/modules/questsystem/AddQuestHint.cc
r5781 r6417 71 71 72 72 XMLPortParam(AddQuestHint, "hintId", setHintId, getHintId, xmlelement, mode); 73 73 74 74 COUT(3) << "New AddQuestHint, with target QuestHint {" << this->getHintId() << "}, created." << std::endl; 75 75 } … … 90 90 return false; 91 91 } 92 92 93 93 this->hintId_ = id; 94 94 return true; -
code/trunk/src/modules/questsystem/AddReward.cc
r5781 r6417 67 67 68 68 XMLPortObject(AddReward, Rewardable, "", addRewardable, getRewardables, xmlelement, mode); 69 69 70 70 COUT(3) << "New AddReward, with " << this->rewards_.size() << " Rewardables created." << std::endl; 71 71 } … … 104 104 { 105 105 COUT(3) << "AddReward on player: " << player << " ." << std::endl; 106 106 107 107 bool check = true; 108 108 for ( std::list<Rewardable*>::iterator reward = this->rewards_.begin(); reward != this->rewards_.end(); ++reward ) … … 110 110 check = check && (*reward)->reward(player); 111 111 } 112 112 113 113 COUT(3) << "Rewardable successfully added to player." << player << " ." << std::endl; 114 114 -
code/trunk/src/modules/questsystem/ChangeQuestStatus.cc
r5781 r6417 83 83 return false; 84 84 } 85 85 86 86 this->questId_ = id; 87 87 return true; -
code/trunk/src/modules/questsystem/CompleteQuest.cc
r5781 r6417 26 26 * 27 27 */ 28 28 29 29 /** 30 30 @file … … 67 67 { 68 68 SUPER(CompleteQuest, XMLPort, xmlelement, mode); 69 69 70 70 COUT(3) << "New CompleteQuest, with target Quest {" << this->getQuestId() << "}, created." << std::endl; 71 71 } -
code/trunk/src/modules/questsystem/FailQuest.cc
r5781 r6417 26 26 * 27 27 */ 28 28 29 29 /** 30 30 @file … … 67 67 { 68 68 SUPER(FailQuest, XMLPort, xmlelement, mode); 69 69 70 70 COUT(3) << "New FailQUest, with target Quest {" << this->getQuestId() << "}, created." << std::endl; 71 71 } … … 103 103 return false; 104 104 } 105 105 106 106 COUT(3) << "Quest {" << quest->getId() << "} failed by player: " << player << " ." << std::endl; 107 107 return true; -
code/trunk/src/modules/questsystem/GlobalQuest.cc
r5781 r6417 26 26 * 27 27 */ 28 28 29 29 /** 30 30 @file … … 59 59 60 60 } 61 61 62 62 /** 63 63 @brief … … 67 67 { 68 68 SUPER(GlobalQuest, XMLPort, xmlelement, mode); 69 69 70 70 XMLPortObject(GlobalQuest, QuestEffect, "reward-effects", addRewardEffect, getRewardEffects, xmlelement, mode); 71 71 72 72 COUT(3) << "New GlobalQuest {" << this->getId() << "} created." << std::endl; 73 73 } 74 74 75 75 /** 76 76 @brief … … 89 89 return false; 90 90 } 91 91 92 92 Quest::fail(player); 93 93 94 94 //! Iterate through all players possessing this Quest. 95 95 for(std::set<PlayerInfo*>::const_iterator it = players_.begin(); it != players_.end(); it++) … … 118 118 return false; 119 119 } 120 120 121 121 //! Iterate through all players possessing the Quest. 122 122 for(std::set<PlayerInfo*>::const_iterator it = players_.begin(); it != players_.end(); it++) … … 124 124 QuestEffect::invokeEffects(*it, this->getCompleteEffectList()); 125 125 } 126 126 127 127 Quest::complete(player); 128 128 129 129 QuestEffect::invokeEffects(player, this->rewards_); //!< Invoke reward QuestEffects on the player completing the Quest. 130 130 return true; … … 230 230 this->players_.insert(player); //!< Add the player to the set. 231 231 } 232 232 233 233 this->status_ = status; //!< Set the status, which is global, remember...? 234 234 return true; 235 235 } 236 236 237 237 /** 238 238 @brief … … 256 256 return true; 257 257 } 258 258 259 259 /** 260 260 @brief -
code/trunk/src/modules/questsystem/LocalQuest.cc
r5781 r6417 87 87 return false; 88 88 } 89 89 90 90 Quest::fail(player); 91 91 92 92 QuestEffect::invokeEffects(player, this->getFailEffectList()); //!< Invoke the failEffects. 93 93 return true; … … 110 110 return false; 111 111 } 112 112 113 113 Quest::complete(player); 114 114 115 115 QuestEffect::invokeEffects(player, this->getCompleteEffectList()); //!< Invoke the complete QuestEffects. 116 116 return true; … … 188 188 return it->second; 189 189 } 190 190 191 191 return QuestStatus::Inactive; //!< If the player is not yet in the map, that means the status of the quest form him is 'inactive'. 192 192 } … … 209 209 return false; 210 210 } 211 211 212 212 this->playerStatus_[player] = status; 213 213 return true; -
code/trunk/src/modules/questsystem/Quest.cc
r5781 r6417 26 26 * 27 27 */ 28 28 29 29 /** 30 30 @file … … 204 204 { 205 205 int i = index; 206 206 207 207 //! Iterate through all subquests. 208 208 for (std::list<Quest*>::const_iterator subQuest = this->subQuests_.begin(); subQuest != this->subQuests_.end(); ++subQuest) … … 214 214 i--; 215 215 } 216 216 217 217 return NULL; //!< If the index is greater than the number of elements in the list. 218 218 } … … 229 229 { 230 230 int i = index; 231 231 232 232 //! Iterate through all QuestHints. 233 233 for (std::list<QuestHint*>::const_iterator hint = this->hints_.begin(); hint != this->hints_.end(); ++hint) … … 253 253 { 254 254 int i = index; 255 255 256 256 //! Iterate through all fail QuestEffects. 257 257 for (std::list<QuestEffect*>::const_iterator effect = this->failEffects_.begin(); effect != this->failEffects_.end(); ++effect) … … 277 277 { 278 278 int i = index; 279 279 280 280 //! Iterate through all complete QuestEffects. 281 281 for (std::list<QuestEffect*>::const_iterator effect = this->completeEffects_.begin(); effect != this->completeEffects_.end(); ++effect) … … 350 350 return this->getStatus(player) == QuestStatus::Completed; 351 351 } 352 352 353 353 /** 354 354 @brief … … 363 363 QuestListener::advertiseStatusChange(this->listeners_, "fail"); //!< Tells the QuestListeners, that the status has changed to failed. 364 364 this->setStatus(player, QuestStatus::Failed); 365 365 366 366 COUT(4) << "Quest {" << this->getId() << "} is failed for player: " << player << " ." <<std::endl; 367 367 368 368 this->getDescription()->sendFailQuestNotification(); 369 369 return true; 370 370 } 371 371 372 372 /** 373 373 @brief … … 382 382 QuestListener::advertiseStatusChange(this->listeners_, "complete"); //!< Tells the QuestListeners, that the status has changed to completed. 383 383 this->setStatus(player, QuestStatus::Completed); 384 384 385 385 COUT(4) << "Quest {" << this->getId() << "} is completed for player: " << player << " ." <<std::endl; 386 386 387 387 this->getDescription()->sendCompleteQuestNotification(); 388 388 return true; … … 404 404 return false; 405 405 } 406 406 407 407 COUT(4) << "Quest {" << this->getId() << "} is started for player: " << player << " ." <<std::endl; 408 408 409 409 QuestListener::advertiseStatusChange(this->listeners_, "start"); //!< Tells the QuestListeners, that the status has changed to active. 410 410 411 411 this->setStatus(player, QuestStatus::Active); 412 412 413 413 this->getDescription()->sendAddQuestNotification(); 414 414 return true; 415 415 } 416 416 417 417 /** 418 418 @brief … … 430 430 return false; 431 431 } 432 432 433 433 this->listeners_.push_back(listener); 434 434 return true; -
code/trunk/src/modules/questsystem/QuestDescription.cc
r5781 r6417 50 50 { 51 51 RegisterObject(QuestDescription); 52 53 this->title_ = "";54 this->description_ = "";55 52 } 56 53 … … 79 76 COUT(3) << "New QuestDescription with title '" << this->getTitle() << "' created." << std::endl; 80 77 } 81 78 82 79 /** 83 80 @brief … … 94 91 bool QuestDescription::notificationHelper(const std::string & item, const std::string & status) const 95 92 { 96 std::string message = "";93 std::string message; 97 94 if(item == "hint") 98 95 { 99 message = "You received a hint: '" + this->title_ + "'";96 message = "You received a hint: '" + this->title_ + '\''; 100 97 } 101 98 else if(item == "quest") … … 103 100 if(status == "start") 104 101 { 105 message = "You received a new quest: '" + this->title_ + "'";102 message = "You received a new quest: '" + this->title_ + '\''; 106 103 } 107 104 else if(status == "fail") 108 105 { 109 message = "You failed the quest: '" + this->title_ + "'";106 message = "You failed the quest: '" + this->title_ + '\''; 110 107 } 111 108 else if(status == "complete") 112 109 { 113 message = "You successfully completed the quest: '" + this->title_ + "'";110 message = "You successfully completed the quest: '" + this->title_ + '\''; 114 111 } 115 112 else … … 124 121 return false; 125 122 } 126 123 127 124 QuestNotification* notification = new QuestNotification(message); 128 125 notification->send(); -
code/trunk/src/modules/questsystem/QuestEffect.cc
r5781 r6417 69 69 { 70 70 bool check = true; 71 71 72 72 COUT(4) << "Invoking QuestEffects on player: " << player << " ." << std::endl; 73 73 -
code/trunk/src/modules/questsystem/QuestGUI.cc
r5929 r6417 77 77 } 78 78 this->windows_.clear(); 79 79 80 80 if(this->root_ != NULL) 81 81 this->root_->destroy(); … … 104 104 105 105 this->clear(); //!< Clear the GUI. 106 106 107 107 int depth = 0; 108 108 int index = 0; … … 116 116 for(std::map<std::string, Quest*>::iterator it = quests.begin(); it != quests.end(); it++) 117 117 { 118 Quest* quest = (*it).second;118 Quest* quest = it->second; 119 119 if(quest->getParentQuest() == NULL && !quest->isInactive(this->player_)) //!< If the Quest isn't inactive and a root Quest (meaning it has no parent.), create a Node. 120 120 { … … 136 136 for(std::map<CEGUI::Window*, QuestGUINode*>::iterator it = this->nodes_.begin(); it != this->nodes_.end(); it++) 137 137 { 138 QuestGUINode* node = (*it).second;138 QuestGUINode* node = it->second; 139 139 if(node == NULL) 140 140 { … … 209 209 for(std::map<PlayerInfo*, QuestGUI*>::iterator it = QuestManager::getInstance().questGUIs_.begin(); it != QuestManager::getInstance().questGUIs_.end(); it++) 210 210 { 211 QuestGUI* gui = (*it).second;211 QuestGUI* gui = it->second; 212 212 std::map<CEGUI::Window*, QuestGUINode*>::iterator node = gui->nodes_.find(window); 213 213 if(node != gui->nodes_.end()) return node->second; … … 235 235 236 236 this->nodes_.insert(std::pair<CEGUI::Window*, QuestGUINode*>(node->getWindow(),node)); //!< Insert the node and its window in the nodes_ map. 237 237 238 238 index++; 239 239 … … 268 268 index = tempIndex; //!< Reset the index to the original level. 269 269 270 return index; 270 return index; 271 271 } 272 272 -
code/trunk/src/modules/questsystem/QuestGUI.h
r5781 r6417 56 56 57 57 public: 58 58 59 59 QuestGUI(PlayerInfo* player); 60 60 virtual ~QuestGUI(); … … 86 86 inline PlayerInfo* getPlayer(void) 87 87 { return this->player_; } 88 88 89 89 private: 90 90 91 91 int createNode(QuestGUINode* parent, QuestItem* item, int depth, int index); //!< Recursive method to create Nodes for all Quests an Hints the given Quest is a parent to. 92 92 -
code/trunk/src/modules/questsystem/QuestGUINode.cc
r5781 r6417 71 71 QuestGUINode::QuestGUINode(QuestGUI* gui, QuestGUINode* parent, QuestItem* item, int depth, int index) 72 72 { 73 this->initialize(); 73 this->initialize(); 74 74 75 75 this->gui_ = gui; … … 119 119 void QuestGUINode::toggleVisibility(void) 120 120 { 121 121 122 122 } 123 123 … … 134 134 if(this->window_ != NULL) 135 135 { 136 buffer = (std::string)(this->window_->getName().c_str());136 buffer = this->window_->getName().c_str(); 137 137 } 138 138 else 139 139 { 140 buffer = "";140 buffer.erase(); 141 141 } 142 142 } … … 154 154 155 155 if(this->details_ == NULL) //!< If the details window was not already created. 156 { 156 { 157 157 std::ostringstream stream; 158 158 … … 187 187 CEGUI::Window* statusWindow = this->gui_->getWindowManager()->createWindow("TaharezLook/StaticText", stream.str()); 188 188 window->addChildWindow(statusWindow); 189 std::string status = "";189 std::string status; 190 190 if(quest->isActive(this->gui_->getPlayer())) 191 191 { … … 209 209 offset += height; 210 210 } 211 211 212 212 //! Create title pane for the description. 213 213 stream.str(""); … … 282 282 { 283 283 COUT(3) << "Open QuestItem..." << std::endl; 284 284 285 285 //CEGUI::Window* window = this->gui_->getRootWindow(); 286 286 CEGUI::Window* window = this->gui_->getWindowManager()->getWindow("orxonox/QuestGUI/Background"); … … 297 297 */ 298 298 bool QuestGUINode::closeDetails(const CEGUI::EventArgs& e) 299 { 299 { 300 300 //CEGUI::Window* window = this->gui_->getRootWindow(); 301 301 CEGUI::Window* window = this->gui_->getWindowManager()->getWindow("orxonox/QuestGUI/Background"); … … 344 344 //! Set the height to the window. 345 345 window->setHeight(CEGUI::UDim(0, height)); 346 346 347 347 //Debug 348 348 const CEGUI::Rect newArea = getStaticTextArea(window); … … 368 368 { 369 369 Quest* quest = dynamic_cast<Quest*>(this->item_); 370 370 371 371 this->window_ = this->gui_->getWindow(); 372 372 std::ostringstream stream; … … 377 377 } 378 378 stream << this->index_; 379 379 380 380 this->window_->rename(stream.str()); 381 381 this->window_->setText(this->item_->getDescription()->getTitle()); -
code/trunk/src/modules/questsystem/QuestGUINode.h
r5781 r6417 44 44 45 45 public: 46 46 47 47 QuestGUINode(void); 48 48 QuestGUINode(QuestGUI* gui, QuestGUINode* parent, QuestItem* item, int depth, int index); 49 49 virtual ~QuestGUINode(void); 50 50 51 51 void toggleVisibility(void); 52 52 … … 54 54 /** 55 55 @brief Retreive the window of this node. 56 @return The CEGUI Window of this node. 56 @return The CEGUI Window of this node. 57 57 */ 58 58 inline CEGUI::Window* getWindow(void) -
code/trunk/src/modules/questsystem/QuestHint.cc
r5781 r6417 26 26 * 27 27 */ 28 28 29 29 /** 30 30 @file … … 71 71 72 72 QuestManager::getInstance().registerHint(this); //!< Registers the QuestHint with the QuestManager. 73 73 74 74 COUT(3) << "New QuestHint {" << this->getId() << "} created." << std::endl; 75 75 } … … 100 100 return it->second; 101 101 } 102 102 103 103 return QuestStatus::Inactive; 104 104 } … … 119 119 { 120 120 this->playerStatus_[player] = QuestHintStatus::Active; 121 121 122 122 this->getDescription()->sendAddHintNotification(); 123 123 return true; … … 129 129 } 130 130 } 131 131 132 132 COUT(2) << "A hint of a non-active quest was trying to get activated." << std::endl; 133 133 return false; -
code/trunk/src/modules/questsystem/QuestItem.cc
r5781 r6417 26 26 * 27 27 */ 28 28 29 29 /** 30 30 @file … … 47 47 { 48 48 RegisterObject(QuestItem); 49 50 this->id_ = "";51 49 } 52 50 … … 86 84 return; 87 85 } 88 86 89 87 this->id_ = id; 90 88 } -
code/trunk/src/modules/questsystem/QuestListener.cc
r5781 r6417 50 50 { 51 51 RegisterObject(QuestListener); 52 52 53 53 this->mode_ = QuestListenerMode::All; 54 54 this->quest_ = NULL; 55 55 } 56 56 57 57 /** 58 58 @brief … … 62 62 { 63 63 } 64 64 65 65 /** 66 66 @brief … … 75 75 76 76 this->quest_->addListener(this); //!< Adds the QuestListener to the Quests list of listeners. 77 77 78 78 COUT(3) << "QuestListener created for quest: {" << this->quest_->getId() << "} with mode '" << this->getMode() << "'." << std::endl; 79 79 } 80 80 81 81 /** 82 82 @brief … … 98 98 } 99 99 } 100 100 101 101 /** 102 102 @brief … … 110 110 { 111 111 this->quest_ = QuestManager::getInstance().findQuest(id); //!< Find the Quest corresponding to the given questId. 112 112 113 113 if(this->quest_ == NULL) //!< If there is no such Quest. 114 114 { … … 116 116 return false; 117 117 } 118 118 119 119 return true; 120 120 } 121 121 122 122 /** 123 123 @brief … … 152 152 return false; 153 153 } 154 154 155 155 return true; 156 156 } 157 157 158 158 /** 159 159 @brief … … 183 183 { 184 184 COUT(1) << "An unforseen, never to happen, Error has occurred. This is impossible!" << std::endl; 185 return "";185 return ""; 186 186 } 187 187 } … … 193 193 Returns the questId of the Quest the QuestListener reacts to. 194 194 */ 195 const std::string & QuestListener::getQuestId(void) 195 const std::string & QuestListener::getQuestId(void) 196 196 { 197 197 return this->quest_->getId(); -
code/trunk/src/modules/questsystem/QuestManager.cc
r5929 r6417 55 55 DeclareToluaInterface(Questsystem); 56 56 57 //! Pointer to the current (and single) instance of this class.58 /*static*/ QuestManager* QuestManager::singletonPtr_s = NULL;59 57 ManageScopedSingleton(QuestManager, ScopeID::Root, false); 60 58 … … 78 76 for(std::map<PlayerInfo*, QuestGUI*>::iterator it = this->questGUIs_.begin(); it != this->questGUIs_.end(); it++) 79 77 { 80 (*it).second->destroy();78 it->second->destroy(); 81 79 } 82 80 this->questGUIs_.clear(); -
code/trunk/src/modules/questsystem/QuestManager.h
r5929 r6417 72 72 static QuestManager& getInstance() { return Singleton<QuestManager>::getInstance(); } // tolua_export 73 73 74 //! Retreive the main window for the GUI. 74 //! Retreive the main window for the GUI. 75 75 CEGUI::Window* getQuestGUI(const std::string & guiName); // tolua_export 76 76 -
code/trunk/src/modules/questsystem/QuestNotification.cc
r5781 r6417 32 32 namespace orxonox { 33 33 34 const std::string QuestNotification::SENDER = "questsystem";34 const std::string QuestNotification::SENDER("questsystem"); 35 35 36 36 QuestNotification::QuestNotification(BaseObject* creator) : Notification(creator) … … 38 38 this->initialize(); 39 39 } 40 40 41 41 QuestNotification::QuestNotification(const std::string & message) : Notification(message) 42 42 { 43 43 this->initialize(); 44 44 } 45 45 46 46 QuestNotification::~QuestNotification() 47 47 { 48 48 49 49 } 50 50 -
code/trunk/src/modules/questsystem/notifications/Notification.cc
r5781 r6417 49 49 this->initialize(); 50 50 } 51 51 52 52 /** 53 53 @brief … … 60 60 this->message_ = message; 61 61 } 62 62 63 63 /** 64 64 @brief … … 68 68 { 69 69 } 70 70 71 71 /** 72 72 @brief … … 75 75 void Notification::initialize(void) 76 76 { 77 this->message_ = "";77 this->message_.clear(); 78 78 this->sender_ = NotificationManager::NONE; 79 79 this->sent_ = false; 80 80 } 81 81 82 82 /** 83 83 @brief … … 90 90 return this->send(NotificationManager::NONE); 91 91 } 92 92 93 93 /** 94 94 @brief … … 106 106 return false; 107 107 this->sent_ = true; 108 108 109 109 COUT(3) << "Notification \"" << this->getMessage() << "\" sent." << std::endl; 110 110 111 111 return true; 112 112 } 113 113 114 114 /** 115 115 @brief -
code/trunk/src/modules/questsystem/notifications/NotificationManager.cc
r5929 r6417 44 44 { 45 45 46 const std::string NotificationManager::ALL = "all";47 const std::string NotificationManager::NONE = "none";46 const std::string NotificationManager::ALL("all"); 47 const std::string NotificationManager::NONE("none"); 48 48 49 NotificationManager* NotificationManager::singletonPtr_s = NULL;50 49 ManageScopedSingleton(NotificationManager, ScopeID::Root, false); 51 50 -
code/trunk/src/modules/questsystem/notifications/NotificationQueue.cc
r5929 r6417 46 46 CreateFactory(NotificationQueue); 47 47 48 const std::string NotificationQueue::DEFAULT_FONT = "VeraMono";49 const Vector2 NotificationQueue::DEFAULT_POSITION = Vector2(0.0,0.0);50 const float NotificationQueue::DEFAULT_FONT_SIZE 48 const std::string NotificationQueue::DEFAULT_FONT("VeraMono"); 49 const Vector2 NotificationQueue::DEFAULT_POSITION(0.0,0.0); 50 const float NotificationQueue::DEFAULT_FONT_SIZE = 0.025f; 51 51 52 52 /** … … 271 271 if(!first) 272 272 { 273 *string += ",";273 *string += ','; 274 274 } 275 275 else … … 300 300 while( index < targets.size() ) //!< Go through the string, character by character until the end is reached. 301 301 { 302 pTemp = new std::string( "");302 pTemp = new std::string(); 303 303 while(index < targets.size() && targets[index] != ',' && targets[index] != ' ') 304 304 { … … 399 399 std::ostringstream stream; 400 400 stream << reinterpret_cast<unsigned long>(notification); 401 std::string addressString = stream.str();401 const std::string& addressString = stream.str(); 402 402 container->name = "NotificationOverlay(" + timeString + ")&" + addressString; 403 403
Note: See TracChangeset
for help on using the changeset viewer.