| 1 | #include "DialogManager.h" |
|---|
| 2 | #include "core/CoreIncludes.h" |
|---|
| 3 | #include "core/singleton/ScopedSingletonIncludes.h" |
|---|
| 4 | #include <string> |
|---|
| 5 | |
|---|
| 6 | namespace orxonox { |
|---|
| 7 | ManageScopedSingleton(DialogManager, ScopeID::ROOT, false); |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | DialogManager::DialogManager() |
|---|
| 12 | { |
|---|
| 13 | this->currentTalk_ = nullptr; |
|---|
| 14 | } |
|---|
| 15 | |
|---|
| 16 | void DialogManager::setDialog(Dialog* dialog) |
|---|
| 17 | { |
|---|
| 18 | this->currentTalk_ = dialog; |
|---|
| 19 | answerIds_ = currentTalk_->getAnswerIds(); |
|---|
| 20 | } |
|---|
| 21 | |
|---|
| 22 | //from here onward funcionality for lua axports |
|---|
| 23 | |
|---|
| 24 | std::string DialogManager::getQuestion() |
|---|
| 25 | { |
|---|
| 26 | return this->currentTalk_->getQuestionString(); |
|---|
| 27 | } |
|---|
| 28 | |
|---|
| 29 | int DialogManager::getSize() |
|---|
| 30 | { |
|---|
| 31 | return this->answerIds_->size(); |
|---|
| 32 | } |
|---|
| 33 | |
|---|
| 34 | std::string DialogManager::getAnswer(int index) |
|---|
| 35 | { |
|---|
| 36 | return this->currentTalk_->getAnswerString(this->answerIds_->at(index)); |
|---|
| 37 | } |
|---|
| 38 | |
|---|
| 39 | std::string DialogManager::getPerson() |
|---|
| 40 | { |
|---|
| 41 | return this->currentTalk_->getName(); |
|---|
| 42 | } |
|---|
| 43 | |
|---|
| 44 | bool DialogManager::endtest(int index) |
|---|
| 45 | { |
|---|
| 46 | if(this->answerIds_->empty()) |
|---|
| 47 | { |
|---|
| 48 | return true; |
|---|
| 49 | } |
|---|
| 50 | else |
|---|
| 51 | { |
|---|
| 52 | return this->currentTalk_->ending(this->answerIds_->at(index)); |
|---|
| 53 | } |
|---|
| 54 | |
|---|
| 55 | } |
|---|
| 56 | |
|---|
| 57 | void DialogManager::update(int index) |
|---|
| 58 | { |
|---|
| 59 | this->currentTalk_->update(answerIds_->at(index)); |
|---|
| 60 | answerIds_ = this->currentTalk_->getAnswerIds(); |
|---|
| 61 | } |
|---|
| 62 | } |
|---|