| 7312 | } |
| 7313 | |
| 7314 | void CEditor::OnUpdate() |
| 7315 | { |
| 7316 | CUIElementBase::Init(Ui()); // update static pointer because game and editor use separate UI |
| 7317 | |
| 7318 | if(!m_EditorWasUsedBefore) |
| 7319 | { |
| 7320 | m_EditorWasUsedBefore = true; |
| 7321 | Reset(); |
| 7322 | } |
| 7323 | |
| 7324 | m_pContainerPannedLast = m_pContainerPanned; |
| 7325 | |
| 7326 | // handle mouse movement |
| 7327 | vec2 CursorRel = vec2(0.0f, 0.0f); |
| 7328 | IInput::ECursorType CursorType = Input()->CursorRelative(&CursorRel.x, &CursorRel.y); |
| 7329 | if(CursorType != IInput::CURSOR_NONE) |
| 7330 | { |
| 7331 | Ui()->ConvertMouseMove(&CursorRel.x, &CursorRel.y, CursorType); |
| 7332 | MouseAxisLock(CursorRel); |
| 7333 | Ui()->OnCursorMove(CursorRel.x, CursorRel.y); |
| 7334 | } |
| 7335 | |
| 7336 | // handle key presses |
| 7337 | Input()->ConsumeEvents([&](const IInput::CEvent &Event) { |
| 7338 | if(m_Dialog == DIALOG_NONE && |
| 7339 | CLineInput::GetActiveInput() == nullptr && |
| 7340 | Event.m_Key == KEY_F1) |
| 7341 | { |
| 7342 | if((Event.m_Flags & IInput::FLAG_PRESS) != 0 && |
| 7343 | (Event.m_Flags & IInput::FLAG_REPEAT) == 0) |
| 7344 | { |
| 7345 | m_QuickActionShowHelp.Call(); |
| 7346 | } |
| 7347 | return; |
| 7348 | } |
| 7349 | |
| 7350 | for(CEditorComponent &Component : m_vComponents) |
| 7351 | { |
| 7352 | // Events with flag `FLAG_RELEASE` must always be forwarded to all components so keys being |
| 7353 | // released can be handled in all components also after some components have been disabled. |
| 7354 | if(Component.OnInput(Event) && (Event.m_Flags & ~IInput::FLAG_RELEASE) != 0) |
| 7355 | return; |
| 7356 | } |
| 7357 | Ui()->OnInput(Event); |
| 7358 | }); |
| 7359 | |
| 7360 | HandleCursorMovement(); |
| 7361 | HandleAutosave(); |
| 7362 | HandleWriterFinishJobs(); |
| 7363 | |
| 7364 | for(CEditorComponent &Component : m_vComponents) |
| 7365 | Component.OnUpdate(); |
| 7366 | } |
| 7367 | |
| 7368 | void CEditor::OnRender() |
| 7369 | { |
no test coverage detected