aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2018-10-21 12:28:46 -0700
committerPaul Gilbert2018-12-08 19:05:59 -0800
commit855fd39a9eb6676760d4e374bfc920000ff51f2e (patch)
tree6b513afe19443781ecf4cb9436fb816b2320f549
parentac9a122e3d140b2cb2e82c8d9dfeff2ee38fff36 (diff)
downloadscummvm-rg350-855fd39a9eb6676760d4e374bfc920000ff51f2e.tar.gz
scummvm-rg350-855fd39a9eb6676760d4e374bfc920000ff51f2e.tar.bz2
scummvm-rg350-855fd39a9eb6676760d4e374bfc920000ff51f2e.zip
GLK: Added WindowStream put methods
-rw-r--r--engines/gargoyle/gargoyle.cpp3
-rw-r--r--engines/gargoyle/gargoyle.h5
-rw-r--r--engines/gargoyle/streams.cpp54
-rw-r--r--engines/gargoyle/streams.h24
-rw-r--r--engines/gargoyle/windows.cpp121
-rw-r--r--engines/gargoyle/windows.h4
6 files changed, 190 insertions, 21 deletions
diff --git a/engines/gargoyle/gargoyle.cpp b/engines/gargoyle/gargoyle.cpp
index 2ca14bf897..8620e886e0 100644
--- a/engines/gargoyle/gargoyle.cpp
+++ b/engines/gargoyle/gargoyle.cpp
@@ -40,7 +40,8 @@ GargoyleEngine *g_vm;
GargoyleEngine::GargoyleEngine(OSystem *syst, const GargoyleGameDescription *gameDesc) :
_gameDescription(gameDesc), Engine(syst), _random("Gargoyle"), _conf(nullptr),
- _events(nullptr), _screen(nullptr), _windows(nullptr) {
+ _events(nullptr), _screen(nullptr), _windows(nullptr),
+ gli_unregister_obj(nullptr), gli_register_arr(nullptr), gli_unregister_arr(nullptr) {
g_vm = this;
}
diff --git a/engines/gargoyle/gargoyle.h b/engines/gargoyle/gargoyle.h
index 976221ab56..1d81cb92e7 100644
--- a/engines/gargoyle/gargoyle.h
+++ b/engines/gargoyle/gargoyle.h
@@ -30,6 +30,7 @@
#include "engines/advancedDetector.h"
#include "engines/engine.h"
#include "graphics/screen.h"
+#include "gargoyle/glk_types.h"
namespace Gargoyle {
@@ -95,6 +96,10 @@ public:
Events *_events;
Streams *_streams;
Windows *_windows;
+ void (*gli_unregister_obj)(void *obj, glui32 objclass, gidispatch_rock_t objrock);
+ gidispatch_rock_t (*gli_register_arr)(void *array, glui32 len, const char *typecode);
+ void (*gli_unregister_arr)(void *array, glui32 len, const char *typecode, gidispatch_rock_t objrock);
+
public:
GargoyleEngine(OSystem *syst, const GargoyleGameDescription *gameDesc);
virtual ~GargoyleEngine();
diff --git a/engines/gargoyle/streams.cpp b/engines/gargoyle/streams.cpp
index 7b6c1ab626..c2a2ff8b60 100644
--- a/engines/gargoyle/streams.cpp
+++ b/engines/gargoyle/streams.cpp
@@ -89,22 +89,60 @@ void WindowStream::putCharUni(uint32 ch) {
return;
++_writeCount;
- //TODO
+ if (_window->_lineRequest || _window->_lineRequestUni) {
+ if (g_conf->_safeClicks && g_vm->_events->_forceClick) {
+ _window->cancelLineEvent(nullptr);
+ g_vm->_events->_forceClick = false;
+ } else {
+ warning("putCharUni: window has pending line request");
+ }
+ }
+
+ _window->putCharUni(ch);
+ if (_window->_echoStream)
+ _window->_echoStream->putCharUni(ch);
}
-void WindowStream::putBuffer(const unsigned char *buf, size_t len) {
+void WindowStream::putBuffer(const char *buf, size_t len) {
if (!_writable)
return;
- ++_writeCount;
- //TODO
+ _writeCount += len;
+
+ if (_window->_lineRequest || _window->_lineRequestUni) {
+ if (g_conf->_safeClicks && g_vm->_events->_forceClick) {
+ _window->cancelLineEvent(nullptr);
+ g_vm->_events->_forceClick = false;
+ } else {
+ warning("putBuffer: window has pending line request");
+ }
+ }
+
+ for (size_t lx = 0; lx < len; lx++, buf++)
+ _window->putChar(*buf);
+ if (_window->_echoStream)
+ _window->_echoStream->putBuffer(buf, len);
}
void WindowStream::putBufferUni(const uint32 *buf, size_t len) {
if (!_writable)
return;
- ++_writeCount;
- //TODO
+ _writeCount += len;
+
+ if (_window->_lineRequest || _window->_lineRequestUni) {
+ if (g_conf->_safeClicks && g_vm->_events->_forceClick) {
+ _window->cancelLineEvent(nullptr);
+ g_vm->_events->_forceClick = false;
+ }
+ else {
+ warning("putBuffer: window has pending line request");
+ }
+ }
+
+ for (size_t lx = 0; lx < len; lx++, buf++)
+ _window->putCharUni(*buf);
+ if (_window->_echoStream)
+ _window->_echoStream->putBufferUni(buf, len);
}
/*--------------------------------------------------------------------------*/
@@ -132,7 +170,7 @@ void MemoryStream::putCharUni(uint32 ch) {
}
-void MemoryStream::putBuffer(const unsigned char *buf, size_t len) {
+void MemoryStream::putBuffer(const char *buf, size_t len) {
//TODO
}
@@ -156,7 +194,7 @@ void FileStream::putCharUni(uint32 ch) {
//TODO
}
-void FileStream::putBuffer(const unsigned char *buf, size_t len) {
+void FileStream::putBuffer(const char *buf, size_t len) {
//TODO
}
diff --git a/engines/gargoyle/streams.h b/engines/gargoyle/streams.h
index c43e2a089c..fd04a1e32e 100644
--- a/engines/gargoyle/streams.h
+++ b/engines/gargoyle/streams.h
@@ -93,12 +93,28 @@ public:
/**
* Write a buffer
*/
- virtual void putBuffer(const unsigned char *buf, size_t len) = 0;
+ virtual void putBuffer(const char *buf, size_t len) = 0;
/**
* Write a unicode character
*/
virtual void putBufferUni(const uint32 *buf, size_t len) = 0;
+
+ /**
+ * Send a line to the stream with a trailing newline
+ */
+ void echoLine(char *buf, glui32 len) {
+ putBuffer(buf, len);
+ putChar('\n');
+ };
+
+ /**
+ * Send a line to the stream with a trailing newline
+ */
+ void echoLineUni(glui32 *buf, glui32 len) {
+ putBufferUni(buf, len);
+ putCharUni('\n');
+ }
};
typedef Stream *strid_t;
@@ -133,7 +149,7 @@ public:
/**
* Write a buffer
*/
- virtual void putBuffer(const unsigned char *buf, size_t len) override;
+ virtual void putBuffer(const char *buf, size_t len) override;
/**
* Write a unicode character
@@ -170,7 +186,7 @@ public:
/**
* Write a buffer
*/
- virtual void putBuffer(const unsigned char *buf, size_t len) override;
+ virtual void putBuffer(const char *buf, size_t len) override;
/**
* Write a unicode character
@@ -202,7 +218,7 @@ public:
/**
* Write a buffer
*/
- virtual void putBuffer(const unsigned char *buf, size_t len) override;
+ virtual void putBuffer(const char *buf, size_t len) override;
/**
* Write a unicode character
diff --git a/engines/gargoyle/windows.cpp b/engines/gargoyle/windows.cpp
index bf671ab197..6070128743 100644
--- a/engines/gargoyle/windows.cpp
+++ b/engines/gargoyle/windows.cpp
@@ -297,7 +297,7 @@ TextGridWindow::TextGridWindow(Windows *windows, uint32 rock) : Window(windows,
_width = _height = 0;
_curX = _curY = 0;
_inBuf = nullptr;
- _inorgX = _inorgY = 0;
+ _inOrgX = _inOrgY = 0;
_inMax = 0;
_inCurs = _inLen = 0;
_inArrayRock.num = 0;
@@ -316,9 +316,9 @@ void TextGridWindow::rearrange(const Common::Rect &box) {
if (newwid == _width && newhgt == _height)
return;
- lines.resize(newhgt);
+ _lines.resize(newhgt);
for (int y = 0; y < newhgt; ++y) {
- lines[y].resize(newwid);
+ _lines[y].resize(newwid);
touch(y);
}
@@ -329,7 +329,7 @@ void TextGridWindow::rearrange(const Common::Rect &box) {
void TextGridWindow::touch(int line) {
int y = bbox.top + line * g_conf->_leading;
- lines[line].dirty = true;
+ _lines[line].dirty = true;
_windows->repaint(Common::Rect(bbox.left, y, bbox.right, y + g_conf->_leading));
}
@@ -339,6 +339,12 @@ glui32 TextGridWindow::getSplit(glui32 size, bool vertical) const {
}
void TextGridWindow::cancelLineEvent(Event *ev) {
+ int ix;
+ void *inbuf;
+ int inmax;
+ int unicode = _lineRequestUni;
+ gidispatch_rock_t inarrayrock;
+ TextGridRow *ln = &_lines[_inOrgY];
Event dummyEv;
if (!ev)
@@ -350,7 +356,51 @@ void TextGridWindow::cancelLineEvent(Event *ev) {
return;
- // TODO : textgrid_cancel_line
+ inbuf = _inBuf;
+ inmax = _inMax;
+ inarrayrock = _inArrayRock;
+
+ if (!unicode) {
+ for (ix = 0; ix<_inLen; ix++)
+ {
+ glui32 ch = ln->chars[_inOrgX + ix];
+ if (ch > 0xff)
+ ch = '?';
+ ((char *)inbuf)[ix] = (char)ch;
+ }
+ if (_echoStream)
+ _echoStream->echoLine((char *)_inBuf, _inLen);
+ } else {
+ for (ix = 0; ix<_inLen; ix++)
+ ((glui32 *)inbuf)[ix] = ln->chars[_inOrgX + ix];
+ if (_echoStream)
+ _echoStream->echoLineUni((glui32 *)inbuf, _inLen);
+ }
+
+ _curY = _inOrgY + 1;
+ _curX = 0;
+ _attr = _origAttr;
+
+ ev->_type = evtype_LineInput;
+ ev->_window = this;
+ ev->_val1 = _inLen;
+ ev->_val2 = 0;
+
+ _lineRequest = false;
+ _lineRequestUni = false;
+
+ if (_lineTerminators) {
+ free(_lineTerminators);
+ _lineTerminators = nullptr;
+ }
+
+ _inBuf = nullptr;
+ _inMax = 0;
+ _inOrgX = 0;
+ _inOrgY = 0;
+
+ if (g_vm->gli_unregister_arr)
+ (*g_vm->gli_unregister_arr)(inbuf, inmax, unicode ? "&+#!Iu" : "&+#!Cn", inarrayrock);
}
/*--------------------------------------------------------------------------*/
@@ -791,6 +841,12 @@ glui32 TextBufferWindow::getSplit(glui32 size, bool vertical) const {
}
void TextBufferWindow::cancelLineEvent(Event *ev) {
+ gidispatch_rock_t inarrayrock;
+ int ix;
+ int len;
+ void *inbuf;
+ int inmax;
+ int unicode = _lineRequestUni;
Event dummyEv;
if (!ev)
@@ -801,8 +857,61 @@ void TextBufferWindow::cancelLineEvent(Event *ev) {
if (!_lineRequest && !_lineRequestUni)
return;
+ if (!_inBuf)
+ return;
+
+ inbuf = _inBuf;
+ inmax = _inMax;
+ inarrayrock = _inArrayRock;
+
+ len = _numChars - _inFence;
+ if (_echoStream)
+ _echoStream->echoLineUni(_chars + _inFence, len);
+
+ if (len > inmax)
+ len = inmax;
+
+ if (!unicode)
+ {
+ for (ix = 0; ix<len; ix++)
+ {
+ glui32 ch = _chars[_inFence + ix];
+ if (ch > 0xff)
+ ch = '?';
+ ((char *)inbuf)[ix] = (char)ch;
+ }
+ }
+ else
+ {
+ for (ix = 0; ix<len; ix++)
+ ((glui32 *)inbuf)[ix] = _chars[_inFence + ix];
+ }
+
+ _attr = _origAttr;
+
+ ev->_type = evtype_LineInput;
+ ev->_window = this;
+ ev->_val1 = len;
+ ev->_val2 = 0;
+
+ _lineRequest = false;
+ _lineRequestUni = false;
+ if (_lineTerminators) {
+ free(_lineTerminators);
+ _lineTerminators = nullptr;
+ }
+ _inBuf = nullptr;
+ _inMax = 0;
+
+ if (_echoLineInput) {
+ putCharUni('\n');
+ } else {
+ _numChars = _inFence;
+ touch(0);
+ }
- // TODO : textbuffer_cancel_line
+ if (g_vm->gli_unregister_arr)
+ (*g_vm->gli_unregister_arr)(inbuf, inmax, unicode ? "&+#!Iu" : "&+#!Cn", inarrayrock);
}
/*--------------------------------------------------------------------------*/
diff --git a/engines/gargoyle/windows.h b/engines/gargoyle/windows.h
index b84ce27b08..0d635fd513 100644
--- a/engines/gargoyle/windows.h
+++ b/engines/gargoyle/windows.h
@@ -313,13 +313,13 @@ private:
void touch(int line);
public:
int _width, _height;
- TextGridRows lines;
+ 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 _inOrgX, _inOrgY;
int _inMax;
int _inCurs, _inLen;
Attributes _origAttr;