EVENTRECORDER: ignore other event sources when playing back a record
This commit is contained in:
parent
5ae72dc190
commit
f35cc92aaf
3 changed files with 27 additions and 5 deletions
|
@ -71,6 +71,8 @@ void EventDispatcher::dispatch() {
|
||||||
dispatchPoll();
|
dispatchPoll();
|
||||||
|
|
||||||
for (List<SourceEntry>::iterator i = _sources.begin(); i != _sources.end(); ++i) {
|
for (List<SourceEntry>::iterator i = _sources.begin(); i != _sources.end(); ++i) {
|
||||||
|
if (i->ignore)
|
||||||
|
continue;
|
||||||
while (i->source->pollEvent(event)) {
|
while (i->source->pollEvent(event)) {
|
||||||
// We only try to process the events via the setup event mapper, when
|
// We only try to process the events via the setup event mapper, when
|
||||||
// we have a setup mapper and when the event source allows mapping.
|
// we have a setup mapper and when the event source allows mapping.
|
||||||
|
@ -102,6 +104,8 @@ void EventDispatcher::clearEvents() {
|
||||||
Event event;
|
Event event;
|
||||||
|
|
||||||
for (List<SourceEntry>::iterator i = _sources.begin(); i != _sources.end(); ++i) {
|
for (List<SourceEntry>::iterator i = _sources.begin(); i != _sources.end(); ++i) {
|
||||||
|
if (i->ignore)
|
||||||
|
continue;
|
||||||
while (i->source->pollEvent(event)) {}
|
while (i->source->pollEvent(event)) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,6 +121,7 @@ void EventDispatcher::registerSource(EventSource *source, bool autoFree) {
|
||||||
|
|
||||||
newEntry.source = source;
|
newEntry.source = source;
|
||||||
newEntry.autoFree = autoFree;
|
newEntry.autoFree = autoFree;
|
||||||
|
newEntry.ignore = false;
|
||||||
|
|
||||||
_sources.push_back(newEntry);
|
_sources.push_back(newEntry);
|
||||||
}
|
}
|
||||||
|
@ -133,6 +138,12 @@ void EventDispatcher::unregisterSource(EventSource *source) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EventDispatcher::ignoreSources(bool ignore) {
|
||||||
|
for (List<SourceEntry>::iterator i = _sources.begin(); i != _sources.end(); ++i) {
|
||||||
|
i->ignore = ignore;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void EventDispatcher::registerObserver(EventObserver *obs, uint priority, bool autoFree, bool notifyPoll) {
|
void EventDispatcher::registerObserver(EventObserver *obs, uint priority, bool autoFree, bool notifyPoll) {
|
||||||
ObserverEntry newEntry;
|
ObserverEntry newEntry;
|
||||||
|
|
||||||
|
|
|
@ -402,6 +402,12 @@ public:
|
||||||
*/
|
*/
|
||||||
void unregisterSource(EventSource *source);
|
void unregisterSource(EventSource *source);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ignore some event sources and don't poll them. This is useful for e.g. the EventRecorder
|
||||||
|
* where you don't want the other EventSource instances to interfer with the serialized events.
|
||||||
|
*/
|
||||||
|
void ignoreSources(bool ignore);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a new EventObserver with the Dispatcher.
|
* Register a new EventObserver with the Dispatcher.
|
||||||
*
|
*
|
||||||
|
@ -421,6 +427,7 @@ private:
|
||||||
|
|
||||||
struct Entry {
|
struct Entry {
|
||||||
bool autoFree;
|
bool autoFree;
|
||||||
|
bool ignore;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SourceEntry : public Entry {
|
struct SourceEntry : public Entry {
|
||||||
|
|
|
@ -107,7 +107,9 @@ void EventRecorder::deinit() {
|
||||||
_controlPanel->close();
|
_controlPanel->close();
|
||||||
delete _controlPanel;
|
delete _controlPanel;
|
||||||
debugC(1, kDebugLevelEventRec, "playback:action=stopplayback");
|
debugC(1, kDebugLevelEventRec, "playback:action=stopplayback");
|
||||||
g_system->getEventManager()->getEventDispatcher()->unregisterSource(this);
|
Common::EventDispatcher *eventDispater = g_system->getEventManager()->getEventDispatcher();
|
||||||
|
eventDispater->unregisterSource(this);
|
||||||
|
eventDispater->ignoreSources(false);
|
||||||
_recordMode = kPassthrough;
|
_recordMode = kPassthrough;
|
||||||
_playbackFile->close();
|
_playbackFile->close();
|
||||||
delete _playbackFile;
|
delete _playbackFile;
|
||||||
|
@ -271,8 +273,11 @@ void EventRecorder::init(const Common::String &recordFileName, RecordMode mode)
|
||||||
}
|
}
|
||||||
if (_recordMode == kRecorderPlayback) {
|
if (_recordMode == kRecorderPlayback) {
|
||||||
debugC(1, kDebugLevelEventRec, "playback:action=\"Load file\" filename=%s", recordFileName.c_str());
|
debugC(1, kDebugLevelEventRec, "playback:action=\"Load file\" filename=%s", recordFileName.c_str());
|
||||||
|
Common::EventDispatcher *eventDispater = g_system->getEventManager()->getEventDispatcher();
|
||||||
|
eventDispater->clearEvents();
|
||||||
|
eventDispater->ignoreSources(true);
|
||||||
|
eventDispater->registerSource(this, false);
|
||||||
}
|
}
|
||||||
g_system->getEventManager()->getEventDispatcher()->registerSource(this, false);
|
|
||||||
_screenshotPeriod = ConfMan.getInt("screenshot_period");
|
_screenshotPeriod = ConfMan.getInt("screenshot_period");
|
||||||
if (_screenshotPeriod == 0) {
|
if (_screenshotPeriod == 0) {
|
||||||
_screenshotPeriod = kDefaultScreenshotPeriod;
|
_screenshotPeriod = kDefaultScreenshotPeriod;
|
||||||
|
@ -306,7 +311,6 @@ void EventRecorder::init(const Common::String &recordFileName, RecordMode mode)
|
||||||
*
|
*
|
||||||
* @param id of recording or playing back game
|
* @param id of recording or playing back game
|
||||||
* @return true in case of success, false in case of error
|
* @return true in case of success, false in case of error
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
bool EventRecorder::openRecordFile(const Common::String &fileName) {
|
bool EventRecorder::openRecordFile(const Common::String &fileName) {
|
||||||
bool result;
|
bool result;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue