diff options
Diffstat (limited to 'engines/mutationofjb/tasks/conversationtask.cpp')
-rw-r--r-- | engines/mutationofjb/tasks/conversationtask.cpp | 54 |
1 files changed, 49 insertions, 5 deletions
diff --git a/engines/mutationofjb/tasks/conversationtask.cpp b/engines/mutationofjb/tasks/conversationtask.cpp index 512b38b710..47f27df247 100644 --- a/engines/mutationofjb/tasks/conversationtask.cpp +++ b/engines/mutationofjb/tasks/conversationtask.cpp @@ -27,11 +27,14 @@ #include "mutationofjb/game.h" #include "mutationofjb/gamedata.h" #include "mutationofjb/gui.h" +#include "mutationofjb/script.h" #include "mutationofjb/tasks/saytask.h" #include "mutationofjb/tasks/taskmanager.h" #include "mutationofjb/util.h" #include "mutationofjb/widgets/conversationwidget.h" +#include "common/translation.h" + namespace MutationOfJB { void ConversationTask::start() { @@ -69,11 +72,11 @@ void ConversationTask::update() { break; } case SAYING_RESPONSE: { - if (_currentItem->_nextLineIndex == 0) { - finish(); - } else { - _currentLineIndex = _currentItem->_nextLineIndex - 1; - showChoicesOrPick(); + startExtra(); + + if (_substate != RUNNING_EXTRA) + { + gotoNextLine(); } break; } @@ -82,6 +85,16 @@ void ConversationTask::update() { } } } + + if (_innerExecCtx) { + Command::ExecuteResult res = _innerExecCtx->runActiveCommand(); + if (res == Command::Finished) { + delete _innerExecCtx; + _innerExecCtx = nullptr; + + gotoNextLine(); + } + } } void ConversationTask::onChoiceClicked(ConversationWidget *convWidget, int, uint32 data) { @@ -203,4 +216,35 @@ void ConversationTask::finish() { game.getGui().markDirty(); // TODO: Handle automatically when changing visibility. } +void ConversationTask::startExtra() { + const ConversationLineList& responseList = getTaskManager()->getGame().getAssets().getResponseList(); + const ConversationLineList::Line *const line = responseList.getLine(_currentItem->_response); + if (!line->_extra.empty()) { + _innerExecCtx = new ScriptExecutionContext(getTaskManager()->getGame()); + Command *const extraCmd = _innerExecCtx->getExtra(line->_extra); + if (extraCmd) { + Command::ExecuteResult res = _innerExecCtx->startCommand(extraCmd); + if (res == Command::InProgress) { + _substate = RUNNING_EXTRA; + } else { + delete _innerExecCtx; + _innerExecCtx = nullptr; + } + } else { + warning(_("Extra '%s' not found"), line->_extra.c_str()); + delete _innerExecCtx; + _innerExecCtx = nullptr; + } + } +} + +void ConversationTask::gotoNextLine() { + if (_currentItem->_nextLineIndex == 0) { + finish(); + } else { + _currentLineIndex = _currentItem->_nextLineIndex - 1; + showChoicesOrPick(); + } +} + } |