[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 | |
---|
[11718] | 14 | RegisterClass(NextQuestion); |
---|
[11393] | 15 | |
---|
[11718] | 16 | NextQuestion::NextQuestion(Context* context) : BaseObject(context) |
---|
[11401] | 17 | { |
---|
| 18 | RegisterObject(NextQuestion); |
---|
[11435] | 19 | |
---|
[11417] | 20 | DialogueManager& m = DialogueManager::getInstance(); |
---|
| 21 | m.registerquestion(this); |
---|
[11435] | 22 | |
---|
[11406] | 23 | |
---|
[11401] | 24 | } |
---|
| 25 | |
---|
[11718] | 26 | void NextQuestion::setquestion(std::string question){ |
---|
| 27 | this->question=question; |
---|
| 28 | } |
---|
[11401] | 29 | |
---|
[11718] | 30 | std::string NextQuestion::getquestion(void){ |
---|
| 31 | return question; |
---|
| 32 | } |
---|
[11401] | 33 | |
---|
| 34 | |
---|
[11718] | 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 |
---|
[11413] | 42 | { |
---|
| 43 | for (NextQuestion* effect : this->possibleQuestions) |
---|
| 44 | { |
---|
| 45 | if(i == 0) |
---|
| 46 | return effect; |
---|
| 47 | i--; |
---|
| 48 | } |
---|
[11421] | 49 | return nullptr; |
---|
| 50 | } |
---|
[11718] | 51 | |
---|
| 52 | |
---|
| 53 | void NextQuestion::XMLPort(Element& xmlelement, XMLPort::Mode mode) |
---|
[11401] | 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 | } |
---|
[11718] | 63 | bool NextQuestion::execute(bool bTriggered, BaseObject* trigger) |
---|
[11401] | 64 | { |
---|
| 65 | |
---|
[11718] | 66 | DialogueManager& m = DialogueManager::getInstance(); |
---|
| 67 | |
---|
[11406] | 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 | |
---|
[11718] | 88 | void NextQuestion::setanswers1(std::string a1){ |
---|
| 89 | this->a1=a1; |
---|
| 90 | } |
---|
[11413] | 91 | |
---|
[11718] | 92 | void NextQuestion::setanswers2(std::string a2){ |
---|
| 93 | this->a2=a2; |
---|
| 94 | } |
---|
[11413] | 95 | |
---|
| 96 | |
---|
[11393] | 97 | |
---|
[11718] | 98 | std::string NextQuestion::getanswers1(void){ |
---|
| 99 | return a1; |
---|
| 100 | } |
---|
[11393] | 101 | |
---|
[11718] | 102 | std::string NextQuestion::getanswers2(void){ |
---|
| 103 | return a2; |
---|
| 104 | } |
---|
[11415] | 105 | |
---|
[11718] | 106 | } |
---|