-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
45274f0
commit cf2ebd0
Showing
77 changed files
with
6,891 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
QT += widgets | ||
qtHaveModule(printsupport): QT += printsupport | ||
|
||
TEMPLATE = app | ||
TARGET = Thunderquake_Qt | ||
|
||
equals(QT_ARCH,"arm") { | ||
DEFINES += HOST_ANDROID_ARM | ||
CONFIG += android_arm | ||
} | ||
equals(QT_ARCH,"x86") { | ||
DEFINES += HOST_ANDROID_X86 | ||
CONFIG += android_x86 | ||
} | ||
equals(QT_ARCH,"x86_64") { | ||
DEFINES += HOST_ANDROID_X86 | ||
CONFIG += android_x86 | ||
} | ||
|
||
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 = \ | ||
remglkprocess.h \ | ||
completerwindow.h \ | ||
remglkcompletertextedit.h \ | ||
remglkoutputlayout.h \ | ||
remglktexteditwindow.h \ | ||
storyrunparameters.h \ | ||
findfileswindow.h \ | ||
findfilessearch.h \ | ||
findfilesthread.h \ | ||
glkwindowdata.h \ | ||
outputstyledchunk.h \ | ||
findstorieswindow.h | ||
SOURCES = \ | ||
remglkprocess.cpp \ | ||
main.cpp \ | ||
completerwindow.cpp \ | ||
remglkcompletertextedit.cpp \ | ||
remglktexteditwindow.cpp \ | ||
remglkoutputlayout.cpp \ | ||
storyrunparameters.cpp \ | ||
findfileswindow.cpp \ | ||
findfilessearch.cpp \ | ||
findfilesthread.cpp \ | ||
glkwindowdata.cpp \ | ||
outputstyledchunk.cpp \ | ||
findstorieswindow.cpp | ||
|
||
RESOURCES += \ | ||
remglktextedit.qrc | ||
|
||
# Example customcompleter | ||
HEADERS += | ||
SOURCES += | ||
|
||
build_all:!build_pass { | ||
CONFIG -= build_all | ||
CONFIG += release | ||
} | ||
|
||
# | ||
# As mentioned in one of the README files, this is incomplete (non-working) logic to try and | ||
# bundle the correct RemGlk executable for arm or x86 CPU into the bundle. | ||
# Right now, it is set for the Android Studio x86 emulator | ||
# | ||
|
||
android-g++ { | ||
message("::: section 0 android-g++") | ||
#ANDROID_EXTRA_LIBS += /data/app/com.wakereality.thunderfall-1/lib/x86/lib_app_git.so | ||
} | ||
|
||
# standard Qt way to act on Android builds | ||
android { | ||
message("::: section 1 android") | ||
message("QT_ARCH: $$QT_ARCH") | ||
message("QMAKE_HOST.arch: $$QMAKE_HOST.arch") | ||
message (HOST:$$QMAKE_HOST) | ||
message (HOST:$$QMAKE_HOST.arch) | ||
message (TARGET:$$QMAKE_TARGET) | ||
message (TARGET:$$QMAKE_TARGET.arch) | ||
|
||
#ANDROID_EXTRA_LIBS += /data/app/com.wakereality.thunderfall-1/lib/x86/lib_app_git.so | ||
} | ||
|
||
android_x86 { | ||
message("::: section 2 android_x86 CPU x86") | ||
# to get compiled Linux console binary into the APK generated by QT Creator | ||
#ANDROID_EXTRA_LIBS += /data/app/com.wakereality.thunderfall-1/lib/x86/lib_app_git.so | ||
} | ||
|
||
android_arm { | ||
message("::: section 3 android_arm CPU arm") | ||
ANDROID_EXTRA_LIBS += /data/app/com.wakereality.thunderfall-1/lib/armeabi-v7a/lib_app_git.so | ||
} | ||
|
||
|
||
# | ||
# Try to copy interpreter binary executable to build output path for Desktop system builds | ||
# ToDo: skip this step for Android builds | ||
# | ||
# using shell_path() to correct path depending on platform | ||
# escaping quotes and backslashes for file paths | ||
copydata.commands = $(COPY_FILE) \"$$shell_path($$PWD\\remglk_desktop_src\\glulxe\\remglk_glulxe)\" \"$$shell_path($$OUT_PWD)\" | ||
first.depends = $(first) copydata | ||
export(first.depends) | ||
export(copydata.commands) | ||
QMAKE_EXTRA_TARGETS += first copydata | ||
|
||
|
||
# install | ||
target.path = /tmp/Qt_Thunderquake_WR0 | ||
INSTALLS += target | ||
|
||
# | ||
# NOTE on RAMdisk use | ||
# "the build directory must be at the same folder level as the project (i.e. it can't be above or below). The reason why is that the linker is called from the build directory. Hence, any relative paths to library files will be different than what you entered in your project file." | ||
# A symbolic link could perhaps work? | ||
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Keystrokes | ||
=============== | ||
Ctrl-T send current ComboBox text | ||
Ctrl-H activates autocomplete, works on 2 letters, test with "rr". | ||
|
||
These can be used to stress-test the RemGlk to User Interface input/output cycle. | ||
|
||
|
||
Menu Mods | ||
============= | ||
Open will allow picking of Glulx story. The "save" dialog will determine cancel. | ||
|
||
New will close story. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
RemGlk far far away | ||
======================= | ||
The design of this app is that the RemGlk interactive fiction interperter ("engine") runs as another operating system process and stdin/stdout JSON is exchanged. This app is a JSON consumer and JSON emitter. | ||
|
||
This is a very flexible design, as the classic IF engine is decoupled from the toolchain and can be remote or local - and there is absolutely no linking of any kind regarding software license conflicts or copyright concerns. | ||
|
||
This also opens up the possibility of "plugin apps" that use intermediate pipes that intercept the JSON before it reaches this app. For example, a profanity filter or language translation app could be developed that consumes RemGlk's JSON and re-emits it - allowing chains of apps to act upon the data stream before it gets here to the presentation layer app. | ||
|
||
NOTE: This project assumes you compile and link the interpreters + RemGlk in outside projects. This app is a client to the RemGlk API. | ||
|
||
|
||
The base code of this app | ||
=========================== | ||
This app started from the Qt 5.9.1 example app for text-editor. It is a rich-text and subset of HTML QTextEdit. | ||
|
||
The assumption was that a rich text editor already knew how to do all the text formatting that Glk needs: change text colors, alignment of paragraphs, bold, undederline, font size changes, etc. | ||
|
||
This has proven, so far, to be a decent enough assumption. During development, it can be useful to re-enable all the toobar icons for the original text edit, do not define HIDE_TEXT_EDIT_TOOLBARS in .pro file. | ||
|
||
|
||
Incomplete | ||
============== | ||
Some things were barely started, such as StoryRunParameters class. This was intended to define a session of data file + engine (Glulx vs. Z-machine) selection. Class was created but not wired up. | ||
|
||
The RemGlkProcess class needs more work to pick multiple engine backends (like Gargoyle or Thunderword). Right now it's pretty much one-engine app level of completeness in it's logic of which remglk binary to launch. | ||
|
||
FindFilesWindow class and FindStoriesWindow class are variations. One is classical file searching taking from the Qt 5.9.1 example apps. A dedicated thread class was added to allow completely hidden background file finding. FindFilewsWindow class could be removed if desired, it's mostly kept in the source tree for reference. The FindStoriesWindow class is reworked to emit an HTML list instead of a QTable as the HTML output works much better on 5" mobile phones with large sets of file. Intelligent grouping is done to cut the folder path name out of individual story file links. Right now the story data file searching logic is Glulx only. It works pretty well on a Linux desktop system and Android device, but it needs to be fleshed out a lot more to support more than Glulx and to cache/save results so it isn't as frequently doing a full scan of the folders. | ||
|
||
The app lacks any code to save or remember user settings. Size of the window, last story played, enabling or disabling rewriting of the Glk TextGrid lines, etc. All preference-saving code needs to be added. | ||
|
||
|
||
State of this App code as a Glk front-end | ||
=========================================== | ||
|
||
Essentially, here is a ToDo list of what needs to be added to make this a full fledge front-end app to RemGlk: | ||
|
||
1. Glk Timer suppot isn't complete. There is only a wisper of code to satisfy a timer response in the opening of the Glulx story "Six". | ||
2. Glk windows are not properly parsed into a maintained data structure. A simple object has been started to hold each window, but it isn't populated from the JSON and it isn't really referenced yet. Right now the code assumes "class Zork-like two-windows" of a main Glk TextBuffer and a Glk TextGrid for the top status line. The logic will essentially merge multiple Glk TextBuffer windows into the main output. | ||
3. Glk style hints are not supported in RemGlk and nothing has been done to add that. This means colored text like in the Glulx story "Rover's Day Out" will not be colored. There is some hacky code out there for Thunderword's fork of RemGlk to add style hints to the JSON output of RemGlk. | ||
4. Glk player input system needs work. autocomplete typing was experiemntal and can be annoying. The code needs an option to disable that autocomplete logic. | ||
5. Glk player input system does not track multiple Glk windows and only tracks if there is character or line input mode, or a combination of both. If two windows have line input, or one window has line and another char, it does not know which window to send the input to when sending input back into RemGlk. It blindly assumes one Glk TextBuffer window and sends the input to that. | ||
6. Glk hyperlinks are working in RemGlk but this code does not yet account for them. Code needs to be added to render them and to assign a handler to send clicks back into RemGlk. | ||
7. Clearing the screen (Glk TextBuffer window) probably doesn't work but that's pretty easy to do. Some stories will clear the screen after there Glk TextBuffer content after opening, find some examples to run that do that and add the logic. | ||
8. Glk inline graphic images (inline to a Glk TextBuffer window), figures, are not coded yet. RemGlk does send the data about the images but there is no Qt C++ code yet to process that information and create a HTML img tag. | ||
9. Glk graphics windows are entirely not working. Code needs to be added. Glk graphics windows are often used to create colored boxes or image graphics. The Glulx stores "Dead Cities by John Ingold" and "Six" are difficult test cases to get working. | ||
10. Glk filename picking for save/restore and other data files needs to be added. RemGlk supports triggering a user dialog to ask for a filename, but the Qt C++ code ignores it. | ||
11. RemGlk's big absent feature is Glk sound. That's one area where contribution to RemGlk itself would be needed to add this Glk feature. RemGlk already does a lot of what it needs to parse the BLORB file for graphics images and emit the JSON - in theory basic sound file support isn't a massive task. | ||
12. The 12 standard Glk text styles are not really recognized and accounted for. Heading and subheading are kind of there, but really it needs to be fleshed out and other styles accounted for. | ||
13. Glk TextGrid support does have a primitive logic for multiple lines. However, it doesn't account for RemGlk incremental frames (generations). If only 3 lines change of a 10 line TextGrid are revised - it doesn't have any concept of this. An array or QMap of the lines needs to be added and logic to update the proper index line. For development coding of this, a Z-machine interpreter bound to RemGlk with the stories Freefall/Tetris and Z-Racer are recommended. | ||
14. Glk text alignment and alignment isn't coded. Pretty rare to encounter stories that use this feature (or is it?). | ||
15. Glk input in char mode special keystrokes such as cursor keys, ESC, F1..F12 function keys, etc. are not encoded into RemGlk's expectation. This can cause troubles with certain stories that expect those keys to be mapped, typically for menu systems. | ||
16. Relating to #10 - the RemGlkProcess QProcess - the current directory, the working directory, needs to be set to a sensible place such as the user's home folder to dump story data files. The Glulx story "Six" is an example of a story that creates data files that it loads on repeat plays. | ||
17. Relating to #8, a path can be sent to RemGlk via args that set the path it uses to reference image, sound, etc assets from blorb files. This app, Thunderquake, will need to independently access those assets from the blorb file - as RemGlk does not currently have an option to extract them for consumer apps and expects that to be done independently. | ||
18. Relating to #2, the RemGlk INIT string sent at story is fixed currently and some stories may not like the relatively small screen it passes along. This init string would need to be parameter-driven and not just a hard-coded line. | ||
19. RemGlkProcess class has no concept of loss of engine. If it were remote and disconnected - it does not track nor does it present any user interface indication. | ||
|
||
Kind of depressing to see how long that ToDo list was ;) It was fun to start from scratch knowing much more about Glk and RemGlk - but looking over this list you can see there is a lot of work to do. | ||
|
||
|
||
Bugs | ||
============= | ||
This is an incomplete prototype app with lots of bugs still, but some mentioned: | ||
|
||
1. Glux story "Six" ends up with bold text output stuck on. Other stories like Glulx "Bronze" don't seem to have this trouble? Test with cold-start of app each time. | ||
2. Glux story "Six" has a 3-line Glk TextGrid status window. However, it expects a monospace font. Set a monospace font on the QLabel. | ||
|
||
|
||
Design issue with Glk input | ||
============================== | ||
Right now there are two places to input into the story | ||
|
||
1. QComboBox at the top that also allows free-form typing. Pressing [enter]/[return] or the "go" button next to it sends to RemGlk. it is only coded for Glk line input and has no concept of char input. | ||
2. The entire canvas of the main Glk TextBuffer window is a Qt TextEdit that can process Glk line or character input. | ||
|
||
Related to #2: this TextEdit allows you to cursor or type anywhere and even destroy the story output text by deleting it, etc. Design work and code need to be done as to make this more usable / user friendly. | ||
|
||
|
||
Android | ||
============ | ||
All the technical side to compile the Qt app and run RemGlk on Android has been extensively tested and works great in testing. However, worth mentioning some very obvious issues: | ||
|
||
1. What's missing is a lot of user-interface work. For example: A QTextEdit scrolling presents a scroll-bar on the right in desktop PC fashion. It does not have normal Android app touch-screen scrolling. | ||
2. The HTML presentation of the File Open found story files is very flexible with different screen sizes. However, it's too tightly packed and it would be difficult to use a touch-screen to click the link without accidently hitting links on other lines of output. | ||
3. BUG: on arm device the TextEdit input system isn't working correctly? However, it works fine on the x86 Andoird 7.1.1 emulator with both soft and hard keyboard. why? | ||
|
||
|
||
Macintosh desktop / Apple iPhone / Windows desktop | ||
===================================================== | ||
Not yet tested in any way shape or form. May have compile problems or runtime problems due to assumptions. | ||
|
||
|
||
Qt project / makefile system | ||
=================================== | ||
Unsolved issues: | ||
|
||
1. Unable to get the .pro file to understand anroid-arm vs. android-x86 as to which binary of the RemGlk engine app to bundle into the apk for Android builds. remglkprocess.h has values of enginePickA set based on this need. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
/**************************************************************************** | ||
** | ||
** Copyright (C) 2016 The Qt Company Ltd. | ||
** Contact: https://www.qt.io/licensing/ | ||
** | ||
** This file is part of the examples of the Qt Toolkit. | ||
** | ||
** $QT_BEGIN_LICENSE:BSD$ | ||
** Commercial License Usage | ||
** Licensees holding valid commercial Qt licenses may use this file in | ||
** accordance with the commercial license agreement provided with the | ||
** Software or, alternatively, in accordance with the terms contained in | ||
** a written agreement between you and The Qt Company. For licensing terms | ||
** and conditions see https://www.qt.io/terms-conditions. For further | ||
** information use the contact form at https://www.qt.io/contact-us. | ||
** | ||
** BSD License Usage | ||
** Alternatively, you may use this file under the terms of the BSD license | ||
** as follows: | ||
** | ||
** "Redistribution and use in source and binary forms, with or without | ||
** modification, are permitted provided that the following conditions are | ||
** met: | ||
** * Redistributions of source code must retain the above copyright | ||
** notice, this list of conditions and the following disclaimer. | ||
** * Redistributions in binary form must reproduce the above copyright | ||
** notice, this list of conditions and the following disclaimer in | ||
** the documentation and/or other materials provided with the | ||
** distribution. | ||
** * Neither the name of The Qt Company Ltd nor the names of its | ||
** contributors may be used to endorse or promote products derived | ||
** from this software without specific prior written permission. | ||
** | ||
** | ||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." | ||
** | ||
** $QT_END_LICENSE$ | ||
** | ||
****************************************************************************/ | ||
|
||
#include <QtWidgets> | ||
#include "completerwindow.h" | ||
#include "remglkcompletertextedit.h" | ||
|
||
//! [0] | ||
CompleterWindow::CompleterWindow(QWidget *parent) | ||
: QMainWindow(parent), completer(0) | ||
{ | ||
qDebug() << "~~~! CompleterWindow constructor"; | ||
|
||
// createMenu(); | ||
|
||
textEdit = new RemGlkCompleterTextEdit; | ||
completer = new QCompleter(this); | ||
// completer->setModel(modelFromFile(":/resources/wordlist.txt")); | ||
completer->setModel(modelFromFile(":/resources/if_wordlist.txt")); | ||
completer->setModelSorting(QCompleter::CaseInsensitivelySortedModel); | ||
completer->setCaseSensitivity(Qt::CaseInsensitive); | ||
completer->setWrapAround(false); | ||
textEdit->setCompleter(completer); | ||
|
||
setCentralWidget(textEdit); | ||
// resize(500, 300); | ||
setWindowTitle(tr("Completer")); | ||
} | ||
//! [0] | ||
|
||
//! [1] | ||
void CompleterWindow::createMenu() | ||
{ | ||
QAction *exitAction = new QAction(tr("Exit"), this); | ||
QAction *aboutAct = new QAction(tr("About"), this); | ||
QAction *aboutQtAct = new QAction(tr("About Qt"), this); | ||
|
||
connect(exitAction, SIGNAL(triggered()), qApp, SLOT(quit())); | ||
connect(aboutAct, SIGNAL(triggered()), this, SLOT(about())); | ||
connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt())); | ||
|
||
QMenu* fileMenu = menuBar()->addMenu(tr("File")); | ||
fileMenu->addAction(exitAction); | ||
|
||
QMenu* helpMenu = menuBar()->addMenu(tr("About")); | ||
helpMenu->addAction(aboutAct); | ||
helpMenu->addAction(aboutQtAct); | ||
} | ||
//! [1] | ||
|
||
//! [2] | ||
QAbstractItemModel *CompleterWindow::modelFromFile(const QString& fileName) | ||
{ | ||
QFile file(fileName); | ||
if (!file.open(QFile::ReadOnly)) | ||
return new QStringListModel(completer); | ||
|
||
#ifndef QT_NO_CURSOR | ||
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); | ||
#endif | ||
QStringList words; | ||
|
||
while (!file.atEnd()) { | ||
QByteArray line = file.readLine(); | ||
if (!line.isEmpty()) | ||
words << line.trimmed(); | ||
} | ||
|
||
#ifndef QT_NO_CURSOR | ||
QApplication::restoreOverrideCursor(); | ||
#endif | ||
return new QStringListModel(words, completer); | ||
} | ||
//! [2] | ||
|
||
//! [3] | ||
void CompleterWindow::about() | ||
{ | ||
// ToDo: Should override in dependent class, but hand-edited anyway. | ||
QMessageBox::about(this, tr("About"), tr("WakeReality.com - Thunderquake::Qt (c) Copyright 2017 Stephen A. Gutknecht.")); | ||
} | ||
//! [3] | ||
|
Oops, something went wrong.