Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 20, 2018, 12:09:09 AM (7 years ago)
Author:
landauf
Message:

tabs → spaces

Location:
code/branches/Presentation_HS17_merge/src/modules/dialog
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • code/branches/Presentation_HS17_merge/src/modules/dialog/Answer.cc

    r11781 r11782  
    3333namespace orxonox{
    3434
    35         RegisterClass(Answer);
     35    RegisterClass(Answer);
    3636
    3737
    38         // Constructor:
    39         Answer::Answer(Context* context) : BaseObject(context)
    40         {
    41             RegisterObject(Answer);
    42         }
     38    // Constructor:
     39    Answer::Answer(Context* context) : BaseObject(context)
     40    {
     41        RegisterObject(Answer);
     42    }
    4343
    44         void Answer::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    45         {
    46                 SUPER(Answer, XMLPort, xmlelement, mode);
     44    void Answer::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     45    {
     46        SUPER(Answer, XMLPort, xmlelement, mode);
    4747
    48                 XMLPortParam(Answer, "Id", setAnswerId, getAnswerId, xmlelement, mode);
    49                 XMLPortParam(Answer, "answer", setAnswer, getAnswer, xmlelement, mode);
    50                 XMLPortParam(Answer, "nextQuestionId", setNextQuestion, getNextQuestion, xmlelement,mode);
    51         }
     48        XMLPortParam(Answer, "Id", setAnswerId, getAnswerId, xmlelement, mode);
     49        XMLPortParam(Answer, "answer", setAnswer, getAnswer, xmlelement, mode);
     50        XMLPortParam(Answer, "nextQuestionId", setNextQuestion, getNextQuestion, xmlelement,mode);
     51    }
    5252
    53         void Answer::setAnswerId(const std::string& answerId){
    54                 this->answerId_ = answerId;
    55         }
     53    void Answer::setAnswerId(const std::string& answerId){
     54        this->answerId_ = answerId;
     55    }
    5656
    57         const std::string& Answer::getAnswerId() const
    58         {
    59                 return this->answerId_;
    60         }
     57    const std::string& Answer::getAnswerId() const
     58    {
     59        return this->answerId_;
     60    }
    6161
    62         void Answer::setNextQuestion(const std::string& nextId)
    63         {
    64                 this->nextQuestionId_ = nextId;
    65         }
     62    void Answer::setNextQuestion(const std::string& nextId)
     63    {
     64        this->nextQuestionId_ = nextId;
     65    }
    6666
    67         const std::string& Answer::getNextQuestion() const
    68         {
    69                 return this->nextQuestionId_;
    70         }
     67    const std::string& Answer::getNextQuestion() const
     68    {
     69        return this->nextQuestionId_;
     70    }
    7171
    72         void Answer::setAnswer(const std::string& answer)
    73         {
    74                 this->answer_ = answer;
    75         }
     72    void Answer::setAnswer(const std::string& answer)
     73    {
     74        this->answer_ = answer;
     75    }
    7676
    77         const std::string& Answer::getAnswer() const
    78         {
    79                 return this->answer_;
    80         }
    81 }       
     77    const std::string& Answer::getAnswer() const
     78    {
     79        return this->answer_;
     80    }
     81}
  • code/branches/Presentation_HS17_merge/src/modules/dialog/Answer.h

    r11781 r11782  
    3838namespace orxonox
    3939{
    40         /**
    41         @brief
     40    /**
     41    @brief
    4242    class containing the pc side of the Dialog
    4343
    4444    this class contains one possible text option of the pc, it's id and the id of the reaction of the npc to this answer
    45         */
     45    */
    4646
    47         class _DialogExport Answer : public BaseObject
    48         {
    49                 public:
    50                         Answer(Context* context);
    51                        
    52                         virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     47    class _DialogExport Answer : public BaseObject
     48    {
     49        public:
     50            Answer(Context* context);
    5351
    54                         void setAnswerId(const std::string& answerId); //xmlPort-Funktion, setzt AntwortId
    55                         const std::string& getAnswerId() const; //xmlPort-Funktion,     gibt AntwortId
     52            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    5653
    57                         void setNextQuestion(const std::string& nextId); //xmlPort-Funktion, um Dialog zu beenden tag benutzen der von keiner Frage benutzt wird
    58                         const std::string& getNextQuestion() const;     //xmlPort-Funktion, gibt Id der Folgefrage
     54            void setAnswerId(const std::string& answerId); //xmlPort-Funktion, setzt AntwortId
     55            const std::string& getAnswerId() const; //xmlPort-Funktion, gibt AntwortId
    5956
    60                         void setAnswer(const std::string& awns);        //xmlPort-Funktion, setzt Antworttext
    61                         const std::string& getAnswer() const;   //xmlPort-Funktion,     gibt Antworttext
     57            void setNextQuestion(const std::string& nextId); //xmlPort-Funktion, um Dialog zu beenden tag benutzen der von keiner Frage benutzt wird
     58            const std::string& getNextQuestion() const; //xmlPort-Funktion, gibt Id der Folgefrage
    6259
    63                 private:
    64                         std::string answerId_;  //!< id of the pc textoption   
    65                         std::string answer_;    //!< string with the pc text
    66                         std::string nextQuestionId_;    //!< id of the npc reaction to pc answer
    67         };
     60            void setAnswer(const std::string& awns); //xmlPort-Funktion, setzt Antworttext
     61            const std::string& getAnswer() const; //xmlPort-Funktion, gibt Antworttext
     62
     63        private:
     64            std::string answerId_;  //!< id of the pc textoption
     65            std::string answer_;    //!< string with the pc text
     66            std::string nextQuestionId_; //!< id of the npc reaction to pc answer
     67    };
    6868}
    6969
  • code/branches/Presentation_HS17_merge/src/modules/dialog/AnswerId.cc

    r11781 r11782  
    3333namespace orxonox{
    3434
    35         RegisterClass(AnswerId);
     35    RegisterClass(AnswerId);
    3636
    37         AnswerId::AnswerId(Context* context) : BaseObject(context)
    38         {
    39                 RegisterObject(AnswerId);
    40         }
     37    AnswerId::AnswerId(Context* context) : BaseObject(context)
     38    {
     39        RegisterObject(AnswerId);
     40    }
    4141
    42         void AnswerId::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    43         {
    44                 SUPER(AnswerId, XMLPort, xmlelement, mode);
     42    void AnswerId::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     43    {
     44        SUPER(AnswerId, XMLPort, xmlelement, mode);
    4545
    46                 XMLPortParam(AnswerId, "Id", setId, getId, xmlelement, mode);
    47         }
     46        XMLPortParam(AnswerId, "Id", setId, getId, xmlelement, mode);
     47    }
    4848
    49         void AnswerId::setId(const std::string& id)
    50         {
    51                 this->id_ = id;
    52         }
    53        
    54         const std::string& AnswerId::getId() const
    55         {
    56                 return this->id_;
    57         }
     49    void AnswerId::setId(const std::string& id)
     50    {
     51        this->id_ = id;
     52    }
     53
     54    const std::string& AnswerId::getId() const
     55    {
     56        return this->id_;
     57    }
    5858}
  • code/branches/Presentation_HS17_merge/src/modules/dialog/AnswerId.h

    r11781 r11782  
    3939namespace orxonox{
    4040
    41         /**
    42         @brief
     41    /**
     42    @brief
    4343    container class for answerids in xml
    4444
    45         */
     45    */
    4646
    47         class _DialogExport AnswerId : public BaseObject
    48         {
    49                 public:
    50                         AnswerId(Context* context);
    51                        
    52                         virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     47    class _DialogExport AnswerId : public BaseObject
     48    {
     49        public:
     50            AnswerId(Context* context);
    5351
    54             void setId(const std::string& Id);  //allows to set Id, only use in xmlPort for initializing AnswerIds in lvl files
    55             const std::string& getId() const;   //allows to get Id, used in xmlPort
     52            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    5653
    57                 private:
    58                         std::string id_;        //!< id of one answer
    59         };
     54            void setId(const std::string& Id);  //allows to set Id, only use in xmlPort for initializing AnswerIds in lvl files
     55            const std::string& getId() const;   //allows to get Id, used in xmlPort
     56
     57        private:
     58            std::string id_;    //!< id of one answer
     59    };
    6060}
    6161
  • code/branches/Presentation_HS17_merge/src/modules/dialog/Dialog.cc

    r11781 r11782  
    3838{
    3939
    40         RegisterClass(Dialog);
    41        
    42         //Constructor:
    43         Dialog::Dialog(Context* context) : BaseObject(context)
    44         {
    45                 RegisterObject(Dialog);
    46         }
     40    RegisterClass(Dialog);
    4741
    48         void Dialog::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    49         {
    50                 SUPER(Dialog, XMLPort, xmlelement, mode);
     42    //Constructor:
     43    Dialog::Dialog(Context* context) : BaseObject(context)
     44    {
     45        RegisterObject(Dialog);
     46    }
    5147
    52                 XMLPortParam(Dialog, "name", setName, getName, xmlelement, mode);
    53                 XMLPortParam(Dialog, "currentQuestionId", setCurrentQuestionId, getCurrentQuestionId, xmlelement, mode);
    54                 XMLPortObject(Dialog, Question, "questions", addQuestion, getQuestion, xmlelement, mode);
    55                 XMLPortObject(Dialog, Answer, "answers", addAnswer, getAnswer, xmlelement, mode);
    56         }
     48    void Dialog::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     49    {
     50        SUPER(Dialog, XMLPort, xmlelement, mode);
    5751
    58         void Dialog::XMLEventPort(Element& xmlelement, XMLPort::Mode mode)
     52        XMLPortParam(Dialog, "name", setName, getName, xmlelement, mode);
     53        XMLPortParam(Dialog, "currentQuestionId", setCurrentQuestionId, getCurrentQuestionId, xmlelement, mode);
     54        XMLPortObject(Dialog, Question, "questions", addQuestion, getQuestion, xmlelement, mode);
     55        XMLPortObject(Dialog, Answer, "answers", addAnswer, getAnswer, xmlelement, mode);
     56    }
     57
     58    void Dialog::XMLEventPort(Element& xmlelement, XMLPort::Mode mode)
    5959    {
    6060        SUPER(Dialog, XMLEventPort, xmlelement, mode);
     
    6363    }
    6464
    65         void Dialog::setName(const std::string& name)
    66         {
    67                 this->name_ = name;
    68         }
     65    void Dialog::setName(const std::string& name)
     66    {
     67        this->name_ = name;
     68    }
    6969
    70         const std::string& Dialog::getName() const
    71         {
    72                 return this->name_;
    73         }
     70    const std::string& Dialog::getName() const
     71    {
     72        return this->name_;
     73    }
    7474
    75         void Dialog::setCurrentQuestionId(const std::string& questionId)
    76         {
    77                 this->currentQuestionId_ = questionId;
    78         }
     75    void Dialog::setCurrentQuestionId(const std::string& questionId)
     76    {
     77        this->currentQuestionId_ = questionId;
     78    }
    7979
    80         const std::string& Dialog::getCurrentQuestionId() const
    81         {
    82                 return this->currentQuestionId_;
    83         }
     80    const std::string& Dialog::getCurrentQuestionId() const
     81    {
     82        return this->currentQuestionId_;
     83    }
    8484
    8585
    86         void Dialog::addQuestion(Question* question) //fuegt Question der Map hinzu
    87         {
    88                 this->questions_.insert(make_pair(question->getQuestionId(), question));
    89         }
     86    void Dialog::addQuestion(Question* question) //fuegt Question der Map hinzu
     87    {
     88        this->questions_.insert(make_pair(question->getQuestionId(), question));
     89    }
    9090
    91         Question* Dialog::getQuestion(unsigned int index) const
    92         {
     91    Question* Dialog::getQuestion(unsigned int index) const
     92    {
    9393        unsigned int i = 0;
    9494        for (auto entry : this->questions_)
     
    9999        }
    100100        return nullptr;
    101         }
     101    }
    102102
    103         void Dialog::addAnswer(Answer* answer) //fuegt Answer der Map hinzu
    104         {
    105                 this->answers_.insert(make_pair(answer->getAnswerId(), answer));
    106         }
     103    void Dialog::addAnswer(Answer* answer) //fuegt Answer der Map hinzu
     104    {
     105        this->answers_.insert(make_pair(answer->getAnswerId(), answer));
     106    }
    107107
    108         Answer* Dialog::getAnswer(unsigned int index) const
    109         {
     108    Answer* Dialog::getAnswer(unsigned int index) const
     109    {
    110110        unsigned int i = 0;
    111111        for (auto entry : this->answers_)
     
    116116        }
    117117        return nullptr;
    118         }
     118    }
    119119
    120120
    121         const std::vector<std::string>& Dialog::getAnswerIds() const // returned vector mit allen momentanen AntwortenIds
    122         {
    123                
    124                 Question* question = (this->questions_.find(this->currentQuestionId_))->second;
    125                 return question->getAnswerIds();
    126                
    127         }
    128        
    129         bool Dialog::execute(bool bTriggered, BaseObject* trigger)
     121    const std::vector<std::string>& Dialog::getAnswerIds() const // returned vector mit allen momentanen AntwortenIds
     122    {
     123
     124        Question* question = (this->questions_.find(this->currentQuestionId_))->second;
     125        return question->getAnswerIds();
     126
     127    }
     128
     129    bool Dialog::execute(bool bTriggered, BaseObject* trigger)
    130130    { 
    131         DialogManager& m = DialogManager::getInstance();
    132        
    133         if(questions_.count(this->currentQuestionId_)){
    134                 m.setDialog(this);
    135                 OrxonoxOverlay::showOverlay("Dialog");
    136         }
    137         else {
    138                 orxout() << "no start defined " << endl;
    139         }
    140        
     131        DialogManager& m = DialogManager::getInstance();
     132
     133        if(questions_.count(this->currentQuestionId_)){
     134            m.setDialog(this);
     135            OrxonoxOverlay::showOverlay("Dialog");
     136        }
     137        else {
     138            orxout() << "no start defined " << endl;
     139        }
     140
    141141        return false;
    142142    }
     
    144144    void Dialog::update(const std::string& givenAnswerId)
    145145    {
    146         Answer* answer = (answers_.find(givenAnswerId))->second;
    147         this->currentQuestionId_ = answer->getNextQuestion();
     146        Answer* answer = (answers_.find(givenAnswerId))->second;
     147        this->currentQuestionId_ = answer->getNextQuestion();
    148148    }
    149149
    150150    bool Dialog::ending(const std::string& givenAnswerId)
    151151    {
    152         return !this->questions_.count(this->answers_.find(givenAnswerId)->second->getNextQuestion());
     152        return !this->questions_.count(this->answers_.find(givenAnswerId)->second->getNextQuestion());
    153153    }
    154154
    155         const std::string& Dialog::getQuestionString()
    156         {
    157                 return this->questions_.find(this->currentQuestionId_)->second->getQuestion();
    158         }
     155    const std::string& Dialog::getQuestionString()
     156    {
     157        return this->questions_.find(this->currentQuestionId_)->second->getQuestion();
     158    }
    159159
    160         const std::string& Dialog::getAnswerString(const std::string& answerId)
    161         {
    162                 return this->answers_.find(answerId)->second->getAnswer();
    163         }
     160    const std::string& Dialog::getAnswerString(const std::string& answerId)
     161    {
     162        return this->answers_.find(answerId)->second->getAnswer();
     163    }
    164164}
  • code/branches/Presentation_HS17_merge/src/modules/dialog/Dialog.h

    r11781 r11782  
    4444namespace orxonox
    4545{
    46                 /**
    47         @brief
     46    /**
     47    @brief
    4848    class containing core of one dialog with one npc
    4949
     
    5151    it realizes a state machine with the question beeing the states and the answers beeing the connections, it has a current state and
    5252    can be commanded to go to the next state according to a given answer
    53         */
     53    */
    5454
    55         class _DialogExport Dialog : public BaseObject
    56         {
    57                 public:
    58                         Dialog(Context* context);
     55    class _DialogExport Dialog : public BaseObject
     56    {
     57        public:
     58            Dialog(Context* context);
    5959
    60                         virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    61                         virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
     60            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     61            virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
    6262
    63                         void setName(const std::string& name);  //xmlPort-Funktion, sets Namen
    64                         const std::string& getName() const;     //xmlPort-Funktion, returns Namen
     63            void setName(const std::string& name); //xmlPort-Funktion, sets Namen
     64            const std::string& getName() const; //xmlPort-Funktion, returns Namen
    6565
    66                         void setCurrentQuestionId(const std::string& questionId);       //xmlPort-Funktion, sets string id of current question
    67                         const std::string& getCurrentQuestionId() const;        //xmlPort-Funktion, returns id of current question
     66            void setCurrentQuestionId(const std::string& questionId); //xmlPort-Funktion, sets string id of current question
     67            const std::string& getCurrentQuestionId() const; //xmlPort-Funktion, returns id of current question
    6868
    69                         void addQuestion(Question* question); //xmlPort-Funktion, adds question to map
    70                         Question* getQuestion(unsigned int index) const; //xmlPort-Funktion
     69            void addQuestion(Question* question); //xmlPort-Funktion, adds question to map
     70            Question* getQuestion(unsigned int index) const; //xmlPort-Funktion
    7171
    72                         void addAnswer(Answer* answer); //xmlPort-Funktion, adds answer to map
    73                         Answer* getAnswer(unsigned int index) const; //xmlPort-Funktion
     72            void addAnswer(Answer* answer); //xmlPort-Funktion, adds answer to map
     73            Answer* getAnswer(unsigned int index) const; //xmlPort-Funktion
    7474
    75                         /**
    76                 @brief
    77                     returns a pointer to the array of answers belonging to the current question for use in dialogManager
     75            /**
     76            @brief
     77                returns a pointer to the array of answers belonging to the current question for use in dialogManager
    7878
    79                 @return
    80                     pointer to answerId array of question
    81                 */
    82                         const std::vector<std::string>& getAnswerIds() const;
     79            @return
     80                pointer to answerId array of question
     81            */
     82            const std::vector<std::string>& getAnswerIds() const;
    8383
    84                         /**
    85                 @brief
    86                     function called when the trigger object defined in the xml file sets to triggered
     84            /**
     85            @brief
     86                function called when the trigger object defined in the xml file sets to triggered
    8787
    88                 @param bTriggered
    89                     needs to be set like this for correctness
    90                 @param trigger
    91                     needs to be set like this for correctness
    92                 @return
    93                         not really used
    94                 */
    95                         bool execute(bool bTriggered, BaseObject* trigger);
     88            @param bTriggered
     89                needs to be set like this for correctness
     90            @param trigger
     91                needs to be set like this for correctness
     92            @return
     93                not really used
     94            */
     95            bool execute(bool bTriggered, BaseObject* trigger);
    9696
    97                         /**
    98                 @brief
    99                     updates the current Dialog according to the id of a given answer, by setting currentQuestionId to the next one
     97            /**
     98            @brief
     99                updates the current Dialog according to the id of a given answer, by setting currentQuestionId to the next one
    100100
    101                 @param givenAnswerId
    102                         id of the answer given by player
    103                 */
    104                         void update(const std::string& givenAnswerId);
     101            @param givenAnswerId
     102                id of the answer given by player
     103            */
     104            void update(const std::string& givenAnswerId);
    105105
    106                         /**
    107                 @brief
    108                     tests if there is a next question for the given answerId
     106            /**
     107            @brief
     108                tests if there is a next question for the given answerId
    109109
    110                 @param givenAnswerId
    111                                 id of the answer given by player
    112                 @return
    113                         true if there is no more Question to the given answerId
    114                 */
    115                         bool ending(const std::string& givenAnswerId);
     110            @param givenAnswerId
     111                id of the answer given by player
     112            @return
     113                true if there is no more Question to the given answerId
     114            */
     115            bool ending(const std::string& givenAnswerId);
    116116
    117                         /**
    118                 @brief
    119                     gives the text of the npc in the current state
     117            /**
     118            @brief
     119                gives the text of the npc in the current state
    120120
    121                 @return
    122                         sting with npc text
    123                 */
    124                         const std::string& getQuestionString();
     121            @return
     122                sting with npc text
     123            */
     124            const std::string& getQuestionString();
    125125
    126                         /**
    127                 @brief
    128                     returns a sting with the pc answer to the id
     126            /**
     127            @brief
     128                returns a sting with the pc answer to the id
    129129
    130                 @param answerId
    131                         the id of the answer looked for
    132                 @return
    133                         sting with answer
    134                 */
    135                         const std::string& getAnswerString(const std::string& answerId);
     130            @param answerId
     131                the id of the answer looked for
     132            @return
     133                sting with answer
     134            */
     135            const std::string& getAnswerString(const std::string& answerId);
    136136
    137                 private:
    138                         std::string name_;      //!< name of the npc talking
    139                         std::string currentQuestionId_; //!< id of the npc question currently active
    140                         std::map<std::string, Question*> questions_;    //!< a map form the ids of npc textoptions to the objects containing them
    141                         std::map<std::string, Answer*> answers_;        //!< a map form the ids of npc textoptions to the objects containing them
    142         };
     137        private:
     138            std::string name_; //!< name of the npc talking
     139            std::string currentQuestionId_; //!< id of the npc question currently active
     140            std::map<std::string, Question*> questions_; //!< a map form the ids of npc textoptions to the objects containing them
     141            std::map<std::string, Answer*> answers_; //!< a map form the ids of npc textoptions to the objects containing them
     142    };
    143143}
    144144
  • code/branches/Presentation_HS17_merge/src/modules/dialog/DialogManager.cc

    r11781 r11782  
    3333
    3434namespace orxonox {
    35         ManageScopedSingleton(DialogManager, ScopeID::ROOT, false);
    36        
     35    ManageScopedSingleton(DialogManager, ScopeID::ROOT, false);
    3736
    38        
    39         DialogManager::DialogManager()
    40         {
    41                 this->currentTalk_ = nullptr;
    42                 this->answerIds_ = nullptr;
    43         }
    4437
    45         void DialogManager::setDialog(Dialog* dialog)
    46         {
    47                 this->currentTalk_ = dialog;
    48                 this->answerIds_ = &this->currentTalk_->getAnswerIds();
    49         }
    5038
    51         //from here onward funcionality for lua axports
     39    DialogManager::DialogManager()
     40    {
     41        this->currentTalk_ = nullptr;
     42        this->answerIds_ = nullptr;
     43    }
     44
     45    void DialogManager::setDialog(Dialog* dialog)
     46    {
     47        this->currentTalk_ = dialog;
     48        this->answerIds_ = &this->currentTalk_->getAnswerIds();
     49    }
     50
     51    //from here onward funcionality for lua axports
    5252
    5353    std::string DialogManager::getQuestion()
    5454    {
    55         return this->currentTalk_->getQuestionString();
     55        return this->currentTalk_->getQuestionString();
    5656    }
    5757
     
    6363    std::string DialogManager::getAnswer(int index)
    6464    {
    65         return this->currentTalk_->getAnswerString(this->answerIds_->at(index));
     65        return this->currentTalk_->getAnswerString(this->answerIds_->at(index));
    6666    }
    67        
     67
    6868    std::string DialogManager::getPerson()
    6969    {
    70         return this->currentTalk_->getName();
     70        return this->currentTalk_->getName();
    7171    }
    7272
     
    8686    void DialogManager::update(int index)
    8787    {
    88         this->currentTalk_->update(this->answerIds_->at(index));
    89         this->answerIds_ = &this->currentTalk_->getAnswerIds();
     88        this->currentTalk_->update(this->answerIds_->at(index));
     89        this->answerIds_ = &this->currentTalk_->getAnswerIds();
    9090    }
    9191}
  • code/branches/Presentation_HS17_merge/src/modules/dialog/Question.cc

    r11781 r11782  
    3333{
    3434
    35         RegisterClass(Question);
     35    RegisterClass(Question);
    3636
    37         Question::Question(Context* context) : BaseObject(context)
    38         {
    39                 RegisterObject(Question);
    40         }
     37    Question::Question(Context* context) : BaseObject(context)
     38    {
     39        RegisterObject(Question);
     40    }
    4141
    42         void Question::XMLPort(Element& xmlement, XMLPort::Mode mode)
    43         {
    44                 SUPER(Question, XMLPort, xmlement, mode);
     42    void Question::XMLPort(Element& xmlement, XMLPort::Mode mode)
     43    {
     44        SUPER(Question, XMLPort, xmlement, mode);
    4545
    46                 XMLPortParam(Question, "question", setQuestion, getQuestion, xmlement, mode);
    47                 XMLPortParam(Question, "Id", setQuestionId, getQuestionId, xmlement, mode);
     46        XMLPortParam(Question, "question", setQuestion, getQuestion, xmlement, mode);
     47        XMLPortParam(Question, "Id", setQuestionId, getQuestionId, xmlement, mode);
    4848
    49                 XMLPortObject(Question, AnswerId, "answerIds", addAnswerId, getAnswerId, xmlement, mode);
    50         }
     49        XMLPortObject(Question, AnswerId, "answerIds", addAnswerId, getAnswerId, xmlement, mode);
     50    }
    5151
    52         void Question::setQuestionId(const std::string& Id)
    53         {
    54                 this->questionId_ = Id;
    55         }
     52    void Question::setQuestionId(const std::string& Id)
     53    {
     54        this->questionId_ = Id;
     55    }
    5656
    57         const std::string& Question::getQuestionId() const
    58         {
    59                 return this->questionId_;
    60         }
     57    const std::string& Question::getQuestionId() const
     58    {
     59        return this->questionId_;
     60    }
    6161
    62         void Question::setQuestion(const std::string& question)
    63         {
    64                 this->question_ = question;
    65         }
     62    void Question::setQuestion(const std::string& question)
     63    {
     64        this->question_ = question;
     65    }
    6666
    67         const std::string& Question::getQuestion() const
    68         {
    69                 return this->question_;
    70         }
     67    const std::string& Question::getQuestion() const
     68    {
     69        return this->question_;
     70    }
    7171
    72         void Question::addAnswerId(AnswerId* answerId)
    73         {
    74                 this->answerIds_.push_back(answerId->getId());
    75         }
     72    void Question::addAnswerId(AnswerId* answerId)
     73    {
     74        this->answerIds_.push_back(answerId->getId());
     75    }
    7676
    77         AnswerId* Question::getAnswerId(unsigned int index) const
    78         {
    79                 return nullptr;
    80         }
     77    AnswerId* Question::getAnswerId(unsigned int index) const
     78    {
     79        return nullptr;
     80    }
    8181
    82         const std::vector<std::string>& Question::getAnswerIds() const
    83         {
    84                 return this->answerIds_;
    85         }
    86        
     82    const std::vector<std::string>& Question::getAnswerIds() const
     83    {
     84        return this->answerIds_;
     85    }
    8786}
  • code/branches/Presentation_HS17_merge/src/modules/dialog/Question.h

    r11781 r11782  
    4242{
    4343
    44         /**
    45         @brief
     44    /**
     45    @brief
    4646    class containing the npc side of the Dialog
    4747
    4848    this class contains one possible text option of the npc, it's id and the ids of possible player reactions (answers)
    49         */
     49    */
    5050
    51         class _DialogExport Question : public BaseObject
    52         {
    53                 public:
    54                         Question(Context* context);
     51    class _DialogExport Question : public BaseObject
     52    {
     53        public:
     54            Question(Context* context);
    5555
    56                         virtual void XMLPort(Element& xmelement, XMLPort::Mode mode);
     56            virtual void XMLPort(Element& xmelement, XMLPort::Mode mode);
    5757
    58                         void setQuestionId(const std::string& Id);      //xmlPort-Funktion, setzt Id
    59                         const std::string& getQuestionId() const;       //xmlPort-Funktion, gibt Id string zuruek
     58            void setQuestionId(const std::string& Id); //xmlPort-Funktion, setzt Id
     59            const std::string& getQuestionId() const; //xmlPort-Funktion, gibt Id string zuruek
    6060
    61                         void setQuestion(const std::string& question);  //xmlPort-Funktion, setzt Fragen string
    62                         const std::string& getQuestion() const; //xmlPort-Funktion, gibt Fragen string
     61            void setQuestion(const std::string& question); //xmlPort-Funktion, setzt Fragen string
     62            const std::string& getQuestion() const; //xmlPort-Funktion, gibt Fragen string
    6363
    64                         void addAnswerId(AnswerId* answerId);   //xmlPort-Funktion, nimmt AnswerIds von entsprechenden Objekten und fuegt sie in List ein.
    65                         AnswerId* getAnswerId(unsigned int index) const;        //xmlPort-Funktion, gibt nichts zuruek
     64            void addAnswerId(AnswerId* answerId);  //xmlPort-Funktion, nimmt AnswerIds von entsprechenden Objekten und fuegt sie in List ein.
     65            AnswerId* getAnswerId(unsigned int index) const; //xmlPort-Funktion, gibt nichts zuruek
    6666
    67                         /**
    68                 @brief
    69                     gives pointer to possivle answerIds of this question
     67            /**
     68            @brief
     69                gives pointer to possivle answerIds of this question
    7070
    71                 @return
    72                         returns pointer to the array with ids of possible pc textoptions
    73                 */
    74                         const std::vector<std::string>& getAnswerIds() const; //returnt Pointer auf Vektor mit allen Ids
     71            @return
     72                returns pointer to the array with ids of possible pc textoptions
     73            */
     74            const std::vector<std::string>& getAnswerIds() const; //returnt Pointer auf Vektor mit allen Ids
    7575
    7676
    7777
    78                 private:       
    79                         std::string questionId_;        //!< id of npc textoption       
    80                         std::string question_;  //!< string with npc text
    81                         std::vector<std::string> answerIds_;    //!< vector with possible player reactions
    82         };
     78        private:
     79            std::string questionId_; //!< id of npc textoption
     80            std::string question_; //!< string with npc text
     81            std::vector<std::string> answerIds_; //!< vector with possible player reactions
     82    };
    8383}
    8484
Note: See TracChangeset for help on using the changeset viewer.