From 4fc1c30423aa8e161a3ea2edd1f45c4ad681a92a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 29 Oct 2018 20:07:36 -0700 Subject: GLK: Fix Attributes equality checks --- engines/gargoyle/window_text_buffer.cpp | 9 ++++----- engines/gargoyle/window_text_grid.cpp | 2 +- engines/gargoyle/windows.h | 17 ++++++++++++++++- 3 files changed, 21 insertions(+), 7 deletions(-) (limited to 'engines') diff --git a/engines/gargoyle/window_text_buffer.cpp b/engines/gargoyle/window_text_buffer.cpp index d40dcf1602..4db0bf9c86 100644 --- a/engines/gargoyle/window_text_buffer.cpp +++ b/engines/gargoyle/window_text_buffer.cpp @@ -960,9 +960,8 @@ void TextBufferWindow::redraw() { x = x0 + SLOP + ln->_lm; a = 0; - for (b = 0; b < linelen; b++) - { - if (ln->_attrs[a] == ln->_attrs[b]) { + for (b = 0; b < linelen; b++) { + if (ln->_attrs[a] != ln->_attrs[b]) { link = ln->_attrs[a].hyper; font = ln->_attrs[a].attrFont(_styles); color = ln->_attrs[a].attrBg(_styles); @@ -1015,7 +1014,7 @@ void TextBufferWindow::redraw() { a = 0; for (b = 0; b < linelen; b++) { - if (ln->_attrs[a] == ln->_attrs[b]) { + if (ln->_attrs[a] != ln->_attrs[b]) { link = ln->_attrs[a].hyper; font = ln->_attrs[a].attrFont(_styles); color = link ? g_conf->_linkColor : ln->_attrs[a].attrFg(_styles); @@ -1603,7 +1602,7 @@ int TextBufferWindow::calcWidth(glui32 *chars, Attributes *attrs, int startchar, a = startchar; for (b = startchar; b < numChars; b++) { - if (attrs[a] == attrs[b]) { + if (attrs[a] != attrs[b]) { w += screen.stringWidthUni(attrs[a].attrFont(_styles), Common::U32String(chars + a, b - a), spw); a = b; diff --git a/engines/gargoyle/window_text_grid.cpp b/engines/gargoyle/window_text_grid.cpp index cad18af48f..6d1aff4946 100644 --- a/engines/gargoyle/window_text_grid.cpp +++ b/engines/gargoyle/window_text_grid.cpp @@ -599,7 +599,7 @@ void TextGridWindow::redraw() { a = 0; for (b = 0; b < _width; b++) { - if (ln->_attrs[a] == ln->_attrs[b]) { + if (ln->_attrs[a] != ln->_attrs[b]) { link = ln->_attrs[a].hyper; font = ln->_attrs[a].attrFont(styles); fgcolor = link ? g_conf->_linkColor : ln->_attrs[a].attrFg(styles); diff --git a/engines/gargoyle/windows.h b/engines/gargoyle/windows.h index 93d7ac24f6..d753d5311e 100644 --- a/engines/gargoyle/windows.h +++ b/engines/gargoyle/windows.h @@ -261,12 +261,27 @@ struct Attributes { && style == src.style && fgcolor == src.fgcolor && bgcolor == src.bgcolor && hyper == src.hyper; } + /** + * Inequality comparison + */ + bool operator!=(const Attributes &src) { + return fgset != src.fgset || bgset != src.bgset || reverse != src.reverse + || style != src.style || fgcolor != src.fgcolor || bgcolor != src.bgcolor + || hyper != src.hyper; + } + /** + * Return the background color for the current font style + */ byte *attrBg(WindowStyle *styles); + + /** + * Return the foreground color for the current font style + */ byte *attrFg(WindowStyle *styles); /** - * Get the font from the attribute's style + * Get the font for the current font style */ FACES attrFont(WindowStyle *styles) const { return styles[style].font; } }; -- cgit v1.2.3