From e36dbfaf2e9d8d44502a7011717bcc97155212ad Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 2 Nov 2018 20:13:17 -0700 Subject: GLK: Prompt for keypress when game is exited --- engines/gargoyle/events.cpp | 16 ++++++++++++++++ engines/gargoyle/events.h | 5 +++++ engines/gargoyle/glk.cpp | 3 +++ engines/gargoyle/scott/scott.cpp | 2 +- engines/gargoyle/streams.cpp | 1 - engines/gargoyle/windows.h | 7 ++++++- 6 files changed, 31 insertions(+), 3 deletions(-) diff --git a/engines/gargoyle/events.cpp b/engines/gargoyle/events.cpp index 93b9141f78..d5eccfeba1 100644 --- a/engines/gargoyle/events.cpp +++ b/engines/gargoyle/events.cpp @@ -226,4 +226,20 @@ void Events::handleButtonUp(bool isLeft, const Point &pos) { } } +void Events::waitForPress() { + Common::Event e; + + do { + g_system->getEventManager()->pollEvent(e); + g_system->delayMillis(10); + + if (checkForNextFrameCounter()) { + // Update the screen + g_vm->_screen->update(); + } + } while (!g_vm->shouldQuit() && e.type != Common::EVENT_KEYDOWN && + e.type != Common::EVENT_LBUTTONDOWN && e.type != Common::EVENT_RBUTTONDOWN && + e.type != Common::EVENT_MBUTTONDOWN); +} + } // End of namespace Gargoyle diff --git a/engines/gargoyle/events.h b/engines/gargoyle/events.h index 4d9e49b55d..3860dc25f4 100644 --- a/engines/gargoyle/events.h +++ b/engines/gargoyle/events.h @@ -210,6 +210,11 @@ public: * Store an event for retrieval */ void store(EvType type, Window *win, uint32 val1 = 0, uint32 val2 = 0); + + /** + * Wait for a keyboard or mouse press + */ + void waitForPress(); }; } // End of namespace Gargoyle diff --git a/engines/gargoyle/glk.cpp b/engines/gargoyle/glk.cpp index c9823a9085..bda0fa74e6 100644 --- a/engines/gargoyle/glk.cpp +++ b/engines/gargoyle/glk.cpp @@ -59,6 +59,9 @@ Glk::Glk(OSystem *syst, const GargoyleGameDescription *gameDesc) : } void Glk::glk_exit(void) { + glk_put_string("[ press any key to exit ]"); + _events->waitForPress(); + quitGame(); } diff --git a/engines/gargoyle/scott/scott.cpp b/engines/gargoyle/scott/scott.cpp index 381239299c..3a085ea756 100644 --- a/engines/gargoyle/scott/scott.cpp +++ b/engines/gargoyle/scott/scott.cpp @@ -93,7 +93,7 @@ Distributed under the GNU software license\n\n"); if (GetInput(&vb, &no) == -1) continue; if (g_vm->shouldQuit()) - return; + break; switch (PerformActions(vb, no)) { case -1: diff --git a/engines/gargoyle/streams.cpp b/engines/gargoyle/streams.cpp index 3ebb98b98f..cdc2e7d17a 100644 --- a/engines/gargoyle/streams.cpp +++ b/engines/gargoyle/streams.cpp @@ -121,7 +121,6 @@ void WindowStream::putBuffer(const char *buf, size_t len) { _window->putCharUni(*buf); if (_window->_echoStream) _window->_echoStream->putBuffer(buf, len); - } void WindowStream::putBufferUni(const uint32 *buf, size_t len) { diff --git a/engines/gargoyle/windows.h b/engines/gargoyle/windows.h index d753d5311e..20ce03d9b2 100644 --- a/engines/gargoyle/windows.h +++ b/engines/gargoyle/windows.h @@ -98,11 +98,16 @@ private: */ PairWindow *newPairWindow(glui32 method, Window *key, glui32 size); + /** + * Set the window focus + */ void refocus(Window *win); + /** + * Used to loop over windows in tree order + */ Window *iterateTreeOrder(Window *win); - /** * Pick first window which has a more request */ -- cgit v1.2.3