Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/notifications/src/modules/questsystem/QuestDescription.h @ 7355

Last change on this file since 7355 was 7355, checked in by dafrick, 14 years ago

Re-enabling Notifications for Quests.
Notifications still only work in standalone, though.

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