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