Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/3DPacman_FS19/src/modules/dialog/Dialog.h @ 12281

Last change on this file since 12281 was 11782, checked in by landauf, 7 years ago

tabs → spaces

  • Property svn:eol-style set to native
File size: 5.0 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 *      ...
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#ifndef _Dialog_H__
30#define _Dialog_H__
31
32#include "core/BaseObject.h"
33#include "DialogPrereqs.h"
34#include "Question.h"
35#include "Answer.h"
36#include "core/XMLPort.h"
37#include "core/CoreIncludes.h"
38#include "overlays/OrxonoxOverlay.h"
39
40#include <map>
41#include <vector>
42#include <string>
43
44namespace orxonox
45{
46    /**
47    @brief
48    class containing core of one dialog with one npc
49
50    this class contains a map of all answerids to answers (player text options) and one of all questionids to questions (npc text options)
51    it realizes a state machine with the question beeing the states and the answers beeing the connections, it has a current state and
52    can be commanded to go to the next state according to a given answer
53    */
54
55    class _DialogExport Dialog : public BaseObject
56    {
57        public:
58            Dialog(Context* context);
59
60            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
61            virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
62
63            void setName(const std::string& name); //xmlPort-Funktion, sets Namen
64            const std::string& getName() const; //xmlPort-Funktion, returns Namen
65
66            void setCurrentQuestionId(const std::string& questionId); //xmlPort-Funktion, sets string id of current question
67            const std::string& getCurrentQuestionId() const; //xmlPort-Funktion, returns id of current question
68
69            void addQuestion(Question* question); //xmlPort-Funktion, adds question to map
70            Question* getQuestion(unsigned int index) const; //xmlPort-Funktion
71
72            void addAnswer(Answer* answer); //xmlPort-Funktion, adds answer to map
73            Answer* getAnswer(unsigned int index) const; //xmlPort-Funktion
74
75            /**
76            @brief
77                returns a pointer to the array of answers belonging to the current question for use in dialogManager
78
79            @return
80                pointer to answerId array of question
81            */
82            const std::vector<std::string>& getAnswerIds() const;
83
84            /**
85            @brief
86                function called when the trigger object defined in the xml file sets to triggered
87
88            @param bTriggered
89                needs to be set like this for correctness
90            @param trigger
91                needs to be set like this for correctness
92            @return
93                not really used
94            */
95            bool execute(bool bTriggered, BaseObject* trigger);
96
97            /**
98            @brief
99                updates the current Dialog according to the id of a given answer, by setting currentQuestionId to the next one
100
101            @param givenAnswerId
102                id of the answer given by player
103            */
104            void update(const std::string& givenAnswerId);
105
106            /**
107            @brief
108                tests if there is a next question for the given answerId
109
110            @param givenAnswerId
111                id of the answer given by player
112            @return
113                true if there is no more Question to the given answerId
114            */
115            bool ending(const std::string& givenAnswerId);
116
117            /**
118            @brief
119                gives the text of the npc in the current state
120
121            @return
122                sting with npc text
123            */
124            const std::string& getQuestionString();
125
126            /**
127            @brief
128                returns a sting with the pc answer to the id
129
130            @param answerId
131                the id of the answer looked for
132            @return
133                sting with answer
134            */
135            const std::string& getAnswerString(const std::string& answerId);
136
137        private:
138            std::string name_; //!< name of the npc talking
139            std::string currentQuestionId_; //!< id of the npc question currently active
140            std::map<std::string, Question*> questions_; //!< a map form the ids of npc textoptions to the objects containing them
141            std::map<std::string, Answer*> answers_; //!< a map form the ids of npc textoptions to the objects containing them
142    };
143}
144
145#endif
Note: See TracBrowser for help on using the repository browser.