Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 11656


Ignore:
Timestamp:
Dec 11, 2017, 3:35:50 PM (6 years ago)
Author:
kuchlert
Message:

fertig kommentierte version

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

Legend:

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

    r11644 r11656  
    1010namespace orxonox
    1111{
    12        
     12        /**
     13        @brief
     14    class containing the pc side of the Dialog
     15
     16    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
     17        */
     18
    1319        class _DialogExport Answer : public BaseObject
    1420        {
     
    2834
    2935                private:
    30                         std::string answerId_;
    31                         std::string answer_;
    32                         std::string nextQuestionId_;
     36                        std::string answerId_;  //!< id of the pc textoption   
     37                        std::string answer_;    //!< string with the pc text
     38                        std::string nextQuestionId_;    //!< id of the npc reaction to pc answer
    3339        };
    3440}
  • code/branches/Dialog_HS17/src/modules/dialog/AnswerId.h

    r11644 r11656  
    99
    1010namespace orxonox{
     11
     12        /**
     13        @brief
     14    container class for answerids in xml
     15
     16        */
     17
    1118        class AnswerId : public BaseObject
    1219        {
     
    2027
    2128                private:
    22                         std::string id_;
     29                        std::string id_;        //!< id of one answer
    2330        };
    2431}
  • code/branches/Dialog_HS17/src/modules/dialog/Dialog.h

    r11644 r11656  
    1616namespace orxonox
    1717{
     18                /**
     19        @brief
     20    class containing core of one dialog with one npc
     21
     22    this class contains a map of all answerids to answers (player text options) and one of all questionids to questions (npc text options)
     23    it realizes a state machine with the question beeing the states and the answers beeing the connections, it has a current state and
     24    can be commanded to go to the next state according to a given answer
     25        */
     26
    1827        class _DialogExport Dialog : public BaseObject
    1928        {
     
    2433                        virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
    2534
    26                         void setName(const std::string& name);  //xmlPort-Funktion, setzt Namen
    27                         const std::string& getName() const;     //xmlPort-Funktion, returnt Namen
     35                        void setName(const std::string& name);  //xmlPort-Funktion, sets Namen
     36                        const std::string& getName() const;     //xmlPort-Funktion, returns Namen
    2837
    29                         void setCurrentQuestionId(const std::string& questionId);       //xmlPort-Funktion, setzt string Id der momentanen Frage
    30                         const std::string& getCurrentQuestionId() const;        //xmlPort-Funktion, gibt Id der momentanen Frage
     38                        void setCurrentQuestionId(const std::string& questionId);       //xmlPort-Funktion, sets string id of current question
     39                        const std::string& getCurrentQuestionId() const;        //xmlPort-Funktion, returns id of current question
    3140
    32                         void addQuestion(Question* question); //xmlPort-Funktion, fuegt Question der Map hinzu
    33                         const Question* getQuestion() const; //xmlPort-Funktion, returnt nullptr
     41                        void addQuestion(Question* question); //xmlPort-Funktion, adds question to map
     42                        const Question* getQuestion() const; //xmlPort-Funktion, returns nullptr
    3443
    35                         void addAnswer(Answer* answer); //xmlPort-Funktion, fuegt Answer der Map hinzu
    36                         const Answer* getAnswer(unsigned int index) const; //xmlPort-Funktion, returnt nullptr
     44                        void addAnswer(Answer* answer); //xmlPort-Funktion, adds answer to map
     45                        const Answer* getAnswer(unsigned int index) const; //xmlPort-Funktion, returns nullptr
    3746
     47                        /**
     48                @brief
     49                    returns a pointer to the array of answers belonging to the current question for use in dialogManager
    3850
    39                         const std::vector<std::string>* getAnswerIds();         // returned Pointer auf Vector mit allen momentanen AntwortenIds
     51                @return
     52                    pointer to answerId array of question
     53                */
     54                        const std::vector<std::string>* getAnswerIds();
    4055
    41                         bool execute(bool bTriggered, BaseObject* trigger); // funktion die aufgerufen wird wenn der im xml verbundene Trigger aktiviert wird
     56                        /**
     57                @brief
     58                    function called when the trigger object defined in the xml file sets to triggered
    4259
    43                         void update(const std::string& givenAnswerId);  //setzt die naechste Frage entsprechend der gegebenen antwortId
     60                @param bTriggered
     61                    needs to be set like this for correctness
     62                @param trigger
     63                    needs to be set like this for correctness
     64                @return
     65                        not really used
     66                */
     67                        bool execute(bool bTriggered, BaseObject* trigger);
    4468
    45                         bool ending(const std::string& givenAnswerId); //ist true falls fuer die gegebene AntwortId keine Frage zur FragenId der Antwort existiert
     69                        /**
     70                @brief
     71                    updates the current Dialog according to the id of a given answer, by setting currentQuestionId to the next one
    4672
    47                         const std::string& getQuestionString(); //gibt string der momentanen Frage
    48                         const std::string& getAnswerString(std::string answerId); //gibt string der zur Id passenden Frage
     73                @param givenAnswerId
     74                        id of the answer given by player
     75                */
     76                        void update(const std::string& givenAnswerId);
     77
     78                        /**
     79                @brief
     80                    tests if there is a next question for the given answerId
     81
     82                @param givenAnswerId
     83                                id of the answer given by player
     84                @return
     85                        true if there is no more Question to the given answerId
     86                */
     87                        bool ending(const std::string& givenAnswerId);
     88
     89                        /**
     90                @brief
     91                    gives the text of the npc in the current state
     92
     93                @return
     94                        sting with npc text
     95                */
     96                        const std::string& getQuestionString();
     97
     98                        /**
     99                @brief
     100                    returns a sting with the pc answer to the id
     101
     102                @param answerId
     103                        the id of the answer looked for
     104                @return
     105                        sting with answer
     106                */
     107                        const std::string& getAnswerString(std::string answerId);
    49108
    50109                private:
    51                         std::string name_;
    52                         std::string currentQuestionId_;
    53                         std::map<std::string, Question*> questions_;
    54                         std::map<std::string, Answer*> answers_;
     110                        std::string name_;      //!< name of the npc talking
     111                        std::string currentQuestionId_; //!< id of the npc question currently active
     112                        std::map<std::string, Question*> questions_;    //!< a map form the ids of npc textoptions to the objects containing them
     113                        std::map<std::string, Answer*> answers_;        //!< a map form the ids of npc textoptions to the objects containing them
    55114        };
    56115}
  • code/branches/Dialog_HS17/src/modules/dialog/DialogManager.h

    r11644 r11656  
    1313
    1414{//tolua_export
     15
     16    /**
     17    @brief
     18    this class is used for calling on a dialog form luascript
     19
     20    the class is the interface of dialog to lua, all lua functionallity is given by this class, it can be found by lua due to singleton definition
     21
     22    */
     23
    1524    class _OrxonoxExport DialogManager //tolua_export
    1625    : public Singleton<DialogManager>
     
    2130       
    2231        DialogManager();
    23        
    24         //gibt lua den pointer auf den Manager
     32
     33        /**
     34        @brief
     35            gives the pointer to the sigleton dialog manager to the lua script
     36
     37        @return
     38            returns pointer
     39        */
     40
    2541        static DialogManager& getInstance() { return Singleton<DialogManager>::getInstance(); } //tolua_export
    2642
    27         //setzt den momentanen Dialog auf den uebergebenen, wird vom Dialog verwendet um bei Trigger event sich selbst zu setzen
     43        /**
     44        @brief
     45            allows to set the current dialog
     46
     47            this is used by a dialog when triggered to set its self to the current dialog
     48
     49        @param dialog
     50            pointer to the dialog that wants to be current one
     51        */
    2852        void setDialog(Dialog* dialog);
    2953
    30         //von hier an sind lua funktionalitaeten definiert
     54        //from here on functions for lua interface
    3155
    32         //gibt den string der momentanen Frage des Dialogs
     56        /**
     57        @brief
     58            gives the string of the momentary npc textoption
     59
     60        @return
     61            string of npc text
     62        */
    3363        std::string getQuestion(); //tolua_export
    3464
    35         //gibt die laenge des Antwort-arrays der momentanen zuruek, 0 falls es leer ist
     65        /**
     66        @brief
     67            function that returns size of answerid array
     68
     69        @return
     70            returns number of possible answers to momentary questions, 0 if there are no player text options
     71        */
    3672        int getSize(); //tolua_export
    3773
    38         //gibt den sting zu einer Frage im antwortarray der momentanen Frage
     74        /**
     75        @brief
     76            returns the answer to the id that is at index in the array of answers
     77
     78        @param param1
     79            index of desired answer
     80
     81        @return
     82            string of answer
     83        */
    3984        std::string getAnswer(int index); //tolua_export
    4085
    41         //gibt den Namen der Person mit der man spricht
     86        /**
     87        @brief
     88            gives name of npc the player is currently talking to
     89
     90        @return
     91            sting with name
     92        */
    4293        std::string getPerson(); //tolua_export
    4394
    44         //testet ob der dialog weiter geht, true wenn es keine weitere Frage nach der Antwort kommt oder keine Antwort zur Frage existiert
     95        /**
     96        @brief
     97            tests the dialog if there are any followup npc textoptions to the given answer or if there are no answers to the current question
     98
     99        @return
     100            true if the answer array of the question is empty or the next question id of the answer does not exist
     101        */
    45102        bool endtest(int index); //tolua_export
    46103
    47         //updated den Dialog so dass er auf die Antwort die im Antwortvector am index steht reagiert
     104        /**
     105        @brief
     106            tells the dialog to update according to a given answer, if no answer is actively clicked the standard index is sett 0 in the lua
     107            when called the current question of the dialog is set to the new one and the answerId vector is set accordingly
     108
     109        @param param1
     110            index of the answer given by the player
     111
     112        */
    48113        void update(int index); //tolua_export
    49114
    50115private:
    51     static DialogManager* singletonPtr_s;
     116    static DialogManager* singletonPtr_s;   //!< a pointer to the single class object
    52117
    53     Dialog* currentTalk_;
    54     const std::vector<std::string>* answerIds_;
     118    Dialog* currentTalk_;   //!< pointer to the currently active dialog or last active if no one is currently active
     119    const std::vector<std::string>* answerIds_; //!< pointer to the possible answerIds of the current question, for faster access
    55120
    56121    };//tolua_export
  • code/branches/Dialog_HS17/src/modules/dialog/Question.h

    r11644 r11656  
    1313namespace orxonox
    1414{
     15
     16        /**
     17        @brief
     18    class containing the npc side of the Dialog
     19
     20    this class contains one possible text option of the npc, it's id and the ids of possible player reactions (answers)
     21        */
     22
    1523        class _DialogExport Question : public BaseObject
    1624        {
     
    2937                        const AnswerId* getAnswerId() const;    //xmlPort-Funktion, gibt nichts zuruek
    3038
     39                        /**
     40                @brief
     41                    gives pointer to possivle answerIds of this question
     42
     43                @return
     44                        returns pointer to the array with ids of possible pc textoptions
     45                */
    3146                        const std::vector<std::string>* getAnswerIds(); //returnt Pointer auf Vektor mit allen Ids
    3247
    3348
    3449
    35                 private:
    36                         std::string questionId_;
    37                         std::string question_;
    38                         std::vector<std::string> answerIds_;
     50                private:        
     51                        std::string questionId_;        //!< id of npc textoption       
     52                        std::string question_;  //!< string with npc text
     53                        std::vector<std::string> answerIds_;    //!< vector with possible player reactions
    3954        };
    4055}
Note: See TracChangeset for help on using the changeset viewer.