Found: Qt Glk / RemGlk app


#41

I used a newer Qt Creator 4.3.1, but only downloaded the Qt 5.6.2 library.

I had to strip out a bunch of things related to printing - as it seems Qt 5.6.2 to 5.9.1 the text-edit example app had been rewritten with newer printer API. Some of the text editing QCombBox stuff was also broken, 3 lines commented out. But once I got past that, it compiled and ran fine on Qt 5.6.2 on my Ubuntu 17.04 desktop. I was able to pick a Glulx story and run it. Here is the printing code deleted and QComboBox code commented out: github.com/WakeRealityDev/Thund … 24320be9c3

All the QJsonObject QJsonArray and QProcess stuff worked perfectly fine on Qt 5.6.2

You want to try this hacked out-branch? github.com/WakeRealityDev/Thund … hackedout0


#42

Thank you a lot for your time.
I have tried the branch with same result. I’m puzzled why QJson* libraries doesn’t work, as you said, the documentation says they’re supported since version 5.0. Might be a thing of the Ubuntu SDK?
I’m downloading Qt Creator 4.3.1 with libraries 5.6, 5.7 and 9.* let’s see if I can compile it or is my system.


#43

I have installed Qt Creator 4.3.1, with Qt 5.6.2 (on the system) and compiled with no problems. So, I can confirm that the error is with my configuration of Ubuntu SDK or with the Ubuntu SDK itself


#44

Cool. Is the *.gblorb filename search working on your system OK?


#45

Yes it is. I browse and then find. It lists all the .gblorb in the folder.


(jkj yuio) #46

just catching up with this. Had a go at building for Windows/mingw. Works with a few changes.

I have problems (in general) building remglk for windows, some functions need changes. i have added files local.h & local.c that fix this, unless there’s a secret windows build option or define i have missed.

here are my diffs:

Left base folder: V:\sw\Thunderquake_Qt
Right base folder: I:\sw\Thunderquake_Qt
--- remglk_desktop_src\glulxe\Makefile	2017-08-29 23:58:00.000000000 +0100
+++ remglk_desktop_src\glulxe\Makefile	2017-08-29 23:56:15.000000000 +0100
@@ -28,13 +28,14 @@
 #GLKMAKEFILE = ../Make.gtkglk
 
 # Pick a C compiler.
 CC = cc
 #CC = gcc
 
-OPTIONS = -g -Wall -Wmissing-prototypes -Wstrict-prototypes -Wno-unused -DOS_UNIX
+# want this change conditional !!
+OPTIONS = -g -Wall -Wmissing-prototypes -Wstrict-prototypes -Wno-unused #-DOS_UNIX
 
 # Locate the libxml2 library. You only need these lines if you are using
 # the VM_DEBUGGER option. If so, uncomment these and set appropriately.
 #XMLLIB = -L/usr/local/lib -lxml2
 #XMLLIBINCLUDEDIR = -I/usr/local/include/libxml2
 
--- 
+++ remglk_desktop_src\remglk\local.c	2017-08-29 23:08:53.000000000 +0100
@@ -0,0 +1,23 @@
+#include "local.h"
+
+#include <time.h>
+
+#ifdef _WIN32
+
+/* should be this, but bug in mingw it is missing from lib */
+time_t _mkgmtime(struct tm * a_tm)
+{
+    time_t ltime = mktime(a_tm);
+    struct tm tm_val;
+    gmtime_s(&tm_val, &ltime);
+    int offset = (tm_val.tm_hour - a_tm->tm_hour);
+    if (offset > 12)
+    {
+        offset = 24 - offset;
+    }
+    time_t utc = mktime(a_tm) - offset * 3600;
+    return utc;
+}
+
+#endif
+
--- 
+++ remglk_desktop_src\remglk\local.h	2017-08-29 23:08:38.000000000 +0100
@@ -0,0 +1,13 @@
+#pragma once
+
+#define bzero(_a, _b) memset(_a, 0, _b)
+
+#ifdef _WIN32
+
+/* should be this, but bug in mingw it is missing from lib */
+#define timegm _mkgmtime
+
+#define srandom srand
+#define random rand
+
+#endif
--- remglk_desktop_src\remglk\Makefile	2017-08-29 22:44:25.000000000 +0100
+++ remglk_desktop_src\remglk\Makefile	2017-08-29 23:57:20.000000000 +0100
@@ -8,28 +8,29 @@
 # and glk.h, glkstart.h, and Make.remglk in the include directory.
 
 # Pick a C compiler.
 #CC = cc
 CC = gcc -ansi
 
