diff options
author | Paul Gilbert | 2019-01-02 14:21:49 -0800 |
---|---|---|
committer | Paul Gilbert | 2019-01-02 14:23:40 -0800 |
commit | 3ed48e3de223259dd58f0c613c2d68d69848e5a2 (patch) | |
tree | 842ff37835be0081400a24e877b555b1d1a4037f /engines/glk/frotz | |
parent | f1fdb0cd26b2645b7b012f5177f50bdaffcd10f9 (diff) | |
download | scummvm-rg350-3ed48e3de223259dd58f0c613c2d68d69848e5a2.tar.gz scummvm-rg350-3ed48e3de223259dd58f0c613c2d68d69848e5a2.tar.bz2 scummvm-rg350-3ed48e3de223259dd58f0c613c2d68d69848e5a2.zip |
GLK: FROTZ: Setting window positon & size, some property reading
Diffstat (limited to 'engines/glk/frotz')
-rw-r--r-- | engines/glk/frotz/windows.cpp | 51 | ||||
-rw-r--r-- | engines/glk/frotz/windows.h | 30 |
2 files changed, 65 insertions, 16 deletions
diff --git a/engines/glk/frotz/windows.cpp b/engines/glk/frotz/windows.cpp index fdcfcf16b1..1863e68032 100644 --- a/engines/glk/frotz/windows.cpp +++ b/engines/glk/frotz/windows.cpp @@ -42,10 +42,16 @@ Window &Windows::operator[](uint idx) { /*--------------------------------------------------------------------------*/ +Window::Window() : _windows(nullptr), _win(nullptr), _tempVal(0) {} + + winid_t Window::getWindow() { if (!_win) { // Window doesn't exist, so create it - // TODO + // TODO: For now I'm assuming all the extra created windows will be graphics, since Glk requires + // us to specify it at creation time. Not sure if it's true or not for all V6 games + winid_t parent = _windows->_lower; + _win = g_vm->glk_window_open(parent, winmethod_OnTop | winmethod_Fixed, 0, wintype_Graphics, 0); } return _win; @@ -54,9 +60,8 @@ winid_t Window::getWindow() { void Window::setSize(const Point &newSize) { winid_t win = getWindow(); + win->setSize(newSize); /* TODO - y_size = zargs[1]; - _wp[win].x_size = zargs[2]; // Keep the cursor within the window if (wp[win].y_cursor > zargs[1] || wp[win].x_cursor > zargs[2]) @@ -69,12 +74,44 @@ void Window::setSize(const Point &newSize) { void Window::setPosition(const Point &newPos) { winid_t win = getWindow(); - /* TODO - if (win == cwin) - update_cursor(); - */ + win->setPosition(newPos); +} + +const uint16 &Window::operator[](WindowProperty propType) { + _tempVal = getProperty(propType); + return _tempVal; } +uint16 Window::getProperty(WindowProperty propType) { + winid_t win = getWindow(); + Point pt; + + switch (propType) { + case Y_POS: + return win->_bbox.top; + case X_POS: + return win->_bbox.left; + case Y_SIZE: + return win->_bbox.height(); + case X_SIZE: + return win->_bbox.width(); + case Y_CURSOR: + return win->getCursor().y; + case X_CURSOR: + return win->getCursor().x; + default: + error("Read of an unimplemented property"); + /* + LEFT_MARGIN = 6, RIGHT_MARGIN = 7, NEWLINE_INTERRUPT = 8, INTERRUPT_COUNTDOWN = 9, + TEXT_STYLE = 10, COLOUR_DATA = 11, FONT_NUMBER = 12, FONT_SIZE = 13, ATTRIBUTES = 14, + LINE_COUNT = 15, TRUE_FG_COLOR = 16, TRUE_BG_COLOR = 17 + */ + } +} + +void Window::setProperty(WindowProperty propType, uint16 value) { + // TODO +} } // End of namespace Frotz } // End of namespace Glk diff --git a/engines/glk/frotz/windows.h b/engines/glk/frotz/windows.h index c94a1edce3..ba277d57dc 100644 --- a/engines/glk/frotz/windows.h +++ b/engines/glk/frotz/windows.h @@ -31,6 +31,13 @@ namespace Frotz { #include "glk/windows.h" #include "glk/utils.h" +enum WindowProperty { + Y_POS = 0, X_POS = 1, Y_SIZE = 2, X_SIZE = 3, Y_CURSOR = 4, X_CURSOR = 5, + LEFT_MARGIN = 6, RIGHT_MARGIN = 7, NEWLINE_INTERRUPT = 8, INTERRUPT_COUNTDOWN = 9, + TEXT_STYLE = 10, COLOUR_DATA = 11, FONT_NUMBER = 12, FONT_SIZE = 13, ATTRIBUTES = 14, + LINE_COUNT = 15, TRUE_FG_COLOR = 16, TRUE_BG_COLOR = 17 +}; + class Windows; /** @@ -41,16 +48,27 @@ class Window { private: Windows *_windows; winid_t _win; + uint16 _tempVal; ///< used in calls to square brackets operator private: /** * Gets a reference to the window, creating a new one if one doesn't already exist */ winid_t getWindow(); + + /** + * Get a property value + */ + uint16 getProperty(WindowProperty propType); + + /** + * Set a property value + */ + void setProperty(WindowProperty propType, uint16 value); public: /** * Constructor */ - Window() : _win(nullptr) {} + Window(); /** * Assignment operator @@ -71,15 +89,9 @@ public: operator bool() const { return _win != nullptr; } /** - * Property access. There are the following properties defined by the spec: - * 0 y coordinate 6 left margin size 12 font number - * 1 x coordinate 7 right margin size 13 font size - * 2 y size 8 newline interrupt routine 14 attributes - * 3 x size 9 interrupt countdown 15 line count - * 4 y cursor 10 text style 16 true foreground colour - * 5 x cursor 11 colour data 17 true background colour + * Property accessor */ - //zword &operator[](uint idx); + const uint16 &operator[](WindowProperty propType); /** * Set the window size |