Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 30, 2017, 9:33:27 AM (7 years ago)
Author:
kuchlert
Message:

fixed addQuestion and addAnswer in Dialog

Location:
code/branches/Dialog_HS17/src/modules/dialog
Files:
1 added
11 edited

Legend:

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

    r11607 r11611  
    11#include "Answer.h"
     2#include "core/CoreIncludes.h"
    23
    34
  • code/branches/Dialog_HS17/src/modules/dialog/Answer.h

    r11607 r11611  
    33
    44#include "core/BaseObject.h"
     5#include "DialogPrereqs.h"
    56#include "core/XMLPort.h"
    67#include "core/CoreIncludes.h"
     
    1011{
    1112       
    12         class Answer : public BaseObject
     13        class _DialogExport Answer : public BaseObject
    1314        {
    1415                public:
    1516                        Answer(Context* context);
    16                 //      virtual ~Answer();
     17                       
    1718                        virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    1819
  • code/branches/Dialog_HS17/src/modules/dialog/AnswerId.cc

    r11607 r11611  
    11#include "AnswerId.h"
     2#include "core/CoreIncludes.h"
    23
    34
     
    1011                RegisterObject(AnswerId);
    1112        }
     13
    1214        void AnswerId::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    1315        {
     
    1719        }
    1820
    19         void AnswerId::setId(std::string Id){
    20                 this->Id_ = Id;
     21        void AnswerId::setId(std::string id)
     22        {
     23                this->id_ = id;
    2124        }
    22         std::string AnswerId::getId(){
    23                 return this->Id_;
     25       
     26        std::string AnswerId::getId()
     27        {
     28                return this->id_;
    2429        }
    2530}
  • code/branches/Dialog_HS17/src/modules/dialog/AnswerId.h

    r11607 r11611  
    1313                public:
    1414                        AnswerId(Context* context);
    15                 //      virtual ~AnswerId();
     15                       
    1616                        virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    1717
    18                         void setId(std::string Id);
    19                         std::string getId();
     18            void setId(std::string Id);
     19            std::string getId();
    2020
    2121                private:
    22                         std::string Id_;
     22                        std::string id_;
    2323        };
    2424}
  • code/branches/Dialog_HS17/src/modules/dialog/CMakeLists.txt

    r11607 r11611  
    1111  FIND_HEADER_FILES
    1212   TOLUA_FILES
     13   DialogManager.h
    1314  LINK_LIBRARIES
    1415    orxonox
  • code/branches/Dialog_HS17/src/modules/dialog/Dialog.cc

    r11607 r11611  
    55#include "Dialog.h"
    66#include "Question.h"
     7
    78
    89namespace orxonox
     
    5758        void Dialog::addQuestion(Question* question) //fuegt Question der Map hinzu
    5859        {
    59                 //questions_.emplace(question->getQuestionId(), question->getQuestion());
     60                this->questions_.insert(make_pair(question->getQuestionId(), question));
    6061        }
    6162
    6263        void Dialog::addAnswer(Answer* answer) //fuegt Answer der Map hinzu
    6364        {
    64                 //answers_.emplace(std::make_pair(answer->getAnswerId(), answer->getAnswer()));
     65                this->answers_.insert(make_pair(answer->getAnswerId(), answer));
    6566        }
    6667
     
    7273        }
    7374
    74         Answer* Dialog::getAnswer(unsigned int index) const//tolua_export               //returned sting der Antwort zur Id.
     75        Answer* Dialog::getAnswer(unsigned int index) const     //returned sting der Antwort zur Id.
    7576        {
    7677                return nullptr;
     
    8182        {
    8283
    83                 Question question = (questions_.find(this->currentQuestionId_))->second;
    84                 std::vector<std::string> answers = question.getAnswerIds();
     84                Question* question = (this->questions_.find(this->currentQuestionId_))->second;
     85                std::vector<std::string> answers = question->getAnswerIds();
    8586                return answers;
    8687        }
     
    9899    void Dialog::update(std::string givenAnswer)
    99100    {
    100         Answer answer = (answers_.find(givenAnswer))->second;
    101         this->currentQuestionId_ = answer.getNextQuestion();
     101        Answer* answer = (answers_.find(givenAnswer))->second;
     102        this->currentQuestionId_ = answer->getNextQuestion();
    102103    }
    103104
    104     bool Dialog::ending() //tolua_export        //retruned true wenn die Id der Antwort end ist oder keine Antworten auf die frage eingetragen sind
     105    bool Dialog::ending() //retruned true wenn die Id der Antwort end ist oder keine Antworten auf die frage eingetragen sind
    105106    {
    106107        bool end = false;
    107108        if (this->currentQuestionId_ == "end"){
    108109                end = true;
    109         } else if ((questions_.find(this->currentQuestionId_)->second).getAnswerIds().empty()){
     110        } else if ((this->questions_.find(this->currentQuestionId_)->second)->getAnswerIds().empty()){
    110111                end = true;
    111112        }       
  • code/branches/Dialog_HS17/src/modules/dialog/Dialog.h

    r11607 r11611  
    33
    44#include "core/BaseObject.h"
     5#include "DialogPrereqs.h"
    56#include "Question.h"
    67#include "Answer.h"
     
    910#include "overlays/OrxonoxOverlay.h"
    1011
     12#include <map>
     13#include <vector>
    1114#include <string>
    1215
    1316namespace orxonox
    1417{
    15         class Dialog : public BaseObject
     18        class _DialogExport Dialog : public BaseObject
    1619        {
    1720                public:
    1821                        Dialog(Context* context);
    19                         // virtual ~Dialog();
     22
    2023                        virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    2124                        virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
     
    3033                        void addAnswer(Answer* answer); //fuegt Answer der Map hinzu
    3134
    32                         Question* getQuestion(unsigned int index) const; //tolua_export // returned string der momentanen Frage
    33                         Answer* getAnswer(unsigned int index) const; //tolua_export     // returned string der momentanen Frage
    34                         std::vector<std::string> getAnswers(); //tolua_export   // returned vector mit allen momentanen AntwortenIds
     35                        Question* getQuestion(unsigned int index) const; // returned string der momentanen Frage
     36                        Answer* getAnswer(unsigned int index) const; // returned string der momentanen Frage
     37                        std::vector<std::string> getAnswers(); // returned vector mit allen momentanen AntwortenIds
    3538
    3639                        bool execute(bool bTriggered, BaseObject* trigger);
    3740
    38                         void update(std::string givenAnswer);   //tolua_export
     41                        void update(std::string givenAnswer);
    3942
    40                         bool ending(); //tolua_export   //retruned true wenn die Id der Antwort end ist oder keine Antworten auf die frage eingetragen sind
     43                        bool ending(); //retruned true wenn die Id der Antwort end ist oder keine Antworten auf die frage eingetragen sind
    4144
    4245
     
    4447                        std::string name_;
    4548                        std::string currentQuestionId_;
    46                         std::map<std::string, Question> questions_;
    47                         std::map<std::string, Answer> answers_;
     49                        std::map<std::string, Question*> questions_;
     50                        std::map<std::string, Answer*> answers_;
    4851        };
    4952}
  • code/branches/Dialog_HS17/src/modules/dialog/DialogManager.cc

    r11607 r11611  
    3838        }
    3939}
    40 /*#include "core/CoreIncludes.h"
    41 #include "core/LuaState.h"
    42 #include "core/GUIManager.h"
    43 #include "core/class/Identifier.h"
    44 #include "core/singleton/ScopedSingletonIncludes.h"
    45 #include "network/Host.h"
    46 #include "network/NetworkFunctionIncludes.h"
    47 #include "DialogManager.h"
    48 #include <vector>
    49 #include <string>
    50 #include "core/XMLPort.h"
    51 #include "Dialog.h"
    52 
    53 
    54 
    55 namespace orxonox {
    56 
    57         ManageScopedSingleton(DialogManager, ScopeID::ROOT, false);
    58 
    59 
    60         DialogManager::DialogManager()
    61         {
    62                 this->currentTalk_ = NULL;
    63         }
    64 
    65         void DialogManager::setDialog(Dialog* dialog)
    66         {
    67                 this->currentTalk_ = dialog;   
    68         }
    69 
    70         const Dialog& getCurrentDialog()
    71         {
    72                 return this->currentTalk_;
    73         }
    74        
    75         bool DialogManager::empty()
    76         {
    77                 if(this->currentTalk_ == NULL)
    78                 {
    79                         return true;
    80                 }
    81                 else
    82                 {
    83                         return false;
    84                 }
    85         }
    86 } */
  • code/branches/Dialog_HS17/src/modules/dialog/DialogManager.h

    r11607 r11611  
    1 /*
    21#ifndef _DialogManager_H__
    32#define _DialogManager_H__
    43
    5 #include "core/CoreIncludes.h"
    6 #include "core/LuaState.h"
    7 #include "core/GUIManager.h"
    8 #include "core/class/Identifier.h"
    9 #include "core/singleton/ScopedSingletonIncludes.h"
    10 #include "network/Host.h"
    11 #include "network/NetworkFunctionIncludes.h"
    12 #include "util/Singleton.h"
    13 #include <string>
    14 #include <vector>
    15 #include "core/config/Configurable.h"
    16 #include "core/XMLPort.h"
    17 #include "core/EventIncludes.h"
    18 #include "Dialog.h"
    19 
    20 
    21 
    22 
    23 
    24 namespace orxonox //tolua_export
    25 
    26 {//tolua_export
    27         class _OrxonoxExport DialogManager //tolua_export
    28         : public Singleton<DialogManager>
    29         {//tolua_export
    30                 friend class Singleton<DialogManager>;
    31        
    32                 public:
    33                
    34                 DialogManager();
    35                
    36 
    37                 static DialogManager& getInstance() { return Singleton<DialogManager>::getInstance(); } //tolua_export
    38                
    39 
    40                 void setDialog(Dialog* dialog); //tolua_export  // the triggered dialog sets it self so the lua can get to it.
    41                 const Dialog& getCurrentDialog();       //tolua_export
    42                 bool empty(); //tolua_export //returns true if no dialog is set.
    43 
    44 private:
    45         Dialog* currentTalk_; //Dialog which is currently set.
    46         static DialogManager* singletonPtr_s;
    47 
    48         };//tolua_export
    49 }//tolua_export
    50 #endif
    51  */
    52 
    53 #ifndef _DialogManager_H__
    54 #define _DialogManager_H__
    55 
     4#include "DialogPrereqs.h"
    565#include "util/Singleton.h"
    576#include "core/object/Listable.h"
     
    609namespace orxonox
    6110{
    62     class DialogManager : public Singleton<DialogManager>, public Listable
     11    class _DialogExport DialogManager : public Singleton<DialogManager>, public Listable
    6312    {
    6413        friend class Singleton<DialogManager>;
     
    6716            DialogManager();
    6817
    69             int getValue() const
    70                 { return this->value_; }
     18           // int getValue() const { return this->value_; }
    7119
    72                 static DialogManager& getInstance() { return Singleton<DialogManager>::getInstance(); }
     20                static DialogManager& getInstance() { return Singleton<DialogManager>::getInstance(); } //toloa_export
    7321
    7422                void setDialog(Dialog* dialog);
     
    7624                bool empty();
    7725
     26            //form here on all lua functionality used in lua scrips is declared
     27
     28
    7829        private:
    7930                Dialog* currentTalk_;
    80             int value_;
     31            //int value_;
    8132
    8233            static DialogManager* singletonPtr_s;
  • code/branches/Dialog_HS17/src/modules/dialog/Question.cc

    r11607 r11611  
    11#include "Question.h"
    2 
     2#include "core/CoreIncludes.h"
    33
    44namespace orxonox
  • code/branches/Dialog_HS17/src/modules/dialog/Question.h

    r11607 r11611  
    33
    44#include "core/BaseObject.h"
     5#include "DialogPrereqs.h"
    56#include "AnswerId.h"
    67#include "core/XMLPort.h"
    78#include "core/CoreIncludes.h"
     9
    810
    911#include <string>
     
    1113namespace orxonox
    1214{
    13         class Question : public BaseObject
     15        class _DialogExport Question : public BaseObject
    1416        {
    1517                public:
    1618                        Question(Context* context);
    17                 //      virtual ~Question();
     19
    1820                        virtual void XMLPort(Element& xmelement, XMLPort::Mode mode);
    1921
Note: See TracChangeset for help on using the changeset viewer.