//#include #include #include "core/CoreIncludes.h" #include "core/GUIManager.h" #include "overlays/OrxonoxOverlay.h" #include "NextQuestion.h" #include "core/XMLPort.h" namespace orxonox{ RegisterClass(NextQuestion); NextQuestion::NextQuestion(Context* context) : BaseObject(context) { RegisterObject(NextQuestion); orxout() << "Klasse aufgerufen" << endl; } void NextQuestion::setquestion(std::string question){ this->question=question; } std::string NextQuestion::getquestion(void){ orxout() << question; return question; } bool NextQuestion::addposQuestion(NextQuestion* nq){ possibleQuestions.push_back(nq); return true; } const NextQuestion* NextQuestion::getposQuestion(unsigned int i) const { for (NextQuestion* effect : this->possibleQuestions) { if(i == 0) return effect; i--; } return nullptr; } //XML and Event stuff void NextQuestion::XMLPort(Element& xmlelement, XMLPort::Mode mode) { SUPER(NextQuestion, XMLPort, xmlelement, mode); XMLPortParam(NextQuestion, "question", setquestion, getquestion, xmlelement, mode); XMLPortParam(NextQuestion, "a1", setanswers1, getanswers1, xmlelement, mode); XMLPortParam(NextQuestion, "a2", setanswers2, getanswers2, xmlelement, mode); XMLPortObject(NextQuestion, NextQuestion, "possibleQuestions", addposQuestion, getposQuestion, xmlelement, mode); } bool NextQuestion::execute(bool bTriggered, BaseObject* trigger) { //if(!bTriggered) return false; orxout() << "bTriggered is " << bTriggered << endl; //for (DialogueManager* hud : ObjectList()) //m = hud; DialogueManager& m = DialogueManager::getInstance(); m.setquestion(question); m.setanswers1(a1); m.setanswers2(a2); orxout() << " 1 " << endl; OrxonoxOverlay::showOverlay("Dialogue"); return false; } void NextQuestion::XMLEventPort(Element& xmlelement, XMLPort::Mode mode) { SUPER(NextQuestion, XMLEventPort, xmlelement, mode); XMLPortEventSink(NextQuestion, BaseObject, "execute", execute, xmlelement, mode); } void NextQuestion::setanswers1(std::string a1){ this->a1=a1; } void NextQuestion::setanswers2(std::string a2){ this->a2=a2; } std::string NextQuestion::getanswers1(void){ return a1; } std::string NextQuestion::getanswers2(void){ return a2; } /*NextQuestion NextQuestion::compare(){ DialogueManager& m = DialogueManager::getInstance(); if(m.a1clicked()){ return *possibleQuestions[0]; } else if(m.a2clicked()){ return *possibleQuestions[1]; } }*/ }