Rename Impl classes to follow Unity naming convention
- SelectionManagerImpl -> SelectionManager - EditorContextImpl -> EditorContext - Removed unused SceneManagerImpl and ISceneManager The Impl suffix was inconsistent with Unity naming conventions.
This commit is contained in:
@@ -473,12 +473,16 @@ private:
|
|||||||
- `editor/src/Core/SelectionManagerImpl.h` - 选择管理器实现
|
- `editor/src/Core/SelectionManagerImpl.h` - 选择管理器实现
|
||||||
- `editor/src/Core/IEditorContext.h` - 编辑器上下文接口
|
- `editor/src/Core/IEditorContext.h` - 编辑器上下文接口
|
||||||
- `editor/src/Core/EditorContextImpl.h` - 编辑器上下文实现
|
- `editor/src/Core/EditorContextImpl.h` - 编辑器上下文实现
|
||||||
|
- `editor/src/Core/EditorConsoleSink.h/cpp` - Editor 专用日志 Sink
|
||||||
|
|
||||||
**2026-03-25 更新**:
|
**2026-03-25 更新**:
|
||||||
- `editor/src/panels/HierarchyPanel.h/cpp` - 已迁移至 IEditorContext
|
- `editor/src/panels/HierarchyPanel.h/cpp` - 已迁移至 IEditorContext
|
||||||
- `editor/src/panels/InspectorPanel.h/cpp` - 已迁移至 IEditorContext + EventBus
|
- `editor/src/panels/InspectorPanel.h/cpp` - 已迁移至 IEditorContext + EventBus
|
||||||
- 移除了所有 Panel 中的 `SelectionManager::Get()` 和 `EditorSceneManager::Get()` 单例调用
|
- 移除了所有 Panel 中的 `SelectionManager::Get()` 和 `EditorSceneManager::Get()` 单例调用
|
||||||
- SceneManager::RenameEntity 实现已添加
|
- SceneManager::RenameEntity 实现已添加
|
||||||
|
- **日志系统统一**:删除了独立的 LogSystem 单例,Editor 和 Engine 共用 Debug::Logger
|
||||||
|
- ConsolePanel 改用 EditorConsoleSink 从 Logger 读取日志
|
||||||
|
- 删除了 `editor/src/Managers/LogSystem.h/cpp` 和 `editor/src/Core/LogEntry.h`
|
||||||
|
|
||||||
### 阶段二:核心功能(第 3-4 周)
|
### 阶段二:核心功能(第 3-4 周)
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
#include "Layers/EditorLayer.h"
|
#include "Layers/EditorLayer.h"
|
||||||
#include "Core/EditorContextImpl.h"
|
#include "Core/EditorContext.h"
|
||||||
#include "Core/EditorConsoleSink.h"
|
#include "Core/EditorConsoleSink.h"
|
||||||
#include <XCEngine/Debug/Logger.h>
|
#include <XCEngine/Debug/Logger.h>
|
||||||
#include <XCEngine/Debug/FileLogSink.h>
|
#include <XCEngine/Debug/FileLogSink.h>
|
||||||
@@ -118,7 +118,7 @@ bool Application::Initialize(HWND hwnd) {
|
|||||||
m_srvHeap->GetCPUDescriptorHandleForHeapStart(),
|
m_srvHeap->GetCPUDescriptorHandleForHeapStart(),
|
||||||
m_srvHeap->GetGPUDescriptorHandleForHeapStart());
|
m_srvHeap->GetGPUDescriptorHandleForHeapStart());
|
||||||
|
|
||||||
m_editorContext = std::make_shared<EditorContextImpl>();
|
m_editorContext = std::make_shared<EditorContext>();
|
||||||
m_editorContext->SetProjectPath(exeDir);
|
m_editorContext->SetProjectPath(exeDir);
|
||||||
|
|
||||||
m_editorLayer = new EditorLayer();
|
m_editorLayer = new EditorLayer();
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include "IEditorContext.h"
|
#include "IEditorContext.h"
|
||||||
#include "EventBus.h"
|
#include "EventBus.h"
|
||||||
#include "SelectionManagerImpl.h"
|
#include "SelectionManager.h"
|
||||||
#include "Managers/SceneManager.h"
|
#include "Managers/SceneManager.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@@ -10,11 +10,11 @@
|
|||||||
namespace XCEngine {
|
namespace XCEngine {
|
||||||
namespace Editor {
|
namespace Editor {
|
||||||
|
|
||||||
class EditorContextImpl : public IEditorContext {
|
class EditorContext : public IEditorContext {
|
||||||
public:
|
public:
|
||||||
EditorContextImpl()
|
EditorContext()
|
||||||
: m_eventBus(std::make_unique<EventBus>())
|
: m_eventBus(std::make_unique<EventBus>())
|
||||||
, m_selectionManager(std::make_unique<SelectionManagerImpl>(*m_eventBus))
|
, m_selectionManager(std::make_unique<SelectionManager>(*m_eventBus))
|
||||||
, m_sceneManager(std::make_unique<SceneManager>()) {
|
, m_sceneManager(std::make_unique<SceneManager>()) {
|
||||||
m_sceneManager->SetSelectionManager(m_selectionManager.get());
|
m_sceneManager->SetSelectionManager(m_selectionManager.get());
|
||||||
}
|
}
|
||||||
@@ -45,7 +45,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<EventBus> m_eventBus;
|
std::unique_ptr<EventBus> m_eventBus;
|
||||||
std::unique_ptr<SelectionManagerImpl> m_selectionManager;
|
std::unique_ptr<SelectionManager> m_selectionManager;
|
||||||
std::unique_ptr<SceneManager> m_sceneManager;
|
std::unique_ptr<SceneManager> m_sceneManager;
|
||||||
std::string m_projectPath;
|
std::string m_projectPath;
|
||||||
};
|
};
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
|
||||||
#include <cstdint>
|
|
||||||
|
|
||||||
namespace XCEngine {
|
|
||||||
namespace Editor {
|
|
||||||
|
|
||||||
using GameObjectID = uint64_t;
|
|
||||||
|
|
||||||
class IGameObject {
|
|
||||||
public:
|
|
||||||
virtual ~IGameObject() = default;
|
|
||||||
virtual GameObjectID GetID() const = 0;
|
|
||||||
virtual const std::string& GetName() const = 0;
|
|
||||||
virtual void SetName(const std::string& name) = 0;
|
|
||||||
virtual IGameObject* GetParent() const = 0;
|
|
||||||
virtual void SetParent(IGameObject* parent) = 0;
|
|
||||||
virtual size_t GetChildCount() const = 0;
|
|
||||||
virtual IGameObject* GetChild(size_t index) const = 0;
|
|
||||||
virtual void DetachFromParent() = 0;
|
|
||||||
virtual const std::vector<IGameObject*>& GetChildren() const = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ISceneManager {
|
|
||||||
public:
|
|
||||||
virtual ~ISceneManager() = default;
|
|
||||||
|
|
||||||
virtual IGameObject* CreateEntity(const std::string& name, IGameObject* parent = nullptr) = 0;
|
|
||||||
virtual void DeleteEntity(GameObjectID id) = 0;
|
|
||||||
virtual void RenameEntity(GameObjectID id, const std::string& newName) = 0;
|
|
||||||
virtual void CopyEntity(GameObjectID id) = 0;
|
|
||||||
virtual GameObjectID PasteEntity(GameObjectID parent = 0) = 0;
|
|
||||||
virtual GameObjectID DuplicateEntity(GameObjectID id) = 0;
|
|
||||||
virtual void MoveEntity(GameObjectID id, GameObjectID newParent) = 0;
|
|
||||||
virtual IGameObject* GetEntity(GameObjectID id) = 0;
|
|
||||||
virtual const std::vector<IGameObject*>& GetRootEntities() const = 0;
|
|
||||||
virtual bool HasClipboardData() const = 0;
|
|
||||||
virtual void CreateDemoScene() = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "ISceneManager.h"
|
|
||||||
#include <unordered_map>
|
|
||||||
#include <vector>
|
|
||||||
#include <memory>
|
|
||||||
#include <optional>
|
|
||||||
#include <string>
|
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
namespace XCEngine {
|
|
||||||
namespace Editor {
|
|
||||||
|
|
||||||
class MathVector3 {
|
|
||||||
public:
|
|
||||||
float x, y, z;
|
|
||||||
};
|
|
||||||
|
|
||||||
class MathQuaternion {
|
|
||||||
public:
|
|
||||||
float x, y, z, w;
|
|
||||||
};
|
|
||||||
|
|
||||||
class SceneManagerImpl : public ISceneManager {
|
|
||||||
public:
|
|
||||||
SceneManagerImpl();
|
|
||||||
|
|
||||||
IGameObject* CreateEntity(const std::string& name, IGameObject* parent = nullptr) override;
|
|
||||||
void DeleteEntity(GameObjectID id) override;
|
|
||||||
void RenameEntity(GameObjectID id, const std::string& newName) override;
|
|
||||||
void CopyEntity(GameObjectID id) override;
|
|
||||||
GameObjectID PasteEntity(GameObjectID parent = 0) override;
|
|
||||||
GameObjectID DuplicateEntity(GameObjectID id) override;
|
|
||||||
void MoveEntity(GameObjectID id, GameObjectID newParent) override;
|
|
||||||
IGameObject* GetEntity(GameObjectID id) override;
|
|
||||||
const std::vector<IGameObject*>& GetRootEntities() const override;
|
|
||||||
bool HasClipboardData() const override;
|
|
||||||
void CreateDemoScene() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
struct ClipboardData {
|
|
||||||
std::string name;
|
|
||||||
MathVector3 localPosition = {0, 0, 0};
|
|
||||||
MathQuaternion localRotation = {0, 0, 0, 1};
|
|
||||||
MathVector3 localScale = {1, 1, 1};
|
|
||||||
std::vector<ClipboardData> children;
|
|
||||||
};
|
|
||||||
|
|
||||||
ClipboardData CopyEntityRecursive(GameObjectID id);
|
|
||||||
GameObjectID PasteEntityRecursive(const ClipboardData& data, GameObjectID parent);
|
|
||||||
IGameObject* CastToIGameObject(GameObject* go);
|
|
||||||
|
|
||||||
GameObjectID m_nextId = 1;
|
|
||||||
std::vector<IGameObject*> m_rootEntities;
|
|
||||||
std::optional<ClipboardData> m_clipboard;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -9,9 +9,9 @@
|
|||||||
namespace XCEngine {
|
namespace XCEngine {
|
||||||
namespace Editor {
|
namespace Editor {
|
||||||
|
|
||||||
class SelectionManagerImpl : public ISelectionManager {
|
class SelectionManager : public ISelectionManager {
|
||||||
public:
|
public:
|
||||||
explicit SelectionManagerImpl(EventBus& eventBus) : m_eventBus(eventBus) {}
|
explicit SelectionManager(EventBus& eventBus) : m_eventBus(eventBus) {}
|
||||||
|
|
||||||
void SetSelectedEntity(uint64_t entityId) override {
|
void SetSelectedEntity(uint64_t entityId) override {
|
||||||
if (m_selectedEntities.empty()) {
|
if (m_selectedEntities.empty()) {
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
#include "panels/ConsolePanel.h"
|
#include "panels/ConsolePanel.h"
|
||||||
#include "panels/ProjectPanel.h"
|
#include "panels/ProjectPanel.h"
|
||||||
#include "Core/IEditorContext.h"
|
#include "Core/IEditorContext.h"
|
||||||
#include "Core/EditorContextImpl.h"
|
#include "Core/EditorContext.h"
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
#include <imgui_internal.h>
|
#include <imgui_internal.h>
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ void EditorLayer::SetContext(std::shared_ptr<IEditorContext> context) {
|
|||||||
|
|
||||||
void EditorLayer::onAttach() {
|
void EditorLayer::onAttach() {
|
||||||
if (!m_context) {
|
if (!m_context) {
|
||||||
m_context = std::make_shared<EditorContextImpl>();
|
m_context = std::make_shared<EditorContext>();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_menuBar = std::make_unique<MenuBar>();
|
m_menuBar = std::make_unique<MenuBar>();
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#include "InspectorPanel.h"
|
#include "InspectorPanel.h"
|
||||||
#include "Core/EditorContextImpl.h"
|
#include "Core/EditorContext.h"
|
||||||
#include "Managers/SceneManager.h"
|
#include "Managers/SceneManager.h"
|
||||||
#include "UI/UI.h"
|
#include "UI/UI.h"
|
||||||
#include <XCEngine/Debug/Logger.h>
|
#include <XCEngine/Debug/Logger.h>
|
||||||
|
|||||||
@@ -19,9 +19,8 @@ bool D3D12CommandAllocator::Initialize(ID3D12Device* device, CommandQueueType ty
|
|||||||
ToD3D12(type),
|
ToD3D12(type),
|
||||||
IID_PPV_ARGS(&m_commandAllocator));
|
IID_PPV_ARGS(&m_commandAllocator));
|
||||||
if (FAILED(hResult)) {
|
if (FAILED(hResult)) {
|
||||||
char buf[256];
|
FILE* f = fopen("D:\\Xuanchi\\Main\\XCEngine\\debug_rhi.log", "a");
|
||||||
sprintf(buf, "[D3D12CommandAllocator] CreateCommandAllocator failed: hr=0x%08X\n", hResult);
|
if (f) { fprintf(f, "[D3D12CommandAllocator] CreateCommandAllocator failed: hr=0x%08X\n", hResult); fclose(f); }
|
||||||
OutputDebugStringA(buf);
|
|
||||||
}
|
}
|
||||||
return SUCCEEDED(hResult);
|
return SUCCEEDED(hResult);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user