From 25848c346357ef1af209c8e55b06f6e05c2b90f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Sun, 9 Jul 2023 17:37:50 +0200 Subject: [PATCH] Handle editor input events in `OnUpdate` instead of `OnRender` To make input handling consistent with the gameclient. Also skip input events that are not valid, same as in the gameclient, as this otherwise causes input events to be handled multiple times. --- src/game/editor/editor.cpp | 15 ++++++++++++--- src/game/editor/editor.h | 1 + 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index b6476538f80..3e783b7a1be 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -7090,6 +7090,17 @@ void CEditor::HandleCursorMovement() } } +void CEditor::DispatchInputEvents() +{ + for(size_t i = 0; i < Input()->NumEvents(); i++) + { + const IInput::CEvent &Event = Input()->GetEvent(i); + if(!Input()->IsEventValid(Event)) + continue; + UI()->OnInput(Event); + } +} + void CEditor::HandleAutosave() { const float Time = Client()->GlobalTime(); @@ -7204,6 +7215,7 @@ void CEditor::OnUpdate() } HandleCursorMovement(); + DispatchInputEvents(); HandleAutosave(); HandleWriterFinishJobs(); } @@ -7227,9 +7239,6 @@ void CEditor::OnRender() ms_pUiGotContext = nullptr; UI()->StartCheck(); - for(size_t i = 0; i < Input()->NumEvents(); i++) - UI()->OnInput(Input()->GetEvent(i)); - UI()->Update(m_MouseX, m_MouseY, m_MouseDeltaX, m_MouseDeltaY, m_MouseWorldX, m_MouseWorldY); Render(); diff --git a/src/game/editor/editor.h b/src/game/editor/editor.h index baa34f4e686..49b3a639e76 100644 --- a/src/game/editor/editor.h +++ b/src/game/editor/editor.h @@ -879,6 +879,7 @@ class CEditor : public IEditor void ResetIngameMoved() override { m_IngameMoved = false; } void HandleCursorMovement(); + void DispatchInputEvents(); void HandleAutosave(); bool PerformAutosave(); void HandleWriterFinishJobs();