Changeset 11656
- Timestamp:
- Dec 11, 2017, 3:35:50 PM (7 years ago)
- Location:
- code/branches/Dialog_HS17/src/modules/dialog
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/Dialog_HS17/src/modules/dialog/Answer.h
r11644 r11656 10 10 namespace orxonox 11 11 { 12 12 /** 13 @brief 14 class containing the pc side of the Dialog 15 16 this class contains one possible text option of the pc, it's id and the id of the reaction of the npc to this answer 17 */ 18 13 19 class _DialogExport Answer : public BaseObject 14 20 { … … 28 34 29 35 private: 30 std::string answerId_; 31 std::string answer_; 32 std::string nextQuestionId_; 36 std::string answerId_; //!< id of the pc textoption 37 std::string answer_; //!< string with the pc text 38 std::string nextQuestionId_; //!< id of the npc reaction to pc answer 33 39 }; 34 40 } -
code/branches/Dialog_HS17/src/modules/dialog/AnswerId.h
r11644 r11656 9 9 10 10 namespace orxonox{ 11 12 /** 13 @brief 14 container class for answerids in xml 15 16 */ 17 11 18 class AnswerId : public BaseObject 12 19 { … … 20 27 21 28 private: 22 std::string id_; 29 std::string id_; //!< id of one answer 23 30 }; 24 31 } -
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 } -
code/branches/Dialog_HS17/src/modules/dialog/DialogManager.h
r11644 r11656 13 13 14 14 {//tolua_export 15 16 /** 17 @brief 18 this class is used for calling on a dialog form luascript 19 20 the class is the interface of dialog to lua, all lua functionallity is given by this class, it can be found by lua due to singleton definition 21 22 */ 23 15 24 class _OrxonoxExport DialogManager //tolua_export 16 25 : public Singleton<DialogManager> … … 21 30 22 31 DialogManager(); 23 24 //gibt lua den pointer auf den Manager 32 33 /** 34 @brief 35 gives the pointer to the sigleton dialog manager to the lua script 36 37 @return 38 returns pointer 39 */ 40 25 41 static DialogManager& getInstance() { return Singleton<DialogManager>::getInstance(); } //tolua_export 26 42 27 //setzt den momentanen Dialog auf den uebergebenen, wird vom Dialog verwendet um bei Trigger event sich selbst zu setzen 43 /** 44 @brief 45 allows to set the current dialog 46 47 this is used by a dialog when triggered to set its self to the current dialog 48 49 @param dialog 50 pointer to the dialog that wants to be current one 51 */ 28 52 void setDialog(Dialog* dialog); 29 53 30 // von hier an sind lua funktionalitaeten definiert54 //from here on functions for lua interface 31 55 32 //gibt den string der momentanen Frage des Dialogs 56 /** 57 @brief 58 gives the string of the momentary npc textoption 59 60 @return 61 string of npc text 62 */ 33 63 std::string getQuestion(); //tolua_export 34 64 35 //gibt die laenge des Antwort-arrays der momentanen zuruek, 0 falls es leer ist 65 /** 66 @brief 67 function that returns size of answerid array 68 69 @return 70 returns number of possible answers to momentary questions, 0 if there are no player text options 71 */ 36 72 int getSize(); //tolua_export 37 73 38 //gibt den sting zu einer Frage im antwortarray der momentanen Frage 74 /** 75 @brief 76 returns the answer to the id that is at index in the array of answers 77 78 @param param1 79 index of desired answer 80 81 @return 82 string of answer 83 */ 39 84 std::string getAnswer(int index); //tolua_export 40 85 41 //gibt den Namen der Person mit der man spricht 86 /** 87 @brief 88 gives name of npc the player is currently talking to 89 90 @return 91 sting with name 92 */ 42 93 std::string getPerson(); //tolua_export 43 94 44 //testet ob der dialog weiter geht, true wenn es keine weitere Frage nach der Antwort kommt oder keine Antwort zur Frage existiert 95 /** 96 @brief 97 tests the dialog if there are any followup npc textoptions to the given answer or if there are no answers to the current question 98 99 @return 100 true if the answer array of the question is empty or the next question id of the answer does not exist 101 */ 45 102 bool endtest(int index); //tolua_export 46 103 47 //updated den Dialog so dass er auf die Antwort die im Antwortvector am index steht reagiert 104 /** 105 @brief 106 tells the dialog to update according to a given answer, if no answer is actively clicked the standard index is sett 0 in the lua 107 when called the current question of the dialog is set to the new one and the answerId vector is set accordingly 108 109 @param param1 110 index of the answer given by the player 111 112 */ 48 113 void update(int index); //tolua_export 49 114 50 115 private: 51 static DialogManager* singletonPtr_s; 116 static DialogManager* singletonPtr_s; //!< a pointer to the single class object 52 117 53 Dialog* currentTalk_; 54 const std::vector<std::string>* answerIds_; 118 Dialog* currentTalk_; //!< pointer to the currently active dialog or last active if no one is currently active 119 const std::vector<std::string>* answerIds_; //!< pointer to the possible answerIds of the current question, for faster access 55 120 56 121 };//tolua_export -
code/branches/Dialog_HS17/src/modules/dialog/Question.h
r11644 r11656 13 13 namespace orxonox 14 14 { 15 16 /** 17 @brief 18 class containing the npc side of the Dialog 19 20 this class contains one possible text option of the npc, it's id and the ids of possible player reactions (answers) 21 */ 22 15 23 class _DialogExport Question : public BaseObject 16 24 { … … 29 37 const AnswerId* getAnswerId() const; //xmlPort-Funktion, gibt nichts zuruek 30 38 39 /** 40 @brief 41 gives pointer to possivle answerIds of this question 42 43 @return 44 returns pointer to the array with ids of possible pc textoptions 45 */ 31 46 const std::vector<std::string>* getAnswerIds(); //returnt Pointer auf Vektor mit allen Ids 32 47 33 48 34 49 35 private: 36 std::string questionId_; 37 std::string question_; 38 std::vector<std::string> answerIds_; 50 private: 51 std::string questionId_; //!< id of npc textoption 52 std::string question_; //!< string with npc text 53 std::vector<std::string> answerIds_; //!< vector with possible player reactions 39 54 }; 40 55 }
Note: See TracChangeset
for help on using the changeset viewer.