/* * ORXONOX - the hottest 3D action shooter ever to exist * > www.orxonox.net < * * * License notice: * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * Author: * ... * Co-authors: * ... * */ #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 Question* getQuestion(unsigned int index) const; //xmlPort-Funktion void addAnswer(Answer* answer); //xmlPort-Funktion, adds answer to map Answer* getAnswer(unsigned int index) const; //xmlPort-Funktion /** @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() const; /** @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(const 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