diff options
author | Paul Gilbert | 2018-10-23 21:55:00 -0700 |
---|---|---|
committer | Paul Gilbert | 2018-12-08 19:05:59 -0800 |
commit | 6939fabbfb9ce63c10f1fcd8cd3c0b7f66ff9bb9 (patch) | |
tree | c483fb1ba45a9b8e249a9bc596de1973aa6d605c /engines/gargoyle | |
parent | 4ddda5cebc3d0f11cc10746e4dcac5bd0e1a7b19 (diff) | |
download | scummvm-rg350-6939fabbfb9ce63c10f1fcd8cd3c0b7f66ff9bb9.tar.gz scummvm-rg350-6939fabbfb9ce63c10f1fcd8cd3c0b7f66ff9bb9.tar.bz2 scummvm-rg350-6939fabbfb9ce63c10f1fcd8cd3c0b7f66ff9bb9.zip |
GLK: Fleshed out graphics window
Diffstat (limited to 'engines/gargoyle')
-rw-r--r-- | engines/gargoyle/draw.cpp | 4 | ||||
-rw-r--r-- | engines/gargoyle/draw.h | 2 | ||||
-rw-r--r-- | engines/gargoyle/gargoyle.h | 2 | ||||
-rw-r--r-- | engines/gargoyle/window_graphics.cpp | 161 | ||||
-rw-r--r-- | engines/gargoyle/window_graphics.h | 17 | ||||
-rw-r--r-- | engines/gargoyle/window_text_buffer.cpp | 24 | ||||
-rw-r--r-- | engines/gargoyle/window_text_buffer.h | 5 | ||||
-rw-r--r-- | engines/gargoyle/window_text_grid.cpp | 8 | ||||
-rw-r--r-- | engines/gargoyle/windows.cpp | 19 | ||||
-rw-r--r-- | engines/gargoyle/windows.h | 10 |
10 files changed, 215 insertions, 37 deletions
diff --git a/engines/gargoyle/draw.cpp b/engines/gargoyle/draw.cpp index 64c9a100e1..59acb96ce6 100644 --- a/engines/gargoyle/draw.cpp +++ b/engines/gargoyle/draw.cpp @@ -52,4 +52,8 @@ void Draw::fillArea(const byte *rgb) { // TODO: gli_draw_clear } +void Draw::drawRect(int x0, int y0, int w, int h, const byte *rgb) { + // TODO: gli_draw_rect +} + } // End of namespace Gargoyle diff --git a/engines/gargoyle/draw.h b/engines/gargoyle/draw.h index f60d57399e..7b74f45170 100644 --- a/engines/gargoyle/draw.h +++ b/engines/gargoyle/draw.h @@ -41,6 +41,8 @@ protected: void drawCaret(const Common::Point &pos); void fillArea(const byte *rgb); + + void drawRect(int x0, int y0, int w, int h, const byte *rgb); }; } // End of namespace Gargoyle diff --git a/engines/gargoyle/gargoyle.h b/engines/gargoyle/gargoyle.h index b99b7b44f6..a8af85ac01 100644 --- a/engines/gargoyle/gargoyle.h +++ b/engines/gargoyle/gargoyle.h @@ -77,7 +77,6 @@ private: void initialize(); protected: const GargoyleGameDescription *_gameDescription; - Graphics::Screen *_screen; Common::RandomSource _random; int _loadSaveSlot; @@ -97,6 +96,7 @@ public: Conf *_conf; Events *_events; PicList *_picList; + Graphics::Screen *_screen; Streams *_streams; Windows *_windows; WindowMask *_windowMask; diff --git a/engines/gargoyle/window_graphics.cpp b/engines/gargoyle/window_graphics.cpp index feddf4e070..bb002bdd50 100644 --- a/engines/gargoyle/window_graphics.cpp +++ b/engines/gargoyle/window_graphics.cpp @@ -21,6 +21,7 @@ */ #include "gargoyle/window_graphics.h" +#include "gargoyle/gargoyle.h" namespace Gargoyle { @@ -85,12 +86,164 @@ void GraphicsWindow::touch() { void GraphicsWindow::redraw() { Window::redraw(); - // TODO + if (_dirty || Windows::_forceRedraw) { + _dirty = 0; + + if (_surface) + g_vm->_screen->blitFrom(*_surface, Common::Point(_bbox.left, _bbox.top)); + } +} + +glui32 GraphicsWindow::drawPicture(glui32 image, glsi32 xpos, glsi32 ypos, int scale, + glui32 imagewidth, glui32 imageheight) { + Picture *pic = Picture::load(image); + glui32 hyperlink = _attr.hyper; + + if (!pic) + return false; + + if (!_imageLoaded) { + g_vm->_picList->increment(); + _imageLoaded = true; + } + + if (!scale) { + imagewidth = pic->w; + imageheight = pic->h; + } + + drawPicture(pic, xpos, ypos, imagewidth, imageheight, hyperlink); + touch(); + + return true; } -glui32 GraphicsWindow::imageDraw(glui32 image, glui32 align, bool scaled, glui32 width, glui32 height) { - // TODO: win_graphics_draw_picture - return 0; +void GraphicsWindow::eraseRect(int whole, glsi32 x0, glsi32 y0, glui32 width, glui32 height) { + int x1 = x0 + width; + int y1 = y0 + height; + int x, y; + int hx0, hx1, hy0, hy1; + + if (whole) { + x0 = 0; + y0 = 0; + x1 = _w; + y1 = _h; + } + + if (x0 < 0) x0 = 0; + if (y0 < 0) y0 = 0; + if (x1 < 0) x1 = 0; + if (y1 < 0) y1 = 0; + if ((glui32)x0 >= _w) x0 = _w; + if ((glui32)y0 >= _h) y0 = _h; + if ((glui32)x1 >= _w) x1 = _w; + if ((glui32)y1 >= _h) y1 = _h; + + hx0 = _bbox.left + x0; + hx1 = _bbox.left + x1; + hy0 = _bbox.top + y0; + hy1 = _bbox.top + y1; + + /* zero out hyperlinks for these coordinates */ + g_vm->_windowMask->putHyperlink(0, hx0, hy0, hx1, hy1); + + _surface->fillRect(Common::Rect(x0, y0, x1, y1), MKTAG(_bgnd[0], _bgnd[1], _bgnd[2], 0)); + touch(); +} + +void GraphicsWindow::fillRect(glui32 color, glsi32 x0, glsi32 y0, glui32 width, glui32 height) { + unsigned char col[3]; + int x1 = x0 + width; + int y1 = y0 + height; + int x, y; + int hx0, hx1, hy0, hy1; + + col[0] = (color >> 16) & 0xff; + col[1] = (color >> 8) & 0xff; + col[2] = (color >> 0) & 0xff; + + if (x0 < 0) x0 = 0; + if (y0 < 0) y0 = 0; + if (x1 < 0) x1 = 0; + if (y1 < 0) y1 = 0; + if ((glui32)x0 > _w) x0 = _w; + if ((glui32)y0 > _h) y0 = _h; + if ((glui32)x1 > _w) x1 = _w; + if ((glui32)y1 > _h) y1 = _h; + + hx0 = _bbox.left + x0; + hx1 = _bbox.left + x1; + hy0 = _bbox.top + y0; + hy1 = _bbox.top + y1; + + /* zero out hyperlinks for these coordinates */ + g_vm->_windowMask->putHyperlink(0, hx0, hy0, hx1, hy1); + + _surface->fillRect(Common::Rect(x0, y0, x1, y1), MKTAG(col[0], col[1], col[2], 0)); + touch(); +} + +void GraphicsWindow::setBackgroundColor(glui32 color) { + _bgnd[0] = (color >> 16) & 0xff; + _bgnd[1] = (color >> 8) & 0xff; + _bgnd[2] = (color >> 0) & 0xff; +} + +void GraphicsWindow::drawPicture(Picture *src, int x0, int y0, int width, int height, glui32 linkval) { + unsigned char *sp, *dp; + int dx1, dy1, x1, y1, sx0, sy0, sx1, sy1; + int x, y, w, h; + int hx0, hx1, hy0, hy1; + + if (width != src->w || height != src->h) + { + src = src->scale(width, height); + if (!src) + return; + } + + sx0 = 0; + sy0 = 0; + sx1 = src->w; + sy1 = src->h; + dx1 = _w; + dy1 = _h; + + x1 = x0 + src->w; + y1 = y0 + src->h; + + if (x1 <= 0 || x0 >= dx1) return; + if (y1 <= 0 || y0 >= dy1) return; + if (x0 < 0) { + sx0 -= x0; + x0 = 0; + } + if (y0 < 0) { + sy0 -= y0; + y0 = 0; + } + if (x1 > dx1) { + sx1 += dx1 - x1; + x1 = dx1; + } + if (y1 > dy1) { + sy1 += dy1 - y1; + y1 = dy1; + } + + hx0 = _bbox.left + x0; + hx1 = _bbox.left + x1; + hy0 = _bbox.top + y0; + hy1 = _bbox.top + y1; + + /* zero out or set hyperlink for these coordinates */ + g_vm->_windowMask->putHyperlink(linkval, hx0, hy0, hx1, hy1); + + w = sx1 - sx0; + h = sy1 - sy0; + + _surface->blitFrom(*g_vm->_screen, Common::Rect(sx0, sy0, sx0 + w, sy0 + h), Common::Point(0, 0)); } } // End of namespace Gargoyle diff --git a/engines/gargoyle/window_graphics.h b/engines/gargoyle/window_graphics.h index b0f53faf72..8e97b56019 100644 --- a/engines/gargoyle/window_graphics.h +++ b/engines/gargoyle/window_graphics.h @@ -34,6 +34,11 @@ namespace Gargoyle { class GraphicsWindow : public Window { private: void touch(); + + void eraseRect(int whole, glsi32 x0, glsi32 y0, glui32 width, glui32 height); + void fillRect(glui32 color, glsi32 x0, glsi32 y0, glui32 width, glui32 height); + void setBackgroundColor(glui32 color); + void drawPicture(Picture *src, int x0, int y0, int width, int height, glui32 linkval); public: unsigned char _bgnd[3]; bool _dirty; @@ -77,8 +82,8 @@ public: */ virtual void redraw() override; - virtual glui32 imageDraw(glui32 image, glui32 align, bool scaled, glui32 width = 0, - glui32 height = 0) override; + glui32 drawPicture(glui32 image, glsi32 xpos, glsi32 ypos, int scale, + glui32 imagewidth, glui32 imageheight); /** * Get the window dimensions @@ -87,6 +92,14 @@ public: *w = _w; *h = _h; } + + /** + * Set the window dimensions + */ + void setSize(glui32 w, glui32 h) { + _w = w; + _h = h; + } }; } // End of namespace Gargoyle diff --git a/engines/gargoyle/window_text_buffer.cpp b/engines/gargoyle/window_text_buffer.cpp index 99bef252b8..6df3ac4a3c 100644 --- a/engines/gargoyle/window_text_buffer.cpp +++ b/engines/gargoyle/window_text_buffer.cpp @@ -266,7 +266,7 @@ bool TextBufferWindow::putPicture(Picture *pic, glui32 align, glui32 linkval) { return true; } -glui32 TextBufferWindow::imageDraw(glui32 image, glui32 align, bool scaled, glui32 width, glui32 height) { +glui32 TextBufferWindow::drawPicture(glui32 image, glui32 align, glui32 scaled, glui32 width, glui32 height) { Picture *pic; glui32 hyperlink; int error; @@ -953,7 +953,7 @@ void TextBufferWindow::redraw() { * fill in background colors */ color = Windows::_overrideBgSet ? g_conf->_windowColor : _bgColor; - _windows->drawRect(x0/GLI_SUBPIX, y, + drawRect(x0/GLI_SUBPIX, y, (x1-x0) / GLI_SUBPIX, g_conf->_leading, color); @@ -966,11 +966,11 @@ void TextBufferWindow::redraw() { font = ln->_attrs[a].attrFont(_styles); color = ln->_attrs[a].attrBg(_styles); w = stringWidthUni(font, ln->_chars + a, b - a, spw); - _windows->drawRect(x/GLI_SUBPIX, y, + drawRect(x/GLI_SUBPIX, y, w/GLI_SUBPIX, g_conf->_leading, color); if (link) { - _windows->drawRect(x/GLI_SUBPIX + 1, y + g_conf->_baseLine + 1, + drawRect(x/GLI_SUBPIX + 1, y + g_conf->_baseLine + 1, w/GLI_SUBPIX + 1, g_conf->_linkStyle, g_conf->_linkColor); g_vm->_windowMask->putHyperlink(link, x/GLI_SUBPIX, y, @@ -985,10 +985,10 @@ void TextBufferWindow::redraw() { font = ln->_attrs[a].attrFont(_styles); color = ln->_attrs[a].attrBg(_styles); w = stringWidthUni(font, ln->_chars + a, b - a, spw); - _windows->drawRect(x/GLI_SUBPIX, y, w/GLI_SUBPIX, + drawRect(x/GLI_SUBPIX, y, w/GLI_SUBPIX, g_conf->_leading, color); if (link) { - _windows->drawRect(x/GLI_SUBPIX + 1, y + g_conf->_baseLine + 1, + drawRect(x/GLI_SUBPIX + 1, y + g_conf->_baseLine + 1, w/GLI_SUBPIX + 1, g_conf->_linkStyle, g_conf->_linkColor); g_vm->_windowMask->putHyperlink(link, x/GLI_SUBPIX, y, @@ -998,7 +998,7 @@ void TextBufferWindow::redraw() { x += w; color = Windows::_overrideBgSet ? g_conf->_windowColor : _bgColor; - _windows->drawRect(x/GLI_SUBPIX, y, + drawRect(x/GLI_SUBPIX, y, x1/GLI_SUBPIX - x/GLI_SUBPIX, g_conf->_leading, color); @@ -1048,7 +1048,7 @@ void TextBufferWindow::redraw() { x1/GLI_SUBPIX, y + g_conf->_leading); color = Windows::_overrideBgSet ? g_conf->_windowColor : _bgColor; - _windows->drawRect(x/GLI_SUBPIX, y, + drawRect(x/GLI_SUBPIX, y, x1/GLI_SUBPIX - x/GLI_SUBPIX, g_conf->_leading, color); @@ -1142,14 +1142,14 @@ void TextBufferWindow::redraw() { t0 = t1 = y0; } - _windows->drawRect(x0+1, y0, x1-x0-2, y1-y0, g_conf->_scrollBg); - _windows->drawRect(x0+1, t0, x1-x0-2, t1-t0, g_conf->_scrollFg); + drawRect(x0+1, y0, x1-x0-2, y1-y0, g_conf->_scrollBg); + drawRect(x0+1, t0, x1-x0-2, t1-t0, g_conf->_scrollFg); for (i = 0; i < g_conf->_scrollWidth / 2 + 1; i++) { - _windows->drawRect(x0+g_conf->_scrollWidth/2-i, + drawRect(x0+g_conf->_scrollWidth/2-i, y0 - g_conf->_scrollWidth/2 + i, i*2, 1, g_conf->_scrollFg); - _windows->drawRect(x0+g_conf->_scrollWidth/2-i, + drawRect(x0+g_conf->_scrollWidth/2-i, y1 + g_conf->_scrollWidth/2 - i, i*2, 1, g_conf->_scrollFg); } diff --git a/engines/gargoyle/window_text_buffer.h b/engines/gargoyle/window_text_buffer.h index 2a1c1f7748..4741877516 100644 --- a/engines/gargoyle/window_text_buffer.h +++ b/engines/gargoyle/window_text_buffer.h @@ -202,14 +202,13 @@ public: */ virtual void redraw() override; - virtual glui32 imageDraw(glui32 image, glui32 align, bool scaled, glui32 width = 0, - glui32 height = 0) override; - virtual void acceptReadLine(glui32 arg) override; virtual void acceptReadChar(glui32 arg) override; int acceptScroll(glui32 arg); + + glui32 drawPicture(glui32 image, glui32 align, glui32 scaled, glui32 width, glui32 height); }; } // End of namespace Gargoyle diff --git a/engines/gargoyle/window_text_grid.cpp b/engines/gargoyle/window_text_grid.cpp index c20bafea35..483d556cf0 100644 --- a/engines/gargoyle/window_text_grid.cpp +++ b/engines/gargoyle/window_text_grid.cpp @@ -601,7 +601,7 @@ void TextGridWindow::redraw() { fgcolor = link ? g_conf->_linkColor : ln->_attrs[a].attrFg(styles); bgcolor = ln->_attrs[a].attrBg(styles); w = (b - a) * g_conf->_cellW; - _windows->drawRect(x, y, w, g_conf->_leading, bgcolor); + drawRect(x, y, w, g_conf->_leading, bgcolor); o = x; for (k = a; k < b; k++) { @@ -611,7 +611,7 @@ void TextGridWindow::redraw() { o += g_conf->_cellW; } if (link) { - _windows->drawRect(x, y + g_conf->_baseLine + 1, w, + drawRect(x, y + g_conf->_baseLine + 1, w, g_conf->_linkStyle, g_conf->_linkColor); g_vm->_windowMask->putHyperlink(link, x, y, x + w, y + g_conf->_leading); } @@ -625,7 +625,7 @@ void TextGridWindow::redraw() { bgcolor = ln->_attrs[a].attrBg(styles); w = (b - a) * g_conf->_cellW; w += _bbox.right - (x + w); - _windows->drawRect(x, y, w, g_conf->_leading, bgcolor); + drawRect(x, y, w, g_conf->_leading, bgcolor); o = x; for (k = a; k < b; k++) { @@ -635,7 +635,7 @@ void TextGridWindow::redraw() { o += g_conf->_cellW; } if (link) { - _windows->drawRect(x, y + g_conf->_baseLine + 1, w, + drawRect(x, y + g_conf->_baseLine + 1, w, g_conf->_linkStyle, g_conf->_linkColor); g_vm->_windowMask->putHyperlink(link, x, y, x + w, y + g_conf->_leading); } diff --git a/engines/gargoyle/windows.cpp b/engines/gargoyle/windows.cpp index 9c8e22c4ef..0dc500e696 100644 --- a/engines/gargoyle/windows.cpp +++ b/engines/gargoyle/windows.cpp @@ -251,10 +251,6 @@ void Windows::repaint(const Common::Rect &box) { // No implementation } -void Windows::drawRect(int x0, int y0, int w, int h, const byte *rgb) { - // TODO -} - byte *Windows::rgbShift(byte *rgb) { _zcolor_Bright[0] = (rgb[0] + 0x30) < 0xff ? (rgb[0] + 0x30) : 0xff; _zcolor_Bright[1] = (rgb[1] + 0x30) < 0xff ? (rgb[1] + 0x30) : 0xff; @@ -403,6 +399,21 @@ bool Window::checkTerminator(glui32 ch) { return false; } +bool Window::imageDraw(glui32 image, glui32 align, glsi32 val1, glsi32 val2) { + if (!g_conf->_graphics) + return false; + + TextBufferWindow *bufWin = dynamic_cast<TextBufferWindow *>(this); + GraphicsWindow *graWin = dynamic_cast<GraphicsWindow *>(this); + + if (bufWin) + return bufWin->drawPicture(image, val1, false, 0, 0); + if (graWin) + return graWin->drawPicture(image, val1, val2, false, 0, 0); + + return false; +} + /*--------------------------------------------------------------------------*/ BlankWindow::BlankWindow(Windows *windows, uint32 rock) : Window(windows, rock) { diff --git a/engines/gargoyle/windows.h b/engines/gargoyle/windows.h index 1f1572070d..9092ea46d8 100644 --- a/engines/gargoyle/windows.h +++ b/engines/gargoyle/windows.h @@ -164,11 +164,6 @@ public: void repaint(const Common::Rect &box); /** - * Draw an area of the windows - */ - void drawRect(int x0, int y0, int w, int h, const byte *rgb); - - /** * Get an iterator that will move over the tree */ iterator begin() { return iterator(this, _windowList); } @@ -354,8 +349,9 @@ public: */ virtual void redraw(); - virtual glui32 imageDraw(glui32 image, glui32 align, bool scaled, glui32 width = 0, - glui32 height = 0) { return false; } + bool imageDraw(glui32 image, glui32 align, glsi32 val1, glsi32 val2); + + virtual glui32 drawPicture(glui32 image, glui32 align, glui32 scaled, glui32 width, glui32 height) { return false; } virtual void acceptReadLine(glui32 arg); |