mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-21 20:08:40 +03:00
Merge branch 'main' of https://github.com/antopilo/Nuake
# Conflicts: # Editor/src/Misc/GizmoDrawer.cpp # Editor/src/Windows/FileSystemUI.cpp
This commit is contained in:
36
Editor/src/ComponentsPanel/BonePanel.h
Normal file
36
Editor/src/ComponentsPanel/BonePanel.h
Normal file
@@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
#include "ComponentPanel.h"
|
||||
|
||||
#include <src/Core/FileSystem.h>
|
||||
#include <src/Core/Maths.h>
|
||||
#include <src/Scene/Components/BoneComponent.h>
|
||||
#include <src/Scene/Entities/ImGuiHelper.h>
|
||||
|
||||
class BonePanel : ComponentPanel
|
||||
{
|
||||
public:
|
||||
BonePanel() {}
|
||||
|
||||
void Draw(Nuake::Entity entity) override
|
||||
{
|
||||
using namespace Nuake;
|
||||
|
||||
if (!entity.HasComponent<BoneComponent>())
|
||||
return;
|
||||
|
||||
auto& component = entity.GetComponent<BoneComponent>();
|
||||
BeginComponentTable(BONE, BoneComponent);
|
||||
{
|
||||
{
|
||||
ImGui::Text("Name");
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
ImGui::InputText("##BoneName", &component.Name);
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
ComponentTableReset(component.Name, "");
|
||||
}
|
||||
}
|
||||
EndComponentTable();
|
||||
}
|
||||
};
|
||||
@@ -12,8 +12,9 @@
|
||||
class SkinnedModelPanel : ComponentPanel
|
||||
{
|
||||
private:
|
||||
Scope<ModelResourceInspector> _modelInspector;
|
||||
bool _expanded = false;
|
||||
Scope<ModelResourceInspector> m_ModelInspector;
|
||||
bool m_Expanded = false;
|
||||
std::string m_QueuedModelPath;
|
||||
|
||||
public:
|
||||
SkinnedModelPanel()
|
||||
@@ -45,9 +46,9 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
if (_expanded)
|
||||
if (m_Expanded)
|
||||
{
|
||||
_modelInspector->Draw();
|
||||
m_ModelInspector->Draw();
|
||||
}
|
||||
|
||||
if (ImGui::BeginDragDropTarget())
|
||||
@@ -64,15 +65,107 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
component.ModelPath = fullPath;
|
||||
component.LoadModel();
|
||||
m_QueuedModelPath = fullPath;
|
||||
ImGui::OpenPopup("Create Skeleton");
|
||||
}
|
||||
}
|
||||
ImGui::EndDragDropTarget();
|
||||
}
|
||||
|
||||
if (ImGui::BeginPopupModal("Create Skeleton", NULL, ImGuiWindowFlags_AlwaysAutoResize))
|
||||
{
|
||||
ImGui::SetItemDefaultFocus();
|
||||
ImGui::Text("Would you like to create the skeleton structure in the scene tree?");
|
||||
ImGui::Separator();
|
||||
|
||||
if (ImGui::Button("OK", ImVec2(120, 0)))
|
||||
{
|
||||
component.ModelPath = m_QueuedModelPath;
|
||||
component.LoadModel();
|
||||
|
||||
Scene* scene = entity.GetScene();
|
||||
scene->CreateSkeleton(entity);
|
||||
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
|
||||
ImGui::SetItemDefaultFocus();
|
||||
ImGui::SameLine();
|
||||
|
||||
if (ImGui::Button("Cancel", ImVec2(120, 0)))
|
||||
{
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ComponentTableReset(component.ModelPath, "");
|
||||
|
||||
if (component.ModelResource)
|
||||
{
|
||||
auto& model = component.ModelResource;
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
{
|
||||
ImGui::Text("Playing");
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
ImGui::Checkbox("##playing", &model->IsPlaying);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ComponentTableReset(model->IsPlaying, true);
|
||||
ImGui::TableNextColumn();
|
||||
}
|
||||
|
||||
if(model->GetCurrentAnimation())
|
||||
{
|
||||
ImGui::Text("Animation");
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
uint32_t animIndex = model->GetCurrentAnimationIndex();
|
||||
uint32_t oldAnimIndex = animIndex;
|
||||
auto& animations = model->GetAnimations();
|
||||
if (ImGui::BeginCombo("Type", model->GetCurrentAnimation()->GetName().c_str()))
|
||||
{
|
||||
for (int n = 0; n < model->GetAnimationsCount(); n++)
|
||||
{
|
||||
bool is_selected = (animIndex == n);
|
||||
std::string animName = animations[n]->GetName();
|
||||
|
||||
if (animName.empty())
|
||||
{
|
||||
animName = "Empty";
|
||||
}
|
||||
|
||||
if (ImGui::Selectable(animName.c_str(), is_selected))
|
||||
{
|
||||
animIndex = n;
|
||||
}
|
||||
|
||||
if (is_selected)
|
||||
ImGui::SetItemDefaultFocus();
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
|
||||
if (animIndex != oldAnimIndex)
|
||||
{
|
||||
model->PlayAnimation(animIndex);
|
||||
}
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0));
|
||||
std::string resetLabel = std::string(ICON_FA_UNDO) + "##ResetAnimId";
|
||||
if (ImGui::Button(resetLabel.c_str()))
|
||||
{
|
||||
model->PlayAnimation(0);
|
||||
}
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
EndComponentTable();
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <src/Resource/ModelLoader.h>
|
||||
#include <src/Rendering/RenderList.h>
|
||||
#include <src/Rendering/Renderer.h>
|
||||
|
||||
#include <dependencies/GLEW/include/GL/glew.h>
|
||||
|
||||
@@ -17,7 +18,7 @@
|
||||
#include <src/Scene/Components/MeshCollider.h>
|
||||
#include <src/Scene/Components/ModelComponent.h>
|
||||
#include <src/Scene/Components/ParticleEmitterComponent.h>
|
||||
|
||||
#include <src/Scene/Components/BoneComponent.h>
|
||||
|
||||
GizmoDrawer::GizmoDrawer()
|
||||
{
|
||||
@@ -275,69 +276,98 @@ void GizmoDrawer::DrawGizmos(Ref<Scene> scene)
|
||||
glLineWidth(1.0f);
|
||||
RenderList renderList;
|
||||
|
||||
auto gizmoShader = ShaderManager::GetShader("resources/Shaders/gizmo.shader");
|
||||
gizmoShader->Bind();
|
||||
gizmoShader->SetUniformMat4f("u_View", scene->m_EditorCamera->GetTransform());
|
||||
gizmoShader->SetUniformMat4f("u_Projection", scene->m_EditorCamera->GetPerspective());
|
||||
|
||||
RenderCommand::Disable(RendererEnum::FACE_CULL);
|
||||
|
||||
// Camera
|
||||
auto camView = scene->m_Registry.view<TransformComponent, CameraComponent>();
|
||||
for (auto e : camView)
|
||||
{
|
||||
auto& [transform, cam] = scene->m_Registry.get<TransformComponent, CameraComponent>(e);
|
||||
gizmoShader->SetUniformTex("gizmo_texture", TextureManager::Get()->GetTexture("resources/Gizmos/camera.png").get());
|
||||
auto [transform, camera] = scene->m_Registry.get<TransformComponent, CameraComponent>(e);
|
||||
|
||||
renderList.AddToRenderList(_gizmos["cam"]->GetMeshes()[0], transform.GetGlobalTransform());
|
||||
auto initialTransform = transform.GetGlobalTransform();
|
||||
Matrix4 particleTransform = initialTransform;
|
||||
particleTransform = glm::inverse(scene->m_EditorCamera->GetTransform());
|
||||
|
||||
auto view = transform.GetGlobalTransform();
|
||||
Frustum& frustum = cam.CameraInstance->GetFrustum();
|
||||
auto& frustumCorners = frustum.GetPoints();
|
||||
// Translation
|
||||
const Vector3& particleGlobalPosition = transform.GetGlobalPosition();
|
||||
particleTransform[3] = initialTransform[3];
|
||||
|
||||
constexpr int frustumEdges[12][2] = {
|
||||
{0, 1}, {1, 3}, {3, 2}, {2, 0}, // Near plane edges
|
||||
{4, 5}, {5, 7}, {7, 6}, {6, 4}, // Far plane edges
|
||||
{0, 4}, {1, 5}, {2, 6}, {3, 7} // Connection lines
|
||||
};
|
||||
|
||||
glBegin(GL_LINES);
|
||||
|
||||
for (int i = 0; i < 12; ++i) {
|
||||
int startIdx = frustumEdges[i][0];
|
||||
int endIdx = frustumEdges[i][1];
|
||||
const Vector3& startCorner = view * Vector4(frustumCorners[startIdx], 1.0f);
|
||||
const Vector3& endCorner = frustumCorners[endIdx];
|
||||
glVertex3f(startCorner.x, startCorner.y, startCorner.z);
|
||||
glVertex3f(endCorner.x, endCorner.y, endCorner.z);
|
||||
}
|
||||
|
||||
glEnd();
|
||||
particleTransform = glm::scale(particleTransform, Vector3(0.5, 0.5, 0.5));
|
||||
|
||||
renderList.AddToRenderList(Renderer::QuadMesh, particleTransform);
|
||||
}
|
||||
|
||||
renderList.Flush(flatShader, true);
|
||||
renderList.Flush(gizmoShader, true);
|
||||
|
||||
// Lights
|
||||
auto lightView = scene->m_Registry.view<TransformComponent, LightComponent>();
|
||||
for (auto e : lightView)
|
||||
{
|
||||
gizmoShader->SetUniformTex("gizmo_texture", TextureManager::Get()->GetTexture("resources/Gizmos/light.png").get());
|
||||
auto [transform, light] = scene->m_Registry.get<TransformComponent, LightComponent>(e);
|
||||
|
||||
flatShader->SetUniformVec4("u_Color", Vector4(light.Color, 1.0f));
|
||||
renderList.AddToRenderList(_gizmos["light"]->GetMeshes()[0], transform.GetGlobalTransform());
|
||||
renderList.Flush(flatShader, true);
|
||||
}
|
||||
renderList.Flush(flatShader, true);
|
||||
auto initialTransform = transform.GetGlobalTransform();
|
||||
Matrix4 particleTransform = initialTransform;
|
||||
particleTransform = glm::inverse(scene->m_EditorCamera->GetTransform());
|
||||
|
||||
// Translation
|
||||
const Vector3& particleGlobalPosition = transform.GetGlobalPosition();
|
||||
particleTransform[3] = initialTransform[3];
|
||||
|
||||
particleTransform = glm::scale(particleTransform, Vector3(0.5, 0.5, 0.5));
|
||||
|
||||
renderList.AddToRenderList(Renderer::QuadMesh, particleTransform);
|
||||
}
|
||||
|
||||
renderList.Flush(gizmoShader, true);
|
||||
|
||||
// Player
|
||||
auto characterControllerView = scene->m_Registry.view<TransformComponent, CharacterControllerComponent>();
|
||||
for (auto e : characterControllerView)
|
||||
{
|
||||
auto [transformComponent, characterControllerComponent] = scene->m_Registry.get<TransformComponent, CharacterControllerComponent>(e);
|
||||
gizmoShader->SetUniformTex("gizmo_texture", TextureManager::Get()->GetTexture("resources/Gizmos/player.png").get());
|
||||
auto [transform, characterControllerComponent] = scene->m_Registry.get<TransformComponent, CharacterControllerComponent>(e);
|
||||
|
||||
flatShader->SetUniformVec4("u_Color", Vector4(0.0f, 1.0f, 0.4f, 1.0f));
|
||||
auto initialTransform = transform.GetGlobalTransform();
|
||||
Matrix4 particleTransform = initialTransform;
|
||||
particleTransform = glm::inverse(scene->m_EditorCamera->GetTransform());
|
||||
|
||||
const auto scaledTransform = glm::scale(transformComponent.GetGlobalTransform(), Vector3(0.25f, 0.25f, 0.25f));
|
||||
renderList.AddToRenderList(_gizmos["player"]->GetMeshes()[0], scaledTransform);
|
||||
renderList.Flush(flatShader, true);
|
||||
// Translation
|
||||
const Vector3& particleGlobalPosition = transform.GetGlobalPosition();
|
||||
particleTransform[3] = initialTransform[3];
|
||||
|
||||
particleTransform = glm::scale(particleTransform, Vector3(0.5, 0.5, 0.5));
|
||||
|
||||
renderList.AddToRenderList(Renderer::QuadMesh, particleTransform);
|
||||
}
|
||||
|
||||
renderList.Flush(flatShader, true);
|
||||
renderList.Flush(gizmoShader, true);
|
||||
|
||||
RenderCommand::Disable(RendererEnum::FACE_CULL);
|
||||
// Bones
|
||||
auto boneView = scene->m_Registry.view<TransformComponent, BoneComponent>();
|
||||
for (auto e : boneView)
|
||||
{
|
||||
gizmoShader->SetUniformTex("gizmo_texture", TextureManager::Get()->GetTexture("resources/Gizmos/bone.png").get());
|
||||
auto [transform, boneComponent] = scene->m_Registry.get<TransformComponent, BoneComponent>(e);
|
||||
|
||||
auto initialTransform = transform.GetGlobalTransform();
|
||||
Matrix4 particleTransform = initialTransform;
|
||||
particleTransform = glm::inverse(scene->m_EditorCamera->GetTransform());
|
||||
|
||||
// Translation
|
||||
const Vector3& particleGlobalPosition = transform.GetGlobalPosition();
|
||||
particleTransform[3] = initialTransform[3];
|
||||
particleTransform = glm::scale(particleTransform, Vector3(0.1, 0.1, 0.1));
|
||||
|
||||
renderList.AddToRenderList(Renderer::QuadMesh, particleTransform);
|
||||
}
|
||||
|
||||
renderList.Flush(gizmoShader, true);
|
||||
|
||||
RenderCommand::Enable(RendererEnum::DEPTH_TEST);
|
||||
}
|
||||
@@ -252,7 +252,7 @@ namespace Nuake {
|
||||
|
||||
m_IsViewportFocused = ImGui::IsWindowFocused();
|
||||
|
||||
if (m_IsHoveringViewport && Input::IsMouseButtonPressed(GLFW_MOUSE_BUTTON_1) && !ImGuizmo::IsUsing())
|
||||
if (m_IsHoveringViewport && Input::IsMouseButtonPressed(GLFW_MOUSE_BUTTON_1) && !ImGuizmo::IsUsing() && m_IsViewportFocused)
|
||||
{
|
||||
const auto windowPosNuake = Vector2(windowPos.x, windowPos.y);
|
||||
auto& gbuffer = Engine::GetCurrentScene()->m_SceneRenderer->GetGBuffer();
|
||||
@@ -289,7 +289,9 @@ namespace Nuake {
|
||||
Entity QueueDeletion;
|
||||
void EditorInterface::DrawEntityTree(Entity e)
|
||||
{
|
||||
ImGuiTreeNodeFlags base_flags = ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_FramePadding | ImGuiTreeNodeFlags_OpenOnDoubleClick | ImGuiTreeNodeFlags_SpanAvailWidth;
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, ImVec2{ 0.0f, 0.0f });
|
||||
|
||||
ImGuiTreeNodeFlags base_flags = ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_FramePadding | ImGuiTreeNodeFlags_OpenOnDoubleClick | ImGuiTreeNodeFlags_SpanFullWidth;
|
||||
|
||||
NameComponent& nameComponent = e.GetComponent<NameComponent>();
|
||||
std::string name = nameComponent.Name;
|
||||
@@ -298,8 +300,6 @@ namespace Nuake {
|
||||
if (Selection.Type == EditorSelectionType::Entity && Selection.Entity == e)
|
||||
base_flags |= ImGuiTreeNodeFlags_Selected;
|
||||
|
||||
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
// Write in normal font.
|
||||
@@ -315,10 +315,8 @@ namespace Nuake {
|
||||
{
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(0, 255, 0, 255));
|
||||
}
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(8, 8));
|
||||
|
||||
bool open = ImGui::TreeNodeEx(name.c_str(), base_flags);
|
||||
ImGui::PopStyleVar();
|
||||
|
||||
if(nameComponent.IsPrefab && e.HasComponent<PrefabComponent>())
|
||||
ImGui::PopStyleColor();
|
||||
@@ -414,21 +412,20 @@ namespace Nuake {
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, ImVec2{ 0.0f, 0.0f });
|
||||
ImGui::TextColored(ImVec4(0.5, 0.5, 0.5, 1.0), GetEntityTypeName(e).c_str());
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
{
|
||||
bool& isVisible = e.GetComponent<VisibilityComponent>().Visible;
|
||||
char* visibilityIcon = isVisible ? ICON_FA_EYE : ICON_FA_EYE_SLASH;
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, { 0, 0, 0, 0 });
|
||||
if (ImGui::Button(visibilityIcon, { 40, 36 }))
|
||||
if (ImGui::Button(visibilityIcon, { 40, 0 }))
|
||||
{
|
||||
isVisible = !isVisible;
|
||||
}
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
|
||||
ImGui::PopStyleVar();
|
||||
|
||||
|
||||
if (open)
|
||||
{
|
||||
// Caching list to prevent deletion while iterating.
|
||||
@@ -438,7 +435,8 @@ namespace Nuake {
|
||||
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
|
||||
ImGui::PopStyleVar();
|
||||
ImGui::PopFont();
|
||||
}
|
||||
|
||||
@@ -763,6 +761,21 @@ namespace Nuake {
|
||||
ImGui::TableSetupColumn("set", 0, 0.6);
|
||||
ImGui::TableSetupColumn("reset", 0, 0.1);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
{
|
||||
// Title
|
||||
ImGui::Text("SSAO");
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
ImGui::Checkbox("##SSAOEnabled", &env->SSAOEnabled);
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
// Reset button
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0));
|
||||
std::string resetSSAO = ICON_FA_UNDO + std::string("##resetSSAO");
|
||||
if (ImGui::Button(resetSSAO.c_str())) env->SSAOEnabled = false;
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
ImGui::TableNextColumn();
|
||||
{
|
||||
// Title
|
||||
@@ -854,10 +867,25 @@ namespace Nuake {
|
||||
ImGui::TableSetupColumn("set", 0, 0.6);
|
||||
ImGui::TableSetupColumn("reset", 0, 0.1);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
SSR* ssr = scene->m_SceneRenderer->mSSR.get();
|
||||
{
|
||||
ImGui::TableNextColumn();
|
||||
// Title
|
||||
ImGui::Text("SSR");
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
ImGui::Checkbox("##SSREnabled", &env->SSREnabled);
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
// Reset button
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0));
|
||||
std::string resetSSR = ICON_FA_UNDO + std::string("##resetSSR");
|
||||
if (ImGui::Button(resetSSR.c_str())) env->SSREnabled = false;
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
|
||||
{
|
||||
ImGui::TableNextColumn();
|
||||
// Title
|
||||
ImGui::Text("SSR RayStep");
|
||||
ImGui::TableNextColumn();
|
||||
@@ -1017,6 +1045,7 @@ namespace Nuake {
|
||||
|
||||
std::string title = ICON_FA_TREE + std::string(" Hierarchy");
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0));
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, ImVec2(4, 0));
|
||||
if (ImGui::Begin(title.c_str()))
|
||||
{
|
||||
// Buttons to add and remove entity.
|
||||
@@ -1038,16 +1067,18 @@ namespace Nuake {
|
||||
ImGui::EndChild();
|
||||
// Draw a tree of entities.
|
||||
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(26.f / 255.0f, 26.f / 255.0f, 26.f / 255.0f, 1));
|
||||
|
||||
if (ImGui::BeginChild("Scene tree", ImGui::GetContentRegionAvail(), false))
|
||||
{
|
||||
if (ImGui::BeginTable("entity_table", 2, ImGuiTableFlags_BordersInnerV | ImGuiTableFlags_NoBordersInBody | ImGuiTableFlags_SizingStretchProp))
|
||||
if (ImGui::BeginTable("entity_table", 3, ImGuiTableFlags_BordersInnerV | ImGuiTableFlags_SizingStretchProp))
|
||||
{
|
||||
ImGui::TableSetupColumn(" Label", ImGuiTableColumnFlags_NoResize | ImGuiTableColumnFlags_IndentEnable);
|
||||
std::string icon = ICON_FA_EYE;
|
||||
ImGui::TableSetupColumn((" " + icon).c_str(), ImGuiTableColumnFlags_NoResize | ImGuiTableColumnFlags_IndentDisable | ImGuiTableColumnFlags_WidthFixed, 32);
|
||||
ImGui::TableSetupColumn("Label", ImGuiTableColumnFlags_IndentEnable);
|
||||
ImGui::TableSetupColumn("Type", ImGuiTableColumnFlags_IndentEnable);
|
||||
ImGui::TableSetupColumn("Visibility", ImGuiTableColumnFlags_NoResize | ImGuiTableColumnFlags_IndentDisable | ImGuiTableColumnFlags_WidthFixed);
|
||||
ImGui::TableHeadersRow();
|
||||
ImGui::TableNextRow();
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, ImVec2(0, 0));
|
||||
std::vector<Entity> entities = scene->GetAllEntities();
|
||||
for (Entity e : entities)
|
||||
{
|
||||
@@ -1060,16 +1091,11 @@ namespace Nuake {
|
||||
// Write in normal font.
|
||||
ImGui::PushFont(normalFont);
|
||||
|
||||
// Small icons + name.
|
||||
std::string label = ICON_FA_CIRCLE + std::string(" ") + name;
|
||||
|
||||
// Draw all entity without parents.
|
||||
if (!e.GetComponent<ParentComponent>().HasParent)
|
||||
{
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, ImVec2{ 0.0f, 0.0f });
|
||||
// Recursively draw childrens.
|
||||
DrawEntityTree(e);
|
||||
ImGui::PopStyleVar();
|
||||
}
|
||||
|
||||
// Pop font.
|
||||
@@ -1079,6 +1105,7 @@ namespace Nuake {
|
||||
//if (ImGui::BeginPopupContextItem())
|
||||
// ImGui::EndPopup();
|
||||
}
|
||||
ImGui::PopStyleVar();
|
||||
}
|
||||
|
||||
ImGui::EndTable();
|
||||
@@ -1110,9 +1137,9 @@ namespace Nuake {
|
||||
QueueDeletion = Entity{ (entt::entity)-1, scene.get() };
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
ImGui::PopStyleVar();
|
||||
ImGui::PopStyleVar();
|
||||
}
|
||||
|
||||
bool EditorInterface::EntityContainsItself(Entity source, Entity target)
|
||||
@@ -1632,4 +1659,36 @@ namespace Nuake {
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0.5f, 0.5f));
|
||||
FontManager::LoadFonts();
|
||||
}
|
||||
|
||||
std::string EditorInterface::GetEntityTypeName(const Entity& entity) const
|
||||
{
|
||||
std::string entityTypeName = "";
|
||||
|
||||
if (entity.HasComponent<LightComponent>())
|
||||
{
|
||||
entityTypeName = "Light";
|
||||
}
|
||||
|
||||
if (entity.HasComponent<RigidBodyComponent>())
|
||||
{
|
||||
entityTypeName = "Rigidbody";
|
||||
}
|
||||
|
||||
if (entity.HasComponent<CharacterControllerComponent>())
|
||||
{
|
||||
entityTypeName = "Character Controller";
|
||||
}
|
||||
|
||||
if (entity.HasComponent<BoneComponent>())
|
||||
{
|
||||
entityTypeName = "Bone";
|
||||
}
|
||||
|
||||
if (entity.HasComponent<PrefabComponent>())
|
||||
{
|
||||
entityTypeName = "Prefab";
|
||||
}
|
||||
|
||||
return entityTypeName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,5 +61,8 @@ namespace Nuake
|
||||
|
||||
bool ShouldDrawAxis() const { return m_DrawAxis; }
|
||||
bool ShouldDrawCollision() const { return m_DebugCollisions; }
|
||||
|
||||
private:
|
||||
std::string GetEntityTypeName(const Entity& entity) const;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -104,6 +104,7 @@ void EditorSelectionPanel::DrawEntity(Nuake::Entity entity)
|
||||
mSpritePanel.Draw(entity);
|
||||
mMeshPanel.Draw(entity);
|
||||
mSkinnedModelPanel.Draw(entity);
|
||||
mBonePanel.Draw(entity);
|
||||
mQuakeMapPanel.Draw(entity);
|
||||
mCameraPanel.Draw(entity);
|
||||
mRigidbodyPanel.Draw(entity);
|
||||
@@ -131,8 +132,11 @@ void EditorSelectionPanel::DrawAddComponentMenu(Nuake::Entity entity)
|
||||
MenuItemComponent("Wren Script", Nuake::WrenScriptComponent)
|
||||
MenuItemComponent("Camera", Nuake::CameraComponent)
|
||||
MenuItemComponent("Light", Nuake::LightComponent)
|
||||
ImGui::Separator();
|
||||
MenuItemComponent("Model", Nuake::ModelComponent)
|
||||
MenuItemComponent("Skinned Model", Nuake::SkinnedModelComponent)
|
||||
MenuItemComponent("Bone", Nuake::BoneComponent)
|
||||
ImGui::Separator();
|
||||
MenuItemComponent("Sprite", Nuake::SpriteComponent)
|
||||
MenuItemComponent("Particle Emitter", Nuake::ParticleEmitterComponent)
|
||||
ImGui::Separator();
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "../ComponentsPanel/SpritePanel.h"
|
||||
#include "../ComponentsPanel/ParticleEmitterPanel.h"
|
||||
#include "../ComponentsPanel/SkinnedModelPanel.h"
|
||||
|
||||
#include "../ComponentsPanel/BonePanel.h"
|
||||
|
||||
class EditorSelectionPanel
|
||||
{
|
||||
@@ -42,6 +42,7 @@ private:
|
||||
SpritePanel mSpritePanel;
|
||||
CharacterControllerPanel mCharacterControllerPanel;
|
||||
ParticleEmitterPanel mParticleEmitterPanel;
|
||||
BonePanel mBonePanel;
|
||||
|
||||
Ref<Nuake::File> currentFile;
|
||||
Ref<Nuake::Resource> selectedResource;
|
||||
|
||||
@@ -62,6 +62,7 @@ namespace Nuake
|
||||
void FileSystemUI::DrawDirectory(Ref<Directory> directory, uint32_t drawId)
|
||||
{
|
||||
ImGui::PushFont(FontManager::GetFont(Icons));
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 4.0f);
|
||||
const char* icon = ICON_FA_FOLDER;
|
||||
const std::string id = ICON_FA_FOLDER + std::string("##") + directory->name;
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 4.0f);
|
||||
@@ -69,9 +70,7 @@ namespace Nuake
|
||||
{
|
||||
m_CurrentDirectory = directory;
|
||||
}
|
||||
|
||||
ImGui::PopStyleVar();
|
||||
|
||||
const std::string hoverMenuId = std::string("item_hover_menu") + std::to_string(drawId);
|
||||
if (ImGui::IsItemHovered() && ImGui::IsMouseReleased(1))
|
||||
{
|
||||
@@ -191,6 +190,7 @@ namespace Nuake
|
||||
void FileSystemUI::DrawFile(Ref<File> file, uint32_t drawId)
|
||||
{
|
||||
ImGui::PushFont(EditorInterface::bigIconFont);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 4.0f);
|
||||
std::string fileExtension = file->GetExtension();
|
||||
if (fileExtension == ".png" || fileExtension == ".jpg")
|
||||
{
|
||||
@@ -215,7 +215,7 @@ namespace Nuake
|
||||
Editor->Selection = EditorSelection(file);
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::PopStyleVar();
|
||||
if (ImGui::BeginDragDropSource())
|
||||
{
|
||||
char pathBuffer[256];
|
||||
@@ -229,7 +229,7 @@ namespace Nuake
|
||||
{
|
||||
dragType = "_Map";
|
||||
}
|
||||
else if (fileExtension == ".obj" || fileExtension == ".mdl" || fileExtension == ".gltf" || fileExtension == ".md3" || fileExtension == ".fbx")
|
||||
else if (fileExtension == ".obj" || fileExtension == ".mdl" || fileExtension == ".gltf" || fileExtension == ".md3" || fileExtension == ".fbx" || fileExtension == ".glb")
|
||||
{
|
||||
dragType = "_Model";
|
||||
}
|
||||
@@ -676,8 +676,8 @@ namespace Nuake
|
||||
if (child)
|
||||
{
|
||||
int width = avail.x;
|
||||
ImVec2 buttonSize = ImVec2(110, 110);
|
||||
int amount = (int)(width / buttonSize.x);
|
||||
ImVec2 buttonSize = ImVec2(80, 80);
|
||||
int amount = (int)(width / 110);
|
||||
if (amount <= 0) amount = 1;
|
||||
|
||||
int i = 1; // current amount of item per row.
|
||||
|
||||
Reference in New Issue
Block a user