Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 7, 2017, 9:25:39 AM (6 years ago)
Author:
kuchlert
Message:

erste version bei der listenauswahl funktioniert

Location:
code/branches/Dialog_HS17/src/modules/dialog
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • code/branches/Dialog_HS17/src/modules/dialog/Dialog.cc

    r11612 r11642  
    2424                XMLPortParam(Dialog, "name", setName, getName, xmlelement, mode);
    2525                XMLPortParam(Dialog, "currentQuestionId", setCurrentQuestionId, getCurrentQuestionId, xmlelement, mode);
    26                 XMLPortObject(Dialog, Question, "Questions", addQuestion, getQuestion, xmlelement, mode);
    27                 XMLPortObject(Dialog, Answer, "Answers", addAnswer, getAnswer, xmlelement, mode);
     26                XMLPortObject(Dialog, Question, "questions", addQuestion, getQuestion, xmlelement, mode);
     27                XMLPortObject(Dialog, Answer, "answers", addAnswer, getAnswer, xmlelement, mode);
    2828        }
    2929
     
    7979        }
    8080
    81         std::vector<std::string> Dialog::getAnswers() // returned vector mit allen momentanen AntwortenIds
     81        std::vector<std::string>* Dialog::getAnswerIds() // returned vector mit allen momentanen AntwortenIds
    8282        {
    83 
     83               
    8484                Question* question = (this->questions_.find(this->currentQuestionId_))->second;
    85                 std::vector<std::string> answers = question->getAnswerIds();
     85                std::vector<std::string>* answers = question->getAnswerIds();
    8686                return answers;
     87               
    8788        }
    8889       
     
    9091    { 
    9192        DialogManager& m = DialogManager::getInstance();
    92         m.setDialog(this);
    93         orxout() << "dialog executed \n";
    94         OrxonoxOverlay::showOverlay("Dialog");
    95 
     93       
     94        if(questions_.count(this->currentQuestionId_)){
     95                m.setDialog(this);
     96                OrxonoxOverlay::showOverlay("Dialog");
     97        }
     98        else {
     99                orxout() << "no start defined " << endl;
     100        }
     101       
    96102        return false;
    97103    }
     
    106112    {
    107113        bool end = false;
    108         if (this->currentQuestionId_ == "end"){
    109                 end = true;
    110         } else if ((this->questions_.find(this->currentQuestionId_)->second)->getAnswerIds().empty()){
     114        if ((this->questions_.find(this->currentQuestionId_)->second)->getAnswerIds()->empty()){
    111115                end = true;
    112116        }       
     
    118122                return this->questions_.find(this->currentQuestionId_)->second->getQuestion();
    119123        }
     124
     125        std::string Dialog::getAnswerString(std::string answerId)
     126        {
     127                return this->answers_.find(answerId)->second->getAnswer();
     128        }
    120129}
  • code/branches/Dialog_HS17/src/modules/dialog/Dialog.h

    r11612 r11642  
    3535                        Question* getQuestion(unsigned int index) const; // // benoetigt fuer xmlPort
    3636                        Answer* getAnswer(unsigned int index) const; // benoetigt fuer xmlPort
    37                         std::vector<std::string> getAnswers();  // returned vector mit allen momentanen AntwortenIds
     37                        std::vector<std::string>* getAnswerIds();       // returned vector mit allen momentanen AntwortenIds
    3838
    3939                        bool execute(bool bTriggered, BaseObject* trigger);
     
    4444
    4545                        std::string getQuestionString(); //gibt string der momentanen Frage
     46                        std::string getAnswerString(std::string answerId); //gibt string der zur Id passenden Frage
    4647
    4748                private:
  • code/branches/Dialog_HS17/src/modules/dialog/DialogManager.cc

    r11612 r11642  
    1616        void DialogManager::setDialog(Dialog* dialog)
    1717        {
    18                 this->currentTalk_ = dialog;   
     18                this->currentTalk_ = dialog;
     19                answerIds_ = currentTalk_->getAnswerIds();     
    1920        }
    2021
     
    2627    }
    2728
    28     /*
    29     std::vector<std::string> DialogManager::getAnswers()
     29    int DialogManager::getSize()
     30    {   
     31        return 2; //return this->answerIds_->size();
     32    }
     33
     34    std::string DialogManager::getAnswer(int index)
    3035    {
    31         // lua hat komisch arrays (eigentlich tables), wie implementiert man answers so das man nacher den key der gegeben antwort a
    32         // hat um ihn fuer update zu benutzen?
     36        return this->currentTalk_->getAnswerString(this->answerIds_->at(index));
    3337    }
    34         */
     38       
     39    std::string DialogManager::getPerson()
     40    {
     41        return this->currentTalk_->getName();
     42    }
     43
     44    bool DialogManager::endtest()
     45    {
     46        return this->currentTalk_->ending();
     47    }
     48
     49    void DialogManager::update(int index)
     50    {
     51        this->currentTalk_->update(answerIds_->at(index));
     52        answerIds_ = this->currentTalk_->getAnswerIds();
     53    }
    3554}
  • code/branches/Dialog_HS17/src/modules/dialog/DialogManager.h

    r11612 r11642  
    3030
    3131        std::string getQuestion(); //tolua_export
    32         //std::vector<std::string> getAnswers();
     32        int getSize(); //tolua_export
     33        std::string getAnswer(int index); //tolua_export
     34        std::string getPerson(); //tolua_export
     35        bool endtest(); //tolua_export
     36        void update(int index); //tolua_export
    3337
    3438private:
     
    3640
    3741    Dialog* currentTalk_;
     42    std::vector<std::string>* answerIds_;
    3843
    3944    };//tolua_export
  • code/branches/Dialog_HS17/src/modules/dialog/Question.cc

    r11611 r11642  
    1919                XMLPortParam(Question, "Id", setQuestionId, getQuestionId, xmlement, mode);
    2020
    21                 XMLPortObject(Question, AnswerId, "answers", addAnswerId, getAnswerId, xmlement, mode);
     21                XMLPortObject(Question, AnswerId, "answerIds", addAnswerId, getAnswerId, xmlement, mode);
    2222        }
    2323
     
    5252        }
    5353
    54         std::vector<std::string> Question::getAnswerIds()
     54        std::vector<std::string>* Question::getAnswerIds()
    5555        {
    56                 return this->answerIds_;
     56                return &(this->answerIds_);
    5757        }
    5858       
  • code/branches/Dialog_HS17/src/modules/dialog/Question.h

    r11611 r11642  
    3333                        // die sowieso gebraucht wird?
    3434
    35                         std::vector<std::string> getAnswerIds(); //returnt vektor mit allen Ids
     35                        std::vector<std::string>* getAnswerIds(); //returnt vektor mit allen Ids
    3636
    3737
Note: See TracChangeset for help on using the changeset viewer.