aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/glk/alan3/alan3.cpp3
-rw-r--r--engines/glk/alan3/alan3.h4
-rw-r--r--engines/glk/alan3/glkio.cpp39
-rw-r--r--engines/glk/alan3/glkio.h20
-rw-r--r--engines/glk/alan3/inter.cpp1
5 files changed, 50 insertions, 17 deletions
diff --git a/engines/glk/alan3/alan3.cpp b/engines/glk/alan3/alan3.cpp
index 990874ee58..33ccf75c20 100644
--- a/engines/glk/alan3/alan3.cpp
+++ b/engines/glk/alan3/alan3.cpp
@@ -41,8 +41,7 @@ namespace Alan3 {
Alan3 *g_vm = nullptr;
-Alan3::Alan3(OSystem *syst, const GlkGameDescription &gameDesc) : GlkIO(syst, gameDesc),
- vm_exited_cleanly(false), _pendingLook(false) {
+Alan3::Alan3(OSystem *syst, const GlkGameDescription &gameDesc) : GlkIO(syst, gameDesc) {
g_vm = this;
// main
diff --git a/engines/glk/alan3/alan3.h b/engines/glk/alan3/alan3.h
index ffb6282ece..f1d88f857f 100644
--- a/engines/glk/alan3/alan3.h
+++ b/engines/glk/alan3/alan3.h
@@ -33,9 +33,7 @@ namespace Alan3 {
*/
class Alan3 : public GlkIO {
public:
- bool vm_exited_cleanly;
Common::String _advName;
- bool _pendingLook;
private:
/**
* Initialization
@@ -73,7 +71,7 @@ public:
* Save the game. The passed write stream represents access to the UMem chunk
* in the Quetzal save file that will be created
*/
- virtual Common::Error writeGameData(Common::WriteStream *ws) override;
+ virtual Common::Error writeGameData(Common::WriteStream *ws) override;;
};
extern Alan3 *g_vm;
diff --git a/engines/glk/alan3/glkio.cpp b/engines/glk/alan3/glkio.cpp
index 15c3278916..61e9f180f1 100644
--- a/engines/glk/alan3/glkio.cpp
+++ b/engines/glk/alan3/glkio.cpp
@@ -62,21 +62,21 @@ void GlkIO::print(const char *fmt, ...) {
va_list argp;
va_start(argp, fmt);
+ Common::String str = Common::String::vformat(fmt, argp);
+ va_end(argp);
+
if (glkMainWin) {
- char buf[1024]; /* FIXME: buf size should be foolproof */
- vsprintf(buf, fmt, argp);
- glk_put_string(buf);
+ glk_put_string(str.c_str());
} else {
// assume stdio is available in this case only
- Common::String str = Common::String::vformat(fmt, argp);
- warning(fmt, argp);
+ warning("%s", str.c_str());
}
-
- va_end(argp);
}
void GlkIO::showImage(int image, int align) {
uint ecode;
+ if (_saveSlot != -1)
+ return;
if ((glk_gestalt(gestalt_Graphics, 0) == 1) &&
(glk_gestalt(gestalt_DrawImage, wintype_TextBuffer) == 1)) {
@@ -88,6 +88,9 @@ void GlkIO::showImage(int image, int align) {
}
void GlkIO::playSound(int sound) {
+ if (_saveSlot != -1)
+ return;
+
#ifdef GLK_MODULE_SOUND
static schanid_t soundChannel = NULL;
@@ -127,8 +130,7 @@ void GlkIO::statusLine(CONTEXT) {
char line[100];
int pcol = col;
- if (!statusLineOption) return;
- if (glkStatusWin == NULL)
+ if (!statusLineOption || _saveSlot != -1 || glkStatusWin == nullptr)
return;
glk_set_window(glkStatusWin);
@@ -171,7 +173,13 @@ bool GlkIO::readLine(CONTEXT, char *buffer, size_t maxLen) {
static frefid_t commandFileRef;
static strid_t commandFile;
- if (readingCommands) {
+ if (_saveSlot != -1) {
+ // Return a "restore" command
+ forcePrint("> ");
+ forcePrint("restore\n");
+ strcpy(buffer, "restore");
+
+ } else if (readingCommands) {
if (glk_get_line_stream(commandFile, buffer, maxLen) == 0) {
glk_stream_close(commandFile, NULL);
readingCommands = FALSE;
@@ -180,6 +188,7 @@ bool GlkIO::readLine(CONTEXT, char *buffer, size_t maxLen) {
printf(buffer);
glk_set_style(style_Normal);
}
+
} else {
glk_request_line_event(glkMainWin, buffer, maxLen, 0);
@@ -214,5 +223,15 @@ bool GlkIO::readLine(CONTEXT, char *buffer, size_t maxLen) {
return TRUE;
}
+Common::Error GlkIO::loadGame() {
+ if (_saveSlot != -1) {
+ int saveSlot = _saveSlot;
+ _saveSlot = -1;
+ return loadGameState(saveSlot);
+ } else {
+ return GlkAPI::loadGame();
+ }
+}
+
} // End of namespace Alan3
} // End of namespace Glk
diff --git a/engines/glk/alan3/glkio.h b/engines/glk/alan3/glkio.h
index 55c8ab6cab..fb342d1569 100644
--- a/engines/glk/alan3/glkio.h
+++ b/engines/glk/alan3/glkio.h
@@ -48,7 +48,17 @@ public:
*/
GlkIO(OSystem *syst, const GlkGameDescription &gameDesc);
- void print(const char *, ...);
+ /**
+ * Print a string to the window
+ */
+ void print(const char *fmt, ...);
+
+ /**
+ * Outputs a string to the window, even during startup
+ */
+ void forcePrint(const char *str) {
+ glk_put_string(str);
+ }
void showImage(int image, int align);
@@ -66,9 +76,15 @@ public:
void flowBreak() {
/* Make a new paragraph, i.e one empty line (one or two newlines). */
- if (glk_gestalt(gestalt_Graphics, 0) == 1)
+ if (_saveSlot == -1 && glk_gestalt(gestalt_Graphics, 0) == 1)
glk_window_flow_break(glkMainWin);
}
+
+ /**
+ * If a savegame was selected to be loaded from the launcher, then load it.
+ * Otherwise, prompt the user for a savegame to load, and then load it
+ */
+ Common::Error loadGame();
};
extern GlkIO *g_io;
diff --git a/engines/glk/alan3/inter.cpp b/engines/glk/alan3/inter.cpp
index 5ee5ea976e..3647548a41 100644
--- a/engines/glk/alan3/inter.cpp
+++ b/engines/glk/alan3/inter.cpp
@@ -21,6 +21,7 @@
*/
#include "glk/alan3/inter.h"
+#include "glk/alan3/alan3.h"
#include "glk/alan3/current.h"
#include "glk/alan3/exe.h"
#include "glk/alan3/syserr.h"