[11413] | 1 | //#include <vector> |
---|
[11393] | 2 | #include <string> |
---|
[11401] | 3 | #include "core/CoreIncludes.h" |
---|
| 4 | #include "core/GUIManager.h" |
---|
[11406] | 5 | #include "overlays/OrxonoxOverlay.h" |
---|
[11393] | 6 | |
---|
[11401] | 7 | |
---|
[11393] | 8 | #include "NextQuestion.h" |
---|
| 9 | #include "core/XMLPort.h" |
---|
[11417] | 10 | #include "DialogueManager.h" |
---|
[11393] | 11 | |
---|
| 12 | namespace orxonox{ |
---|
| 13 | |
---|
| 14 | RegisterClass(NextQuestion); |
---|
| 15 | |
---|
[11401] | 16 | NextQuestion::NextQuestion(Context* context) : BaseObject(context) |
---|
| 17 | { |
---|
| 18 | RegisterObject(NextQuestion); |
---|
[11435] | 19 | |
---|
[11417] | 20 | DialogueManager& m = DialogueManager::getInstance(); |
---|
| 21 | m.registerquestion(this); |
---|
[11435] | 22 | |
---|
[11406] | 23 | |
---|
[11401] | 24 | } |
---|
| 25 | |
---|
| 26 | void NextQuestion::setquestion(std::string question){ |
---|
[11406] | 27 | this->question=question; |
---|
[11401] | 28 | } |
---|
| 29 | |
---|
| 30 | std::string NextQuestion::getquestion(void){ |
---|
| 31 | return question; |
---|
| 32 | } |
---|
| 33 | |
---|
| 34 | |
---|
[11413] | 35 | bool NextQuestion::addposQuestion(NextQuestion* nq){ |
---|
| 36 | |
---|
| 37 | possibleQuestions.push_back(nq); |
---|
| 38 | return true; |
---|
| 39 | } |
---|
[11401] | 40 | |
---|
[11413] | 41 | const NextQuestion* NextQuestion::getposQuestion(unsigned int i) const |
---|
| 42 | { |
---|
| 43 | for (NextQuestion* effect : this->possibleQuestions) |
---|
| 44 | { |
---|
| 45 | if(i == 0) |
---|
| 46 | return effect; |
---|
| 47 | i--; |
---|
| 48 | } |
---|
[11421] | 49 | return nullptr; |
---|
| 50 | } |
---|
[11401] | 51 | |
---|
[11435] | 52 | |
---|
[11401] | 53 | void NextQuestion::XMLPort(Element& xmlelement, XMLPort::Mode mode) |
---|
| 54 | { |
---|
| 55 | SUPER(NextQuestion, XMLPort, xmlelement, mode); |
---|
| 56 | |
---|
| 57 | XMLPortParam(NextQuestion, "question", setquestion, getquestion, xmlelement, mode); |
---|
[11413] | 58 | XMLPortParam(NextQuestion, "a1", setanswers1, getanswers1, xmlelement, mode); |
---|
| 59 | XMLPortParam(NextQuestion, "a2", setanswers2, getanswers2, xmlelement, mode); |
---|
| 60 | XMLPortObject(NextQuestion, NextQuestion, "possibleQuestions", addposQuestion, getposQuestion, xmlelement, mode); |
---|
| 61 | |
---|
[11401] | 62 | } |
---|
| 63 | bool NextQuestion::execute(bool bTriggered, BaseObject* trigger) |
---|
| 64 | { |
---|
| 65 | |
---|
[11435] | 66 | DialogueManager& m = DialogueManager::getInstance(); |
---|
[11406] | 67 | |
---|
| 68 | m.setquestion(question); |
---|
[11432] | 69 | m.setCurrentQuestion(this); |
---|
[11413] | 70 | m.setanswers1(a1); |
---|
| 71 | m.setanswers2(a2); |
---|
[11435] | 72 | |
---|
[11406] | 73 | |
---|
| 74 | |
---|
| 75 | OrxonoxOverlay::showOverlay("Dialogue"); |
---|
| 76 | |
---|
[11401] | 77 | return false; |
---|
| 78 | } |
---|
| 79 | |
---|
| 80 | void NextQuestion::XMLEventPort(Element& xmlelement, XMLPort::Mode mode) |
---|
| 81 | { |
---|
| 82 | SUPER(NextQuestion, XMLEventPort, xmlelement, mode); |
---|
| 83 | |
---|
| 84 | XMLPortEventSink(NextQuestion, BaseObject, "execute", execute, xmlelement, mode); |
---|
| 85 | } |
---|
[11413] | 86 | |
---|
| 87 | |
---|
| 88 | void NextQuestion::setanswers1(std::string a1){ |
---|
| 89 | this->a1=a1; |
---|
| 90 | } |
---|
| 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; |
---|
[11393] | 100 | } |
---|
| 101 | |
---|
[11413] | 102 | std::string NextQuestion::getanswers2(void){ |
---|
| 103 | return a2; |
---|
[11393] | 104 | } |
---|
| 105 | |
---|
[11428] | 106 | |
---|
[11415] | 107 | |
---|
[11393] | 108 | |
---|
[11421] | 109 | |
---|
[11413] | 110 | |
---|
[11393] | 111 | } |
---|