Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 11422 was 11421, checked in by rrogge, 8 years ago

question updates

File size: 2.9 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"
[11417]10#include "DialogueManager.h"
[11393]11
12namespace orxonox{
13
14        RegisterClass(NextQuestion);
15
[11401]16        NextQuestion::NextQuestion(Context* context) : BaseObject(context)
17    {
18        RegisterObject(NextQuestion);
19        orxout() << "Klasse aufgerufen" << endl;
[11417]20        DialogueManager& m = DialogueManager::getInstance();
21        m.registerquestion(this);
[11415]22       
[11406]23       
[11401]24    }
25
26        void NextQuestion::setquestion(std::string question){
[11406]27                this->question=question;
[11401]28        }
29
30        std::string NextQuestion::getquestion(void){
[11406]31                orxout() << question;
[11401]32                return question;
33        }
34
35       
[11413]36        bool NextQuestion::addposQuestion(NextQuestion* nq){
37               
38                possibleQuestions.push_back(nq);
39                return true;
40        }
[11401]41
[11413]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        }
[11421]50        return nullptr;
51         }
[11401]52       
[11413]53        //XML and Event stuff
[11401]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);
[11413]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       
[11401]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
[11406]73        //for (DialogueManager* hud : ObjectList<DialogueManager>())
74            //m = hud;
75
76        DialogueManager& m = DialogueManager::getInstance();
77               
78        m.setquestion(question);
[11413]79        m.setanswers1(a1);
80        m.setanswers2(a2);
[11406]81        orxout() << " 1 " << endl;
82
83       
84        OrxonoxOverlay::showOverlay("Dialogue");
85
[11401]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    }
[11413]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;
[11393]109        }
110
[11413]111        std::string NextQuestion::getanswers2(void){
112                return a2;
[11393]113        }
114
[11421]115        std::vector<NextQuestion*> NextQuestion::retposQues(){
116                orxout() << "fish" << endl;
117                assert(possibleQuestions[0]);
118                orxout() << possibleQuestions.size() << endl;
119                return possibleQuestions;
120        }
[11415]121
[11393]122
[11421]123        /*
124
[11415]125        }*/
[11413]126
127
[11393]128}
Note: See TracBrowser for help on using the repository browser.