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