From 0b873d74e0a607ddf460c91fc6e18d04c7fb7b8c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 31 Mar 2015 08:28:51 -0400 Subject: SHERLOCK: Implemented displayTalk --- engines/sherlock/screen.h | 3 +- engines/sherlock/talk.cpp | 95 ++++++++++++++++++++++++++++++++++++++++++++++- engines/sherlock/talk.h | 8 +++- 3 files changed, 102 insertions(+), 4 deletions(-) (limited to 'engines/sherlock') diff --git a/engines/sherlock/screen.h b/engines/sherlock/screen.h index 597c47c83a..edc0136471 100644 --- a/engines/sherlock/screen.h +++ b/engines/sherlock/screen.h @@ -49,7 +49,8 @@ enum { BUTTON_TOP = 233, BUTTON_MIDDLE = 244, BUTTON_BOTTOM = 248, - TALK_FOREGROUND = 12 + TALK_FOREGROUND = 12, + TALK_NULL = 16 }; class SherlockEngine; diff --git a/engines/sherlock/talk.cpp b/engines/sherlock/talk.cpp index e3c5ebc5e0..e915169903 100644 --- a/engines/sherlock/talk.cpp +++ b/engines/sherlock/talk.cpp @@ -22,6 +22,7 @@ #include "sherlock/talk.h" #include "sherlock/sherlock.h" +#include "sherlock/screen.h" namespace Sherlock { @@ -83,6 +84,7 @@ Talk::Talk(SherlockEngine *vm): _vm(vm) { _converseNum = -1; _talkStealth = 0; _talkToFlag = -1; + _moreTalkDown = _moreTalkUp = false; } /** @@ -405,6 +407,7 @@ void Talk::talkTo(const Common::String &filename) { } void Talk::talk(int objNum) { + // TODO } @@ -510,8 +513,98 @@ void Talk::drawInterface() { // TODO } -void Talk::displayTalk(bool slamIt) { +/** + * Display a list of statements in a window at the bottom of the scren that the + * player can select from. + */ +bool Talk::displayTalk(bool slamIt) { + Screen &screen = *_vm->_screen; + int yp = CONTROLS_Y + 14; + int lineY = -1; + _moreTalkDown = _moreTalkUp = false; + + for (uint idx = 0; idx < _statements.size(); ++idx) { + _statements[idx]._talkPos.top = _statements[idx]._talkPos.bottom = -1; + } + + if (_talkIndex) { + for (uint idx = 0; idx < _statements.size(); ++idx) { + if (_statements[idx]._talkMap != -1) + _moreTalkUp = true; + } + } + + // Display the up arrow if the first option is scrolled off-screen + if (_moreTalkUp) { + if (slamIt) { + screen.print(Common::Point(5, CONTROLS_Y + 13), INV_FOREGROUND, "~"); + screen.buttonPrint(Common::Point(159, CONTROLS_Y), COMMAND_FOREGROUND, true, "Up"); + } else { + screen.gPrint(Common::Point(5, CONTROLS_Y + 12), INV_FOREGROUND, "~"); + screen.buttonPrint(Common::Point(159, CONTROLS_Y), COMMAND_FOREGROUND, false, "Up"); + } + } else { + if (slamIt) { + screen.buttonPrint(Common::Point(159, CONTROLS_Y), COMMAND_NULL, true, "Up"); + screen.vgaBar(Common::Rect(5, CONTROLS_Y + 11, 15, CONTROLS_Y + 22), INV_BACKGROUND); + } else { + screen.buttonPrint(Common::Point(159, CONTROLS_Y), COMMAND_NULL, false, "Up"); + screen._backBuffer1.fillRect(Common::Rect(5, CONTROLS_Y + 11, + 15, CONTROLS_Y + 22), INV_BACKGROUND); + } + } + + // Loop through the statements + bool done = false; + for (uint idx = _talkIndex; idx < _statements.size() && !done; ++idx) { + Statement &statement = _statements[idx]; + + if (statement._talkMap != -1) { + bool flag = _talkHistory[_converseNum][idx]; + lineY = talkLine(idx, statement._talkMap, flag ? TALK_NULL : INV_FOREGROUND, + yp, slamIt); + + if (lineY != -1) { + statement._talkPos.top = yp; + yp = lineY; + statement._talkPos.bottom = yp; + + if (yp == SHERLOCK_SCREEN_HEIGHT) + done = true; + } else { + done = true; + } + } + } + + // Display the down arrow if there are more statements available + if (lineY == -1 || lineY == SHERLOCK_SCREEN_HEIGHT) { + _moreTalkDown = true; + + if (slamIt) { + screen.print(Common::Point(5, 190), INV_FOREGROUND, "|"); + screen.buttonPrint(Common::Point(200, CONTROLS_Y), COMMAND_FOREGROUND, true, "Down"); + } else { + screen.gPrint(Common::Point(5, 189), INV_FOREGROUND, "|"); + screen.buttonPrint(Common::Point(200, CONTROLS_Y), COMMAND_FOREGROUND, false, "Down"); + } + } else { + if (slamIt) { + screen.buttonPrint(Common::Point(200, CONTROLS_Y), COMMAND_NULL, true, "Down"); + screen.vgaBar(Common::Rect(5, 189, 16, 199), INV_BACKGROUND); + } else { + screen.buttonPrint(Common::Point(200, CONTROLS_Y), COMMAND_FOREGROUND, false, "Down"); + screen._backBuffer1.fillRect(Common::Rect(5, 189, 16, 199), INV_BACKGROUND); + } + } + + return done; +} + +int Talk::talkLine(int lineNum, int stateNum, byte color, int lineY, bool slamIt) { // TODO + return 0; } + } // End of namespace Sherlock diff --git a/engines/sherlock/talk.h b/engines/sherlock/talk.h index 6557f6eed6..d44419f9a9 100644 --- a/engines/sherlock/talk.h +++ b/engines/sherlock/talk.h @@ -25,6 +25,7 @@ #include "common/scummsys.h" #include "common/array.h" +#include "common/rect.h" #include "common/stream.h" #include "common/stack.h" @@ -45,6 +46,7 @@ struct Statement { int _portraitSide; int _quotient; int _talkMap; + Common::Rect _talkPos; void synchronize(Common::SeekableReadStream &s); }; @@ -59,7 +61,6 @@ struct TalkHistoryEntry { class SherlockEngine; class Talk { - private: SherlockEngine *_vm; int _saveSeqNum; @@ -74,6 +75,7 @@ private: int _converseNum; int _talkStealth; int _talkToFlag; + bool _moreTalkUp, _moreTalkDown; void pullSequence(); @@ -84,7 +86,9 @@ private: void stripVoiceCommands(); void setTalkMap(); - void displayTalk(bool slamIt); + bool displayTalk(bool slamIt); + + int talkLine(int lineNum, int stateNum, byte color, int lineY, bool slamIt); public: bool _talkToAbort; int _talkCounter; -- cgit v1.2.3