refactor(editor): Phase 1 architecture refactoring
- Decouple Panel from Core::Layer (P0 issue resolved) - Add EventBus with type-safe event system - Add ISelectionManager interface with SelectionManagerImpl - Add IEditorContext for dependency injection - Update EditorLayer to use new architecture - Update Application to create and inject EditorContext New files: - editor/src/Core/EventBus.h - editor/src/Core/EditorEvents.h - editor/src/Core/ISelectionManager.h - editor/src/Core/SelectionManagerImpl.h - editor/src/Core/IEditorContext.h - editor/src/Core/EditorContextImpl.h This enables future improvements: Undo/Redo, serialization, component extensibility.
This commit is contained in:
@@ -6,8 +6,8 @@
|
||||
#include "panels/InspectorPanel.h"
|
||||
#include "panels/ConsolePanel.h"
|
||||
#include "panels/ProjectPanel.h"
|
||||
#include "Managers/SelectionManager.h"
|
||||
#include "Managers/SceneManager.h"
|
||||
#include "Core/IEditorContext.h"
|
||||
#include "Core/EditorContextImpl.h"
|
||||
#include <imgui.h>
|
||||
#include <imgui_internal.h>
|
||||
|
||||
@@ -16,7 +16,15 @@ namespace Editor {
|
||||
|
||||
EditorLayer::EditorLayer() : Layer("Editor") {}
|
||||
|
||||
void EditorLayer::SetContext(std::shared_ptr<IEditorContext> context) {
|
||||
m_context = context;
|
||||
}
|
||||
|
||||
void EditorLayer::onAttach() {
|
||||
if (!m_context) {
|
||||
m_context = std::make_shared<EditorContextImpl>();
|
||||
}
|
||||
|
||||
m_menuBar = std::make_unique<MenuBar>();
|
||||
m_hierarchyPanel = std::make_unique<HierarchyPanel>();
|
||||
m_sceneViewPanel = std::make_unique<SceneViewPanel>();
|
||||
@@ -25,14 +33,25 @@ void EditorLayer::onAttach() {
|
||||
m_consolePanel = std::make_unique<ConsolePanel>();
|
||||
m_projectPanel = std::make_unique<ProjectPanel>();
|
||||
|
||||
m_projectPanel->Initialize(m_projectPath);
|
||||
m_menuBar->OnAttach();
|
||||
m_hierarchyPanel->OnAttach();
|
||||
m_sceneViewPanel->OnAttach();
|
||||
m_gameViewPanel->OnAttach();
|
||||
m_inspectorPanel->OnAttach();
|
||||
m_consolePanel->OnAttach();
|
||||
m_projectPanel->OnAttach();
|
||||
|
||||
auto& selection = SelectionManager::Get();
|
||||
selection.OnSelectionChanged.Subscribe([](uint64_t id) {
|
||||
});
|
||||
m_projectPanel->Initialize(m_context->GetProjectPath());
|
||||
}
|
||||
|
||||
void EditorLayer::onDetach() {
|
||||
m_menuBar->OnDetach();
|
||||
m_hierarchyPanel->OnDetach();
|
||||
m_sceneViewPanel->OnDetach();
|
||||
m_gameViewPanel->OnDetach();
|
||||
m_inspectorPanel->OnDetach();
|
||||
m_consolePanel->OnDetach();
|
||||
m_projectPanel->OnDetach();
|
||||
}
|
||||
|
||||
void EditorLayer::onUpdate(float dt) {
|
||||
@@ -58,10 +77,6 @@ void EditorLayer::onImGuiRender() {
|
||||
renderAllPanels();
|
||||
}
|
||||
|
||||
void EditorLayer::SetProjectPath(const std::string& path) {
|
||||
m_projectPath = path;
|
||||
}
|
||||
|
||||
void EditorLayer::setupDockspace() {
|
||||
static ImGuiDockNodeFlags dockspaceFlags = ImGuiDockNodeFlags_NoWindowMenuButton;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user