aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/gargoyle/glk.cpp8
-rw-r--r--engines/gargoyle/glk_types.h7
-rw-r--r--engines/gargoyle/streams.cpp66
-rw-r--r--engines/gargoyle/streams.h10
4 files changed, 89 insertions, 2 deletions
diff --git a/engines/gargoyle/glk.cpp b/engines/gargoyle/glk.cpp
index 8beca88f2c..6022a86999 100644
--- a/engines/gargoyle/glk.cpp
+++ b/engines/gargoyle/glk.cpp
@@ -1148,11 +1148,15 @@ void Glk::garglk_unput_string_uni(const glui32 *str) {
}
void Glk::garglk_set_zcolors(glui32 fg, glui32 bg) {
- // TODO
+ _streams->getCurrent()->setZColors(fg, bg);
}
void Glk::garglk_set_zcolors_stream(strid_t str, glui32 fg, glui32 bg) {
- // TODO
+ if (str) {
+ str->setZColors(fg, bg);
+ } else {
+ warning("set_style_stream: Invalid ref");
+ }
}
void Glk::garglk_set_reversevideo(glui32 reverse) {
diff --git a/engines/gargoyle/glk_types.h b/engines/gargoyle/glk_types.h
index 6ea4408305..6dd8504326 100644
--- a/engines/gargoyle/glk_types.h
+++ b/engines/gargoyle/glk_types.h
@@ -179,6 +179,13 @@ enum giDisp {
gidisp_Class_Schannel = 3,
};
+enum zcolor {
+ zcolor_Transparent = (uint32)-4,
+ zcolor_Cursor = (uint32)-3,
+ zcolor_Current = (uint32)-2,
+ zcolor_Default = (uint32)-1
+};
+
#ifdef GLK_MODULE_IMAGE
enum ImageAlign {
diff --git a/engines/gargoyle/streams.cpp b/engines/gargoyle/streams.cpp
index 0f95984046..9d257f2fa1 100644
--- a/engines/gargoyle/streams.cpp
+++ b/engines/gargoyle/streams.cpp
@@ -63,6 +63,11 @@ void Stream::close(StreamResult *result) {
delete this;
}
+void Stream::setZColors(glui32 fg, glui32 bg) {
+ if (_writable && g_conf->_styleHint)
+ Windows::_forceRedraw = true;
+}
+
/*--------------------------------------------------------------------------*/
void WindowStream::close(StreamResult *result) {
@@ -217,6 +222,67 @@ void WindowStream::setHyperlink(glui32 linkVal) {
_window->_attr.hyper = linkVal;
}
+void WindowStream::setZColors(glui32 fg, glui32 bg) {
+ if (!_writable || !g_conf->_styleHint)
+ return;
+
+ byte fore[3], back[3];
+ fore[0] = (fg >> 16) & 0xff;
+ fore[1] = (fg >> 8) & 0xff;
+ fore[2] = (fg) & 0xff;
+ back[0] = (bg >> 16) & 0xff;
+ back[1] = (bg >> 8) & 0xff;
+ back[2] = (bg) & 0xff;
+
+ if (fg != zcolor_Transparent && fg != zcolor_Cursor) {
+ if (fg == zcolor_Default) {
+ _window->_attr.fgset = 0;
+ _window->_attr.fgcolor = 0;
+ Windows::_overrideFgSet = false;
+ Windows::_overrideFgVal = 0;
+
+ Common::copy(g_conf->_moreSave, g_conf->_moreSave + 3, g_conf->_moreColor);
+ Common::copy(g_conf->_caretSave, g_conf->_caretSave + 3, g_conf->_caretColor);
+ Common::copy(g_conf->_linkSave, g_conf->_linkSave + 3, g_conf->_linkColor);
+ } else if (fg != zcolor_Current) {
+ _window->_attr.fgset = 1;
+ _window->_attr.fgcolor = fg;
+ Windows::_overrideFgSet = true;
+ Windows::_overrideFgVal = fg;
+
+ Common::copy(fore, fore + 3, g_conf->_moreColor);
+ Common::copy(fore, fore + 3, g_conf->_caretColor);
+ Common::copy(fore, fore + 3, g_conf->_linkColor);
+ }
+ }
+
+ if (bg != zcolor_Transparent && bg != zcolor_Cursor) {
+ if (bg == zcolor_Default) {
+ _window->_attr.bgset = 0;
+ _window->_attr.bgcolor = 0;
+ Windows::_overrideBgSet = false;
+ Windows::_overrideBgVal = 0;
+
+ Common::copy(g_conf->_windowSave, g_conf->_windowSave + 3, g_conf->_windowColor);
+ Common::copy(g_conf->_borderSave, g_conf->_borderSave + 3, g_conf->_borderColor);
+ } else if (bg != zcolor_Current) {
+ _window->_attr.bgset = 1;
+ _window->_attr.bgcolor = bg;
+ Windows::_overrideBgSet = true;
+ Windows::_overrideBgVal = bg;
+
+ Common::copy(back, back + 3, g_conf->_windowColor);
+ Common::copy(back, back + 3, g_conf->_borderColor);
+ }
+ }
+
+ Windows::_overrideReverse = !(fg == zcolor_Default && bg == zcolor_Default);
+ Windows::_forceRedraw = true;
+
+ if (_window->_echoStream)
+ _window->_echoStream->setZColors(fg, bg);
+}
+
/*--------------------------------------------------------------------------*/
MemoryStream::MemoryStream(Streams *streams, void *buf, size_t buflen, FileMode mode, uint32 rock, bool unicode) :
diff --git a/engines/gargoyle/streams.h b/engines/gargoyle/streams.h
index 02e2f3b7e6..ac2503220f 100644
--- a/engines/gargoyle/streams.h
+++ b/engines/gargoyle/streams.h
@@ -257,6 +257,11 @@ public:
* Set a hyperlink
*/
virtual void setHyperlink(glui32 linkVal) {}
+
+ /**
+ * Set the style colors
+ */
+ virtual void setZColors(glui32 fg, glui32 bg);
};
typedef Stream *strid_t;
@@ -314,6 +319,11 @@ public:
* Set a hyperlink
*/
virtual void setHyperlink(glui32 linkVal) override;
+
+ /**
+ * Set the style colors
+ */
+ virtual void setZColors(glui32 fg, glui32 bg) override;
};
/**