diff options
author | Matthew Hoops | 2011-02-20 12:35:15 -0500 |
---|---|---|
committer | Matthew Hoops | 2011-02-20 12:44:59 -0500 |
commit | 0933325b7cc6d512327a02716f95748fc9a16bba (patch) | |
tree | 2dcd6c6faf50733c44f01c5ca46252d6ee184db2 /engines/sci/graphics | |
parent | 257bae431ac7e9a966e0cc1e41c7f10dc0125092 (diff) | |
download | scummvm-rg350-0933325b7cc6d512327a02716f95748fc9a16bba.tar.gz scummvm-rg350-0933325b7cc6d512327a02716f95748fc9a16bba.tar.bz2 scummvm-rg350-0933325b7cc6d512327a02716f95748fc9a16bba.zip |
SCI: Add support for enabling/disabling Mac icon bar images
Diffstat (limited to 'engines/sci/graphics')
-rw-r--r-- | engines/sci/graphics/maciconbar.cpp | 67 | ||||
-rw-r--r-- | engines/sci/graphics/maciconbar.h | 8 |
2 files changed, 69 insertions, 6 deletions
diff --git a/engines/sci/graphics/maciconbar.cpp b/engines/sci/graphics/maciconbar.cpp index 1800f79609..ea44db654b 100644 --- a/engines/sci/graphics/maciconbar.cpp +++ b/engines/sci/graphics/maciconbar.cpp @@ -63,6 +63,7 @@ void GfxMacIconBar::addIcon(reg_t obj) { item.object = obj; item.nonSelectedImage = createImage(iconIndex, false); item.selectedImage = createImage(iconIndex, true); + item.enabled = true; // Start after the main viewing window and add a two pixel buffer uint16 y = g_sci->_gfxScreen->getHeight() + 2; @@ -80,13 +81,67 @@ void GfxMacIconBar::addIcon(reg_t obj) { void GfxMacIconBar::drawIcons() { // Draw the icons to the bottom of the screen - for (uint32 i = 0; i < _iconBarItems.size(); i++) { - Graphics::Surface *surface = _iconBarItems[i].nonSelectedImage; + for (uint32 i = 0; i < _iconBarItems.size(); i++) + redrawIcon(i); +} - if (surface) { - g_system->copyRectToScreen((byte *)surface->pixels, surface->pitch, _iconBarItems[i].rect.left, - _iconBarItems[i].rect.top, _iconBarItems[i].rect.width(), _iconBarItems[i].rect.height()); - } +void GfxMacIconBar::redrawIcon(uint16 iconIndex) { + if (iconIndex >= _iconBarItems.size()) + return; + + if (_iconBarItems[iconIndex].enabled) + drawEnabledImage(_iconBarItems[iconIndex].nonSelectedImage, _iconBarItems[iconIndex].rect); + else + drawDisabledImage(_iconBarItems[iconIndex].nonSelectedImage, _iconBarItems[iconIndex].rect); +} + +void GfxMacIconBar::drawEnabledImage(Graphics::Surface *surface, const Common::Rect &rect) { + if (surface) + g_system->copyRectToScreen((byte *)surface->pixels, surface->pitch, rect.left, rect.top, rect.width(), rect.height()); +} + +void GfxMacIconBar::drawDisabledImage(Graphics::Surface *surface, const Common::Rect &rect) { + if (!surface) + return; + + // Add a black checkboard pattern to the image before copying it to the screen + + Graphics::Surface newSurf; + newSurf.copyFrom(*surface); + + for (int i = 0; i < newSurf.h; i++) { + int startX = rect.left & 3; + + if ((i + rect.top) & 1) + startX += 2; + + for (int j = startX; j < newSurf.w; j += 4) + *((byte *)newSurf.getBasePtr(j, i)) = 0; + } + + g_system->copyRectToScreen((byte *)newSurf.pixels, newSurf.pitch, rect.left, rect.top, rect.width(), rect.height()); + newSurf.free(); +} + +void GfxMacIconBar::drawSelectedImage(uint16 iconIndex) { + assert(iconIndex <= _iconBarItems.size()); + + // TODO +} + +bool GfxMacIconBar::isIconEnabled(uint16 iconIndex) const { + if (iconIndex >= _iconBarItems.size()) + return false; + + return _iconBarItems[iconIndex].enabled; +} + +void GfxMacIconBar::setIconEnabled(uint16 iconIndex, bool enabled) { + if (iconIndex == 0xffff) { + for (uint32 i = 0; i < _iconBarItems.size(); i++) + _iconBarItems[i].enabled = enabled; + } else if (iconIndex < _iconBarItems.size()) { + _iconBarItems[iconIndex].enabled = enabled; } } diff --git a/engines/sci/graphics/maciconbar.h b/engines/sci/graphics/maciconbar.h index 0731da497d..0db9454eb7 100644 --- a/engines/sci/graphics/maciconbar.h +++ b/engines/sci/graphics/maciconbar.h @@ -43,6 +43,10 @@ public: void addIcon(reg_t obj); void drawIcons(); + void redrawIcon(uint16 index); + void drawSelectedImage(uint16 index); + bool isIconEnabled(uint16 index) const; + void setIconEnabled(uint16 index, bool enabled); private: struct IconBarItem { @@ -50,6 +54,7 @@ private: Graphics::Surface *nonSelectedImage; Graphics::Surface *selectedImage; Common::Rect rect; + bool enabled; }; Common::Array<IconBarItem> _iconBarItems; @@ -57,6 +62,9 @@ private: Graphics::Surface *createImage(uint32 iconIndex, bool isSelected); void remapColors(Graphics::Surface *surf, byte *palette); + + void drawEnabledImage(Graphics::Surface *surface, const Common::Rect &rect); + void drawDisabledImage(Graphics::Surface *surface, const Common::Rect &rect); }; } // End of namespace Sci |