diff options
author | Paul Gilbert | 2014-05-11 18:08:31 -0400 |
---|---|---|
committer | Paul Gilbert | 2014-05-11 18:08:31 -0400 |
commit | 8abcbf3fb08fbca6f0cfdb9eabd22cf56e83b440 (patch) | |
tree | 9b24d0bd0e59fc81371ded67613a821fb3c2f323 /engines/mads/nebular | |
parent | e21534ecc2d39864d2cb3ba67248ad0dadecf72e (diff) | |
download | scummvm-rg350-8abcbf3fb08fbca6f0cfdb9eabd22cf56e83b440.tar.gz scummvm-rg350-8abcbf3fb08fbca6f0cfdb9eabd22cf56e83b440.tar.bz2 scummvm-rg350-8abcbf3fb08fbca6f0cfdb9eabd22cf56e83b440.zip |
MADS: Refactoring of dialog classes, more implementation of PictureDialog
Diffstat (limited to 'engines/mads/nebular')
-rw-r--r-- | engines/mads/nebular/dialogs_nebular.cpp | 86 | ||||
-rw-r--r-- | engines/mads/nebular/dialogs_nebular.h | 9 |
2 files changed, 50 insertions, 45 deletions
diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp index 6ddb3230d9..2e020f3677 100644 --- a/engines/mads/nebular/dialogs_nebular.cpp +++ b/engines/mads/nebular/dialogs_nebular.cpp @@ -171,20 +171,6 @@ void DialogsNebular::showItem(int objectId, int messageId, int speech) { assert(!speech); show(messageId, objectId); -#if 0 - Scene &scene = _vm->_game->_scene; - byte highPalette[8 * 3]; - Common::copy(&_vm->_palette->_mainPalette[0x2E8], &_vm->_palette->_mainPalette[PALETTE_SIZE], - &highPalette[0]); - byte *depthP = scene._depthSurface.getData(); - byte greyScale[3]; - greyScale[0] = greyScale[1] = greyScale[2] = 0xFFFF; - Common::String setName = Common::String::format("*OBJ%.3d.SS", objectId); - - - - delete[] savedSurface; -#endif } Common::String DialogsNebular::getVocab(int vocabId) { @@ -211,7 +197,7 @@ Common::String DialogsNebular::getVocab(int vocabId) { bool DialogsNebular::textNoun(Common::String &dialogText, int nounNum, const Common::String &valStr) { - warning("TODO: textNoun"); + error("TODO: textNoun"); return false; } @@ -337,12 +323,25 @@ bool CopyProtectionDialog::getHogAnusEntry(HOGANUS &entry) { PictureDialog::PictureDialog(MADSEngine *vm, const Common::Point &pos, int maxChars, int objectId) : TextDialog(vm, FONT_INTERFACE, pos, maxChars), _objectId(objectId) { - Scene &scene = _vm->_game->_scene; - Palette &palette = *_vm->_palette; - // Turn off cycling if active + Scene &scene = _vm->_game->_scene; _cyclingActive = scene._cyclingActive; scene._cyclingActive = false; +} + +PictureDialog::~PictureDialog() { + // Restore cycling flag + Scene &scene = _vm->_game->_scene; + scene._cyclingActive = _cyclingActive; +} + +void PictureDialog::save() { + Palette &palette = *_vm->_palette; + byte map[PALETTE_COUNT]; + + // Save the entire screen + _savedSurface = new MSurface(MADS_SCREEN_WIDTH, MADS_SCREEN_HEIGHT); + _vm->_screen.copyTo(_savedSurface); // Save palette information Common::copy(&palette._mainPalette[0], &palette._mainPalette[PALETTE_SIZE], &_palette[0]); @@ -358,34 +357,43 @@ PictureDialog::PictureDialog(MADSEngine *vm, const Common::Point &pos, // Reset the flag list palette._rgbList.reset(); -} -PictureDialog::~PictureDialog() { - // Restore cycling flag - Scene &scene = _vm->_game->_scene; - Palette &palette = *_vm->_palette; - scene._cyclingActive = _cyclingActive; + // Fade the screen to grey + int numColors = PALETTE_COUNT - PALETTE_RESERVED_LOW_COUNT - PALETTE_RESERVED_HIGH_COUNT; + palette.fadeToGrey(palette._mainPalette, &map[PALETTE_RESERVED_LOW_COUNT], + PALETTE_RESERVED_LOW_COUNT, numColors, 248, 8, 1, 16); - // Restore palette information - Common::copy(&_palette[0], &_palette[PALETTE_SIZE], &palette._mainPalette[0]); - _vm->_palette->setFullPalette(palette._mainPalette); - Common::copy(&_palFlags[0], &_palFlags[PALETTE_COUNT], &palette._palFlags[0]); - palette._rgbList.copy(_rgbList); -} + // Remap the greyed out screen to use the small greyscale range + // at the top end of the palette + _vm->_screen.translate(map); -void PictureDialog::show() { - setupPalette(); + // Load the inventory picture + Common::String setName = Common::String::format("*OB%.3d.SS", _objectId); + SpriteAsset *asset = new SpriteAsset(_vm, setName, 0x8000); + palette.setFullPalette(palette._mainPalette); - TextDialog::show(); + // Draw the inventory picture + MSprite *frame = asset->getFrame(0); + frame->copyTo(&_vm->_screen, Common::Point(160 - frame->w / 2, 6), + frame->getTransparencyIndex()); + _vm->_screen.copyRectToScreen(_vm->_screen.getBounds()); } -void PictureDialog::setupPalette() { - Palette &palette = *_vm->_palette; - byte map[PALETTE_COUNT]; +void PictureDialog::restore() { + if (_savedSurface) { + _savedSurface->copyTo(&_vm->_screen); + delete _savedSurface; + _savedSurface = nullptr; - int numColors = PALETTE_COUNT - PALETTE_RESERVED_LOW_COUNT - PALETTE_RESERVED_HIGH_COUNT; - palette.fadeToGrey(palette._mainPalette, &map[PALETTE_RESERVED_LOW_COUNT], - PALETTE_RESERVED_LOW_COUNT, numColors, 248, 8, 1, 16); + _vm->_screen.copyRectToScreen(_vm->_screen.getBounds()); + + // Restore palette information + Palette &palette = *_vm->_palette; + Common::copy(&_palette[0], &_palette[PALETTE_SIZE], &palette._mainPalette[0]); + _vm->_palette->setFullPalette(palette._mainPalette); + Common::copy(&_palFlags[0], &_palFlags[PALETTE_COUNT], &palette._palFlags[0]); + palette._rgbList.copy(_rgbList); + } } /*------------------------------------------------------------------------*/ diff --git a/engines/mads/nebular/dialogs_nebular.h b/engines/mads/nebular/dialogs_nebular.h index fd4d6e706e..60a215197f 100644 --- a/engines/mads/nebular/dialogs_nebular.h +++ b/engines/mads/nebular/dialogs_nebular.h @@ -89,17 +89,14 @@ private: byte _palette[PALETTE_SIZE]; uint32 _palFlags[PALETTE_COUNT]; RGBList _rgbList; +protected: + virtual void save(); - /** - * Sets up the palette and fades the screen to gray - */ - void setupPalette(); + virtual void restore(); public: PictureDialog(MADSEngine *vm, const Common::Point &pos, int maxChars, int objectId); virtual ~PictureDialog(); - - virtual void show(); }; enum DialogTextAlign { ALIGN_CENTER = -1, ALIGN_AT_CENTER = -2, ALIGN_RIGHT = -3 }; |