Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 4, 2017, 4:11:36 PM (7 years ago)
Author:
rrogge
Message:

Buttons

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

Legend:

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

    r11406 r11413  
    3636
    3737    void DialogueManager::setquestion(std::string q){
    38                 orxout() << "setquestion" << endl;
    3938                question=q;
    40                 orxout() << "Question is " << question;
     39               
    4140        }
    4241
     
    4443                orxout() << question << endl;
    4544                return question;
     45        }
     46        void DialogueManager::setanswers1(std::string a1){
     47                orxout() << "setanswers1" << endl;
     48                this->a1=a1;
     49                orxout() << "A1 is " << a1;
     50                                }
     51
     52        void DialogueManager::setanswers2(std::string a2){
     53                this->a2=a2;
     54                                }
     55
     56       
     57
     58        std::string DialogueManager::getanswers1(void){
     59                orxout() << "getanswers1" << endl;
     60                return a1;
     61        }
     62
     63        std::string DialogueManager::getanswers2(void){
     64                return a2;
     65        }
     66        bool DialogueManager::a1clicked(void){
     67                orxout() << "a1 clicked" << endl;
     68                return true;
     69        }
     70        bool DialogueManager::a2clicked(void){
     71                orxout() << "a2 clicked" << endl;
     72                return true;
    4673        }
    4774        /*void DialogueManager::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     
    6087       
    6188
    62         void DialogueManager::setanswers(std::string option1, std::string option2, std::string option3){
    63                 options.at(0)=option1;
    64                 options.at(1)=option2;
    65                 options.at(2)=option3;
    66         }
    67 
     89       
    6890        vector<std::string> DialogueManager::getanswers(void){
    6991                return options;
  • code/branches/Dialogue_FS17/src/modules/dialogue/DialogueManager.h

    r11406 r11413  
    1313#include "core/XMLPort.h"
    1414#include "core/EventIncludes.h"
     15
    1516
    1617
     
    3536               
    3637
    37                
    38        
    39 
     38                void setanswers1(std::string a1); //tolua_export
     39                void setanswers2(std::string a2); //tolua_export
     40                std::string getanswers1(void); //tolua_export
     41                std::string getanswers2(void); //tolua_export
     42                bool a1clicked(void); //tolua_export
     43                bool a2clicked(void); //tolua_export
    4044                        /*std::string setnpc(std::string npc);
    4145
     
    5256*/
    5357private:
     58        std::string a1;
     59        std::string a2;
    5460        std::string question;
    5561        static DialogueManager* singletonPtr_s;
  • code/branches/Dialogue_FS17/src/modules/dialogue/NextQuestion.cc

    r11406 r11413  
    1 #include <vector>
     1//#include <vector>
    22#include <string>
    33#include "core/CoreIncludes.h"
     
    1919         DialogueManager* d = new DialogueManager(context);
    2020       
    21 
    2221    }
    2322
     
    3231
    3332       
    34         //
     33        bool NextQuestion::addposQuestion(NextQuestion* nq){
     34               
     35                possibleQuestions.push_back(nq);
     36                return true;
     37        }
    3538
     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; }
    3648       
    37         //XML and Event shit
     49        //XML and Event stuff
    3850        void NextQuestion::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    3951    {
     
    4153
    4254        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       
    4359    }
    4460        bool NextQuestion::execute(bool bTriggered, BaseObject* trigger)
     
    5773               
    5874        m.setquestion(question);
     75        m.setanswers1(a1);
     76        m.setanswers2(a2);
    5977        orxout() << " 1 " << endl;
    6078
     
    7189        XMLPortEventSink(NextQuestion, BaseObject, "execute", execute, xmlelement, mode);
    7290    }
    73         /*void NextQuestion::setanswers(std::string option1, std::string option2, std::string option3){
    74                 options.at(0)=option1;
    75                 options.at(1)=option2;
    76                 options.at(2)=option3;
     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;
    77105        }
    78106
    79         vector<std::string> NextQuestion::getanswers(void){
    80                 return options;
     107        std::string NextQuestion::getanswers2(void){
     108                return a2;
    81109        }
    82110
    83         int NextQuestion::getnumOptions(){
    84                 return options.size();
    85         }*/
     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
    86122
    87123}
  • code/branches/Dialogue_FS17/src/modules/dialogue/NextQuestion.h

    r11401 r11413  
    1 #include <vector>
     1//#include <vector>
    22#include <string>
    33#include "core/class/Identifier.h"
     
    2323
    2424
    25                
     25                bool addposQuestion(NextQuestion* nq);
     26                const NextQuestion* getposQuestion(unsigned int index) const;
    2627 
    2728               
    2829                virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    2930
    30                 /*void setanswers(std::string option1, std::string option2, std::string option3);
    31                 std::vector <std::string> getanswers(void);
     31                void setanswers1(std::string a1);
     32                void setanswers2(std::string a2);
     33                std::string getanswers1(void);
     34                std::string getanswers2(void);
    3235
    33                 int getnumOptions();
    34                 std::vector<std::string> options;*/
     36                NextQuestion compare();
     37               
    3538
    3639                //Event
     
    4043               
    4144        private:
     45                std::string a1;
     46                std::string a2;
     47                std::vector<NextQuestion*> possibleQuestions;
     48
     49
    4250                std::string question;
    4351                DialogueManager* m;
Note: See TracChangeset for help on using the changeset viewer.