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
RevLine 
[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"
10
11namespace orxonox{
12
13        RegisterClass(NextQuestion);
14
[11401]15        NextQuestion::NextQuestion(Context* context) : BaseObject(context)
16    {
17        RegisterObject(NextQuestion);
18        orxout() << "Klasse aufgerufen" << endl;
[11406]19         DialogueManager* d = new DialogueManager(context);
20       
[11401]21    }
22
23        void NextQuestion::setquestion(std::string question){
[11406]24                this->question=question;
[11401]25        }
26
27        std::string NextQuestion::getquestion(void){
[11406]28                orxout() << question;
[11401]29                return question;
30        }
31
32       
[11413]33        bool NextQuestion::addposQuestion(NextQuestion* nq){
34               
35                possibleQuestions.push_back(nq);
36                return true;
37        }
[11401]38
[11413]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; }
[11401]48       
[11413]49        //XML and Event stuff
[11401]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);
[11413]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       
[11401]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
[11406]69        //for (DialogueManager* hud : ObjectList<DialogueManager>())
70            //m = hud;
71
72        DialogueManager& m = DialogueManager::getInstance();
73               
74        m.setquestion(question);
[11413]75        m.setanswers1(a1);
76        m.setanswers2(a2);
[11406]77        orxout() << " 1 " << endl;
78
79       
80        OrxonoxOverlay::showOverlay("Dialogue");
81
[11401]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    }
[11413]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;
[11393]105        }
106
[11413]107        std::string NextQuestion::getanswers2(void){
108                return a2;
[11393]109        }
110
[11413]111        NextQuestion NextQuestion::compare(){
112                DialogueManager& m = DialogueManager::getInstance();
113                if(m.a1clicked()){
114                        return *possibleQuestions[0];
115                }
[11393]116
[11413]117                else if(m.a2clicked()){
118                        return *possibleQuestions[1];
119                }
120        }
121
122
[11393]123}
Note: See TracBrowser for help on using the repository browser.