aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2015-07-02 23:10:24 -0400
committerPaul Gilbert2015-07-02 23:10:24 -0400
commit8d7528c4ce1d938e3bf43b69f88a6a90f0e6d017 (patch)
tree597cad5352956972b406d9d1497dd689d1855d9b /engines
parent480003f48d0cb8fd0fa40cb8a3ebab8dc8597f8a (diff)
downloadscummvm-rg350-8d7528c4ce1d938e3bf43b69f88a6a90f0e6d017.tar.gz
scummvm-rg350-8d7528c4ce1d938e3bf43b69f88a6a90f0e6d017.tar.bz2
scummvm-rg350-8d7528c4ce1d938e3bf43b69f88a6a90f0e6d017.zip
SHERLOCK: RT: Implemented render method for talk dialog
Diffstat (limited to 'engines')
-rw-r--r--engines/sherlock/tattoo/tattoo_talk.h3
-rw-r--r--engines/sherlock/tattoo/tattoo_user_interface.cpp14
-rw-r--r--engines/sherlock/tattoo/tattoo_user_interface.h6
-rw-r--r--engines/sherlock/tattoo/widget_base.cpp52
-rw-r--r--engines/sherlock/tattoo/widget_base.h5
-rw-r--r--engines/sherlock/tattoo/widget_inventory.cpp57
-rw-r--r--engines/sherlock/tattoo/widget_inventory.h6
-rw-r--r--engines/sherlock/tattoo/widget_talk.cpp60
-rw-r--r--engines/sherlock/tattoo/widget_talk.h20
9 files changed, 142 insertions, 81 deletions
diff --git a/engines/sherlock/tattoo/tattoo_talk.h b/engines/sherlock/tattoo/tattoo_talk.h
index 252518c462..e2fa60b384 100644
--- a/engines/sherlock/tattoo/tattoo_talk.h
+++ b/engines/sherlock/tattoo/tattoo_talk.h
@@ -36,7 +36,10 @@ namespace Sherlock {
namespace Tattoo {
+class WidgetTalk;
+
class TattooTalk : public Talk {
+ friend class WidgetTalk;
private:
WidgetTalk _talkWidget;
diff --git a/engines/sherlock/tattoo/tattoo_user_interface.cpp b/engines/sherlock/tattoo/tattoo_user_interface.cpp
index 93290c67dd..2179dd132c 100644
--- a/engines/sherlock/tattoo/tattoo_user_interface.cpp
+++ b/engines/sherlock/tattoo/tattoo_user_interface.cpp
@@ -278,12 +278,6 @@ void TattooUserInterface::handleInput() {
case FILES_MODE:
doFileControl();
break;
- case VERB_MODE:
- doVerbControl();
- break;
- case TALK_MODE:
- doTalkControl();
- break;
case LAB_MODE:
doLabControl();
break;
@@ -527,14 +521,6 @@ void TattooUserInterface::doFileControl() {
warning("TODO: ui control (file)");
}
-void TattooUserInterface::doVerbControl() {
- _verbsWidget.handleEvents();
-}
-
-void TattooUserInterface::doTalkControl() {
- warning("TODO: ui control (talk)");
-}
-
void TattooUserInterface::doLabControl() {
warning("TODO: ui control (lab)");
}
diff --git a/engines/sherlock/tattoo/tattoo_user_interface.h b/engines/sherlock/tattoo/tattoo_user_interface.h
index ba98e5c59c..baf5cdcf25 100644
--- a/engines/sherlock/tattoo/tattoo_user_interface.h
+++ b/engines/sherlock/tattoo/tattoo_user_interface.h
@@ -74,12 +74,6 @@ private:
* Handle input while the verb menu is open
*/
void doVerbControl();
-
- /**
- * Handles input when in talk mode. It highlights the buttons and response statements,
- * and handles any actions for clicking on the buttons or statements.
- */
- void doTalkControl();
/**
* Handles input when the player is in the Lab Table scene
diff --git a/engines/sherlock/tattoo/widget_base.cpp b/engines/sherlock/tattoo/widget_base.cpp
index 00bc83d0f2..c33e9017d2 100644
--- a/engines/sherlock/tattoo/widget_base.cpp
+++ b/engines/sherlock/tattoo/widget_base.cpp
@@ -204,6 +204,58 @@ const Common::Point &WidgetBase::getCurrentScroll() const {
void WidgetBase::checkTabbingKeys(int numOptions) {
}
+
+void WidgetBase::drawScrollBar(int index, int pageSize, int count) {
+ TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui;
+ bool raised;
+
+ // Fill the area with transparency
+ Common::Rect r(BUTTON_SIZE, _bounds.height() - 6);
+ r.moveTo(_bounds.width() - BUTTON_SIZE - 3, 3);
+ _surface.fillRect(r, TRANSPARENCY);
+
+ raised = ui._scrollHighlight != 1;
+ _surface.fillRect(Common::Rect(r.left + 2, r.top + 2, r.right - 2, r.top + BUTTON_SIZE - 2), INFO_MIDDLE);
+ ui.drawDialogRect(_surface, Common::Rect(r.left, r.top, r.left + BUTTON_SIZE, r.top + BUTTON_SIZE), raised);
+
+ raised = ui._scrollHighlight != 5;
+ _surface.fillRect(Common::Rect(r.left + 2, r.bottom - BUTTON_SIZE + 2, r.right - 2, r.bottom - 2), INFO_MIDDLE);
+ ui.drawDialogRect(_surface, Common::Rect(r.left, r.bottom - BUTTON_SIZE, r.right, r.bottom), raised);
+
+ // Draw the arrows on the scroll buttons
+ byte color = index ? INFO_BOTTOM + 2 : INFO_BOTTOM;
+ _surface.hLine(r.right / 2, r.top - 2 + BUTTON_SIZE / 2, r.right / 2, color);
+ _surface.fillRect(Common::Rect(r.right / 2 - 1, r.top - 1 + BUTTON_SIZE / 2,
+ r.right / 2 + 1, r.top - 1 + BUTTON_SIZE / 2), color);
+ _surface.fillRect(Common::Rect(r.right / 2 - 2, r.top + BUTTON_SIZE / 2,
+ r.right / 2 + 2, r.top + BUTTON_SIZE / 2), color);
+ _surface.fillRect(Common::Rect(r.right / 2 - 3, r.top + 1 + BUTTON_SIZE / 2,
+ r.right / 2 + 3, r.top + 1 + BUTTON_SIZE / 2), color);
+
+ color = (index + NUM_INVENTORY_SHOWN) < count ? INFO_BOTTOM + 2 : INFO_BOTTOM;
+ _surface.fillRect(Common::Rect(r.right / 2 - 3, r.bottom - 1 - BUTTON_SIZE + BUTTON_SIZE / 2,
+ r.right / 2 + 3, r.bottom - 1 - BUTTON_SIZE + BUTTON_SIZE / 2), color);
+ _surface.fillRect(Common::Rect(r.right / 2 - 2, r.bottom - 1 - BUTTON_SIZE + 1 + BUTTON_SIZE / 2,
+ r.right / 2 + 2, r.bottom - 1 - BUTTON_SIZE + 1 + BUTTON_SIZE / 2), color);
+ _surface.fillRect(Common::Rect(r.right / 2 - 1, r.bottom - 1 - BUTTON_SIZE + 2 + BUTTON_SIZE / 2,
+ r.right / 2 + 1, r.bottom - 1 - BUTTON_SIZE + 2 + BUTTON_SIZE / 2), color);
+ _surface.fillRect(Common::Rect(r.right / 2, r.bottom - 1 - BUTTON_SIZE + 3 + BUTTON_SIZE / 2,
+ r.right / 2, r.bottom - 1 - BUTTON_SIZE + 3 + BUTTON_SIZE / 2), color);
+
+ // Draw the scroll position bar
+ int idx = count;
+ if (idx % (NUM_INVENTORY_SHOWN / 2))
+ idx = (idx + (NUM_INVENTORY_SHOWN / 2)) / (NUM_INVENTORY_SHOWN / 2) * (NUM_INVENTORY_SHOWN / 2);
+ int barHeight = NUM_INVENTORY_SHOWN * (_bounds.height() - BUTTON_SIZE * 2) / idx;
+ barHeight = CLIP(barHeight, BUTTON_SIZE, _bounds.height() - BUTTON_SIZE * 2);
+
+ int barY = (idx<= NUM_INVENTORY_SHOWN) ? r.top + BUTTON_SIZE :
+ (r.height() - BUTTON_SIZE * 2 - barHeight) * FIXED_INT_MULTIPLIER / (idx- NUM_INVENTORY_SHOWN)
+ * index / FIXED_INT_MULTIPLIER + r.top + BUTTON_SIZE;
+ _surface.fillRect(Common::Rect(r.left + 2, barY + 2, r.right - 2, barY + barHeight - 3), INFO_MIDDLE);
+ ui.drawDialogRect(_surface, Common::Rect(r.left, barY, r.right, barY + barHeight), true);
+}
+
} // End of namespace Tattoo
} // End of namespace Sherlock
diff --git a/engines/sherlock/tattoo/widget_base.h b/engines/sherlock/tattoo/widget_base.h
index 3bf3095faf..67a8332397 100644
--- a/engines/sherlock/tattoo/widget_base.h
+++ b/engines/sherlock/tattoo/widget_base.h
@@ -64,6 +64,11 @@ protected:
void makeInfoArea();
/**
+ * Draw the scrollbar for the dialog
+ */
+ void drawScrollBar(int index, int pageSize, int count);
+
+ /**
* Returns the current scroll position
*/
virtual const Common::Point &getCurrentScroll() const;
diff --git a/engines/sherlock/tattoo/widget_inventory.cpp b/engines/sherlock/tattoo/widget_inventory.cpp
index 1df0e995c5..bc2ae66ea0 100644
--- a/engines/sherlock/tattoo/widget_inventory.cpp
+++ b/engines/sherlock/tattoo/widget_inventory.cpp
@@ -257,7 +257,6 @@ WidgetInventory::WidgetInventory(SherlockEngine *vm) : WidgetBase(vm), _tooltipW
_selector = _oldSelector = -1;
_invVerbSelect = _oldInvVerbSelect = -1;
_dialogTimer = -1;
- _scrollHighlight = 0;
_swapItems = false;
}
@@ -350,59 +349,7 @@ void WidgetInventory::drawInventory() {
}
}
- drawScrollBar();
-}
-
-void WidgetInventory::drawScrollBar() {
- Inventory &inv = *_vm->_inventory;
- TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui;
- bool raised;
-
- // Fill the area with transparency
- Common::Rect r(BUTTON_SIZE, _bounds.height() - 6);
- r.moveTo(_bounds.width() - BUTTON_SIZE - 3, 3);
- _surface.fillRect(r, TRANSPARENCY);
-
- raised = ui._scrollHighlight != 1;
- _surface.fillRect(Common::Rect(r.left + 2, r.top + 2, r.right - 2, r.top + BUTTON_SIZE - 2), INFO_MIDDLE);
- ui.drawDialogRect(_surface, Common::Rect(r.left, r.top, r.left + BUTTON_SIZE, r.top + BUTTON_SIZE), raised);
-
- raised = ui._scrollHighlight != 5;
- _surface.fillRect(Common::Rect(r.left + 2, r.bottom - BUTTON_SIZE + 2, r.right - 2, r.bottom - 2), INFO_MIDDLE);
- ui.drawDialogRect(_surface, Common::Rect(r.left, r.bottom - BUTTON_SIZE, r.right, r.bottom), raised);
-
- // Draw the arrows on the scroll buttons
- byte color = inv._invIndex? INFO_BOTTOM + 2 : INFO_BOTTOM;
- _surface.hLine(r.right / 2, r.top - 2 + BUTTON_SIZE / 2, r.right / 2, color);
- _surface.fillRect(Common::Rect(r.right / 2 - 1, r.top - 1 + BUTTON_SIZE / 2,
- r.right / 2 + 1, r.top - 1 + BUTTON_SIZE / 2), color);
- _surface.fillRect(Common::Rect(r.right / 2 - 2, r.top + BUTTON_SIZE / 2,
- r.right / 2 + 2, r.top + BUTTON_SIZE / 2), color);
- _surface.fillRect(Common::Rect(r.right / 2 - 3, r.top + 1 + BUTTON_SIZE / 2,
- r.right / 2 + 3, r.top + 1 + BUTTON_SIZE / 2), color);
-
- color = (inv._invIndex + NUM_INVENTORY_SHOWN) < inv._holdings ? INFO_BOTTOM + 2 : INFO_BOTTOM;
- _surface.fillRect(Common::Rect(r.right / 2 - 3, r.bottom - 1 - BUTTON_SIZE + BUTTON_SIZE / 2,
- r.right / 2 + 3, r.bottom - 1 - BUTTON_SIZE + BUTTON_SIZE / 2), color);
- _surface.fillRect(Common::Rect(r.right / 2 - 2, r.bottom - 1 - BUTTON_SIZE + 1 + BUTTON_SIZE / 2,
- r.right / 2 + 2, r.bottom - 1 - BUTTON_SIZE + 1 + BUTTON_SIZE / 2), color);
- _surface.fillRect(Common::Rect(r.right / 2 - 1, r.bottom - 1 - BUTTON_SIZE + 2 + BUTTON_SIZE / 2,
- r.right / 2 + 1, r.bottom - 1 - BUTTON_SIZE + 2 + BUTTON_SIZE / 2), color);
- _surface.fillRect(Common::Rect(r.right / 2, r.bottom - 1 - BUTTON_SIZE + 3 + BUTTON_SIZE / 2,
- r.right / 2, r.bottom - 1 - BUTTON_SIZE + 3 + BUTTON_SIZE / 2), color);
-
- // Draw the scroll position bar
- int idx = inv._holdings;
- if (idx % (NUM_INVENTORY_SHOWN / 2))
- idx = (idx + (NUM_INVENTORY_SHOWN / 2)) / (NUM_INVENTORY_SHOWN / 2) * (NUM_INVENTORY_SHOWN / 2);
- int barHeight = NUM_INVENTORY_SHOWN * (_bounds.height() - BUTTON_SIZE * 2) / idx;
- barHeight = CLIP(barHeight, BUTTON_SIZE, _bounds.height() - BUTTON_SIZE * 2);
-
- int barY = (idx<= NUM_INVENTORY_SHOWN) ? r.top + BUTTON_SIZE :
- (r.height() - BUTTON_SIZE * 2 - barHeight) * FIXED_INT_MULTIPLIER / (idx- NUM_INVENTORY_SHOWN)
- * inv._invIndex / FIXED_INT_MULTIPLIER + r.top + BUTTON_SIZE;
- _surface.fillRect(Common::Rect(r.left + 2, barY + 2, r.right - 2, barY + barHeight - 3), INFO_MIDDLE);
- ui.drawDialogRect(_surface, Common::Rect(r.left, barY, r.right, barY + barHeight), true);
+ drawScrollBar(inv._invIndex, NUM_INVENTORY_SHOWN, inv._holdings);
}
void WidgetInventory::handleEvents() {
@@ -432,7 +379,7 @@ void WidgetInventory::handleEvents() {
// See if they released a mouse button button
if (events._released || events._rightReleased || ui._keyState.keycode == Common::KEYCODE_ESCAPE) {
_dialogTimer = -1;
- _scrollHighlight = 0;
+ ui._scrollHighlight = 0;
// See if they have a Verb List open for an Inventry Item
if (_invVerbMode == 1) {
diff --git a/engines/sherlock/tattoo/widget_inventory.h b/engines/sherlock/tattoo/widget_inventory.h
index 77caddf86b..365dff6299 100644
--- a/engines/sherlock/tattoo/widget_inventory.h
+++ b/engines/sherlock/tattoo/widget_inventory.h
@@ -69,7 +69,6 @@ private:
int _selector, _oldSelector;
int _invVerbSelect, _oldInvVerbSelect;
int _dialogTimer;
- int _scrollHighlight;
Common::StringArray _inventCommands;
WidgetInventoryTooltip _tooltipWidget;
Common::String _invVerb;
@@ -87,11 +86,6 @@ private:
void drawBars();
/**
- * Draw the scrollbar for the dialog
- */
- void drawScrollBar();
-
- /**
* Check for keys to mouse the mouse within the inventory dialog
*/
void checkInvTabbingKeys();
diff --git a/engines/sherlock/tattoo/widget_talk.cpp b/engines/sherlock/tattoo/widget_talk.cpp
index ed0f2d35c8..bfbf10e24f 100644
--- a/engines/sherlock/tattoo/widget_talk.cpp
+++ b/engines/sherlock/tattoo/widget_talk.cpp
@@ -31,8 +31,14 @@ namespace Sherlock {
namespace Tattoo {
+#define STATEMENT_NUM_X 6
+#define VISIBLE_TALK_LINES 6
+
WidgetTalk::WidgetTalk(SherlockEngine *vm) : WidgetBase(vm) {
_talkScroll = false;
+ _talkScrollIndex = 0;
+ _selector = _oldSelector = -1;
+ _talkTextX = 0;
}
void WidgetTalk::getTalkWindowSize() {
@@ -133,6 +139,60 @@ void WidgetTalk::load() {
}
}
+void WidgetTalk::handleEvents() {
+ // TODO
+}
+
+void WidgetTalk::render(Highlight highlightMode) {
+ TattooTalk &talk = *(TattooTalk *)_vm->_talk;
+ int yp = 5;
+ int statementNum = 1;
+ byte color;
+
+ if (highlightMode != HL_SCROLLBAR_ONLY) {
+ // Draw all the statements
+ // Check whether scrolling has occurred, and if so, figure out what the starting
+ // number for the first visible statement will be
+ if (_talkScrollIndex) {
+ for (int idx = 1; idx <= _talkScrollIndex; ++idx) {
+ if (_statementLines[idx - 1]._num != _statementLines[idx]._num)
+ ++statementNum;
+ }
+ }
+
+ // Main drawing loop
+ for (uint idx = _talkScrollIndex; idx < _statementLines.size() && yp < (_bounds.height() - _surface.fontHeight()); ++idx) {
+ if (highlightMode == HL_NO_HIGHLIGHTING || _statementLines[idx]._num == _selector ||
+ _statementLines[idx]._num == _oldSelector) {
+ // Different coloring based on whether the option has been previously chosen or not
+ color = (!talk._talkHistory[talk._converseNum][_statementLines[idx]._num]) ?
+ INFO_TOP : INFO_BOTTOM;
+
+ if (_statementLines[idx]._num == _selector && highlightMode == HL_CHANGED_HIGHLIGHTS)
+ color = COMMAND_HIGHLIGHTED;
+
+ // See if it's the start of a new statement, so needs the statement number to be displayed
+ if (!idx || _statementLines[idx]._num != _statementLines[idx - 1]._num) {
+ Common::String numStr = Common::String::format("%d.", statementNum);
+ _surface.writeString(numStr, Common::Point(STATEMENT_NUM_X, yp), color);
+ }
+
+ // Display the statement line
+ _surface.writeString(_statementLines[idx]._line, Common::Point(_talkTextX, yp), color);
+ }
+ yp += _surface.fontHeight() + 1;
+
+ // If the next line starts a new statement, then increment the statement number
+ if (idx == (_statementLines.size() - 1) || _statementLines[idx]._num != _statementLines[idx + 1]._num)
+ ++statementNum;
+ }
+ }
+
+ // See if the scroll bar needs to be drawn
+ if (_talkScroll && highlightMode != HL_CHANGED_HIGHLIGHTS)
+ drawScrollBar(_talkScrollIndex, VISIBLE_TALK_LINES, _statementLines.size());
+}
+
} // End of namespace Tattoo
} // End of namespace Sherlock
diff --git a/engines/sherlock/tattoo/widget_talk.h b/engines/sherlock/tattoo/widget_talk.h
index 12ac93bab9..c399f2f4c5 100644
--- a/engines/sherlock/tattoo/widget_talk.h
+++ b/engines/sherlock/tattoo/widget_talk.h
@@ -32,14 +32,29 @@ class SherlockEngine;
namespace Tattoo {
+enum Highlight { HL_NO_HIGHLIGHTING, HL_CHANGED_HIGHLIGHTS, HL_SCROLLBAR_ONLY };
+
/**
* Handles displaying a dialog with conversation options the player can select from
*/
class WidgetTalk: public WidgetBase {
+ struct StatementLine {
+ Common::String _line;
+ int _num;
+ };
private:
bool _talkScroll;
+ int _talkScrollIndex;
+ Common::Array<StatementLine> _statementLines;
+ int _selector, _oldSelector;
+ int _talkTextX;
void getTalkWindowSize();
+
+ /**
+ * Re-renders the contenst of the window to the widget's surface
+ */
+ void render(Highlight highlightMode);
public:
WidgetTalk(SherlockEngine *vm);
virtual ~WidgetTalk() {}
@@ -49,6 +64,11 @@ public:
* of appropriate size
*/
void load();
+
+ /**
+ * Handle event processing
+ */
+ virtual void handleEvents();
};
} // End of namespace Tattoo