diff options
| author | Ľubomír Remák | 2018-07-15 00:18:54 +0200 |
|---|---|---|
| committer | Eugene Sandulenko | 2018-08-25 23:12:01 +0200 |
| commit | febff83a4edc89e1dbc6f4c56f5531f0eb8f3287 (patch) | |
| tree | 756129c1736a39aad5473d7873810a3a742911ae /engines/mutationofjb/widgets | |
| parent | d2e354b51f637dc2e9b251256b5a017cb41cfe59 (diff) | |
| download | scummvm-rg350-febff83a4edc89e1dbc6f4c56f5531f0eb8f3287.tar.gz scummvm-rg350-febff83a4edc89e1dbc6f4c56f5531f0eb8f3287.tar.bz2 scummvm-rg350-febff83a4edc89e1dbc6f4c56f5531f0eb8f3287.zip | |
MUTATIONOFJB: Draw objects (first frame only) and improve conversation support.
Diffstat (limited to 'engines/mutationofjb/widgets')
| -rw-r--r-- | engines/mutationofjb/widgets/conversationwidget.cpp | 29 | ||||
| -rw-r--r-- | engines/mutationofjb/widgets/conversationwidget.h | 12 |
2 files changed, 27 insertions, 14 deletions
diff --git a/engines/mutationofjb/widgets/conversationwidget.cpp b/engines/mutationofjb/widgets/conversationwidget.cpp index 71a3483b75..a46b9c50f8 100644 --- a/engines/mutationofjb/widgets/conversationwidget.cpp +++ b/engines/mutationofjb/widgets/conversationwidget.cpp @@ -41,26 +41,35 @@ ConversationWidget::ConversationWidget(Gui &gui, const Common::Rect &area, const _callback(nullptr) {} -void ConversationWidget::setLine(int lineNo, const Common::String &str) { - if (lineNo >= CONVERSATION_LINES) { +void ConversationWidget::setChoice(int choiceNo, const Common::String &str, uint32 data) { + if (choiceNo >= CONVERSATION_MAX_CHOICES) { return; } - _lines[lineNo] = str; + _choices[choiceNo]._str = str; + _choices[choiceNo]._data = data; + markDirty(); +} + +void ConversationWidget::clearChoices() { + for (int i = 0; i < CONVERSATION_MAX_CHOICES; ++i) { + _choices[i]._str.clear(); + _choices[i]._data = 0; + } markDirty(); } void ConversationWidget::_draw(Graphics::ManagedSurface &surface) { surface.blitFrom(_surface, Common::Point(_area.left, _area.top)); - for (int i = 0; i < CONVERSATION_LINES; ++i) { - Common::String &line = _lines[i]; - if (line.empty()) { + for (int i = 0; i < CONVERSATION_MAX_CHOICES; ++i) { + Common::String &str = _choices[i]._str; + if (str.empty()) { continue; } // TODO: Active line should be WHITE. - _gui.getGame().getAssets().getSystemFont().drawString(line, LIGHTGRAY, CONVERSATION_LINES_X, CONVERSATION_LINES_Y + i * CONVERSATION_LINE_HEIGHT, surface); + _gui.getGame().getAssets().getSystemFont().drawString(str, LIGHTGRAY, CONVERSATION_LINES_X, CONVERSATION_LINES_Y + i * CONVERSATION_LINE_HEIGHT, surface); } } @@ -72,9 +81,9 @@ void ConversationWidget::handleEvent(const Common::Event &event) { 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); + int choiceNo = (y - CONVERSATION_LINES_Y) / CONVERSATION_LINE_HEIGHT; + if (!_choices[choiceNo]._str.empty()) { + _callback->onChoiceClicked(this, choiceNo, _choices[choiceNo]._data); } } } diff --git a/engines/mutationofjb/widgets/conversationwidget.h b/engines/mutationofjb/widgets/conversationwidget.h index b404abc198..51ea86ed02 100644 --- a/engines/mutationofjb/widgets/conversationwidget.h +++ b/engines/mutationofjb/widgets/conversationwidget.h @@ -33,17 +33,18 @@ class ConversationWidget; class ConversationWidgetCallback { public: virtual ~ConversationWidgetCallback() {} - virtual void onResponseClicked(ConversationWidget *, int response) = 0; + virtual void onChoiceClicked(ConversationWidget *, int choiceNo, uint32 data) = 0; }; class ConversationWidget : public Widget { public: - enum { CONVERSATION_LINES = 4 }; + enum { CONVERSATION_MAX_CHOICES = 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); + void setChoice(int choiceNo, const Common::String &str, uint32 data = 0); + void clearChoices(); virtual void handleEvent(const Common::Event &event) override; @@ -52,7 +53,10 @@ protected: private: Graphics::Surface _surface; - Common::String _lines[CONVERSATION_LINES]; + struct ChoiceInfo { + Common::String _str; + uint32 _data; + } _choices[CONVERSATION_MAX_CHOICES]; ConversationWidgetCallback *_callback; }; |
