Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

Reload works now

File size: 2.9 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        orxout() << "Klasse aufgerufen" << endl;
20        DialogueManager& m = DialogueManager::getInstance();
21        m.registerquestion(this);
22       //possibleQuestions=nullptr;
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.setCurrentQuestion(this);
80        m.setanswers1(a1);
81        m.setanswers2(a2);
82        orxout() << " 1 " << endl;
83
84       
85        OrxonoxOverlay::showOverlay("Dialogue");
86
87        return false;
88    }
89
90    void NextQuestion::XMLEventPort(Element& xmlelement, XMLPort::Mode mode)
91    {
92        SUPER(NextQuestion, XMLEventPort, xmlelement, mode);
93
94        XMLPortEventSink(NextQuestion, BaseObject, "execute", execute, xmlelement, mode); 
95    }
96
97
98        void NextQuestion::setanswers1(std::string a1){
99                this->a1=a1;
100                                }
101
102        void NextQuestion::setanswers2(std::string a2){
103                this->a2=a2;
104                                }
105
106       
107
108        std::string NextQuestion::getanswers1(void){
109                return a1;
110        }
111
112        std::string NextQuestion::getanswers2(void){
113                return a2;
114        }
115
116        std::vector<NextQuestion*> NextQuestion::retposQues(){
117                //if(possibleQuestions.size()==0) return NULL;
118       
119                orxout() << "SIZE" << possibleQuestions.size() << endl;
120                return possibleQuestions;
121        }
122
123
124        /*
125
126        }*/
127
128
129}
Note: See TracBrowser for help on using the repository browser.