From 54c4515232ec26397903373ed46e9492223ce2f2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 22 Feb 2014 08:39:44 -0500 Subject: MADS: Beginnings of dialog class hierarchy --- engines/mads/dialogs.cpp | 200 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 200 insertions(+) create mode 100644 engines/mads/dialogs.cpp (limited to 'engines/mads/dialogs.cpp') diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp new file mode 100644 index 0000000000..4e64f08822 --- /dev/null +++ b/engines/mads/dialogs.cpp @@ -0,0 +1,200 @@ +/* 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 "common/scummsys.h" +#include "common/config-manager.h" +#include "mads/mads.h" +#include "mads/graphics.h" +#include "mads/msurface.h" +#include "mads/nebular/dialogs_nebular.h" + +namespace MADS { + +Dialog::Dialog(MADSEngine *vm): _vm(vm), _savedSurface(nullptr), + _position(Common::Point(-1, -1)), _width(0), _height(0) { +} + +Dialog::~Dialog() { + delete _savedSurface; +} + + +void Dialog::save(MSurface *s) { + _savedSurface = MSurface::init(_width, _height); + s->copyTo(_savedSurface, + Common::Rect(_position.x, _position.y, _position.x + _width, _position.y + _height), + Common::Point()); +} + +void Dialog::restore(MSurface *s) { + _savedSurface->copyTo(s, _position); + delete _savedSurface; + _savedSurface = nullptr; +} + +/*------------------------------------------------------------------------*/ + +TextDialog::TextDialog(MADSEngine *vm, const Common::String &fontName, + const Common::Point &pos, int maxChars): + Dialog(vm) { + _vm = vm; + _fontName = fontName; + _position = pos; + + _vm->_font->setFont(FONT_INTERFACE); + _vm->_font->setColors(TEXTDIALOG_FONT, TEXTDIALOG_FONT, TEXTDIALOG_FONT, TEXTDIALOG_FONT); + + _innerWidth = (_vm->_font->maxWidth() + 1) * maxChars; + _width = _innerWidth + 10; + _lineSize = maxChars * 2; + _lineWidth = 0; + _currentX = 0; + _numLines = 0; + Common::fill(&_lineXp[0], &_lineXp[TEXT_DIALOG_MAX_LINES], 0); + + Common::copy(&_vm->_palette->_mainPalette[TEXTDIALOG_F8 * 3], + &_vm->_palette->_mainPalette[TEXTDIALOG_F8 * 3 + 8 * 3], + &_savedPalette[0]); + Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_F8, 2, 0x24, 0x20); + Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_FA, 2, 0x27, 0x1C); + Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_FC, 2, 0x24, 0x20); + Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_FE, 1, 0x37, 0x37); + + _vm->_palette->setPalette(_vm->_palette->_mainPalette + (TEXTDIALOG_F8 * 3), + TEXTDIALOG_F8, 8); +} + +TextDialog::~TextDialog() { +} + +void TextDialog::addLine(const Common::String &line, bool underline) { + if (_lineWidth > 0 || _currentX > 0) + incNumLines(); + + int stringWidth = _vm->_font->getWidth(line); + if (stringWidth >= _innerWidth || (int)line.size() >= _lineSize) { + wordWrap(line); + } else { + _lineXp[_numLines] = (_innerWidth / 2) - (stringWidth / 2); + _lines[_numLines] = line; + + if (underline) + underlineLine(); + } + + incNumLines(); +} + +void TextDialog::underlineLine() { + _lineXp[_numLines] |= 0x80; +} + +void TextDialog::incNumLines() { + _lineWidth = 0; + _currentX = 0; + if (++_numLines == TEXT_DIALOG_MAX_LINES) + error("Exceeded text dialog line max"); +} + +void TextDialog::wordWrap(const Common::String &line) { + Common::String tempLine; + + if (!line.empty()) { + const char *srcP = line.c_str(); + + do { + tempLine = ""; + bool endWord = false; + bool newLine = false; + bool continueFlag = true; + + do { + if (!*srcP) { + continueFlag = false; + } else { + tempLine += *srcP; + + if (*srcP == 10) { + continueFlag = false; + newLine = true; + ++srcP; + tempLine.deleteLastChar(); + } else if (*srcP == ' ') { + ++srcP; + endWord = true; + } else if (!endWord) { + ++srcP; + } else { + tempLine.deleteLastChar(); + continueFlag = false; + } + } + } while (continueFlag); + + if (tempLine.hasSuffix(" ")) + tempLine.deleteLastChar(); + + Common::String tempLine2; + if (_currentX > 0) + tempLine2 += ' '; + tempLine2 += tempLine; + + int lineWidth = _vm->_font->getWidth(tempLine2, 1); + if (((_currentX + (int)tempLine2.size()) > _lineSize) || + ((_lineWidth + lineWidth) > _innerWidth)) { + incNumLines(); + appendLine(tempLine); + } else { + appendLine(tempLine2); + } + + if (newLine) + incNumLines(); + } while (*srcP); + } +} + +void TextDialog::appendLine(const Common::String &line) { + _currentX += line.size(); + _lineWidth += _vm->_font->getWidth(line, 1); + _lines[_numLines] += line; +} + +/*------------------------------------------------------------------------*/ + +MessageDialog::MessageDialog(MADSEngine *vm, int maxChars, ...): + TextDialog(vm, FONT_INTERFACE, Common::Point(-1, -1), maxChars) { + // Add in passed line list + va_list va; + va_start(va, maxChars); + + const char *line = va_arg(va, const char *); + while (line) { + addLine(line); + line = va_arg(va, const char *); + } + va_end(va); + + // TODO +} + +} // End of namespace MADS -- cgit v1.2.3 From 6c354bccf253118d459f92f16d8f702ae07806fb Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 22 Feb 2014 17:25:30 -0500 Subject: MADS: Implemented more logic for dialog display --- engines/mads/dialogs.cpp | 108 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 100 insertions(+), 8 deletions(-) (limited to 'engines/mads/dialogs.cpp') diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp index 4e64f08822..ebb21418b1 100644 --- a/engines/mads/dialogs.cpp +++ b/engines/mads/dialogs.cpp @@ -51,6 +51,44 @@ void Dialog::restore(MSurface *s) { _savedSurface = nullptr; } +void Dialog::draw() { + // Save the screen portion the dialog will overlap + save(_vm->_screen); + + // Draw the dialog + // Fill entire content of dialog + _vm->_screen->fillRect(Common::Rect(_position.x, _position.y, + _position.x + _width, _position.y + _height), TEXTDIALOG_BACKGROUND); + + // Draw the outer edge line + _vm->_screen->frameRect(Common::Rect(_position.x, _position.y, + _position.x + _width, _position.y + _height), TEXTDIALOG_EDGE); + + // Draw the gravelly dialog content + drawContent(Common::Rect(_position.x + 2, _position.y + 2, + _position.x + _width - 4, _position.y + _height - 4), 0, + TEXTDIALOG_CONTENT1, TEXTDIALOG_CONTENT2); +} + +void Dialog::drawContent(const Common::Rect &r, int seed, byte color1, byte color2) { + uint16 currSeed = seed ? seed : 0xB78E; + + for (int yp = 0; yp < r.height(); ++yp) { + byte *destP = _vm->_screen->getBasePtr(r.left, r.top + yp); + + for (int xp = 0; xp < r.width(); ++xp) { + uint16 seedAdjust = currSeed; + currSeed += 0x181D; + seedAdjust = (seedAdjust >> 9) | ((seedAdjust & 0x1ff) << 7); + currSeed ^= seedAdjust; + seedAdjust = (seedAdjust >> 3) | ((seedAdjust & 7) << 13); + currSeed += seedAdjust; + + *destP++ = (currSeed & 0x10) ? color1 : color2; + } + } +} + /*------------------------------------------------------------------------*/ TextDialog::TextDialog(MADSEngine *vm, const Common::String &fontName, @@ -61,7 +99,7 @@ TextDialog::TextDialog(MADSEngine *vm, const Common::String &fontName, _position = pos; _vm->_font->setFont(FONT_INTERFACE); - _vm->_font->setColors(TEXTDIALOG_FONT, TEXTDIALOG_FONT, TEXTDIALOG_FONT, TEXTDIALOG_FONT); + _vm->_font->setColors(TEXTDIALOG_BLACK, TEXTDIALOG_BLACK, TEXTDIALOG_BLACK, TEXTDIALOG_BLACK); _innerWidth = (_vm->_font->maxWidth() + 1) * maxChars; _width = _innerWidth + 10; @@ -71,16 +109,16 @@ TextDialog::TextDialog(MADSEngine *vm, const Common::String &fontName, _numLines = 0; Common::fill(&_lineXp[0], &_lineXp[TEXT_DIALOG_MAX_LINES], 0); - Common::copy(&_vm->_palette->_mainPalette[TEXTDIALOG_F8 * 3], - &_vm->_palette->_mainPalette[TEXTDIALOG_F8 * 3 + 8 * 3], + Common::copy(&_vm->_palette->_mainPalette[TEXTDIALOG_CONTENT1 * 3], + &_vm->_palette->_mainPalette[TEXTDIALOG_CONTENT1 * 3 + 8 * 3], &_savedPalette[0]); - Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_F8, 2, 0x24, 0x20); - Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_FA, 2, 0x27, 0x1C); + Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_CONTENT1, 2, 0x24, 0x20); + Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_EDGE, 2, 0x27, 0x1C); Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_FC, 2, 0x24, 0x20); Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_FE, 1, 0x37, 0x37); - _vm->_palette->setPalette(_vm->_palette->_mainPalette + (TEXTDIALOG_F8 * 3), - TEXTDIALOG_F8, 8); + _vm->_palette->setPalette(_vm->_palette->_mainPalette + (TEXTDIALOG_CONTENT1 * 3), + TEXTDIALOG_CONTENT1, 8); } TextDialog::~TextDialog() { @@ -179,6 +217,58 @@ void TextDialog::appendLine(const Common::String &line) { _lines[_numLines] += line; } +void TextDialog::draw() { + if (!_lineWidth) + --_numLines; + + // Figure out the size and position for the dialog + _height = (_vm->_font->getHeight() + 1) * (_numLines + 1) + 10; + if (_position.x == -1) + _position.x = 160 - (_width / 2); + if (_position.y == -1) + _position.y = 100 - (_height / 2); + + if ((_position.x + _width) > _vm->_screen->getWidth()) + _position.x = _vm->_screen->getWidth() - (_position.x + _width); + if ((_position.y + _height) > _vm->_screen->getHeight()) + _position.y = _vm->_screen->getHeight() - (_position.y + _height); + +// int askYp = (_vm->_font->getHeight() + 1) * _vm->_font->getHeight() + 3; + + // Draw the underlying dialog + Dialog::draw(); + + // Draw the text lines + int lineYp = _position.y + 5; + for (int lineNum = 0; lineNum < _numLines; ++lineNum) { + if (_lineXp[lineNum] == -1) { + // Draw a line across the entire dialog + _vm->_screen->setColor(TEXTDIALOG_BLACK); + _vm->_screen->hLine(_position.x + 2, + lineYp + (_vm->_font->getHeight() + 1) / 2, + _position.x + _width - 4); + } else { + // Draw a text line + int xp = (_lineXp[lineNum] & 0x7F) + 5; + int yp = lineYp; + if (_lineXp[lineNum] & 0x40) + ++yp; + + _vm->_font->writeString(_vm->_screen, _lines[lineNum], + Common::Point(xp, yp), 1); + + if (_lineXp[lineNum] & 0x80) { + // Draw an underline under the text + int lineWidth = _vm->_font->getWidth(_lines[lineNum]); + _vm->_screen->setColor(TEXTDIALOG_BLACK); + _vm->_screen->hLine(xp, yp + _vm->_font->getHeight(), xp + lineWidth); + } + } + + lineYp += _vm->_font->getHeight() + 1; + } +} + /*------------------------------------------------------------------------*/ MessageDialog::MessageDialog(MADSEngine *vm, int maxChars, ...): @@ -193,8 +283,10 @@ MessageDialog::MessageDialog(MADSEngine *vm, int maxChars, ...): line = va_arg(va, const char *); } va_end(va); +} + +void MessageDialog::show() { - // TODO } } // End of namespace MADS -- cgit v1.2.3 From 6b774d228495e2dc9de08520a3064889d439335d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 22 Feb 2014 18:21:18 -0500 Subject: MADS: Copy protection dialog is starting to be displayed --- engines/mads/dialogs.cpp | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) (limited to 'engines/mads/dialogs.cpp') diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp index ebb21418b1..d5a6bfd5be 100644 --- a/engines/mads/dialogs.cpp +++ b/engines/mads/dialogs.cpp @@ -34,7 +34,7 @@ Dialog::Dialog(MADSEngine *vm): _vm(vm), _savedSurface(nullptr), } Dialog::~Dialog() { - delete _savedSurface; + restore(_vm->_screen); } @@ -46,9 +46,11 @@ void Dialog::save(MSurface *s) { } void Dialog::restore(MSurface *s) { - _savedSurface->copyTo(s, _position); - delete _savedSurface; - _savedSurface = nullptr; + if (_savedSurface) { + _savedSurface->copyTo(s, _position); + delete _savedSurface; + _savedSurface = nullptr; + } } void Dialog::draw() { @@ -109,26 +111,28 @@ TextDialog::TextDialog(MADSEngine *vm, const Common::String &fontName, _numLines = 0; Common::fill(&_lineXp[0], &_lineXp[TEXT_DIALOG_MAX_LINES], 0); + // Save the high end of the palette, and set up the entries for dialog display Common::copy(&_vm->_palette->_mainPalette[TEXTDIALOG_CONTENT1 * 3], &_vm->_palette->_mainPalette[TEXTDIALOG_CONTENT1 * 3 + 8 * 3], &_savedPalette[0]); - Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_CONTENT1, 2, 0x24, 0x20); - Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_EDGE, 2, 0x27, 0x1C); - Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_FC, 2, 0x24, 0x20); - Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_FE, 1, 0x37, 0x37); + Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_CONTENT1, 2, 0x90, 0x80); + Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_EDGE, 2, 0x9C, 0x70); + Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_FC, 2, 0x90, 0x80); + Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_FE, 1, 0xDC, 0xDC); _vm->_palette->setPalette(_vm->_palette->_mainPalette + (TEXTDIALOG_CONTENT1 * 3), TEXTDIALOG_CONTENT1, 8); } TextDialog::~TextDialog() { + restorePalette(); } void TextDialog::addLine(const Common::String &line, bool underline) { if (_lineWidth > 0 || _currentX > 0) incNumLines(); - int stringWidth = _vm->_font->getWidth(line); + int stringWidth = _vm->_font->getWidth(line, 1); if (stringWidth >= _innerWidth || (int)line.size() >= _lineSize) { wordWrap(line); } else { @@ -249,17 +253,17 @@ void TextDialog::draw() { _position.x + _width - 4); } else { // Draw a text line - int xp = (_lineXp[lineNum] & 0x7F) + 5; + int xp = (_lineXp[lineNum] & 0x7F) + _position.x + 5; int yp = lineYp; if (_lineXp[lineNum] & 0x40) ++yp; _vm->_font->writeString(_vm->_screen, _lines[lineNum], - Common::Point(xp, yp), 1); + Common::Point(xp, yp), 0, 1); if (_lineXp[lineNum] & 0x80) { // Draw an underline under the text - int lineWidth = _vm->_font->getWidth(_lines[lineNum]); + int lineWidth = _vm->_font->getWidth(_lines[lineNum], 1); _vm->_screen->setColor(TEXTDIALOG_BLACK); _vm->_screen->hLine(xp, yp + _vm->_font->getHeight(), xp + lineWidth); } @@ -269,6 +273,12 @@ void TextDialog::draw() { } } +void TextDialog::restorePalette() { + Common::copy(&_savedPalette[0], &_savedPalette[8 * 3], + &_vm->_palette->_mainPalette[248 * 3]); + _vm->_palette->setPalette(_vm->_palette->_mainPalette, 248, 8); +} + /*------------------------------------------------------------------------*/ MessageDialog::MessageDialog(MADSEngine *vm, int maxChars, ...): @@ -286,7 +296,13 @@ MessageDialog::MessageDialog(MADSEngine *vm, int maxChars, ...): } void MessageDialog::show() { + draw(); + _vm->_events->showCursor(); + while (!_vm->shouldQuit() && !_vm->_events->_keyPressed && + !_vm->_events->_mouseClicked) { + _vm->_events->delay(1); + } } } // End of namespace MADS -- cgit v1.2.3 From 1d80edb2dd092b7e91805f359f0e2a7d470ed7c4 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 23 Feb 2014 13:39:53 -0500 Subject: MADS: Fixes for the display of dialogs --- engines/mads/dialogs.cpp | 47 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 12 deletions(-) (limited to 'engines/mads/dialogs.cpp') diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp index d5a6bfd5be..c6049c3c1a 100644 --- a/engines/mads/dialogs.cpp +++ b/engines/mads/dialogs.cpp @@ -62,13 +62,19 @@ void Dialog::draw() { _vm->_screen->fillRect(Common::Rect(_position.x, _position.y, _position.x + _width, _position.y + _height), TEXTDIALOG_BACKGROUND); - // Draw the outer edge line - _vm->_screen->frameRect(Common::Rect(_position.x, _position.y, - _position.x + _width, _position.y + _height), TEXTDIALOG_EDGE); + // Draw the outer edge lines + _vm->_screen->hLine(_position.x + 1, _position.y + _height - 2, + _position.x + _width - 2, TEXTDIALOG_EDGE); + _vm->_screen->hLine(_position.x, _position.y + _height - 1, + _position.x + _width - 1, TEXTDIALOG_EDGE); + _vm->_screen->vLine(_position.x + _width - 2, _position.y + 2, + _position.y + _height - 2, TEXTDIALOG_EDGE); + _vm->_screen->vLine(_position.x + _width - 1, _position.y + 1, + _position.y + _height - 1, TEXTDIALOG_EDGE); // Draw the gravelly dialog content drawContent(Common::Rect(_position.x + 2, _position.y + 2, - _position.x + _width - 4, _position.y + _height - 4), 0, + _position.x + _width - 2, _position.y + _height - 2), 0, TEXTDIALOG_CONTENT1, TEXTDIALOG_CONTENT2); } @@ -86,7 +92,7 @@ void Dialog::drawContent(const Common::Rect &r, int seed, byte color1, byte colo seedAdjust = (seedAdjust >> 3) | ((seedAdjust & 7) << 13); currSeed += seedAdjust; - *destP++ = (currSeed & 0x10) ? color1 : color2; + *destP++ = (currSeed & 0x10) ? color2 : color1; } } } @@ -110,7 +116,9 @@ TextDialog::TextDialog(MADSEngine *vm, const Common::String &fontName, _currentX = 0; _numLines = 0; Common::fill(&_lineXp[0], &_lineXp[TEXT_DIALOG_MAX_LINES], 0); - + _askLineNum = -1; + _askXp = 0; + // Save the high end of the palette, and set up the entries for dialog display Common::copy(&_vm->_palette->_mainPalette[TEXTDIALOG_CONTENT1 * 3], &_vm->_palette->_mainPalette[TEXTDIALOG_CONTENT1 * 3 + 8 * 3], @@ -221,6 +229,12 @@ void TextDialog::appendLine(const Common::String &line) { _lines[_numLines] += line; } +void TextDialog::addInput() { + _askXp = _currentX + 1; + _askLineNum = _numLines; + incNumLines(); +} + void TextDialog::draw() { if (!_lineWidth) --_numLines; @@ -237,8 +251,6 @@ void TextDialog::draw() { if ((_position.y + _height) > _vm->_screen->getHeight()) _position.y = _vm->_screen->getHeight() - (_position.y + _height); -// int askYp = (_vm->_font->getHeight() + 1) * _vm->_font->getHeight() + 3; - // Draw the underlying dialog Dialog::draw(); @@ -247,10 +259,9 @@ void TextDialog::draw() { for (int lineNum = 0; lineNum < _numLines; ++lineNum) { if (_lineXp[lineNum] == -1) { // Draw a line across the entire dialog - _vm->_screen->setColor(TEXTDIALOG_BLACK); _vm->_screen->hLine(_position.x + 2, lineYp + (_vm->_font->getHeight() + 1) / 2, - _position.x + _width - 4); + _position.x + _width - 4, TEXTDIALOG_BLACK); } else { // Draw a text line int xp = (_lineXp[lineNum] & 0x7F) + _position.x + 5; @@ -264,8 +275,8 @@ void TextDialog::draw() { if (_lineXp[lineNum] & 0x80) { // Draw an underline under the text int lineWidth = _vm->_font->getWidth(_lines[lineNum], 1); - _vm->_screen->setColor(TEXTDIALOG_BLACK); - _vm->_screen->hLine(xp, yp + _vm->_font->getHeight(), xp + lineWidth); + _vm->_screen->hLine(xp, yp + _vm->_font->getHeight(), xp + lineWidth, + TEXTDIALOG_BLACK); } } @@ -273,6 +284,18 @@ void TextDialog::draw() { } } +void TextDialog::drawWithInput() { + int innerWidth = _innerWidth; + int lineHeight = _vm->_font->getHeight() + 1; + int xp = _position.x + 5; + + // Draw the content of the dialog + drawContent(Common::Rect(_position.x + 2, _position.y + 2, + _position.x + _width - 2, _position.y + _height - 2), 0, + TEXTDIALOG_CONTENT1, TEXTDIALOG_CONTENT2); + +} + void TextDialog::restorePalette() { Common::copy(&_savedPalette[0], &_savedPalette[8 * 3], &_vm->_palette->_mainPalette[248 * 3]); -- cgit v1.2.3 From 8c9420a8349b0cdb93dcace36c2bd5f93e03476f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 23 Feb 2014 19:33:26 -0500 Subject: MADS: Added game initialisation code --- engines/mads/dialogs.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'engines/mads/dialogs.cpp') diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp index c6049c3c1a..34a0b86abc 100644 --- a/engines/mads/dialogs.cpp +++ b/engines/mads/dialogs.cpp @@ -285,15 +285,16 @@ void TextDialog::draw() { } void TextDialog::drawWithInput() { - int innerWidth = _innerWidth; - int lineHeight = _vm->_font->getHeight() + 1; - int xp = _position.x + 5; + //int innerWidth = _innerWidth; + //int lineHeight = _vm->_font->getHeight() + 1; + //int xp = _position.x + 5; // Draw the content of the dialog drawContent(Common::Rect(_position.x + 2, _position.y + 2, _position.x + _width - 2, _position.y + _height - 2), 0, TEXTDIALOG_CONTENT1, TEXTDIALOG_CONTENT2); - + + error("TODO: drawWithInput"); } void TextDialog::restorePalette() { -- cgit v1.2.3 From 37b788b7ddb679f32653be326ae96ad9132feb1f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 24 Feb 2014 00:20:53 -0500 Subject: MADS: Added skeleton framework for game scene classes --- engines/mads/dialogs.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'engines/mads/dialogs.cpp') diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp index 34a0b86abc..fd42eb5db0 100644 --- a/engines/mads/dialogs.cpp +++ b/engines/mads/dialogs.cpp @@ -329,4 +329,16 @@ void MessageDialog::show() { } } +/*------------------------------------------------------------------------*/ + +Dialogs *Dialogs::init(MADSEngine *vm) { + if (vm->getGameID() == GType_RexNebular) + return new Dialogs(vm); + + error("Unknown game"); +} + +Dialogs::Dialogs(MADSEngine *vm): _vm(vm) { +} + } // End of namespace MADS -- cgit v1.2.3 From 4c867aa62fea19f2bff7d3aa632b340aae110306 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 24 Feb 2014 00:38:49 -0500 Subject: MADS: Shift some fields and methods to Dialogs and Game classes --- engines/mads/dialogs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/mads/dialogs.cpp') diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp index fd42eb5db0..c865e048da 100644 --- a/engines/mads/dialogs.cpp +++ b/engines/mads/dialogs.cpp @@ -333,7 +333,7 @@ void MessageDialog::show() { Dialogs *Dialogs::init(MADSEngine *vm) { if (vm->getGameID() == GType_RexNebular) - return new Dialogs(vm); + return new Nebular::DialogsNebular(vm); error("Unknown game"); } -- cgit v1.2.3 From c49d7196fcabf18d9e97711f67b864808ca7848a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 25 Feb 2014 23:10:51 -0500 Subject: MADS: In progress implementation of loadScene --- engines/mads/dialogs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/mads/dialogs.cpp') diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp index c865e048da..e4c7682a38 100644 --- a/engines/mads/dialogs.cpp +++ b/engines/mads/dialogs.cpp @@ -39,7 +39,7 @@ Dialog::~Dialog() { void Dialog::save(MSurface *s) { - _savedSurface = MSurface::init(_width, _height); + _savedSurface = new MSurface(_width, _height); s->copyTo(_savedSurface, Common::Rect(_position.x, _position.y, _position.x + _width, _position.y + _height), Common::Point()); -- cgit v1.2.3 From 568fc31b3090a70aa922479991540d4f5c2e918c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 4 Mar 2014 22:33:27 -0500 Subject: MADS: Beginnings of code support for Scene::drawElements --- engines/mads/dialogs.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'engines/mads/dialogs.cpp') diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp index e4c7682a38..d159d48ace 100644 --- a/engines/mads/dialogs.cpp +++ b/engines/mads/dialogs.cpp @@ -34,7 +34,7 @@ Dialog::Dialog(MADSEngine *vm): _vm(vm), _savedSurface(nullptr), } Dialog::~Dialog() { - restore(_vm->_screen); + restore(&_vm->_screen); } @@ -55,21 +55,21 @@ void Dialog::restore(MSurface *s) { void Dialog::draw() { // Save the screen portion the dialog will overlap - save(_vm->_screen); + save(&_vm->_screen); // Draw the dialog // Fill entire content of dialog - _vm->_screen->fillRect(Common::Rect(_position.x, _position.y, + _vm->_screen.fillRect(Common::Rect(_position.x, _position.y, _position.x + _width, _position.y + _height), TEXTDIALOG_BACKGROUND); // Draw the outer edge lines - _vm->_screen->hLine(_position.x + 1, _position.y + _height - 2, + _vm->_screen.hLine(_position.x + 1, _position.y + _height - 2, _position.x + _width - 2, TEXTDIALOG_EDGE); - _vm->_screen->hLine(_position.x, _position.y + _height - 1, + _vm->_screen.hLine(_position.x, _position.y + _height - 1, _position.x + _width - 1, TEXTDIALOG_EDGE); - _vm->_screen->vLine(_position.x + _width - 2, _position.y + 2, + _vm->_screen.vLine(_position.x + _width - 2, _position.y + 2, _position.y + _height - 2, TEXTDIALOG_EDGE); - _vm->_screen->vLine(_position.x + _width - 1, _position.y + 1, + _vm->_screen.vLine(_position.x + _width - 1, _position.y + 1, _position.y + _height - 1, TEXTDIALOG_EDGE); // Draw the gravelly dialog content @@ -82,7 +82,7 @@ void Dialog::drawContent(const Common::Rect &r, int seed, byte color1, byte colo uint16 currSeed = seed ? seed : 0xB78E; for (int yp = 0; yp < r.height(); ++yp) { - byte *destP = _vm->_screen->getBasePtr(r.left, r.top + yp); + byte *destP = _vm->_screen.getBasePtr(r.left, r.top + yp); for (int xp = 0; xp < r.width(); ++xp) { uint16 seedAdjust = currSeed; @@ -246,10 +246,10 @@ void TextDialog::draw() { if (_position.y == -1) _position.y = 100 - (_height / 2); - if ((_position.x + _width) > _vm->_screen->getWidth()) - _position.x = _vm->_screen->getWidth() - (_position.x + _width); - if ((_position.y + _height) > _vm->_screen->getHeight()) - _position.y = _vm->_screen->getHeight() - (_position.y + _height); + if ((_position.x + _width) > _vm->_screen.getWidth()) + _position.x = _vm->_screen.getWidth() - (_position.x + _width); + if ((_position.y + _height) > _vm->_screen.getHeight()) + _position.y = _vm->_screen.getHeight() - (_position.y + _height); // Draw the underlying dialog Dialog::draw(); @@ -259,7 +259,7 @@ void TextDialog::draw() { for (int lineNum = 0; lineNum < _numLines; ++lineNum) { if (_lineXp[lineNum] == -1) { // Draw a line across the entire dialog - _vm->_screen->hLine(_position.x + 2, + _vm->_screen.hLine(_position.x + 2, lineYp + (_vm->_font->getHeight() + 1) / 2, _position.x + _width - 4, TEXTDIALOG_BLACK); } else { @@ -269,13 +269,13 @@ void TextDialog::draw() { if (_lineXp[lineNum] & 0x40) ++yp; - _vm->_font->writeString(_vm->_screen, _lines[lineNum], + _vm->_font->writeString(&_vm->_screen, _lines[lineNum], Common::Point(xp, yp), 0, 1); if (_lineXp[lineNum] & 0x80) { // Draw an underline under the text int lineWidth = _vm->_font->getWidth(_lines[lineNum], 1); - _vm->_screen->hLine(xp, yp + _vm->_font->getHeight(), xp + lineWidth, + _vm->_screen.hLine(xp, yp + _vm->_font->getHeight(), xp + lineWidth, TEXTDIALOG_BLACK); } } -- cgit v1.2.3 From 3f0cd4771c94a83c72f09f74ba351a3905357d1c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 13 Mar 2014 22:25:16 -0400 Subject: MADS: Fixed handling of dirty rects to copy areas to the physical screen --- engines/mads/dialogs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/mads/dialogs.cpp') diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp index d159d48ace..571cca5d29 100644 --- a/engines/mads/dialogs.cpp +++ b/engines/mads/dialogs.cpp @@ -23,7 +23,7 @@ #include "common/scummsys.h" #include "common/config-manager.h" #include "mads/mads.h" -#include "mads/graphics.h" +#include "mads/screen.h" #include "mads/msurface.h" #include "mads/nebular/dialogs_nebular.h" -- cgit v1.2.3 From acba8f9254a724ce9c57f5ddd81e6b9264c07274 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 16 Mar 2014 23:40:21 -0400 Subject: MADS: Implementing user interface text display methods --- engines/mads/dialogs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/mads/dialogs.cpp') diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp index 571cca5d29..4c1a789a57 100644 --- a/engines/mads/dialogs.cpp +++ b/engines/mads/dialogs.cpp @@ -270,7 +270,7 @@ void TextDialog::draw() { ++yp; _vm->_font->writeString(&_vm->_screen, _lines[lineNum], - Common::Point(xp, yp), 0, 1); + Common::Point(xp, yp), 1); if (_lineXp[lineNum] & 0x80) { // Draw an underline under the text -- cgit v1.2.3 From b831323c85bb1ca26368cee6690d4664c37e9c0b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 17 Mar 2014 00:00:22 -0400 Subject: MADS: Added caching for font instances --- engines/mads/dialogs.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'engines/mads/dialogs.cpp') diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp index 4c1a789a57..333bbe98b4 100644 --- a/engines/mads/dialogs.cpp +++ b/engines/mads/dialogs.cpp @@ -106,7 +106,6 @@ TextDialog::TextDialog(MADSEngine *vm, const Common::String &fontName, _fontName = fontName; _position = pos; - _vm->_font->setFont(FONT_INTERFACE); _vm->_font->setColors(TEXTDIALOG_BLACK, TEXTDIALOG_BLACK, TEXTDIALOG_BLACK, TEXTDIALOG_BLACK); _innerWidth = (_vm->_font->maxWidth() + 1) * maxChars; -- cgit v1.2.3 From 2b141aaba681a3c7b848010cd58768f55f4434a3 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 21 Mar 2014 09:27:22 -0400 Subject: MADS: Fixes for screen objects loading and checking --- engines/mads/dialogs.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines/mads/dialogs.cpp') diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp index 333bbe98b4..d5d7d64380 100644 --- a/engines/mads/dialogs.cpp +++ b/engines/mads/dialogs.cpp @@ -338,6 +338,7 @@ Dialogs *Dialogs::init(MADSEngine *vm) { } Dialogs::Dialogs(MADSEngine *vm): _vm(vm) { + _pendingDialog = DIALOG_NONE; } } // End of namespace MADS -- cgit v1.2.3 From 377cbbe77d5c7f16aba086e4fb1707de843ddc1a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 27 Mar 2014 21:04:27 -0400 Subject: MADS: Cleanup of game and player fields used during initialization --- engines/mads/dialogs.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'engines/mads/dialogs.cpp') diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp index d5d7d64380..c5e99f859e 100644 --- a/engines/mads/dialogs.cpp +++ b/engines/mads/dialogs.cpp @@ -341,4 +341,8 @@ Dialogs::Dialogs(MADSEngine *vm): _vm(vm) { _pendingDialog = DIALOG_NONE; } +void Dialogs::show(int msgId) { + +} + } // End of namespace MADS -- cgit v1.2.3 From 89af9dde8c412b4d11cd0107fe20f9bbbfd2e3bc Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 29 Mar 2014 22:28:22 -0400 Subject: MADS: Implemented message loading/decoding --- engines/mads/dialogs.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines/mads/dialogs.cpp') diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp index c5e99f859e..04e89fad61 100644 --- a/engines/mads/dialogs.cpp +++ b/engines/mads/dialogs.cpp @@ -342,7 +342,8 @@ Dialogs::Dialogs(MADSEngine *vm): _vm(vm) { } void Dialogs::show(int msgId) { - + Common::StringArray msg = _vm->_game->getMessage(msgId); + warning("%s\n", msg[0].c_str()); } } // End of namespace MADS -- cgit v1.2.3 From 57f1c6e9d9ff82513205a1dc8ec05c335486759f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 30 Mar 2014 21:10:07 -0400 Subject: MADS: Implemented message parser for action dialog display --- engines/mads/dialogs.cpp | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) (limited to 'engines/mads/dialogs.cpp') diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp index 04e89fad61..1215df36ae 100644 --- a/engines/mads/dialogs.cpp +++ b/engines/mads/dialogs.cpp @@ -157,6 +157,10 @@ void TextDialog::underlineLine() { _lineXp[_numLines] |= 0x80; } +void TextDialog::downPixelLine() { + _lineXp[_numLines] |= 0x40; +} + void TextDialog::incNumLines() { _lineWidth = 0; _currentX = 0; @@ -234,6 +238,18 @@ void TextDialog::addInput() { incNumLines(); } +void TextDialog::addBarLine() { + if (_lineWidth > 0 || _currentX > 0) + incNumLines(); + + _lineXp[_numLines] = 0xFF; + incNumLines(); +} + +void TextDialog::setLineXp(int xp) { + _lineXp[_numLines] = xp; +} + void TextDialog::draw() { if (!_lineWidth) --_numLines; @@ -302,6 +318,16 @@ void TextDialog::restorePalette() { _vm->_palette->setPalette(_vm->_palette->_mainPalette, 248, 8); } +void TextDialog::show() { + draw(); + _vm->_events->showCursor(); + + while (!_vm->shouldQuit() && !_vm->_events->_keyPressed && + !_vm->_events->_mouseClicked) { + _vm->_events->delay(1); + } +} + /*------------------------------------------------------------------------*/ MessageDialog::MessageDialog(MADSEngine *vm, int maxChars, ...): @@ -318,16 +344,6 @@ MessageDialog::MessageDialog(MADSEngine *vm, int maxChars, ...): va_end(va); } -void MessageDialog::show() { - draw(); - _vm->_events->showCursor(); - - while (!_vm->shouldQuit() && !_vm->_events->_keyPressed && - !_vm->_events->_mouseClicked) { - _vm->_events->delay(1); - } -} - /*------------------------------------------------------------------------*/ Dialogs *Dialogs::init(MADSEngine *vm) { @@ -341,9 +357,4 @@ Dialogs::Dialogs(MADSEngine *vm): _vm(vm) { _pendingDialog = DIALOG_NONE; } -void Dialogs::show(int msgId) { - Common::StringArray msg = _vm->_game->getMessage(msgId); - warning("%s\n", msg[0].c_str()); -} - } // End of namespace MADS -- cgit v1.2.3 From 7f15c6d5fd0f2c1bfef1d69d0556233543a6cd8a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 4 Apr 2014 08:19:37 -0400 Subject: MADS: Beginnings of proper look dialog display --- engines/mads/dialogs.cpp | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) (limited to 'engines/mads/dialogs.cpp') diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp index 1215df36ae..13342f14f1 100644 --- a/engines/mads/dialogs.cpp +++ b/engines/mads/dialogs.cpp @@ -59,8 +59,8 @@ void Dialog::draw() { // Draw the dialog // Fill entire content of dialog - _vm->_screen.fillRect(Common::Rect(_position.x, _position.y, - _position.x + _width, _position.y + _height), TEXTDIALOG_BACKGROUND); + Common::Rect bounds = getBounds(); + _vm->_screen.fillRect(bounds, TEXTDIALOG_BACKGROUND); // Draw the outer edge lines _vm->_screen.hLine(_position.x + 1, _position.y + _height - 2, @@ -76,6 +76,8 @@ void Dialog::draw() { drawContent(Common::Rect(_position.x + 2, _position.y + 2, _position.x + _width - 2, _position.y + _height - 2), 0, TEXTDIALOG_CONTENT1, TEXTDIALOG_CONTENT2); + + _vm->_screen.copyRectToScreen(bounds); } void Dialog::drawContent(const Common::Rect &r, int seed, byte color1, byte color2) { @@ -103,12 +105,12 @@ TextDialog::TextDialog(MADSEngine *vm, const Common::String &fontName, const Common::Point &pos, int maxChars): Dialog(vm) { _vm = vm; - _fontName = fontName; + _font = _vm->_font->getFont(fontName); _position = pos; _vm->_font->setColors(TEXTDIALOG_BLACK, TEXTDIALOG_BLACK, TEXTDIALOG_BLACK, TEXTDIALOG_BLACK); - _innerWidth = (_vm->_font->maxWidth() + 1) * maxChars; + _innerWidth = (_font->maxWidth() + 1) * maxChars; _width = _innerWidth + 10; _lineSize = maxChars * 2; _lineWidth = 0; @@ -139,7 +141,7 @@ void TextDialog::addLine(const Common::String &line, bool underline) { if (_lineWidth > 0 || _currentX > 0) incNumLines(); - int stringWidth = _vm->_font->getWidth(line, 1); + int stringWidth = _font->getWidth(line, 1); if (stringWidth >= _innerWidth || (int)line.size() >= _lineSize) { wordWrap(line); } else { @@ -211,7 +213,7 @@ void TextDialog::wordWrap(const Common::String &line) { tempLine2 += ' '; tempLine2 += tempLine; - int lineWidth = _vm->_font->getWidth(tempLine2, 1); + int lineWidth = _font->getWidth(tempLine2, 1); if (((_currentX + (int)tempLine2.size()) > _lineSize) || ((_lineWidth + lineWidth) > _innerWidth)) { incNumLines(); @@ -228,7 +230,7 @@ void TextDialog::wordWrap(const Common::String &line) { void TextDialog::appendLine(const Common::String &line) { _currentX += line.size(); - _lineWidth += _vm->_font->getWidth(line, 1); + _lineWidth += _font->getWidth(line, 1); _lines[_numLines] += line; } @@ -255,7 +257,7 @@ void TextDialog::draw() { --_numLines; // Figure out the size and position for the dialog - _height = (_vm->_font->getHeight() + 1) * (_numLines + 1) + 10; + _height = (_font->getHeight() + 1) * (_numLines + 1) + 10; if (_position.x == -1) _position.x = 160 - (_width / 2); if (_position.y == -1) @@ -275,7 +277,7 @@ void TextDialog::draw() { if (_lineXp[lineNum] == -1) { // Draw a line across the entire dialog _vm->_screen.hLine(_position.x + 2, - lineYp + (_vm->_font->getHeight() + 1) / 2, + lineYp + (_font->getHeight() + 1) / 2, _position.x + _width - 4, TEXTDIALOG_BLACK); } else { // Draw a text line @@ -284,24 +286,26 @@ void TextDialog::draw() { if (_lineXp[lineNum] & 0x40) ++yp; - _vm->_font->writeString(&_vm->_screen, _lines[lineNum], + _font->writeString(&_vm->_screen, _lines[lineNum], Common::Point(xp, yp), 1); if (_lineXp[lineNum] & 0x80) { // Draw an underline under the text - int lineWidth = _vm->_font->getWidth(_lines[lineNum], 1); - _vm->_screen.hLine(xp, yp + _vm->_font->getHeight(), xp + lineWidth, + int lineWidth = _font->getWidth(_lines[lineNum], 1); + _vm->_screen.hLine(xp, yp + _font->getHeight(), xp + lineWidth, TEXTDIALOG_BLACK); } } - lineYp += _vm->_font->getHeight() + 1; + lineYp += _font->getHeight() + 1; } + + _vm->_screen.copyRectToScreen(getBounds()); } void TextDialog::drawWithInput() { //int innerWidth = _innerWidth; - //int lineHeight = _vm->_font->getHeight() + 1; + //int lineHeight = _font->getHeight() + 1; //int xp = _position.x + 5; // Draw the content of the dialog @@ -322,10 +326,9 @@ void TextDialog::show() { draw(); _vm->_events->showCursor(); - while (!_vm->shouldQuit() && !_vm->_events->_keyPressed && - !_vm->_events->_mouseClicked) { - _vm->_events->delay(1); - } + do { + _vm->_events->waitForNextFrame(); + } while (!_vm->shouldQuit() && !_vm->_events->_mouseReleased); } /*------------------------------------------------------------------------*/ -- cgit v1.2.3 From 4639d37609f62bae8d0bcffc5a2e64c79f2659a7 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 4 Apr 2014 09:35:18 -0400 Subject: MADS: Fixes for properly displaying the text of a message dialog --- engines/mads/dialogs.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'engines/mads/dialogs.cpp') diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp index 13342f14f1..d5e8ad5ba9 100644 --- a/engines/mads/dialogs.cpp +++ b/engines/mads/dialogs.cpp @@ -43,6 +43,8 @@ void Dialog::save(MSurface *s) { s->copyTo(_savedSurface, Common::Rect(_position.x, _position.y, _position.x + _width, _position.y + _height), Common::Point()); + + _vm->_screen.copyRectToScreen(getBounds()); } void Dialog::restore(MSurface *s) { @@ -50,6 +52,8 @@ void Dialog::restore(MSurface *s) { _savedSurface->copyTo(s, _position); delete _savedSurface; _savedSurface = nullptr; + + _vm->_screen.copyRectToScreen(getBounds()); } } @@ -76,8 +80,6 @@ void Dialog::draw() { drawContent(Common::Rect(_position.x + 2, _position.y + 2, _position.x + _width - 2, _position.y + _height - 2), 0, TEXTDIALOG_CONTENT1, TEXTDIALOG_CONTENT2); - - _vm->_screen.copyRectToScreen(bounds); } void Dialog::drawContent(const Common::Rect &r, int seed, byte color1, byte color2) { @@ -273,7 +275,7 @@ void TextDialog::draw() { // Draw the text lines int lineYp = _position.y + 5; - for (int lineNum = 0; lineNum < _numLines; ++lineNum) { + for (int lineNum = 0; lineNum <= _numLines; ++lineNum) { if (_lineXp[lineNum] == -1) { // Draw a line across the entire dialog _vm->_screen.hLine(_position.x + 2, @@ -326,9 +328,14 @@ void TextDialog::show() { draw(); _vm->_events->showCursor(); + // Wait for mouse click do { _vm->_events->waitForNextFrame(); } while (!_vm->shouldQuit() && !_vm->_events->_mouseReleased); + + // Allow the mouse release to be gobbled up + if (!_vm->shouldQuit()) + _vm->_events->waitForNextFrame(); } /*------------------------------------------------------------------------*/ -- cgit v1.2.3 From 4e13e74f2774a182b82abe6aa9400c5098bac4d9 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 6 Apr 2014 17:50:07 -0400 Subject: MADS: Fix to correctly wrap lines in text dialogs --- engines/mads/dialogs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/mads/dialogs.cpp') diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp index d5e8ad5ba9..23015413b8 100644 --- a/engines/mads/dialogs.cpp +++ b/engines/mads/dialogs.cpp @@ -232,7 +232,7 @@ void TextDialog::wordWrap(const Common::String &line) { void TextDialog::appendLine(const Common::String &line) { _currentX += line.size(); - _lineWidth += _font->getWidth(line, 1); + _lineWidth += _font->getWidth(line, 1) + 1; _lines[_numLines] += line; } -- cgit v1.2.3 From 531ebab4da814aac23a9b084772a6156bfb3b9b8 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 8 Apr 2014 22:04:43 -0400 Subject: MADS: Added preliminary keyboard handling and keypress process stub --- engines/mads/dialogs.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'engines/mads/dialogs.cpp') diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp index 23015413b8..8bc73e55dc 100644 --- a/engines/mads/dialogs.cpp +++ b/engines/mads/dialogs.cpp @@ -331,11 +331,13 @@ void TextDialog::show() { // Wait for mouse click do { _vm->_events->waitForNextFrame(); - } while (!_vm->shouldQuit() && !_vm->_events->_mouseReleased); + } while (!_vm->shouldQuit() && !_vm->_events->isKeyPressed() && !_vm->_events->_mouseReleased); - // Allow the mouse release to be gobbled up - if (!_vm->shouldQuit()) + // Allow the mouse release or keypress to be gobbled up + if (!_vm->shouldQuit()) { _vm->_events->waitForNextFrame(); + _vm->_events->_pendingKeys.clear(); + } } /*------------------------------------------------------------------------*/ -- cgit v1.2.3 From 1362414e77bfbd17d7a0224ce5fb7275c793c7c4 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 19 Apr 2014 22:49:14 -0400 Subject: MADS: Implement palette animation code --- engines/mads/dialogs.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/mads/dialogs.cpp') diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp index 8bc73e55dc..3c771e7ed9 100644 --- a/engines/mads/dialogs.cpp +++ b/engines/mads/dialogs.cpp @@ -125,7 +125,7 @@ TextDialog::TextDialog(MADSEngine *vm, const Common::String &fontName, // Save the high end of the palette, and set up the entries for dialog display Common::copy(&_vm->_palette->_mainPalette[TEXTDIALOG_CONTENT1 * 3], &_vm->_palette->_mainPalette[TEXTDIALOG_CONTENT1 * 3 + 8 * 3], - &_savedPalette[0]); + &_cyclingPalette[0]); Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_CONTENT1, 2, 0x90, 0x80); Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_EDGE, 2, 0x9C, 0x70); Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_FC, 2, 0x90, 0x80); @@ -319,7 +319,7 @@ void TextDialog::drawWithInput() { } void TextDialog::restorePalette() { - Common::copy(&_savedPalette[0], &_savedPalette[8 * 3], + Common::copy(&_cyclingPalette[0], &_cyclingPalette[8 * 3], &_vm->_palette->_mainPalette[248 * 3]); _vm->_palette->setPalette(_vm->_palette->_mainPalette, 248, 8); } -- cgit v1.2.3 From 87ad5a8397cc332c6e3580725df39925eb5b66c5 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 27 Apr 2014 21:18:24 +0300 Subject: MADS: Add a HACK to reuse the Nebular dialog class for now for V2 games There aren't any dialogs shown yet for these games, we just reuse the implemented class to avoid crashes when it's initialized --- engines/mads/dialogs.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'engines/mads/dialogs.cpp') diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp index 3c771e7ed9..519b273efb 100644 --- a/engines/mads/dialogs.cpp +++ b/engines/mads/dialogs.cpp @@ -362,7 +362,10 @@ Dialogs *Dialogs::init(MADSEngine *vm) { if (vm->getGameID() == GType_RexNebular) return new Nebular::DialogsNebular(vm); - error("Unknown game"); + // Throw a warning for now, since the associated Dialogs class isn't implemented yet + warning("Dialogs: Unknown game"); + // HACK: Reuse the implemented Nebular dialogs for now, to avoid crashing later on + return new Nebular::DialogsNebular(vm); } Dialogs::Dialogs(MADSEngine *vm): _vm(vm) { -- cgit v1.2.3 From b7dd01fdefd910c3c0f6291145ceab4060ae1a70 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 8 May 2014 11:43:23 +0300 Subject: MADS: Remove trailing whitespace --- engines/mads/dialogs.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'engines/mads/dialogs.cpp') diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp index 519b273efb..e68411a4bb 100644 --- a/engines/mads/dialogs.cpp +++ b/engines/mads/dialogs.cpp @@ -40,7 +40,7 @@ Dialog::~Dialog() { void Dialog::save(MSurface *s) { _savedSurface = new MSurface(_width, _height); - s->copyTo(_savedSurface, + s->copyTo(_savedSurface, Common::Rect(_position.x, _position.y, _position.x + _width, _position.y + _height), Common::Point()); @@ -87,7 +87,7 @@ void Dialog::drawContent(const Common::Rect &r, int seed, byte color1, byte colo for (int yp = 0; yp < r.height(); ++yp) { byte *destP = _vm->_screen.getBasePtr(r.left, r.top + yp); - + for (int xp = 0; xp < r.width(); ++xp) { uint16 seedAdjust = currSeed; currSeed += 0x181D; @@ -103,13 +103,13 @@ void Dialog::drawContent(const Common::Rect &r, int seed, byte color1, byte colo /*------------------------------------------------------------------------*/ -TextDialog::TextDialog(MADSEngine *vm, const Common::String &fontName, +TextDialog::TextDialog(MADSEngine *vm, const Common::String &fontName, const Common::Point &pos, int maxChars): Dialog(vm) { _vm = vm; _font = _vm->_font->getFont(fontName); _position = pos; - + _vm->_font->setColors(TEXTDIALOG_BLACK, TEXTDIALOG_BLACK, TEXTDIALOG_BLACK, TEXTDIALOG_BLACK); _innerWidth = (_font->maxWidth() + 1) * maxChars; @@ -123,8 +123,8 @@ TextDialog::TextDialog(MADSEngine *vm, const Common::String &fontName, _askXp = 0; // Save the high end of the palette, and set up the entries for dialog display - Common::copy(&_vm->_palette->_mainPalette[TEXTDIALOG_CONTENT1 * 3], - &_vm->_palette->_mainPalette[TEXTDIALOG_CONTENT1 * 3 + 8 * 3], + Common::copy(&_vm->_palette->_mainPalette[TEXTDIALOG_CONTENT1 * 3], + &_vm->_palette->_mainPalette[TEXTDIALOG_CONTENT1 * 3 + 8 * 3], &_cyclingPalette[0]); Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_CONTENT1, 2, 0x90, 0x80); Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_EDGE, 2, 0x9C, 0x70); @@ -177,7 +177,7 @@ void TextDialog::wordWrap(const Common::String &line) { if (!line.empty()) { const char *srcP = line.c_str(); - + do { tempLine = ""; bool endWord = false; @@ -274,11 +274,11 @@ void TextDialog::draw() { Dialog::draw(); // Draw the text lines - int lineYp = _position.y + 5; + int lineYp = _position.y + 5; for (int lineNum = 0; lineNum <= _numLines; ++lineNum) { if (_lineXp[lineNum] == -1) { // Draw a line across the entire dialog - _vm->_screen.hLine(_position.x + 2, + _vm->_screen.hLine(_position.x + 2, lineYp + (_font->getHeight() + 1) / 2, _position.x + _width - 4, TEXTDIALOG_BLACK); } else { @@ -288,7 +288,7 @@ void TextDialog::draw() { if (_lineXp[lineNum] & 0x40) ++yp; - _font->writeString(&_vm->_screen, _lines[lineNum], + _font->writeString(&_vm->_screen, _lines[lineNum], Common::Point(xp, yp), 1); if (_lineXp[lineNum] & 0x80) { @@ -314,7 +314,7 @@ void TextDialog::drawWithInput() { drawContent(Common::Rect(_position.x + 2, _position.y + 2, _position.x + _width - 2, _position.y + _height - 2), 0, TEXTDIALOG_CONTENT1, TEXTDIALOG_CONTENT2); - + error("TODO: drawWithInput"); } @@ -342,7 +342,7 @@ void TextDialog::show() { /*------------------------------------------------------------------------*/ -MessageDialog::MessageDialog(MADSEngine *vm, int maxChars, ...): +MessageDialog::MessageDialog(MADSEngine *vm, int maxChars, ...): TextDialog(vm, FONT_INTERFACE, Common::Point(-1, -1), maxChars) { // Add in passed line list va_list va; -- cgit v1.2.3 From 8abcbf3fb08fbca6f0cfdb9eabd22cf56e83b440 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 11 May 2014 18:08:31 -0400 Subject: MADS: Refactoring of dialog classes, more implementation of PictureDialog --- engines/mads/dialogs.cpp | 46 +++++++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 17 deletions(-) (limited to 'engines/mads/dialogs.cpp') diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp index e68411a4bb..3ea47c4de6 100644 --- a/engines/mads/dialogs.cpp +++ b/engines/mads/dialogs.cpp @@ -34,22 +34,20 @@ Dialog::Dialog(MADSEngine *vm): _vm(vm), _savedSurface(nullptr), } Dialog::~Dialog() { - restore(&_vm->_screen); } - -void Dialog::save(MSurface *s) { +void Dialog::save() { _savedSurface = new MSurface(_width, _height); - s->copyTo(_savedSurface, + _vm->_screen.copyTo(_savedSurface, Common::Rect(_position.x, _position.y, _position.x + _width, _position.y + _height), Common::Point()); _vm->_screen.copyRectToScreen(getBounds()); } -void Dialog::restore(MSurface *s) { +void Dialog::restore() { if (_savedSurface) { - _savedSurface->copyTo(s, _position); + _savedSurface->copyTo(&_vm->_screen, _position); delete _savedSurface; _savedSurface = nullptr; @@ -58,8 +56,11 @@ void Dialog::restore(MSurface *s) { } void Dialog::draw() { + // Calculate the dialog positioning + calculateBounds(); + // Save the screen portion the dialog will overlap - save(&_vm->_screen); + save(); // Draw the dialog // Fill entire content of dialog @@ -82,6 +83,9 @@ void Dialog::draw() { TEXTDIALOG_CONTENT1, TEXTDIALOG_CONTENT2); } +void Dialog::calculateBounds() { +} + void Dialog::drawContent(const Common::Rect &r, int seed, byte color1, byte color2) { uint16 currSeed = seed ? seed : 0xB78E; @@ -259,16 +263,7 @@ void TextDialog::draw() { --_numLines; // Figure out the size and position for the dialog - _height = (_font->getHeight() + 1) * (_numLines + 1) + 10; - if (_position.x == -1) - _position.x = 160 - (_width / 2); - if (_position.y == -1) - _position.y = 100 - (_height / 2); - - if ((_position.x + _width) > _vm->_screen.getWidth()) - _position.x = _vm->_screen.getWidth() - (_position.x + _width); - if ((_position.y + _height) > _vm->_screen.getHeight()) - _position.y = _vm->_screen.getHeight() - (_position.y + _height); + calculateBounds(); // Draw the underlying dialog Dialog::draw(); @@ -305,6 +300,19 @@ void TextDialog::draw() { _vm->_screen.copyRectToScreen(getBounds()); } +void TextDialog::calculateBounds() { + _height = (_font->getHeight() + 1) * (_numLines + 1) + 10; + if (_position.x == -1) + _position.x = 160 - (_width / 2); + if (_position.y == -1) + _position.y = 100 - (_height / 2); + + if ((_position.x + _width) > _vm->_screen.getWidth()) + _position.x = _vm->_screen.getWidth() - (_position.x + _width); + if ((_position.y + _height) > _vm->_screen.getHeight()) + _position.y = _vm->_screen.getHeight() - (_position.y + _height); +} + void TextDialog::drawWithInput() { //int innerWidth = _innerWidth; //int lineHeight = _font->getHeight() + 1; @@ -325,6 +333,7 @@ void TextDialog::restorePalette() { } void TextDialog::show() { + // Draw the dialog draw(); _vm->_events->showCursor(); @@ -338,6 +347,9 @@ void TextDialog::show() { _vm->_events->waitForNextFrame(); _vm->_events->_pendingKeys.clear(); } + + // Restore the background + restore(); } /*------------------------------------------------------------------------*/ -- cgit v1.2.3 From 24243d57e6a3b6fc291b754339aa60e98a76592e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 11 May 2014 23:57:01 -0400 Subject: MADS: Fix dialog colors for PictureDialog class --- engines/mads/dialogs.cpp | 47 ++++++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 19 deletions(-) (limited to 'engines/mads/dialogs.cpp') diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp index 3ea47c4de6..b1a0b53b5a 100644 --- a/engines/mads/dialogs.cpp +++ b/engines/mads/dialogs.cpp @@ -31,6 +31,14 @@ namespace MADS { Dialog::Dialog(MADSEngine *vm): _vm(vm), _savedSurface(nullptr), _position(Common::Point(-1, -1)), _width(0), _height(0) { + TEXTDIALOG_CONTENT1 = 0XF8; + TEXTDIALOG_CONTENT2 = 0XF9; + TEXTDIALOG_EDGE = 0XFA; + TEXTDIALOG_BACKGROUND = 0XFB; + TEXTDIALOG_FC = 0XFC; + TEXTDIALOG_FD = 0XFD; + TEXTDIALOG_FE = 0XFE; + TEXTDIALOG_BLACK = 0; } Dialog::~Dialog() { @@ -52,6 +60,10 @@ void Dialog::restore() { _savedSurface = nullptr; _vm->_screen.copyRectToScreen(getBounds()); + + Common::copy(&_dialogPalette[0], &_dialogPalette[8 * 3], + &_vm->_palette->_mainPalette[248 * 3]); + _vm->_palette->setPalette(_vm->_palette->_mainPalette, 248, 8); } } @@ -62,6 +74,8 @@ void Dialog::draw() { // Save the screen portion the dialog will overlap save(); + setDialogPalette(); + // Draw the dialog // Fill entire content of dialog Common::Rect bounds = getBounds(); @@ -83,6 +97,20 @@ void Dialog::draw() { TEXTDIALOG_CONTENT1, TEXTDIALOG_CONTENT2); } +void Dialog::setDialogPalette() { + // Save the high end of the palette, and set up the entries for dialog display + Common::copy(&_vm->_palette->_mainPalette[TEXTDIALOG_CONTENT1 * 3], + &_vm->_palette->_mainPalette[TEXTDIALOG_CONTENT1 * 3 + 8 * 3], + &_dialogPalette[0]); + Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_CONTENT1, 2, 0x90, 0x80); + Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_EDGE, 2, 0x9C, 0x70); + Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_FC, 2, 0x90, 0x80); + Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_FE, 1, 0xDC, 0xDC); + + _vm->_palette->setPalette(_vm->_palette->_mainPalette + (TEXTDIALOG_CONTENT1 * 3), + TEXTDIALOG_CONTENT1, 8); +} + void Dialog::calculateBounds() { } @@ -125,22 +153,9 @@ TextDialog::TextDialog(MADSEngine *vm, const Common::String &fontName, Common::fill(&_lineXp[0], &_lineXp[TEXT_DIALOG_MAX_LINES], 0); _askLineNum = -1; _askXp = 0; - - // Save the high end of the palette, and set up the entries for dialog display - Common::copy(&_vm->_palette->_mainPalette[TEXTDIALOG_CONTENT1 * 3], - &_vm->_palette->_mainPalette[TEXTDIALOG_CONTENT1 * 3 + 8 * 3], - &_cyclingPalette[0]); - Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_CONTENT1, 2, 0x90, 0x80); - Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_EDGE, 2, 0x9C, 0x70); - Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_FC, 2, 0x90, 0x80); - Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_FE, 1, 0xDC, 0xDC); - - _vm->_palette->setPalette(_vm->_palette->_mainPalette + (TEXTDIALOG_CONTENT1 * 3), - TEXTDIALOG_CONTENT1, 8); } TextDialog::~TextDialog() { - restorePalette(); } void TextDialog::addLine(const Common::String &line, bool underline) { @@ -326,12 +341,6 @@ void TextDialog::drawWithInput() { error("TODO: drawWithInput"); } -void TextDialog::restorePalette() { - Common::copy(&_cyclingPalette[0], &_cyclingPalette[8 * 3], - &_vm->_palette->_mainPalette[248 * 3]); - _vm->_palette->setPalette(_vm->_palette->_mainPalette, 248, 8); -} - void TextDialog::show() { // Draw the dialog draw(); -- cgit v1.2.3 From 9866aba2e43da914a17d17b695456ca25a875469 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 27 May 2014 00:58:25 +0200 Subject: MADS: Slight formatting fixes. --- engines/mads/dialogs.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'engines/mads/dialogs.cpp') diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp index b1a0b53b5a..dc8c846beb 100644 --- a/engines/mads/dialogs.cpp +++ b/engines/mads/dialogs.cpp @@ -29,8 +29,9 @@ namespace MADS { -Dialog::Dialog(MADSEngine *vm): _vm(vm), _savedSurface(nullptr), - _position(Common::Point(-1, -1)), _width(0), _height(0) { +Dialog::Dialog(MADSEngine *vm) + : _vm(vm), _savedSurface(nullptr), _position(Common::Point(-1, -1)), + _width(0), _height(0) { TEXTDIALOG_CONTENT1 = 0XF8; TEXTDIALOG_CONTENT2 = 0XF9; TEXTDIALOG_EDGE = 0XFA; @@ -136,8 +137,8 @@ void Dialog::drawContent(const Common::Rect &r, int seed, byte color1, byte colo /*------------------------------------------------------------------------*/ TextDialog::TextDialog(MADSEngine *vm, const Common::String &fontName, - const Common::Point &pos, int maxChars): - Dialog(vm) { + const Common::Point &pos, int maxChars) + : Dialog(vm) { _vm = vm; _font = _vm->_font->getFont(fontName); _position = pos; @@ -363,8 +364,8 @@ void TextDialog::show() { /*------------------------------------------------------------------------*/ -MessageDialog::MessageDialog(MADSEngine *vm, int maxChars, ...): - TextDialog(vm, FONT_INTERFACE, Common::Point(-1, -1), maxChars) { +MessageDialog::MessageDialog(MADSEngine *vm, int maxChars, ...) + : TextDialog(vm, FONT_INTERFACE, Common::Point(-1, -1), maxChars) { // Add in passed line list va_list va; va_start(va, maxChars); @@ -389,7 +390,8 @@ Dialogs *Dialogs::init(MADSEngine *vm) { return new Nebular::DialogsNebular(vm); } -Dialogs::Dialogs(MADSEngine *vm): _vm(vm) { +Dialogs::Dialogs(MADSEngine *vm) + : _vm(vm) { _pendingDialog = DIALOG_NONE; } -- cgit v1.2.3