3#include "editor/assets/Assets.h"
4#include "core/ecs/ECS.h"
5#include "core/ecs/ComponentFactory.h"
11 void SceneUI::DrawSceneUI()
13 ImGui::Begin(
"Scene");
14 for (
auto entity : Vivid::ECS::g_Entities)
16 if (ImGui::Selectable(entity.second->GetName().c_str(), m_SelectedEntity == entity.second.get()))
18 m_SelectedEntity = entity.second.get();
22 unsigned int texId = VividGui::Assets::GetInstance()->GetTexPlus()->GetRendererID();
23 if (ImGui::ImageButton((ImTextureID)texId,
24 ImVec2(VividGui::Assets::GetInstance()->GetButtonWidth(), VividGui::Assets::GetInstance()->GetButtonWidth()),
25 { 0, 0 }, { 1, 1 }, 2))
27 Vivid::ECS::CreateEntity(
"Entity" + std::to_string(Vivid::ECS::s_EntityID));
32 ImGui::Begin(
"Inspector");
33 m_SelectedEntity->ImguiRender();
35 char* name = m_SelectedEntity->GetName().data();
36 static const ImGuiInputTextFlags flags = ImGuiInputTextFlags_EnterReturnsTrue;
37 if (ImGui::InputText(m_SelectedEntity->GetName().c_str(), name, 255, flags))
41 m_SelectedEntity->SetName(
"Entity" + std::to_string(Vivid::ECS::s_EntityID));
46 for (
int i = 0; i < temp.size(); i++)
53 m_SelectedEntity->SetName(String(name));
56 for (
auto& entity : Vivid::ECS::g_Entities)
58 if (entity.first == m_SelectedEntity->GetEntityID())
63 if (m_SelectedEntity->GetName() == entity.second->GetName())
65 ImGui::Text(
"Name Already Exist");
71 if (ImGui::BeginPopupContextWindow())
73 if (ImGui::BeginMenu(
"Add Component"))
75 for (
auto ct : Vivid::g_AllComponentStrings)
77 bool doesComponentExist =
false;
78 auto component = m_SelectedEntity->
HasComponent(ct.first);
81 doesComponentExist =
true;
84 if (ImGui::MenuItem(Vivid::g_AllComponentStrings.at(ct.first).c_str(), NULL, doesComponentExist))
86 if (doesComponentExist)
88 if (ct.first == Vivid::ComponentType::TransformComponent)
90 doesComponentExist =
true;
93 Vivid::ECS::RemoveComponent(component, m_SelectedEntity->GetEntityID());
97 Vivid::ECS::AddComponent(component, m_SelectedEntity->GetEntityID());
107 ImGui::SetWindowPos(ImVec2(200, 50));
111 void SceneUI::DrawGizmo(
Camera* camera)
113 if (m_SelectedEntity)
115 m_SelectedEntity->DrawGizmo(camera);
A class that represents the camera.
int HasComponent(ComponentType ct)
Checks if the Entity has a component.