aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/mads/dialogs.cpp47
-rw-r--r--engines/mads/dialogs.h54
-rw-r--r--engines/mads/nebular/dialogs_nebular.cpp12
3 files changed, 66 insertions, 47 deletions
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();
diff --git a/engines/mads/dialogs.h b/engines/mads/dialogs.h
index 078415bad9..6de6ea71c1 100644
--- a/engines/mads/dialogs.h
+++ b/engines/mads/dialogs.h
@@ -31,27 +31,24 @@
namespace MADS {
class Dialog {
+private:
+ void setDialogPalette();
protected:
MADSEngine *_vm;
MSurface *_savedSurface;
Common::Point _position;
int _width;
int _height;
-
- /**
- * Save the section of the passed surface the dialog will cover.
- */
- virtual void save();
-
- /**
- * Restore saved dialog surface
- */
- virtual void restore();
-
- /**
- * Draws the content of a dialog with a gravelly alternating color.
- */
- void drawContent(const Common::Rect &r, int seed, byte color1, byte color2);
+ byte _dialogPalette[8 * 3];
+
+ int TEXTDIALOG_CONTENT1;
+ int TEXTDIALOG_CONTENT2;
+ int TEXTDIALOG_EDGE;
+ int TEXTDIALOG_BACKGROUND;
+ int TEXTDIALOG_FC;
+ int TEXTDIALOG_FD;
+ int TEXTDIALOG_FE;
+ int TEXTDIALOG_BLACK;
protected:
/**
* Draw the dialog
@@ -62,6 +59,21 @@ protected:
* Calculate bounds for the dialog
*/
virtual void calculateBounds();
+
+ /**
+ * Save the section of the passed surface the dialog will cover.
+ */
+ virtual void save();
+
+ /**
+ * Restore saved dialog surface
+ */
+ virtual void restore();
+
+ /**
+ * Draws the content of a dialog with a gravelly alternating color.
+ */
+ void drawContent(const Common::Rect &r, int seed, byte color1, byte color2);
public:
/**
* Constructor
@@ -82,17 +94,6 @@ public:
}
};
-enum {
- TEXTDIALOG_CONTENT1 = 0XF8,
- TEXTDIALOG_CONTENT2 = 0XF9,
- TEXTDIALOG_EDGE = 0XFA,
- TEXTDIALOG_BACKGROUND = 0XFB,
- TEXTDIALOG_FC = 0XFC,
- TEXTDIALOG_FD = 0XFD,
- TEXTDIALOG_FE = 0XFE,
- TEXTDIALOG_BLACK = 0
-};
-
#define TEXT_DIALOG_MAX_LINES 20
class TextDialog: protected Dialog {
@@ -117,7 +118,6 @@ protected:
int _askLineNum;
Common::String _lines[TEXT_DIALOG_MAX_LINES];
int _lineXp[TEXT_DIALOG_MAX_LINES];
- byte _cyclingPalette[8 * 3];
/**
* Calculate the bounds for the dialog
diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp
index 63b0edf2f1..df423f92a8 100644
--- a/engines/mads/nebular/dialogs_nebular.cpp
+++ b/engines/mads/nebular/dialogs_nebular.cpp
@@ -416,13 +416,23 @@ void PictureDialog::save() {
SpriteAsset *asset = new SpriteAsset(_vm, setName, 0x8000);
palette.setFullPalette(palette._mainPalette);
- // Draw the inventory picture
+ // Get the inventory frame, and adjust the dialog position to allow for it
MSprite *frame = asset->getFrame(0);
_position.y = frame->h + 12;
+ // Draw the inventory picture
frame->copyTo(&_vm->_screen, Common::Point(160 - frame->w / 2, 6),
frame->getTransparencyIndex());
_vm->_screen.copyRectToScreen(_vm->_screen.getBounds());
+
+ // Adjust the dialog colours to use
+ TEXTDIALOG_CONTENT1 -= 10;
+ TEXTDIALOG_CONTENT2 -= 10;
+ TEXTDIALOG_EDGE -= 10;
+ TEXTDIALOG_BACKGROUND -= 10;
+ TEXTDIALOG_FC -= 10;
+ TEXTDIALOG_FD -= 10;
+ TEXTDIALOG_FE -= 10;
}
void PictureDialog::restore() {