[1996] | 1 | /* |
---|
| 2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
| 3 | * > www.orxonox.net < |
---|
| 4 | * |
---|
| 5 | * |
---|
| 6 | * License notice: |
---|
| 7 | * |
---|
| 8 | * This program is free software; you can redistribute it and/or |
---|
| 9 | * modify it under the terms of the GNU General Public License |
---|
| 10 | * as published by the Free Software Foundation; either version 2 |
---|
| 11 | * of the License, or (at your option) any later version. |
---|
| 12 | * |
---|
| 13 | * This program is distributed in the hope that it will be useful, |
---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 16 | * GNU General Public License for more details. |
---|
| 17 | * |
---|
| 18 | * You should have received a copy of the GNU General Public License |
---|
| 19 | * along with this program; if not, write to the Free Software |
---|
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
| 21 | * |
---|
| 22 | * Author: |
---|
| 23 | * Damian 'Mozork' Frick |
---|
| 24 | * Co-authors: |
---|
| 25 | * ... |
---|
| 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
[2261] | 29 | /** |
---|
| 30 | @file QuestDescription.cc |
---|
| 31 | @brief |
---|
| 32 | Implementation of the QuestDescription class. |
---|
| 33 | */ |
---|
| 34 | |
---|
[2105] | 35 | #include "OrxonoxStableHeaders.h" |
---|
[2261] | 36 | |
---|
[2105] | 37 | #include "QuestDescription.h" |
---|
| 38 | |
---|
[1996] | 39 | #include "core/CoreIncludes.h" |
---|
[2346] | 40 | #include "orxonox/overlays/notifications/Notification.h" |
---|
[2021] | 41 | |
---|
[1996] | 42 | namespace orxonox { |
---|
| 43 | |
---|
| 44 | CreateFactory(QuestDescription); |
---|
[2092] | 45 | |
---|
[2261] | 46 | /** |
---|
| 47 | @brief |
---|
| 48 | Constructor. Registers and initializes the object. |
---|
| 49 | */ |
---|
[2092] | 50 | QuestDescription::QuestDescription(BaseObject* creator) : BaseObject(creator) |
---|
[1996] | 51 | { |
---|
[2092] | 52 | RegisterObject(QuestDescription); |
---|
[2261] | 53 | |
---|
| 54 | this->title_ = ""; |
---|
| 55 | this->description_ = ""; |
---|
[2021] | 56 | } |
---|
[2092] | 57 | |
---|
[2261] | 58 | /** |
---|
| 59 | @brief |
---|
| 60 | Destructor. |
---|
| 61 | */ |
---|
[1996] | 62 | QuestDescription::~QuestDescription() |
---|
| 63 | { |
---|
[2092] | 64 | |
---|
[1996] | 65 | } |
---|
[2092] | 66 | |
---|
[2261] | 67 | /** |
---|
| 68 | @brief |
---|
| 69 | Method for creating a QuestDescription object through XML. |
---|
| 70 | */ |
---|
[2068] | 71 | void QuestDescription::XMLPort(Element& xmlelement, XMLPort::Mode mode) |
---|
| 72 | { |
---|
| 73 | SUPER(QuestDescription, XMLPort, xmlelement, mode); |
---|
[2092] | 74 | |
---|
[2068] | 75 | XMLPortParam(QuestDescription, "title", setTitle, getTitle, xmlelement, mode); |
---|
| 76 | XMLPortParam(QuestDescription, "description", setDescription, getDescription, xmlelement, mode); |
---|
[2328] | 77 | XMLPortParam(QuestDescription, "failMessage", setFailMessage, getFailMessage, xmlelement, mode); |
---|
[2346] | 78 | XMLPortParam(QuestDescription, "completeMessage", setCompleteMessage, getCompleteMessage, xmlelement, mode); |
---|
[2092] | 79 | |
---|
[2081] | 80 | COUT(3) << "New QuestDescription with title '" << this->getTitle() << "' created." << std::endl; |
---|
[2068] | 81 | } |
---|
[2346] | 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; |
---|
| 134 | } |
---|
[2092] | 135 | |
---|
[1996] | 136 | |
---|
| 137 | } |
---|