Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/questsystem3/src/orxonox/objects/quest/QuestDescription.cc @ 2346

Last change on this file since 2346 was 2346, checked in by dafrick, 15 years ago
  • QuestListener works now.
  • Rearranged the places Notifications are sent from, and also created actually meaningfull Notification messages
  • Done some changes to Notifications
File size: 4.1 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.cc
31    @brief
32    Implementation of the QuestDescription class.
33*/
34
35#include "OrxonoxStableHeaders.h"
36
37#include "QuestDescription.h"
38
39#include "core/CoreIncludes.h"
40#include "orxonox/overlays/notifications/Notification.h"
41
42namespace orxonox {
43
44    CreateFactory(QuestDescription);
45
46    /**
47    @brief
48        Constructor. Registers and initializes the object.
49    */
50    QuestDescription::QuestDescription(BaseObject* creator) : BaseObject(creator)
51    {
52        RegisterObject(QuestDescription);
53       
54        this->title_ = "";
55        this->description_ = "";
56    }
57
58    /**
59    @brief
60        Destructor.
61    */
62    QuestDescription::~QuestDescription()
63    {
64
65    }
66
67    /**
68    @brief
69        Method for creating a QuestDescription object through XML.
70    */
71    void QuestDescription::XMLPort(Element& xmlelement, XMLPort::Mode mode)
72    {
73        SUPER(QuestDescription, XMLPort, xmlelement, mode);
74
75        XMLPortParam(QuestDescription, "title", setTitle, getTitle, xmlelement, mode);
76        XMLPortParam(QuestDescription, "description", setDescription, getDescription, xmlelement, mode);
77        XMLPortParam(QuestDescription, "failMessage", setFailMessage, getFailMessage, xmlelement, mode);
78        XMLPortParam(QuestDescription, "completeMessage", setCompleteMessage, getCompleteMessage, xmlelement, mode);
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;
134    }
135
136
137}
Note: See TracBrowser for help on using the repository browser.