-OPTIONS = -g -Wall
+## want this option conditional on mingw
+OPTIONS = -g -Wall -D_POSIX_C_SOURCE
 
 CFLAGS = $(OPTIONS) $(INCLUDEDIRS)
 
 GLKLIB = libremglk.a
 
 REMGLK_OBJS = \
   main.o rgevent.o rgfref.o rggestal.o \
   rgdata.o rgmisc.o rgstream.o rgstyle.o \
   rgwin_blank.o rgwin_buf.o rgwin_grid.o rgwin_pair.o rgwin_graph.o \
   rgwindow.o rgschan.o rgblorb.o \
-  cgunicod.o cgdate.o gi_dispa.o gi_debug.o gi_blorb.o
+  cgunicod.o cgdate.o gi_dispa.o gi_debug.o gi_blorb.o local.o
 
 REMGLK_HEADERS = \
   remglk.h rgdata.h rgwin_blank.h rgwin_buf.h \
-  rgwin_grid.h rgwin_graph.h rgwin_pair.h gi_debug.h gi_dispa.h
+  rgwin_grid.h rgwin_graph.h rgwin_pair.h gi_debug.h gi_dispa.h local.h
 
 all: $(GLKLIB) Make.remglk
 
 cgunicod.o: cgunigen.c
 
 $(GLKLIB): $(REMGLK_OBJS)
--- remglk_desktop_src\remglk\remglk.h	2017-08-29 22:44:25.000000000 +0100
+++ remglk_desktop_src\remglk\remglk.h	2017-08-29 23:01:55.000000000 +0100
@@ -297,7 +297,9 @@
     )
 
 #ifdef NO_MEMMOVE
     extern void *memmove(void *dest, void *src, int n);
 #endif /* NO_MEMMOVE */
 
+#include "local.h"
+
 #endif /* REMGLK_H */
