[Orxonox-commit 7037] r11656 - code/branches/Dialog_HS17/src/modules/dialog
kuchlert at orxonox.net
kuchlert at orxonox.net
Mon Dec 11 15:35:50 CET 2017
Author: kuchlert
Date: 2017-12-11 15:35:50 +0100 (Mon, 11 Dec 2017)
New Revision: 11656
Modified:
code/branches/Dialog_HS17/src/modules/dialog/Answer.h
code/branches/Dialog_HS17/src/modules/dialog/AnswerId.h
code/branches/Dialog_HS17/src/modules/dialog/Dialog.h
code/branches/Dialog_HS17/src/modules/dialog/DialogManager.h
code/branches/Dialog_HS17/src/modules/dialog/Question.h
Log:
fertig kommentierte version
Modified: code/branches/Dialog_HS17/src/modules/dialog/Answer.h
===================================================================
--- code/branches/Dialog_HS17/src/modules/dialog/Answer.h 2017-12-11 14:24:03 UTC (rev 11655)
+++ code/branches/Dialog_HS17/src/modules/dialog/Answer.h 2017-12-11 14:35:50 UTC (rev 11656)
@@ -9,7 +9,13 @@
namespace orxonox
{
-
+ /**
+ @brief
+ class containing the pc side of the Dialog
+
+ 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
+ */
+
class _DialogExport Answer : public BaseObject
{
public:
@@ -27,9 +33,9 @@
const std::string& getAnswer() const; //xmlPort-Funktion, gibt Antworttext
private:
- std::string answerId_;
- std::string answer_;
- std::string nextQuestionId_;
+ std::string answerId_; //!< id of the pc textoption
+ std::string answer_; //!< string with the pc text
+ std::string nextQuestionId_; //!< id of the npc reaction to pc answer
};
}
Modified: code/branches/Dialog_HS17/src/modules/dialog/AnswerId.h
===================================================================
--- code/branches/Dialog_HS17/src/modules/dialog/AnswerId.h 2017-12-11 14:24:03 UTC (rev 11655)
+++ code/branches/Dialog_HS17/src/modules/dialog/AnswerId.h 2017-12-11 14:35:50 UTC (rev 11656)
@@ -8,6 +8,13 @@
#include <string>
namespace orxonox{
+
+ /**
+ @brief
+ container class for answerids in xml
+
+ */
+
class AnswerId : public BaseObject
{
public:
@@ -19,7 +26,7 @@
const std::string& getId() const; //allows to get Id, used in xmlPort
private:
- std::string id_;
+ std::string id_; //!< id of one answer
};
}
Modified: code/branches/Dialog_HS17/src/modules/dialog/Dialog.h
===================================================================
--- code/branches/Dialog_HS17/src/modules/dialog/Dialog.h 2017-12-11 14:24:03 UTC (rev 11655)
+++ code/branches/Dialog_HS17/src/modules/dialog/Dialog.h 2017-12-11 14:35:50 UTC (rev 11656)
@@ -15,6 +15,15 @@
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:
@@ -23,35 +32,85 @@
virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
- void setName(const std::string& name); //xmlPort-Funktion, setzt Namen
- const std::string& getName() const; //xmlPort-Funktion, returnt Namen
+ 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, setzt string Id der momentanen Frage
- const std::string& getCurrentQuestionId() const; //xmlPort-Funktion, gibt Id der momentanen Frage
+ 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, fuegt Question der Map hinzu
- const Question* getQuestion() const; //xmlPort-Funktion, returnt nullptr
+ void addQuestion(Question* question); //xmlPort-Funktion, adds question to map
+ const Question* getQuestion() const; //xmlPort-Funktion, returns nullptr
- void addAnswer(Answer* answer); //xmlPort-Funktion, fuegt Answer der Map hinzu
- const Answer* getAnswer(unsigned int index) const; //xmlPort-Funktion, returnt 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
- const std::vector<std::string>* getAnswerIds(); // returned Pointer auf Vector mit allen momentanen AntwortenIds
+ @return
+ pointer to answerId array of question
+ */
+ const std::vector<std::string>* getAnswerIds();
- bool execute(bool bTriggered, BaseObject* trigger); // funktion die aufgerufen wird wenn der im xml verbundene Trigger aktiviert wird
+ /**
+ @brief
+ function called when the trigger object defined in the xml file sets to triggered
- void update(const std::string& givenAnswerId); //setzt die naechste Frage entsprechend der gegebenen antwortId
+ @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);
- bool ending(const std::string& givenAnswerId); //ist true falls fuer die gegebene AntwortId keine Frage zur FragenId der Antwort existiert
+ /**
+ @brief
+ updates the current Dialog according to the id of a given answer, by setting currentQuestionId to the next one
- const std::string& getQuestionString(); //gibt string der momentanen Frage
- const std::string& getAnswerString(std::string answerId); //gibt string der zur Id passenden Frage
+ @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_;
- std::string currentQuestionId_;
- std::map<std::string, Question*> questions_;
- std::map<std::string, Answer*> answers_;
+ std::string name_; //!< name of the npc talking
+ std::string currentQuestionId_; //!< id of the npc question currently active
+ std::map<std::string, Question*> questions_; //!< a map form the ids of npc textoptions to the objects containing them
+ std::map<std::string, Answer*> answers_; //!< a map form the ids of npc textoptions to the objects containing them
};
}
Modified: code/branches/Dialog_HS17/src/modules/dialog/DialogManager.h
===================================================================
--- code/branches/Dialog_HS17/src/modules/dialog/DialogManager.h 2017-12-11 14:24:03 UTC (rev 11655)
+++ code/branches/Dialog_HS17/src/modules/dialog/DialogManager.h 2017-12-11 14:35:50 UTC (rev 11656)
@@ -12,6 +12,15 @@
namespace orxonox //tolua_export
{//tolua_export
+
+ /**
+ @brief
+ this class is used for calling on a dialog form luascript
+
+ 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
+
+ */
+
class _OrxonoxExport DialogManager //tolua_export
: public Singleton<DialogManager>
{//tolua_export
@@ -20,38 +29,94 @@
public:
DialogManager();
-
- //gibt lua den pointer auf den Manager
+
+ /**
+ @brief
+ gives the pointer to the sigleton dialog manager to the lua script
+
+ @return
+ returns pointer
+ */
+
static DialogManager& getInstance() { return Singleton<DialogManager>::getInstance(); } //tolua_export
- //setzt den momentanen Dialog auf den uebergebenen, wird vom Dialog verwendet um bei Trigger event sich selbst zu setzen
+ /**
+ @brief
+ allows to set the current dialog
+
+ this is used by a dialog when triggered to set its self to the current dialog
+
+ @param dialog
+ pointer to the dialog that wants to be current one
+ */
void setDialog(Dialog* dialog);
- //von hier an sind lua funktionalitaeten definiert
+ //from here on functions for lua interface
- //gibt den string der momentanen Frage des Dialogs
+ /**
+ @brief
+ gives the string of the momentary npc textoption
+
+ @return
+ string of npc text
+ */
std::string getQuestion(); //tolua_export
- //gibt die laenge des Antwort-arrays der momentanen zuruek, 0 falls es leer ist
+ /**
+ @brief
+ function that returns size of answerid array
+
+ @return
+ returns number of possible answers to momentary questions, 0 if there are no player text options
+ */
int getSize(); //tolua_export
- //gibt den sting zu einer Frage im antwortarray der momentanen Frage
+ /**
+ @brief
+ returns the answer to the id that is at index in the array of answers
+
+ @param param1
+ index of desired answer
+
+ @return
+ string of answer
+ */
std::string getAnswer(int index); //tolua_export
- //gibt den Namen der Person mit der man spricht
+ /**
+ @brief
+ gives name of npc the player is currently talking to
+
+ @return
+ sting with name
+ */
std::string getPerson(); //tolua_export
- //testet ob der dialog weiter geht, true wenn es keine weitere Frage nach der Antwort kommt oder keine Antwort zur Frage existiert
+ /**
+ @brief
+ tests the dialog if there are any followup npc textoptions to the given answer or if there are no answers to the current question
+
+ @return
+ true if the answer array of the question is empty or the next question id of the answer does not exist
+ */
bool endtest(int index); //tolua_export
- //updated den Dialog so dass er auf die Antwort die im Antwortvector am index steht reagiert
+ /**
+ @brief
+ 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
+ when called the current question of the dialog is set to the new one and the answerId vector is set accordingly
+
+ @param param1
+ index of the answer given by the player
+
+ */
void update(int index); //tolua_export
private:
- static DialogManager* singletonPtr_s;
+ static DialogManager* singletonPtr_s; //!< a pointer to the single class object
- Dialog* currentTalk_;
- const std::vector<std::string>* answerIds_;
+ Dialog* currentTalk_; //!< pointer to the currently active dialog or last active if no one is currently active
+ const std::vector<std::string>* answerIds_; //!< pointer to the possible answerIds of the current question, for faster access
};//tolua_export
}//tolua_export
Modified: code/branches/Dialog_HS17/src/modules/dialog/Question.h
===================================================================
--- code/branches/Dialog_HS17/src/modules/dialog/Question.h 2017-12-11 14:24:03 UTC (rev 11655)
+++ code/branches/Dialog_HS17/src/modules/dialog/Question.h 2017-12-11 14:35:50 UTC (rev 11656)
@@ -12,6 +12,14 @@
namespace orxonox
{
+
+ /**
+ @brief
+ class containing the npc side of the Dialog
+
+ this class contains one possible text option of the npc, it's id and the ids of possible player reactions (answers)
+ */
+
class _DialogExport Question : public BaseObject
{
public:
@@ -28,14 +36,21 @@
void addAnswerId(AnswerId* answerId); //xmlPort-Funktion, nimmt AnswerIds von entsprechenden Objekten und fuegt sie in List ein.
const AnswerId* getAnswerId() const; //xmlPort-Funktion, gibt nichts zuruek
+ /**
+ @brief
+ gives pointer to possivle answerIds of this question
+
+ @return
+ returns pointer to the array with ids of possible pc textoptions
+ */
const std::vector<std::string>* getAnswerIds(); //returnt Pointer auf Vektor mit allen Ids
- private:
- std::string questionId_;
- std::string question_;
- std::vector<std::string> answerIds_;
+ private:
+ std::string questionId_; //!< id of npc textoption
+ std::string question_; //!< string with npc text
+ std::vector<std::string> answerIds_; //!< vector with possible player reactions
};
}
More information about the Orxonox-commit
mailing list