Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/Dialogue_FS17/src/modules/dialogue/NextQuestion.cc @ 11413

Last change on this file since 11413 was 11413, checked in by rrogge, 7 years ago

Buttons

File size: 2.8 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
11namespace orxonox{
12
13        RegisterClass(NextQuestion);
14
15        NextQuestion::NextQuestion(Context* context) : BaseObject(context)
16    {
17        RegisterObject(NextQuestion);
18        orxout() << "Klasse aufgerufen" << endl;
19         DialogueManager* d = new DialogueManager(context);
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        NextQuestion NextQuestion::compare(){
112                DialogueManager& m = DialogueManager::getInstance();
113                if(m.a1clicked()){
114                        return *possibleQuestions[0];
115                }
116
117                else if(m.a2clicked()){
118                        return *possibleQuestions[1];
119                }
120        }
121
122
123}
Note: See TracBrowser for help on using the repository browser.