aboutsummaryrefslogtreecommitdiff
path: root/engines/glk/archetype
diff options
context:
space:
mode:
authorPaul Gilbert2019-11-02 16:49:00 -0700
committerPaul Gilbert2019-11-11 18:20:29 -0800
commit3165d52a7b586a7b1442ba8ae7e3167d852d220f (patch)
tree49e0474c95440f411f20930719e1d126095cf882 /engines/glk/archetype
parente1911f9aff91a2264b6d05c3fda8505bed07739a (diff)
downloadscummvm-rg350-3165d52a7b586a7b1442ba8ae7e3167d852d220f.tar.gz
scummvm-rg350-3165d52a7b586a7b1442ba8ae7e3167d852d220f.tar.bz2
scummvm-rg350-3165d52a7b586a7b1442ba8ae7e3167d852d220f.zip
GLK: ARCHETYPE: Adding GLK hookups
Diffstat (limited to 'engines/glk/archetype')
-rw-r--r--engines/glk/archetype/archetype.cpp44
-rw-r--r--engines/glk/archetype/archetype.h5
2 files changed, 42 insertions, 7 deletions
diff --git a/engines/glk/archetype/archetype.cpp b/engines/glk/archetype/archetype.cpp
index 5ab3744d4a..416cf6cc25 100644
--- a/engines/glk/archetype/archetype.cpp
+++ b/engines/glk/archetype/archetype.cpp
@@ -34,6 +34,8 @@
namespace Glk {
namespace Archetype {
+#define MAX_INPUT_LINE 100
+
Archetype *g_vm;
Archetype::Archetype(OSystem *syst, const GlkGameDescription &gameDesc) : GlkAPI(syst, gameDesc),
@@ -75,10 +77,15 @@ bool Archetype::initialize() {
new_xarray(Object_List);
NullStr = NewConstStr("null");
+ // GLK window
+ _mainWindow = glk_window_open(0, 0, 0, wintype_TextBuffer);
+ glk_set_window(_mainWindow);
+
return true;
}
void Archetype::deinitialize() {
+ glk_window_close(_mainWindow);
}
Common::Error Archetype::readSaveData(Common::SeekableReadStream *rs) {
@@ -110,16 +117,43 @@ void Archetype::interpret() {
cleanup(result);
}
-void Archetype::write(const String &fmt, ...) {
- // TODO
+void Archetype::write(const String fmt, ...) {
+ va_list ap;
+ va_start(ap, fmt);
+ Common::String s = Common::String::format(fmt.c_str(), ap);
+ va_end(ap);
+
+ glk_put_buffer(s.c_str(), s.size());
}
-void Archetype::writeln(const String &fmt, ...) {
- // TODO
+void Archetype::writeln(const String fmt, ...) {
+ va_list ap;
+ va_start(ap, fmt);
+ Common::String s = Common::String::format(fmt.c_str(), ap);
+ va_end(ap);
+
+ s += '\n';
+ glk_put_buffer(s.c_str(), s.size());
}
void Archetype::readln(String &s) {
- // TODO
+ event_t ev;
+ char buffer[MAX_INPUT_LINE + 1];
+
+ glk_request_line_event(_mainWindow, buffer, MAX_INPUT_LINE, 0);
+
+ do {
+ glk_select(&ev);
+ if (ev.type == evtype_Quit) {
+ glk_cancel_line_event(_mainWindow, &ev);
+ return;
+ } else if (ev.type == evtype_LineInput)
+ break;
+ } while (ev.type != evtype_Quit);
+
+ buffer[ev.val1] = 0;
+
+ s = String(buffer);
}
char Archetype::ReadKey() {
diff --git a/engines/glk/archetype/archetype.h b/engines/glk/archetype/archetype.h
index f671df3193..85e3a4e8b3 100644
--- a/engines/glk/archetype/archetype.h
+++ b/engines/glk/archetype/archetype.h
@@ -40,6 +40,7 @@ class Archetype : public GlkAPI {
private:
int _saveSlot;
bool Translating;
+ winid_t _mainWindow;
public:
// keywords.cpp
XArrayType Literals, Vocabulary;
@@ -157,12 +158,12 @@ public:
/**
* Write some text to the screen
*/
- void write(const String &fmt, ...);
+ void write(const String fmt, ...);
/**
* Write a line to the screen
*/
- void writeln(const String &fmt, ...);
+ void writeln(const String fmt, ...);
void writeln() { writeln(""); }
void readln(String &s);