diff options
-rw-r--r-- | engines/sherlock/module.mk | 1 | ||||
-rw-r--r-- | engines/sherlock/talk.h | 2 | ||||
-rw-r--r-- | engines/sherlock/tattoo/tattoo_talk.cpp | 5 | ||||
-rw-r--r-- | engines/sherlock/tattoo/tattoo_talk.h | 6 | ||||
-rw-r--r-- | engines/sherlock/tattoo/widget_talk.cpp | 138 | ||||
-rw-r--r-- | engines/sherlock/tattoo/widget_talk.h | 58 |
6 files changed, 205 insertions, 5 deletions
diff --git a/engines/sherlock/module.mk b/engines/sherlock/module.mk index 55d38401bf..8bbee9d701 100644 --- a/engines/sherlock/module.mk +++ b/engines/sherlock/module.mk @@ -25,6 +25,7 @@ MODULE_OBJS = \ tattoo/tattoo_user_interface.o \ tattoo/widget_base.o \ tattoo/widget_inventory.o \ + tattoo/widget_talk.o \ tattoo/widget_text.o \ tattoo/widget_tooltip.o \ tattoo/widget_verbs.o \ diff --git a/engines/sherlock/talk.h b/engines/sherlock/talk.h index d44fa15f7c..62a839e4ea 100644 --- a/engines/sherlock/talk.h +++ b/engines/sherlock/talk.h @@ -214,7 +214,6 @@ protected: Common::Stack<SequenceEntry> _savedSequences; Common::Stack<SequenceEntry> _sequenceStack; Common::Stack<ScriptStackEntry> _scriptStack; - Common::Array<Statement> _statements; Common::Array<TalkHistoryEntry> _talkHistory; int _speaker; int _talkIndex; @@ -277,6 +276,7 @@ protected: public: TalkSequence _talkSequenceStack[TALK_SEQUENCE_STACK_SIZE]; + Common::Array<Statement> _statements; bool _talkToAbort; int _talkCounter; int _talkTo; diff --git a/engines/sherlock/tattoo/tattoo_talk.cpp b/engines/sherlock/tattoo/tattoo_talk.cpp index 1ae36eaebe..ec75b31329 100644 --- a/engines/sherlock/tattoo/tattoo_talk.cpp +++ b/engines/sherlock/tattoo/tattoo_talk.cpp @@ -110,7 +110,7 @@ const byte TATTOO_OPCODES[] = { /*----------------------------------------------------------------*/ -TattooTalk::TattooTalk(SherlockEngine *vm) : Talk(vm) { +TattooTalk::TattooTalk(SherlockEngine *vm) : Talk(vm), _talkWidget(vm) { static OpcodeMethod OPCODE_METHODS[] = { (OpcodeMethod)&TattooTalk::cmdSwitchSpeaker, @@ -201,7 +201,8 @@ void TattooTalk::talkInterface(const byte *&str) { } void TattooTalk::openTalkWindow() { - // TODO + _talkWidget.load(); + _talkWidget.summonWindow(); } OpcodeReturn TattooTalk::cmdSwitchSpeaker(const byte *&str) { diff --git a/engines/sherlock/tattoo/tattoo_talk.h b/engines/sherlock/tattoo/tattoo_talk.h index 33eacd2db3..252518c462 100644 --- a/engines/sherlock/tattoo/tattoo_talk.h +++ b/engines/sherlock/tattoo/tattoo_talk.h @@ -30,6 +30,7 @@ #include "common/stream.h" #include "common/stack.h" #include "sherlock/talk.h" +#include "sherlock/tattoo/widget_talk.h" namespace Sherlock { @@ -37,6 +38,8 @@ namespace Tattoo { class TattooTalk : public Talk { private: + WidgetTalk _talkWidget; + OpcodeReturn cmdSwitchSpeaker(const byte *&str); OpcodeReturn cmdMouseOnOff(const byte *&str); OpcodeReturn cmdGotoScene(const byte *&str); @@ -77,8 +80,7 @@ private: void drawTalk(const char *str); /** - * Figures out how many lines the available talk lines will take up, and opens a text window - * of appropriate size + * Open the talk window */ void openTalkWindow(); protected: diff --git a/engines/sherlock/tattoo/widget_talk.cpp b/engines/sherlock/tattoo/widget_talk.cpp new file mode 100644 index 0000000000..ed0f2d35c8 --- /dev/null +++ b/engines/sherlock/tattoo/widget_talk.cpp @@ -0,0 +1,138 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "sherlock/tattoo/widget_talk.h" +#include "sherlock/tattoo/tattoo_people.h" +#include "sherlock/tattoo/tattoo_talk.h" +#include "sherlock/tattoo/tattoo_scene.h" +#include "sherlock/tattoo/tattoo_user_interface.h" +#include "sherlock/tattoo/tattoo.h" + +namespace Sherlock { + +namespace Tattoo { + +WidgetTalk::WidgetTalk(SherlockEngine *vm) : WidgetBase(vm) { + _talkScroll = false; +} + +void WidgetTalk::getTalkWindowSize() { + TattooTalk &talk = *(TattooTalk *)_vm->_talk; + Common::StringArray lines; + const char *const NUM_STR = "19."; + int width, height; + + // See how many statements are going to be available + int numStatements = 0; + for (uint idx = 0; idx < talk._statements.size(); ++idx) { + if (talk._statements[idx]._talkMap != -1) + ++numStatements; + } + + // Figure out the width, allowing room for both the text and the statement numbers on the side + width = SHERLOCK_SCREEN_WIDTH * 2 / 3; + int n = (numStatements < 10) ? 1 : 0; + width -= _surface.stringWidth(NUM_STR + n) + _surface.widestChar() / 2 + 9; + + // Now that we have a width, split up the text into individual lines + int numLines = 0; + for (uint idx = 0; idx < talk._statements.size(); ++idx) { + if (talk._statements[idx]._talkMap != -1) { + splitLines(talk._statements[idx]._statement, lines, width, 999); + numLines += lines.size(); + } + } + + // Make sure that the window does not get too big + if (numLines < 7) { + height = (_surface.fontHeight() + 1) * numLines + 9; + _talkScroll = false; + } else { + // Set up the height to a constrained amount, and add extra width for the scrollbar + width += BUTTON_SIZE + 3; + height = (_surface.fontHeight() + 1) * 6 + 9; + _talkScroll = false; + } + + _bounds = Common::Rect(width, height); + + // Allocate a surface for the window + _surface.create(_bounds.width(), _bounds.height()); + _surface.fill(TRANSPARENCY); + + // Form the background for the new window + makeInfoArea(); + + int yp = 5; + for (int lineNum = 0; yp < (_bounds.height() - _surface.fontHeight() / 2); ++lineNum) { + _surface.writeString(lines[lineNum], Common::Point(_surface.widestChar(), yp), INFO_TOP); + yp += _surface.fontHeight() + 1; + } +} + +void WidgetTalk::load() { + TattooPeople &people = *(TattooPeople *)_vm->_people; + TattooScene &scene = *(TattooScene *)_vm->_scene; + TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui; + ImageFile &images = *ui._interfaceImages; + + // Figure out the window size + getTalkWindowSize(); + + // Place the window centered above the player + Common::Point pt; + int scaleVal = scene.getScaleVal(people[HOLMES]._position); + pt.x = people[HOLMES]._position.x / FIXED_INT_MULTIPLIER; + + if (scaleVal == SCALE_THRESHOLD) { + pt.x += people[0].frameWidth() / 2; + pt.y = people[HOLMES]._position.y / FIXED_INT_MULTIPLIER - people[HOLMES].frameHeight() + - _bounds.height() - _surface.fontHeight(); + } else { + pt.x += people[HOLMES]._imageFrame->sDrawXSize(scaleVal) / 2; + pt.y = people[HOLMES]._position.y / FIXED_INT_MULTIPLIER - people[HOLMES]._imageFrame->sDrawYSize(scaleVal) + - _bounds.height() - _surface.fontHeight(); + } + + _bounds.moveTo(pt); + + // Set up the surface + _surface.create(_bounds.width(), _bounds.height()); + _surface.fill(TRANSPARENCY); + + // Form the background for the new window + makeInfoArea(); + + // If a scrollbar is needed, draw it in + if (_talkScroll) { + int xp = _surface.w() - BUTTON_SIZE - 6; + _surface.vLine(xp, 3, _surface.h() - 4, INFO_TOP); + _surface.vLine(xp + 1, 3, _surface.h() - 4, INFO_MIDDLE); + _surface.vLine(xp + 2, 3, _surface.h() - 4, INFO_BOTTOM); + _surface.transBlitFrom(images[6], Common::Point(xp - 1, 1)); + _surface.transBlitFrom(images[7], Common::Point(xp - 1, _surface.h() - 4)); + } +} + +} // End of namespace Tattoo + +} // End of namespace Sherlock diff --git a/engines/sherlock/tattoo/widget_talk.h b/engines/sherlock/tattoo/widget_talk.h new file mode 100644 index 0000000000..12ac93bab9 --- /dev/null +++ b/engines/sherlock/tattoo/widget_talk.h @@ -0,0 +1,58 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef SHERLOCK_TATTOO_WIDGET_TALK_H +#define SHERLOCK_TATTOO_WIDGET_TALK_H + +#include "common/scummsys.h" +#include "sherlock/tattoo/widget_base.h" + +namespace Sherlock { + +class SherlockEngine; + +namespace Tattoo { + +/** + * Handles displaying a dialog with conversation options the player can select from + */ +class WidgetTalk: public WidgetBase { +private: + bool _talkScroll; + + void getTalkWindowSize(); +public: + WidgetTalk(SherlockEngine *vm); + virtual ~WidgetTalk() {} + + /** + * Figures out how many lines the available talk lines will take up, and opens a text window + * of appropriate size + */ + void load(); +}; + +} // End of namespace Tattoo + +} // End of namespace Sherlock + +#endif |