Changeset 2346
- Timestamp:
- Dec 5, 2008, 7:38:53 AM (16 years ago)
- Location:
- code/branches/questsystem3/src/orxonox
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/questsystem3/src/orxonox/objects/quest/AddQuest.cc
r2328 r2346 42 42 43 43 #include "orxonox/objects/infos/PlayerInfo.h" 44 #include "orxonox/overlays/notifications/Notification.h"45 44 #include "QuestManager.h" 46 45 #include "Quest.h" … … 111 110 112 111 COUT(3) << "Quest {" << this->getQuestId() << "} successfully added to player." << std::endl; 113 Notification* notification = new Notification("Crazy Message...", "Title", 30);114 notification->send();115 112 return true; 116 113 } -
code/branches/questsystem3/src/orxonox/objects/quest/CompleteQuest.cc
r2280 r2346 42 42 #include "QuestManager.h" 43 43 #include "Quest.h" 44 #include "orxonox/overlays/notifications/Notification.h"45 44 46 45 namespace orxonox { … … 111 110 112 111 COUT(3) << "Quest {" << quest->getId() << "} successfully completed by player: " << player << " ." << std::endl; 113 Notification* notification = new Notification("Crazy Message...", "Title", 30);114 notification->send();115 112 return true; 116 113 } -
code/branches/questsystem3/src/orxonox/objects/quest/FailQuest.cc
r2328 r2346 40 40 41 41 #include "orxonox/objects/infos/PlayerInfo.h" 42 #include "orxonox/overlays/notifications/Notification.h"43 42 #include "QuestManager.h" 44 43 #include "Quest.h" -
code/branches/questsystem3/src/orxonox/objects/quest/Quest.cc
r2328 r2346 377 377 QuestListener::advertiseStatusChange(this->listeners_, "fail"); //!< Tells the QuestListeners, that the status has changed to failed. 378 378 this->setStatus(player, questStatus::failed); 379 380 this->getDescription()->sendFailQuestNotification(); 379 381 return true; 380 382 } … … 392 394 QuestListener::advertiseStatusChange(this->listeners_, "complete"); //!< Tells the QuestListeners, that the status has changed to completed. 393 395 this->setStatus(player, questStatus::completed); 396 397 this->getDescription()->sendCompleteQuestNotification(); 394 398 return true; 395 399 } … … 414 418 415 419 this->setStatus(player, questStatus::active); 420 421 this->getDescription()->sendAddQuestNotification(); 416 422 return true; 417 423 } -
code/branches/questsystem3/src/orxonox/objects/quest/QuestDescription.cc
r2328 r2346 38 38 39 39 #include "core/CoreIncludes.h" 40 #include "orxonox/overlays/notifications/Notification.h" 40 41 41 42 namespace orxonox { … … 75 76 XMLPortParam(QuestDescription, "description", setDescription, getDescription, xmlelement, mode); 76 77 XMLPortParam(QuestDescription, "failMessage", setFailMessage, getFailMessage, xmlelement, mode); 77 XMLPortParam(QuestDescription, " failMessage", setCompleteMessage, getCompleteMessage, xmlelement, mode);78 XMLPortParam(QuestDescription, "completeMessage", setCompleteMessage, getCompleteMessage, xmlelement, mode); 78 79 79 80 COUT(3) << "New QuestDescription with title '" << this->getTitle() << "' created." << std::endl; 81 } 82 83 /** 84 @brief 85 This method is a helper for sending QuestDescriptions as Notifications. 86 @param item 87 The item the QuestDescription is for. 88 @param status 89 The status the QuestDescription us for. 90 @return 91 Returns true if successful. 92 */ 93 bool QuestDescription::notificationHelper(const std::string & item, const std::string & status) const 94 { 95 std::string message = ""; 96 std::string title = ""; 97 if(item == "hint") 98 { 99 title = "You received a hint: '" + this->title_ + "'"; 100 message = this->description_; 101 } 102 else if(item == "quest") 103 { 104 if(status == "start") 105 { 106 title = "You received a new quest: '" + this->title_ + "'"; 107 message = this->description_; 108 } 109 else if(status == "fail") 110 { 111 title = "You failed the quest: '" + this->title_ + "'"; 112 message = this->failMessage_; 113 } 114 else if(status == "complete") 115 { 116 title = "You successfully completed the quest: '" + this->title_ + "'"; 117 message = this->completeMessage_; 118 } 119 else 120 { 121 COUT(2) << "Bad input in notificationHelper, this should not be happening!" << std::endl; 122 return false; 123 } 124 } 125 else 126 { 127 COUT(2) << "Bad input in notificationHelper, this should not be happening!" << std::endl; 128 return false; 129 } 130 131 Notification* notification = new Notification(message, title, 10); 132 notification->send(); 133 return true; 80 134 } 81 135 -
code/branches/questsystem3/src/orxonox/objects/quest/QuestDescription.h
r2328 r2346 91 91 inline const std::string & getCompleteMessage(void) const 92 92 { return this->completeMessage_; } 93 94 /** 95 @brief Sends a Notification displaying that a QuestHint was added. 96 @return Returns true if successful. 97 */ 98 inline bool sendAddHintNotification(void) const 99 { return notificationHelper("hint", ""); } 100 101 /** 102 @brief Sends a Notification displaying that a Quest was added. 103 @return Returns true if successful. 104 */ 105 inline bool sendAddQuestNotification(void) const 106 { return notificationHelper("quest", "start"); } 107 108 /** 109 @brief Sends a Notification displaying that a Quest was failed. 110 @return Returns true if successful. 111 */ 112 inline bool sendFailQuestNotification(void) const 113 { return notificationHelper("quest", "fail"); } 114 115 /** 116 @brief Sends a Notification displaying that a Quest was completed. 117 @return Returns true if successful. 118 */ 119 inline bool sendCompleteQuestNotification(void) const 120 { return notificationHelper("quest", "complete"); } 93 121 94 122 private: … … 97 125 std::string failMessage_; //!< The message displayed when the Quest is failed. 98 126 std::string completeMessage_; //!< The message displayed when the Quest is completed. 127 128 bool notificationHelper(const std::string & item, const std::string & status) const; //!< Helper for sending QuestDescriptions as Notifications. 99 129 100 130 /** -
code/branches/questsystem3/src/orxonox/objects/quest/QuestHint.cc
r2261 r2346 41 41 #include "orxonox/objects/infos/PlayerInfo.h" 42 42 #include "QuestManager.h" 43 #include "QuestDescription.h" 43 44 #include "Quest.h" 44 45 … … 122 123 { 123 124 this->playerStatus_[player] = questHintStatus::active; 125 126 this->getDescription()->sendAddHintNotification(); 124 127 return true; 125 128 } -
code/branches/questsystem3/src/orxonox/objects/quest/QuestItem.h
r2261 r2346 67 67 /** 68 68 @brief Returns the id of this QuestItem. 69 @return Returns the id of the QuestItem.69 @return Returns the id of the QuestItem. 70 70 */ 71 71 inline const std::string & getId(void) const 72 72 { return this->id_; } 73 74 75 76 73 /** 74 @brief Returns the QuestDescription of the QuestItem. 75 @return Returns a pointer to the QuestDescription object of the QuestItem. 76 */ 77 77 inline const QuestDescription* getDescription(void) const 78 78 { return this->description_; } -
code/branches/questsystem3/src/orxonox/objects/quest/QuestListener.cc
r2333 r2346 43 43 { 44 44 RegisterObject(QuestListener); 45 46 this->status_ = questListenerStatus::start; 47 this->quest_ = NULL; 45 48 } 46 49 … … 62 65 this->quest_->addListener(this); 63 66 64 COUT(3) << "QuestListener created for quest: {" << this->quest_->getId() << "} and status '" << this-> status_<< "'." << std::endl;67 COUT(3) << "QuestListener created for quest: {" << this->quest_->getId() << "} and status '" << this->getQuestStatus() << "'." << std::endl; 65 68 } 66 69 … … 80 83 { 81 84 this->fireEvent(true); //TDO This' right? 82 83 COUT(3) << "QuestListener fired Event, expect for something to happen." << std::endl; //TDO remove84 85 85 return true; 86 86 } -
code/branches/questsystem3/src/orxonox/objects/quest/QuestListener.h
r2329 r2346 80 80 questListenerStatus::Enum status_; 81 81 Quest* quest_; 82 BaseObject* target_;83 82 84 83 }; -
code/branches/questsystem3/src/orxonox/overlays/notifications/NotificationManager.cc
r2328 r2346 87 87 updateQueue(); 88 88 89 COUT( 3) << "Notification inserted, title: " << notification->getTitle() << ", message: " << notification->getMessage() << std::endl;89 COUT(4) << "Notification inserted. Title: " << notification->getTitle() << std::endl; 90 90 91 91 return true; … … 104 104 continue; 105 105 106 COUT(3) << "Update, title: " << container->notification->getTitle() << ", message: " << container->notification->getMessage() << std::endl; 107 108 text = text + "\n\n\n------------" + container->notification->getTitle() + "\n\n" + container->notification->getMessage(); 106 text = text + "\n\n\n------------\n\n" + container->notification->getTitle() + "\n\n" + container->notification->getMessage(); 109 107 } 110 111 COUT(3) << "Queue updated: " << text << std::endl;112 108 113 109 NotificationQueue::queue_s->setQueueText(text); 114 110 } 111 112 const std::string & NotificationManager::clipMessage(const std::string & message) 113 { 114 std::string* clippedMessageP = new std::string(); 115 std::string clippedMessage = *clippedMessageP; 116 clippedMessage = ""; 117 std::string tempWord = ""; 118 int wordLength = 0; 119 signed int i = 0; 120 int widthLeft = NotificationQueue::queue_s->getWidth(); 121 while(i < message.length()) 122 { 123 while(i < message.length() && message[i] != ' ' && message[i] != '\n') 124 { 125 tempWord = tempWord + message[i]; 126 i++; 127 wordLength++; 128 } 129 130 if(wordLength <= widthLeft) 131 { 132 clippedMessage = clippedMessage + tempWord + message[i]; 133 widthLeft -= (wordLength+1); 134 wordLength = 0; 135 tempWord = ""; 136 i++; 137 } 138 else 139 { 140 clippedMessage = clippedMessage + '\n' + tempWord + message[i]; 141 widthLeft = NotificationQueue::queue_s->getWidth() - (wordLength+1); 142 i++; 143 wordLength = 0; 144 tempWord = ""; 145 } 146 } 147 148 return clippedMessage; 149 } 115 150 116 151 } -
code/branches/questsystem3/src/orxonox/overlays/notifications/NotificationManager.h
r2280 r2346 66 66 67 67 static void updateQueue(void); 68 static const std::string & clipMessage(const std::string & message); 68 69 69 70 }; -
code/branches/questsystem3/src/orxonox/overlays/notifications/NotificationQueue.cc
r2287 r2346 53 53 queue_s = this; 54 54 } 55 56 this->length_ = 3; 57 this->width_ = 50; 55 58 } 56 59 … … 65 68 66 69 XMLPortParam(NotificationQueue, "length", setLength, getLength, xmlElement, mode); 70 XMLPortParam(NotificationQueue, "width", setWidth, getWidth, xmlElement, mode); 67 71 } 68 72 … … 84 88 } 85 89 90 bool NotificationQueue::setWidth(int width) 91 { 92 if(width > 0) 93 { 94 this->width_ = width; 95 return true; 96 } 97 return false; 98 } 99 86 100 void NotificationQueue::setQueueText(const std::string & text) 87 101 { -
code/branches/questsystem3/src/orxonox/overlays/notifications/NotificationQueue.h
r2287 r2346 62 62 int getLength(void) const 63 63 { return this->length_; } 64 int getWidth(void) const 65 { return this->width_; } 64 66 65 67 void setQueueText(const std::string & text); 66 68 bool setLength(int length); 69 bool setWidth(int width); 67 70 68 71 private: 69 72 Ogre::UTFString queueText_; 70 73 int length_; 74 int width_; 71 75 72 76 };
Note: See TracChangeset
for help on using the changeset viewer.