--- remglkprocess.cpp	2017-08-29 22:38:41.000000000 +0100
+++ remglkprocess.cpp	2017-08-29 23:49:06.000000000 +0100
@@ -108,13 +108,17 @@
 }
 
 void RemGlkProcess::setRemGlkEngine(int engineCode)
 {
     switch (enginePickA) {
     case 0:
+#ifdef Q_OS_WIN
+        appRemGlkBinaryPath = "./remglk_glulxe.exe";
+#else
         appRemGlkBinaryPath = "./remglk_glulxe";
+#endif        
         break;
     case 1:
         // if inside this APK use:
         appRemGlkBinaryPath = "../lib/lib_app_git.so";
         // if inside the Thunderfall APK, use this (or modify to be -2 APK variation)
         // NOTE: this needs to distinguish x86 vs arm CPU, currently does not
--- Thunderquake_Qt_GitHub.pro	2017-08-29 22:38:41.000000000 +0100
+++ Thunderquake_Qt_GitHub.pro	2017-08-29 23:25:14.000000000 +0100
@@ -14,12 +14,16 @@
 }
 equals(QT_ARCH,"x86_64") {
     DEFINES += HOST_ANDROID_X86
     CONFIG += android_x86
 }
 
+CONFIG(debug, debug|release) {
+    CONFIG += console
+}
+
 DEFINES += APPDEV_TEST_SETA=yes
 
 # developers working on the JSON Glk formatting can comment this out to get a full idea of the available output formatting options.
 DEFINES += HIDE_TEXT_EDIT_TOOLBARS=yes
 
 HEADERS         = \

#47

On the topic of building RemGlk - and terps in general: there is an entirely new build system to try :slight_smile: I’m in the process of updating this Qt examples (Thunderquake) and my Android Studio examples with it, but you can go directly to the source, Chris did all the work.

Basically the new build system takes all the terps from the long-standing Gargoyle project and splits them out into their own GitHub project - with a freshly written set of CMake makefiles. It also has a CMake makefile for each of the major Glk libraries - including RemGlk. Chris did a great job on this, and it’s far better than all the stuff I’ve worked with for the past 12 months. This works very well with cross-compiling (Raspberry Pi, OpenWrt, Android, etc) and eliminates a lot of confusion with 6 year old Makefiles that reference obsolete tips about gcc 2.95, etc.

Here it is: github.com/cspiegel/terps - the project README has the steps you need to do - you will need to populate the RemGlk directory with the RemGlk source files - but all the other source files are there in the terps project.

I do have a Windows 10 system handy, so if you get stuck with this, I will try to help you. Comment back and tell us how it goes.


#48

I’m starting to learn conditional cases in the building… So, you coud adapt the code if the os is windows for example.


#49

I’m glad two people tried it out so quickly. I was looking over the code on GitHub this morning and I know the code is pretty messy with comments and unused functions, but I’m fine with that because I’ve already seen a couple people get it up and running by just changing a few lines of code to adapt to Windows, etc.

I encourage you to comment the DEFINES += HIDE_TEXT_EDIT_TOOLBARS=yes and look at how this was assembled.

  1. The Qt 5.9.1 Example Project “Text Edit” was opened.
  2. A QProcess class is created to run the RemGlk process and exchange JSON.
  3. A class was created to unwrap the JSON and put text into the QTextEdit body. A robot typing into the text editor.
  4. I did add a file searcher thread that kicks off on app start to locate game data files. But mostly I did that to get a sense of programming background threads in Qt.

I encourage you to play around with the QTextEdit example app, in it’s original state. Do what it says “If you are viewing this document in the textedit example, you can edit this document to explore Qt’s rich text editing features. We have included some comments in each of the following sections to encourage you to experiment.” That’s your modern terminal, isn’t it? Right there you can bold, italic, font change, indent, bullet list. I mean for mostly-text Interactive Fiction, this has got it all. And the code is simple, reasonably cross-platform, and it’s quirks are well know as there are hundreds of active projects out there built around this.

RemGlk’s JSON can be hand-read for the most-part. You can see the story text and get a sense of the story right with raw RemGlk. You can see the structure changes. The Qt QJsonArray and QJsonObject classes are easy to work with and are similar to libraries in Java and other languages. Now you are dealing with the story itself. Throw this code away if you want, start from scratch.

I encourage you to look at the Qt 5.9.1 example “WebEngine Markdown Editor Example”, it has two window elements side-by side with source on the left and formatted HTML output on the right. Think JSON on the left, output on the right. Wire in a QProcess, start looping the QJsonObject and QJsonArray elements - you have another basic structure to work with. Is it fun enough we can get a decent app together? GlkOte could be brought into that “WebEngine Markdown Editor Example” app if you wanted - as it already knows how to talk to RemGlk and the dozen interpreters that RemGlk can link to: github.com/cspiegel/terps . Who is going to code that?


#50

Anyone adding code? I hooked up the Qt WebView from MarkdownEdtior example to RemGlk backend and it seems to work fine. Will try to get an app together.

EDIT: Good News! I got GlkOte running with RemGlk in the Qt code. I’ll put up on GitHub soon.


#51

New Branch is published on GitHub: github.com/WakeRealityDev/Thund … e_WebView0

It can now run GlkOte in a WebView - wired up to the RemGlk interpreter of your choice! This is 100% self-contained, meaning it can run entirely offline with no Internet connection.

A couple issues to note: The gblorb assets are not extracted currently, so images and sound files won’t show up… as RemGlk expects them to be independently extracted. I also suggest you do a GitHub checkout into a fresh folder for this branch - as I renamed the .pro file for Qt Creator so that it’s clear which one you are looking at. I have not yet put in the Windows 10 compile fixes that were posted earlier in this thread - so you will have to re-patch that problem.

Please let me know if you get a chance to try this out. Thank you.


#52

Very interesting.
I took your idea and did a similar project (I know) so now I more or less understand what is happening:
A QProcess that starts a remglk instance (I use a level9 interpreter) but I use qml so I can run it on my phone.
Connecting the stdout to a signal, I make the qml get the json info (raw for now) to show it in the main qml. Is working pretty good. No images though :frowning: but I guess I’m doing some stupid mistake here.

So, I guess we are in the same road: now I need to implement the json read and write


#53

Great to hear. I think pure qml wrapping around the QProcess is how most people would want to work on the code. My lack of skill and experience was holding me back from that. Keep it up.


#54

Main menu

Ugly early text interaction


#55

I’m surprised that I could make it, actually. It’s my hundred thousandth time I tried to port the code and this is pretty near to get something usable.

If you want to see how it’s made (it’s pretty straight forward) just tell me, even I don’t think you can use the code as is, you can see how it’s made and I’m pretty confident is pretty adaptable


#56

Sure, share what you can, any condition. As I said, what I shared was pretty messy, but hopefully inspirational :wink: I think there is good long-term fruit in a Qt on RemGlk chain.


#57

For now the code is embarrassingly horrible, so, let me try to get at least a minimum decent thing to show (even if it doesn’t work properly) and I’ll share it so you can take a look :slight_smile:


#58

I’m nearly able to show some code, a couple of things I want to check and some explanation that will be needed.
In the meanwhile:

  • Is there a way to say to remglk to do the savegames as text?
  • I’m using the Level9glk and even if I use .sna games (that should include line art) is not accessible. My init is
{ "type": "init", "gen": 0, "metrics": { "width":60, "height":24 },  "support": [ "graphics", "graphicswin" ] }

so in theory should find the graphics automatically… but it doesn’t.

Any idea?


(Andrew Plotkin) #59

No. I’m not sure what that would mean. It’s the VM interpreter which opens the save file and writes out the contents.


#60

My idea was to show some nice info about each save file. The route to the game, a screenshot, etc.
I read in the docs that you could use TextMode but now that I read it again, I see I understood it wrong. So is fileusage_TextMode for data that used be used as a text?