From 7fd850c745fef7a222a1af9242799e8c11b4765c Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Thu, 28 Apr 2016 17:14:13 +0200 Subject: WAGE: Remove yet another indirect reference to WAGE engine in WM --- engines/wage/macmenu.cpp | 8 ++++-- engines/wage/macwindowmanager.cpp | 53 +++++++++++++++++++++++++++++++++++++-- engines/wage/macwindowmanager.h | 1 + 3 files changed, 58 insertions(+), 4 deletions(-) diff --git a/engines/wage/macmenu.cpp b/engines/wage/macmenu.cpp index bed9dd42f4..a97e442c83 100644 --- a/engines/wage/macmenu.cpp +++ b/engines/wage/macmenu.cpp @@ -318,6 +318,9 @@ bool Menu::draw(Graphics::ManagedSurface *g, bool forceRedraw) { r.top = 7; _screen.fillRect(r, kColorWhite); r.top = kMenuHeight - 1; + r.bottom++; + _screen.fillRect(r, kColorGreen); + r.bottom--; _screen.fillRect(r, kColorBlack); for (uint i = 0; i < _items.size(); i++) { @@ -411,8 +414,9 @@ void Menu::renderSubmenu(MenuItem *menu) { } } else { // Delimiter bool flip = r->left & 2; - for (int xx = r->left + 1; xx <= r->right - 1; xx++) { - drawPixelPlain(xx, y + kMenuDropdownItemHeight / 2, (flip ? kColorBlack : kColorWhite), &_screen); + byte *ptr = (byte *)_screen.getBasePtr(r->left + 1, y + kMenuDropdownItemHeight / 2); + for (int xx = r->left + 1; xx <= r->right - 1; xx++, ptr++) { + *ptr = flip ? kColorBlack : kColorWhite; flip = !flip; } } diff --git a/engines/wage/macwindowmanager.cpp b/engines/wage/macwindowmanager.cpp index 3bebd865ef..5cc54d648a 100644 --- a/engines/wage/macwindowmanager.cpp +++ b/engines/wage/macwindowmanager.cpp @@ -50,13 +50,14 @@ #include "common/list.h" #include "common/unzip.h" #include "common/system.h" +#include "common/stream.h" #include "graphics/cursorman.h" #include "graphics/fonts/bdf.h" #include "graphics/managed_surface.h" #include "graphics/palette.h" +#include "graphics/primitives.h" -#include "wage/design.h" #include "wage/macwindowmanager.h" #include "wage/macwindow.h" #include "wage/macmenu.h" @@ -184,10 +185,58 @@ void MacWindowManager::setActive(int id) { _fullRefresh = true; } +struct PlotData { + Graphics::ManagedSurface *surface; + Patterns *patterns; + uint fillType; + int thickness; + + PlotData(Graphics::ManagedSurface *s, Patterns *p, int f, int t) : + surface(s), patterns(p), fillType(f), thickness(t) {} +}; + +static void drawPixel(int x, int y, int color, void *data) { + PlotData *p = (PlotData *)data; + + if (p->fillType > p->patterns->size()) + return; + + byte *pat = p->patterns->operator[](p->fillType - 1); + + if (p->thickness == 1) { + if (x >= 0 && x < p->surface->w && y >= 0 && y < p->surface->h) { + uint xu = (uint)x; // for letting compiler optimize it + uint yu = (uint)y; + + *((byte *)p->surface->getBasePtr(xu, yu)) = + (pat[yu % 8] & (1 << (7 - xu % 8))) ? + color : kColorWhite; + } + } else { + int x1 = x; + int x2 = x1 + p->thickness; + int y1 = y; + int y2 = y1 + p->thickness; + + for (y = y1; y < y2; y++) + for (x = x1; x < x2; x++) + if (x >= 0 && x < p->surface->w && y >= 0 && y < p->surface->h) { + uint xu = (uint)x; // for letting compiler optimize it + uint yu = (uint)y; + *((byte *)p->surface->getBasePtr(xu, yu)) = + (pat[yu % 8] & (1 << (7 - xu % 8))) ? + color : kColorWhite; + } + } +} + void MacWindowManager::drawDesktop() { Common::Rect r(_screen->getBounds()); - Design::drawFilledRoundRect(_screen, r, kDesktopArc, kColorBlack, _patterns, kPatternCheckers); + PlotData pd(_screen, &_patterns, kPatternCheckers, 1); + + Graphics::drawRoundRect(r, kDesktopArc, kColorBlack, true, drawPixel, &pd); + g_system->copyRectToScreen(_screen->getPixels(), _screen->pitch, 0, 0, _screen->w, _screen->h); } diff --git a/engines/wage/macwindowmanager.h b/engines/wage/macwindowmanager.h index 2d03c9b11d..13f85cddd4 100644 --- a/engines/wage/macwindowmanager.h +++ b/engines/wage/macwindowmanager.h @@ -108,6 +108,7 @@ public: BaseMacWindow *getWindow(int id) { return _windows[id]; } Patterns &getPatterns() { return _patterns; } + void drawFilledRoundRect(Graphics::ManagedSurface *surface, Common::Rect &rect, int arc, int color); void pushArrowCursor(); void popCursor(); -- cgit v1.2.3