Changeset 11435 for code/branches/Dialogue_FS17/src/modules
- Timestamp:
- May 26, 2017, 3:40:04 PM (8 years ago)
- Location:
- code/branches/Dialogue_FS17/src/modules/dialogue
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/Dialogue_FS17/src/modules/dialogue/DialogueManager.cc
r11432 r11435 18 18 19 19 20 //DialogueManager* DialogueManager::singletonPtr_s =nullptr; 21 22 DialogueManager::DialogueManager(){ 23 orxout() << "Dialog Konstruktor" << endl; 24 //RegisterObject(DialogueManager); 25 26 } 20 21 DialogueManager::DialogueManager(){} 27 22 28 23 29 /** 30 * @brief set the config values in the orxonox.ini file 31 */ 24 32 25 33 26 … … 35 28 if(allQuestions.size()==0) { 36 29 orxout(internal_info) << "At least one NextQuestion has to be set." << endl; 37 } else { 38 currentQuestion = allQuestions[0]; 39 } 30 } 40 31 allQuestions.push_back(nq); 41 32 orxout(internal_info) << "qsize " << allQuestions.size(); … … 53 44 54 45 std::string DialogueManager::getquestion(void){ 55 orxout() << question << endl;56 46 return question; 57 47 } 48 58 49 void DialogueManager::setanswers1(std::string a1){ 59 orxout() << "setanswers1" << endl;60 50 this->a1=a1; 61 orxout() << "A1 is " << a1;62 51 } 63 52 … … 69 58 70 59 std::string DialogueManager::getanswers1(void){ 71 orxout() << "getanswers1" << endl;72 60 return a1; 73 61 } … … 76 64 return a2; 77 65 } 66 78 67 void DialogueManager::a1clicked(void){ 79 80 68 81 69 currentQuestion = currentQuestion->possibleQuestions[0]; … … 85 73 } 86 74 void DialogueManager::a2clicked(void){ 87 orxout() << "a2 clicked" << endl; 88 75 89 76 currentQuestion = currentQuestion->possibleQuestions[1]; 90 77 update(currentQuestion); 78 } 91 79 92 93 }94 80 void DialogueManager::update(NextQuestion* nq){ 95 81 this->setquestion(nq->getquestion()); 96 82 this->setanswers1(nq->getanswers1()); 97 83 this->setanswers2(nq->getanswers2()); 98 depth=depth+1;99 100 101 84 } 102 void DialogueManager::clean(){ 103 orxout() <<" depth " << depth << endl; 104 //allQuestions.at(2*depth+1); 105 } 85 106 86 bool DialogueManager::theEnd(){ 107 87 if((currentQuestion->possibleQuestions).empty()) { 108 orxout() << "endtrue" << endl;109 88 return true;} 110 89 else return false; 111 90 } 112 91 113 114 115 /*116 117 118 119 120 121 vector<std::string> DialogueManager::getanswers(void){122 return options;123 }124 125 int DialogueManager::getnumOptions(){126 return options.size();127 }128 129 */130 92 } -
code/branches/Dialogue_FS17/src/modules/dialogue/DialogueManager.h
r11432 r11435 12 12 #include <string> 13 13 #include <vector> 14 //#include "OrxonoxPrereqs.h"15 14 #include "core/config/Configurable.h" 16 15 #include "core/XMLPort.h" … … 32 31 public: 33 32 34 35 33 DialogueManager(); 36 34 … … 38 36 static DialogueManager& getInstance() { return Singleton<DialogueManager>::getInstance(); } //tolua_export 39 37 38 40 39 void setquestion(std::string question); //tolua_export 41 40 std::string getquestion(void); //tolua_export 42 41 43 void registerquestion(NextQuestion* nq);42 44 43 void setanswers1(std::string a1); //tolua_export 44 std::string getanswers1(void); //tolua_export 45 45 46 void setanswers2(std::string a2); //tolua_export 46 std::string getanswers1(void); //tolua_export47 47 std::string getanswers2(void); //tolua_export 48 49 void setCurrentQuestion(NextQuestion* q); 50 51 //Sets the current Question to the question corresponding to the first/second answer 48 52 void a1clicked(void); //tolua_export 49 53 void a2clicked(void); //tolua_export 54 55 //Checks whether there are any more Questions to come 50 56 bool theEnd(); //tolua_export 57 58 //Sets question and a1, a2 for new currentQuestion 51 59 void update(NextQuestion* nq); 52 void clean(); //tolua_export 53 void setCurrentQuestion(NextQuestion* q); 60 61 //Is executed whenever a NextQuestion is created and pushes all NextQuestion into the allQuestion vector. 62 void registerquestion(NextQuestion* nq); 54 63 55 64 private: 56 NextQuestion* currentQuestion; 65 NextQuestion* currentQuestion; //The Question which is currently displayed 57 66 std::vector<NextQuestion*> allQuestions; 58 std::string a1; 59 std::string a2; 67 std::string a1; //answer on first button 68 std::string a2; //answer on second button 60 69 std::string question; 61 int depth = 0;62 70 static DialogueManager* singletonPtr_s; 63 71 -
code/branches/Dialogue_FS17/src/modules/dialogue/NextQuestion.cc
r11433 r11435 17 17 { 18 18 RegisterObject(NextQuestion); 19 orxout() << "Klasse aufgerufen" << endl; 19 20 20 DialogueManager& m = DialogueManager::getInstance(); 21 21 m.registerquestion(this); 22 //possibleQuestions=nullptr;22 23 23 24 24 } … … 29 29 30 30 std::string NextQuestion::getquestion(void){ 31 orxout() << question;32 31 return question; 33 32 } … … 51 50 } 52 51 53 //XML and Event stuff52 54 53 void NextQuestion::XMLPort(Element& xmlelement, XMLPort::Mode mode) 55 54 { … … 64 63 bool NextQuestion::execute(bool bTriggered, BaseObject* trigger) 65 64 { 66 //if(!bTriggered) return false;67 68 65 69 70 71 orxout() << "bTriggered is " << bTriggered << endl; 72 73 //for (DialogueManager* hud : ObjectList<DialogueManager>()) 74 //m = hud; 75 76 DialogueManager& m = DialogueManager::getInstance(); 66 DialogueManager& m = DialogueManager::getInstance(); 77 67 78 68 m.setquestion(question); … … 80 70 m.setanswers1(a1); 81 71 m.setanswers2(a2); 82 orxout() << " 1 " << endl;72 83 73 84 74 … … 114 104 } 115 105 116 std::vector<NextQuestion*> NextQuestion::retposQues(){117 //if(possibleQuestions.size()==0) return NULL;118 106 119 orxout() << "SIZE" << possibleQuestions.size() << endl;120 return possibleQuestions;121 }122 107 123 108 124 /*125 126 }*/127 109 128 110 -
code/branches/Dialogue_FS17/src/modules/dialogue/NextQuestion.h
r11432 r11435 3 3 4 4 5 //#include <vector> 5 6 6 #include <string> 7 7 #include "core/class/Identifier.h" … … 25 25 std::string getquestion(void); 26 26 27 28 bool addposQuestion(NextQuestion* nq);29 const NextQuestion* getposQuestion(unsigned int index) const;30 31 32 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);33 34 27 void setanswers1(std::string a1); 35 28 void setanswers2(std::string a2); … … 37 30 std::string getanswers2(void); 38 31 39 NextQuestion compare();32 40 33 41 34 42 // Event35 //XMLEventPort for Event that first triggers the Dialogue 43 36 virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode); 37 38 //XMLPort for setting questions and answers and the vector possibleQuestions 39 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 40 41 bool addposQuestion(NextQuestion* nq); 42 const NextQuestion* getposQuestion(unsigned int index) const; 43 44 //Sets very first currentQuestion in the DialogueManager when the event is triggered 44 45 bool execute(bool bTriggered, BaseObject* trigger); 45 46 46 47 std::vector<NextQuestion*> possibleQuestions; 47 std::vector<NextQuestion*> retposQues();48 48 49 private: 49 50 std::string a1;
Note: See TracChangeset
for help on using the changeset viewer.