#include "Inspector.h" void Inspector::Draw() { } void Inspector::AddComponentDropDown(YoggieEngine::Entity& selected) { static char* names[] = { "Script Component", "Camera Component", "Light Component" }; if (ImGui::Button("Add Component")) ImGui::OpenPopup("Component picker"); ImGui::SameLine(); if (ImGui::BeginPopup("Component picker")) { for (int i = 0; i < IM_ARRAYSIZE(names); i++) if (ImGui::MenuItem(names[i])) { std::cout << "Add a " << names[i] << " to " << selected.GetComponent().name << std::endl; } ImGui::EndPopup(); } ImGui::NewLine(); } void Inspector::ShowComponents(YoggieEngine::Entity& selected) { auto component = selected.GetComponent(); ImGui::InputText("Name:", (char*)component.name.c_str(), component.name.size() * sizeof(char), ImGuiInputTextFlags_ReadOnly); if (selected.HasComponent()) { auto& transform = selected.GetComponent(); if (ImGui::CollapsingHeader("Transform", ImGuiTreeNodeFlags_DefaultOpen)) { ImGui::DragFloat3("Position", glm::value_ptr(transform.Position), 0.1f); ImGui::DragFloat3("Rotation", glm::value_ptr(transform.Rotation), 0.1f); ImGui::DragFloat3("Scale", glm::value_ptr(transform.Scale), 0.1f, 0.0f); } if (selected.HasComponent()) { ImGui::Text("Has relation"); } } if (selected.HasComponent()) { auto& render3d = selected.GetComponent(); if (ImGui::CollapsingHeader("Render3D", ImGuiTreeNodeFlags_DefaultOpen)) { ImGui::ColorEdit3("Colour", glm::value_ptr(render3d.color)); ImGui::Checkbox("Use static rendering:", &render3d.isStatic); } } static bool deferred = true; if (selected.HasComponent()) { auto& light = selected.GetComponent(); if (ImGui::CollapsingHeader("Light", ImGuiTreeNodeFlags_DefaultOpen)) { ImGui::ColorEdit3("Colour", glm::value_ptr(light.Color)); ImGui::Checkbox("Deferred", &deferred); } } if (selected.HasComponent ()) { auto& camera = selected.GetComponent(); if (ImGui::CollapsingHeader("Camera")) { ImGui::DragFloat3("Position:", glm::value_ptr(camera.Position), 0.01f); ImGui::DragFloat3("Rotation:", glm::value_ptr(camera.Rotation), 0.01f); } } if (selected.HasComponent()) { auto& rigibody = selected.GetComponent(); if (ImGui::CollapsingHeader("RigidBody")) { } } if (selected.HasComponent()) { ComponentView("Scripting", [] { ImGui::LabelText("##--", "Hello scripting"); }); } } void ComponentView(const std::string& componentName, voidFunction func) { ImGuiWindowFlags_ window_flags = ImGuiWindowFlags_None; ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 5.0f); ImGui::BeginChild(componentName.c_str()); func(); ImGui::EndChild(); ImGui::PopStyleVar(); }