[11749] | 1 | /* |
---|
| 2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
| 3 | * > www.orxonox.net < |
---|
| 4 | * |
---|
| 5 | * |
---|
| 6 | * License notice: |
---|
| 7 | * |
---|
| 8 | * This program is free software; you can redistribute it and/or |
---|
| 9 | * modify it under the terms of the GNU General Public License |
---|
| 10 | * as published by the Free Software Foundation; either version 2 |
---|
| 11 | * of the License, or (at your option) any later version. |
---|
| 12 | * |
---|
| 13 | * This program is distributed in the hope that it will be useful, |
---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 16 | * GNU General Public License for more details. |
---|
| 17 | * |
---|
| 18 | * You should have received a copy of the GNU General Public License |
---|
| 19 | * along with this program; if not, write to the Free Software |
---|
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
| 21 | * |
---|
| 22 | * Author: |
---|
| 23 | * ... |
---|
| 24 | * Co-authors: |
---|
| 25 | * ... |
---|
| 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
[11579] | 29 | #ifndef _DialogManager_H__ |
---|
| 30 | #define _DialogManager_H__ |
---|
| 31 | |
---|
[11611] | 32 | #include "DialogPrereqs.h" |
---|
[11579] | 33 | #include "util/Singleton.h" |
---|
[11612] | 34 | #include "core/singleton/ScopedSingletonIncludes.h" |
---|
[11579] | 35 | #include "core/object/Listable.h" |
---|
| 36 | #include "Dialog.h" |
---|
| 37 | |
---|
[11612] | 38 | #include <string> |
---|
| 39 | |
---|
| 40 | namespace orxonox //tolua_export |
---|
| 41 | |
---|
| 42 | {//tolua_export |
---|
[11656] | 43 | |
---|
| 44 | /** |
---|
| 45 | @brief |
---|
| 46 | this class is used for calling on a dialog form luascript |
---|
| 47 | |
---|
| 48 | 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 |
---|
| 49 | |
---|
[11658] | 50 | @todo |
---|
| 51 | reseting or setting new start for dialog on exit, to allow coming back to a npc |
---|
| 52 | picture of person |
---|
| 53 | parameters to differ dialog depending on some world values, like items, completed objectives etc... |
---|
[11656] | 54 | */ |
---|
| 55 | |
---|
[11748] | 56 | class _DialogExport DialogManager //tolua_export |
---|
[11612] | 57 | : public Singleton<DialogManager> |
---|
| 58 | {//tolua_export |
---|
[11579] | 59 | friend class Singleton<DialogManager>; |
---|
[11612] | 60 | |
---|
[11579] | 61 | public: |
---|
[11612] | 62 | |
---|
| 63 | DialogManager(); |
---|
[11656] | 64 | |
---|
| 65 | /** |
---|
| 66 | @brief |
---|
| 67 | gives the pointer to the sigleton dialog manager to the lua script |
---|
| 68 | |
---|
| 69 | @return |
---|
| 70 | returns pointer |
---|
| 71 | */ |
---|
| 72 | |
---|
[11612] | 73 | static DialogManager& getInstance() { return Singleton<DialogManager>::getInstance(); } //tolua_export |
---|
[11579] | 74 | |
---|
[11656] | 75 | /** |
---|
| 76 | @brief |
---|
| 77 | allows to set the current dialog |
---|
| 78 | |
---|
| 79 | this is used by a dialog when triggered to set its self to the current dialog |
---|
| 80 | |
---|
| 81 | @param dialog |
---|
| 82 | pointer to the dialog that wants to be current one |
---|
| 83 | */ |
---|
[11612] | 84 | void setDialog(Dialog* dialog); |
---|
[11579] | 85 | |
---|
[11656] | 86 | //from here on functions for lua interface |
---|
[11579] | 87 | |
---|
[11656] | 88 | /** |
---|
| 89 | @brief |
---|
| 90 | gives the string of the momentary npc textoption |
---|
| 91 | |
---|
| 92 | @return |
---|
| 93 | string of npc text |
---|
| 94 | */ |
---|
[11612] | 95 | std::string getQuestion(); //tolua_export |
---|
[11644] | 96 | |
---|
[11656] | 97 | /** |
---|
| 98 | @brief |
---|
| 99 | function that returns size of answerid array |
---|
| 100 | |
---|
| 101 | @return |
---|
| 102 | returns number of possible answers to momentary questions, 0 if there are no player text options |
---|
| 103 | */ |
---|
[11642] | 104 | int getSize(); //tolua_export |
---|
[11644] | 105 | |
---|
[11656] | 106 | /** |
---|
| 107 | @brief |
---|
| 108 | returns the answer to the id that is at index in the array of answers |
---|
| 109 | |
---|
| 110 | @param param1 |
---|
| 111 | index of desired answer |
---|
| 112 | |
---|
| 113 | @return |
---|
| 114 | string of answer |
---|
| 115 | */ |
---|
[11642] | 116 | std::string getAnswer(int index); //tolua_export |
---|
[11644] | 117 | |
---|
[11656] | 118 | /** |
---|
| 119 | @brief |
---|
| 120 | gives name of npc the player is currently talking to |
---|
| 121 | |
---|
| 122 | @return |
---|
| 123 | sting with name |
---|
| 124 | */ |
---|
[11642] | 125 | std::string getPerson(); //tolua_export |
---|
[11644] | 126 | |
---|
[11656] | 127 | /** |
---|
| 128 | @brief |
---|
| 129 | tests the dialog if there are any followup npc textoptions to the given answer or if there are no answers to the current question |
---|
| 130 | |
---|
| 131 | @return |
---|
| 132 | true if the answer array of the question is empty or the next question id of the answer does not exist |
---|
| 133 | */ |
---|
[11644] | 134 | bool endtest(int index); //tolua_export |
---|
| 135 | |
---|
[11656] | 136 | /** |
---|
| 137 | @brief |
---|
| 138 | 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 |
---|
| 139 | when called the current question of the dialog is set to the new one and the answerId vector is set accordingly |
---|
| 140 | |
---|
| 141 | @param param1 |
---|
| 142 | index of the answer given by the player |
---|
| 143 | |
---|
| 144 | */ |
---|
[11642] | 145 | void update(int index); //tolua_export |
---|
[11611] | 146 | |
---|
[11612] | 147 | private: |
---|
[11656] | 148 | static DialogManager* singletonPtr_s; //!< a pointer to the single class object |
---|
[11611] | 149 | |
---|
[11656] | 150 | Dialog* currentTalk_; //!< pointer to the currently active dialog or last active if no one is currently active |
---|
| 151 | const std::vector<std::string>* answerIds_; //!< pointer to the possible answerIds of the current question, for faster access |
---|
[11579] | 152 | |
---|
[11612] | 153 | };//tolua_export |
---|
| 154 | }//tolua_export |
---|
[11579] | 155 | |
---|
[11748] | 156 | #endif /* _DialogManager_H__ */ |
---|