Changeset 11656 for code/branches/Dialog_HS17/src/modules/dialog/Dialog.h
- Timestamp:
- Dec 11, 2017, 3:35:50 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/Dialog_HS17/src/modules/dialog/Dialog.h
r11644 r11656 16 16 namespace orxonox 17 17 { 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 18 27 class _DialogExport Dialog : public BaseObject 19 28 { … … 24 33 virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode); 25 34 26 void setName(const std::string& name); //xmlPort-Funktion, set ztNamen27 const std::string& getName() const; //xmlPort-Funktion, return tNamen35 void setName(const std::string& name); //xmlPort-Funktion, sets Namen 36 const std::string& getName() const; //xmlPort-Funktion, returns Namen 28 37 29 void setCurrentQuestionId(const std::string& questionId); //xmlPort-Funktion, set zt string Id der momentanen Frage30 const std::string& getCurrentQuestionId() const; //xmlPort-Funktion, gibt Id der momentanen Frage38 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 31 40 32 void addQuestion(Question* question); //xmlPort-Funktion, fuegt Question der Map hinzu33 const Question* getQuestion() const; //xmlPort-Funktion, return tnullptr41 void addQuestion(Question* question); //xmlPort-Funktion, adds question to map 42 const Question* getQuestion() const; //xmlPort-Funktion, returns nullptr 34 43 35 void addAnswer(Answer* answer); //xmlPort-Funktion, fuegt Answer der Map hinzu36 const Answer* getAnswer(unsigned int index) const; //xmlPort-Funktion, return tnullptr44 void addAnswer(Answer* answer); //xmlPort-Funktion, adds answer to map 45 const Answer* getAnswer(unsigned int index) const; //xmlPort-Funktion, returns nullptr 37 46 47 /** 48 @brief 49 returns a pointer to the array of answers belonging to the current question for use in dialogManager 38 50 39 const std::vector<std::string>* getAnswerIds(); // returned Pointer auf Vector mit allen momentanen AntwortenIds 51 @return 52 pointer to answerId array of question 53 */ 54 const std::vector<std::string>* getAnswerIds(); 40 55 41 bool execute(bool bTriggered, BaseObject* trigger); // funktion die aufgerufen wird wenn der im xml verbundene Trigger aktiviert wird 56 /** 57 @brief 58 function called when the trigger object defined in the xml file sets to triggered 42 59 43 void update(const std::string& givenAnswerId); //setzt die naechste Frage entsprechend der gegebenen antwortId 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); 44 68 45 bool ending(const std::string& givenAnswerId); //ist true falls fuer die gegebene AntwortId keine Frage zur FragenId der Antwort existiert 69 /** 70 @brief 71 updates the current Dialog according to the id of a given answer, by setting currentQuestionId to the next one 46 72 47 const std::string& getQuestionString(); //gibt string der momentanen Frage 48 const std::string& getAnswerString(std::string answerId); //gibt string der zur Id passenden Frage 73 @param givenAnswerId 74 id of the answer given by player 75 */ 76 void update(const std::string& givenAnswerId); 77 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); 49 108 50 109 private: 51 std::string name_; 52 std::string currentQuestionId_; 53 std::map<std::string, Question*> questions_; 54 std::map<std::string, Answer*> answers_; 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 55 114 }; 56 115 }
Note: See TracChangeset
for help on using the changeset viewer.