aboutsummaryrefslogtreecommitdiff
path: root/engines/glk/frotz
diff options
context:
space:
mode:
authorPaul Gilbert2019-03-27 19:07:08 -0700
committerPaul Gilbert2019-04-04 18:50:52 -0700
commit10a5b70b0af167c1f154a4c9dbe8829fe966fffa (patch)
treef80f2a480ba4a21e36a53b3533c1e46afbe25cf9 /engines/glk/frotz
parentf04705084c6745b67766f33eac25cc73b4d3f524 (diff)
downloadscummvm-rg350-10a5b70b0af167c1f154a4c9dbe8829fe966fffa.tar.gz
scummvm-rg350-10a5b70b0af167c1f154a4c9dbe8829fe966fffa.tar.bz2
scummvm-rg350-10a5b70b0af167c1f154a4c9dbe8829fe966fffa.zip
GLK: FROTZ: Handle creating Glk window when switching to/from fixed width styles
Diffstat (limited to 'engines/glk/frotz')
-rw-r--r--engines/glk/frotz/windows.cpp22
-rw-r--r--engines/glk/frotz/windows.h7
2 files changed, 20 insertions, 9 deletions
diff --git a/engines/glk/frotz/windows.cpp b/engines/glk/frotz/windows.cpp
index 8ebc263151..0619030567 100644
--- a/engines/glk/frotz/windows.cpp
+++ b/engines/glk/frotz/windows.cpp
@@ -23,6 +23,7 @@
#include "glk/frotz/windows.h"
#include "glk/frotz/frotz.h"
#include "glk/window_pair.h"
+#include "glk/window_text_grid.h"
#include "glk/window_text_buffer.h"
#include "glk/conf.h"
@@ -143,6 +144,11 @@ void Window::setPosition(const Point &newPos) {
void Window::setCursor(const Point &newPos) {
int x = newPos.x, y = newPos.y;
+ if (!(_currStyle & FIXED_WIDTH_STYLE)) {
+ _currStyle |= FIXED_WIDTH_STYLE;
+ ensureGlkWindow();
+ }
+
if (y < 0) {
// Cursor on/off
if (y == -2)
@@ -226,10 +232,10 @@ uint Window::setFont(uint font) {
return result;
}
-void Window::setStyle(int style) {
+void Window::setStyle(uint style) {
if (style == 0)
_currStyle = 0;
- else if (style != -1)
+ else if (style != 0xf000)
// not tickle time
_currStyle |= style;
@@ -247,8 +253,7 @@ void Window::setStyle(int style) {
void Window::updateStyle() {
uint style = _currStyle;
- if (!_win)
- createGlkWindow();
+ ensureGlkWindow();
if (style & REVERSE_STYLE)
setReverseVideo(true);
@@ -289,9 +294,14 @@ void Window::setReverseVideo(bool reverse) {
_win->_stream->setReverseVideo(reverse);
}
-void Window::createGlkWindow() {
+void Window::ensureGlkWindow() {
// Create a new window
- if (_index == 1) {
+ if (_win && (dynamic_cast<TextGridWindow *>(_win) != nullptr) != ((_currStyle & FIXED_WIDTH_STYLE) != 0)) {
+ g_vm->glk_window_close(_win);
+ _win = nullptr;
+ }
+
+ if (_currStyle & FIXED_WIDTH_STYLE) {
// Text grid window
_win = g_vm->glk_window_open(g_vm->glk_window_get_root(),
winmethod_Arbitrary | winmethod_Fixed, 0, wintype_TextGrid, 0);
diff --git a/engines/glk/frotz/windows.h b/engines/glk/frotz/windows.h
index fe59cc7e00..f12d9eec20 100644
--- a/engines/glk/frotz/windows.h
+++ b/engines/glk/frotz/windows.h
@@ -102,9 +102,10 @@ private:
void update();
/**
- * Creates a new Glk window to attach to the window
+ * Creates a new Glk window to attach to the window if not already present, or recreates the window
+ * if the font style has changed to/from fixed width
*/
- void createGlkWindow();
+ void ensureGlkWindow();
/**
* Updates the current font/style
@@ -191,7 +192,7 @@ public:
/**
* Set the textstyle
*/
- void setStyle(int style = -1);
+ void setStyle(uint style = 0xf000);
/**
* Set reverse video