aboutsummaryrefslogtreecommitdiff
path: root/engines/mutationofjb/widgets
diff options
context:
space:
mode:
authorĽubomír Remák2018-07-08 17:06:41 +0200
committerEugene Sandulenko2018-08-25 23:12:01 +0200
commit20d6d71ec97c1f7bc4b95ed6c98375b47dff6646 (patch)
tree527a0c509903ac64e9ea878aedd6421932bdd11c /engines/mutationofjb/widgets
parentf102667fc20d91149b685aac1bb5b05cabbc6e2b (diff)
downloadscummvm-rg350-20d6d71ec97c1f7bc4b95ed6c98375b47dff6646.tar.gz
scummvm-rg350-20d6d71ec97c1f7bc4b95ed6c98375b47dff6646.tar.bz2
scummvm-rg350-20d6d71ec97c1f7bc4b95ed6c98375b47dff6646.zip
MUTATIONOFJB: Basic conversation support.
Diffstat (limited to 'engines/mutationofjb/widgets')
-rw-r--r--engines/mutationofjb/widgets/conversationwidget.cpp27
-rw-r--r--engines/mutationofjb/widgets/conversationwidget.h15
2 files changed, 38 insertions, 4 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;
}
}
diff --git a/engines/mutationofjb/widgets/conversationwidget.h b/engines/mutationofjb/widgets/conversationwidget.h
index 0f26a99d3f..b404abc198 100644
--- a/engines/mutationofjb/widgets/conversationwidget.h
+++ b/engines/mutationofjb/widgets/conversationwidget.h
@@ -28,21 +28,32 @@
namespace MutationOfJB {
+class ConversationWidget;
+
+class ConversationWidgetCallback {
+public:
+ virtual ~ConversationWidgetCallback() {}
+ virtual void onResponseClicked(ConversationWidget *, int response) = 0;
+};
+
class ConversationWidget : public Widget {
public:
enum { CONVERSATION_LINES = 4 };
ConversationWidget(Gui &gui, const Common::Rect &area, const Graphics::Surface &surface);
+ void setCallback(ConversationWidgetCallback *callback) { _callback = callback; }
void setLine(int lineNo, const Common::String &str);
+ virtual void handleEvent(const Common::Event &event) override;
+
protected:
- void _draw(Graphics::ManagedSurface &surface);
+ virtual void _draw(Graphics::ManagedSurface &surface) override;
private:
-
Graphics::Surface _surface;
Common::String _lines[CONVERSATION_LINES];
+ ConversationWidgetCallback *_callback;
};
}