Changeset 11642 for code/branches/Dialog_HS17/src/modules
- Timestamp:
- Dec 7, 2017, 9:25:39 AM (7 years ago)
- Location:
- code/branches/Dialog_HS17/src/modules/dialog
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/Dialog_HS17/src/modules/dialog/Dialog.cc
r11612 r11642 24 24 XMLPortParam(Dialog, "name", setName, getName, xmlelement, mode); 25 25 XMLPortParam(Dialog, "currentQuestionId", setCurrentQuestionId, getCurrentQuestionId, xmlelement, mode); 26 XMLPortObject(Dialog, Question, " Questions", addQuestion, getQuestion, xmlelement, mode);27 XMLPortObject(Dialog, Answer, " Answers", addAnswer, getAnswer, xmlelement, mode);26 XMLPortObject(Dialog, Question, "questions", addQuestion, getQuestion, xmlelement, mode); 27 XMLPortObject(Dialog, Answer, "answers", addAnswer, getAnswer, xmlelement, mode); 28 28 } 29 29 … … 79 79 } 80 80 81 std::vector<std::string> Dialog::getAnswers() // returned vector mit allen momentanen AntwortenIds81 std::vector<std::string>* Dialog::getAnswerIds() // returned vector mit allen momentanen AntwortenIds 82 82 { 83 83 84 84 Question* question = (this->questions_.find(this->currentQuestionId_))->second; 85 std::vector<std::string> answers = question->getAnswerIds();85 std::vector<std::string>* answers = question->getAnswerIds(); 86 86 return answers; 87 87 88 } 88 89 … … 90 91 { 91 92 DialogManager& m = DialogManager::getInstance(); 92 m.setDialog(this); 93 orxout() << "dialog executed \n"; 94 OrxonoxOverlay::showOverlay("Dialog"); 95 93 94 if(questions_.count(this->currentQuestionId_)){ 95 m.setDialog(this); 96 OrxonoxOverlay::showOverlay("Dialog"); 97 } 98 else { 99 orxout() << "no start defined " << endl; 100 } 101 96 102 return false; 97 103 } … … 106 112 { 107 113 bool end = false; 108 if (this->currentQuestionId_ == "end"){ 109 end = true; 110 } else if ((this->questions_.find(this->currentQuestionId_)->second)->getAnswerIds().empty()){ 114 if ((this->questions_.find(this->currentQuestionId_)->second)->getAnswerIds()->empty()){ 111 115 end = true; 112 116 } … … 118 122 return this->questions_.find(this->currentQuestionId_)->second->getQuestion(); 119 123 } 124 125 std::string Dialog::getAnswerString(std::string answerId) 126 { 127 return this->answers_.find(answerId)->second->getAnswer(); 128 } 120 129 } -
code/branches/Dialog_HS17/src/modules/dialog/Dialog.h
r11612 r11642 35 35 Question* getQuestion(unsigned int index) const; // // benoetigt fuer xmlPort 36 36 Answer* getAnswer(unsigned int index) const; // benoetigt fuer xmlPort 37 std::vector<std::string> getAnswers(); // returned vector mit allen momentanen AntwortenIds37 std::vector<std::string>* getAnswerIds(); // returned vector mit allen momentanen AntwortenIds 38 38 39 39 bool execute(bool bTriggered, BaseObject* trigger); … … 44 44 45 45 std::string getQuestionString(); //gibt string der momentanen Frage 46 std::string getAnswerString(std::string answerId); //gibt string der zur Id passenden Frage 46 47 47 48 private: -
code/branches/Dialog_HS17/src/modules/dialog/DialogManager.cc
r11612 r11642 16 16 void DialogManager::setDialog(Dialog* dialog) 17 17 { 18 this->currentTalk_ = dialog; 18 this->currentTalk_ = dialog; 19 answerIds_ = currentTalk_->getAnswerIds(); 19 20 } 20 21 … … 26 27 } 27 28 28 /* 29 std::vector<std::string> DialogManager::getAnswers() 29 int DialogManager::getSize() 30 { 31 return 2; //return this->answerIds_->size(); 32 } 33 34 std::string DialogManager::getAnswer(int index) 30 35 { 31 // lua hat komisch arrays (eigentlich tables), wie implementiert man answers so das man nacher den key der gegeben antwort a 32 // hat um ihn fuer update zu benutzen? 36 return this->currentTalk_->getAnswerString(this->answerIds_->at(index)); 33 37 } 34 */ 38 39 std::string DialogManager::getPerson() 40 { 41 return this->currentTalk_->getName(); 42 } 43 44 bool DialogManager::endtest() 45 { 46 return this->currentTalk_->ending(); 47 } 48 49 void DialogManager::update(int index) 50 { 51 this->currentTalk_->update(answerIds_->at(index)); 52 answerIds_ = this->currentTalk_->getAnswerIds(); 53 } 35 54 } -
code/branches/Dialog_HS17/src/modules/dialog/DialogManager.h
r11612 r11642 30 30 31 31 std::string getQuestion(); //tolua_export 32 //std::vector<std::string> getAnswers(); 32 int getSize(); //tolua_export 33 std::string getAnswer(int index); //tolua_export 34 std::string getPerson(); //tolua_export 35 bool endtest(); //tolua_export 36 void update(int index); //tolua_export 33 37 34 38 private: … … 36 40 37 41 Dialog* currentTalk_; 42 std::vector<std::string>* answerIds_; 38 43 39 44 };//tolua_export -
code/branches/Dialog_HS17/src/modules/dialog/Question.cc
r11611 r11642 19 19 XMLPortParam(Question, "Id", setQuestionId, getQuestionId, xmlement, mode); 20 20 21 XMLPortObject(Question, AnswerId, "answer s", addAnswerId, getAnswerId, xmlement, mode);21 XMLPortObject(Question, AnswerId, "answerIds", addAnswerId, getAnswerId, xmlement, mode); 22 22 } 23 23 … … 52 52 } 53 53 54 std::vector<std::string> Question::getAnswerIds()54 std::vector<std::string>* Question::getAnswerIds() 55 55 { 56 return this->answerIds_;56 return &(this->answerIds_); 57 57 } 58 58 -
code/branches/Dialog_HS17/src/modules/dialog/Question.h
r11611 r11642 33 33 // die sowieso gebraucht wird? 34 34 35 std::vector<std::string> getAnswerIds(); //returnt vektor mit allen Ids35 std::vector<std::string>* getAnswerIds(); //returnt vektor mit allen Ids 36 36 37 37
Note: See TracChangeset
for help on using the changeset viewer.