Skip to content

Commit

Permalink
Handle editor input events in OnUpdate instead of OnRender
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Robyt3 committed Jul 12, 2023
1 parent 92c053f commit 25848c3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/game/editor/editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -7204,6 +7215,7 @@ void CEditor::OnUpdate()
}

HandleCursorMovement();
DispatchInputEvents();
HandleAutosave();
HandleWriterFinishJobs();
}
Expand All @@ -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();
Expand Down
1 change: 1 addition & 0 deletions src/game/editor/editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,7 @@ class CEditor : public IEditor
void ResetIngameMoved() override { m_IngameMoved = false; }

void HandleCursorMovement();
void DispatchInputEvents();
void HandleAutosave();
bool PerformAutosave();
void HandleWriterFinishJobs();
Expand Down

0 comments on commit 25848c3

Please sign in to comment.