Fix Irrlicht log events not being passed through

This commit is contained in:
sfan5 2024-04-20 15:43:34 +02:00
parent af27d97003
commit e7f6e7d7b6
1 changed files with 19 additions and 20 deletions

View File

@ -99,19 +99,30 @@ void KeyCache::populate()
bool MyEventReceiver::OnEvent(const SEvent &event) bool MyEventReceiver::OnEvent(const SEvent &event)
{ {
/* if (event.EventType == irr::EET_LOG_TEXT_EVENT) {
React to nothing here if a menu is active static const LogLevel irr_loglev_conv[] = {
*/ LL_VERBOSE, // ELL_DEBUG
LL_INFO, // ELL_INFORMATION
LL_WARNING, // ELL_WARNING
LL_ERROR, // ELL_ERROR
LL_NONE, // ELL_NONE
};
assert(event.LogEvent.Level < ARRLEN(irr_loglev_conv));
g_logger.log(irr_loglev_conv[event.LogEvent.Level],
std::string("Irrlicht: ") + event.LogEvent.Text);
return true;
}
// Let the menu handle events, if one is active.
if (isMenuActive()) { if (isMenuActive()) {
if (g_touchscreengui) { if (g_touchscreengui)
g_touchscreengui->setVisible(false); g_touchscreengui->setVisible(false);
}
return g_menumgr.preprocessEvent(event); return g_menumgr.preprocessEvent(event);
} }
// Remember whether each key is down or up // Remember whether each key is down or up
if (event.EventType == irr::EET_KEY_INPUT_EVENT) { if (event.EventType == irr::EET_KEY_INPUT_EVENT) {
const KeyPress &keyCode = event.KeyInput; const KeyPress keyCode(event.KeyInput);
if (keysListenedFor[keyCode]) { if (keysListenedFor[keyCode]) {
if (event.KeyInput.PressedDown) { if (event.KeyInput.PressedDown) {
if (!IsKeyDown(keyCode)) if (!IsKeyDown(keyCode))
@ -133,7 +144,6 @@ bool MyEventReceiver::OnEvent(const SEvent &event)
// In case of touchscreengui, we have to handle different events // In case of touchscreengui, we have to handle different events
g_touchscreengui->translateEvent(event); g_touchscreengui->translateEvent(event);
return true; return true;
} else if (event.EventType == irr::EET_JOYSTICK_INPUT_EVENT) { } else if (event.EventType == irr::EET_JOYSTICK_INPUT_EVENT) {
// joystick may be nullptr if game is launched with '--random-input' parameter // joystick may be nullptr if game is launched with '--random-input' parameter
return joystick && joystick->handleEvent(event.JoystickEvent); return joystick && joystick->handleEvent(event.JoystickEvent);
@ -179,20 +189,9 @@ bool MyEventReceiver::OnEvent(const SEvent &event)
break; break;
default: break; default: break;
} }
} else if (event.EventType == irr::EET_LOG_TEXT_EVENT) {
static const LogLevel irr_loglev_conv[] = {
LL_VERBOSE, // ELL_DEBUG
LL_INFO, // ELL_INFORMATION
LL_WARNING, // ELL_WARNING
LL_ERROR, // ELL_ERROR
LL_NONE, // ELL_NONE
};
assert(event.LogEvent.Level < ARRLEN(irr_loglev_conv));
g_logger.log(irr_loglev_conv[event.LogEvent.Level],
std::string("Irrlicht: ") + event.LogEvent.Text);
return true;
} }
/* always return false in order to continue processing events */
// tell Irrlicht to continue processing this event
return false; return false;
} }