| [11749] | 1 | /* |
|---|
| 2 | * ORXONOX - the hottest 3D action shooter ever to exist |
|---|
| 3 | * > www.orxonox.net < |
|---|
| 4 | * |
|---|
| 5 | * |
|---|
| 6 | * License notice: |
|---|
| 7 | * |
|---|
| 8 | * This program is free software; you can redistribute it and/or |
|---|
| 9 | * modify it under the terms of the GNU General Public License |
|---|
| 10 | * as published by the Free Software Foundation; either version 2 |
|---|
| 11 | * of the License, or (at your option) any later version. |
|---|
| 12 | * |
|---|
| 13 | * This program is distributed in the hope that it will be useful, |
|---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 16 | * GNU General Public License for more details. |
|---|
| 17 | * |
|---|
| 18 | * You should have received a copy of the GNU General Public License |
|---|
| 19 | * along with this program; if not, write to the Free Software |
|---|
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|---|
| 21 | * |
|---|
| 22 | * Author: |
|---|
| 23 | * ... |
|---|
| 24 | * Co-authors: |
|---|
| 25 | * ... |
|---|
| 26 | * |
|---|
| 27 | */ |
|---|
| 28 | |
|---|
| [11607] | 29 | #ifndef _Dialog_H__ |
|---|
| 30 | #define _Dialog_H__ |
|---|
| 31 | |
|---|
| [11579] | 32 | #include "core/BaseObject.h" |
|---|
| [11611] | 33 | #include "DialogPrereqs.h" |
|---|
| [11579] | 34 | #include "Question.h" |
|---|
| 35 | #include "Answer.h" |
|---|
| 36 | #include "core/XMLPort.h" |
|---|
| [11607] | 37 | #include "core/CoreIncludes.h" |
|---|
| [11579] | 38 | #include "overlays/OrxonoxOverlay.h" |
|---|
| 39 | |
|---|
| [11611] | 40 | #include <map> |
|---|
| 41 | #include <vector> |
|---|
| [11579] | 42 | #include <string> |
|---|
| 43 | |
|---|
| 44 | namespace orxonox |
|---|
| 45 | { |
|---|
| [11782] | 46 | /** |
|---|
| 47 | @brief |
|---|
| [11656] | 48 | class containing core of one dialog with one npc |
|---|
| 49 | |
|---|
| 50 | this class contains a map of all answerids to answers (player text options) and one of all questionids to questions (npc text options) |
|---|
| 51 | it realizes a state machine with the question beeing the states and the answers beeing the connections, it has a current state and |
|---|
| 52 | can be commanded to go to the next state according to a given answer |
|---|
| [11782] | 53 | */ |
|---|
| [11656] | 54 | |
|---|
| [11782] | 55 | class _DialogExport Dialog : public BaseObject |
|---|
| 56 | { |
|---|
| 57 | public: |
|---|
| 58 | Dialog(Context* context); |
|---|
| [11611] | 59 | |
|---|
| [11782] | 60 | virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); |
|---|
| 61 | virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode); |
|---|
| [11579] | 62 | |
|---|
| [11782] | 63 | void setName(const std::string& name); //xmlPort-Funktion, sets Namen |
|---|
| 64 | const std::string& getName() const; //xmlPort-Funktion, returns Namen |
|---|
| [11579] | 65 | |
|---|
| [11782] | 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 |
|---|
| [11579] | 68 | |
|---|
| [11782] | 69 | void addQuestion(Question* question); //xmlPort-Funktion, adds question to map |
|---|
| 70 | Question* getQuestion(unsigned int index) const; //xmlPort-Funktion |
|---|
| [11579] | 71 | |
|---|
| [11782] | 72 | void addAnswer(Answer* answer); //xmlPort-Funktion, adds answer to map |
|---|
| 73 | Answer* getAnswer(unsigned int index) const; //xmlPort-Funktion |
|---|
| [11579] | 74 | |
|---|
| [11782] | 75 | /** |
|---|
| 76 | @brief |
|---|
| 77 | returns a pointer to the array of answers belonging to the current question for use in dialogManager |
|---|
| [11579] | 78 | |
|---|
| [11782] | 79 | @return |
|---|
| 80 | pointer to answerId array of question |
|---|
| 81 | */ |
|---|
| 82 | const std::vector<std::string>& getAnswerIds() const; |
|---|
| [11579] | 83 | |
|---|
| [11782] | 84 | /** |
|---|
| 85 | @brief |
|---|
| 86 | function called when the trigger object defined in the xml file sets to triggered |
|---|
| [11579] | 87 | |
|---|
| [11782] | 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); |
|---|
| [11579] | 96 | |
|---|
| [11782] | 97 | /** |
|---|
| 98 | @brief |
|---|
| 99 | updates the current Dialog according to the id of a given answer, by setting currentQuestionId to the next one |
|---|
| [11644] | 100 | |
|---|
| [11782] | 101 | @param givenAnswerId |
|---|
| 102 | id of the answer given by player |
|---|
| 103 | */ |
|---|
| 104 | void update(const std::string& givenAnswerId); |
|---|
| [11644] | 105 | |
|---|
| [11782] | 106 | /** |
|---|
| 107 | @brief |
|---|
| 108 | tests if there is a next question for the given answerId |
|---|
| [11656] | 109 | |
|---|
| [11782] | 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); |
|---|
| [11656] | 116 | |
|---|
| [11782] | 117 | /** |
|---|
| 118 | @brief |
|---|
| 119 | gives the text of the npc in the current state |
|---|
| [11656] | 120 | |
|---|
| [11782] | 121 | @return |
|---|
| 122 | sting with npc text |
|---|
| 123 | */ |
|---|
| 124 | const std::string& getQuestionString(); |
|---|
| [11656] | 125 | |
|---|
| [11782] | 126 | /** |
|---|
| 127 | @brief |
|---|
| 128 | returns a sting with the pc answer to the id |
|---|
| [11656] | 129 | |
|---|
| [11782] | 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); |
|---|
| [11656] | 136 | |
|---|
| [11782] | 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 | }; |
|---|
| [11607] | 143 | } |
|---|
| 144 | |
|---|
| [11749] | 145 | #endif |
|---|