diff options
author | Eugene Sandulenko | 2014-05-03 02:50:47 +0300 |
---|---|---|
committer | Alexander Tkachev | 2016-08-24 16:07:55 +0600 |
commit | f0c52096f3e9215cb584b3862f2cd4b9632761d5 (patch) | |
tree | dd16034089864033d71055e97f107f3c664250e7 /gui/widget.cpp | |
parent | 53a42ececfff48b93cef414bc2762806786da8d5 (diff) | |
download | scummvm-rg350-f0c52096f3e9215cb584b3862f2cd4b9632761d5.tar.gz scummvm-rg350-f0c52096f3e9215cb584b3862f2cd4b9632761d5.tar.bz2 scummvm-rg350-f0c52096f3e9215cb584b3862f2cd4b9632761d5.zip |
GUI: Implemented possibility to use alphabitmaps in GraphicsWidget
Diffstat (limited to 'gui/widget.cpp')
-rw-r--r-- | gui/widget.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/gui/widget.cpp b/gui/widget.cpp index dfc0a5b50c..62a69d9540 100644 --- a/gui/widget.cpp +++ b/gui/widget.cpp @@ -702,6 +702,25 @@ void GraphicsWidget::setGfx(const Graphics::Surface *gfx) { _gfx.copyFrom(*gfx); } +void GraphicsWidget::setAGfx(const Graphics::TransparentSurface *gfx) { + _agfx.free(); + + if (!gfx || !gfx->getPixels()) + return; + + if (gfx->format.bytesPerPixel == 1) { + warning("GraphicsWidget::setGfx got paletted surface passed"); + return; + } + + if (gfx->w > _w || gfx->h > _h) { + warning("GraphicsWidget has size %dx%d, but a surface with %dx%d is to be set", _w, _h, gfx->w, gfx->h); + return; + } + + _agfx.copyFrom(*gfx); +} + void GraphicsWidget::setGfx(int w, int h, int r, int g, int b) { if (w == -1) w = _w; @@ -728,6 +747,18 @@ void GraphicsWidget::drawWidget() { const int y = _y + (_h - _gfx.h) / 2; g_gui.theme()->drawSurfaceClip(Common::Rect(x, y, x + _gfx.w, y + _gfx.h), getBossClipRect(), _gfx, _state, _alpha, _transparency); + } else if (_agfx.getPixels()) { + // Check whether the set up surface needs to be converted to the GUI + // color format. + const Graphics::PixelFormat &requiredFormat = g_gui.theme()->getPixelFormat(); + if (_agfx.format != requiredFormat) { + _agfx.convertToInPlace(requiredFormat); + } + + const int x = _x + (_w - _agfx.w) / 2; + const int y = _y + (_h - _agfx.h) / 2; + + g_gui.theme()->drawASurface(Common::Rect(x, y, x + _agfx.w, y + _agfx.h), _agfx, _state, _alpha, _transparency); } } |