Extract CEditor::HandleCursorMovement function

This commit is contained in:
Robert Müller 2023-06-23 18:05:33 +02:00
parent 4372932480
commit e04eee9d44
2 changed files with 65 additions and 61 deletions

View file

@ -6812,18 +6812,8 @@ void CEditor::PlaceBorderTiles()
pT->m_pTiles[i].m_Index = 1; pT->m_pTiles[i].m_Index = 1;
} }
void CEditor::OnUpdate() void CEditor::HandleCursorMovement()
{ {
CUIElementBase::Init(UI()); // update static pointer because game and editor use separate UI
if(!m_EditorWasUsedBefore)
{
m_EditorWasUsedBefore = true;
Reset();
}
// handle cursor movement
{
static float s_MouseX = 0.0f; static float s_MouseX = 0.0f;
static float s_MouseY = 0.0f; static float s_MouseY = 0.0f;
@ -6882,7 +6872,19 @@ void CEditor::OnUpdate()
m_MouseWorldNoParaX = aPoints[0] + WorldWidth * (s_MouseX / Graphics()->WindowWidth()); m_MouseWorldNoParaX = aPoints[0] + WorldWidth * (s_MouseX / Graphics()->WindowWidth());
m_MouseWorldNoParaY = aPoints[1] + WorldHeight * (s_MouseY / Graphics()->WindowHeight()); m_MouseWorldNoParaY = aPoints[1] + WorldHeight * (s_MouseY / Graphics()->WindowHeight());
} }
}
void CEditor::OnUpdate()
{
CUIElementBase::Init(UI()); // update static pointer because game and editor use separate UI
if(!m_EditorWasUsedBefore)
{
m_EditorWasUsedBefore = true;
Reset();
} }
HandleCursorMovement();
} }
void CEditor::OnRender() void CEditor::OnRender()

View file

@ -848,6 +848,8 @@ public:
void UpdateMentions() override { m_Mentions++; } void UpdateMentions() override { m_Mentions++; }
void ResetMentions() override { m_Mentions = 0; } void ResetMentions() override { m_Mentions = 0; }
void HandleCursorMovement();
CLayerGroup *m_apSavedBrushes[10]; CLayerGroup *m_apSavedBrushes[10];
void RefreshFilteredFileList(); void RefreshFilteredFileList();