aboutsummaryrefslogtreecommitdiff
path: root/engines/glk
diff options
context:
space:
mode:
authorPaul Gilbert2019-08-11 14:38:32 -0700
committerPaul Gilbert2019-08-11 20:05:12 -0700
commitec3af0e0c610bd793a84cbfdfcef1b296d8883ba (patch)
tree2003aff794a84692581c6b52ce0c97501efdc528 /engines/glk
parent2d7635736f3023c23f7e7537f6549b34479014b7 (diff)
downloadscummvm-rg350-ec3af0e0c610bd793a84cbfdfcef1b296d8883ba.tar.gz
scummvm-rg350-ec3af0e0c610bd793a84cbfdfcef1b296d8883ba.tar.bz2
scummvm-rg350-ec3af0e0c610bd793a84cbfdfcef1b296d8883ba.zip
GLK: FROTZ: Allow window positioning before creating Glk window
This fixes a bug window with Athur that after the intro an extra text buffer window was needlessly being created which covered the play area, simply because one of the frotz windows had it's properties set
Diffstat (limited to 'engines/glk')
-rw-r--r--engines/glk/frotz/windows.cpp34
-rw-r--r--engines/glk/frotz/windows.h15
2 files changed, 40 insertions, 9 deletions
diff --git a/engines/glk/frotz/windows.cpp b/engines/glk/frotz/windows.cpp
index 677b213246..824bec5c64 100644
--- a/engines/glk/frotz/windows.cpp
+++ b/engines/glk/frotz/windows.cpp
@@ -161,8 +161,12 @@ void Window::setSize(const Point &newSize) {
_properties[X_SIZE] = newSize.x;
_properties[Y_SIZE] = newSize.y;
+ setSize();
+}
+
+void Window::setSize() {
if (_win)
- _win->setSize(Point(newSize.x * g_conf->_monoInfo._cellW, newSize.y * g_conf->_monoInfo._cellH));
+ _win->setSize(Point(_properties[X_SIZE] * g_conf->_monoInfo._cellW, _properties[Y_SIZE] * g_conf->_monoInfo._cellH));
}
void Window::setPosition(const Point &newPos) {
@@ -171,8 +175,12 @@ void Window::setPosition(const Point &newPos) {
_properties[X_POS] = newPos.x;
_properties[Y_POS] = newPos.y;
+ setPosition();
+}
+
+void Window::setPosition() {
if (_win)
- _win->setPosition(Point((newPos.x - 1) * g_conf->_monoInfo._cellW, (newPos.y - 1) * g_conf->_monoInfo._cellH));
+ _win->setPosition(Point((_properties[X_POS] - 1) * g_conf->_monoInfo._cellW, (_properties[Y_POS] - 1) * g_conf->_monoInfo._cellH));
}
void Window::setCursor(const Point &newPos) {
@@ -196,7 +204,14 @@ void Window::setCursor(const Point &newPos) {
y = _properties[Y_CURSOR];
}
- g_vm->glk_window_move_cursor(_win, x - 1, y - 1);
+ _properties[X_CURSOR] = x;
+ _properties[Y_CURSOR] = y;
+
+ setCursor();
+}
+
+void Window::setCursor() {
+ g_vm->glk_window_move_cursor(_win, _properties[X_CURSOR] - 1, _properties[Y_CURSOR] - 1);
}
void Window::clear() {
@@ -280,11 +295,10 @@ void Window::setStyle(int style) {
}
void Window::updateStyle() {
- uint style = _currStyle;
-
if (!_win)
- createGlkWindow();
+ return;
+ uint style = _currStyle;
if (style & REVERSE_STYLE)
setReverseVideo(true);
@@ -339,8 +353,10 @@ void Window::createGlkWindow() {
winmethod_Arbitrary | winmethod_Fixed, 0, wintype_TextBuffer, 0);
}
- setSize(Point(_properties[X_SIZE], _properties[Y_SIZE]));
- setPosition(Point(_properties[X_POS], _properties[Y_POS]));
+ updateStyle();
+ setPosition();
+ setSize();
+ setCursor();
g_vm->glk_set_window(_win);
}
@@ -366,7 +382,7 @@ void Window::setProperty(WindowProperty propType, uint value) {
}
void Window::checkRepositionLower() {
- if (&_windows->_lower == this) {
+ if (&_windows->_lower == this && _win) {
PairWindow *parent = dynamic_cast<PairWindow *>(_win->_parent);
if (!parent)
error("Parent was not a pair window");
diff --git a/engines/glk/frotz/windows.h b/engines/glk/frotz/windows.h
index d55c928a30..bd2cfd1c7f 100644
--- a/engines/glk/frotz/windows.h
+++ b/engines/glk/frotz/windows.h
@@ -164,16 +164,31 @@ public:
void setSize(const Point &newSize);
/**
+ * Copys a window's size to the underlying Glk one, if present
+ */
+ void setSize();
+
+ /**
* Set the position of a window
*/
void setPosition(const Point &newPos);
/**
+ * Copys a window's position to the underlying Glk one, if present
+ */
+ void setPosition();
+
+ /**
* Set the cursor position
*/
void setCursor(const Point &newPos);
/**
+ * Copys a window's position to the underlying Glk one, if present
+ */
+ void setCursor();
+
+ /**
* Clear the window
*/
void clear();