diff options
author | Paul Gilbert | 2019-11-26 21:19:17 -0800 |
---|---|---|
committer | Paul Gilbert | 2019-11-27 21:10:29 -0800 |
commit | 5d7386e42b54e69b071e726dec5c3e1bfcb5298f (patch) | |
tree | 62295cccd79ca404e9a3a66d500199a776e1caf9 /engines | |
parent | c0999ae5ba6800e06c35bb23a9613dd878147618 (diff) | |
download | scummvm-rg350-5d7386e42b54e69b071e726dec5c3e1bfcb5298f.tar.gz scummvm-rg350-5d7386e42b54e69b071e726dec5c3e1bfcb5298f.tar.bz2 scummvm-rg350-5d7386e42b54e69b071e726dec5c3e1bfcb5298f.zip |
GLK: AGT: Properly exit when game window is closed
Diffstat (limited to 'engines')
-rw-r--r-- | engines/glk/agt/agil.cpp | 15 | ||||
-rw-r--r-- | engines/glk/agt/interface.cpp | 7 | ||||
-rw-r--r-- | engines/glk/agt/os_glk.cpp | 6 |
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; } |