From deada3e30d1b897191dd2a97ac74999a1f967578 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 21 Jun 2015 10:11:43 -0400 Subject: SHERLOCK: RT: Beginnings of journal display --- engines/sherlock/tattoo/tattoo_journal.cpp | 21 +++ engines/sherlock/tattoo/tattoo_journal.h | 8 ++ engines/sherlock/tattoo/tattoo_scene.cpp | 150 +++++++--------------- engines/sherlock/tattoo/tattoo_scene.h | 10 -- engines/sherlock/tattoo/tattoo_user_interface.cpp | 73 ++++++++++- engines/sherlock/tattoo/tattoo_user_interface.h | 11 ++ 6 files changed, 154 insertions(+), 119 deletions(-) (limited to 'engines') diff --git a/engines/sherlock/tattoo/tattoo_journal.cpp b/engines/sherlock/tattoo/tattoo_journal.cpp index ff4f6b3eda..380f6efc54 100644 --- a/engines/sherlock/tattoo/tattoo_journal.cpp +++ b/engines/sherlock/tattoo/tattoo_journal.cpp @@ -21,6 +21,8 @@ */ #include "sherlock/tattoo/tattoo_journal.h" +#include "sherlock/tattoo/tattoo_scene.h" +#include "sherlock/tattoo/tattoo_user_interface.h" #include "sherlock/sherlock.h" namespace Sherlock { @@ -28,6 +30,25 @@ namespace Sherlock { namespace Tattoo { TattooJournal::TattooJournal(SherlockEngine *vm) : Journal(vm) { + _journalImages = nullptr; +} + +void TattooJournal::show() { + Resources &res = *_vm->_res; + Screen &screen = *_vm->_screen; + TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui; + + // Load journal images + _journalImages = new ImageFile("journal.vgs"); + + // Load palette + Common::SeekableReadStream *stream = res.load("journal.pal"); + stream->read(screen._tMap, PALETTE_SIZE); + screen.translatePalette(screen._tMap); + ui.setupBGArea(screen._tMap); + + + delete _journalImages; } void TattooJournal::synchronize(Serializer &s) { diff --git a/engines/sherlock/tattoo/tattoo_journal.h b/engines/sherlock/tattoo/tattoo_journal.h index ebfcd4691b..db70c290fc 100644 --- a/engines/sherlock/tattoo/tattoo_journal.h +++ b/engines/sherlock/tattoo/tattoo_journal.h @@ -24,16 +24,24 @@ #define SHERLOCK_TATTOO_JOURNAL_H #include "sherlock/journal.h" +#include "sherlock/image_file.h" namespace Sherlock { namespace Tattoo { class TattooJournal : public Journal { +private: + ImageFile *_journalImages; public: TattooJournal(SherlockEngine *vm); virtual ~TattooJournal() {} + /** + * Show the journal + */ + void show(); + /** * Synchronize the data for a savegame */ diff --git a/engines/sherlock/tattoo/tattoo_scene.cpp b/engines/sherlock/tattoo/tattoo_scene.cpp index 1c398907dd..81ae50ce5e 100644 --- a/engines/sherlock/tattoo/tattoo_scene.cpp +++ b/engines/sherlock/tattoo/tattoo_scene.cpp @@ -50,11 +50,7 @@ static bool sortImagesY(const ShapeEntry &s1, const ShapeEntry &s2) { /*----------------------------------------------------------------*/ TattooScene::TattooScene(SherlockEngine *vm) : Scene(vm) { - Common::fill(&_lookupTable[0], &_lookupTable[PALETTE_COUNT], 0); - Common::fill(&_lookupTable1[0], &_lookupTable1[PALETTE_COUNT], 0); _arrowZone = -1; - _mask = _mask1 = nullptr; - _maskCounter = 0; _labTableScene = false; } @@ -263,7 +259,7 @@ void TattooScene::paletteLoaded() { Screen &screen = *_vm->_screen; TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui; - setupBGArea(screen._cMap); + ui.setupBGArea(screen._cMap); ui.initScrollVars(); } @@ -326,7 +322,7 @@ void TattooScene::doBgAnimEraseBackground() { static const int16 OFFSETS[16] = { -1, -2, -3, -3, -2, -1, -1, 0, 1, 2, 3, 3, 2, 1, 0, 0 }; - if (_mask != nullptr) { + if (ui._mask != nullptr) { if (screen._backBuffer1.w() > screen.w()) screen.blitFrom(screen._backBuffer1, Common::Point(0, 0), Common::Rect(ui._currentScroll.x, 0, ui._currentScroll.x + screen.w(), screen.h())); @@ -335,33 +331,33 @@ void TattooScene::doBgAnimEraseBackground() { switch (_currentScene) { case 7: - if (++_maskCounter == 2) { - _maskCounter = 0; - if (--_maskOffset.x < 0) - _maskOffset.x = SHERLOCK_SCREEN_WIDTH - 1; + if (++ui._maskCounter == 2) { + ui._maskCounter = 0; + if (--ui._maskOffset.x < 0) + ui._maskOffset.x = SHERLOCK_SCREEN_WIDTH - 1; } break; case 8: - _maskOffset.x += 2; - if (_maskOffset.x >= SHERLOCK_SCREEN_WIDTH) - _maskOffset.x = 0; + ui._maskOffset.x += 2; + if (ui._maskOffset.x >= SHERLOCK_SCREEN_WIDTH) + ui._maskOffset.x = 0; break; case 18: case 68: - ++_maskCounter; - if (_maskCounter / 4 >= 16) - _maskCounter = 0; + ++ui._maskCounter; + if (ui._maskCounter / 4 >= 16) + ui._maskCounter = 0; - _maskOffset.x = OFFSETS[_maskCounter / 4]; + ui._maskOffset.x = OFFSETS[ui._maskCounter / 4]; break; case 53: - if (++_maskCounter == 2) { - _maskCounter = 0; - if (++_maskOffset.x == screen._backBuffer1.w()) - _maskOffset.x = 0; + if (++ui._maskCounter == 2) { + ui._maskCounter = 0; + if (++ui._maskOffset.x == screen._backBuffer1.w()) + ui._maskOffset.x = 0; } break; @@ -501,36 +497,36 @@ void TattooScene::doBgAnimUpdateBgObjectsAndAnim() { drawAllShapes(); - if (_mask != nullptr) { + if (ui._mask != nullptr) { switch (_currentScene) { case 7: - screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x - SHERLOCK_SCREEN_WIDTH, 110), ui._currentScroll.x); - screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x, 110), ui._currentScroll.x); - screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x + SHERLOCK_SCREEN_WIDTH, 110), ui._currentScroll.x); + screen._backBuffer1.maskArea((*ui._mask)[0], Common::Point(ui._maskOffset.x - SHERLOCK_SCREEN_WIDTH, 110), ui._currentScroll.x); + screen._backBuffer1.maskArea((*ui._mask)[0], Common::Point(ui._maskOffset.x, 110), ui._currentScroll.x); + screen._backBuffer1.maskArea((*ui._mask)[0], Common::Point(ui._maskOffset.x + SHERLOCK_SCREEN_WIDTH, 110), ui._currentScroll.x); break; case 8: - screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x - SHERLOCK_SCREEN_WIDTH, 180), ui._currentScroll.x); - screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x, 180), ui._currentScroll.x); - screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x + SHERLOCK_SCREEN_WIDTH, 180), ui._currentScroll.x); + screen._backBuffer1.maskArea((*ui._mask)[0], Common::Point(ui._maskOffset.x - SHERLOCK_SCREEN_WIDTH, 180), ui._currentScroll.x); + screen._backBuffer1.maskArea((*ui._mask)[0], Common::Point(ui._maskOffset.x, 180), ui._currentScroll.x); + screen._backBuffer1.maskArea((*ui._mask)[0], Common::Point(ui._maskOffset.x + SHERLOCK_SCREEN_WIDTH, 180), ui._currentScroll.x); if (!_vm->readFlags(880)) - screen._backBuffer1.maskArea((*_mask1)[0], Common::Point(940, 300), ui._currentScroll.x); + screen._backBuffer1.maskArea((*ui._mask1)[0], Common::Point(940, 300), ui._currentScroll.x); break; case 18: - screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x, 203), ui._currentScroll.x); + screen._backBuffer1.maskArea((*ui._mask)[0], Common::Point(ui._maskOffset.x, 203), ui._currentScroll.x); if (!_vm->readFlags(189)) - screen._backBuffer1.maskArea((*_mask1)[0], Common::Point(124 + _maskOffset.x, 239), ui._currentScroll.x); + screen._backBuffer1.maskArea((*ui._mask1)[0], Common::Point(124 + ui._maskOffset.x, 239), ui._currentScroll.x); break; case 53: - screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x, 110), ui._currentScroll.x); - screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x - SHERLOCK_SCREEN_WIDTH, 110), ui._currentScroll.x); + screen._backBuffer1.maskArea((*ui._mask)[0], Common::Point(ui._maskOffset.x, 110), ui._currentScroll.x); + screen._backBuffer1.maskArea((*ui._mask)[0], Common::Point(ui._maskOffset.x - SHERLOCK_SCREEN_WIDTH, 110), ui._currentScroll.x); break; case 68: - screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x, 203), ui._currentScroll.x); - screen._backBuffer1.maskArea((*_mask1)[0], Common::Point(124 + _maskOffset.x, 239), ui._currentScroll.x); + screen._backBuffer1.maskArea((*ui._mask)[0], Common::Point(ui._maskOffset.x, 203), ui._currentScroll.x); + screen._backBuffer1.maskArea((*ui._mask1)[0], Common::Point(124 + ui._maskOffset.x, 239), ui._currentScroll.x); break; } } @@ -543,35 +539,35 @@ void TattooScene::updateBackground() { Scene::updateBackground(); - if (_mask != nullptr) { + if (ui._mask != nullptr) { switch (_currentScene) { case 7: - screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x - SHERLOCK_SCREEN_WIDTH, 110), ui._currentScroll.x); - screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x, 110), ui._currentScroll.x); - screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x + SHERLOCK_SCREEN_WIDTH, 110), ui._currentScroll.x); + screen._backBuffer1.maskArea((*ui._mask)[0], Common::Point(ui._maskOffset.x - SHERLOCK_SCREEN_WIDTH, 110), ui._currentScroll.x); + screen._backBuffer1.maskArea((*ui._mask)[0], Common::Point(ui._maskOffset.x, 110), ui._currentScroll.x); + screen._backBuffer1.maskArea((*ui._mask)[0], Common::Point(ui._maskOffset.x + SHERLOCK_SCREEN_WIDTH, 110), ui._currentScroll.x); break; case 8: - screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x - SHERLOCK_SCREEN_WIDTH, 180), ui._currentScroll.x); - screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x, 180), ui._currentScroll.x); - screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x + SHERLOCK_SCREEN_WIDTH, 180), ui._currentScroll.x); + screen._backBuffer1.maskArea((*ui._mask)[0], Common::Point(ui._maskOffset.x - SHERLOCK_SCREEN_WIDTH, 180), ui._currentScroll.x); + screen._backBuffer1.maskArea((*ui._mask)[0], Common::Point(ui._maskOffset.x, 180), ui._currentScroll.x); + screen._backBuffer1.maskArea((*ui._mask)[0], Common::Point(ui._maskOffset.x + SHERLOCK_SCREEN_WIDTH, 180), ui._currentScroll.x); if (!_vm->readFlags(880)) - screen._backBuffer1.maskArea((*_mask1)[0], Common::Point(940, 300), ui._currentScroll.x); + screen._backBuffer1.maskArea((*ui._mask1)[0], Common::Point(940, 300), ui._currentScroll.x); break; case 18: - screen._backBuffer1.maskArea((*_mask)[0], Common::Point(0, 203), ui._currentScroll.x); + screen._backBuffer1.maskArea((*ui._mask)[0], Common::Point(0, 203), ui._currentScroll.x); if (!_vm->readFlags(189)) - screen._backBuffer1.maskArea((*_mask1)[0], Common::Point(124, 239), ui._currentScroll.x); + screen._backBuffer1.maskArea((*ui._mask1)[0], Common::Point(124, 239), ui._currentScroll.x); break; case 53: - screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x, 110), ui._currentScroll.x); + screen._backBuffer1.maskArea((*ui._mask)[0], Common::Point(ui._maskOffset.x, 110), ui._currentScroll.x); break; case 68: - screen._backBuffer1.maskArea((*_mask)[0], Common::Point(0, 203), ui._currentScroll.x); - screen._backBuffer1.maskArea((*_mask1)[0], Common::Point(124, 239), ui._currentScroll.x); + screen._backBuffer1.maskArea((*ui._mask)[0], Common::Point(0, 203), ui._currentScroll.x); + screen._backBuffer1.maskArea((*ui._mask1)[0], Common::Point(124, 239), ui._currentScroll.x); break; default: @@ -751,64 +747,6 @@ int TattooScene::getScaleVal(const Point32 &pt) { return result; } -void TattooScene::setupBGArea(const byte cMap[PALETTE_SIZE]) { - // This requires that there is a 16 grayscale palette sequence in the palette that goes from lighter - // to darker as the palette numbers go up. The last palette entry in that run is specified by _bgColor - byte *p = &_lookupTable[0]; - for (int idx = 0; idx < PALETTE_COUNT; ++idx) - *p++ = BG_GREYSCALE_RANGE_END - (cMap[idx * 3] * 30 + cMap[idx * 3 + 1] * 59 + cMap[idx * 3 + 2] * 11) / 480; - - // If we're going to a scene with a haze special effect, initialize the translate table to lighten the colors - if (_mask != nullptr) { - p = &_lookupTable1[0]; - - for (int idx = 0; idx < PALETTE_COUNT; ++idx) { - int r, g, b; - switch (_currentScene) { - case 8: - r = cMap[idx * 3] * 4 / 5; - g = cMap[idx * 3 + 1] * 3 / 4; - b = cMap[idx * 3 + 2] * 3 / 4; - break; - - case 18: - case 68: - r = cMap[idx * 3] * 4 / 3; - g = cMap[idx * 3 + 1] * 4 / 3; - b = cMap[idx * 3 + 2] * 4 / 3; - break; - - case 7: - case 53: - r = cMap[idx * 3] * 4 / 3; - g = cMap[idx * 3 + 1] * 4 / 3; - b = cMap[idx * 3 + 2] * 4 / 3; - break; - - default: - r = g = b = 0; - break; - } - - byte c = 0; - int cd = (r - cMap[0]) * (r - cMap[0]) + (g - cMap[1]) * (g - cMap[1]) + (b - cMap[2]) * (b - cMap[2]); - - for (int pal = 0; pal < PALETTE_COUNT; ++pal) { - int d = (r - cMap[pal * 3]) * (r - cMap[pal * 3]) + (g - cMap[pal * 3 + 1]) * (g - cMap[pal * 3 + 1]) - + (b - cMap[pal * 3 + 2])*(b - cMap[pal * 3 + 2]); - - if (d < cd) { - c = pal; - cd = d; - if (!d) - break; - } - } - *p++ = c; - } - } -} - #define ADJUST_COORD(COORD) \ if (COORD.x != -1) \ COORD.x *= FIXED_INT_MULTIPLIER; \ diff --git a/engines/sherlock/tattoo/tattoo_scene.h b/engines/sherlock/tattoo/tattoo_scene.h index 58a73ec557..0118a9dd26 100644 --- a/engines/sherlock/tattoo/tattoo_scene.h +++ b/engines/sherlock/tattoo/tattoo_scene.h @@ -47,10 +47,6 @@ struct SceneTripEntry { class TattooScene : public Scene { private: int _arrowZone; - int _maskCounter; - Common::Point _maskOffset; - byte _lookupTable[PALETTE_COUNT]; - byte _lookupTable1[PALETTE_COUNT]; private: void doBgAnimCheckCursor(); @@ -63,11 +59,6 @@ private: void doBgAnimDrawSprites(); - /** - * Makes a greyscale translation table for each palette entry in the table - */ - void setupBGArea(const byte cMap[PALETTE_SIZE]); - /** * Resets the NPC path information when entering a new scene. * @remarks The default talk file for the given NPC is set to WATS##A, where ## is @@ -108,7 +99,6 @@ protected: */ virtual void synchronize(Serializer &s); public: - ImageFile *_mask, *_mask1; CAnimStream _activeCAnim; Common::Array _sceneTripCounters; bool _labTableScene; diff --git a/engines/sherlock/tattoo/tattoo_user_interface.cpp b/engines/sherlock/tattoo/tattoo_user_interface.cpp index 462eccc132..a324eba1aa 100644 --- a/engines/sherlock/tattoo/tattoo_user_interface.cpp +++ b/engines/sherlock/tattoo/tattoo_user_interface.cpp @@ -21,6 +21,7 @@ */ #include "sherlock/tattoo/tattoo_user_interface.h" +#include "sherlock/tattoo/tattoo_journal.h" #include "sherlock/tattoo/tattoo_scene.h" #include "sherlock/tattoo/tattoo.h" @@ -30,6 +31,8 @@ namespace Tattoo { TattooUserInterface::TattooUserInterface(SherlockEngine *vm): UserInterface(vm), _inventoryWidget(vm), _tooltipWidget(vm), _verbsWidget(vm), _textWidget(vm) { + Common::fill(&_lookupTable[0], &_lookupTable[PALETTE_COUNT], 0); + Common::fill(&_lookupTable1[0], &_lookupTable1[PALETTE_COUNT], 0); _menuBuffer = nullptr; _invMenuBuffer = nullptr; _invGraphic = nullptr; @@ -46,6 +49,8 @@ TattooUserInterface::TattooUserInterface(SherlockEngine *vm): UserInterface(vm), _cAnimFramePause = 0; _widget = nullptr; _scrollHighlight = 0; + _mask = _mask1 = nullptr; + _maskCounter = 0; } void TattooUserInterface::initScrollVars() { @@ -186,7 +191,10 @@ void TattooUserInterface::printObjectDesc(const Common::String &str, bool firstT } void TattooUserInterface::doJournal() { - // TODO + TattooJournal &journal = *(TattooJournal *)_vm->_journal; + + _menuMode = JOURNAL_MODE; + journal.show(); } void TattooUserInterface::reset() { @@ -261,7 +269,6 @@ void TattooUserInterface::handleInput() { } void TattooUserInterface::drawInterface(int bufferNum) { - TattooScene &scene = *(TattooScene *)_vm->_scene; Screen &screen = *_vm->_screen; TattooEngine &vm = *(TattooEngine *)_vm; @@ -298,7 +305,7 @@ void TattooUserInterface::drawInterface(int bufferNum) { vm.drawCredits(); // Bring the widgets to the screen - if (scene._mask != nullptr) + if (_mask != nullptr) screen._flushScreen = true; if (screen._flushScreen) @@ -648,6 +655,66 @@ void TattooUserInterface::putMessage(const Common::String &str) { // TODO } +void TattooUserInterface::setupBGArea(const byte cMap[PALETTE_SIZE]) { + Scene &scene = *_vm->_scene; + + // This requires that there is a 16 grayscale palette sequence in the palette that goes from lighter + // to darker as the palette numbers go up. The last palette entry in that run is specified by _bgColor + byte *p = &_lookupTable[0]; + for (int idx = 0; idx < PALETTE_COUNT; ++idx) + *p++ = BG_GREYSCALE_RANGE_END - (cMap[idx * 3] * 30 + cMap[idx * 3 + 1] * 59 + cMap[idx * 3 + 2] * 11) / 480; + + // If we're going to a scene with a haze special effect, initialize the translate table to lighten the colors + if (_mask != nullptr) { + p = &_lookupTable1[0]; + + for (int idx = 0; idx < PALETTE_COUNT; ++idx) { + int r, g, b; + switch (scene._currentScene) { + case 8: + r = cMap[idx * 3] * 4 / 5; + g = cMap[idx * 3 + 1] * 3 / 4; + b = cMap[idx * 3 + 2] * 3 / 4; + break; + + case 18: + case 68: + r = cMap[idx * 3] * 4 / 3; + g = cMap[idx * 3 + 1] * 4 / 3; + b = cMap[idx * 3 + 2] * 4 / 3; + break; + + case 7: + case 53: + r = cMap[idx * 3] * 4 / 3; + g = cMap[idx * 3 + 1] * 4 / 3; + b = cMap[idx * 3 + 2] * 4 / 3; + break; + + default: + r = g = b = 0; + break; + } + + byte c = 0; + int cd = (r - cMap[0]) * (r - cMap[0]) + (g - cMap[1]) * (g - cMap[1]) + (b - cMap[2]) * (b - cMap[2]); + + for (int pal = 0; pal < PALETTE_COUNT; ++pal) { + int d = (r - cMap[pal * 3]) * (r - cMap[pal * 3]) + (g - cMap[pal * 3 + 1]) * (g - cMap[pal * 3 + 1]) + + (b - cMap[pal * 3 + 2])*(b - cMap[pal * 3 + 2]); + + if (d < cd) { + c = pal; + cd = d; + if (!d) + break; + } + } + *p++ = c; + } + } +} + } // End of namespace Tattoo } // End of namespace Sherlock diff --git a/engines/sherlock/tattoo/tattoo_user_interface.h b/engines/sherlock/tattoo/tattoo_user_interface.h index 935e0769ed..49f7c1f37e 100644 --- a/engines/sherlock/tattoo/tattoo_user_interface.h +++ b/engines/sherlock/tattoo/tattoo_user_interface.h @@ -25,6 +25,7 @@ #include "common/scummsys.h" #include "sherlock/saveload.h" +#include "sherlock/screen.h" #include "sherlock/user_interface.h" #include "sherlock/tattoo/widget_inventory.h" #include "sherlock/tattoo/widget_text.h" @@ -60,6 +61,8 @@ private: WidgetSceneTooltip _tooltipWidget; WidgetVerbs _verbsWidget; WidgetBase *_widget; + byte _lookupTable[PALETTE_COUNT]; + byte _lookupTable1[PALETTE_COUNT]; private: /** * Draws designated areas of the screen that are meant to be grayed out using grayscale colors @@ -138,6 +141,9 @@ public: Common::KeyState _keyState; Common::Point _lookPos; int _scrollHighlight; + ImageFile *_mask, *_mask1; + Common::Point _maskOffset; + int _maskCounter; public: TattooUserInterface(SherlockEngine *vm); virtual ~TattooUserInterface() {} @@ -190,6 +196,11 @@ public: void pickUpObject(int objNum); void putMessage(const Common::String &str); + + /** + * Makes a greyscale translation table for each palette entry in the table + */ + void setupBGArea(const byte cMap[PALETTE_SIZE]); public: /** * Resets the user interface -- cgit v1.2.3