Skip to content

Commit

Permalink
SHERLOCK: RT: Implemented shaded background for dialogs
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Jun 25, 2015
1 parent 7f57db2 commit 05ba90b
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 12 deletions.
9 changes: 4 additions & 5 deletions engines/sherlock/tattoo/tattoo_user_interface.cpp
Expand Up @@ -350,10 +350,6 @@ void TattooUserInterface::doScroll() {
}
}

void TattooUserInterface::drawGrayAreas() {
// TODO
}

void TattooUserInterface::doStandardControl() {
TattooEngine &vm = *(TattooEngine *)_vm;
Events &events = *_vm->_events;
Expand Down Expand Up @@ -612,7 +608,8 @@ void TattooUserInterface::setupBGArea(const byte cMap[PALETTE_SIZE]) {
// 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;
*p++ = BG_GREYSCALE_RANGE_END - ((cMap[idx * 3] / 4) * 30 + (cMap[idx * 3 + 1] / 4) * 59 +
(cMap[idx * 3 + 2] / 4) * 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) {
Expand Down Expand Up @@ -822,6 +819,8 @@ void TattooUserInterface::makeBGArea(const Common::Rect &r) {
for (int xp = r.left; xp < r.right; ++xp, ++ptr)
*ptr = _lookupTable[*ptr];
}

screen.slamRect(r);
}

void TattooUserInterface::drawDialogRect(Surface &s, const Common::Rect &r, bool raised) {
Expand Down
6 changes: 0 additions & 6 deletions engines/sherlock/tattoo/tattoo_user_interface.h
Expand Up @@ -43,7 +43,6 @@ class WidgetBase;
class TattooUserInterface : public UserInterface {
friend class WidgetBase;
private:
Common::Array<Common::Rect> _grayAreas;
int _lockoutTimer;
SaveMode _fileMode;
int _exitZone;
Expand All @@ -57,11 +56,6 @@ class TattooUserInterface : public UserInterface {
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
*/
void drawGrayAreas();

/**
* Handle any input when we're in standard mode (with no windows open)
*/
Expand Down
22 changes: 21 additions & 1 deletion engines/sherlock/tattoo/widget_base.cpp
Expand Up @@ -79,8 +79,11 @@ void WidgetBase::draw() {
Common::Rect bounds = _bounds;
bounds.translate(currentScroll.x, currentScroll.y);

// Copy any area to be drawn on from the secondary back buffer, and then draw surface on top
// Draw the background for the widget
screen._backBuffer1.blitFrom(screen._backBuffer2, Common::Point(bounds.left, bounds.top), bounds);
drawBackground();

// Draw the widget onto the back buffer and then slam it to the screen
screen._backBuffer1.transBlitFrom(_surface, Common::Point(bounds.left, bounds.top));
screen.blitFrom(screen._backBuffer1, Common::Point(_bounds.left, _bounds.top), bounds);

Expand All @@ -89,6 +92,23 @@ void WidgetBase::draw() {
}
}

void WidgetBase::drawBackground() {
TattooEngine &vm = *(TattooEngine *)_vm;
Screen &screen = *_vm->_screen;
TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui;

Common::Rect bounds = _bounds;
const Common::Point &currentScroll = getCurrentScroll();
bounds.translate(currentScroll.x, currentScroll.y);

if (vm._transparentMenus) {
ui.makeBGArea(bounds);
} else {
bounds.grow(-3);
screen._backBuffer1.fillRect(bounds, MENU_BACKGROUND);
}
}

Common::String WidgetBase::splitLines(const Common::String &str, Common::StringArray &lines, int maxWidth, uint maxLines) {
Talk &talk = *_vm->_talk;
const char *strP = str.c_str();
Expand Down
5 changes: 5 additions & 0 deletions engines/sherlock/tattoo/widget_base.h
Expand Up @@ -68,6 +68,11 @@ class WidgetBase {
* Returns the current scroll position
*/
virtual const Common::Point &getCurrentScroll() const;

/**
* Handle drawing the background on the area the widget is going to cover
*/
virtual void drawBackground();
public:
WidgetBase(SherlockEngine *vm);
virtual ~WidgetBase() {}
Expand Down
5 changes: 5 additions & 0 deletions engines/sherlock/tattoo/widget_tooltip.h
Expand Up @@ -34,6 +34,11 @@ class SherlockEngine;
namespace Tattoo {

class WidgetTooltip: public WidgetBase {
protected:
/**
* Overriden from base class, since tooltips have a completely transparent background
*/
virtual void drawBackground() {}
public:
WidgetTooltip(SherlockEngine *vm);
virtual ~WidgetTooltip() {}
Expand Down

0 comments on commit 05ba90b

Please sign in to comment.