aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/glk/agt/agil.cpp15
-rw-r--r--engines/glk/agt/interface.cpp7
-rw-r--r--engines/glk/agt/os_glk.cpp6
3 files changed, 26 insertions, 2 deletions
diff --git a/engines/glk/agt/agil.cpp b/engines/glk/agt/agil.cpp
index 5bf19f74ae..a813b84ee7 100644
--- a/engines/glk/agt/agil.cpp
+++ b/engines/glk/agt/agil.cpp
@@ -546,6 +546,9 @@ static void mainloop(void) {
if (!menu_mode) {
prompt_out(1);
s = agt_readline(0);
+ if (g_vm->shouldQuit())
+ return;
+
agt_newline();
if (!doing_restore) tokenise(s); /* Tokenizes into input */
rfree(s);
@@ -891,6 +894,7 @@ static fc_type setup_game(fc_type fc)
pictcmd(3, 0); /* Show title image, if there is one */
print_title(fc);
have_ins = open_ins_file(fc, 0);
+
do {
if (have_ins)
writestr("Choose <I>nstructions, <A>GiliTy Information, "
@@ -898,11 +902,15 @@ static fc_type setup_game(fc_type fc)
else
writestr("Choose <A>GiliTy Information or <other> to start the game");
choice = tolower(agt_getchar()); /* Wait for keypress */
+ if (g_vm->shouldQuit())
+ return nullptr;
+
agt_clrscr();
if (have_ins && choice == 'i') print_instructions(fc);
else if (choice == 'a') print_license();
} while ((choice == 'i' && have_ins) || choice == 'a');
close_ins_file();
+
if (!intro_first && intro_ptr.size > 0) {
print_descr(intro_ptr, 1);
wait_return();
@@ -970,8 +978,13 @@ void run_game(fc_type fc) {
fc = setup_game(new_game());
} else setup_game(fc);
doing_restore = 0;
- mainloop();
+
+ if (!g_vm->shouldQuit())
+ mainloop();
close_game();
+
+ if (g_vm->shouldQuit())
+ break;
} while (doing_restore == 3);
release_file_context(&fc);
}
diff --git a/engines/glk/agt/interface.cpp b/engines/glk/agt/interface.cpp
index e7875696fa..75763d3fb0 100644
--- a/engines/glk/agt/interface.cpp
+++ b/engines/glk/agt/interface.cpp
@@ -275,7 +275,12 @@ char *agt_readline(int in_type) {
s = get_log();
else
s = agt_input(in_type);
- if (PURE_INPUT) agt_textcolor(-2);
+
+ if (g_vm->shouldQuit())
+ return nullptr;
+
+ if (PURE_INPUT)
+ agt_textcolor(-2);
if (logflag & 1)
put_log(s);
diff --git a/engines/glk/agt/os_glk.cpp b/engines/glk/agt/os_glk.cpp
index 9f01eec9d5..d7f8f143db 100644
--- a/engines/glk/agt/os_glk.cpp
+++ b/engines/glk/agt/os_glk.cpp
@@ -4775,6 +4775,10 @@ char *agt_input(int in_type) {
/* Set this up as a read buffer for the main window, and wait. */
g_vm->glk_request_line_event(gagt_main_window, buffer, length - 1, 0);
gagt_event_wait(evtype_LineInput, &event);
+ if (g_vm->shouldQuit()) {
+ g_vm->glk_cancel_line_event(gagt_main_window, &event);
+ return nullptr;
+ }
/* Terminate the input line with a NUL. */
assert((int)event.val1 < length);
@@ -4994,6 +4998,8 @@ static void gagt_event_wait_2(glui32 wait_type_1, glui32 wait_type_2, event_t *e
case evtype_Redraw:
gagt_status_redraw();
break;
+ case evtype_Quit:
+ return;
default:
break;
}