Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/modules/questsystem/QuestDescription.h @ 11942

Last change on this file since 11942 was 11071, checked in by landauf, 9 years ago

merged branch cpp11_v3 back to trunk

  • Property svn:eol-style set to native
File size: 6.2 KB
Line 
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
29/**
30    @file QuestDescription.h
31    @brief Definition of the QuestDescription class.
32    @ingroup Questsystem
33*/
34
35#ifndef _QuestDescription_H__
36#define _QuestDescription_H__
37
38#include "questsystem/QuestsystemPrereqs.h"
39
40#include <string>
41#include "core/BaseObject.h"
42
43// tolua_begin
44namespace orxonox
45{
46
47    /**
48    @brief
49        This class is a description of a QuestItem (@ref orxonox::Quest "Quest" and @ref orxonox::QuestHint "QuestHint").
50        It holds a title and a description. For quests also messages that are sent, when failing or completing the quest can be added.
51
52        Creating a QuestDescription through XML goes as follows:
53        @code
54        <QuestDescription title="Title" description="Description Text" failMessage="You fail." completeMessage="You win!" />
55        @endcode
56
57    @author
58        Damian 'Mozork' Frick
59
60    @ingroup Questsystem
61    */
62    class _QuestsystemExport QuestDescription : public BaseObject
63    {
64// tolua_end
65        public:
66            QuestDescription(Context* context);
67            virtual ~QuestDescription();
68
69            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; //!< Method for creating a QuestDescription object through XML.
70
71// tolua_begin
72            /**
73            @brief Returns the title.
74            @return Returns a string containing the title of the QuestDescription.
75            */
76            inline const std::string & getTitle(void) const
77                { return this->title_; }
78
79            /**
80            @brief Returns the description text.
81            @return Returns a string containing the description text of the QuestDescription.
82            */
83            inline const std::string & getDescription(void) const
84                { return this->description_; }
85// tolua_end
86
87            /**
88            @brief Returns the fail message.
89            @return Returns a string containing the fail message of the QuestDescription.
90            */
91            inline const std::string & getFailMessage(void)
92                { return this->failMessage_; }
93
94            /**
95            @brief Returns the complete message.
96            @return Returns a string containing the complete message of the QuestDescription.
97            */
98            inline const std::string & getCompleteMessage(void)
99                { return this->completeMessage_; }
100
101            /**
102            @brief Sends a Notification displaying that a QuestHint was added.
103            @param player The player the Notification is sent to.
104            @return Returns true if successful.
105            */
106            inline bool sendAddHintNotification(PlayerInfo* player)
107                { return notificationHelper("hint", "", player); }
108
109            /**
110            @brief Sends a Notification displaying that a Quest was added.
111            @param player The player the Notification is sent to.
112            @return Returns true if successful.
113            */
114            inline bool sendAddQuestNotification(PlayerInfo* player)
115                { return notificationHelper("quest", "start", player); }
116
117            /**
118            @brief Sends a Notification displaying that a Quest was failed.
119            @param player The player the Notification is sent to.
120            @return Returns true if successful.
121            */
122            inline bool sendFailQuestNotification(PlayerInfo* player)
123                { return notificationHelper("quest", "fail", player); }
124
125            /**
126            @brief Sends a Notification displaying that a Quest was completed.
127            @param player The player the Notification is sent to.
128            @return Returns true if successful.
129            */
130            inline bool sendCompleteQuestNotification(PlayerInfo* player)
131                { return notificationHelper("quest", "complete", player); }
132
133        private:
134            static const std::string SENDER;
135
136            std::string title_; //!< The title.
137            std::string description_; //!< The description.
138            std::string failMessage_; //!< The message displayed when the Quest is failed.
139            std::string completeMessage_; //!< The message displayed when the Quest is completed.
140
141            bool notificationHelper(const std::string & item, const std::string & status, PlayerInfo* player); //!< Helper for sending QuestDescriptions as Notifications.
142
143            /**
144            @brief Sets the title.
145            @param title The title to be set.
146            */
147            inline void setTitle(const std::string & title)
148                { this->title_ = title; }
149
150            /**
151            @brief Sets the description text.
152            @param description The description text to be set.
153            */
154            inline void setDescription(const std::string & description)
155                { this->description_ = description; }
156
157            /**
158            @brief Sets the fail message.
159            @param message The fail message to be set.
160            */
161            inline void setFailMessage(const std::string & message)
162                { this->failMessage_ = message; }
163
164            /**
165            @brief Sets the complete message.
166            @param message The complete message to be set.
167            */
168            inline void setCompleteMessage(const std::string & message)
169                { this->completeMessage_ = message; }
170
171    }; // tolua_export
172
173} // tolua_export
174
175#endif /* _QuestDescription_H__ */
Note: See TracBrowser for help on using the repository browser.