Changeset 11718 for code/trunk/src/modules
- Timestamp:
- Jan 7, 2018, 10:34:30 PM (7 years ago)
- Location:
- code/trunk/src/modules
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/modules/dialogue/DialogueManager.cc
r11435 r11718 15 15 16 16 namespace orxonox { 17 ManageScopedSingleton(DialogueManager, ScopeID::ROOT, false); 18 17 ManageScopedSingleton(DialogueManager, ScopeID::ROOT, false); 18 19 DialogueManager::DialogueManager(){} 19 20 20 21 DialogueManager::DialogueManager(){} 22 21 void DialogueManager::registerquestion(NextQuestion* nq){ 22 if(allQuestions.size()==0) { 23 orxout(internal_info) << "At least one NextQuestion has to be set." << endl; 24 } 25 allQuestions.push_back(nq); 26 orxout(internal_info) << "qsize " << allQuestions.size(); 23 27 24 25 26 27 void DialogueManager::registerquestion(NextQuestion* nq){ 28 if(allQuestions.size()==0) { 29 orxout(internal_info) << "At least one NextQuestion has to be set." << endl; 30 } 31 allQuestions.push_back(nq); 32 orxout(internal_info) << "qsize " << allQuestions.size(); 33 34 } 28 } 35 29 36 30 void DialogueManager::setquestion(std::string q){ 37 question=q; 38 39 } 40 void DialogueManager::setCurrentQuestion(NextQuestion* nq){ 41 currentQuestion=nq; 42 43 } 31 question=q; 44 32 45 std::string DialogueManager::getquestion(void){ 46 return question; 47 } 33 } 34 void DialogueManager::setCurrentQuestion(NextQuestion* nq){ 35 currentQuestion=nq; 48 36 49 void DialogueManager::setanswers1(std::string a1){ 50 this->a1=a1; 51 } 37 } 52 38 53 void DialogueManager::setanswers2(std::string a2){54 this->a2=a2;55 39 std::string DialogueManager::getquestion(void){ 40 return question; 41 } 56 42 57 43 void DialogueManager::setanswers1(std::string a1){ 44 this->a1=a1; 45 } 58 46 59 std::string DialogueManager::getanswers1(void){60 return a1;61 47 void DialogueManager::setanswers2(std::string a2){ 48 this->a2=a2; 49 } 62 50 63 std::string DialogueManager::getanswers2(void){64 return a2;65 }66 51 67 void DialogueManager::a1clicked(void){68 69 currentQuestion = currentQuestion->possibleQuestions[0];70 update(currentQuestion);71 52 72 73 } 74 void DialogueManager::a2clicked(void){ 75 76 currentQuestion = currentQuestion->possibleQuestions[1]; 77 update(currentQuestion); 78 } 53 std::string DialogueManager::getanswers1(void){ 54 return a1; 55 } 79 56 80 void DialogueManager::update(NextQuestion* nq){ 81 this->setquestion(nq->getquestion()); 82 this->setanswers1(nq->getanswers1()); 83 this->setanswers2(nq->getanswers2()); 84 } 57 std::string DialogueManager::getanswers2(void){ 58 return a2; 59 } 85 60 86 bool DialogueManager::theEnd(){ 87 if((currentQuestion->possibleQuestions).empty()) { 88 return true;} 89 else return false; 90 } 61 void DialogueManager::a1clicked(void){ 62 63 currentQuestion = currentQuestion->possibleQuestions[0]; 64 update(currentQuestion); 65 66 67 } 68 void DialogueManager::a2clicked(void){ 69 70 currentQuestion = currentQuestion->possibleQuestions[1]; 71 update(currentQuestion); 72 } 73 74 void DialogueManager::update(NextQuestion* nq){ 75 this->setquestion(nq->getquestion()); 76 this->setanswers1(nq->getanswers1()); 77 this->setanswers2(nq->getanswers2()); 78 } 79 80 bool DialogueManager::theEnd(){ 81 if((currentQuestion->possibleQuestions).empty()) 82 return true; 83 else 84 return false; 85 } 91 86 92 87 } -
code/trunk/src/modules/dialogue/DialogueManager.h
r11699 r11718 24 24 25 25 {//tolua_export 26 class _DialogueExport DialogueManager //tolua_export 27 : public Singleton<DialogueManager> 28 {//tolua_export 29 friend class Singleton<DialogueManager>; 30 31 public: 32 33 DialogueManager(); 34 26 class _DialogueExport DialogueManager //tolua_export 27 : public Singleton<DialogueManager> 28 {//tolua_export 29 friend class Singleton<DialogueManager>; 35 30 36 static DialogueManager& getInstance() { return Singleton<DialogueManager>::getInstance(); } //tolua_export 37 31 public: 38 32 39 void setquestion(std::string question); //tolua_export 40 std::string getquestion(void); //tolua_export 41 42 43 void setanswers1(std::string a1); //tolua_export 44 std::string getanswers1(void); //tolua_export 45 46 void setanswers2(std::string a2); //tolua_export 47 std::string getanswers2(void); //tolua_export 48 49 void setCurrentQuestion(NextQuestion* q); 33 DialogueManager(); 50 34 51 //Sets the current Question to the question corresponding to the first/second answer52 void a1clicked(void); //tolua_export53 void a2clicked(void); //tolua_export54 55 //Checks whether there are any more Questions to come56 bool theEnd(); //tolua_export57 35 58 //Sets question and a1, a2 for new currentQuestion 59 void update(NextQuestion* nq); 36 static DialogueManager& getInstance() { return Singleton<DialogueManager>::getInstance(); } //tolua_export 60 37 61 //Is executed whenever a NextQuestion is created and pushes all NextQuestion into the allQuestion vector. 62 void registerquestion(NextQuestion* nq); 38 39 void setquestion(std::string question); //tolua_export 40 std::string getquestion(void); //tolua_export 41 42 43 void setanswers1(std::string a1); //tolua_export 44 std::string getanswers1(void); //tolua_export 45 46 void setanswers2(std::string a2); //tolua_export 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 52 void a1clicked(void); //tolua_export 53 void a2clicked(void); //tolua_export 54 55 //Checks whether there are any more Questions to come 56 bool theEnd(); //tolua_export 57 58 //Sets question and a1, a2 for new currentQuestion 59 void update(NextQuestion* nq); 60 61 //Is executed whenever a NextQuestion is created and pushes all NextQuestion into the allQuestion vector. 62 void registerquestion(NextQuestion* nq); 63 63 64 64 private: 65 66 67 68 69 70 65 NextQuestion* currentQuestion; //The Question which is currently displayed 66 std::vector<NextQuestion*> allQuestions; 67 std::string a1; //answer on first button 68 std::string a2; //answer on second button 69 std::string question; 70 static DialogueManager* singletonPtr_s; 71 71 72 72 };//tolua_export 73 73 }//tolua_export 74 74 #endif -
code/trunk/src/modules/dialogue/NextQuestion.cc
r11435 r11718 12 12 namespace orxonox{ 13 13 14 14 RegisterClass(NextQuestion); 15 15 16 16 NextQuestion::NextQuestion(Context* context) : BaseObject(context) 17 17 { 18 18 RegisterObject(NextQuestion); … … 24 24 } 25 25 26 27 28 26 void NextQuestion::setquestion(std::string question){ 27 this->question=question; 28 } 29 29 30 31 32 30 std::string NextQuestion::getquestion(void){ 31 return question; 32 } 33 33 34 35 bool NextQuestion::addposQuestion(NextQuestion* nq){36 37 possibleQuestions.push_back(nq);38 return true;39 }40 34 41 const NextQuestion* NextQuestion::getposQuestion(unsigned int i) const 35 bool NextQuestion::addposQuestion(NextQuestion* nq){ 36 37 possibleQuestions.push_back(nq); 38 return true; 39 } 40 41 const NextQuestion* NextQuestion::getposQuestion(unsigned int i) const 42 42 { 43 43 for (NextQuestion* effect : this->possibleQuestions) … … 49 49 return nullptr; 50 50 } 51 52 53 51 52 53 void NextQuestion::XMLPort(Element& xmlelement, XMLPort::Mode mode) 54 54 { 55 55 SUPER(NextQuestion, XMLPort, xmlelement, mode); … … 61 61 62 62 } 63 63 bool NextQuestion::execute(bool bTriggered, BaseObject* trigger) 64 64 { 65 65 66 67 66 DialogueManager& m = DialogueManager::getInstance(); 67 68 68 m.setquestion(question); 69 69 m.setCurrentQuestion(this); … … 86 86 87 87 88 89 90 88 void NextQuestion::setanswers1(std::string a1){ 89 this->a1=a1; 90 } 91 91 92 void NextQuestion::setanswers2(std::string a2){ 93 this->a2=a2; 94 } 95 96 97 98 std::string NextQuestion::getanswers1(void){ 99 return a1; 100 } 101 102 std::string NextQuestion::getanswers2(void){ 103 return a2; 104 } 105 106 92 void NextQuestion::setanswers2(std::string a2){ 93 this->a2=a2; 94 } 107 95 108 96 109 97 98 std::string NextQuestion::getanswers1(void){ 99 return a1; 100 } 101 102 std::string NextQuestion::getanswers2(void){ 103 return a2; 104 } 110 105 111 106 } -
code/trunk/src/modules/dialogue/NextQuestion.h
r11699 r11718 13 13 14 14 namespace orxonox{ 15 class _DialogueExport NextQuestion : public BaseObject 16 { 17 18 //tolua_begin 19 public: 15 class _DialogueExport NextQuestion : public BaseObject 16 { 20 17 21 NextQuestion (Context* context); // tolua_export 22 18 //tolua_begin 19 public: 23 20 24 void setquestion(std::string question); 25 std::string getquestion(void); 26 27 void setanswers1(std::string a1); 28 void setanswers2(std::string a2); 29 std::string getanswers1(void); 30 std::string getanswers2(void); 31 32 33 34 35 //XMLEventPort for Event that first triggers the Dialogue 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 45 bool execute(bool bTriggered, BaseObject* trigger); 46 47 std::vector<NextQuestion*> possibleQuestions; 48 49 private: 50 std::string a1; 51 std::string a2; 52 21 NextQuestion (Context* context); // tolua_export 53 22 54 23 55 std::string question;56 DialogueManager* m;24 void setquestion(std::string question); 25 std::string getquestion(void); 57 26 58 }; 59 27 void setanswers1(std::string a1); 28 void setanswers2(std::string a2); 29 std::string getanswers1(void); 30 std::string getanswers2(void); 31 32 33 34 35 //XMLEventPort for Event that first triggers the Dialogue 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 45 bool execute(bool bTriggered, BaseObject* trigger); 46 47 std::vector<NextQuestion*> possibleQuestions; 48 49 private: 50 std::string a1; 51 std::string a2; 52 53 54 55 std::string question; 56 DialogueManager* m; 57 58 }; 59 60 60 } 61 61 #endif -
code/trunk/src/modules/gametypes/SpaceRaceBot.h
r11358 r11718 39 39 { 40 40 public: 41 41 SpaceRaceBot(Context* context); 42 42 virtual ~SpaceRaceBot(); 43 43
Note: See TracChangeset
for help on using the changeset viewer.