From a4f56de13ac2a7daaf5654c75f07ad6331f375e6 Mon Sep 17 00:00:00 2001 From: Christopher Page Date: Mon, 7 Jul 2008 22:34:45 +0000 Subject: Implemented Common::EventManager::pushEvent() to insert fake events into the event queue. Quit and RTL events have been added, and are now tracked by the DefaultEventManager using shouldQuit() and shouldRTL(). AGOS is working with this new implementation, other engines to follow. svn-id: r32952 --- backends/events/default/default-events.cpp | 31 ++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) (limited to 'backends/events/default/default-events.cpp') 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) -- cgit v1.2.3