| [11579] | 1 | #ifndef _DialogManager_H__ |
|---|
| 2 | #define _DialogManager_H__ |
|---|
| 3 | |
|---|
| [11611] | 4 | #include "DialogPrereqs.h" |
|---|
| [11579] | 5 | #include "util/Singleton.h" |
|---|
| [11612] | 6 | #include "core/singleton/ScopedSingletonIncludes.h" |
|---|
| [11579] | 7 | #include "core/object/Listable.h" |
|---|
| 8 | #include "Dialog.h" |
|---|
| 9 | |
|---|
| [11612] | 10 | #include <string> |
|---|
| 11 | |
|---|
| 12 | namespace orxonox //tolua_export |
|---|
| 13 | |
|---|
| 14 | {//tolua_export |
|---|
| [11656] | 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 | |
|---|
| [11658] | 22 | @todo |
|---|
| 23 | reseting or setting new start for dialog on exit, to allow coming back to a npc |
|---|
| 24 | picture of person |
|---|
| 25 | parameters to differ dialog depending on some world values, like items, completed objectives etc... |
|---|
| [11656] | 26 | */ |
|---|
| 27 | |
|---|
| [11612] | 28 | class _OrxonoxExport DialogManager //tolua_export |
|---|
| 29 | : public Singleton<DialogManager> |
|---|
| 30 | {//tolua_export |
|---|
| [11579] | 31 | friend class Singleton<DialogManager>; |
|---|
| [11612] | 32 | |
|---|
| [11579] | 33 | public: |
|---|
| [11612] | 34 | |
|---|
| 35 | DialogManager(); |
|---|
| [11656] | 36 | |
|---|
| 37 | /** |
|---|
| 38 | @brief |
|---|
| 39 | gives the pointer to the sigleton dialog manager to the lua script |
|---|
| 40 | |
|---|
| 41 | @return |
|---|
| 42 | returns pointer |
|---|
| 43 | */ |
|---|
| 44 | |
|---|
| [11612] | 45 | static DialogManager& getInstance() { return Singleton<DialogManager>::getInstance(); } //tolua_export |
|---|
| [11579] | 46 | |
|---|
| [11656] | 47 | /** |
|---|
| 48 | @brief |
|---|
| 49 | allows to set the current dialog |
|---|
| 50 | |
|---|
| 51 | this is used by a dialog when triggered to set its self to the current dialog |
|---|
| 52 | |
|---|
| 53 | @param dialog |
|---|
| 54 | pointer to the dialog that wants to be current one |
|---|
| 55 | */ |
|---|
| [11612] | 56 | void setDialog(Dialog* dialog); |
|---|
| [11579] | 57 | |
|---|
| [11656] | 58 | //from here on functions for lua interface |
|---|
| [11579] | 59 | |
|---|
| [11656] | 60 | /** |
|---|
| 61 | @brief |
|---|
| 62 | gives the string of the momentary npc textoption |
|---|
| 63 | |
|---|
| 64 | @return |
|---|
| 65 | string of npc text |
|---|
| 66 | */ |
|---|
| [11612] | 67 | std::string getQuestion(); //tolua_export |
|---|
| [11644] | 68 | |
|---|
| [11656] | 69 | /** |
|---|
| 70 | @brief |
|---|
| 71 | function that returns size of answerid array |
|---|
| 72 | |
|---|
| 73 | @return |
|---|
| 74 | returns number of possible answers to momentary questions, 0 if there are no player text options |
|---|
| 75 | */ |
|---|
| [11642] | 76 | int getSize(); //tolua_export |
|---|
| [11644] | 77 | |
|---|
| [11656] | 78 | /** |
|---|
| 79 | @brief |
|---|
| 80 | returns the answer to the id that is at index in the array of answers |
|---|
| 81 | |
|---|
| 82 | @param param1 |
|---|
| 83 | index of desired answer |
|---|
| 84 | |
|---|
| 85 | @return |
|---|
| 86 | string of answer |
|---|
| 87 | */ |
|---|
| [11642] | 88 | std::string getAnswer(int index); //tolua_export |
|---|
| [11644] | 89 | |
|---|
| [11656] | 90 | /** |
|---|
| 91 | @brief |
|---|
| 92 | gives name of npc the player is currently talking to |
|---|
| 93 | |
|---|
| 94 | @return |
|---|
| 95 | sting with name |
|---|
| 96 | */ |
|---|
| [11642] | 97 | std::string getPerson(); //tolua_export |
|---|
| [11644] | 98 | |
|---|
| [11656] | 99 | /** |
|---|
| 100 | @brief |
|---|
| 101 | tests the dialog if there are any followup npc textoptions to the given answer or if there are no answers to the current question |
|---|
| 102 | |
|---|
| 103 | @return |
|---|
| 104 | true if the answer array of the question is empty or the next question id of the answer does not exist |
|---|
| 105 | */ |
|---|
| [11644] | 106 | bool endtest(int index); //tolua_export |
|---|
| 107 | |
|---|
| [11656] | 108 | /** |
|---|
| 109 | @brief |
|---|
| 110 | 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 |
|---|
| 111 | when called the current question of the dialog is set to the new one and the answerId vector is set accordingly |
|---|
| 112 | |
|---|
| 113 | @param param1 |
|---|
| 114 | index of the answer given by the player |
|---|
| 115 | |
|---|
| 116 | */ |
|---|
| [11642] | 117 | void update(int index); //tolua_export |
|---|
| [11611] | 118 | |
|---|
| [11612] | 119 | private: |
|---|
| [11656] | 120 | static DialogManager* singletonPtr_s; //!< a pointer to the single class object |
|---|
| [11611] | 121 | |
|---|
| [11656] | 122 | Dialog* currentTalk_; //!< pointer to the currently active dialog or last active if no one is currently active |
|---|
| 123 | const std::vector<std::string>* answerIds_; //!< pointer to the possible answerIds of the current question, for faster access |
|---|
| [11579] | 124 | |
|---|
| [11612] | 125 | };//tolua_export |
|---|
| 126 | }//tolua_export |
|---|
| [11579] | 127 | |
|---|
| 128 | #endif /* _DialogManager_H__ */ |
|---|