Replace anonymous union in Event with pointer to appropriate struct
parent
28163cc008
commit
f95980456a
151
src/app/app.cpp
151
src/app/app.cpp
|
@ -941,12 +941,13 @@ int CApplication::Run()
|
||||||
if (event.type == EVENT_SYS_QUIT)
|
if (event.type == EVENT_SYS_QUIT)
|
||||||
goto end; // exit the loop
|
goto end; // exit the loop
|
||||||
|
|
||||||
if (event.type != EVENT_NULL)
|
|
||||||
m_eventQueue->AddEvent(event);
|
|
||||||
|
|
||||||
Event virtualEvent = CreateVirtualEvent(event);
|
Event virtualEvent = CreateVirtualEvent(event);
|
||||||
|
|
||||||
|
if (event.type != EVENT_NULL)
|
||||||
|
m_eventQueue->AddEvent(std::move(event));
|
||||||
|
|
||||||
if (virtualEvent.type != EVENT_NULL)
|
if (virtualEvent.type != EVENT_NULL)
|
||||||
m_eventQueue->AddEvent(virtualEvent);
|
m_eventQueue->AddEvent(std::move(virtualEvent));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -961,15 +962,16 @@ int CApplication::Run()
|
||||||
goto end; // exit the loop
|
goto end; // exit the loop
|
||||||
|
|
||||||
if (event.type != EVENT_NULL)
|
if (event.type != EVENT_NULL)
|
||||||
m_eventQueue->AddEvent(event);
|
m_eventQueue->AddEvent(std::move(event));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enter game update & frame rendering only if active
|
// Enter game update & frame rendering only if active
|
||||||
if (m_active)
|
if (m_active)
|
||||||
{
|
{
|
||||||
Event event;
|
while (! m_eventQueue->IsEmpty())
|
||||||
while (m_eventQueue->GetEvent(event))
|
|
||||||
{
|
{
|
||||||
|
Event event = m_eventQueue->GetEvent();
|
||||||
|
|
||||||
if (event.type == EVENT_SYS_QUIT || event.type == EVENT_QUIT)
|
if (event.type == EVENT_SYS_QUIT || event.type == EVENT_QUIT)
|
||||||
goto end; // exit both loops
|
goto end; // exit both loops
|
||||||
|
|
||||||
|
@ -988,7 +990,7 @@ int CApplication::Run()
|
||||||
StartPerformanceCounter(PCNT_UPDATE_ALL);
|
StartPerformanceCounter(PCNT_UPDATE_ALL);
|
||||||
|
|
||||||
// Prepare and process step simulation event
|
// Prepare and process step simulation event
|
||||||
event = CreateUpdateEvent();
|
Event event = CreateUpdateEvent();
|
||||||
if (event.type != EVENT_NULL && m_controller != nullptr)
|
if (event.type != EVENT_NULL && m_controller != nullptr)
|
||||||
{
|
{
|
||||||
LogEvent(event);
|
LogEvent(event);
|
||||||
|
@ -1067,22 +1069,26 @@ Event CApplication::ProcessSystemEvent()
|
||||||
else
|
else
|
||||||
event.type = EVENT_KEY_UP;
|
event.type = EVENT_KEY_UP;
|
||||||
|
|
||||||
event.key.virt = false;
|
auto data = MakeUnique<KeyEventData>();
|
||||||
event.key.key = m_private->currentEvent.key.keysym.sym;
|
|
||||||
event.key.unicode = m_private->currentEvent.key.keysym.unicode;
|
data->virt = false;
|
||||||
|
data->key = m_private->currentEvent.key.keysym.sym;
|
||||||
|
data->unicode = m_private->currentEvent.key.keysym.unicode;
|
||||||
event.kmodState = m_private->currentEvent.key.keysym.mod;
|
event.kmodState = m_private->currentEvent.key.keysym.mod;
|
||||||
|
|
||||||
// Some keyboards return numerical enter keycode instead of normal enter
|
// Some keyboards return numerical enter keycode instead of normal enter
|
||||||
// See issue #427 for details
|
// See issue #427 for details
|
||||||
if (event.key.key == KEY(KP_ENTER))
|
if (data->key == KEY(KP_ENTER))
|
||||||
event.key.key = KEY(RETURN);
|
data->key = KEY(RETURN);
|
||||||
|
|
||||||
if (event.key.key == KEY(TAB) && ((event.kmodState & KEY_MOD(ALT)) != 0))
|
if (data->key == KEY(TAB) && ((event.kmodState & KEY_MOD(ALT)) != 0))
|
||||||
{
|
{
|
||||||
GetLogger()->Debug("Minimize to taskbar\n");
|
GetLogger()->Debug("Minimize to taskbar\n");
|
||||||
SDL_WM_IconifyWindow();
|
SDL_WM_IconifyWindow();
|
||||||
event.type = EVENT_NULL;
|
event.type = EVENT_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
event.data = std::move(data);
|
||||||
}
|
}
|
||||||
else if ( (m_private->currentEvent.type == SDL_MOUSEBUTTONDOWN) ||
|
else if ( (m_private->currentEvent.type == SDL_MOUSEBUTTONDOWN) ||
|
||||||
(m_private->currentEvent.type == SDL_MOUSEBUTTONUP) )
|
(m_private->currentEvent.type == SDL_MOUSEBUTTONUP) )
|
||||||
|
@ -1090,23 +1096,34 @@ Event CApplication::ProcessSystemEvent()
|
||||||
if ((m_private->currentEvent.button.button == SDL_BUTTON_WHEELUP) ||
|
if ((m_private->currentEvent.button.button == SDL_BUTTON_WHEELUP) ||
|
||||||
(m_private->currentEvent.button.button == SDL_BUTTON_WHEELDOWN))
|
(m_private->currentEvent.button.button == SDL_BUTTON_WHEELDOWN))
|
||||||
{
|
{
|
||||||
|
|
||||||
if (m_private->currentEvent.type == SDL_MOUSEBUTTONDOWN) // ignore the following up event
|
if (m_private->currentEvent.type == SDL_MOUSEBUTTONDOWN) // ignore the following up event
|
||||||
{
|
{
|
||||||
event.type = EVENT_MOUSE_WHEEL;
|
event.type = EVENT_MOUSE_WHEEL;
|
||||||
|
|
||||||
|
auto data = MakeUnique<MouseWheelEventData>();
|
||||||
|
|
||||||
if (m_private->currentEvent.button.button == SDL_BUTTON_WHEELDOWN)
|
if (m_private->currentEvent.button.button == SDL_BUTTON_WHEELDOWN)
|
||||||
event.mouseWheel.dir = WHEEL_DOWN;
|
data->dir = WHEEL_DOWN;
|
||||||
else
|
else
|
||||||
event.mouseWheel.dir = WHEEL_UP;
|
data->dir = WHEEL_UP;
|
||||||
|
|
||||||
|
event.data = std::move(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
auto data = MakeUnique<MouseButtonEventData>();
|
||||||
|
|
||||||
if (m_private->currentEvent.type == SDL_MOUSEBUTTONDOWN)
|
if (m_private->currentEvent.type == SDL_MOUSEBUTTONDOWN)
|
||||||
event.type = EVENT_MOUSE_BUTTON_DOWN;
|
event.type = EVENT_MOUSE_BUTTON_DOWN;
|
||||||
else
|
else
|
||||||
event.type = EVENT_MOUSE_BUTTON_UP;
|
event.type = EVENT_MOUSE_BUTTON_UP;
|
||||||
|
|
||||||
event.mouseButton.button = static_cast<MouseButton>(1 << m_private->currentEvent.button.button);
|
data->button = static_cast<MouseButton>(1 << m_private->currentEvent.button.button);
|
||||||
|
|
||||||
|
event.data = std::move(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (m_private->currentEvent.type == SDL_MOUSEMOTION)
|
else if (m_private->currentEvent.type == SDL_MOUSEMOTION)
|
||||||
|
@ -1119,8 +1136,10 @@ Event CApplication::ProcessSystemEvent()
|
||||||
{
|
{
|
||||||
event.type = EVENT_JOY_AXIS;
|
event.type = EVENT_JOY_AXIS;
|
||||||
|
|
||||||
event.joyAxis.axis = m_private->currentEvent.jaxis.axis;
|
auto data = MakeUnique<JoyAxisEventData>();
|
||||||
event.joyAxis.value = m_private->currentEvent.jaxis.value;
|
data->axis = m_private->currentEvent.jaxis.axis;
|
||||||
|
data->value = m_private->currentEvent.jaxis.value;
|
||||||
|
event.data = std::move(data);
|
||||||
}
|
}
|
||||||
else if ( (m_private->currentEvent.type == SDL_JOYBUTTONDOWN) ||
|
else if ( (m_private->currentEvent.type == SDL_JOYBUTTONDOWN) ||
|
||||||
(m_private->currentEvent.type == SDL_JOYBUTTONUP) )
|
(m_private->currentEvent.type == SDL_JOYBUTTONUP) )
|
||||||
|
@ -1130,20 +1149,26 @@ Event CApplication::ProcessSystemEvent()
|
||||||
else
|
else
|
||||||
event.type = EVENT_JOY_BUTTON_UP;
|
event.type = EVENT_JOY_BUTTON_UP;
|
||||||
|
|
||||||
event.joyButton.button = m_private->currentEvent.jbutton.button;
|
auto data = MakeUnique<JoyButtonEventData>();
|
||||||
|
data->button = m_private->currentEvent.jbutton.button;
|
||||||
|
event.data = std::move(data);
|
||||||
}
|
}
|
||||||
else if (m_private->currentEvent.type == SDL_ACTIVEEVENT)
|
else if (m_private->currentEvent.type == SDL_ACTIVEEVENT)
|
||||||
{
|
{
|
||||||
event.type = EVENT_ACTIVE;
|
event.type = EVENT_ACTIVE;
|
||||||
|
|
||||||
if (m_private->currentEvent.active.type & SDL_APPINPUTFOCUS)
|
auto data = MakeUnique<ActiveEventData>();
|
||||||
event.active.flags |= ACTIVE_INPUT;
|
|
||||||
if (m_private->currentEvent.active.type & SDL_APPMOUSEFOCUS)
|
|
||||||
event.active.flags |= ACTIVE_MOUSE;
|
|
||||||
if (m_private->currentEvent.active.type & SDL_APPACTIVE)
|
|
||||||
event.active.flags |= ACTIVE_APP;
|
|
||||||
|
|
||||||
event.active.gain = m_private->currentEvent.active.gain == 1;
|
if (m_private->currentEvent.active.type & SDL_APPINPUTFOCUS)
|
||||||
|
data->flags |= ACTIVE_INPUT;
|
||||||
|
if (m_private->currentEvent.active.type & SDL_APPMOUSEFOCUS)
|
||||||
|
data->flags |= ACTIVE_MOUSE;
|
||||||
|
if (m_private->currentEvent.active.type & SDL_APPACTIVE)
|
||||||
|
data->flags |= ACTIVE_APP;
|
||||||
|
|
||||||
|
data->gain = m_private->currentEvent.active.gain == 1;
|
||||||
|
|
||||||
|
event.data = std::move(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_input->EventProcess(event);
|
m_input->EventProcess(event);
|
||||||
|
@ -1176,29 +1201,47 @@ void CApplication::LogEvent(const Event &event)
|
||||||
{
|
{
|
||||||
case EVENT_KEY_DOWN:
|
case EVENT_KEY_DOWN:
|
||||||
case EVENT_KEY_UP:
|
case EVENT_KEY_UP:
|
||||||
l->Trace(" virt = %s\n", (event.key.virt) ? "true" : "false");
|
{
|
||||||
l->Trace(" key = %d\n", event.key.key);
|
auto data = event.GetData<KeyEventData>();
|
||||||
l->Trace(" unicode = 0x%04x\n", event.key.unicode);
|
l->Trace(" virt = %s\n", data->virt ? "true" : "false");
|
||||||
|
l->Trace(" key = %d\n", data->key);
|
||||||
|
l->Trace(" unicode = 0x%04x\n", data->unicode);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case EVENT_MOUSE_BUTTON_DOWN:
|
case EVENT_MOUSE_BUTTON_DOWN:
|
||||||
case EVENT_MOUSE_BUTTON_UP:
|
case EVENT_MOUSE_BUTTON_UP:
|
||||||
l->Trace(" button = %d\n", event.mouseButton.button);
|
{
|
||||||
|
auto data = event.GetData<MouseButtonEventData>();
|
||||||
|
l->Trace(" button = %d\n", data->button);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case EVENT_MOUSE_WHEEL:
|
case EVENT_MOUSE_WHEEL:
|
||||||
l->Trace(" dir = %s\n", (event.mouseWheel.dir == WHEEL_DOWN) ? "WHEEL_DOWN" : "WHEEL_UP");
|
{
|
||||||
break;
|
auto data = event.GetData<MouseWheelEventData>();
|
||||||
case EVENT_JOY_AXIS:
|
l->Trace(" dir = %s\n", (data->dir == WHEEL_DOWN) ? "WHEEL_DOWN" : "WHEEL_UP");
|
||||||
l->Trace(" axis = %d\n", event.joyAxis.axis);
|
|
||||||
l->Trace(" value = %d\n", event.joyAxis.value);
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
case EVENT_JOY_AXIS:
|
||||||
|
{
|
||||||
|
auto data = event.GetData<JoyAxisEventData>();
|
||||||
|
l->Trace(" axis = %d\n", data->axis);
|
||||||
|
l->Trace(" value = %d\n", data->value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case EVENT_JOY_BUTTON_DOWN:
|
case EVENT_JOY_BUTTON_DOWN:
|
||||||
case EVENT_JOY_BUTTON_UP:
|
case EVENT_JOY_BUTTON_UP:
|
||||||
l->Trace(" button = %d\n", event.joyButton.button);
|
{
|
||||||
|
auto data = event.GetData<JoyButtonEventData>();
|
||||||
|
l->Trace(" button = %d\n", data->button);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case EVENT_ACTIVE:
|
case EVENT_ACTIVE:
|
||||||
l->Trace(" flags = 0x%x\n", event.active.flags);
|
{
|
||||||
l->Trace(" gain = %s\n", event.active.gain ? "true" : "false");
|
auto data = event.GetData<ActiveEventData>();
|
||||||
|
l->Trace(" flags = 0x%x\n", data->flags);
|
||||||
|
l->Trace(" gain = %s\n", data->gain ? "true" : "false");
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1221,13 +1264,23 @@ Event CApplication::CreateVirtualEvent(const Event& sourceEvent)
|
||||||
|
|
||||||
if ((sourceEvent.type == EVENT_KEY_DOWN) || (sourceEvent.type == EVENT_KEY_UP))
|
if ((sourceEvent.type == EVENT_KEY_DOWN) || (sourceEvent.type == EVENT_KEY_UP))
|
||||||
{
|
{
|
||||||
virtualEvent.type = sourceEvent.type;
|
auto sourceData = sourceEvent.GetData<KeyEventData>();
|
||||||
virtualEvent.key = sourceEvent.key;
|
auto virtualKey = GetVirtualKey(sourceData->key);
|
||||||
virtualEvent.key.key = GetVirtualKey(sourceEvent.key.key);
|
|
||||||
virtualEvent.key.virt = true;
|
|
||||||
|
|
||||||
if (virtualEvent.key.key == sourceEvent.key.key)
|
if (virtualKey == sourceData->key)
|
||||||
|
{
|
||||||
virtualEvent.type = EVENT_NULL;
|
virtualEvent.type = EVENT_NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
virtualEvent.type = sourceEvent.type;
|
||||||
|
|
||||||
|
auto data = sourceData->Clone();
|
||||||
|
auto keyData = static_cast<KeyEventData*>(data.get());
|
||||||
|
keyData->key = virtualKey;
|
||||||
|
keyData->virt = true;
|
||||||
|
virtualEvent.data = std::move(data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if ((sourceEvent.type == EVENT_JOY_BUTTON_DOWN) || (sourceEvent.type == EVENT_JOY_BUTTON_UP))
|
else if ((sourceEvent.type == EVENT_JOY_BUTTON_DOWN) || (sourceEvent.type == EVENT_JOY_BUTTON_UP))
|
||||||
{
|
{
|
||||||
|
@ -1236,9 +1289,13 @@ Event CApplication::CreateVirtualEvent(const Event& sourceEvent)
|
||||||
else
|
else
|
||||||
virtualEvent.type = EVENT_KEY_UP;
|
virtualEvent.type = EVENT_KEY_UP;
|
||||||
|
|
||||||
virtualEvent.key.virt = true;
|
auto sourceData = sourceEvent.GetData<JoyButtonEventData>();
|
||||||
virtualEvent.key.key = VIRTUAL_JOY(sourceEvent.joyButton.button);
|
|
||||||
virtualEvent.key.unicode = 0;
|
auto data = MakeUnique<KeyEventData>();
|
||||||
|
data->virt = true;
|
||||||
|
data->key = VIRTUAL_JOY(sourceData->button);
|
||||||
|
data->unicode = 0;
|
||||||
|
virtualEvent.data = std::move(data);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -78,8 +78,8 @@ CInput::CInput()
|
||||||
|
|
||||||
void CInput::EventProcess(Event& event)
|
void CInput::EventProcess(Event& event)
|
||||||
{
|
{
|
||||||
if(event.type == EVENT_KEY_DOWN ||
|
if (event.type == EVENT_KEY_DOWN ||
|
||||||
event.type == EVENT_KEY_UP)
|
event.type == EVENT_KEY_UP)
|
||||||
{
|
{
|
||||||
// Use the occasion to update kmods
|
// Use the occasion to update kmods
|
||||||
m_kmodState = event.kmodState;
|
m_kmodState = event.kmodState;
|
||||||
|
@ -88,18 +88,21 @@ void CInput::EventProcess(Event& event)
|
||||||
// Use the occasion to update mouse button state
|
// Use the occasion to update mouse button state
|
||||||
if (event.type == EVENT_MOUSE_BUTTON_DOWN)
|
if (event.type == EVENT_MOUSE_BUTTON_DOWN)
|
||||||
{
|
{
|
||||||
m_mouseButtonsState |= event.mouseButton.button;
|
auto data = event.GetData<MouseButtonEventData>();
|
||||||
|
m_mouseButtonsState |= data->button;
|
||||||
}
|
}
|
||||||
if(event.type == EVENT_MOUSE_BUTTON_UP)
|
if (event.type == EVENT_MOUSE_BUTTON_UP)
|
||||||
{
|
{
|
||||||
m_mouseButtonsState &= ~event.mouseButton.button;
|
auto data = event.GetData<MouseButtonEventData>();
|
||||||
|
m_mouseButtonsState &= ~data->button;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(event.type == EVENT_KEY_DOWN ||
|
if (event.type == EVENT_KEY_DOWN ||
|
||||||
event.type == EVENT_KEY_UP)
|
event.type == EVENT_KEY_UP)
|
||||||
{
|
{
|
||||||
event.key.slot = FindBinding(event.key.key);
|
auto data = event.GetData<KeyEventData>();
|
||||||
|
data->slot = FindBinding(data->key);
|
||||||
}
|
}
|
||||||
|
|
||||||
event.kmodState = m_kmodState;
|
event.kmodState = m_kmodState;
|
||||||
|
@ -110,7 +113,8 @@ void CInput::EventProcess(Event& event)
|
||||||
if (event.type == EVENT_KEY_DOWN ||
|
if (event.type == EVENT_KEY_DOWN ||
|
||||||
event.type == EVENT_KEY_UP)
|
event.type == EVENT_KEY_UP)
|
||||||
{
|
{
|
||||||
m_keyPresses[event.key.slot] = (event.type == EVENT_KEY_DOWN);
|
auto data = event.GetData<KeyEventData>();
|
||||||
|
m_keyPresses[data->slot] = (event.type == EVENT_KEY_DOWN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -119,41 +123,47 @@ void CInput::EventProcess(Event& event)
|
||||||
|
|
||||||
if (event.type == EVENT_KEY_DOWN && !(event.kmodState & KEY_MOD(ALT) ) )
|
if (event.type == EVENT_KEY_DOWN && !(event.kmodState & KEY_MOD(ALT) ) )
|
||||||
{
|
{
|
||||||
if (event.key.slot == INPUT_SLOT_UP ) m_keyMotion.y = 1.0f;
|
auto data = event.GetData<KeyEventData>();
|
||||||
if (event.key.slot == INPUT_SLOT_DOWN ) m_keyMotion.y = -1.0f;
|
|
||||||
if (event.key.slot == INPUT_SLOT_LEFT ) m_keyMotion.x = -1.0f;
|
if (data->slot == INPUT_SLOT_UP ) m_keyMotion.y = 1.0f;
|
||||||
if (event.key.slot == INPUT_SLOT_RIGHT) m_keyMotion.x = 1.0f;
|
if (data->slot == INPUT_SLOT_DOWN ) m_keyMotion.y = -1.0f;
|
||||||
if (event.key.slot == INPUT_SLOT_GUP ) m_keyMotion.z = 1.0f;
|
if (data->slot == INPUT_SLOT_LEFT ) m_keyMotion.x = -1.0f;
|
||||||
if (event.key.slot == INPUT_SLOT_GDOWN) m_keyMotion.z = -1.0f;
|
if (data->slot == INPUT_SLOT_RIGHT) m_keyMotion.x = 1.0f;
|
||||||
|
if (data->slot == INPUT_SLOT_GUP ) m_keyMotion.z = 1.0f;
|
||||||
|
if (data->slot == INPUT_SLOT_GDOWN) m_keyMotion.z = -1.0f;
|
||||||
}
|
}
|
||||||
else if (event.type == EVENT_KEY_UP)
|
else if (event.type == EVENT_KEY_UP)
|
||||||
{
|
{
|
||||||
if (event.key.slot == INPUT_SLOT_UP ) m_keyMotion.y = 0.0f;
|
auto data = event.GetData<KeyEventData>();
|
||||||
if (event.key.slot == INPUT_SLOT_DOWN ) m_keyMotion.y = 0.0f;
|
|
||||||
if (event.key.slot == INPUT_SLOT_LEFT ) m_keyMotion.x = 0.0f;
|
if (data->slot == INPUT_SLOT_UP ) m_keyMotion.y = 0.0f;
|
||||||
if (event.key.slot == INPUT_SLOT_RIGHT) m_keyMotion.x = 0.0f;
|
if (data->slot == INPUT_SLOT_DOWN ) m_keyMotion.y = 0.0f;
|
||||||
if (event.key.slot == INPUT_SLOT_GUP ) m_keyMotion.z = 0.0f;
|
if (data->slot == INPUT_SLOT_LEFT ) m_keyMotion.x = 0.0f;
|
||||||
if (event.key.slot == INPUT_SLOT_GDOWN) m_keyMotion.z = 0.0f;
|
if (data->slot == INPUT_SLOT_RIGHT) m_keyMotion.x = 0.0f;
|
||||||
|
if (data->slot == INPUT_SLOT_GUP ) m_keyMotion.z = 0.0f;
|
||||||
|
if (data->slot == INPUT_SLOT_GDOWN) m_keyMotion.z = 0.0f;
|
||||||
}
|
}
|
||||||
else if (event.type == EVENT_JOY_AXIS)
|
else if (event.type == EVENT_JOY_AXIS)
|
||||||
{
|
{
|
||||||
if (event.joyAxis.axis == GetJoyAxisBinding(JOY_AXIS_SLOT_X).axis)
|
auto data = event.GetData<JoyAxisEventData>();
|
||||||
|
|
||||||
|
if (data->axis == GetJoyAxisBinding(JOY_AXIS_SLOT_X).axis)
|
||||||
{
|
{
|
||||||
m_joyMotion.x = Math::Neutral(event.joyAxis.value / 32768.0f, m_joystickDeadzone);
|
m_joyMotion.x = Math::Neutral(data->value / 32768.0f, m_joystickDeadzone);
|
||||||
if (GetJoyAxisBinding(JOY_AXIS_SLOT_X).invert)
|
if (GetJoyAxisBinding(JOY_AXIS_SLOT_X).invert)
|
||||||
m_joyMotion.x *= -1.0f;
|
m_joyMotion.x *= -1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.joyAxis.axis == GetJoyAxisBinding(JOY_AXIS_SLOT_Y).axis)
|
if (data->axis == GetJoyAxisBinding(JOY_AXIS_SLOT_Y).axis)
|
||||||
{
|
{
|
||||||
m_joyMotion.y = Math::Neutral(event.joyAxis.value / 32768.0f, m_joystickDeadzone);
|
m_joyMotion.y = Math::Neutral(data->value / 32768.0f, m_joystickDeadzone);
|
||||||
if (GetJoyAxisBinding(JOY_AXIS_SLOT_Y).invert)
|
if (GetJoyAxisBinding(JOY_AXIS_SLOT_Y).invert)
|
||||||
m_joyMotion.y *= -1.0f;
|
m_joyMotion.y *= -1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.joyAxis.axis == GetJoyAxisBinding(JOY_AXIS_SLOT_Z).axis)
|
if (data->axis == GetJoyAxisBinding(JOY_AXIS_SLOT_Z).axis)
|
||||||
{
|
{
|
||||||
m_joyMotion.z = Math::Neutral(event.joyAxis.value / 32768.0f, m_joystickDeadzone);
|
m_joyMotion.z = Math::Neutral(data->value / 32768.0f, m_joystickDeadzone);
|
||||||
if (GetJoyAxisBinding(JOY_AXIS_SLOT_Z).invert)
|
if (GetJoyAxisBinding(JOY_AXIS_SLOT_Z).invert)
|
||||||
m_joyMotion.z *= -1.0f;
|
m_joyMotion.z *= -1.0f;
|
||||||
}
|
}
|
||||||
|
|
|
@ -558,9 +558,14 @@ CEventQueue::CEventQueue()
|
||||||
CEventQueue::~CEventQueue()
|
CEventQueue::~CEventQueue()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
bool CEventQueue::IsEmpty()
|
||||||
|
{
|
||||||
|
return m_head == m_tail;
|
||||||
|
}
|
||||||
|
|
||||||
/** If the maximum size of queue has been reached, returns \c false.
|
/** If the maximum size of queue has been reached, returns \c false.
|
||||||
Else, adds the event to the queue and returns \c true. */
|
Else, adds the event to the queue and returns \c true. */
|
||||||
bool CEventQueue::AddEvent(const Event &event)
|
bool CEventQueue::AddEvent(Event&& event)
|
||||||
{
|
{
|
||||||
bool result{};
|
bool result{};
|
||||||
|
|
||||||
|
@ -574,7 +579,7 @@ bool CEventQueue::AddEvent(const Event &event)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_fifo[m_head++] = event;
|
m_fifo[m_head++] = std::move(event);
|
||||||
|
|
||||||
if (m_head >= MAX_EVENT_QUEUE)
|
if (m_head >= MAX_EVENT_QUEUE)
|
||||||
m_head = 0;
|
m_head = 0;
|
||||||
|
@ -589,31 +594,28 @@ bool CEventQueue::AddEvent(const Event &event)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** If the queue is empty, returns \c false.
|
Event CEventQueue::GetEvent()
|
||||||
Else, gets the event from the front, puts it into \a event and returns \c true. */
|
|
||||||
bool CEventQueue::GetEvent(Event &event)
|
|
||||||
{
|
{
|
||||||
bool result{};
|
Event event;
|
||||||
|
|
||||||
SDL_LockMutex(*m_mutex);
|
SDL_LockMutex(*m_mutex);
|
||||||
|
|
||||||
if (m_head == m_tail)
|
if (m_head == m_tail)
|
||||||
{
|
{
|
||||||
result = false;
|
event.type = EVENT_NULL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
event = m_fifo[m_tail++];
|
event = std::move(m_fifo[m_tail++]);
|
||||||
|
|
||||||
if (m_tail >= MAX_EVENT_QUEUE)
|
if (m_tail >= MAX_EVENT_QUEUE)
|
||||||
m_tail = 0;
|
m_tail = 0;
|
||||||
|
|
||||||
m_total--;
|
m_total--;
|
||||||
|
|
||||||
result = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_UnlockMutex(*m_mutex);
|
SDL_UnlockMutex(*m_mutex);
|
||||||
|
|
||||||
return result;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,14 +24,16 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
#include "common/key.h"
|
#include "common/key.h"
|
||||||
|
#include "common/make_unique.h"
|
||||||
|
|
||||||
#include "common/thread/sdl_mutex_wrapper.h"
|
#include "common/thread/sdl_mutex_wrapper.h"
|
||||||
|
|
||||||
#include "math/point.h"
|
#include "math/point.h"
|
||||||
#include "math/vector.h"
|
#include "math/vector.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\enum EventType
|
\enum EventType
|
||||||
\brief Type of event message
|
\brief Type of event message
|
||||||
|
@ -543,13 +545,29 @@ enum EventType
|
||||||
EVENT_FORCE_LONG = 0x7fffffff
|
EVENT_FORCE_LONG = 0x7fffffff
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \struct EventData
|
||||||
|
* \brief Base class for additional event data
|
||||||
|
*/
|
||||||
|
struct EventData
|
||||||
|
{
|
||||||
|
virtual ~EventData()
|
||||||
|
{}
|
||||||
|
|
||||||
|
virtual std::unique_ptr<EventData> Clone() const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \struct KeyEventData
|
* \struct KeyEventData
|
||||||
* \brief Additional data for keyboard event
|
* \brief Additional data for keyboard event
|
||||||
*/
|
*/
|
||||||
struct KeyEventData
|
struct KeyEventData : public EventData
|
||||||
{
|
{
|
||||||
|
std::unique_ptr<EventData> Clone() const override
|
||||||
|
{
|
||||||
|
return MakeUnique<KeyEventData>(*this);
|
||||||
|
}
|
||||||
|
|
||||||
//! If true, the key is a virtual code generated by certain key modifiers or joystick buttons
|
//! If true, the key is a virtual code generated by certain key modifiers or joystick buttons
|
||||||
bool virt = false;
|
bool virt = false;
|
||||||
//! Key symbol: KEY(...) macro value or virtual key VIRTUAL_... (from common/key.h)
|
//! Key symbol: KEY(...) macro value or virtual key VIRTUAL_... (from common/key.h)
|
||||||
|
@ -580,8 +598,13 @@ enum MouseButton
|
||||||
* \struct MouseButtonEventData
|
* \struct MouseButtonEventData
|
||||||
* \brief Additional data mouse button event
|
* \brief Additional data mouse button event
|
||||||
*/
|
*/
|
||||||
struct MouseButtonEventData
|
struct MouseButtonEventData : public EventData
|
||||||
{
|
{
|
||||||
|
std::unique_ptr<EventData> Clone() const override
|
||||||
|
{
|
||||||
|
return MakeUnique<MouseButtonEventData>(*this);
|
||||||
|
}
|
||||||
|
|
||||||
//! The mouse button
|
//! The mouse button
|
||||||
MouseButton button = {};
|
MouseButton button = {};
|
||||||
};
|
};
|
||||||
|
@ -600,8 +623,13 @@ enum WheelDirection
|
||||||
* \struct MouseWheelEventData
|
* \struct MouseWheelEventData
|
||||||
* \brief Additional data for mouse wheel event.
|
* \brief Additional data for mouse wheel event.
|
||||||
*/
|
*/
|
||||||
struct MouseWheelEventData
|
struct MouseWheelEventData : public EventData
|
||||||
{
|
{
|
||||||
|
std::unique_ptr<EventData> Clone() const override
|
||||||
|
{
|
||||||
|
return MakeUnique<MouseWheelEventData>(*this);
|
||||||
|
}
|
||||||
|
|
||||||
//! Wheel direction
|
//! Wheel direction
|
||||||
WheelDirection dir = {};
|
WheelDirection dir = {};
|
||||||
};
|
};
|
||||||
|
@ -610,8 +638,13 @@ struct MouseWheelEventData
|
||||||
* \struct JoyAxisEventData
|
* \struct JoyAxisEventData
|
||||||
* \brief Additional data for joystick axis event
|
* \brief Additional data for joystick axis event
|
||||||
*/
|
*/
|
||||||
struct JoyAxisEventData
|
struct JoyAxisEventData : public EventData
|
||||||
{
|
{
|
||||||
|
std::unique_ptr<EventData> Clone() const override
|
||||||
|
{
|
||||||
|
return MakeUnique<JoyAxisEventData>(*this);
|
||||||
|
}
|
||||||
|
|
||||||
//! The joystick axis index
|
//! The joystick axis index
|
||||||
unsigned char axis = 0;
|
unsigned char axis = 0;
|
||||||
//! The axis value (range: -32768 to 32767)
|
//! The axis value (range: -32768 to 32767)
|
||||||
|
@ -622,8 +655,13 @@ struct JoyAxisEventData
|
||||||
* \struct JoyButtonEventData
|
* \struct JoyButtonEventData
|
||||||
* \brief Additional data for joystick button event
|
* \brief Additional data for joystick button event
|
||||||
*/
|
*/
|
||||||
struct JoyButtonEventData
|
struct JoyButtonEventData : public EventData
|
||||||
{
|
{
|
||||||
|
std::unique_ptr<EventData> Clone() const override
|
||||||
|
{
|
||||||
|
return MakeUnique<JoyButtonEventData>(*this);
|
||||||
|
}
|
||||||
|
|
||||||
//! The joystick button index
|
//! The joystick button index
|
||||||
unsigned char button = 0;
|
unsigned char button = 0;
|
||||||
};
|
};
|
||||||
|
@ -647,15 +685,19 @@ enum ActiveEventFlags
|
||||||
* \struct ActiveEventData
|
* \struct ActiveEventData
|
||||||
* \brief Additional data for active event
|
* \brief Additional data for active event
|
||||||
*/
|
*/
|
||||||
struct ActiveEventData
|
struct ActiveEventData : public EventData
|
||||||
{
|
{
|
||||||
|
std::unique_ptr<EventData> Clone() const override
|
||||||
|
{
|
||||||
|
return MakeUnique<ActiveEventData>(*this);
|
||||||
|
}
|
||||||
|
|
||||||
//! Flags (bitmask of enum values ActiveEventFlags)
|
//! Flags (bitmask of enum values ActiveEventFlags)
|
||||||
unsigned char flags = 0;
|
unsigned char flags = 0;
|
||||||
//! True if the focus was gained; false otherwise
|
//! True if the focus was gained; false otherwise
|
||||||
bool gain = false;
|
bool gain = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \struct Event
|
* \struct Event
|
||||||
* \brief Event sent by system, interface or game
|
* \brief Event sent by system, interface or game
|
||||||
|
@ -669,6 +711,49 @@ struct ActiveEventData
|
||||||
**/
|
**/
|
||||||
struct Event
|
struct Event
|
||||||
{
|
{
|
||||||
|
explicit Event(EventType type = EVENT_NULL)
|
||||||
|
: type(type),
|
||||||
|
rTime(0.0f),
|
||||||
|
kmodState(0),
|
||||||
|
mouseButtonsState(0),
|
||||||
|
customParam(0)
|
||||||
|
{}
|
||||||
|
|
||||||
|
//! Convenience function for getting appropriate EventData subclass
|
||||||
|
template<typename EventDataSubclass>
|
||||||
|
EventDataSubclass* GetData()
|
||||||
|
{
|
||||||
|
return static_cast<EventDataSubclass*>(data.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Convenience function for getting appropriate EventData subclass
|
||||||
|
template<typename EventDataSubclass>
|
||||||
|
const EventDataSubclass* GetData() const
|
||||||
|
{
|
||||||
|
return static_cast<EventDataSubclass*>(data.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Returns a clone of this event
|
||||||
|
Event Clone() const
|
||||||
|
{
|
||||||
|
Event clone;
|
||||||
|
|
||||||
|
clone.type = type;
|
||||||
|
clone.rTime = rTime;
|
||||||
|
clone.motionInput = motionInput;
|
||||||
|
clone.kmodState = kmodState;
|
||||||
|
clone.mousePos = mousePos;
|
||||||
|
clone.mouseButtonsState = mouseButtonsState;
|
||||||
|
clone.customParam = customParam;
|
||||||
|
|
||||||
|
if (data != nullptr)
|
||||||
|
{
|
||||||
|
clone.data = data->Clone();
|
||||||
|
}
|
||||||
|
|
||||||
|
return clone;
|
||||||
|
}
|
||||||
|
|
||||||
//! Type of event
|
//! Type of event
|
||||||
EventType type;
|
EventType type;
|
||||||
|
|
||||||
|
@ -697,30 +782,8 @@ struct Event
|
||||||
//! Scope: some interface events
|
//! Scope: some interface events
|
||||||
long customParam;
|
long customParam;
|
||||||
|
|
||||||
//! Union with additional data, applicable only to some events
|
//! Additional data for some events
|
||||||
union
|
std::unique_ptr<EventData> data;
|
||||||
{
|
|
||||||
//! Additional data for EVENT_KEY_DOWN and EVENT_KEY_UP
|
|
||||||
KeyEventData key;
|
|
||||||
//! Additional data for EVENT_MOUSE_BUTTON_DOWN and EVENT_MOUSE_BUTTON_UP
|
|
||||||
MouseButtonEventData mouseButton;
|
|
||||||
//! Additional data for EVENT_MOUSE_WHEEL
|
|
||||||
MouseWheelEventData mouseWheel;
|
|
||||||
//! Additional data for EVENT_JOY
|
|
||||||
JoyAxisEventData joyAxis;
|
|
||||||
//! Additional data for EVENT_JOY_AXIS
|
|
||||||
JoyButtonEventData joyButton;
|
|
||||||
//! Additional data for EVENT_ACTIVE
|
|
||||||
ActiveEventData active;
|
|
||||||
};
|
|
||||||
|
|
||||||
explicit Event(EventType _type = EVENT_NULL)
|
|
||||||
: type(_type)
|
|
||||||
, rTime(0.0f)
|
|
||||||
, kmodState(0)
|
|
||||||
, mouseButtonsState(0)
|
|
||||||
, customParam(0)
|
|
||||||
{}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -754,10 +817,12 @@ public:
|
||||||
//! Object's destructor
|
//! Object's destructor
|
||||||
~CEventQueue();
|
~CEventQueue();
|
||||||
|
|
||||||
|
//! Checks if queue is empty
|
||||||
|
bool IsEmpty();
|
||||||
//! Adds an event to the queue
|
//! Adds an event to the queue
|
||||||
bool AddEvent(const Event &event);
|
bool AddEvent(Event&& event);
|
||||||
//! Removes and returns an event from queue front
|
//! Removes and returns an event from queue front; if queue is empty, returns event of type EVENT_NULL
|
||||||
bool GetEvent(Event &event);
|
Event GetEvent();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CSDLMutexWrapper m_mutex;
|
CSDLMutexWrapper m_mutex;
|
||||||
|
|
|
@ -1055,7 +1055,7 @@ bool CCamera::EventProcess(const Event &event)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EVENT_MOUSE_WHEEL:
|
case EVENT_MOUSE_WHEEL:
|
||||||
EventMouseWheel(event.mouseWheel.dir);
|
EventMouseWheel(event.GetData<MouseWheelEventData>()->dir);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -407,19 +407,21 @@ bool CEngine::ProcessEvent(const Event &event)
|
||||||
{
|
{
|
||||||
if (event.type == EVENT_KEY_DOWN)
|
if (event.type == EVENT_KEY_DOWN)
|
||||||
{
|
{
|
||||||
if (event.key.key == KEY(F12))
|
auto data = event.GetData<KeyEventData>();
|
||||||
|
|
||||||
|
if (data->key == KEY(F12))
|
||||||
{
|
{
|
||||||
m_showStats = !m_showStats;
|
m_showStats = !m_showStats;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.key.key == KEY(F11))
|
if (data->key == KEY(F11))
|
||||||
{
|
{
|
||||||
m_debugLights = !m_debugLights;
|
m_debugLights = !m_debugLights;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.key.key == KEY(F10))
|
if (data->key == KEY(F10))
|
||||||
{
|
{
|
||||||
m_debugDumpLights = true;
|
m_debugDumpLights = true;
|
||||||
return false;
|
return false;
|
||||||
|
@ -524,8 +526,7 @@ void CEngine::WriteScreenShotThread(std::unique_ptr<WriteScreenShotData> data)
|
||||||
GetLogger()->Error("%s!\n", data->img->GetError().c_str());
|
GetLogger()->Error("%s!\n", data->img->GetError().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
Event event(EVENT_WRITE_SCENE_FINISHED);
|
CApplication::GetInstancePointer()->GetEventQueue()->AddEvent(Event(EVENT_WRITE_SCENE_FINISHED));
|
||||||
CApplication::GetInstancePointer()->GetEventQueue()->AddEvent(event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CEngine::GetPause()
|
bool CEngine::GetPause()
|
||||||
|
|
|
@ -120,7 +120,6 @@ void CAutoBase::Start(int param)
|
||||||
bool CAutoBase::EventProcess(const Event &event)
|
bool CAutoBase::EventProcess(const Event &event)
|
||||||
{
|
{
|
||||||
Math::Matrix* mat;
|
Math::Matrix* mat;
|
||||||
Event newEvent;
|
|
||||||
CObject* pObj;
|
CObject* pObj;
|
||||||
Math::Vector pos, speed, vibCir, iPos;
|
Math::Vector pos, speed, vibCir, iPos;
|
||||||
Math::Point dim, p;
|
Math::Point dim, p;
|
||||||
|
@ -804,8 +803,7 @@ begin:
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_soundChannel = -1;
|
m_soundChannel = -1;
|
||||||
newEvent.type = EVENT_WIN;
|
m_eventQueue->AddEvent(Event(EVENT_WIN));
|
||||||
m_eventQueue->AddEvent(newEvent);
|
|
||||||
|
|
||||||
m_phase = ABP_WAIT;
|
m_phase = ABP_WAIT;
|
||||||
m_progress = 0.0f;
|
m_progress = 0.0f;
|
||||||
|
@ -1054,7 +1052,6 @@ begin:
|
||||||
|
|
||||||
bool CAutoBase::Abort()
|
bool CAutoBase::Abort()
|
||||||
{
|
{
|
||||||
Event newEvent;
|
|
||||||
CObject* pObj;
|
CObject* pObj;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -1137,8 +1134,7 @@ bool CAutoBase::Abort()
|
||||||
m_phase == ABP_TOWAIT ||
|
m_phase == ABP_TOWAIT ||
|
||||||
m_phase == ABP_TAKEOFF ) // off?
|
m_phase == ABP_TAKEOFF ) // off?
|
||||||
{
|
{
|
||||||
newEvent.type = EVENT_WIN;
|
m_eventQueue->AddEvent(Event(EVENT_WIN));
|
||||||
m_eventQueue->AddEvent(newEvent);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1384,9 +1380,7 @@ Error CAutoBase::TakeOff(bool printMsg)
|
||||||
m_main->SetMovieLock(true); // blocks everything until the end
|
m_main->SetMovieLock(true); // blocks everything until the end
|
||||||
m_main->DeselectAll();
|
m_main->DeselectAll();
|
||||||
|
|
||||||
Event newEvent;
|
m_eventQueue->AddEvent(Event(EVENT_UPDINTERFACE));
|
||||||
newEvent.type = EVENT_UPDINTERFACE;
|
|
||||||
m_eventQueue->AddEvent(newEvent);
|
|
||||||
|
|
||||||
m_camera->SetType(Gfx::CAM_TYPE_SCRIPT);
|
m_camera->SetType(Gfx::CAM_TYPE_SCRIPT);
|
||||||
|
|
||||||
|
|
|
@ -226,9 +226,14 @@ bool CBrain::EventProcess(const Event &event)
|
||||||
|
|
||||||
action = EVENT_NULL;
|
action = EVENT_NULL;
|
||||||
|
|
||||||
if ( event.type == EVENT_KEY_DOWN &&
|
bool isActionSlot = false;
|
||||||
event.key.slot == INPUT_SLOT_ACTION &&
|
if (event.type == EVENT_KEY_DOWN && !m_main->GetEditLock())
|
||||||
!m_main->GetEditLock() )
|
{
|
||||||
|
auto data = event.GetData<KeyEventData>();
|
||||||
|
isActionSlot = data->slot == INPUT_SLOT_ACTION;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isActionSlot)
|
||||||
{
|
{
|
||||||
pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));
|
pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));
|
||||||
if ( pw != 0 )
|
if ( pw != 0 )
|
||||||
|
@ -248,19 +253,21 @@ bool CBrain::EventProcess(const Event &event)
|
||||||
action = event.type;
|
action = event.type;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(event.type == EVENT_KEY_DOWN && m_object->GetSelect())
|
if (event.type == EVENT_KEY_DOWN && m_object->GetSelect())
|
||||||
{
|
{
|
||||||
bool bControl = (event.kmodState & KEY_MOD(CTRL)) != 0;
|
auto data = event.GetData<KeyEventData>();
|
||||||
bool bAlt = (event.kmodState & KEY_MOD(ALT)) != 0;
|
|
||||||
|
bool control = (event.kmodState & KEY_MOD(CTRL)) != 0;
|
||||||
|
bool alt = (event.kmodState & KEY_MOD(ALT)) != 0;
|
||||||
CEventQueue* queue = CApplication::GetInstancePointer()->GetEventQueue();
|
CEventQueue* queue = CApplication::GetInstancePointer()->GetEventQueue();
|
||||||
|
|
||||||
if(event.key.slot == INPUT_SLOT_ACTION && bControl)
|
if (data->slot == INPUT_SLOT_ACTION && control)
|
||||||
{
|
{
|
||||||
queue->AddEvent(Event(m_studio == nullptr ? EVENT_OBJECT_PROGEDIT : EVENT_STUDIO_OK));
|
queue->AddEvent(Event(m_studio == nullptr ? EVENT_OBJECT_PROGEDIT : EVENT_STUDIO_OK));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(event.key.slot == INPUT_SLOT_ACTION && bAlt)
|
if (data->slot == INPUT_SLOT_ACTION && alt)
|
||||||
{
|
{
|
||||||
pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));
|
pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));
|
||||||
if ( pw != 0 )
|
if ( pw != 0 )
|
||||||
|
@ -277,16 +284,16 @@ bool CBrain::EventProcess(const Event &event)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(bAlt)
|
if (alt)
|
||||||
{
|
{
|
||||||
int index = GetSelScript();
|
int index = GetSelScript();
|
||||||
if(event.key.slot == INPUT_SLOT_UP)
|
if(data->slot == INPUT_SLOT_UP)
|
||||||
index--;
|
index--;
|
||||||
else if(event.key.slot == INPUT_SLOT_DOWN)
|
else if(data->slot == INPUT_SLOT_DOWN)
|
||||||
index++;
|
index++;
|
||||||
else if(event.key.key >= KEY(1) && event.key.key <= KEY(9))
|
else if(data->key >= KEY(1) && data->key <= KEY(9))
|
||||||
index = event.key.key-KEY(1);
|
index = data->key-KEY(1);
|
||||||
else if(event.key.key == KEY(0))
|
else if(data->key == KEY(0))
|
||||||
index = 9;
|
index = 9;
|
||||||
if(index < 0) index = m_program.size()-1;
|
if(index < 0) index = m_program.size()-1;
|
||||||
if(index > static_cast<int>(m_program.size())-1) index = 0;
|
if(index > static_cast<int>(m_program.size())-1) index = 0;
|
||||||
|
@ -295,9 +302,7 @@ bool CBrain::EventProcess(const Event &event)
|
||||||
{
|
{
|
||||||
SetSelScript(index);
|
SetSelScript(index);
|
||||||
|
|
||||||
Event newEvent = event;
|
queue->AddEvent(Event(EVENT_OBJECT_PROGLIST));
|
||||||
newEvent.type = EVENT_OBJECT_PROGLIST;
|
|
||||||
queue->AddEvent(newEvent);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -666,11 +666,11 @@ bool CRobotMain::ProcessEvent(Event &event)
|
||||||
|
|
||||||
// Management of the console.
|
// Management of the console.
|
||||||
if (event.type == EVENT_KEY_DOWN &&
|
if (event.type == EVENT_KEY_DOWN &&
|
||||||
event.key.key == KEY(BACKQUOTE)) // Pause ?
|
event.GetData<KeyEventData>()->key == KEY(BACKQUOTE)) // Pause ?
|
||||||
{
|
{
|
||||||
if (m_phase != PHASE_PLAYER_SELECT &&
|
if (m_phase != PHASE_PLAYER_SELECT &&
|
||||||
!m_movie->IsExist() &&
|
!m_movie->IsExist() &&
|
||||||
!m_movieLock && !m_editLock)
|
!m_movieLock && !m_editLock)
|
||||||
{
|
{
|
||||||
Ui::CEdit* pe = static_cast<Ui::CEdit*>(m_interface->SearchControl(EVENT_CMD));
|
Ui::CEdit* pe = static_cast<Ui::CEdit*>(m_interface->SearchControl(EVENT_CMD));
|
||||||
if (pe == nullptr) return false;
|
if (pe == nullptr) return false;
|
||||||
|
@ -681,8 +681,9 @@ bool CRobotMain::ProcessEvent(Event &event)
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.type == EVENT_KEY_DOWN &&
|
if (event.type == EVENT_KEY_DOWN &&
|
||||||
event.key.key == KEY(RETURN) && m_cmdEdit)
|
event.GetData<KeyEventData>()->key == KEY(RETURN) && m_cmdEdit)
|
||||||
{
|
{
|
||||||
char cmd[50];
|
char cmd[50];
|
||||||
Ui::CEdit* pe = static_cast<Ui::CEdit*>(m_interface->SearchControl(EVENT_CMD));
|
Ui::CEdit* pe = static_cast<Ui::CEdit*>(m_interface->SearchControl(EVENT_CMD));
|
||||||
|
@ -724,9 +725,11 @@ bool CRobotMain::ProcessEvent(Event &event)
|
||||||
|
|
||||||
if (event.type == EVENT_KEY_DOWN)
|
if (event.type == EVENT_KEY_DOWN)
|
||||||
{
|
{
|
||||||
if (event.key.slot == INPUT_SLOT_HELP ||
|
auto data = event.GetData<KeyEventData>();
|
||||||
event.key.slot == INPUT_SLOT_PROG ||
|
|
||||||
event.key.key == KEY(ESCAPE))
|
if (data->slot == INPUT_SLOT_HELP ||
|
||||||
|
data->slot == INPUT_SLOT_PROG ||
|
||||||
|
data->key == KEY(ESCAPE))
|
||||||
{
|
{
|
||||||
StopDisplayInfo();
|
StopDisplayInfo();
|
||||||
}
|
}
|
||||||
|
@ -749,21 +752,24 @@ bool CRobotMain::ProcessEvent(Event &event)
|
||||||
switch (event.type)
|
switch (event.type)
|
||||||
{
|
{
|
||||||
case EVENT_KEY_DOWN:
|
case EVENT_KEY_DOWN:
|
||||||
KeyCamera(event.type, event.key.slot);
|
{
|
||||||
|
auto data = event.GetData<KeyEventData>();
|
||||||
|
|
||||||
|
KeyCamera(event.type, data->slot);
|
||||||
HiliteClear();
|
HiliteClear();
|
||||||
if (event.key.key == KEY(F11))
|
if (data->key == KEY(F11))
|
||||||
{
|
{
|
||||||
m_particle->WriteWheelTrace("Savegame/t.png", 256, 256, Math::Vector(16.0f, 0.0f, -368.0f), Math::Vector(140.0f, 0.0f, -248.0f));
|
m_particle->WriteWheelTrace("Savegame/t.png", 256, 256, Math::Vector(16.0f, 0.0f, -368.0f), Math::Vector(140.0f, 0.0f, -248.0f));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (m_editLock) // current edition?
|
if (m_editLock) // current edition?
|
||||||
{
|
{
|
||||||
if (event.key.slot == INPUT_SLOT_HELP)
|
if (data->slot == INPUT_SLOT_HELP)
|
||||||
{
|
{
|
||||||
StartDisplayInfo(SATCOM_HUSTON, false);
|
StartDisplayInfo(SATCOM_HUSTON, false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (event.key.slot == INPUT_SLOT_PROG)
|
if (data->slot == INPUT_SLOT_PROG)
|
||||||
{
|
{
|
||||||
StartDisplayInfo(SATCOM_PROG, false);
|
StartDisplayInfo(SATCOM_PROG, false);
|
||||||
return false;
|
return false;
|
||||||
|
@ -772,8 +778,8 @@ bool CRobotMain::ProcessEvent(Event &event)
|
||||||
}
|
}
|
||||||
if (m_movieLock) // current movie?
|
if (m_movieLock) // current movie?
|
||||||
{
|
{
|
||||||
if (event.key.slot == INPUT_SLOT_QUIT ||
|
if (data->slot == INPUT_SLOT_QUIT ||
|
||||||
event.key.key == KEY(ESCAPE))
|
data->key == KEY(ESCAPE))
|
||||||
{
|
{
|
||||||
AbortMovie();
|
AbortMovie();
|
||||||
}
|
}
|
||||||
|
@ -781,18 +787,18 @@ bool CRobotMain::ProcessEvent(Event &event)
|
||||||
}
|
}
|
||||||
if (m_camera->GetType() == Gfx::CAM_TYPE_VISIT)
|
if (m_camera->GetType() == Gfx::CAM_TYPE_VISIT)
|
||||||
{
|
{
|
||||||
if (event.key.slot == INPUT_SLOT_VISIT)
|
if (data->slot == INPUT_SLOT_VISIT)
|
||||||
{
|
{
|
||||||
StartDisplayVisit(EVENT_NULL);
|
StartDisplayVisit(EVENT_NULL);
|
||||||
}
|
}
|
||||||
if (event.key.slot == INPUT_SLOT_QUIT ||
|
if (data->slot == INPUT_SLOT_QUIT ||
|
||||||
event.key.key == KEY(ESCAPE))
|
data->key == KEY(ESCAPE))
|
||||||
{
|
{
|
||||||
StopDisplayVisit();
|
StopDisplayVisit();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (event.key.slot == INPUT_SLOT_QUIT)
|
if (data->slot == INPUT_SLOT_QUIT)
|
||||||
{
|
{
|
||||||
if (m_movie->IsExist())
|
if (m_movie->IsExist())
|
||||||
StartDisplayInfo(SATCOM_HUSTON, false);
|
StartDisplayInfo(SATCOM_HUSTON, false);
|
||||||
|
@ -803,7 +809,7 @@ bool CRobotMain::ProcessEvent(Event &event)
|
||||||
else if (!m_cmdEdit)
|
else if (!m_cmdEdit)
|
||||||
m_ui->GetDialog()->StartPauseMenu(); // do you want to leave?
|
m_ui->GetDialog()->StartPauseMenu(); // do you want to leave?
|
||||||
}
|
}
|
||||||
if (event.key.slot == INPUT_SLOT_PAUSE)
|
if (data->slot == INPUT_SLOT_PAUSE)
|
||||||
{
|
{
|
||||||
if (!m_movieLock && !m_editLock && !m_cmdEdit &&
|
if (!m_movieLock && !m_editLock && !m_cmdEdit &&
|
||||||
m_camera->GetType() != Gfx::CAM_TYPE_VISIT &&
|
m_camera->GetType() != Gfx::CAM_TYPE_VISIT &&
|
||||||
|
@ -812,70 +818,70 @@ bool CRobotMain::ProcessEvent(Event &event)
|
||||||
ChangePause(m_pause->GetPause(PAUSE_USER) || m_pause->GetPause(PAUSE_CODE_BATTLE_LOCK) ? PAUSE_NONE : PAUSE_USER);
|
ChangePause(m_pause->GetPause(PAUSE_USER) || m_pause->GetPause(PAUSE_CODE_BATTLE_LOCK) ? PAUSE_NONE : PAUSE_USER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (event.key.slot == INPUT_SLOT_CAMERA)
|
if (data->slot == INPUT_SLOT_CAMERA)
|
||||||
{
|
{
|
||||||
ChangeCamera();
|
ChangeCamera();
|
||||||
}
|
}
|
||||||
if (event.key.slot == INPUT_SLOT_DESEL)
|
if (data->slot == INPUT_SLOT_DESEL)
|
||||||
{
|
{
|
||||||
if (m_shortCut)
|
if (m_shortCut)
|
||||||
DeselectObject();
|
DeselectObject();
|
||||||
}
|
}
|
||||||
if (event.key.slot == INPUT_SLOT_HUMAN)
|
if (data->slot == INPUT_SLOT_HUMAN)
|
||||||
{
|
{
|
||||||
SelectHuman();
|
SelectHuman();
|
||||||
}
|
}
|
||||||
if (event.key.slot == INPUT_SLOT_NEXT && ((event.kmodState & KEY_MOD(CTRL)) != 0))
|
if (data->slot == INPUT_SLOT_NEXT && ((event.kmodState & KEY_MOD(CTRL)) != 0))
|
||||||
{
|
{
|
||||||
m_short->SelectShortcut(EVENT_OBJECT_SHORTCUT_MODE); // switch bots <-> buildings
|
m_short->SelectShortcut(EVENT_OBJECT_SHORTCUT_MODE); // switch bots <-> buildings
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (event.key.slot == INPUT_SLOT_NEXT)
|
if (data->slot == INPUT_SLOT_NEXT)
|
||||||
{
|
{
|
||||||
if (m_shortCut)
|
if (m_shortCut)
|
||||||
m_short->SelectNext();
|
m_short->SelectNext();
|
||||||
}
|
}
|
||||||
if (event.key.slot == INPUT_SLOT_HELP)
|
if (data->slot == INPUT_SLOT_HELP)
|
||||||
{
|
{
|
||||||
StartDisplayInfo(SATCOM_HUSTON, true);
|
StartDisplayInfo(SATCOM_HUSTON, true);
|
||||||
}
|
}
|
||||||
if (event.key.slot == INPUT_SLOT_PROG)
|
if (data->slot == INPUT_SLOT_PROG)
|
||||||
{
|
{
|
||||||
StartDisplayInfo(SATCOM_PROG, true);
|
StartDisplayInfo(SATCOM_PROG, true);
|
||||||
}
|
}
|
||||||
if (event.key.slot == INPUT_SLOT_VISIT)
|
if (data->slot == INPUT_SLOT_VISIT)
|
||||||
{
|
{
|
||||||
StartDisplayVisit(EVENT_NULL);
|
StartDisplayVisit(EVENT_NULL);
|
||||||
}
|
}
|
||||||
if (event.key.slot == INPUT_SLOT_SPEED05)
|
if (data->slot == INPUT_SLOT_SPEED05)
|
||||||
{
|
{
|
||||||
SetSpeed(0.5f);
|
SetSpeed(0.5f);
|
||||||
}
|
}
|
||||||
if (event.key.slot == INPUT_SLOT_SPEED10)
|
if (data->slot == INPUT_SLOT_SPEED10)
|
||||||
{
|
{
|
||||||
SetSpeed(1.0f);
|
SetSpeed(1.0f);
|
||||||
}
|
}
|
||||||
if (event.key.slot == INPUT_SLOT_SPEED15)
|
if (data->slot == INPUT_SLOT_SPEED15)
|
||||||
{
|
{
|
||||||
SetSpeed(1.5f);
|
SetSpeed(1.5f);
|
||||||
}
|
}
|
||||||
if (event.key.slot == INPUT_SLOT_SPEED20)
|
if (data->slot == INPUT_SLOT_SPEED20)
|
||||||
{
|
{
|
||||||
SetSpeed(2.0f);
|
SetSpeed(2.0f);
|
||||||
}
|
}
|
||||||
if (event.key.slot == INPUT_SLOT_SPEED30)
|
if (data->slot == INPUT_SLOT_SPEED30)
|
||||||
{
|
{
|
||||||
SetSpeed(3.0f);
|
SetSpeed(3.0f);
|
||||||
}
|
}
|
||||||
if (event.key.slot == INPUT_SLOT_SPEED40)
|
if (data->slot == INPUT_SLOT_SPEED40)
|
||||||
{
|
{
|
||||||
SetSpeed(4.0f);
|
SetSpeed(4.0f);
|
||||||
}
|
}
|
||||||
if (event.key.slot == INPUT_SLOT_SPEED60)
|
if (data->slot == INPUT_SLOT_SPEED60)
|
||||||
{
|
{
|
||||||
SetSpeed(6.0f);
|
SetSpeed(6.0f);
|
||||||
}
|
}
|
||||||
if (event.key.key == KEY(c) && ((event.kmodState & KEY_MOD(CTRL)) != 0) && m_engine->GetShowStats())
|
if (data->key == KEY(c) && ((event.kmodState & KEY_MOD(CTRL)) != 0) && m_engine->GetShowStats())
|
||||||
{
|
{
|
||||||
CObject* obj = GetSelect();
|
CObject* obj = GetSelect();
|
||||||
if (obj != nullptr)
|
if (obj != nullptr)
|
||||||
|
@ -893,13 +899,18 @@ bool CRobotMain::ProcessEvent(Event &event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case EVENT_KEY_UP:
|
case EVENT_KEY_UP:
|
||||||
KeyCamera(event.type, event.key.slot);
|
{
|
||||||
|
auto data = event.GetData<KeyEventData>();
|
||||||
|
KeyCamera(event.type, data->slot);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case EVENT_MOUSE_BUTTON_DOWN:
|
case EVENT_MOUSE_BUTTON_DOWN:
|
||||||
if (event.mouseButton.button != MOUSE_BUTTON_LEFT) // only left mouse button
|
{
|
||||||
|
if (event.GetData<MouseButtonEventData>()->button != MOUSE_BUTTON_LEFT) // only left mouse button
|
||||||
break;
|
break;
|
||||||
|
|
||||||
obj = DetectObject(event.mousePos);
|
obj = DetectObject(event.mousePos);
|
||||||
|
@ -917,11 +928,14 @@ bool CRobotMain::ProcessEvent(Event &event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
SelectObject(obj);
|
SelectObject(obj);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case EVENT_MOUSE_BUTTON_UP:
|
case EVENT_MOUSE_BUTTON_UP:
|
||||||
if (event.mouseButton.button != MOUSE_BUTTON_LEFT) // only left mouse button
|
if (event.GetData<MouseButtonEventData>()->button != MOUSE_BUTTON_LEFT) // only left mouse button
|
||||||
break;
|
break;
|
||||||
|
|
||||||
m_cameraPan = 0.0f;
|
m_cameraPan = 0.0f;
|
||||||
|
@ -1026,8 +1040,11 @@ bool CRobotMain::ProcessEvent(Event &event)
|
||||||
switch (event.type)
|
switch (event.type)
|
||||||
{
|
{
|
||||||
case EVENT_KEY_DOWN:
|
case EVENT_KEY_DOWN:
|
||||||
if (event.key.key == KEY(ESCAPE) ||
|
{
|
||||||
event.key.key == KEY(RETURN))
|
auto data = event.GetData<KeyEventData>();
|
||||||
|
|
||||||
|
if (data->key == KEY(ESCAPE) ||
|
||||||
|
data->key == KEY(RETURN))
|
||||||
{
|
{
|
||||||
if (m_winTerminate)
|
if (m_winTerminate)
|
||||||
ChangePhase(PHASE_MAIN_MENU);
|
ChangePhase(PHASE_MAIN_MENU);
|
||||||
|
@ -1035,6 +1052,7 @@ bool CRobotMain::ProcessEvent(Event &event)
|
||||||
ChangePhase(PHASE_LEVEL_LIST);
|
ChangePhase(PHASE_LEVEL_LIST);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case EVENT_BUTTON_OK:
|
case EVENT_BUTTON_OK:
|
||||||
if (m_winTerminate)
|
if (m_winTerminate)
|
||||||
|
|
|
@ -373,7 +373,7 @@ bool CScript::Continue(const Event &event)
|
||||||
if( m_botProg == 0 ) return true;
|
if( m_botProg == 0 ) return true;
|
||||||
if ( !m_bRun ) return true;
|
if ( !m_bRun ) return true;
|
||||||
|
|
||||||
m_event = event;
|
m_event = event.Clone();
|
||||||
|
|
||||||
if ( m_bStepMode ) // step by step mode?
|
if ( m_bStepMode ) // step by step mode?
|
||||||
{
|
{
|
||||||
|
@ -452,7 +452,7 @@ bool CScript::Step(const Event &event)
|
||||||
// TODO: m_app StepSimulation??? m_engine->StepSimulation(0.01f); // advance of 10ms
|
// TODO: m_app StepSimulation??? m_engine->StepSimulation(0.01f); // advance of 10ms
|
||||||
// ??? m_engine->SetPause(true);
|
// ??? m_engine->SetPause(true);
|
||||||
|
|
||||||
m_event = event;
|
m_event = event.Clone();
|
||||||
|
|
||||||
if ( m_botProg->Run(m_object, 0) ) // step mode
|
if ( m_botProg->Run(m_object, 0) ) // step mode
|
||||||
{
|
{
|
||||||
|
|
|
@ -89,16 +89,14 @@ bool CButton::EventProcess(const Event &event)
|
||||||
{
|
{
|
||||||
m_repeat = DELAY2;
|
m_repeat = DELAY2;
|
||||||
|
|
||||||
Event newEvent = event;
|
m_event->AddEvent(Event(m_eventType));
|
||||||
newEvent.type = m_eventType;
|
|
||||||
m_event->AddEvent(newEvent);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( event.type == EVENT_MOUSE_BUTTON_DOWN &&
|
if ( event.type == EVENT_MOUSE_BUTTON_DOWN &&
|
||||||
event.mouseButton.button == MOUSE_BUTTON_LEFT &&
|
event.GetData<MouseButtonEventData>()->button == MOUSE_BUTTON_LEFT &&
|
||||||
(m_state & STATE_VISIBLE) &&
|
(m_state & STATE_VISIBLE) &&
|
||||||
(m_state & STATE_ENABLE) )
|
(m_state & STATE_ENABLE) )
|
||||||
{
|
{
|
||||||
|
@ -109,9 +107,7 @@ bool CButton::EventProcess(const Event &event)
|
||||||
|
|
||||||
if ( m_bImmediat || m_bRepeat )
|
if ( m_bImmediat || m_bRepeat )
|
||||||
{
|
{
|
||||||
Event newEvent = event;
|
m_event->AddEvent(Event(m_eventType));
|
||||||
newEvent.type = m_eventType;
|
|
||||||
m_event->AddEvent(newEvent);
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -122,16 +118,14 @@ bool CButton::EventProcess(const Event &event)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( event.type == EVENT_MOUSE_BUTTON_UP && //left
|
if ( event.type == EVENT_MOUSE_BUTTON_UP && //left
|
||||||
event.mouseButton.button == MOUSE_BUTTON_LEFT &&
|
event.GetData<MouseButtonEventData>()->button == MOUSE_BUTTON_LEFT &&
|
||||||
m_bCapture )
|
m_bCapture )
|
||||||
{
|
{
|
||||||
if ( CControl::Detect(event.mousePos) )
|
if ( CControl::Detect(event.mousePos) )
|
||||||
{
|
{
|
||||||
if ( !m_bImmediat && !m_bRepeat )
|
if ( !m_bImmediat && !m_bRepeat )
|
||||||
{
|
{
|
||||||
Event newEvent = event;
|
m_event->AddEvent(Event(m_eventType));
|
||||||
newEvent.type = m_eventType;
|
|
||||||
m_event->AddEvent(newEvent);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,15 +70,13 @@ bool CCheck::EventProcess(const Event &event)
|
||||||
CControl::EventProcess(event);
|
CControl::EventProcess(event);
|
||||||
|
|
||||||
if ( event.type == EVENT_MOUSE_BUTTON_DOWN &&
|
if ( event.type == EVENT_MOUSE_BUTTON_DOWN &&
|
||||||
event.mouseButton.button == MOUSE_BUTTON_LEFT &&
|
event.GetData<MouseButtonEventData>()->button == MOUSE_BUTTON_LEFT &&
|
||||||
(m_state & STATE_VISIBLE) &&
|
(m_state & STATE_VISIBLE) &&
|
||||||
(m_state & STATE_ENABLE) )
|
(m_state & STATE_ENABLE) )
|
||||||
{
|
{
|
||||||
if ( CControl::Detect(event.mousePos) )
|
if ( CControl::Detect(event.mousePos) )
|
||||||
{
|
{
|
||||||
Event newEvent = event;
|
m_event->AddEvent(Event(m_eventType));
|
||||||
newEvent.type = m_eventType;
|
|
||||||
m_event->AddEvent(newEvent);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,16 +93,14 @@ bool CColor::EventProcess(const Event &event)
|
||||||
{
|
{
|
||||||
m_repeat = DELAY2;
|
m_repeat = DELAY2;
|
||||||
|
|
||||||
Event newEvent = event;
|
m_event->AddEvent(Event(m_eventType));
|
||||||
newEvent.type = m_eventType;
|
|
||||||
m_event->AddEvent(newEvent);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( event.type == EVENT_MOUSE_BUTTON_DOWN &&
|
if ( event.type == EVENT_MOUSE_BUTTON_DOWN &&
|
||||||
event.mouseButton.button == MOUSE_BUTTON_LEFT &&
|
event.GetData<MouseButtonEventData>()->button == MOUSE_BUTTON_LEFT &&
|
||||||
(m_state & STATE_VISIBLE) &&
|
(m_state & STATE_VISIBLE) &&
|
||||||
(m_state & STATE_ENABLE) )
|
(m_state & STATE_ENABLE) )
|
||||||
{
|
{
|
||||||
|
@ -110,14 +108,13 @@ bool CColor::EventProcess(const Event &event)
|
||||||
{
|
{
|
||||||
m_repeat = DELAY1;
|
m_repeat = DELAY1;
|
||||||
|
|
||||||
Event newEvent = event;
|
m_event->AddEvent(Event(m_eventType));
|
||||||
newEvent.type = m_eventType;
|
|
||||||
m_event->AddEvent(newEvent);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( event.type == EVENT_MOUSE_BUTTON_UP && event.mouseButton.button == MOUSE_BUTTON_LEFT)
|
if (event.type == EVENT_MOUSE_BUTTON_UP &&
|
||||||
|
event.GetData<MouseButtonEventData>()->button == MOUSE_BUTTON_LEFT)
|
||||||
{
|
{
|
||||||
m_repeat = 0.0f;
|
m_repeat = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,16 +62,12 @@ bool CCompass::EventProcess(const Event &event)
|
||||||
{
|
{
|
||||||
CControl::EventProcess(event);
|
CControl::EventProcess(event);
|
||||||
|
|
||||||
if ( event.type == EVENT_MOUSE_BUTTON_DOWN &&
|
if (event.type == EVENT_MOUSE_BUTTON_DOWN &&
|
||||||
event.mouseButton.button == MOUSE_BUTTON_LEFT)
|
event.GetData<MouseButtonEventData>()->button == MOUSE_BUTTON_LEFT &&
|
||||||
|
Detect(event.mousePos))
|
||||||
{
|
{
|
||||||
if ( CControl::Detect(event.mousePos) )
|
m_event->AddEvent(Event(m_eventType));
|
||||||
{
|
return false;
|
||||||
Event newEvent = event;
|
|
||||||
newEvent.type = m_eventType;
|
|
||||||
m_event->AddEvent(newEvent);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -329,7 +329,8 @@ bool CControl::EventProcess(const Event &event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( event.type == EVENT_MOUSE_BUTTON_DOWN && event.mouseButton.button == MOUSE_BUTTON_LEFT)
|
if (event.type == EVENT_MOUSE_BUTTON_DOWN &&
|
||||||
|
event.GetData<MouseButtonEventData>()->button == MOUSE_BUTTON_LEFT)
|
||||||
{
|
{
|
||||||
if ( Detect(event.mousePos) )
|
if ( Detect(event.mousePos) )
|
||||||
{
|
{
|
||||||
|
@ -350,7 +351,9 @@ bool CControl::EventProcess(const Event &event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( event.type == EVENT_MOUSE_BUTTON_UP && m_bCapture && event.mouseButton.button == MOUSE_BUTTON_LEFT)
|
if (event.type == EVENT_MOUSE_BUTTON_UP &&
|
||||||
|
m_bCapture &&
|
||||||
|
event.GetData<MouseButtonEventData>()->button == MOUSE_BUTTON_LEFT)
|
||||||
{
|
{
|
||||||
m_bCapture = false;
|
m_bCapture = false;
|
||||||
ClearState(STATE_PRESS);
|
ClearState(STATE_PRESS);
|
||||||
|
|
|
@ -239,17 +239,17 @@ bool CEdit::EventProcess(const Event &event)
|
||||||
if ( (m_state & STATE_VISIBLE) == 0 ) return true;
|
if ( (m_state & STATE_VISIBLE) == 0 ) return true;
|
||||||
|
|
||||||
if (event.type == EVENT_MOUSE_WHEEL &&
|
if (event.type == EVENT_MOUSE_WHEEL &&
|
||||||
event.mouseWheel.dir == WHEEL_UP &&
|
Detect(event.mousePos))
|
||||||
Detect(event.mousePos) )
|
|
||||||
{
|
{
|
||||||
Scroll(m_lineFirst-3, true);
|
auto data = event.GetData<MouseWheelEventData>();
|
||||||
return true;
|
if (data->dir == WHEEL_UP)
|
||||||
}
|
{
|
||||||
if (event.type == EVENT_MOUSE_WHEEL &&
|
Scroll(m_lineFirst - 3, true);
|
||||||
event.mouseWheel.dir == WHEEL_DOWN &&
|
}
|
||||||
Detect(event.mousePos) )
|
else
|
||||||
{
|
{
|
||||||
Scroll(m_lineFirst+3, true);
|
Scroll(m_lineFirst + 3, true);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -307,95 +307,95 @@ bool CEdit::EventProcess(const Event &event)
|
||||||
|
|
||||||
if ( event.type == EVENT_KEY_DOWN && m_bFocus )
|
if ( event.type == EVENT_KEY_DOWN && m_bFocus )
|
||||||
{
|
{
|
||||||
if ( (event.key.key == KEY(x) && !bShift && bControl) ||
|
auto data = event.GetData<KeyEventData>();
|
||||||
(event.key.key == KEY(DELETE) && bShift && !bControl) )
|
|
||||||
|
if ( (data->key == KEY(x) && !bShift && bControl) ||
|
||||||
|
(data->key == KEY(DELETE) && bShift && !bControl) )
|
||||||
{
|
{
|
||||||
Cut();
|
Cut();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if ( (event.key.key == KEY(c) && !bShift && bControl) ||
|
if ( (data->key == KEY(c) && !bShift && bControl) ||
|
||||||
(event.key.key == KEY(INSERT) && !bShift && bControl) )
|
(data->key == KEY(INSERT) && !bShift && bControl) )
|
||||||
{
|
{
|
||||||
Copy();
|
Copy();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if ( (event.key.key == KEY(v) && !bShift && bControl) ||
|
if ( (data->key == KEY(v) && !bShift && bControl) ||
|
||||||
(event.key.key == KEY(INSERT) && bShift && !bControl) )
|
(data->key == KEY(INSERT) && bShift && !bControl) )
|
||||||
{
|
{
|
||||||
Paste();
|
Paste();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( event.key.key == KEY(a) && !bShift && bControl )
|
if ( data->key == KEY(a) && !bShift && bControl )
|
||||||
{
|
{
|
||||||
SetCursor(999999, 0);
|
SetCursor(999999, 0);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( event.key.key == KEY(o) && !bShift && bControl )
|
if ( data->key == KEY(o) && !bShift && bControl )
|
||||||
{
|
{
|
||||||
Event newEvent(EVENT_STUDIO_OPEN);
|
m_event->AddEvent(Event(EVENT_STUDIO_OPEN));
|
||||||
m_event->AddEvent(newEvent);
|
|
||||||
}
|
}
|
||||||
if ( event.key.key == KEY(s) && !bShift && bControl )
|
if ( data->key == KEY(s) && !bShift && bControl )
|
||||||
{
|
{
|
||||||
Event newEvent( EVENT_STUDIO_SAVE );
|
m_event->AddEvent(Event(EVENT_STUDIO_SAVE));
|
||||||
m_event->AddEvent(newEvent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( event.key.key == KEY(z) && !bShift && bControl )
|
if ( data->key == KEY(z) && !bShift && bControl )
|
||||||
{
|
{
|
||||||
Undo();
|
Undo();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( event.key.key == KEY(u) && !bShift && bControl )
|
if ( data->key == KEY(u) && !bShift && bControl )
|
||||||
{
|
{
|
||||||
if ( MinMaj(false) ) return true;
|
if ( MinMaj(false) ) return true;
|
||||||
}
|
}
|
||||||
if ( event.key.key == KEY(u) && bShift && bControl )
|
if ( data->key == KEY(u) && bShift && bControl )
|
||||||
{
|
{
|
||||||
if ( MinMaj(true) ) return true;
|
if ( MinMaj(true) ) return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( event.key.key == KEY(TAB) && !bShift && !bControl && !m_bAutoIndent )
|
if ( data->key == KEY(TAB) && !bShift && !bControl && !m_bAutoIndent )
|
||||||
{
|
{
|
||||||
if ( Shift(false) ) return true;
|
if ( Shift(false) ) return true;
|
||||||
}
|
}
|
||||||
if ( event.key.key == KEY(TAB) && bShift && !bControl && !m_bAutoIndent )
|
if ( data->key == KEY(TAB) && bShift && !bControl && !m_bAutoIndent )
|
||||||
{
|
{
|
||||||
if ( Shift(true) ) return true;
|
if ( Shift(true) ) return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( m_bEdit )
|
if ( m_bEdit )
|
||||||
{
|
{
|
||||||
if ( event.key.key == KEY(LEFT) )
|
if ( data->key == KEY(LEFT) )
|
||||||
{
|
{
|
||||||
MoveChar(-1, bControl, bShift);
|
MoveChar(-1, bControl, bShift);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if ( event.key.key == KEY(RIGHT) )
|
if ( data->key == KEY(RIGHT) )
|
||||||
{
|
{
|
||||||
MoveChar(1, bControl, bShift);
|
MoveChar(1, bControl, bShift);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if ( event.key.key == KEY(UP) && m_bMulti )
|
if ( data->key == KEY(UP) && m_bMulti )
|
||||||
{
|
{
|
||||||
MoveLine(-1, bControl, bShift);
|
MoveLine(-1, bControl, bShift);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if ( event.key.key == KEY(DOWN) && m_bMulti )
|
if ( data->key == KEY(DOWN) && m_bMulti )
|
||||||
{
|
{
|
||||||
MoveLine(1, bControl, bShift);
|
MoveLine(1, bControl, bShift);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( event.key.key == KEY(PAGEUP) && m_bMulti ) // PageUp ?
|
if ( data->key == KEY(PAGEUP) && m_bMulti ) // PageUp ?
|
||||||
{
|
{
|
||||||
MoveLine(-(m_lineVisible-1), bControl, bShift);
|
MoveLine(-(m_lineVisible-1), bControl, bShift);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if ( event.key.key == KEY(PAGEDOWN) && m_bMulti ) // PageDown ?
|
if ( data->key == KEY(PAGEDOWN) && m_bMulti ) // PageDown ?
|
||||||
{
|
{
|
||||||
MoveLine(m_lineVisible-1, bControl, bShift);
|
MoveLine(m_lineVisible-1, bControl, bShift);
|
||||||
return true;
|
return true;
|
||||||
|
@ -403,62 +403,62 @@ bool CEdit::EventProcess(const Event &event)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( event.key.key == KEY(LEFT) ||
|
if ( data->key == KEY(LEFT) ||
|
||||||
event.key.key == KEY(UP) )
|
data->key == KEY(UP) )
|
||||||
{
|
{
|
||||||
Scroll(m_lineFirst-1, true);
|
Scroll(m_lineFirst-1, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if ( event.key.key == KEY(RIGHT) ||
|
if ( data->key == KEY(RIGHT) ||
|
||||||
event.key.key == KEY(DOWN) )
|
data->key == KEY(DOWN) )
|
||||||
{
|
{
|
||||||
Scroll(m_lineFirst+1, true);
|
Scroll(m_lineFirst+1, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( event.key.key == KEY(PAGEUP) ) // PageUp ?
|
if ( data->key == KEY(PAGEUP) ) // PageUp ?
|
||||||
{
|
{
|
||||||
Scroll(m_lineFirst-(m_lineVisible-1), true);
|
Scroll(m_lineFirst-(m_lineVisible-1), true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if ( event.key.key == KEY(PAGEDOWN) ) // PageDown ?
|
if ( data->key == KEY(PAGEDOWN) ) // PageDown ?
|
||||||
{
|
{
|
||||||
Scroll(m_lineFirst+(m_lineVisible-1), true);
|
Scroll(m_lineFirst+(m_lineVisible-1), true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( event.key.key == KEY(HOME) )
|
if ( data->key == KEY(HOME) )
|
||||||
{
|
{
|
||||||
MoveHome(bControl, bShift);
|
MoveHome(bControl, bShift);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if ( event.key.key == KEY(END) )
|
if ( data->key == KEY(END) )
|
||||||
{
|
{
|
||||||
MoveEnd(bControl, bShift);
|
MoveEnd(bControl, bShift);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( event.key.key == KEY(BACKSPACE) && !bControl ) // backspace ( <- ) ?
|
if ( data->key == KEY(BACKSPACE) && !bControl ) // backspace ( <- ) ?
|
||||||
{
|
{
|
||||||
Delete(-1);
|
Delete(-1);
|
||||||
SendModifEvent();
|
SendModifEvent();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if ( event.key.key == KEY(DELETE) && !bControl )
|
if ( data->key == KEY(DELETE) && !bControl )
|
||||||
{
|
{
|
||||||
Delete(1);
|
Delete(1);
|
||||||
SendModifEvent();
|
SendModifEvent();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( event.key.key == KEY(RETURN) && !bControl )
|
if ( data->key == KEY(RETURN) && !bControl )
|
||||||
{
|
{
|
||||||
Insert('\n');
|
Insert('\n');
|
||||||
SendModifEvent();
|
SendModifEvent();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if ( event.key.key == KEY(TAB) && !bControl )
|
if ( data->key == KEY(TAB) && !bControl )
|
||||||
{
|
{
|
||||||
Insert('\t');
|
Insert('\t');
|
||||||
SendModifEvent();
|
SendModifEvent();
|
||||||
|
@ -468,9 +468,10 @@ bool CEdit::EventProcess(const Event &event)
|
||||||
|
|
||||||
if ( event.type == EVENT_KEY_DOWN && !bControl && m_bFocus )
|
if ( event.type == EVENT_KEY_DOWN && !bControl && m_bFocus )
|
||||||
{
|
{
|
||||||
if (event.key.unicode >= ' ')
|
auto data = event.GetData<KeyEventData>();
|
||||||
|
if (data->unicode >= ' ')
|
||||||
{
|
{
|
||||||
Insert(static_cast<char>(event.key.unicode)); // TODO: insert utf-8 char
|
Insert(static_cast<char>(data->unicode)); // TODO: insert utf-8 char
|
||||||
SendModifEvent();
|
SendModifEvent();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -488,8 +489,8 @@ bool CEdit::EventProcess(const Event &event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( event.type == EVENT_MOUSE_BUTTON_DOWN &&
|
if (event.type == EVENT_MOUSE_BUTTON_DOWN &&
|
||||||
event.mouseButton.button == MOUSE_BUTTON_LEFT)
|
event.GetData<MouseButtonEventData>()->button == MOUSE_BUTTON_LEFT)
|
||||||
{
|
{
|
||||||
m_mouseFirstPos = event.mousePos;
|
m_mouseFirstPos = event.mousePos;
|
||||||
m_mouseLastPos = event.mousePos;
|
m_mouseLastPos = event.mousePos;
|
||||||
|
@ -519,8 +520,8 @@ bool CEdit::EventProcess(const Event &event)
|
||||||
MouseMove(m_mouseLastPos);
|
MouseMove(m_mouseLastPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( event.type == EVENT_MOUSE_BUTTON_UP &&
|
if (event.type == EVENT_MOUSE_BUTTON_UP &&
|
||||||
event.mouseButton.button == MOUSE_BUTTON_LEFT)
|
event.GetData<MouseButtonEventData>()->button == MOUSE_BUTTON_LEFT)
|
||||||
{
|
{
|
||||||
if ( Detect(event.mousePos) )
|
if ( Detect(event.mousePos) )
|
||||||
{
|
{
|
||||||
|
@ -548,10 +549,7 @@ bool CEdit::EventProcess(const Event &event)
|
||||||
|
|
||||||
void CEdit::SendModifEvent()
|
void CEdit::SendModifEvent()
|
||||||
{
|
{
|
||||||
Event newEvent (m_eventType);
|
m_event->AddEvent(Event(m_eventType));
|
||||||
|
|
||||||
// m_event->MakeEvent(newEvent, m_eventType);
|
|
||||||
m_event->AddEvent(newEvent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -157,7 +157,7 @@ bool CEditValue::EventProcess(const Event &event)
|
||||||
{
|
{
|
||||||
if ( m_edit->GetFocus() &&
|
if ( m_edit->GetFocus() &&
|
||||||
event.type == EVENT_KEY_DOWN &&
|
event.type == EVENT_KEY_DOWN &&
|
||||||
event.key.key == KEY(RETURN) )
|
event.GetData<KeyEventData>()->key == KEY(RETURN) )
|
||||||
{
|
{
|
||||||
value = GetValue();
|
value = GetValue();
|
||||||
if ( value > m_maxValue ) value = m_maxValue;
|
if ( value > m_maxValue ) value = m_maxValue;
|
||||||
|
@ -169,8 +169,7 @@ bool CEditValue::EventProcess(const Event &event)
|
||||||
|
|
||||||
if ( event.type == m_edit->GetEventType() )
|
if ( event.type == m_edit->GetEventType() )
|
||||||
{
|
{
|
||||||
Event newEvent(m_eventType);
|
m_event->AddEvent(Event(m_eventType));
|
||||||
m_event->AddEvent(newEvent);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,7 +198,7 @@ bool CEditValue::EventProcess(const Event &event)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.type == EVENT_MOUSE_WHEEL &&
|
if (event.type == EVENT_MOUSE_WHEEL &&
|
||||||
event.mouseWheel.dir == WHEEL_UP &&
|
event.GetData<MouseWheelEventData>()->dir == WHEEL_UP &&
|
||||||
Detect(event.mousePos))
|
Detect(event.mousePos))
|
||||||
{
|
{
|
||||||
value = GetValue()+m_stepValue;
|
value = GetValue()+m_stepValue;
|
||||||
|
@ -207,8 +206,8 @@ bool CEditValue::EventProcess(const Event &event)
|
||||||
SetValue(value, true);
|
SetValue(value, true);
|
||||||
HiliteValue(event);
|
HiliteValue(event);
|
||||||
}
|
}
|
||||||
if ( event.type == EVENT_KEY_DOWN &&
|
if ( event.type == EVENT_MOUSE_WHEEL &&
|
||||||
event.mouseWheel.dir == WHEEL_DOWN &&
|
event.GetData<MouseWheelEventData>()->dir == WHEEL_DOWN &&
|
||||||
Detect(event.mousePos))
|
Detect(event.mousePos))
|
||||||
{
|
{
|
||||||
value = GetValue()-m_stepValue;
|
value = GetValue()-m_stepValue;
|
||||||
|
@ -238,10 +237,10 @@ void CEditValue::HiliteValue(const Event &event)
|
||||||
m_edit->SetCursor(pos, 0);
|
m_edit->SetCursor(pos, 0);
|
||||||
m_interface->SetFocus(m_edit);
|
m_interface->SetFocus(m_edit);
|
||||||
|
|
||||||
Event newEvent = event;
|
Event newEvent = event.Clone();
|
||||||
newEvent.type = EVENT_FOCUS;
|
newEvent.type = EVENT_FOCUS;
|
||||||
newEvent.customParam = m_edit->GetEventType();
|
newEvent.customParam = m_edit->GetEventType();
|
||||||
m_event->AddEvent(newEvent); // defocus the other objects
|
m_event->AddEvent(std::move(newEvent)); // defocus the other objects
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -315,8 +314,7 @@ void CEditValue::SetValue(float value, bool bSendMessage)
|
||||||
|
|
||||||
if ( bSendMessage )
|
if ( bSendMessage )
|
||||||
{
|
{
|
||||||
Event newEvent(m_eventType);
|
m_event->AddEvent(Event(m_eventType));
|
||||||
m_event->AddEvent(newEvent);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,9 +60,7 @@ bool CGauge::EventProcess(const Event &event)
|
||||||
{
|
{
|
||||||
if ( CControl::Detect(event.mousePos) )
|
if ( CControl::Detect(event.mousePos) )
|
||||||
{
|
{
|
||||||
Event newEvent = event;
|
m_event->AddEvent(Event(m_eventType));
|
||||||
newEvent.type = m_eventType;
|
|
||||||
m_event->AddEvent(newEvent);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,14 +68,14 @@ bool CKey::EventProcess(const Event &event)
|
||||||
|
|
||||||
if (event.type == EVENT_MOUSE_BUTTON_DOWN)
|
if (event.type == EVENT_MOUSE_BUTTON_DOWN)
|
||||||
{
|
{
|
||||||
if (event.mouseButton.button == MOUSE_BUTTON_LEFT) // left
|
if (event.GetData<MouseButtonEventData>()->button == MOUSE_BUTTON_LEFT) // left
|
||||||
m_catch = Detect(event.mousePos);
|
m_catch = Detect(event.mousePos);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.type == EVENT_KEY_DOWN && m_catch)
|
if (event.type == EVENT_KEY_DOWN && m_catch)
|
||||||
{
|
{
|
||||||
m_catch = false;
|
m_catch = false;
|
||||||
unsigned int key = GetVirtualKey(event.key.key);
|
unsigned int key = GetVirtualKey(event.GetData<KeyEventData>()->key);
|
||||||
|
|
||||||
if (TestKey(key)) // impossible ?
|
if (TestKey(key)) // impossible ?
|
||||||
{
|
{
|
||||||
|
@ -95,9 +95,7 @@ bool CKey::EventProcess(const Event &event)
|
||||||
}
|
}
|
||||||
m_sound->Play(SOUND_CLICK);
|
m_sound->Play(SOUND_CLICK);
|
||||||
|
|
||||||
Event newEvent = event;
|
m_event->AddEvent(Event(m_eventType));
|
||||||
newEvent.type = m_eventType;
|
|
||||||
m_event->AddEvent(newEvent);
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -270,10 +270,9 @@ bool CList::ClearState(int state)
|
||||||
|
|
||||||
bool CList::EventProcess(const Event &event)
|
bool CList::EventProcess(const Event &event)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
if (m_bBlink && event.type == EVENT_FRAME)
|
if (m_bBlink && event.type == EVENT_FRAME)
|
||||||
{
|
{
|
||||||
i = m_selectLine-m_firstLine;
|
int i = m_selectLine-m_firstLine;
|
||||||
|
|
||||||
if (i >= 0 && i < 4 && m_button[i] != nullptr)
|
if (i >= 0 && i < 4 && m_button[i] != nullptr)
|
||||||
{
|
{
|
||||||
|
@ -296,19 +295,20 @@ bool CList::EventProcess(const Event &event)
|
||||||
if ((m_state & STATE_ENABLE) == 0)
|
if ((m_state & STATE_ENABLE) == 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (event.type == EVENT_MOUSE_WHEEL && event.mouseWheel.dir == WHEEL_UP && Detect(event.mousePos))
|
if (event.type == EVENT_MOUSE_WHEEL && Detect(event.mousePos))
|
||||||
{
|
{
|
||||||
if (m_firstLine > 0)
|
auto data = event.GetData<MouseWheelEventData>();
|
||||||
m_firstLine--;
|
if (data->dir == WHEEL_UP)
|
||||||
UpdateScroll();
|
{
|
||||||
UpdateButton();
|
if (m_firstLine > 0)
|
||||||
return true;
|
m_firstLine--;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (m_firstLine < m_totalLine - m_displayLine)
|
||||||
|
m_firstLine++;
|
||||||
|
}
|
||||||
|
|
||||||
if (event.type == EVENT_MOUSE_WHEEL && event.mouseWheel.dir == WHEEL_DOWN && Detect(event.mousePos))
|
|
||||||
{
|
|
||||||
if (m_firstLine < m_totalLine - m_displayLine)
|
|
||||||
m_firstLine++;
|
|
||||||
UpdateScroll();
|
UpdateScroll();
|
||||||
UpdateButton();
|
UpdateButton();
|
||||||
return true;
|
return true;
|
||||||
|
@ -319,7 +319,7 @@ bool CList::EventProcess(const Event &event)
|
||||||
if (event.type == EVENT_MOUSE_MOVE && Detect(event.mousePos))
|
if (event.type == EVENT_MOUSE_MOVE && Detect(event.mousePos))
|
||||||
{
|
{
|
||||||
m_engine->SetMouseType(Gfx::ENG_MOUSE_NORM);
|
m_engine->SetMouseType(Gfx::ENG_MOUSE_NORM);
|
||||||
for (i = 0; i < m_displayLine; i++)
|
for (int i = 0; i < m_displayLine; i++)
|
||||||
{
|
{
|
||||||
if (i + m_firstLine >= m_totalLine)
|
if (i + m_firstLine >= m_totalLine)
|
||||||
break;
|
break;
|
||||||
|
@ -330,7 +330,7 @@ bool CList::EventProcess(const Event &event)
|
||||||
|
|
||||||
if (m_bSelectCap)
|
if (m_bSelectCap)
|
||||||
{
|
{
|
||||||
for (i = 0; i < m_displayLine; i++)
|
for (int i = 0; i < m_displayLine; i++)
|
||||||
{
|
{
|
||||||
if (i + m_firstLine >= m_totalLine)
|
if (i + m_firstLine >= m_totalLine)
|
||||||
break;
|
break;
|
||||||
|
@ -344,9 +344,7 @@ bool CList::EventProcess(const Event &event)
|
||||||
{
|
{
|
||||||
SetSelect(m_firstLine + i);
|
SetSelect(m_firstLine + i);
|
||||||
|
|
||||||
Event newEvent = event;
|
m_event->AddEvent(Event(m_eventType)); // selected line changes
|
||||||
newEvent.type = m_eventType;
|
|
||||||
m_event->AddEvent(newEvent); // selected line changes
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -191,8 +191,6 @@ bool CMap::GetFixImage()
|
||||||
|
|
||||||
bool CMap::EventProcess(const Event &event)
|
bool CMap::EventProcess(const Event &event)
|
||||||
{
|
{
|
||||||
bool bInMap;
|
|
||||||
|
|
||||||
if ( (m_state & STATE_VISIBLE) == 0 )
|
if ( (m_state & STATE_VISIBLE) == 0 )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -204,11 +202,13 @@ bool CMap::EventProcess(const Event &event)
|
||||||
if ( event.type == EVENT_MOUSE_MOVE && Detect(event.mousePos) )
|
if ( event.type == EVENT_MOUSE_MOVE && Detect(event.mousePos) )
|
||||||
{
|
{
|
||||||
m_engine->SetMouseType(Gfx::ENG_MOUSE_NORM);
|
m_engine->SetMouseType(Gfx::ENG_MOUSE_NORM);
|
||||||
if ( DetectObject(event.mousePos, bInMap) != 0 )
|
bool inMap = false;
|
||||||
|
if (DetectObject(event.mousePos, inMap) != nullptr)
|
||||||
m_engine->SetMouseType(Gfx::ENG_MOUSE_HAND);
|
m_engine->SetMouseType(Gfx::ENG_MOUSE_HAND);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( event.type == EVENT_MOUSE_BUTTON_DOWN && event.mouseButton.button == MOUSE_BUTTON_LEFT )
|
if (event.type == EVENT_MOUSE_BUTTON_DOWN &&
|
||||||
|
event.GetData<MouseButtonEventData>()->button == MOUSE_BUTTON_LEFT)
|
||||||
{
|
{
|
||||||
if ( CControl::Detect(event.mousePos) )
|
if ( CControl::Detect(event.mousePos) )
|
||||||
{
|
{
|
||||||
|
|
|
@ -218,9 +218,7 @@ bool CScroll::EventProcess(const Event &event)
|
||||||
if ( m_visibleValue < 0.0f ) m_visibleValue = 0.0f;
|
if ( m_visibleValue < 0.0f ) m_visibleValue = 0.0f;
|
||||||
AdjustGlint();
|
AdjustGlint();
|
||||||
|
|
||||||
Event newEvent = event;
|
m_event->AddEvent(Event(m_eventType));
|
||||||
newEvent.type = m_eventType;
|
|
||||||
m_event->AddEvent(newEvent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( event.type == m_eventDown && m_step > 0.0f )
|
if ( event.type == m_eventDown && m_step > 0.0f )
|
||||||
|
@ -229,17 +227,15 @@ bool CScroll::EventProcess(const Event &event)
|
||||||
if ( m_visibleValue > 1.0f ) m_visibleValue = 1.0f;
|
if ( m_visibleValue > 1.0f ) m_visibleValue = 1.0f;
|
||||||
AdjustGlint();
|
AdjustGlint();
|
||||||
|
|
||||||
Event newEvent = event;
|
m_event->AddEvent(Event(m_eventType));
|
||||||
newEvent.type = m_eventType;
|
|
||||||
m_event->AddEvent(newEvent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hButton = m_buttonUp?m_dim.x/0.75f:0.0f;
|
hButton = m_buttonUp?m_dim.x/0.75f:0.0f;
|
||||||
|
|
||||||
if ( event.type == EVENT_MOUSE_BUTTON_DOWN &&
|
if (event.type == EVENT_MOUSE_BUTTON_DOWN &&
|
||||||
event.mouseButton.button == MOUSE_BUTTON_LEFT &&
|
event.GetData<MouseButtonEventData>()->button == MOUSE_BUTTON_LEFT &&
|
||||||
(m_state & STATE_VISIBLE) &&
|
(m_state & STATE_VISIBLE) &&
|
||||||
(m_state & STATE_ENABLE) )
|
(m_state & STATE_ENABLE) )
|
||||||
{
|
{
|
||||||
if ( CControl::Detect(event.mousePos) )
|
if ( CControl::Detect(event.mousePos) )
|
||||||
{
|
{
|
||||||
|
@ -257,9 +253,7 @@ bool CScroll::EventProcess(const Event &event)
|
||||||
m_visibleValue = value;
|
m_visibleValue = value;
|
||||||
AdjustGlint();
|
AdjustGlint();
|
||||||
|
|
||||||
Event newEvent = event;
|
m_event->AddEvent(Event(m_eventType));
|
||||||
newEvent.type = m_eventType;
|
|
||||||
m_event->AddEvent(newEvent);
|
|
||||||
}
|
}
|
||||||
m_bCapture = true;
|
m_bCapture = true;
|
||||||
m_pressPos = event.mousePos;
|
m_pressPos = event.mousePos;
|
||||||
|
@ -281,37 +275,31 @@ bool CScroll::EventProcess(const Event &event)
|
||||||
m_visibleValue = value;
|
m_visibleValue = value;
|
||||||
AdjustGlint();
|
AdjustGlint();
|
||||||
|
|
||||||
Event newEvent = event;
|
m_event->AddEvent(Event(m_eventType));
|
||||||
newEvent.type = m_eventType;
|
|
||||||
m_event->AddEvent(newEvent);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( event.type == EVENT_MOUSE_BUTTON_UP &&
|
if (event.type == EVENT_MOUSE_BUTTON_UP &&
|
||||||
event.mouseButton.button == MOUSE_BUTTON_LEFT &&
|
event.GetData<MouseButtonEventData>()->button == MOUSE_BUTTON_LEFT &&
|
||||||
m_bCapture )
|
m_bCapture)
|
||||||
{
|
{
|
||||||
m_bCapture = false;
|
m_bCapture = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.type == EVENT_MOUSE_WHEEL &&
|
if (event.type == EVENT_MOUSE_WHEEL &&
|
||||||
event.mouseWheel.dir == WHEEL_UP &&
|
event.GetData<MouseWheelEventData>()->dir == WHEEL_UP &&
|
||||||
Detect(event.mousePos) &&
|
Detect(event.mousePos) &&
|
||||||
m_buttonUp != 0)
|
m_buttonUp != nullptr)
|
||||||
{
|
{
|
||||||
Event newEvent = event;
|
m_event->AddEvent(Event(m_buttonUp->GetEventType()));
|
||||||
newEvent.type = m_buttonUp->GetEventType();
|
|
||||||
m_event->AddEvent(newEvent);
|
|
||||||
}
|
}
|
||||||
if (event.type == EVENT_MOUSE_WHEEL &&
|
if (event.type == EVENT_MOUSE_WHEEL &&
|
||||||
event.mouseWheel.dir == WHEEL_DOWN &&
|
event.GetData<MouseWheelEventData>()->dir == WHEEL_DOWN &&
|
||||||
Detect(event.mousePos) &&
|
Detect(event.mousePos) &&
|
||||||
m_buttonDown != 0)
|
m_buttonDown != nullptr)
|
||||||
{
|
{
|
||||||
Event newEvent = event;
|
m_event->AddEvent(Event(m_buttonDown->GetEventType()));
|
||||||
newEvent.type = m_buttonDown->GetEventType();
|
|
||||||
m_event->AddEvent(newEvent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -68,14 +68,12 @@ bool CShortcut::EventProcess(const Event &event)
|
||||||
m_time += event.rTime;
|
m_time += event.rTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( event.type == EVENT_MOUSE_BUTTON_DOWN &&
|
if (event.type == EVENT_MOUSE_BUTTON_DOWN &&
|
||||||
event.mouseButton.button == MOUSE_BUTTON_LEFT)
|
event.GetData<MouseButtonEventData>()->button == MOUSE_BUTTON_LEFT)
|
||||||
{
|
{
|
||||||
if ( CControl::Detect(event.mousePos) )
|
if ( CControl::Detect(event.mousePos) )
|
||||||
{
|
{
|
||||||
Event newEvent = event;
|
m_event->AddEvent(Event(m_eventType));
|
||||||
newEvent.type = m_eventType;
|
|
||||||
m_event->AddEvent(newEvent);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -270,9 +270,7 @@ bool CSlider::EventProcess(const Event &event)
|
||||||
if ( m_visibleValue > 1.0f ) m_visibleValue = 1.0f;
|
if ( m_visibleValue > 1.0f ) m_visibleValue = 1.0f;
|
||||||
AdjustGlint();
|
AdjustGlint();
|
||||||
|
|
||||||
Event newEvent = event;
|
m_event->AddEvent(Event(m_eventType));
|
||||||
newEvent.type = m_eventType;
|
|
||||||
m_event->AddEvent(newEvent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( event.type == m_eventDown && m_step > 0.0f )
|
if ( event.type == m_eventDown && m_step > 0.0f )
|
||||||
|
@ -282,15 +280,13 @@ bool CSlider::EventProcess(const Event &event)
|
||||||
if ( m_visibleValue > 1.0f ) m_visibleValue = 1.0f;
|
if ( m_visibleValue > 1.0f ) m_visibleValue = 1.0f;
|
||||||
AdjustGlint();
|
AdjustGlint();
|
||||||
|
|
||||||
Event newEvent = event;
|
m_event->AddEvent(Event(m_eventType));
|
||||||
newEvent.type = m_eventType;
|
|
||||||
m_event->AddEvent(newEvent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( event.type == EVENT_MOUSE_BUTTON_DOWN &&
|
if (event.type == EVENT_MOUSE_BUTTON_DOWN &&
|
||||||
(event.mouseButton.button == MOUSE_BUTTON_LEFT ) &&
|
event.GetData<MouseButtonEventData>()->button == MOUSE_BUTTON_LEFT &&
|
||||||
(m_state & STATE_VISIBLE) &&
|
(m_state & STATE_VISIBLE) &&
|
||||||
(m_state & STATE_ENABLE) )
|
(m_state & STATE_ENABLE))
|
||||||
{
|
{
|
||||||
if ( CControl::Detect(event.mousePos) )
|
if ( CControl::Detect(event.mousePos) )
|
||||||
{
|
{
|
||||||
|
@ -313,9 +309,7 @@ bool CSlider::EventProcess(const Event &event)
|
||||||
m_visibleValue = value;
|
m_visibleValue = value;
|
||||||
AdjustGlint();
|
AdjustGlint();
|
||||||
|
|
||||||
Event newEvent = event;
|
m_event->AddEvent(Event(m_eventType));
|
||||||
newEvent.type = m_eventType;
|
|
||||||
m_event->AddEvent(newEvent);
|
|
||||||
|
|
||||||
m_bCapture = true;
|
m_bCapture = true;
|
||||||
m_pressPos = event.mousePos;
|
m_pressPos = event.mousePos;
|
||||||
|
@ -347,37 +341,31 @@ bool CSlider::EventProcess(const Event &event)
|
||||||
m_visibleValue = value;
|
m_visibleValue = value;
|
||||||
AdjustGlint();
|
AdjustGlint();
|
||||||
|
|
||||||
Event newEvent = event;
|
m_event->AddEvent(Event(m_eventType));
|
||||||
newEvent.type = m_eventType;
|
|
||||||
m_event->AddEvent(newEvent);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ( event.type == EVENT_MOUSE_BUTTON_UP ) &&
|
if (event.type == EVENT_MOUSE_BUTTON_UP &&
|
||||||
( event.mouseButton.button == MOUSE_BUTTON_LEFT ) &&
|
event.GetData<MouseButtonEventData>()->button == MOUSE_BUTTON_LEFT &&
|
||||||
m_bCapture )
|
m_bCapture)
|
||||||
{
|
{
|
||||||
m_bCapture = false;
|
m_bCapture = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.type == EVENT_MOUSE_WHEEL &&
|
if (event.type == EVENT_MOUSE_WHEEL &&
|
||||||
event.mouseWheel.dir == WHEEL_UP &&
|
event.GetData<MouseWheelEventData>()->dir == WHEEL_UP &&
|
||||||
Detect(event.mousePos) &&
|
Detect(event.mousePos) &&
|
||||||
m_buttonLeft != 0)
|
m_buttonLeft != nullptr)
|
||||||
{
|
{
|
||||||
Event newEvent = event;
|
m_event->AddEvent(Event(m_buttonLeft->GetEventType()));
|
||||||
newEvent.type = m_buttonLeft->GetEventType();
|
|
||||||
m_event->AddEvent(newEvent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.type == EVENT_MOUSE_WHEEL &&
|
if (event.type == EVENT_MOUSE_WHEEL &&
|
||||||
event.mouseWheel.dir == WHEEL_DOWN &&
|
event.GetData<MouseWheelEventData>()->dir == WHEEL_DOWN &&
|
||||||
Detect(event.mousePos) &&
|
Detect(event.mousePos) &&
|
||||||
m_buttonRight != 0)
|
m_buttonRight != nullptr)
|
||||||
{
|
{
|
||||||
Event newEvent = event;
|
m_event->AddEvent(Event(m_buttonRight->GetEventType()));
|
||||||
newEvent.type = m_buttonRight->GetEventType();
|
|
||||||
m_event->AddEvent(newEvent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -74,7 +74,7 @@ bool CTarget::EventProcess(const Event &event)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( event.type == EVENT_MOUSE_BUTTON_DOWN &&
|
if ( event.type == EVENT_MOUSE_BUTTON_DOWN &&
|
||||||
event.mouseButton.button == MOUSE_BUTTON_LEFT &&
|
event.GetData<MouseButtonEventData>()->button == MOUSE_BUTTON_LEFT &&
|
||||||
(m_state & STATE_VISIBLE) &&
|
(m_state & STATE_VISIBLE) &&
|
||||||
(m_state & STATE_ENABLE) )
|
(m_state & STATE_ENABLE) )
|
||||||
{
|
{
|
||||||
|
@ -107,9 +107,7 @@ bool CTarget::EventProcess(const Event &event)
|
||||||
{
|
{
|
||||||
m_engine->SetMouseType(Gfx::ENG_MOUSE_TARGET);
|
m_engine->SetMouseType(Gfx::ENG_MOUSE_TARGET);
|
||||||
|
|
||||||
Event newEvent = event;
|
m_event->AddEvent(Event(m_eventType));
|
||||||
newEvent.type = m_eventType;
|
|
||||||
m_event->AddEvent(newEvent);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -120,18 +118,16 @@ bool CTarget::EventProcess(const Event &event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( event.type == EVENT_MOUSE_BUTTON_DOWN &&
|
if (event.type == EVENT_MOUSE_BUTTON_DOWN &&
|
||||||
event.mouseButton.button == MOUSE_BUTTON_LEFT &&
|
event.GetData<MouseButtonEventData>()->button == MOUSE_BUTTON_LEFT &&
|
||||||
(m_state & STATE_VISIBLE) &&
|
(m_state & STATE_VISIBLE) &&
|
||||||
(m_state & STATE_ENABLE) )
|
(m_state & STATE_ENABLE))
|
||||||
{
|
{
|
||||||
if ( CControl::Detect(event.mousePos) )
|
if ( CControl::Detect(event.mousePos) )
|
||||||
{
|
{
|
||||||
if ( !m_main->GetFriendAim() )
|
if ( !m_main->GetFriendAim() )
|
||||||
{
|
{
|
||||||
Event newEvent = event;
|
m_event->AddEvent(Event(EVENT_OBJECT_FIRE));
|
||||||
newEvent.type = EVENT_OBJECT_FIRE;
|
|
||||||
m_event->AddEvent(newEvent);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -998,8 +998,9 @@ bool CWindow::EventProcess(const Event &event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( m_bTrashEvent && event.type == EVENT_MOUSE_BUTTON_DOWN &&
|
if (m_bTrashEvent &&
|
||||||
event.mouseButton.button == MOUSE_BUTTON_LEFT)
|
event.type == EVENT_MOUSE_BUTTON_DOWN &&
|
||||||
|
event.GetData<MouseButtonEventData>()->button == MOUSE_BUTTON_LEFT)
|
||||||
{
|
{
|
||||||
if ( Detect(event.mousePos) )
|
if ( Detect(event.mousePos) )
|
||||||
{
|
{
|
||||||
|
@ -1064,12 +1065,12 @@ bool CWindow::EventProcess(const Event &event)
|
||||||
m_pressPos = pos;
|
m_pressPos = pos;
|
||||||
AdjustButtons();
|
AdjustButtons();
|
||||||
|
|
||||||
Event newEvent = event;
|
m_event->AddEvent(Event(m_eventType));
|
||||||
newEvent.type = m_eventType;
|
|
||||||
m_event->AddEvent(newEvent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( event.type == EVENT_MOUSE_BUTTON_UP && event.mouseButton.button == MOUSE_BUTTON_LEFT && m_bCapture )
|
if (event.type == EVENT_MOUSE_BUTTON_UP &&
|
||||||
|
event.GetData<MouseButtonEventData>()->button == MOUSE_BUTTON_LEFT &&
|
||||||
|
m_bCapture )
|
||||||
{
|
{
|
||||||
m_bCapture = false;
|
m_bCapture = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,9 +116,7 @@ bool CDisplayInfo::EventProcess(const Event &event)
|
||||||
{
|
{
|
||||||
if ( event.type == pw->GetEventTypeClose() )
|
if ( event.type == pw->GetEventTypeClose() )
|
||||||
{
|
{
|
||||||
Event newEvent = event;
|
m_event->AddEvent(Event(EVENT_OBJECT_INFOOK));
|
||||||
newEvent.type = EVENT_OBJECT_INFOOK;
|
|
||||||
m_event->AddEvent(newEvent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( event.type == EVENT_SATCOM_HUSTON )
|
if ( event.type == EVENT_SATCOM_HUSTON )
|
||||||
|
@ -204,8 +202,8 @@ bool CDisplayInfo::EventProcess(const Event &event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ( event.type == EVENT_MOUSE_BUTTON_DOWN && event.mouseButton.button == MOUSE_BUTTON_LEFT )||
|
if ((event.type == EVENT_MOUSE_BUTTON_DOWN || event.type == EVENT_MOUSE_BUTTON_UP) &&
|
||||||
( event.type == EVENT_MOUSE_BUTTON_UP && event.mouseButton.button == MOUSE_BUTTON_LEFT ))
|
event.GetData<MouseButtonEventData>()->button == MOUSE_BUTTON_LEFT)
|
||||||
{
|
{
|
||||||
UpdateCopyButton();
|
UpdateCopyButton();
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,11 +77,11 @@ bool CMainDialog::EventProcess(const Event &event)
|
||||||
}
|
}
|
||||||
|
|
||||||
EventType pressedButton = event.type;
|
EventType pressedButton = event.type;
|
||||||
if (event.type == EVENT_KEY_DOWN && event.key.key == KEY(RETURN) )
|
if (event.type == EVENT_KEY_DOWN && event.GetData<KeyEventData>()->key == KEY(RETURN) )
|
||||||
{
|
{
|
||||||
pressedButton = EVENT_DIALOG_OK;
|
pressedButton = EVENT_DIALOG_OK;
|
||||||
}
|
}
|
||||||
if (event.type == EVENT_KEY_DOWN && event.key.key == KEY(ESCAPE) )
|
if (event.type == EVENT_KEY_DOWN && event.GetData<KeyEventData>()->key == KEY(ESCAPE) )
|
||||||
{
|
{
|
||||||
pressedButton = EVENT_DIALOG_CANCEL;
|
pressedButton = EVENT_DIALOG_CANCEL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -315,15 +315,19 @@ bool CScreenApperance::EventProcess(const Event &event)
|
||||||
switch( event.type )
|
switch( event.type )
|
||||||
{
|
{
|
||||||
case EVENT_KEY_DOWN:
|
case EVENT_KEY_DOWN:
|
||||||
if ( event.key.key == KEY(RETURN) )
|
{
|
||||||
|
auto data = event.GetData<KeyEventData>();
|
||||||
|
|
||||||
|
if (data->key == KEY(RETURN))
|
||||||
{
|
{
|
||||||
m_main->ChangePhase(PHASE_MAIN_MENU);
|
m_main->ChangePhase(PHASE_MAIN_MENU);
|
||||||
}
|
}
|
||||||
if ( event.key.key == KEY(ESCAPE) )
|
if (data->key == KEY(ESCAPE))
|
||||||
{
|
{
|
||||||
m_main->ChangePhase(PHASE_PLAYER_SELECT);
|
m_main->ChangePhase(PHASE_PLAYER_SELECT);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case EVENT_INTERFACE_PHEAD:
|
case EVENT_INTERFACE_PHEAD:
|
||||||
m_apperanceTab = 0;
|
m_apperanceTab = 0;
|
||||||
|
|
|
@ -126,7 +126,7 @@ bool CScreenIORead::EventProcess(const Event &event)
|
||||||
|
|
||||||
if ( event.type == pw->GetEventTypeClose() ||
|
if ( event.type == pw->GetEventTypeClose() ||
|
||||||
event.type == EVENT_INTERFACE_BACK ||
|
event.type == EVENT_INTERFACE_BACK ||
|
||||||
(event.type == EVENT_KEY_DOWN && event.key.key == KEY(ESCAPE)) )
|
(event.type == EVENT_KEY_DOWN && event.GetData<KeyEventData>()->key == KEY(ESCAPE)) )
|
||||||
{
|
{
|
||||||
m_main->ChangePhase(PHASE_LEVEL_LIST);
|
m_main->ChangePhase(PHASE_LEVEL_LIST);
|
||||||
return false;
|
return false;
|
||||||
|
@ -139,7 +139,7 @@ bool CScreenIORead::EventProcess(const Event &event)
|
||||||
|
|
||||||
if ( event.type == pw->GetEventTypeClose() ||
|
if ( event.type == pw->GetEventTypeClose() ||
|
||||||
event.type == EVENT_INTERFACE_BACK ||
|
event.type == EVENT_INTERFACE_BACK ||
|
||||||
(event.type == EVENT_KEY_DOWN && event.key.key == KEY(ESCAPE)) )
|
(event.type == EVENT_KEY_DOWN && event.GetData<KeyEventData>()->key == KEY(ESCAPE)) )
|
||||||
{
|
{
|
||||||
m_interface->DeleteControl(EVENT_WINDOW5);
|
m_interface->DeleteControl(EVENT_WINDOW5);
|
||||||
m_main->ChangePhase(PHASE_SIMUL);
|
m_main->ChangePhase(PHASE_SIMUL);
|
||||||
|
|
|
@ -127,7 +127,7 @@ bool CScreenIOWrite::EventProcess(const Event &event)
|
||||||
|
|
||||||
if ( event.type == pw->GetEventTypeClose() ||
|
if ( event.type == pw->GetEventTypeClose() ||
|
||||||
event.type == EVENT_INTERFACE_BACK ||
|
event.type == EVENT_INTERFACE_BACK ||
|
||||||
(event.type == EVENT_KEY_DOWN && event.key.key == KEY(ESCAPE)) )
|
(event.type == EVENT_KEY_DOWN && event.GetData<KeyEventData>()->key == KEY(ESCAPE)) )
|
||||||
{
|
{
|
||||||
m_interface->DeleteControl(EVENT_WINDOW5);
|
m_interface->DeleteControl(EVENT_WINDOW5);
|
||||||
m_main->ChangePhase(PHASE_SIMUL);
|
m_main->ChangePhase(PHASE_SIMUL);
|
||||||
|
|
|
@ -245,7 +245,7 @@ bool CScreenLevelList::EventProcess(const Event &event)
|
||||||
|
|
||||||
if ( event.type == pw->GetEventTypeClose() ||
|
if ( event.type == pw->GetEventTypeClose() ||
|
||||||
event.type == EVENT_INTERFACE_BACK ||
|
event.type == EVENT_INTERFACE_BACK ||
|
||||||
(event.type == EVENT_KEY_DOWN && event.key.key == KEY(ESCAPE)) )
|
(event.type == EVENT_KEY_DOWN && event.GetData<KeyEventData>()->key == KEY(ESCAPE)) )
|
||||||
{
|
{
|
||||||
m_main->ChangePhase(PHASE_MAIN_MENU);
|
m_main->ChangePhase(PHASE_MAIN_MENU);
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -167,7 +167,7 @@ bool CScreenMainMenu::EventProcess(const Event &event)
|
||||||
switch (event.type)
|
switch (event.type)
|
||||||
{
|
{
|
||||||
case EVENT_KEY_DOWN:
|
case EVENT_KEY_DOWN:
|
||||||
if ( event.key.key == KEY(ESCAPE) )
|
if ( event.GetData<KeyEventData>()->key == KEY(ESCAPE) )
|
||||||
{
|
{
|
||||||
m_sound->Play(SOUND_TZOING);
|
m_sound->Play(SOUND_TZOING);
|
||||||
m_main->ChangePhase(PHASE_QUIT_SCREEN);
|
m_main->ChangePhase(PHASE_QUIT_SCREEN);
|
||||||
|
|
|
@ -158,11 +158,13 @@ bool CScreenPlayerSelect::EventProcess(const Event &event)
|
||||||
switch( event.type )
|
switch( event.type )
|
||||||
{
|
{
|
||||||
case EVENT_KEY_DOWN:
|
case EVENT_KEY_DOWN:
|
||||||
if ( event.key.key == KEY(RETURN) )
|
{
|
||||||
|
auto data = event.GetData<KeyEventData>();
|
||||||
|
if (data->key == KEY(RETURN))
|
||||||
{
|
{
|
||||||
NameSelect();
|
NameSelect();
|
||||||
}
|
}
|
||||||
if ( event.key.key == KEY(ESCAPE) )
|
if (data->key == KEY(ESCAPE))
|
||||||
{
|
{
|
||||||
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
|
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
|
||||||
if ( pw == 0 ) break;
|
if ( pw == 0 ) break;
|
||||||
|
@ -174,6 +176,7 @@ bool CScreenPlayerSelect::EventProcess(const Event &event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case EVENT_INTERFACE_NEDIT:
|
case EVENT_INTERFACE_NEDIT:
|
||||||
UpdateNameList();
|
UpdateNameList();
|
||||||
|
|
|
@ -111,7 +111,7 @@ bool CScreenQuit::EventProcess(const Event &event)
|
||||||
|
|
||||||
if ( event.type == EVENT_KEY_DOWN )
|
if ( event.type == EVENT_KEY_DOWN )
|
||||||
{
|
{
|
||||||
if ( event.key.key == KEY(ESCAPE) )
|
if ( event.GetData<KeyEventData>()->key == KEY(ESCAPE) )
|
||||||
{
|
{
|
||||||
m_main->ChangePhase(PHASE_MAIN_MENU);
|
m_main->ChangePhase(PHASE_MAIN_MENU);
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -151,7 +151,7 @@ bool CScreenSetup::EventProcess(const Event &event)
|
||||||
|
|
||||||
if ( event.type == pw->GetEventTypeClose() ||
|
if ( event.type == pw->GetEventTypeClose() ||
|
||||||
event.type == EVENT_INTERFACE_BACK ||
|
event.type == EVENT_INTERFACE_BACK ||
|
||||||
(event.type == EVENT_KEY_DOWN && event.key.key == KEY(ESCAPE)) )
|
(event.type == EVENT_KEY_DOWN && event.GetData<KeyEventData>()->key == KEY(ESCAPE)) )
|
||||||
{
|
{
|
||||||
m_settings->SaveSettings();
|
m_settings->SaveSettings();
|
||||||
m_engine->ApplyChange();
|
m_engine->ApplyChange();
|
||||||
|
@ -192,7 +192,7 @@ bool CScreenSetup::EventProcess(const Event &event)
|
||||||
|
|
||||||
if ( event.type == pw->GetEventTypeClose() ||
|
if ( event.type == pw->GetEventTypeClose() ||
|
||||||
event.type == EVENT_INTERFACE_BACK ||
|
event.type == EVENT_INTERFACE_BACK ||
|
||||||
(event.type == EVENT_KEY_DOWN && event.key.key == KEY(ESCAPE)) )
|
(event.type == EVENT_KEY_DOWN && event.GetData<KeyEventData>()->key == KEY(ESCAPE)) )
|
||||||
{
|
{
|
||||||
m_settings->SaveSettings();
|
m_settings->SaveSettings();
|
||||||
m_engine->ApplyChange();
|
m_engine->ApplyChange();
|
||||||
|
|
|
@ -124,9 +124,7 @@ bool CStudio::EventProcess(const Event &event)
|
||||||
|
|
||||||
if ( event.type == pw->GetEventTypeClose() )
|
if ( event.type == pw->GetEventTypeClose() )
|
||||||
{
|
{
|
||||||
Event newEvent = event;
|
m_event->AddEvent(Event(EVENT_STUDIO_OK));
|
||||||
newEvent.type = EVENT_STUDIO_OK;
|
|
||||||
m_event->AddEvent(newEvent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( event.type == EVENT_STUDIO_EDIT ) // text modifief?
|
if ( event.type == EVENT_STUDIO_EDIT ) // text modifief?
|
||||||
|
@ -209,9 +207,7 @@ bool CStudio::EventProcess(const Event &event)
|
||||||
{
|
{
|
||||||
if ( m_script->IsRunning() )
|
if ( m_script->IsRunning() )
|
||||||
{
|
{
|
||||||
Event newEvent = event;
|
m_event->AddEvent(Event(EVENT_OBJECT_PROGSTOP));
|
||||||
newEvent.type = EVENT_OBJECT_PROGSTOP;
|
|
||||||
m_event->AddEvent(newEvent); // stop
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -219,9 +215,7 @@ bool CStudio::EventProcess(const Event &event)
|
||||||
{
|
{
|
||||||
SetInfoText("", false);
|
SetInfoText("", false);
|
||||||
|
|
||||||
Event newEvent = event;
|
m_event->AddEvent(Event(EVENT_OBJECT_PROGSTART));
|
||||||
newEvent.type = EVENT_OBJECT_PROGSTART;
|
|
||||||
m_event->AddEvent(newEvent); // start
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -361,9 +355,7 @@ bool CStudio::EventFrame(const Event &event)
|
||||||
GetResource(RES_TEXT, RT_STUDIO_PROGSTOP, res);
|
GetResource(RES_TEXT, RT_STUDIO_PROGSTOP, res);
|
||||||
SetInfoText(res, false);
|
SetInfoText(res, false);
|
||||||
|
|
||||||
Event newEvent = event;
|
m_event->AddEvent(Event(EVENT_OBJECT_PROGSTOP));
|
||||||
newEvent.type = EVENT_OBJECT_PROGSTOP;
|
|
||||||
m_event->AddEvent(newEvent); // stop
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( m_script->IsRunning() && !m_bRunning ) // starting?
|
if ( m_script->IsRunning() && !m_bRunning ) // starting?
|
||||||
|
@ -1393,7 +1385,7 @@ bool CStudio::EventDialog(const Event &event)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( event.type == EVENT_DIALOG_OK ||
|
if ( event.type == EVENT_DIALOG_OK ||
|
||||||
(event.type == EVENT_KEY_DOWN && event.key.key == KEY(RETURN)) )
|
(event.type == EVENT_KEY_DOWN && event.GetData<KeyEventData>()->key == KEY(RETURN)) )
|
||||||
{
|
{
|
||||||
if ( m_dialog == SD_OPEN )
|
if ( m_dialog == SD_OPEN )
|
||||||
{
|
{
|
||||||
|
@ -1409,7 +1401,7 @@ bool CStudio::EventDialog(const Event &event)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( event.type == EVENT_DIALOG_CANCEL ||
|
if ( event.type == EVENT_DIALOG_CANCEL ||
|
||||||
(event.type == EVENT_KEY_DOWN && event.key.key == KEY(ESCAPE)) ||
|
(event.type == EVENT_KEY_DOWN && event.GetData<KeyEventData>()->key == KEY(ESCAPE)) ||
|
||||||
event.type == pw->GetEventTypeClose() )
|
event.type == pw->GetEventTypeClose() )
|
||||||
{
|
{
|
||||||
StopDialog();
|
StopDialog();
|
||||||
|
|
Loading…
Reference in New Issue