重构ui_editor:向引擎核心类型对齐

- 删除UI::Event,使用XCEngine::Core::Event替代
- GameObject.h重构,Component添加friend class Entity
- LogEntry使用XCEngine::Debug::LogLevel
- SceneManager/SelectionManager使用XCEngine::Core::Event
- LogSystem使用XCEngine::Debug::LogLevel
- CMakeLists.txt添加engine/include路径
This commit is contained in:
2026-03-20 17:28:06 +08:00
parent 376fa08e56
commit a40544344b
13 changed files with 96 additions and 111 deletions

View File

@@ -41,7 +41,7 @@ void HierarchyPanel::Render() {
}
if (ImGui::BeginPopupContextWindow("HierarchyContextMenu", ImGuiPopupFlags_MouseButtonRight)) {
RenderCreateMenu(INVALID_ENTITY);
RenderCreateMenu(INVALID_ENTITY_ID);
ImGui::EndPopup();
}
@@ -49,10 +49,10 @@ void HierarchyPanel::Render() {
if (ImGui::BeginDragDropTarget()) {
if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload("ENTITY_ID")) {
EntityID sourceId = *(const EntityID*)payload->Data;
if (sourceId != INVALID_ENTITY) {
if (sourceId != INVALID_ENTITY_ID) {
const Entity* sourceEntity = SceneManager::Get().GetEntity(sourceId);
if (sourceEntity && sourceEntity->parent != INVALID_ENTITY) {
SceneManager::Get().MoveEntity(sourceId, INVALID_ENTITY);
if (sourceEntity && sourceEntity->parent != INVALID_ENTITY_ID) {
SceneManager::Get().MoveEntity(sourceId, INVALID_ENTITY_ID);
}
}
}
@@ -102,7 +102,7 @@ void HierarchyPanel::RenderEntity(EntityID id, const std::string& filter) {
sceneManager.RenameEntity(id, m_renameBuffer);
}
m_renaming = false;
m_renamingEntity = INVALID_ENTITY;
m_renamingEntity = INVALID_ENTITY_ID;
}
if (!ImGui::IsItemActive() && ImGui::IsMouseClicked(0)) {
@@ -110,7 +110,7 @@ void HierarchyPanel::RenderEntity(EntityID id, const std::string& filter) {
sceneManager.RenameEntity(id, m_renameBuffer);
}
m_renaming = false;
m_renamingEntity = INVALID_ENTITY;
m_renamingEntity = INVALID_ENTITY_ID;
}
} else {
bool isOpen = ImGui::TreeNodeEx(entity->name.c_str(), flags);
@@ -181,7 +181,7 @@ void HierarchyPanel::RenderContextMenu(EntityID id) {
if (ImGui::MenuItem("Duplicate", "Ctrl+D")) {
EntityID newId = sceneManager.DuplicateEntity(id);
if (newId != INVALID_ENTITY) {
if (newId != INVALID_ENTITY_ID) {
selectionManager.SetSelectedEntity(newId);
}
}
@@ -249,19 +249,19 @@ void HierarchyPanel::HandleDragDrop(EntityID id) {
if (ImGui::BeginDragDropTarget()) {
if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload("ENTITY_ID")) {
EntityID sourceId = *(const EntityID*)payload->Data;
if (sourceId != id && sourceId != INVALID_ENTITY) {
if (sourceId != id && sourceId != INVALID_ENTITY_ID) {
const Entity* targetEntity = sceneManager.GetEntity(id);
const Entity* sourceEntity = sceneManager.GetEntity(sourceId);
bool isValidMove = true;
EntityID checkParent = targetEntity ? targetEntity->parent : INVALID_ENTITY;
while (checkParent != INVALID_ENTITY) {
EntityID checkParent = targetEntity ? targetEntity->parent : INVALID_ENTITY_ID;
while (checkParent != INVALID_ENTITY_ID) {
if (checkParent == sourceId) {
isValidMove = false;
break;
}
const Entity* parentEntity = sceneManager.GetEntity(checkParent);
checkParent = parentEntity ? parentEntity->parent : INVALID_ENTITY;
checkParent = parentEntity ? parentEntity->parent : INVALID_ENTITY_ID;
}
if (isValidMove && sourceEntity && sourceEntity->parent != id) {
@@ -281,13 +281,13 @@ void HierarchyPanel::HandleKeyboardShortcuts() {
if (ImGui::IsWindowFocused()) {
if (ImGui::IsKeyPressed(ImGuiKey_Delete)) {
if (selectedId != INVALID_ENTITY) {
if (selectedId != INVALID_ENTITY_ID) {
sceneManager.DeleteEntity(selectedId);
}
}
if (ImGui::IsKeyPressed(ImGuiKey_F2)) {
if (selectedId != INVALID_ENTITY) {
if (selectedId != INVALID_ENTITY_ID) {
const Entity* entity = sceneManager.GetEntity(selectedId);
if (entity) {
m_renaming = true;
@@ -301,7 +301,7 @@ void HierarchyPanel::HandleKeyboardShortcuts() {
ImGuiIO& io = ImGui::GetIO();
if (io.KeyCtrl) {
if (ImGui::IsKeyPressed(ImGuiKey_C)) {
if (selectedId != INVALID_ENTITY) {
if (selectedId != INVALID_ENTITY_ID) {
sceneManager.CopyEntity(selectedId);
}
}
@@ -313,9 +313,9 @@ void HierarchyPanel::HandleKeyboardShortcuts() {
}
if (ImGui::IsKeyPressed(ImGuiKey_D)) {
if (selectedId != INVALID_ENTITY) {
if (selectedId != INVALID_ENTITY_ID) {
EntityID newId = sceneManager.DuplicateEntity(selectedId);
if (newId != INVALID_ENTITY) {
if (newId != INVALID_ENTITY_ID) {
selectionManager.SetSelectedEntity(newId);
}
}