aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/director/frame.cpp2
-rw-r--r--graphics/macgui/macmenu.cpp32
-rw-r--r--graphics/macgui/mactextwindow.cpp10
-rw-r--r--graphics/macgui/macwindow.cpp35
-rw-r--r--graphics/macgui/macwindowmanager.cpp55
-rw-r--r--graphics/macgui/macwindowmanager.h6
6 files changed, 100 insertions, 40 deletions
diff --git a/engines/director/frame.cpp b/engines/director/frame.cpp
index e42444dc00..231a2ea3b9 100644
--- a/engines/director/frame.cpp
+++ b/engines/director/frame.cpp
@@ -700,7 +700,7 @@ void Frame::renderButton(Graphics::ManagedSurface &surface, uint16 spriteId) {
break;
case kTypeButton: {
_rect = Common::Rect(x, y, x + width, y + height + 3);
- Graphics::MacPlotData pd(&surface, &_vm->getMacWindowManager()->getPatterns(), Graphics::MacGUIConstants::kPatternSolid, 1);
+ Graphics::MacPlotData pd(&surface, &_vm->getMacWindowManager()->getPatterns(), Graphics::MacGUIConstants::kPatternSolid, 1, Graphics::kColorWhite);
Graphics::drawRoundRect(_rect, 4, 0, false, Graphics::macDrawPixel, &pd);
addDrawRect(spriteId, _rect);
}
diff --git a/graphics/macgui/macmenu.cpp b/graphics/macgui/macmenu.cpp
index 4ca541324e..9ab92a8fd1 100644
--- a/graphics/macgui/macmenu.cpp
+++ b/graphics/macgui/macmenu.cpp
@@ -362,17 +362,17 @@ bool MacMenu::draw(ManagedSurface *g, bool forceRedraw) {
_screen.clear(kColorGreen);
- drawFilledRoundRect(&_screen, r, kDesktopArc, kColorWhite);
+ drawFilledRoundRect(&_screen, r, kDesktopArc, _wm->_colorWhite);
r.top = 7;
- _screen.fillRect(r, kColorWhite);
+ _screen.fillRect(r, _wm->_colorWhite);
r.top = kMenuHeight - 1;
r.bottom++;
_screen.fillRect(r, kColorGreen);
r.bottom--;
- _screen.fillRect(r, kColorBlack);
+ _screen.fillRect(r, _wm->_colorBlack);
for (uint i = 0; i < _items.size(); i++) {
- int color = kColorBlack;
+ int color = _wm->_colorBlack;
MacMenuItem *it = _items[i];
if ((uint)_activeItem == i) {
@@ -382,8 +382,8 @@ bool MacMenu::draw(ManagedSurface *g, bool forceRedraw) {
hbox.right += 3;
hbox.bottom += 1;
- _screen.fillRect(hbox, kColorBlack);
- color = kColorWhite;
+ _screen.fillRect(hbox, _wm->_colorBlack);
+ color = _wm->_colorWhite;
if (!it->subitems.empty())
renderSubmenu(it);
@@ -405,12 +405,12 @@ void MacMenu::renderSubmenu(MacMenuItem *menu) {
if (r->width() == 0 || r->height() == 0)
return;
- _screen.fillRect(*r, kColorWhite);
- _screen.frameRect(*r, kColorBlack);
- _screen.vLine(r->right, r->top + 3, r->bottom + 1, kColorBlack);
- _screen.vLine(r->right + 1, r->top + 3, r->bottom + 1, kColorBlack);
- _screen.hLine(r->left + 3, r->bottom, r->right + 1, kColorBlack);
- _screen.hLine(r->left + 3, r->bottom + 1, r->right + 1, kColorBlack);
+ _screen.fillRect(*r, _wm->_colorWhite);
+ _screen.frameRect(*r, _wm->_colorBlack);
+ _screen.vLine(r->right, r->top + 3, r->bottom + 1, _wm->_colorBlack);
+ _screen.vLine(r->right + 1, r->top + 3, r->bottom + 1, _wm->_colorBlack);
+ _screen.hLine(r->left + 3, r->bottom, r->right + 1, _wm->_colorBlack);
+ _screen.hLine(r->left + 3, r->bottom + 1, r->right + 1, _wm->_colorBlack);
int x = r->left + kMenuDropdownPadding;
int y = r->top + 1;
@@ -419,12 +419,12 @@ void MacMenu::renderSubmenu(MacMenuItem *menu) {
Common::String acceleratorText(getAcceleratorString(menu->subitems[i], ""));
int accelX = r->right - 25;
- int color = kColorBlack;
+ int color = _wm->_colorBlack;
if (i == (uint)_activeSubItem && !text.empty() && menu->subitems[i]->enabled) {
- color = kColorWhite;
+ color = _wm->_colorWhite;
Common::Rect trect(r->left, y - (_wm->_fontMan->hasBuiltInFonts() ? 1 : 0), r->right, y + _font->getFontHeight());
- _screen.fillRect(trect, kColorBlack);
+ _screen.fillRect(trect, _wm->_colorBlack);
}
if (!text.empty()) {
@@ -464,7 +464,7 @@ void MacMenu::renderSubmenu(MacMenuItem *menu) {
bool flip = r->left & 2;
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;
+ *ptr = flip ? _wm->_colorBlack : _wm->_colorWhite;
flip = !flip;
}
}
diff --git a/graphics/macgui/mactextwindow.cpp b/graphics/macgui/mactextwindow.cpp
index c05468c2e3..b43948af3b 100644
--- a/graphics/macgui/mactextwindow.cpp
+++ b/graphics/macgui/mactextwindow.cpp
@@ -70,7 +70,7 @@ MacTextWindow::MacTextWindow(MacWindowManager *wm, const MacFont *font, int fgco
_cursorRect = new Common::Rect(0, 0, 1, kCursorHeight);
_cursorSurface = new ManagedSurface(1, kCursorHeight);
- _cursorSurface->fillRect(*_cursorRect, kColorBlack);
+ _cursorSurface->fillRect(*_cursorRect, _wm->_colorBlack);
g_system->getTimerManager()->installTimerProc(&cursorTimerHandler, 200000, this, "textWindowCursor");
}
@@ -131,7 +131,7 @@ bool MacTextWindow::draw(ManagedSurface *g, bool forceRedraw) {
if (_borderIsDirty || forceRedraw) {
drawBorder();
- _composeSurface.clear(kColorWhite);
+ _composeSurface.clear(_wm->_colorWhite);
}
if (_inputIsDirty || forceRedraw) {
@@ -209,10 +209,10 @@ void MacTextWindow::drawSelection() {
byte *ptr = (byte *)_composeSurface.getBasePtr(x1 + kConWOverlap - 2, y + kConWOverlap - 2);
for (int x = x1; x < x2; x++, ptr++)
- if (*ptr == kColorBlack)
- *ptr = kColorWhite;
+ if (*ptr == _wm->_colorBlack)
+ *ptr = _wm->_colorWhite;
else
- *ptr = kColorBlack;
+ *ptr = _wm->_colorBlack;
}
}
diff --git a/graphics/macgui/macwindow.cpp b/graphics/macgui/macwindow.cpp
index 7b9afa4157..a64cc88a43 100644
--- a/graphics/macgui/macwindow.cpp
+++ b/graphics/macgui/macwindow.cpp
@@ -159,13 +159,15 @@ const int arrowPixels[ARROW_H][ARROW_W] = {
{0,1,1,1,1,1,1,1,1,1,1,0},
{1,1,1,1,1,1,1,1,1,1,1,1}};
+int localColorWhite, localColorBlack;
+
static void drawPixelInverted(int x, int y, int color, void *data) {
ManagedSurface *surface = (ManagedSurface *)data;
if (x >= 0 && x < surface->w && y >= 0 && y < surface->h) {
byte *p = (byte *)surface->getBasePtr(x, y);
- *p = *p == kColorWhite ? kColorBlack : kColorWhite;
+ *p = *p == localColorWhite ? localColorBlack : localColorWhite;
}
}
@@ -234,26 +236,26 @@ void MacWindow::drawSimpleBorder(ManagedSurface *g) {
drawBox(g, x + width - size + 1, y + size, size - 4, height - 2 * size - 1);
if (active) {
- fillRect(g, x + size, y + 5, width - 2 * size - 1, 8, kColorBlack);
- fillRect(g, x + size, y + height - 13, width - 2 * size - 1, 8, kColorBlack);
- fillRect(g, x + 5, y + size, 8, height - 2 * size - 1, kColorBlack);
+ fillRect(g, x + size, y + 5, width - 2 * size - 1, 8, _wm->_colorBlack);
+ fillRect(g, x + size, y + height - 13, width - 2 * size - 1, 8, _wm->_colorBlack);
+ fillRect(g, x + 5, y + size, 8, height - 2 * size - 1, _wm->_colorBlack);
if (!scrollable) {
- fillRect(g, x + width - 13, y + size, 8, height - 2 * size - 1, kColorBlack);
+ fillRect(g, x + width - 13, y + size, 8, height - 2 * size - 1, _wm->_colorBlack);
} else {
int x1 = x + width - 15;
int y1 = y + size + 1;
for (int yy = 0; yy < ARROW_H; yy++) {
for (int xx = 0; xx < ARROW_W; xx++)
- g->hLine(x1 + xx, y1 + yy, x1 + xx, (arrowPixels[yy][xx] != 0 ? kColorBlack : kColorWhite));
+ g->hLine(x1 + xx, y1 + yy, x1 + xx, (arrowPixels[yy][xx] != 0 ? _wm->_colorBlack : _wm->_colorWhite));
}
- fillRect(g, x + width - 13, y + size + ARROW_H, 8, height - 2 * size - 1 - ARROW_H * 2, kColorBlack);
+ fillRect(g, x + width - 13, y + size + ARROW_H, 8, height - 2 * size - 1 - ARROW_H * 2, _wm->_colorBlack);
y1 += height - 2 * size - ARROW_H - 2;
for (int yy = 0; yy < ARROW_H; yy++) {
for (int xx = 0; xx < ARROW_W; xx++)
- g->hLine(x1 + xx, y1 + yy, x1 + xx, (arrowPixels[ARROW_H - yy - 1][xx] != 0 ? kColorBlack : kColorWhite));
+ g->hLine(x1 + xx, y1 + yy, x1 + xx, (arrowPixels[ARROW_H - yy - 1][xx] != 0 ? _wm->_colorBlack : _wm->_colorWhite));
}
if (_highlightedPart == kBorderScrollUp || _highlightedPart == kBorderScrollDown) {
@@ -263,12 +265,15 @@ void MacWindow::drawSimpleBorder(ManagedSurface *g) {
int ry2 = ry1 + _dims.height() * _scrollSize;
Common::Rect rr(rx1, ry1, rx2, ry2);
- Graphics::drawFilledRect(rr, kColorBlack, drawPixelInverted, g);
+ localColorWhite = _wm->_colorWhite;
+ localColorBlack = _wm->_colorBlack;
+
+ Graphics::drawFilledRect(rr, _wm->_colorBlack, drawPixelInverted, g);
}
}
if (closeable) {
if (_highlightedPart == kBorderCloseButton) {
- fillRect(g, x + 6, y + 6, 6, 6, kColorBlack);
+ fillRect(g, x + 6, y + 6, 6, 6, _wm->_colorBlack);
} else {
drawBox(g, x + 5, y + 5, 7, 7);
}
@@ -284,7 +289,7 @@ void MacWindow::drawSimpleBorder(ManagedSurface *g) {
if (w > maxWidth)
w = maxWidth;
drawBox(g, x + (width - w) / 2, y, w, size);
- font->drawString(g, _title, x + (width - w) / 2 + 5, y + yOff, w, kColorBlack);
+ font->drawString(g, _title, x + (width - w) / 2 + 5, y + yOff, w, _wm->_colorBlack);
}
}
@@ -294,9 +299,9 @@ void MacWindow::drawPattern() {
for (int x = 0; x < _surface.w; x++) {
byte *dst = (byte *)_surface.getBasePtr(x, y);
if (pat[y % 8] & (1 << (7 - (x % 8))))
- *dst = kColorBlack;
+ *dst = _wm->_colorBlack;
else
- *dst = kColorWhite;
+ *dst = _wm->_colorWhite;
}
}
}
@@ -350,8 +355,8 @@ void MacWindow::setCloseable(bool closeable) {
void MacWindow::drawBox(ManagedSurface *g, int x, int y, int w, int h) {
Common::Rect r(x, y, x + w + 1, y + h + 1);
- g->fillRect(r, kColorWhite);
- g->frameRect(r, kColorBlack);
+ g->fillRect(r, _wm->_colorWhite);
+ g->frameRect(r, _wm->_colorBlack);
}
void MacWindow::fillRect(ManagedSurface *g, int x, int y, int w, int h, int color) {
diff --git a/graphics/macgui/macwindowmanager.cpp b/graphics/macgui/macwindowmanager.cpp
index cbc2159536..bde17b6e49 100644
--- a/graphics/macgui/macwindowmanager.cpp
+++ b/graphics/macgui/macwindowmanager.cpp
@@ -158,6 +158,9 @@ MacWindowManager::MacWindowManager() {
_menuDelay = 0;
_menuTimerActive = false;
+ _colorBlack = 0;
+ _colorWhite = 2;
+
_fullRefresh = true;
for (int i = 0; i < ARRAYSIZE(fillPatterns); i++)
@@ -290,9 +293,9 @@ void macDrawPixel(int x, int y, int color, void *data) {
void MacWindowManager::drawDesktop() {
Common::Rect r(_screen->getBounds());
- MacPlotData pd(_screen, &_patterns, kPatternCheckers, 1);
+ MacPlotData pd(_screen, &_patterns, kPatternCheckers, 1, _colorWhite);
- Graphics::drawRoundRect(r, kDesktopArc, kColorBlack, true, macDrawPixel, &pd);
+ Graphics::drawRoundRect(r, kDesktopArc, _colorBlack, true, macDrawPixel, &pd);
g_system->copyRectToScreen(_screen->getPixels(), _screen->pitch, 0, 0, _screen->w, _screen->h);
}
@@ -450,5 +453,53 @@ void MacWindowManager::popCursor() {
CursorMan.popCursor();
}
+///////////////////
+// Palette stuff
+///////////////////
+void MacWindowManager::passPalette(const byte *pal, uint size) {
+ const byte *p = pal;
+
+ _colorWhite = -1;
+ _colorBlack = -1;
+
+ // Search pure white and black colors
+ for (uint i = 0; i < size; i++) {
+ if (_colorWhite == -1 && p[0] == 0xff && p[1] == 0xff && p[2] == 0xff)
+ _colorWhite = i;
+
+
+ if (_colorBlack == -1 && p[0] == 0x00 && p[1] == 0x00 && p[2] == 0x00)
+ _colorBlack = i;
+
+ p += 3;
+ }
+
+ if (_colorWhite != -1 && _colorBlack != -1)
+ return;
+
+ // We did not find some color. Let's find closest approximations
+ float darkest = 1000.0f, brightest = -1.0f;
+ int di = -1, bi = -1;
+ p = pal;
+
+ for (uint i = 0; i < size; i++) {
+ float gray = p[0] * 0.3f + p[1] * 0.59f + p[2] * 0.11f;
+
+ if (darkest > gray) {
+ darkest = gray;
+ di = i;
+ }
+
+ if (brightest < gray) {
+ brightest = gray;
+ bi = i;
+ }
+
+ p += 3;
+ }
+
+ _colorWhite = brightest;
+ _colorBlack = darkest;
+}
} // End of namespace Graphics
diff --git a/graphics/macgui/macwindowmanager.h b/graphics/macgui/macwindowmanager.h
index 07a60cba82..a220b737e8 100644
--- a/graphics/macgui/macwindowmanager.h
+++ b/graphics/macgui/macwindowmanager.h
@@ -83,7 +83,7 @@ struct MacPlotData {
int thickness;
uint bgColor;
- MacPlotData(Graphics::ManagedSurface *s, MacPatterns *p, int f, int t, uint bg = kColorWhite) :
+ MacPlotData(Graphics::ManagedSurface *s, MacPatterns *p, int f, int t, uint bg) :
surface(s), patterns(p), fillType(f), thickness(t), bgColor(bg) {
}
};
@@ -210,6 +210,8 @@ public:
void setMode(uint32 mode) { _mode = mode; }
+ void passPalette(const byte *palette, uint size);
+
public:
MacFontManager *_fontMan;
uint32 _mode;
@@ -219,6 +221,8 @@ public:
bool _menuTimerActive;
+ int _colorBlack, _colorWhite;
+
private:
void drawDesktop();