Changeset 11611 for code/branches/Dialog_HS17
- Timestamp:
- Nov 30, 2017, 9:33:27 AM (7 years ago)
- Location:
- code/branches/Dialog_HS17/src/modules/dialog
- Files:
-
- 1 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/Dialog_HS17/src/modules/dialog/Answer.cc
r11607 r11611 1 1 #include "Answer.h" 2 #include "core/CoreIncludes.h" 2 3 3 4 -
code/branches/Dialog_HS17/src/modules/dialog/Answer.h
r11607 r11611 3 3 4 4 #include "core/BaseObject.h" 5 #include "DialogPrereqs.h" 5 6 #include "core/XMLPort.h" 6 7 #include "core/CoreIncludes.h" … … 10 11 { 11 12 12 class Answer : public BaseObject13 class _DialogExport Answer : public BaseObject 13 14 { 14 15 public: 15 16 Answer(Context* context); 16 // virtual ~Answer();17 17 18 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 18 19 -
code/branches/Dialog_HS17/src/modules/dialog/AnswerId.cc
r11607 r11611 1 1 #include "AnswerId.h" 2 #include "core/CoreIncludes.h" 2 3 3 4 … … 10 11 RegisterObject(AnswerId); 11 12 } 13 12 14 void AnswerId::XMLPort(Element& xmlelement, XMLPort::Mode mode) 13 15 { … … 17 19 } 18 20 19 void AnswerId::setId(std::string Id){ 20 this->Id_ = Id; 21 void AnswerId::setId(std::string id) 22 { 23 this->id_ = id; 21 24 } 22 std::string AnswerId::getId(){ 23 return this->Id_; 25 26 std::string AnswerId::getId() 27 { 28 return this->id_; 24 29 } 25 30 } -
code/branches/Dialog_HS17/src/modules/dialog/AnswerId.h
r11607 r11611 13 13 public: 14 14 AnswerId(Context* context); 15 // virtual ~AnswerId();15 16 16 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 17 17 18 19 18 void setId(std::string Id); 19 std::string getId(); 20 20 21 21 private: 22 std::string Id_;22 std::string id_; 23 23 }; 24 24 } -
code/branches/Dialog_HS17/src/modules/dialog/CMakeLists.txt
r11607 r11611 11 11 FIND_HEADER_FILES 12 12 TOLUA_FILES 13 DialogManager.h 13 14 LINK_LIBRARIES 14 15 orxonox -
code/branches/Dialog_HS17/src/modules/dialog/Dialog.cc
r11607 r11611 5 5 #include "Dialog.h" 6 6 #include "Question.h" 7 7 8 8 9 namespace orxonox … … 57 58 void Dialog::addQuestion(Question* question) //fuegt Question der Map hinzu 58 59 { 59 //questions_.emplace(question->getQuestionId(), question->getQuestion());60 this->questions_.insert(make_pair(question->getQuestionId(), question)); 60 61 } 61 62 62 63 void Dialog::addAnswer(Answer* answer) //fuegt Answer der Map hinzu 63 64 { 64 //answers_.emplace(std::make_pair(answer->getAnswerId(), answer->getAnswer()));65 this->answers_.insert(make_pair(answer->getAnswerId(), answer)); 65 66 } 66 67 … … 72 73 } 73 74 74 Answer* Dialog::getAnswer(unsigned int index) const //tolua_export//returned sting der Antwort zur Id.75 Answer* Dialog::getAnswer(unsigned int index) const //returned sting der Antwort zur Id. 75 76 { 76 77 return nullptr; … … 81 82 { 82 83 83 Question question = (questions_.find(this->currentQuestionId_))->second;84 std::vector<std::string> answers = question .getAnswerIds();84 Question* question = (this->questions_.find(this->currentQuestionId_))->second; 85 std::vector<std::string> answers = question->getAnswerIds(); 85 86 return answers; 86 87 } … … 98 99 void Dialog::update(std::string givenAnswer) 99 100 { 100 Answer answer = (answers_.find(givenAnswer))->second;101 this->currentQuestionId_ = answer .getNextQuestion();101 Answer* answer = (answers_.find(givenAnswer))->second; 102 this->currentQuestionId_ = answer->getNextQuestion(); 102 103 } 103 104 104 bool Dialog::ending() // tolua_export //retruned true wenn die Id der Antwort end ist oder keine Antworten auf die frage eingetragen sind105 bool Dialog::ending() //retruned true wenn die Id der Antwort end ist oder keine Antworten auf die frage eingetragen sind 105 106 { 106 107 bool end = false; 107 108 if (this->currentQuestionId_ == "end"){ 108 109 end = true; 109 } else if (( questions_.find(this->currentQuestionId_)->second).getAnswerIds().empty()){110 } else if ((this->questions_.find(this->currentQuestionId_)->second)->getAnswerIds().empty()){ 110 111 end = true; 111 112 } -
code/branches/Dialog_HS17/src/modules/dialog/Dialog.h
r11607 r11611 3 3 4 4 #include "core/BaseObject.h" 5 #include "DialogPrereqs.h" 5 6 #include "Question.h" 6 7 #include "Answer.h" … … 9 10 #include "overlays/OrxonoxOverlay.h" 10 11 12 #include <map> 13 #include <vector> 11 14 #include <string> 12 15 13 16 namespace orxonox 14 17 { 15 class Dialog : public BaseObject18 class _DialogExport Dialog : public BaseObject 16 19 { 17 20 public: 18 21 Dialog(Context* context); 19 // virtual ~Dialog(); 22 20 23 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 21 24 virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode); … … 30 33 void addAnswer(Answer* answer); //fuegt Answer der Map hinzu 31 34 32 Question* getQuestion(unsigned int index) const; // tolua_export //returned string der momentanen Frage33 Answer* getAnswer(unsigned int index) const; // tolua_export //returned string der momentanen Frage34 std::vector<std::string> getAnswers(); //tolua_export// returned vector mit allen momentanen AntwortenIds35 Question* getQuestion(unsigned int index) const; // returned string der momentanen Frage 36 Answer* getAnswer(unsigned int index) const; // returned string der momentanen Frage 37 std::vector<std::string> getAnswers(); // returned vector mit allen momentanen AntwortenIds 35 38 36 39 bool execute(bool bTriggered, BaseObject* trigger); 37 40 38 void update(std::string givenAnswer); //tolua_export41 void update(std::string givenAnswer); 39 42 40 bool ending(); // tolua_export //retruned true wenn die Id der Antwort end ist oder keine Antworten auf die frage eingetragen sind43 bool ending(); //retruned true wenn die Id der Antwort end ist oder keine Antworten auf die frage eingetragen sind 41 44 42 45 … … 44 47 std::string name_; 45 48 std::string currentQuestionId_; 46 std::map<std::string, Question > questions_;47 std::map<std::string, Answer > answers_;49 std::map<std::string, Question*> questions_; 50 std::map<std::string, Answer*> answers_; 48 51 }; 49 52 } -
code/branches/Dialog_HS17/src/modules/dialog/DialogManager.cc
r11607 r11611 38 38 } 39 39 } 40 /*#include "core/CoreIncludes.h"41 #include "core/LuaState.h"42 #include "core/GUIManager.h"43 #include "core/class/Identifier.h"44 #include "core/singleton/ScopedSingletonIncludes.h"45 #include "network/Host.h"46 #include "network/NetworkFunctionIncludes.h"47 #include "DialogManager.h"48 #include <vector>49 #include <string>50 #include "core/XMLPort.h"51 #include "Dialog.h"52 53 54 55 namespace orxonox {56 57 ManageScopedSingleton(DialogManager, ScopeID::ROOT, false);58 59 60 DialogManager::DialogManager()61 {62 this->currentTalk_ = NULL;63 }64 65 void DialogManager::setDialog(Dialog* dialog)66 {67 this->currentTalk_ = dialog;68 }69 70 const Dialog& getCurrentDialog()71 {72 return this->currentTalk_;73 }74 75 bool DialogManager::empty()76 {77 if(this->currentTalk_ == NULL)78 {79 return true;80 }81 else82 {83 return false;84 }85 }86 } */ -
code/branches/Dialog_HS17/src/modules/dialog/DialogManager.h
r11607 r11611 1 /*2 1 #ifndef _DialogManager_H__ 3 2 #define _DialogManager_H__ 4 3 5 #include "core/CoreIncludes.h" 6 #include "core/LuaState.h" 7 #include "core/GUIManager.h" 8 #include "core/class/Identifier.h" 9 #include "core/singleton/ScopedSingletonIncludes.h" 10 #include "network/Host.h" 11 #include "network/NetworkFunctionIncludes.h" 12 #include "util/Singleton.h" 13 #include <string> 14 #include <vector> 15 #include "core/config/Configurable.h" 16 #include "core/XMLPort.h" 17 #include "core/EventIncludes.h" 18 #include "Dialog.h" 19 20 21 22 23 24 namespace orxonox //tolua_export 25 26 {//tolua_export 27 class _OrxonoxExport DialogManager //tolua_export 28 : public Singleton<DialogManager> 29 {//tolua_export 30 friend class Singleton<DialogManager>; 31 32 public: 33 34 DialogManager(); 35 36 37 static DialogManager& getInstance() { return Singleton<DialogManager>::getInstance(); } //tolua_export 38 39 40 void setDialog(Dialog* dialog); //tolua_export // the triggered dialog sets it self so the lua can get to it. 41 const Dialog& getCurrentDialog(); //tolua_export 42 bool empty(); //tolua_export //returns true if no dialog is set. 43 44 private: 45 Dialog* currentTalk_; //Dialog which is currently set. 46 static DialogManager* singletonPtr_s; 47 48 };//tolua_export 49 }//tolua_export 50 #endif 51 */ 52 53 #ifndef _DialogManager_H__ 54 #define _DialogManager_H__ 55 4 #include "DialogPrereqs.h" 56 5 #include "util/Singleton.h" 57 6 #include "core/object/Listable.h" … … 60 9 namespace orxonox 61 10 { 62 class DialogManager : public Singleton<DialogManager>, public Listable11 class _DialogExport DialogManager : public Singleton<DialogManager>, public Listable 63 12 { 64 13 friend class Singleton<DialogManager>; … … 67 16 DialogManager(); 68 17 69 int getValue() const 70 { return this->value_; } 18 // int getValue() const { return this->value_; } 71 19 72 static DialogManager& getInstance() { return Singleton<DialogManager>::getInstance(); } 20 static DialogManager& getInstance() { return Singleton<DialogManager>::getInstance(); } //toloa_export 73 21 74 22 void setDialog(Dialog* dialog); … … 76 24 bool empty(); 77 25 26 //form here on all lua functionality used in lua scrips is declared 27 28 78 29 private: 79 30 Dialog* currentTalk_; 80 int value_;31 //int value_; 81 32 82 33 static DialogManager* singletonPtr_s; -
code/branches/Dialog_HS17/src/modules/dialog/Question.cc
r11607 r11611 1 1 #include "Question.h" 2 2 #include "core/CoreIncludes.h" 3 3 4 4 namespace orxonox -
code/branches/Dialog_HS17/src/modules/dialog/Question.h
r11607 r11611 3 3 4 4 #include "core/BaseObject.h" 5 #include "DialogPrereqs.h" 5 6 #include "AnswerId.h" 6 7 #include "core/XMLPort.h" 7 8 #include "core/CoreIncludes.h" 9 8 10 9 11 #include <string> … … 11 13 namespace orxonox 12 14 { 13 class Question : public BaseObject15 class _DialogExport Question : public BaseObject 14 16 { 15 17 public: 16 18 Question(Context* context); 17 // virtual ~Question(); 19 18 20 virtual void XMLPort(Element& xmelement, XMLPort::Mode mode); 19 21
Note: See TracChangeset
for help on using the changeset viewer.