From 5599de315383df712151d1d3b1a1f072b51f910a Mon Sep 17 00:00:00 2001 From: Corantin H Date: Sat, 23 Dec 2023 14:45:36 +0100 Subject: [PATCH] Use `CEditorComponent` methods instead of only `CMapView` Small changes to `CEditorObject` --- src/game/editor/editor.cpp | 14 ++++++++++++-- src/game/editor/editor_object.cpp | 3 +-- src/game/editor/editor_object.h | 4 ++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index a14a10536..286249357 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -8164,6 +8164,9 @@ void CEditor::Render() MapView()->Zoom()->ChangeValue(-20.0f); } + for(CEditorComponent &Component : m_vComponents) + Component.OnRender(View); + MapView()->UpdateZoom(); UI()->RenderPopupMenus(); @@ -8259,7 +8262,9 @@ void CEditor::Reset(bool CreateDefault) UI()->ClosePopupMenus(); m_Map.Clean(); - m_MapView.OnReset(); + for(CEditorComponent &Component : m_vComponents) + Component.OnReset(); + // create default layers if(CreateDefault) { @@ -8633,6 +8638,9 @@ void CEditor::OnUpdate() DispatchInputEvents(); HandleAutosave(); HandleWriterFinishJobs(); + + for(CEditorComponent &Component : m_vComponents) + Component.OnUpdate(); } void CEditor::OnRender() @@ -8760,7 +8768,9 @@ bool CEditor::Load(const char *pFileName, int StorageType) str_copy(m_aFileName, pFileName); SortImages(); SelectGameLayer(); - MapView()->OnMapLoad(); + + for(CEditorComponent &Component : m_vComponents) + Component.OnMapLoad(); } else { diff --git a/src/game/editor/editor_object.cpp b/src/game/editor/editor_object.cpp index 2154c3d10..0e182fa80 100644 --- a/src/game/editor/editor_object.cpp +++ b/src/game/editor/editor_object.cpp @@ -8,9 +8,8 @@ void CEditorObject::Init(CEditor *pEditor) OnReset(); } -void CEditorObject::OnUpdate(CUIRect View) +void CEditorObject::OnUpdate() { - OnRender(View); if(IsActive()) OnActive(); else if(IsHot()) diff --git a/src/game/editor/editor_object.h b/src/game/editor/editor_object.h index 87ec1df4e..d0715091f 100644 --- a/src/game/editor/editor_object.h +++ b/src/game/editor/editor_object.h @@ -31,9 +31,9 @@ public: virtual void Init(CEditor *pEditor); /** - * Calls `OnRender` and then maybe `OnHot` or `OnActive`. + * Maybe calls `OnHot` or `OnActive`. */ - void OnUpdate(CUIRect View); + virtual void OnUpdate(); /** * Gets called before `OnRender`. Should return true