aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2018-10-18 21:15:43 -0700
committerPaul Gilbert2018-12-08 19:05:59 -0800
commit47a7a1d4e2640b3b34e2091be606b26723990efb (patch)
treeb2756a6f1f5d8f8724fd9dfaf099f4434f321b70
parent77f357e72f1f1bfad93b3b1c54f6f57b67131ba7 (diff)
downloadscummvm-rg350-47a7a1d4e2640b3b34e2091be606b26723990efb.tar.gz
scummvm-rg350-47a7a1d4e2640b3b34e2091be606b26723990efb.tar.bz2
scummvm-rg350-47a7a1d4e2640b3b34e2091be606b26723990efb.zip
GLK: Added setup of text grid windows
-rw-r--r--engines/gargoyle/windows.cpp139
-rw-r--r--engines/gargoyle/windows.h107
2 files changed, 212 insertions, 34 deletions
diff --git a/engines/gargoyle/windows.cpp b/engines/gargoyle/windows.cpp
index ad03ab860a..25af90b277 100644
--- a/engines/gargoyle/windows.cpp
+++ b/engines/gargoyle/windows.cpp
@@ -28,8 +28,47 @@ namespace Gargoyle {
#define MAGIC_WINDOW_NUM (9876)
+bool Windows::_confLockCols;
+bool Windows::_confLockRows;
+int Windows::_wMarginx;
+int Windows::_wMarginy;
+int Windows::_wPaddingx;
+int Windows::_wPaddingy;
+int Windows::_wBorderx;
+int Windows::_wBordery;
+int Windows::_tMarginx;
+int Windows::_tMarginy;
+int Windows::_wMarginXsave;
+int Windows::_wMarginYsave;
+int Windows::_cols;
+int Windows::_rows;
+int Windows::_imageW;
+int Windows::_imageH;
+int Windows::_cellW;
+int Windows::_cellH;
+int Windows::_baseLine;
+int Windows::_leading;
+
Windows::Windows(Graphics::Screen *screen) : _screen(screen), _forceRedraw(true), _moreFocus(false),
_windowList(nullptr), _rootWin(nullptr), _focusWin(nullptr) {
+ _confLockCols = false;
+ _confLockRows = false;
+ _wMarginx = 15;
+ _wMarginy = 15;
+ _wPaddingx = 0;
+ _wPaddingy = 0;
+ _wBorderx = 1;
+ _wBordery = 1;
+ _tMarginx = 7;
+ _tMarginy = 7;
+ _wMarginXsave = 15;
+ _wMarginYsave = 15;
+ _cols = 60;
+ _rows = 25;
+ _imageW = _imageH = 0;
+ _cellW = _cellH = 0;
+ _baseLine = 15;
+ _leading = 20;
}
Window *Windows::windowOpen(Window *splitwin, glui32 method, glui32 size,
@@ -154,35 +193,32 @@ PairWindow *Windows::newPairWindow(glui32 method, Window *key, glui32 size) {
}
void Windows::rearrange() {
- // TODO
- /*
if (_rootWin) {
- rect_t box;
+ Common::Rect box;
- if (gli_conf_lockcols) {
- int desired_width = gli_wmarginx_save * 2 + gli_cellw * gli_cols;
- if (desired_width > gli_image_w)
- gli_wmarginx = gli_wmarginx_save;
+ if (_confLockCols) {
+ int desired_width = _wMarginXsave * 2 + _cellW * _cols;
+ if (desired_width > _imageW)
+ _wMarginx = _wMarginXsave;
else
- gli_wmarginx = (gli_image_w - gli_cellw * gli_cols) / 2;
+ _wMarginx = (_imageW - _cellW * _cols) / 2;
}
- if (gli_conf_lockrows)
- {
- int desired_height = gli_wmarginy_save * 2 + gli_cellh * gli_rows;
- if (desired_height > gli_image_h)
- gli_wmarginy = gli_wmarginy_save;
+ if (_confLockRows) {
+ int desired_height = _wMarginYsave * 2 + _cellH * _rows;
+ if (desired_height > _imageH)
+ _wMarginy = _wMarginYsave;
else
- gli_wmarginy = (gli_image_h - gli_cellh * gli_rows) / 2;
+ _wMarginy = (_imageH - _cellH * _rows) / 2;
}
- box.x0 = gli_wmarginx;
- box.y0 = gli_wmarginy;
- box.x1 = gli_image_w - gli_wmarginx;
- box.y1 = gli_image_h - gli_wmarginy;
- gli_window_rearrange(_rootWin, &box);
+ box.left = _wMarginx;
+ box.top = _wMarginy;
+ box.right = _imageW - _wMarginx;
+ box.bottom = _imageH - _wMarginy;
+
+ _rootWin->rearrange(box);
}
- */
}
/*--------------------------------------------------------------------------*/
@@ -215,6 +251,50 @@ BlankWindow::BlankWindow(uint32 rock) : Window(rock) {
TextGridWindow::TextGridWindow(uint32 rock) : Window(rock) {
_type = wintype_TextGrid;
+ width = height = 0;
+ curx = cury = 0;
+ inbuf = nullptr;
+ inorgx = inorgy = 0;
+ inmax = 0;
+ incurs = inlen = 0;
+ inarrayrock.num = 0;
+ line_terminators = nullptr;
+}
+
+void TextGridWindow::rearrange(const Common::Rect &box) {
+ Window::rearrange(box);
+ int newwid, newhgt;
+
+ newwid = box.width() / Windows::_cellW;
+ newhgt = box.height() / Windows::_cellH;
+
+ if (newwid == width && newhgt == height)
+ return;
+
+ lines.resize(newhgt);
+ for (int y = 0; y < newhgt; ++y) {
+ lines[y].resize(newwid);
+ touch(y);
+ }
+
+ attr.clear();
+ width = newwid;
+ height = newhgt;
+}
+
+void TextGridWindow::touch(int line) {
+// int y = bbox.top + line * Windows::_leading;
+ lines[line].dirty = true;
+ // TODO
+// winrepaint(bbox.left, y, bbox.right, y + Windows::_leading);
+}
+
+void TextGridWindow::TextGridRow::resize(size_t newSize) {
+ chars.clear();
+ attr.clear();
+ chars.resize(newSize);
+ attr.resize(newSize);
+ Common::fill(&chars[0], &chars[0] + newSize, ' ');
}
/*--------------------------------------------------------------------------*/
@@ -241,4 +321,23 @@ PairWindow::PairWindow(glui32 method, Window *_key, glui32 _size) : Window(0),
_type = wintype_Pair;
}
+/*--------------------------------------------------------------------------*/
+
+WindowStyle::WindowStyle() : font(0), reverse(0) {
+ Common::fill(&bg[0], &bg[3], 0);
+ Common::fill(&fg[0], &fg[3], 0);
+}
+
+/*--------------------------------------------------------------------------*/
+
+void Attributes::clear() {
+ fgset = 0;
+ bgset = 0;
+ fgcolor = 0;
+ bgcolor = 0;
+ reverse = false;
+ hyper = 0;
+ style = 0;
+}
+
} // End of namespace Gargoyle
diff --git a/engines/gargoyle/windows.h b/engines/gargoyle/windows.h
index 91cbc91a53..45907a86e3 100644
--- a/engines/gargoyle/windows.h
+++ b/engines/gargoyle/windows.h
@@ -23,6 +23,7 @@
#ifndef GARGOYLE_WINDOWS_H
#define GARGOYLE_WINDOWS_H
+#include "common/array.h"
#include "common/list.h"
#include "common/rect.h"
#include "common/stream.h"
@@ -58,6 +59,24 @@ private:
*/
void rearrange();
public:
+ static bool _confLockCols, _confLockRows;
+ static int _wMarginx;
+ static int _wMarginy;
+ static int _wPaddingx;
+ static int _wPaddingy;
+ static int _wBorderx;
+ static int _wBordery;
+ static int _tMarginx;
+ static int _tMarginy;
+ static int _wMarginXsave;
+ static int _wMarginYsave;
+ static int _cols;
+ static int _rows;
+ static int _imageW, _imageH;
+ static int _cellW, _cellH;
+ static int _baseLine;
+ static int _leading;
+public:
/**
* Constructor
*/
@@ -76,9 +95,21 @@ public:
};
/**
+ * Window styles
+ */
+struct WindowStyle {
+ int font;
+ byte bg[3];
+ byte fg[3];
+ int reverse;
+
+ WindowStyle();
+};
+
+/**
* Window attributes
*/
-struct attr_t {
+struct Attributes {
unsigned fgset : 1;
unsigned bgset : 1;
unsigned reverse : 1;
@@ -87,20 +118,18 @@ struct attr_t {
unsigned fgcolor : 24;
unsigned bgcolor : 24;
unsigned hyper : 32;
-};
-struct WindowPair {
- Window *owner;
- Window *child1, *child2;
+ /**
+ * Constructor
+ */
+ Attributes() {
+ clear();
+ }
- // split info...
- glui32 dir; ///< winmethod_Left, Right, Above, or Below
- int vertical, backward; ///< flags
- glui32 division; ///< winmethod_Fixed or winmethod_Proportional
- Window *key; ///< NULL or a leaf-descendant (not a Pair)
- int keydamage; ///< used as scratch space in window closing
- glui32 size; ///< size value
- glui32 wborder; ///< winMethod_Border, NoBorder
+ /**
+ * Clear
+ */
+ void clear();
};
/**
@@ -133,7 +162,7 @@ public:
glui32 *line_terminators;
glui32 termct;
- attr_t attr;
+ Attributes attr;
byte bgcolor[3];
byte fgcolor[3];
@@ -149,6 +178,11 @@ public:
* Destructor
*/
virtual ~Window() {}
+
+ /**
+ * Rearranges the window
+ */
+ virtual void rearrange(const Common::Rect &box) { bbox = box; }
};
typedef Window *winid_t;
@@ -167,11 +201,56 @@ public:
* Text Grid window
*/
class TextGridWindow : public Window {
+ /**
+ * Structure for a row within the grid window
+ */
+ struct TextGridRow {
+ Common::Array<uint32> chars;
+ Common::Array<Attributes> attr;
+ bool dirty;
+
+ /**
+ * Constructor
+ */
+ TextGridRow() : dirty(false) {}
+
+ /**
+ * Resize the row
+ */
+ void resize(size_t newSize);
+ };
+ typedef Common::Array<TextGridRow> TextGridRows;
+private:
+ /**
+ * Mark a given text row as modified
+ */
+ void touch(int line);
+public:
+ int width, height;
+ TextGridRows lines;
+
+ int curx, cury; ///< the window cursor position
+
+ ///< for line input
+ void *inbuf; ///< unsigned char* for latin1, glui32* for unicode
+ int inorgx, inorgy;
+ int inmax;
+ int incurs, inlen;
+ Attributes origattr;
+ gidispatch_rock_t inarrayrock;
+ glui32 *line_terminators;
+
+ WindowStyle styles[style_NUMSTYLES]; ///< style hints and settings
public:
/**
* Constructor
*/
TextGridWindow(uint32 rock);
+
+ /**
+ * Rearranges the window
+ */
+ virtual void rearrange(const Common::Rect &box);
};
/**