diff options
Diffstat (limited to 'backends')
-rw-r--r-- | backends/events/default/default-events.cpp | 31 | ||||
-rw-r--r-- | backends/events/default/default-events.h | 4 |
2 files changed, 21 insertions, 14 deletions
diff --git a/backends/events/default/default-events.cpp b/backends/events/default/default-events.cpp index 7e9157edd9..71e19329bf 100644 --- a/backends/events/default/default-events.cpp +++ b/backends/events/default/default-events.cpp @@ -201,6 +201,9 @@ DefaultEventManager::~DefaultEventManager() { _boss->unlockMutex(_timeMutex); _boss->unlockMutex(_recorderMutex); + if (!artificialEventQueue.empty()) + artificialEventQueue.clear(); + if (_playbackFile != NULL) { delete _playbackFile; } @@ -350,7 +353,11 @@ bool DefaultEventManager::pollEvent(Common::Event &event) { uint32 time = _boss->getMillis(); bool result; - result = _boss->pollEvent(event); + if (!artificialEventQueue.empty()) { + event.type = artificialEventQueue.pop(); + result = true; + } else + result = _boss->pollEvent(event); if (_recordMode != kPassthrough) { @@ -387,12 +394,8 @@ bool DefaultEventManager::pollEvent(Common::Event &event) { // Global Main Menu if (event.kbd.keycode == Common::KEYCODE_F11) if (g_engine && !g_engine->isPaused()) - g_engine->mainMenuDialog(); - - if (g_engine->_quit) - event.type = Common::EVENT_QUIT; - else - break; + pushEvent(Common::EVENT_MAINMENU); + break; case Common::EVENT_KEYUP: _modifierState = event.kbd.flags; @@ -429,11 +432,12 @@ bool DefaultEventManager::pollEvent(Common::Event &event) { case Common::EVENT_MAINMENU: if (g_engine && !g_engine->isPaused()) g_engine->mainMenuDialog(); + break; - if (g_engine->_quit) - event.type = Common::EVENT_QUIT; - else - break; + case Common::EVENT_RTL: + _shouldRTL = true; + _shouldQuit = true; + break; case Common::EVENT_QUIT: if (ConfMan.getBool("confirm_exit")) { @@ -446,7 +450,6 @@ bool DefaultEventManager::pollEvent(Common::Event &event) { } else _shouldQuit = true; - g_engine->_quit = true; break; default: @@ -469,4 +472,8 @@ bool DefaultEventManager::pollEvent(Common::Event &event) { return result; } +void DefaultEventManager::pushEvent(Common::EventType eventType) { + artificialEventQueue.push(eventType); +} + #endif // !defined(DISABLE_DEFAULT_EVENTMANAGER) diff --git a/backends/events/default/default-events.h b/backends/events/default/default-events.h index d22658b672..88e3fd6afe 100644 --- a/backends/events/default/default-events.h +++ b/backends/events/default/default-events.h @@ -108,6 +108,7 @@ public: ~DefaultEventManager(); virtual bool pollEvent(Common::Event &event); + virtual void pushEvent(Common::EventType eventType); virtual void registerRandomSource(Common::RandomSource &rnd, const char *name); virtual void processMillis(uint32 &millis); @@ -116,8 +117,7 @@ public: virtual int getModifierState() const { return _modifierState; } virtual int shouldQuit() const { return _shouldQuit; } virtual int shouldRTL() const { return _shouldRTL; } - virtual void setQuit() { _shouldQuit = true; } - virtual void setRTL() { _shouldRTL = true; } + virtual void resetQuit() { _shouldQuit = false; } virtual void resetRTL() { _shouldRTL = false; } }; |