diff options
-rw-r--r-- | engines/gargoyle/gargoyle.cpp | 3 | ||||
-rw-r--r-- | engines/gargoyle/gargoyle.h | 6 | ||||
-rw-r--r-- | engines/gargoyle/module.mk | 2 | ||||
-rw-r--r-- | engines/gargoyle/screen.cpp (renamed from engines/gargoyle/draw.cpp) | 30 | ||||
-rw-r--r-- | engines/gargoyle/screen.h (renamed from engines/gargoyle/draw.h) | 25 | ||||
-rw-r--r-- | engines/gargoyle/window_graphics.cpp | 12 | ||||
-rw-r--r-- | engines/gargoyle/window_text_buffer.cpp | 43 | ||||
-rw-r--r-- | engines/gargoyle/window_text_grid.cpp | 14 | ||||
-rw-r--r-- | engines/gargoyle/windows.cpp | 5 | ||||
-rw-r--r-- | engines/gargoyle/windows.h | 5 |
10 files changed, 78 insertions, 67 deletions
diff --git a/engines/gargoyle/gargoyle.cpp b/engines/gargoyle/gargoyle.cpp index 37df6d1f3e..1a8cc617fb 100644 --- a/engines/gargoyle/gargoyle.cpp +++ b/engines/gargoyle/gargoyle.cpp @@ -32,6 +32,7 @@ #include "gargoyle/conf.h" #include "gargoyle/events.h" #include "gargoyle/picture.h" +#include "gargoyle/screen.h" #include "gargoyle/streams.h" #include "gargoyle/windows.h" #include "gargoyle/window_mask.h" @@ -66,7 +67,7 @@ void GargoyleEngine::initialize() { DebugMan.addDebugChannel(kDebugSound, "sound", "Sound and Music handling"); initGraphics(640, 480, false); - _screen = new Graphics::Screen(); + _screen = new Screen(); _conf = new Conf(); _events = new Events(); _picList = new PicList(); diff --git a/engines/gargoyle/gargoyle.h b/engines/gargoyle/gargoyle.h index a8af85ac01..c34538b47c 100644 --- a/engines/gargoyle/gargoyle.h +++ b/engines/gargoyle/gargoyle.h @@ -29,7 +29,6 @@ #include "common/serializer.h" #include "engines/advancedDetector.h" #include "engines/engine.h" -#include "graphics/screen.h" #include "gargoyle/glk_types.h" namespace Gargoyle { @@ -37,9 +36,10 @@ namespace Gargoyle { class Conf; class Events; class PicList; +class Screen; +class Streams; class Windows; class WindowMask; -class Streams; enum InterpreterType { INTERPRETER_SCOTT @@ -96,7 +96,7 @@ public: Conf *_conf; Events *_events; PicList *_picList; - Graphics::Screen *_screen; + Screen *_screen; Streams *_streams; Windows *_windows; WindowMask *_windowMask; diff --git a/engines/gargoyle/module.mk b/engines/gargoyle/module.mk index e684ff998b..e2584b48d7 100644 --- a/engines/gargoyle/module.mk +++ b/engines/gargoyle/module.mk @@ -3,12 +3,12 @@ MODULE := engines/gargoyle MODULE_OBJS := \ conf.o \ detection.o \ - draw.o \ events.o \ fonts.o \ gargoyle.o \ glk.o \ picture.o \ + screen.o \ streams.o \ string.o \ windows.o \ diff --git a/engines/gargoyle/draw.cpp b/engines/gargoyle/screen.cpp index 59acb96ce6..dad3e6d4d3 100644 --- a/engines/gargoyle/draw.cpp +++ b/engines/gargoyle/screen.cpp @@ -20,40 +20,42 @@ * */ -#include "gargoyle/draw.h" +#include "gargoyle/screen.h" namespace Gargoyle { -int Draw::drawString(int x, int y, int fidx, const byte *rgb, const char *s, int n, int spw) { - // TODO - return 0; +void Screen::fill(const byte *rgb) { + uint color = format.RGBToColor(rgb[0], rgb[1], rgb[2]); + clear(color); } -int Draw::drawStringUni(int x, int y, int fidx, const byte *rgb, const glui32 *s, int n, int spw) { - // TODO - return 0; +void Screen::fillRect(uint x, uint y, uint w, uint h, const byte *rgb) { + uint color = format.RGBToColor(rgb[0], rgb[1], rgb[2]); + Graphics::Screen::fillRect(Common::Rect(x, y, x + w, y + h), color); } -int Draw::stringWidth(int fidx, const char *s, int n, int spw) { +int Screen::drawString(int x, int y, int fidx, const byte *rgb, const char *s, int n, int spw) { // TODO return 0; } -int Draw::stringWidthUni(int fidx, const glui32 *s, int n, int spw) { +int Screen::drawStringUni(int x, int y, int fidx, const byte *rgb, const uint32 *s, int n, int spw) { // TODO return 0; } -void Draw::drawCaret(const Common::Point &pos) { +int Screen::stringWidth(int fidx, const char *s, int n, int spw) { // TODO + return 0; } -void Draw::fillArea(const byte *rgb) { - // TODO: gli_draw_clear +int Screen::stringWidthUni(int fidx, const uint32 *s, int n, int spw) { + // TODO + return 0; } -void Draw::drawRect(int x0, int y0, int w, int h, const byte *rgb) { - // TODO: gli_draw_rect +void Screen::drawCaret(const Common::Point &pos) { + // TODO } } // End of namespace Gargoyle diff --git a/engines/gargoyle/draw.h b/engines/gargoyle/screen.h index 7b74f45170..ce9088d556 100644 --- a/engines/gargoyle/draw.h +++ b/engines/gargoyle/screen.h @@ -23,26 +23,31 @@ #ifndef GARGOYLE_DRAW_H #define GARGOYLE_DRAW_H -#include "common/rect.h" -#include "gargoyle/glk_types.h" +#include "graphics/screen.h" namespace Gargoyle { -class Draw { -protected: +class Screen : public Graphics::Screen { +public: + /** + * Fills the screen with a given rgb color + */ + void fill(const byte *rgb); + + /** + * Fill a given area of the screen with an rgb color + */ + void fillRect(uint x, uint y, uint w, uint h, const byte *rgb); + int drawString(int x, int y, int fidx, const byte *rgb, const char *s, int n, int spw); - int drawStringUni(int x, int y, int fidx, const byte *rgb, const glui32 *s, int n, int spw); + int drawStringUni(int x, int y, int fidx, const byte *rgb, const uint32 *s, int n, int spw); int stringWidth(int fidx, const char *s, int n, int spw); - int stringWidthUni(int fidx, const glui32 *s, int n, int spw); + int stringWidthUni(int fidx, const uint32 *s, int n, int spw); 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/window_graphics.cpp b/engines/gargoyle/window_graphics.cpp index bb002bdd50..caf51a2e9a 100644 --- a/engines/gargoyle/window_graphics.cpp +++ b/engines/gargoyle/window_graphics.cpp @@ -22,6 +22,7 @@ #include "gargoyle/window_graphics.h" #include "gargoyle/gargoyle.h" +#include "gargoyle/screen.h" namespace Gargoyle { @@ -84,13 +85,14 @@ void GraphicsWindow::touch() { } void GraphicsWindow::redraw() { + Screen &screen = *g_vm->_screen; Window::redraw(); if (_dirty || Windows::_forceRedraw) { _dirty = 0; if (_surface) - g_vm->_screen->blitFrom(*_surface, Common::Point(_bbox.left, _bbox.top)); + screen.blitFrom(*_surface, Common::Point(_bbox.left, _bbox.top)); } } @@ -121,7 +123,6 @@ glui32 GraphicsWindow::drawPicture(glui32 image, glsi32 xpos, glsi32 ypos, int s 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) { @@ -156,7 +157,6 @@ void GraphicsWindow::fillRect(glui32 color, glsi32 x0, glsi32 y0, glui32 width, 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; @@ -191,13 +191,11 @@ void GraphicsWindow::setBackgroundColor(glui32 color) { } 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; + int w, h; - if (width != src->w || height != src->h) - { + if (width != src->w || height != src->h) { src = src->scale(width, height); if (!src) return; diff --git a/engines/gargoyle/window_text_buffer.cpp b/engines/gargoyle/window_text_buffer.cpp index 6df3ac4a3c..b940fe60a7 100644 --- a/engines/gargoyle/window_text_buffer.cpp +++ b/engines/gargoyle/window_text_buffer.cpp @@ -23,6 +23,7 @@ #include "gargoyle/window_text_buffer.h" #include "gargoyle/conf.h" #include "gargoyle/gargoyle.h" +#include "gargoyle/screen.h" #include "gargoyle/string.h" namespace Gargoyle { @@ -795,6 +796,7 @@ void TextBufferWindow::redraw() { int hx0, hx1, hy0, hy1; int selbuf, selrow, selchar, sx0, sx1, selleft, selright; int tx, tsc, tsw, lsc, rsc; + Screen &screen = *g_vm->_screen; Window::redraw(); @@ -953,7 +955,7 @@ void TextBufferWindow::redraw() { * fill in background colors */ color = Windows::_overrideBgSet ? g_conf->_windowColor : _bgColor; - drawRect(x0/GLI_SUBPIX, y, + screen.fillRect(x0/GLI_SUBPIX, y, (x1-x0) / GLI_SUBPIX, g_conf->_leading, color); @@ -965,12 +967,12 @@ void TextBufferWindow::redraw() { link = ln->_attrs[a].hyper; font = ln->_attrs[a].attrFont(_styles); color = ln->_attrs[a].attrBg(_styles); - w = stringWidthUni(font, ln->_chars + a, b - a, spw); - drawRect(x/GLI_SUBPIX, y, + w = screen.stringWidthUni(font, ln->_chars + a, b - a, spw); + screen.fillRect(x/GLI_SUBPIX, y, w/GLI_SUBPIX, g_conf->_leading, color); if (link) { - drawRect(x/GLI_SUBPIX + 1, y + g_conf->_baseLine + 1, + screen.fillRect(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, @@ -984,11 +986,11 @@ void TextBufferWindow::redraw() { link = ln->_attrs[a].hyper; font = ln->_attrs[a].attrFont(_styles); color = ln->_attrs[a].attrBg(_styles); - w = stringWidthUni(font, ln->_chars + a, b - a, spw); - drawRect(x/GLI_SUBPIX, y, w/GLI_SUBPIX, + w = screen.stringWidthUni(font, ln->_chars + a, b - a, spw); + screen.fillRect(x/GLI_SUBPIX, y, w/GLI_SUBPIX, g_conf->_leading, color); if (link) { - drawRect(x/GLI_SUBPIX + 1, y + g_conf->_baseLine + 1, + screen.fillRect(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 +1000,7 @@ void TextBufferWindow::redraw() { x += w; color = Windows::_overrideBgSet ? g_conf->_windowColor : _bgColor; - drawRect(x/GLI_SUBPIX, y, + screen.fillRect(x/GLI_SUBPIX, y, x1/GLI_SUBPIX - x/GLI_SUBPIX, g_conf->_leading, color); @@ -1009,7 +1011,7 @@ void TextBufferWindow::redraw() { if (_windows->getFocusWindow() == this && i == 0 && (_lineRequest || _lineRequestUni)) { w = calcWidth(_chars, _attrs, 0, _inCurs, spw); if (w < pw - g_conf->_caretShape * 2 * GLI_SUBPIX) - drawCaret(Common::Point(x0 + SLOP + ln->_lm + w, y + g_conf->_baseLine)); + screen.drawCaret(Common::Point(x0 + SLOP + ln->_lm + w, y + g_conf->_baseLine)); } /* @@ -1024,7 +1026,7 @@ void TextBufferWindow::redraw() { link = ln->_attrs[a].hyper; font = ln->_attrs[a].attrFont(_styles); color = link ? g_conf->_linkColor : ln->_attrs[a].attrFg(_styles); - x = drawStringUni(x, y + g_conf->_baseLine, + x = screen.drawStringUni(x, y + g_conf->_baseLine, font, color, ln->_chars + a, b - a, spw); a = b; } @@ -1032,7 +1034,7 @@ void TextBufferWindow::redraw() { link = ln->_attrs[a].hyper; font = ln->_attrs[a].attrFont(_styles); color = link ? g_conf->_linkColor : ln->_attrs[a].attrFg(_styles); - drawStringUni(x, y + g_conf->_baseLine, + screen.drawStringUni(x, y + g_conf->_baseLine, font, color, ln->_chars + a, linelen - a, spw); } @@ -1048,11 +1050,11 @@ void TextBufferWindow::redraw() { x1/GLI_SUBPIX, y + g_conf->_leading); color = Windows::_overrideBgSet ? g_conf->_windowColor : _bgColor; - drawRect(x/GLI_SUBPIX, y, + screen.fillRect(x/GLI_SUBPIX, y, x1/GLI_SUBPIX - x/GLI_SUBPIX, g_conf->_leading, color); - w = stringWidth(g_conf->_moreFont, + w = screen.stringWidth(g_conf->_moreFont, g_conf->_morePrompt.c_str(), g_conf->_morePrompt.size(), -1); if (g_conf->_moreAlign == 1) /* center */ @@ -1061,7 +1063,7 @@ void TextBufferWindow::redraw() { x = x1 - SLOP - w; color = Windows::_overrideFgSet ? g_conf->_moreColor : _fgColor; - drawString(x, y + g_conf->_baseLine, + screen.drawString(x, y + g_conf->_baseLine, g_conf->_moreFont, color, g_conf->_morePrompt.c_str(), g_conf->_morePrompt.size(), -1); y1 = y; /* don't want pictures overdrawing "[more]" */ @@ -1142,14 +1144,14 @@ void TextBufferWindow::redraw() { t0 = t1 = y0; } - drawRect(x0+1, y0, x1-x0-2, y1-y0, g_conf->_scrollBg); - drawRect(x0+1, t0, x1-x0-2, t1-t0, g_conf->_scrollFg); + screen.fillRect(x0+1, y0, x1-x0-2, y1-y0, g_conf->_scrollBg); + screen.fillRect(x0+1, t0, x1-x0-2, t1-t0, g_conf->_scrollFg); for (i = 0; i < g_conf->_scrollWidth / 2 + 1; i++) { - drawRect(x0+g_conf->_scrollWidth/2-i, + screen.fillRect(x0+g_conf->_scrollWidth/2-i, y0 - g_conf->_scrollWidth/2 + i, i*2, 1, g_conf->_scrollFg); - drawRect(x0+g_conf->_scrollWidth/2-i, + screen.fillRect(x0+g_conf->_scrollWidth/2-i, y1 + g_conf->_scrollWidth/2 - i, i*2, 1, g_conf->_scrollFg); } @@ -1608,19 +1610,20 @@ void TextBufferWindow::scrollResize() { int TextBufferWindow::calcWidth(glui32 *chars, Attributes *attrs, int startchar, int numChars, int spw) { + Screen &screen = *g_vm->_screen; int w = 0; int a, b; a = startchar; for (b = startchar; b < numChars; b++) { if (attrs[a] == attrs[b]) { - w += stringWidthUni(attrs[a].attrFont(_styles), + w += screen.stringWidthUni(attrs[a].attrFont(_styles), chars + a, b - a, spw); a = b; } } - w += stringWidthUni(attrs[a].attrFont(_styles), + w += screen.stringWidthUni(attrs[a].attrFont(_styles), chars + a, b - a, spw); return w; diff --git a/engines/gargoyle/window_text_grid.cpp b/engines/gargoyle/window_text_grid.cpp index 483d556cf0..bf0f39cb93 100644 --- a/engines/gargoyle/window_text_grid.cpp +++ b/engines/gargoyle/window_text_grid.cpp @@ -23,6 +23,7 @@ #include "gargoyle/window_text_grid.h" #include "gargoyle/conf.h" #include "gargoyle/gargoyle.h" +#include "gargoyle/screen.h" #include "gargoyle/window_mask.h" namespace Gargoyle { @@ -576,6 +577,7 @@ void TextGridWindow::redraw() { glui32 link; int font; byte *fgcolor, *bgcolor; + Screen &screen = *g_vm->_screen; Window::redraw(); @@ -601,17 +603,17 @@ 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; - drawRect(x, y, w, g_conf->_leading, bgcolor); + screen.fillRect(x, y, w, g_conf->_leading, bgcolor); o = x; for (k = a; k < b; k++) { - drawStringUni(o * GLI_SUBPIX, + screen.drawStringUni(o * GLI_SUBPIX, y + g_conf->_baseLine, font, fgcolor, &ln->_chars[k], 1, -1); o += g_conf->_cellW; } if (link) { - drawRect(x, y + g_conf->_baseLine + 1, w, + screen.fillRect(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,17 +627,17 @@ void TextGridWindow::redraw() { bgcolor = ln->_attrs[a].attrBg(styles); w = (b - a) * g_conf->_cellW; w += _bbox.right - (x + w); - drawRect(x, y, w, g_conf->_leading, bgcolor); + screen.fillRect(x, y, w, g_conf->_leading, bgcolor); o = x; for (k = a; k < b; k++) { - drawStringUni(o * GLI_SUBPIX, + screen.drawStringUni(o * GLI_SUBPIX, y + g_conf->_baseLine, font, fgcolor, &ln->_chars[k], 1, -1); o += g_conf->_cellW; } if (link) { - drawRect(x, y + g_conf->_baseLine + 1, w, + screen.fillRect(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 0dc500e696..6fb834d381 100644 --- a/engines/gargoyle/windows.cpp +++ b/engines/gargoyle/windows.cpp @@ -27,6 +27,7 @@ #include "gargoyle/window_text_grid.h" #include "gargoyle/conf.h" #include "gargoyle/gargoyle.h" +#include "gargoyle/screen.h" #include "gargoyle/streams.h" #include "common/algorithm.h" #include "common/textconsole.h" @@ -230,7 +231,7 @@ void Windows::redraw() { if (_forceRedraw) { repaint(Common::Rect(0, 0, g_conf->_imageW, g_conf->_imageH)); - fillArea(g_conf->_windowColor); + g_vm->_screen->fill(g_conf->_windowColor); } if (_rootWin) @@ -378,7 +379,7 @@ void Window::redraw() { if (Windows::_forceRedraw) { unsigned char *color = Windows::_overrideBgSet ? g_conf->_windowColor : _bgColor; int y0 = _yAdj ? _bbox.top - _yAdj : _bbox.top; - _windows->drawRect(_bbox.left, y0, _bbox.width(), _bbox.bottom - y0, color); + g_vm->_screen->fillRect(_bbox.left, y0, _bbox.width(), _bbox.bottom - y0, color); } } diff --git a/engines/gargoyle/windows.h b/engines/gargoyle/windows.h index 9092ea46d8..ba9cb9210d 100644 --- a/engines/gargoyle/windows.h +++ b/engines/gargoyle/windows.h @@ -27,7 +27,6 @@ #include "common/list.h" #include "common/rect.h" #include "graphics/screen.h" -#include "gargoyle/draw.h" #include "gargoyle/events.h" #include "gargoyle/glk_types.h" #include "gargoyle/fonts.h" @@ -48,7 +47,7 @@ class PairWindow; /** * Main windows manager */ -class Windows : public Draw { +class Windows { friend class Window; public: class iterator { @@ -238,7 +237,7 @@ struct Attributes { /** * Window definition */ -class Window : public Draw { +class Window { public: Windows *_windows; glui32 _rock; |