Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 26, 2017, 3:40:04 PM (7 years ago)
Author:
rrogge
Message:

Code aufgeraeumt

Location:
code/branches/Dialogue_FS17/src/modules/dialogue
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/Dialogue_FS17/src/modules/dialogue/DialogueManager.cc

    r11432 r11435  
    1818       
    1919
    20         //DialogueManager* DialogueManager::singletonPtr_s =nullptr;
    21 
    22         DialogueManager::DialogueManager(){
    23                 orxout() << "Dialog Konstruktor" << endl;
    24                 //RegisterObject(DialogueManager);
    25                
    26         }
     20       
     21        DialogueManager::DialogueManager(){}
    2722       
    2823
    29         /**
    30      * @brief set the config values in the orxonox.ini file
    31      */
     24       
    3225   
    3326
     
    3528                if(allQuestions.size()==0) {
    3629                        orxout(internal_info) << "At least one NextQuestion has to be set." << endl;
    37                 } else  {
    38                         currentQuestion = allQuestions[0];
    39                 }
     30                }
    4031                allQuestions.push_back(nq);
    4132                        orxout(internal_info) << "qsize " << allQuestions.size();
     
    5344
    5445        std::string DialogueManager::getquestion(void){
    55                 orxout() << question << endl;
    5646                return question;
    5747        }
     48
    5849        void DialogueManager::setanswers1(std::string a1){
    59                 orxout() << "setanswers1" << endl;
    6050                this->a1=a1;
    61                 orxout() << "A1 is " << a1;
    6251                                }
    6352
     
    6958
    7059        std::string DialogueManager::getanswers1(void){
    71                 orxout() << "getanswers1" << endl;
    7260                return a1;
    7361        }
     
    7664                return a2;
    7765        }
     66
    7867        void DialogueManager::a1clicked(void){
    79                
    8068               
    8169                currentQuestion = currentQuestion->possibleQuestions[0];
     
    8573        }
    8674        void DialogueManager::a2clicked(void){
    87                 orxout() << "a2 clicked" << endl;
    88 
     75               
    8976                currentQuestion = currentQuestion->possibleQuestions[1];
    9077                update(currentQuestion);
     78        }
    9179
    92                
    93         }
    9480         void DialogueManager::update(NextQuestion* nq){
    9581                this->setquestion(nq->getquestion());
    9682                this->setanswers1(nq->getanswers1());
    9783                this->setanswers2(nq->getanswers2());
    98                 depth=depth+1;
    99                
    100                
    10184         }
    102         void DialogueManager::clean(){
    103                 orxout() <<" depth " << depth << endl;
    104                 //allQuestions.at(2*depth+1);
    105         }
     85
    10686        bool DialogueManager::theEnd(){
    10787        if((currentQuestion->possibleQuestions).empty()) {
    108                 orxout() << "endtrue" << endl;
    10988                return true;}
    11089        else return false;
    11190        }
    11291
    113        
    114 
    115         /*
    116        
    117        
    118        
    119 
    120        
    121         vector<std::string> DialogueManager::getanswers(void){
    122                 return options;
    123         }
    124 
    125         int DialogueManager::getnumOptions(){
    126                 return options.size();
    127         }
    128 
    129         */
    13092}
  • code/branches/Dialogue_FS17/src/modules/dialogue/DialogueManager.h

    r11432 r11435  
    1212#include <string>
    1313#include <vector>
    14 //#include "OrxonoxPrereqs.h"
    1514#include "core/config/Configurable.h"
    1615#include "core/XMLPort.h"
     
    3231                public:
    3332               
    34 
    3533                DialogueManager();
    3634               
     
    3836                static DialogueManager& getInstance() { return Singleton<DialogueManager>::getInstance(); } //tolua_export
    3937               
     38
    4039                void setquestion(std::string question); //tolua_export
    4140                std::string getquestion(void); //tolua_export
    4241               
    43                 void registerquestion(NextQuestion* nq);
     42               
    4443                void setanswers1(std::string a1); //tolua_export
     44                std::string getanswers1(void); //tolua_export
     45               
    4546                void setanswers2(std::string a2); //tolua_export
    46                 std::string getanswers1(void); //tolua_export
    4747                std::string getanswers2(void); //tolua_export
     48               
     49                void setCurrentQuestion(NextQuestion* q);
     50
     51                //Sets the current Question to the question corresponding to the first/second answer 
    4852                void a1clicked(void); //tolua_export
    4953                void a2clicked(void); //tolua_export
     54               
     55                //Checks whether there are any more Questions to come
    5056                bool theEnd(); //tolua_export
     57
     58                //Sets question and a1, a2 for new currentQuestion
    5159                void update(NextQuestion* nq);
    52                 void clean(); //tolua_export
    53                 void setCurrentQuestion(NextQuestion* q);
     60
     61                //Is executed whenever a NextQuestion is created and pushes all NextQuestion into the allQuestion vector.
     62                void registerquestion(NextQuestion* nq);
    5463
    5564private:
    56         NextQuestion* currentQuestion;
     65        NextQuestion* currentQuestion; //The Question which is currently displayed
    5766        std::vector<NextQuestion*> allQuestions;
    58         std::string a1;
    59         std::string a2;
     67        std::string a1; //answer on first button
     68        std::string a2; //answer on second button
    6069        std::string question;
    61         int depth = 0;
    6270        static DialogueManager* singletonPtr_s;
    6371
  • code/branches/Dialogue_FS17/src/modules/dialogue/NextQuestion.cc

    r11433 r11435  
    1717    {
    1818        RegisterObject(NextQuestion);
    19         orxout() << "Klasse aufgerufen" << endl;
     19
    2020        DialogueManager& m = DialogueManager::getInstance();
    2121        m.registerquestion(this);
    22        //possibleQuestions=nullptr;
     22       
    2323       
    2424    }
     
    2929
    3030        std::string NextQuestion::getquestion(void){
    31                 orxout() << question;
    3231                return question;
    3332        }
     
    5150         }
    5251       
    53         //XML and Event stuff
     52       
    5453        void NextQuestion::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    5554    {
     
    6463        bool NextQuestion::execute(bool bTriggered, BaseObject* trigger)
    6564    { 
    66         //if(!bTriggered) return false;
    67        
    6865       
    69        
    70 
    71         orxout() << "bTriggered is " << bTriggered << endl;
    72 
    73         //for (DialogueManager* hud : ObjectList<DialogueManager>())
    74             //m = hud;
    75 
    76         DialogueManager& m = DialogueManager::getInstance();
     66        DialogueManager& m = DialogueManager::getInstance();
    7767               
    7868        m.setquestion(question);
     
    8070        m.setanswers1(a1);
    8171        m.setanswers2(a2);
    82         orxout() << " 1 " << endl;
     72       
    8373
    8474       
     
    114104        }
    115105
    116         std::vector<NextQuestion*> NextQuestion::retposQues(){
    117                 //if(possibleQuestions.size()==0) return NULL;
    118106       
    119                 orxout() << "SIZE" << possibleQuestions.size() << endl;
    120                 return possibleQuestions;
    121         }
    122107
    123108
    124         /*
    125 
    126         }*/
    127109
    128110
  • code/branches/Dialogue_FS17/src/modules/dialogue/NextQuestion.h

    r11432 r11435  
    33
    44
    5 //#include <vector>
     5
    66#include <string>
    77#include "core/class/Identifier.h"
     
    2525                std::string getquestion(void);
    2626
    27 
    28                 bool addposQuestion(NextQuestion* nq);
    29                 const NextQuestion* getposQuestion(unsigned int index) const;
    30  
    31                
    32                 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    33 
    3427                void setanswers1(std::string a1);
    3528                void setanswers2(std::string a2);
     
    3730                std::string getanswers2(void);
    3831
    39                 NextQuestion compare();
     32               
    4033               
    4134
    42                 //Event
     35                //XMLEventPort for Event that first triggers the Dialogue
    4336                virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
     37
     38                //XMLPort for setting questions and answers and the vector possibleQuestions
     39                virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     40
     41                bool addposQuestion(NextQuestion* nq);
     42                const NextQuestion* getposQuestion(unsigned int index) const;
     43
     44                //Sets very first currentQuestion in the DialogueManager when the event is triggered
    4445                bool execute(bool bTriggered, BaseObject* trigger);
    4546
    4647                std::vector<NextQuestion*> possibleQuestions;
    47                 std::vector<NextQuestion*> retposQues();
     48       
    4849        private:
    4950                std::string a1;
Note: See TracChangeset for help on using the changeset viewer.