mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-09 20:08:57 +03:00
Can now rename entities pressing f2 or double clicking and selecting an entity should unfold the tree
This commit is contained in:
@@ -51,7 +51,6 @@
|
||||
#include <src/UI/ImUI.h>
|
||||
#include "src/Core/FileSystem.h"
|
||||
#include <src/Resource/StaticResources.h>
|
||||
#include <src/Scripting/ScriptingEngineNet.h>
|
||||
#include <src/Threading/JobSystem.h>
|
||||
#include "../Commands/Commands/Commands.h"
|
||||
#include <src/Resource/ModelLoader.h>
|
||||
@@ -345,6 +344,7 @@ namespace Nuake {
|
||||
if (ent.IsValid())
|
||||
{
|
||||
Selection = EditorSelection(ent);
|
||||
foundSomethingToSelect = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -354,6 +354,11 @@ namespace Nuake {
|
||||
|
||||
gbuffer.Unbind();
|
||||
}
|
||||
|
||||
if (foundSomethingToSelect = true)
|
||||
{
|
||||
m_ShouldUnfoldEntityTree = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -701,15 +706,40 @@ namespace Nuake {
|
||||
{
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(0, 255, 0, 255));
|
||||
}
|
||||
|
||||
|
||||
if (!m_IsRenaming && m_ShouldUnfoldEntityTree && Selection.Type == EditorSelectionType::Entity && e.GetScene()->EntityIsParent(Selection.Entity, e))
|
||||
{
|
||||
ImGui::SetNextItemOpen(true);
|
||||
}
|
||||
|
||||
auto cursorPos = ImGui::GetCursorPos();
|
||||
|
||||
ImGui::SetNextItemAllowOverlap();
|
||||
|
||||
bool open = ImGui::TreeNodeEx(name.c_str(), base_flags);
|
||||
|
||||
if (m_IsRenaming)
|
||||
{
|
||||
if (Selection.Type == EditorSelectionType::Entity && Selection.Entity == e)
|
||||
{
|
||||
ImGui::SetCursorPosY(cursorPos.y);
|
||||
ImGui::Indent();
|
||||
ImGui::InputText("##renamingEntity", &name);
|
||||
ImGui::Unindent();
|
||||
if (Input::IsKeyDown(Key::ENTER))
|
||||
{
|
||||
nameComponent.Name = name;
|
||||
m_IsRenaming = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool isDragging = false;
|
||||
if (nameComponent.IsPrefab && e.HasComponent<PrefabComponent>())
|
||||
{
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
else if (ImGui::BeginDragDropSource())
|
||||
else if (!m_IsRenaming && ImGui::BeginDragDropSource())
|
||||
{
|
||||
ImGui::SetDragDropPayload("ENTITY", (void*)&e, sizeof(Entity));
|
||||
ImGui::Text(name.c_str());
|
||||
@@ -742,7 +772,20 @@ namespace Nuake {
|
||||
}
|
||||
|
||||
if (!isDragging && ImGui::IsItemHovered() && ImGui::IsMouseReleased(0))
|
||||
{
|
||||
// We selected another another that we werent renaming
|
||||
if (Selection.Entity != e)
|
||||
{
|
||||
m_IsRenaming = false;
|
||||
}
|
||||
|
||||
Selection = EditorSelection(e);
|
||||
}
|
||||
|
||||
if (!isDragging && (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(0)) || Input::IsKeyPressed(Key::F2))
|
||||
{
|
||||
m_IsRenaming = true;
|
||||
}
|
||||
|
||||
if (ImGui::BeginPopupContextItem())
|
||||
{
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
#include "../Commands/ICommand.h"
|
||||
#include "MapImporterWindow.h"
|
||||
|
||||
#include <src/Scripting/ScriptingEngineNet.h>
|
||||
|
||||
using namespace NuakeEditor;
|
||||
|
||||
namespace Nuake
|
||||
@@ -25,6 +27,7 @@ namespace Nuake
|
||||
class EditorInterface
|
||||
{
|
||||
private:
|
||||
std::vector<CompilationError> errors;
|
||||
Ref<Scene> SceneSnapshot;
|
||||
NuakeEditor::CommandBuffer* mCommandBuffer;
|
||||
|
||||
@@ -36,6 +39,8 @@ namespace Nuake
|
||||
bool m_ShowOverlay = true;
|
||||
bool m_IsHoveringViewport = false;
|
||||
bool m_IsViewportFocused = false;
|
||||
bool m_IsRenaming = false;
|
||||
bool m_ShouldUnfoldEntityTree = false;
|
||||
bool m_ShowTrenchbroomConfigurator = false;
|
||||
bool m_ShowMapImporter = false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user