Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/Dialog_HS17/src/modules/dialog/Dialog.h @ 11703

Last change on this file since 11703 was 11656, checked in by kuchlert, 7 years ago

fertig kommentierte version

File size: 3.7 KB
RevLine 
[11607]1#ifndef _Dialog_H__
2#define _Dialog_H__
3
[11579]4#include "core/BaseObject.h"
[11611]5#include "DialogPrereqs.h"
[11579]6#include "Question.h"
7#include "Answer.h"
8#include "core/XMLPort.h"
[11607]9#include "core/CoreIncludes.h"
[11579]10#include "overlays/OrxonoxOverlay.h"
11
[11611]12#include <map>
13#include <vector>
[11579]14#include <string>
15
16namespace orxonox
17{
[11656]18                /**
19        @brief
20    class containing core of one dialog with one npc
21
22    this class contains a map of all answerids to answers (player text options) and one of all questionids to questions (npc text options)
23    it realizes a state machine with the question beeing the states and the answers beeing the connections, it has a current state and
24    can be commanded to go to the next state according to a given answer
25        */
26
[11611]27        class _DialogExport Dialog : public BaseObject
[11579]28        {
29                public:
30                        Dialog(Context* context);
[11611]31
[11579]32                        virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
33                        virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
34
[11656]35                        void setName(const std::string& name);  //xmlPort-Funktion, sets Namen
36                        const std::string& getName() const;     //xmlPort-Funktion, returns Namen
[11579]37
[11656]38                        void setCurrentQuestionId(const std::string& questionId);       //xmlPort-Funktion, sets string id of current question
39                        const std::string& getCurrentQuestionId() const;        //xmlPort-Funktion, returns id of current question
[11579]40
[11656]41                        void addQuestion(Question* question); //xmlPort-Funktion, adds question to map
42                        const Question* getQuestion() const; //xmlPort-Funktion, returns nullptr
[11579]43
[11656]44                        void addAnswer(Answer* answer); //xmlPort-Funktion, adds answer to map
45                        const Answer* getAnswer(unsigned int index) const; //xmlPort-Funktion, returns nullptr
[11579]46
[11656]47                        /**
48                @brief
49                    returns a pointer to the array of answers belonging to the current question for use in dialogManager
[11579]50
[11656]51                @return
52                    pointer to answerId array of question
53                */
54                        const std::vector<std::string>* getAnswerIds(); 
[11579]55
[11656]56                        /**
57                @brief
58                    function called when the trigger object defined in the xml file sets to triggered
[11579]59
[11656]60                @param bTriggered
61                    needs to be set like this for correctness
62                @param trigger
63                    needs to be set like this for correctness
64                @return
65                        not really used
66                */
67                        bool execute(bool bTriggered, BaseObject* trigger);
[11579]68
[11656]69                        /**
70                @brief
71                    updates the current Dialog according to the id of a given answer, by setting currentQuestionId to the next one
[11644]72
[11656]73                @param givenAnswerId
74                        id of the answer given by player
75                */
76                        void update(const std::string& givenAnswerId);
[11644]77
[11656]78                        /**
79                @brief
80                    tests if there is a next question for the given answerId
81
82                @param givenAnswerId
83                                id of the answer given by player
84                @return
85                        true if there is no more Question to the given answerId
86                */
87                        bool ending(const std::string& givenAnswerId);
88
89                        /**
90                @brief
91                    gives the text of the npc in the current state
92
93                @return
94                        sting with npc text
95                */
96                        const std::string& getQuestionString();
97
98                        /**
99                @brief
100                    returns a sting with the pc answer to the id
101
102                @param answerId
103                        the id of the answer looked for
104                @return
105                        sting with answer
106                */
107                        const std::string& getAnswerString(std::string answerId);
108
[11579]109                private: 
[11656]110                        std::string name_;      //!< name of the npc talking
111                        std::string currentQuestionId_; //!< id of the npc question currently active
112                        std::map<std::string, Question*> questions_;    //!< a map form the ids of npc textoptions to the objects containing them
113                        std::map<std::string, Answer*> answers_;        //!< a map form the ids of npc textoptions to the objects containing them
[11579]114        };
[11607]115}
116
117#endif
Note: See TracBrowser for help on using the repository browser.