aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/glk/frotz/processor_screen.cpp21
-rw-r--r--engines/glk/frotz/windows.cpp14
-rw-r--r--engines/glk/frotz/windows.h24
3 files changed, 41 insertions, 18 deletions
diff --git a/engines/glk/frotz/processor_screen.cpp b/engines/glk/frotz/processor_screen.cpp
index beebb54bea..992df74757 100644
--- a/engines/glk/frotz/processor_screen.cpp
+++ b/engines/glk/frotz/processor_screen.cpp
@@ -191,15 +191,9 @@ void Processor::screen_word(const zchar *s) {
}
void Processor::erase_screen(zword win) {
- int curr_fg = _wp[1][TRUE_FG_COLOR];
- int curr_bg = _wp[1][TRUE_BG_COLOR];
-
if ((short)win == -1) {
if (_wp._upper) {
- glk_set_window(_wp._upper);
-#ifdef GARGLK
- garglk_set_zcolors(curr_fg, curr_bg);
-#endif /* GARGLK */
+ _wp._upper.updateColors();
_wp._upper.clear();
}
@@ -211,13 +205,12 @@ void Processor::erase_screen(zword win) {
void Processor::erase_window(zword win) {
if (h_version == V6 && win != _wp._cwin && h_interpreter_number != INTERP_AMIGA)
- garglk_set_zcolors(_wp[win][TRUE_FG_COLOR], _wp[win][TRUE_BG_COLOR]);
-
- if (_wp[win])
- glk_window_clear(_wp[win]);
+ _wp[win].updateColors();
+ _wp[win].clear();
+
if (h_version == V6 && win != _wp._cwin && h_interpreter_number != INTERP_AMIGA)
- garglk_set_zcolors(_wp[_wp._cwin][TRUE_FG_COLOR], _wp[_wp._cwin][TRUE_BG_COLOR]);
+ _wp[_wp._cwin].updateColors();
}
void Processor::z_buffer_mode() {
@@ -309,9 +302,7 @@ void Processor::z_set_true_colour() {
if (!(zback < 0))
zback = zRGB(zargs[1]);
-#ifdef GARGLK
- garglk_set_zcolors(zfore, zback);
-#endif /* GARGLK */
+ _wp[_wp._cwin].updateColors(zfore, zback);
}
void Processor::z_set_colour() {
diff --git a/engines/glk/frotz/windows.cpp b/engines/glk/frotz/windows.cpp
index e94a345f4b..38e5dd96dc 100644
--- a/engines/glk/frotz/windows.cpp
+++ b/engines/glk/frotz/windows.cpp
@@ -165,6 +165,17 @@ void Window::clear() {
g_vm->glk_window_clear(_win);
}
+void Window::updateColors() {
+ if (_win)
+ _win->_stream->setZColors(_properties[TRUE_FG_COLOR], _properties[TRUE_BG_COLOR]);
+}
+
+void Window::updateColors(uint fore, uint back) {
+ _properties[TRUE_FG_COLOR] = fore;
+ _properties[TRUE_BG_COLOR] = back;
+ updateColors();
+}
+
const uint &Window::getProperty(WindowProperty propType) {
if (_win)
update();
@@ -177,8 +188,7 @@ void Window::setProperty(WindowProperty propType, uint value) {
case TRUE_FG_COLOR:
case TRUE_BG_COLOR:
_properties[propType] = value;
- if (_win && _win->_stream)
- _win->_stream->setZColors(_properties[TRUE_FG_COLOR], _properties[TRUE_BG_COLOR]);
+ updateColors();
break;
default:
diff --git a/engines/glk/frotz/windows.h b/engines/glk/frotz/windows.h
index dce980b7c8..9d9af2aa00 100644
--- a/engines/glk/frotz/windows.h
+++ b/engines/glk/frotz/windows.h
@@ -119,6 +119,11 @@ public:
}
/**
+ * Equality operator
+ */
+ inline bool operator==(const Window &rhs) { return this == &rhs; }
+
+ /**
* Cast operator for testing if the window has a proper Glk window attached to it
*/
operator bool() const { return _win != nullptr; }
@@ -147,6 +152,16 @@ public:
* Clear the window
*/
void clear();
+
+ /**
+ * Update colors for the window
+ */
+ void updateColors();
+
+ /**
+ * Update colors for the window
+ */
+ void updateColors(uint fore, uint back);
};
/**
@@ -187,9 +202,16 @@ public:
void setWindow(int win);
/**
+ * Get the current window
+ */
+ Window &currWin() {
+ return _windows[_cwin];
+ }
+
+ /**
* Get the current window pointer
*/
- winid_t currWin() const {
+ winid_t glkWin() const {
assert(_windows[_cwin]._win);
return _windows[_cwin]._win;
}