- Timestamp:
- Feb 20, 2018, 12:09:09 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/Presentation_HS17_merge/src/modules/dialog/Dialog.h
r11781 r11782 44 44 namespace orxonox 45 45 { 46 47 46 /** 47 @brief 48 48 class containing core of one dialog with one npc 49 49 … … 51 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 52 can be commanded to go to the next state according to a given answer 53 53 */ 54 54 55 56 57 58 55 class _DialogExport Dialog : public BaseObject 56 { 57 public: 58 Dialog(Context* context); 59 59 60 61 60 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 61 virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode); 62 62 63 void setName(const std::string& name);//xmlPort-Funktion, sets Namen64 const std::string& getName() const;//xmlPort-Funktion, returns Namen63 void setName(const std::string& name); //xmlPort-Funktion, sets Namen 64 const std::string& getName() const; //xmlPort-Funktion, returns Namen 65 65 66 void setCurrentQuestionId(const std::string& questionId);//xmlPort-Funktion, sets string id of current question67 const std::string& getCurrentQuestionId() const;//xmlPort-Funktion, returns id of current question66 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 68 69 70 69 void addQuestion(Question* question); //xmlPort-Funktion, adds question to map 70 Question* getQuestion(unsigned int index) const; //xmlPort-Funktion 71 71 72 73 72 void addAnswer(Answer* answer); //xmlPort-Funktion, adds answer to map 73 Answer* getAnswer(unsigned int index) const; //xmlPort-Funktion 74 74 75 76 77 75 /** 76 @brief 77 returns a pointer to the array of answers belonging to the current question for use in dialogManager 78 78 79 80 81 82 79 @return 80 pointer to answerId array of question 81 */ 82 const std::vector<std::string>& getAnswerIds() const; 83 83 84 85 86 84 /** 85 @brief 86 function called when the trigger object defined in the xml file sets to triggered 87 87 88 89 90 91 92 93 94 95 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 96 97 98 99 97 /** 98 @brief 99 updates the current Dialog according to the id of a given answer, by setting currentQuestionId to the next one 100 100 101 102 103 104 101 @param givenAnswerId 102 id of the answer given by player 103 */ 104 void update(const std::string& givenAnswerId); 105 105 106 107 108 106 /** 107 @brief 108 tests if there is a next question for the given answerId 109 109 110 111 112 113 114 115 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 116 117 118 119 117 /** 118 @brief 119 gives the text of the npc in the current state 120 120 121 122 123 124 121 @return 122 sting with npc text 123 */ 124 const std::string& getQuestionString(); 125 125 126 127 128 returns a sting with the pc answer to the id 126 /** 127 @brief 128 returns a sting with the pc answer to the id 129 129 130 131 132 133 134 135 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 136 137 private: 138 std::string name_;//!< name of the npc talking139 std::string currentQuestionId_;//!< id of the npc question currently active140 std::map<std::string, Question*> questions_;//!< a map form the ids of npc textoptions to the objects containing them141 std::map<std::string, Answer*> answers_;//!< a map form the ids of npc textoptions to the objects containing them142 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 143 } 144 144
Note: See TracChangeset
for help on using the changeset viewer.