diff options
author | Paul Gilbert | 2014-02-23 13:39:53 -0500 |
---|---|---|
committer | Paul Gilbert | 2014-02-23 13:39:53 -0500 |
commit | 1d80edb2dd092b7e91805f359f0e2a7d470ed7c4 (patch) | |
tree | 3115206f755c336ece75b34b76d76811850dc8e9 /engines | |
parent | 6b774d228495e2dc9de08520a3064889d439335d (diff) | |
download | scummvm-rg350-1d80edb2dd092b7e91805f359f0e2a7d470ed7c4.tar.gz scummvm-rg350-1d80edb2dd092b7e91805f359f0e2a7d470ed7c4.tar.bz2 scummvm-rg350-1d80edb2dd092b7e91805f359f0e2a7d470ed7c4.zip |
MADS: Fixes for the display of dialogs
Diffstat (limited to 'engines')
-rw-r--r-- | engines/mads/dialogs.cpp | 47 | ||||
-rw-r--r-- | engines/mads/dialogs.h | 10 | ||||
-rw-r--r-- | engines/mads/msurface.cpp | 71 | ||||
-rw-r--r-- | engines/mads/msurface.h | 58 | ||||
-rw-r--r-- | engines/mads/nebular/dialogs_nebular.cpp | 3 |
5 files changed, 46 insertions, 143 deletions
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]); diff --git a/engines/mads/dialogs.h b/engines/mads/dialogs.h index 163d66ed51..0945ad9436 100644 --- a/engines/mads/dialogs.h +++ b/engines/mads/dialogs.h @@ -126,6 +126,11 @@ protected: * Adds one or more lines, word wrapping the passed text */ void wordWrap(const Common::String &line); + + /** + * Adds an input area following previously added text + */ + void addInput(); public: /** * Constructor @@ -146,6 +151,11 @@ public: * Draw the dialog */ virtual void draw(); + + /** + * Draw the dialog along with any input box + */ + void drawWithInput(); }; class MessageDialog: protected TextDialog { diff --git a/engines/mads/msurface.cpp b/engines/mads/msurface.cpp index 0846470e60..a9561cdd9b 100644 --- a/engines/mads/msurface.cpp +++ b/engines/mads/msurface.cpp @@ -66,77 +66,6 @@ void MSurface::setSize(int width, int height) { Graphics::Surface::create(width, height, Graphics::PixelFormat::createFormatCLUT8()); } -void MSurface::vLine(int x, int y1, int y2) { - Graphics::Surface::vLine(x, y1, y2, _color); -} - -void MSurface::hLine(int x1, int x2, int y) { - Graphics::Surface::hLine(x1, y, x2, _color); -} - -void MSurface::vLineXor(int x, int y1, int y2) { - // Clipping - if (x < 0 || x >= w) - return; - - if (y2 < y1) - SWAP(y2, y1); - - if (y1 < 0) - y1 = 0; - if (y2 >= h) - y2 = h - 1; - - byte *ptr = (byte *)getBasePtr(x, y1); - while (y1++ <= y2) { - *ptr ^= 0xFF; - ptr += pitch; - } - -} - -void MSurface::hLineXor(int x1, int x2, int y) { - // Clipping - if (y < 0 || y >= h) - return; - - if (x2 < x1) - SWAP(x2, x1); - - if (x1 < 0) - x1 = 0; - if (x2 >= w) - x2 = w - 1; - - if (x2 < x1) - return; - - byte *ptr = (byte *)getBasePtr(x1, y); - while (x1++ <= x2) - *ptr++ ^= 0xFF; - -} - -void MSurface::line(const Common::Point &startPos, const Common::Point &endPos, byte color) { - Graphics::Surface::drawLine(startPos.x, startPos.y, endPos.x, endPos.y, color); -} - -void MSurface::frameRect(const Common::Rect &r) { - Graphics::Surface::frameRect(r, _color); -} - -void MSurface::frameRect(const Common::Rect &r, byte color) { - Graphics::Surface::frameRect(r, color); -} - -void MSurface::fillRect(const Common::Rect &r) { - Graphics::Surface::fillRect(r, _color); -} - -void MSurface::fillRect(const Common::Rect &r, byte color) { - Graphics::Surface::fillRect(r, color); -} - int MSurface::scaleValue(int value, int scale, int err) { int scaled = 0; while (value--) { diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h index 2e4ca7e728..3904aa1e92 100644 --- a/engines/mads/msurface.h +++ b/engines/mads/msurface.h @@ -67,8 +67,6 @@ public: * Create a surface */ static MSurface *init(int width, int height); -private: - byte _color; protected: /** * Basic constructor @@ -96,36 +94,6 @@ public: void setSize(int width, int height); /** - * Sets the color used for drawing on the surface - */ - void setColor(byte value) { _color = value; } - - /** - * Returns the currently active color - */ - byte getColor() const { return _color; } - - /** - * Draws a vertical line using the currently set color - */ - void vLine(int x, int y1, int y2); - - /** - * Draws a horizontal line using the currently set color - */ - void hLine(int x1, int x2, int y); - - /** - * Draws a vertical line using an Xor on each pixel - */ - void vLineXor(int x, int y1, int y2); - - /** - * Draws a horizontal line using an Xor on each pixel - */ - void hLineXor(int x1, int x2, int y); - - /** * Draws an arbitrary line on the screen using a specified color * @param startPos Starting position * @param endPos Ending position @@ -134,32 +102,6 @@ public: void line(const Common::Point &startPos, const Common::Point &endPos, byte color); /** - * Draws a rectangular frame using the currently set color - * @param r Bounds for rectangle - */ - void frameRect(const Common::Rect &r); - - /** - * Draws a rectangular frame using the currently set color - * @param r Bounds for rectangle - * @param color Color to use - */ - void frameRect(const Common::Rect &r, byte color); - - /** - * Draws a filled in box using the currently set color - * @param r Bounds for rectangle - */ - void fillRect(const Common::Rect &r); - - /** - * Draws a filled in box using the currently set color - * @param r Bounds for rectangle - * @param color Color to use - */ - void fillRect(const Common::Rect &r, byte color); - - /** * Draws a sprite * @param pt Position to draw sprite at * @param info General sprite details diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp index 95a485d170..6d2321eae2 100644 --- a/engines/mads/nebular/dialogs_nebular.cpp +++ b/engines/mads/nebular/dialogs_nebular.cpp @@ -67,9 +67,8 @@ CopyProtectionDialog::CopyProtectionDialog(MADSEngine *vm, bool priorAnswerWrong wordWrap("right into this really COOL adventure game!\n"); wordWrap("\n"); wordWrap(" "); + addInput(); wordWrap("\n"); - - // TODO: Rest of setup } bool CopyProtectionDialog::show() { |