#ifndef _Dialog_H__ #define _Dialog_H__ #include "core/BaseObject.h" #include "DialogPrereqs.h" #include "Question.h" #include "Answer.h" #include "core/XMLPort.h" #include "core/CoreIncludes.h" #include "overlays/OrxonoxOverlay.h" #include #include #include namespace orxonox { /** @brief class containing core of one dialog with one npc this class contains a map of all answerids to answers (player text options) and one of all questionids to questions (npc text options) it realizes a state machine with the question beeing the states and the answers beeing the connections, it has a current state and can be commanded to go to the next state according to a given answer */ class _DialogExport Dialog : public BaseObject { public: Dialog(Context* context); virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode); void setName(const std::string& name); //xmlPort-Funktion, sets Namen const std::string& getName() const; //xmlPort-Funktion, returns Namen void setCurrentQuestionId(const std::string& questionId); //xmlPort-Funktion, sets string id of current question const std::string& getCurrentQuestionId() const; //xmlPort-Funktion, returns id of current question void addQuestion(Question* question); //xmlPort-Funktion, adds question to map const Question* getQuestion() const; //xmlPort-Funktion, returns nullptr void addAnswer(Answer* answer); //xmlPort-Funktion, adds answer to map const Answer* getAnswer(unsigned int index) const; //xmlPort-Funktion, returns nullptr /** @brief returns a pointer to the array of answers belonging to the current question for use in dialogManager @return pointer to answerId array of question */ const std::vector* getAnswerIds(); /** @brief function called when the trigger object defined in the xml file sets to triggered @param bTriggered needs to be set like this for correctness @param trigger needs to be set like this for correctness @return not really used */ bool execute(bool bTriggered, BaseObject* trigger); /** @brief updates the current Dialog according to the id of a given answer, by setting currentQuestionId to the next one @param givenAnswerId id of the answer given by player */ void update(const std::string& givenAnswerId); /** @brief tests if there is a next question for the given answerId @param givenAnswerId id of the answer given by player @return true if there is no more Question to the given answerId */ bool ending(const std::string& givenAnswerId); /** @brief gives the text of the npc in the current state @return sting with npc text */ const std::string& getQuestionString(); /** @brief returns a sting with the pc answer to the id @param answerId the id of the answer looked for @return sting with answer */ const std::string& getAnswerString(std::string answerId); private: std::string name_; //!< name of the npc talking std::string currentQuestionId_; //!< id of the npc question currently active std::map questions_; //!< a map form the ids of npc textoptions to the objects containing them std::map answers_; //!< a map form the ids of npc textoptions to the objects containing them }; } #endif