Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/modules/dialogue/NextQuestion.cc @ 11718

Last change on this file since 11718 was 11718, checked in by landauf, 6 years ago

tabs → spaces

File size: 2.5 KB
Line 
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
12namespace orxonox{
13
14    RegisterClass(NextQuestion);
15
16    NextQuestion::NextQuestion(Context* context) : BaseObject(context)
17    {
18        RegisterObject(NextQuestion);
19
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        return question;
32    }
33
34
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
42    {
43        for (NextQuestion* effect : this->possibleQuestions)
44        {
45            if(i == 0)
46               return effect;
47            i--;
48        }
49        return nullptr;
50         }
51
52
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);
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       
62    }
63    bool NextQuestion::execute(bool bTriggered, BaseObject* trigger)
64    { 
65       
66        DialogueManager& m = DialogueManager::getInstance();
67
68        m.setquestion(question);
69        m.setCurrentQuestion(this);
70        m.setanswers1(a1);
71        m.setanswers2(a2);
72       
73
74       
75        OrxonoxOverlay::showOverlay("Dialogue");
76
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    }
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;
100    }
101
102    std::string NextQuestion::getanswers2(void){
103        return a2;
104    }
105
106}
Note: See TracBrowser for help on using the repository browser.