1 | //#include <vector> |
---|
2 | #include <string> |
---|
3 | #include "core/CoreIncludes.h" |
---|
4 | #include "core/GUIManager.h" |
---|
5 | #include "overlays/OrxonoxOverlay.h" |
---|
6 | |
---|
7 | |
---|
8 | #include "NextQuestion.h" |
---|
9 | #include "core/XMLPort.h" |
---|
10 | |
---|
11 | namespace orxonox{ |
---|
12 | |
---|
13 | RegisterClass(NextQuestion); |
---|
14 | |
---|
15 | NextQuestion::NextQuestion(Context* context) : BaseObject(context) |
---|
16 | { |
---|
17 | RegisterObject(NextQuestion); |
---|
18 | orxout() << "Klasse aufgerufen" << endl; |
---|
19 | |
---|
20 | |
---|
21 | } |
---|
22 | |
---|
23 | void NextQuestion::setquestion(std::string question){ |
---|
24 | this->question=question; |
---|
25 | } |
---|
26 | |
---|
27 | std::string NextQuestion::getquestion(void){ |
---|
28 | orxout() << question; |
---|
29 | return question; |
---|
30 | } |
---|
31 | |
---|
32 | |
---|
33 | bool NextQuestion::addposQuestion(NextQuestion* nq){ |
---|
34 | |
---|
35 | possibleQuestions.push_back(nq); |
---|
36 | return true; |
---|
37 | } |
---|
38 | |
---|
39 | const NextQuestion* NextQuestion::getposQuestion(unsigned int i) const |
---|
40 | { |
---|
41 | for (NextQuestion* effect : this->possibleQuestions) |
---|
42 | { |
---|
43 | if(i == 0) |
---|
44 | return effect; |
---|
45 | i--; |
---|
46 | } |
---|
47 | return nullptr; } |
---|
48 | |
---|
49 | //XML and Event stuff |
---|
50 | void NextQuestion::XMLPort(Element& xmlelement, XMLPort::Mode mode) |
---|
51 | { |
---|
52 | SUPER(NextQuestion, XMLPort, xmlelement, mode); |
---|
53 | |
---|
54 | XMLPortParam(NextQuestion, "question", setquestion, getquestion, xmlelement, mode); |
---|
55 | XMLPortParam(NextQuestion, "a1", setanswers1, getanswers1, xmlelement, mode); |
---|
56 | XMLPortParam(NextQuestion, "a2", setanswers2, getanswers2, xmlelement, mode); |
---|
57 | XMLPortObject(NextQuestion, NextQuestion, "possibleQuestions", addposQuestion, getposQuestion, xmlelement, mode); |
---|
58 | |
---|
59 | } |
---|
60 | bool NextQuestion::execute(bool bTriggered, BaseObject* trigger) |
---|
61 | { |
---|
62 | //if(!bTriggered) return false; |
---|
63 | |
---|
64 | |
---|
65 | |
---|
66 | |
---|
67 | orxout() << "bTriggered is " << bTriggered << endl; |
---|
68 | |
---|
69 | //for (DialogueManager* hud : ObjectList<DialogueManager>()) |
---|
70 | //m = hud; |
---|
71 | |
---|
72 | DialogueManager& m = DialogueManager::getInstance(); |
---|
73 | |
---|
74 | m.setquestion(question); |
---|
75 | m.setanswers1(a1); |
---|
76 | m.setanswers2(a2); |
---|
77 | orxout() << " 1 " << endl; |
---|
78 | |
---|
79 | |
---|
80 | OrxonoxOverlay::showOverlay("Dialogue"); |
---|
81 | |
---|
82 | return false; |
---|
83 | } |
---|
84 | |
---|
85 | void NextQuestion::XMLEventPort(Element& xmlelement, XMLPort::Mode mode) |
---|
86 | { |
---|
87 | SUPER(NextQuestion, XMLEventPort, xmlelement, mode); |
---|
88 | |
---|
89 | XMLPortEventSink(NextQuestion, BaseObject, "execute", execute, xmlelement, mode); |
---|
90 | } |
---|
91 | |
---|
92 | |
---|
93 | void NextQuestion::setanswers1(std::string a1){ |
---|
94 | this->a1=a1; |
---|
95 | } |
---|
96 | |
---|
97 | void NextQuestion::setanswers2(std::string a2){ |
---|
98 | this->a2=a2; |
---|
99 | } |
---|
100 | |
---|
101 | |
---|
102 | |
---|
103 | std::string NextQuestion::getanswers1(void){ |
---|
104 | return a1; |
---|
105 | } |
---|
106 | |
---|
107 | std::string NextQuestion::getanswers2(void){ |
---|
108 | return a2; |
---|
109 | } |
---|
110 | |
---|
111 | |
---|
112 | /*NextQuestion NextQuestion::compare(){ |
---|
113 | DialogueManager& m = DialogueManager::getInstance(); |
---|
114 | if(m.a1clicked()){ |
---|
115 | return *possibleQuestions[0]; |
---|
116 | } |
---|
117 | |
---|
118 | else if(m.a2clicked()){ |
---|
119 | return *possibleQuestions[1]; |
---|
120 | } |
---|
121 | }*/ |
---|
122 | |
---|
123 | |
---|
124 | } |
---|