diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/gargoyle/events.cpp | 32 | ||||
-rw-r--r-- | engines/gargoyle/events.h | 34 | ||||
-rw-r--r-- | engines/gargoyle/window_text_buffer.cpp | 8 | ||||
-rw-r--r-- | engines/gargoyle/window_text_grid.cpp | 10 |
4 files changed, 71 insertions, 13 deletions
diff --git a/engines/gargoyle/events.cpp b/engines/gargoyle/events.cpp index a4dadcbaef..6fcf6340c8 100644 --- a/engines/gargoyle/events.cpp +++ b/engines/gargoyle/events.cpp @@ -28,8 +28,36 @@ void Events::getEvent(event_t *event, bool polled) { // TODO } -void Events::eventStore(EvType type, Window *win, uint32 val1, uint32 val2) { - // TODO +void Events::store(EvType type, Window *win, uint32 val1, uint32 val2) { + Event ev(type, win, val1, val2); + + switch (type) { + case evtype_Arrange: + case evtype_Redraw: + case evtype_SoundNotify: + case evtype_Timer: + _eventsPolled.push(ev); + break; + + default: + _eventsLogged.push(ev); + break; + } +} + +void Events::dispatchEvent(Event &ev, bool polled) { + Event dispatch; + + if (!polled) { + dispatch = _eventsLogged.retrieve(); + if (dispatch) + dispatch = _eventsPolled.retrieve(); + } else { + dispatch = _eventsPolled.retrieve(); + } + + if (dispatch) + ev = dispatch; } } // End of namespace Gargoyle diff --git a/engines/gargoyle/events.h b/engines/gargoyle/events.h index 6140dc4e30..54a277424a 100644 --- a/engines/gargoyle/events.h +++ b/engines/gargoyle/events.h @@ -100,7 +100,17 @@ struct Event { /** * Constructor */ - Event() : type(evtype_None), window(nullptr), val1(0), val2(0) {} + Event() { clear(); } + + /** + * Constructor + */ + Event(EvType evType, Window *evWindow, uint32 evVal1, uint32 evVal2) { + type = evType; + window = evWindow; + val1 = evVal1; + val2 = evVal2; + } /** * Clear @@ -110,10 +120,30 @@ struct Event { window = nullptr; val1 = val2 = 0; } + + /** + * Boolean cast to allow checking whether event is filled out + */ + operator bool() const { return type != evtype_None; } }; typedef Event event_t; +class EventQueue : public Common::Queue<Event> { +public: + /** + * Retrieve a pending event, if any + */ + Event retrieve() { + return empty() ? Event() : pop(); + } +}; + class Events { +private: + EventQueue _eventsPolled; + EventQueue _eventsLogged; +private: + void dispatchEvent(Event &ev, bool polled); public: bool _forceClick; public: @@ -130,7 +160,7 @@ public: /** * Store an event for retrieval */ - void eventStore(EvType type, Window *win, uint32 val1 = 0, uint32 val2 = 0); + void store(EvType type, Window *win, uint32 val1 = 0, uint32 val2 = 0); }; } // End of namespace Gargoyle diff --git a/engines/gargoyle/window_text_buffer.cpp b/engines/gargoyle/window_text_buffer.cpp index 26244e3e9c..fa8a7cced5 100644 --- a/engines/gargoyle/window_text_buffer.cpp +++ b/engines/gargoyle/window_text_buffer.cpp @@ -574,7 +574,7 @@ void TextBufferWindow::click(const Common::Point &newPos) { if (_hyperRequest) { glui32 linkval = g_vm->_windowMask->getHyperlink(newPos); if (linkval) { - g_vm->_events->eventStore(evtype_Hyperlink, this, linkval, 0); + g_vm->_events->store(evtype_Hyperlink, this, linkval, 0); _hyperRequest = false; if (g_conf->_safeClicks) g_vm->_events->_forceClick = 1; @@ -1246,7 +1246,7 @@ void TextBufferWindow::acceptReadChar(glui32 arg) { _charRequest = false; _charRequestUni = false; - g_vm->_events->eventStore(evtype_CharInput, this, key, 0); + g_vm->_events->store(evtype_CharInput, this, key, 0); } void TextBufferWindow::acceptReadLine(glui32 arg) { @@ -1479,11 +1479,11 @@ void TextBufferWindow::acceptLine(glui32 keycode) { glui32 val2 = keycode; if (val2 == keycode_Return) val2 = 0; - g_vm->_events->eventStore(evtype_LineInput, this, len, val2); + g_vm->_events->store(evtype_LineInput, this, len, val2); free(_lineTerminators); _lineTerminators = nullptr; } else { - g_vm->_events->eventStore(evtype_LineInput, this, len, 0); + g_vm->_events->store(evtype_LineInput, this, len, 0); } _lineRequest = false; diff --git a/engines/gargoyle/window_text_grid.cpp b/engines/gargoyle/window_text_grid.cpp index 4786d02735..e2ee06ec6a 100644 --- a/engines/gargoyle/window_text_grid.cpp +++ b/engines/gargoyle/window_text_grid.cpp @@ -198,7 +198,7 @@ void TextGridWindow::click(const Common::Point &newPos) { _windows->setFocus(this); if (_mouseRequest) { - g_vm->_events->eventStore(evtype_MouseInput, this, x / g_conf->_cellW, y / g_conf->_leading); + g_vm->_events->store(evtype_MouseInput, this, x / g_conf->_cellW, y / g_conf->_leading); _mouseRequest = false; if (g_conf->_safeClicks) g_vm->_events->_forceClick = true; @@ -208,7 +208,7 @@ void TextGridWindow::click(const Common::Point &newPos) { glui32 linkval = g_vm->_windowMask->getHyperlink(newPos); if (linkval) { - g_vm->_events->eventStore(evtype_Hyperlink, this, linkval, 0); + g_vm->_events->store(evtype_Hyperlink, this, linkval, 0); _hyperRequest = false; if (g_conf->_safeClicks) g_vm->_events->_forceClick = true; @@ -405,7 +405,7 @@ void TextGridWindow::acceptReadChar(glui32 arg) { _charRequest = false; _charRequestUni = false; - g_vm->_events->eventStore(evtype_CharInput, this, key, 0); + g_vm->_events->store(evtype_CharInput, this, key, 0); } void TextGridWindow::acceptLine(glui32 keycode) { @@ -444,11 +444,11 @@ void TextGridWindow::acceptLine(glui32 keycode) { glui32 val2 = keycode; if (val2 == keycode_Return) val2 = 0; - g_vm->_events->eventStore(evtype_LineInput, this, _inLen, val2); + g_vm->_events->store(evtype_LineInput, this, _inLen, val2); free(_lineTerminators); _lineTerminators = NULL; } else { - g_vm->_events->eventStore(evtype_LineInput, this, _inLen, 0); + g_vm->_events->store(evtype_LineInput, this, _inLen, 0); } _lineRequest = false; _lineRequestUni = false; |