diff options
author | Ľubomír Remák | 2018-07-08 17:06:41 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2018-08-25 23:12:01 +0200 |
commit | 20d6d71ec97c1f7bc4b95ed6c98375b47dff6646 (patch) | |
tree | 527a0c509903ac64e9ea878aedd6421932bdd11c /engines/mutationofjb/widgets/conversationwidget.cpp | |
parent | f102667fc20d91149b685aac1bb5b05cabbc6e2b (diff) | |
download | scummvm-rg350-20d6d71ec97c1f7bc4b95ed6c98375b47dff6646.tar.gz scummvm-rg350-20d6d71ec97c1f7bc4b95ed6c98375b47dff6646.tar.bz2 scummvm-rg350-20d6d71ec97c1f7bc4b95ed6c98375b47dff6646.zip |
MUTATIONOFJB: Basic conversation support.
Diffstat (limited to 'engines/mutationofjb/widgets/conversationwidget.cpp')
-rw-r--r-- | engines/mutationofjb/widgets/conversationwidget.cpp | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/engines/mutationofjb/widgets/conversationwidget.cpp b/engines/mutationofjb/widgets/conversationwidget.cpp index c609fb4bfc..71a3483b75 100644 --- a/engines/mutationofjb/widgets/conversationwidget.cpp +++ b/engines/mutationofjb/widgets/conversationwidget.cpp @@ -25,6 +25,7 @@ #include "mutationofjb/gamedata.h" #include "mutationofjb/gui.h" #include "mutationofjb/font.h" +#include "common/events.h" namespace MutationOfJB { @@ -36,7 +37,8 @@ enum { ConversationWidget::ConversationWidget(Gui &gui, const Common::Rect &area, const Graphics::Surface &surface) : Widget(gui, area), - _surface(surface) {} + _surface(surface), + _callback(nullptr) {} void ConversationWidget::setLine(int lineNo, const Common::String &str) { @@ -58,7 +60,28 @@ void ConversationWidget::_draw(Graphics::ManagedSurface &surface) { } // TODO: Active line should be WHITE. - _gui.getGame().getSystemFont().drawString(line, LIGHTGRAY, CONVERSATION_LINES_X, CONVERSATION_LINES_Y + i * CONVERSATION_LINE_HEIGHT, surface); + _gui.getGame().getAssets().getSystemFont().drawString(line, LIGHTGRAY, CONVERSATION_LINES_X, CONVERSATION_LINES_Y + i * CONVERSATION_LINE_HEIGHT, surface); + } +} + +void ConversationWidget::handleEvent(const Common::Event &event) { + switch(event.type) { + case Common::EVENT_LBUTTONDOWN: + { + const int16 x = event.mouse.x; + const int16 y = event.mouse.y; + if (_area.contains(x, y)) { + if (_callback) { + int lineNum = (y - CONVERSATION_LINES_Y) / CONVERSATION_LINE_HEIGHT; + if (!_lines[lineNum].empty()) { + _callback->onResponseClicked(this, lineNum); + } + } + } + break; + } + default: + break; } } |