mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-15 20:08:54 +03:00
Improved Editor Interface
- Moved Add component button - Removed rounding on collapsed component header - Added indention in component panels - Changed frame background color
This commit is contained in:
@@ -14,14 +14,19 @@
|
||||
else if (ImGui::MenuItem(label)) \
|
||||
entity.AddComponent<Component>();
|
||||
|
||||
#define CompononentPropertyName(name) \
|
||||
ImGui::AlignTextToFramePadding(); \
|
||||
ImGui::Text(##name);
|
||||
|
||||
#define BeginComponentTable(name, component) \
|
||||
UIFont* boldFont = new UIFont(Fonts::Bold); \
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.f, 0.f)); \
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0.f, 8.f)); \
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 0.0f); \
|
||||
bool removed = false; \
|
||||
bool headerOpened = ImGui::CollapsingHeader(#name, ImGuiTreeNodeFlags_DefaultOpen); \
|
||||
if (#name != "TRANSFORM" && ImGui::BeginPopupContextItem()) \
|
||||
ImGui::PopStyleVar(); \
|
||||
if (#name != "TRANSFORM" && ImGui::BeginPopupContextItem()) \
|
||||
{ \
|
||||
if (ImGui::Selectable("Remove")) { removed = true; } \
|
||||
ImGui::EndPopup(); \
|
||||
@@ -37,10 +42,11 @@
|
||||
{ \
|
||||
delete boldFont; \
|
||||
ImGui::PopStyleVar(); \
|
||||
if (ImGui::BeginTable(#name, 3, ImGuiTableFlags_BordersInner | ImGuiTableFlags_SizingStretchProp)) \
|
||||
ImGui::Indent(); \
|
||||
if (ImGui::BeginTable(#name, 3, ImGuiTableFlags_SizingStretchProp)) \
|
||||
{ \
|
||||
ImGui::TableSetupColumn("name", 0, 0.25f); \
|
||||
ImGui::TableSetupColumn("set", 0, 0.65f); \
|
||||
ImGui::TableSetupColumn("name", 0, 0.25f); \
|
||||
ImGui::TableSetupColumn("set", 0, 0.65f); \
|
||||
ImGui::TableSetupColumn("reset", 0, 0.1f); \
|
||||
\
|
||||
ImGui::TableNextColumn();
|
||||
@@ -49,13 +55,14 @@
|
||||
#define EndComponentTable() \
|
||||
ImGui::EndTable(); \
|
||||
} \
|
||||
ImGui::Unindent(); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
ImGui::PopStyleVar(); \
|
||||
delete boldFont; \
|
||||
} \
|
||||
ImGui::PopStyleVar();
|
||||
ImGui::PopStyleVar(); \
|
||||
|
||||
|
||||
#define ComponentTableReset(setting, value) \
|
||||
|
||||
@@ -12,73 +12,84 @@ public:
|
||||
{
|
||||
using namespace Nuake;
|
||||
Nuake::TransformComponent& component = entity.GetComponent<Nuake::TransformComponent>();
|
||||
BeginComponentTable(TRANSFORM, Nuake::TransformComponent);
|
||||
{
|
||||
{
|
||||
ImGui::Text("Translation");
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
Vector3 position = component.GetLocalPosition();
|
||||
ImGuiHelper::DrawVec3("Translation", &position);
|
||||
if (position != component.GetLocalPosition())
|
||||
component.SetLocalPosition(position);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0));
|
||||
std::string resetLabel = std::string(ICON_FA_UNDO) + "##ResetTranslation";
|
||||
if (ImGui::Button(resetLabel.c_str()))
|
||||
component.SetLocalPosition(Vector3(0, 0, 0));
|
||||
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
ImGui::Indent();
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.f, 0.f));
|
||||
if (ImGui::BeginTable("#transform", 3, ImGuiTableFlags_SizingStretchProp))
|
||||
{
|
||||
ImGui::TableSetupColumn("name", 0, 0.25f);
|
||||
ImGui::TableSetupColumn("set", 0, 0.65f);
|
||||
ImGui::TableSetupColumn("reset", 0, 0.1f);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
{
|
||||
ImGui::Text("Rotation");
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
Vector3 eulerAngles = glm::eulerAngles(component.GetLocalRotation());
|
||||
Vector3 eulerDegrees = Vector3(glm::degrees(eulerAngles.x), glm::degrees(eulerAngles.y), glm::degrees(eulerAngles.z));
|
||||
ImGuiHelper::DrawVec3("Rotation", &eulerDegrees);
|
||||
Vector3 eulerAnglesDelta = Vector3(glm::radians(eulerDegrees.x), glm::radians(eulerDegrees.y), glm::radians(eulerDegrees.z));
|
||||
|
||||
float delta = glm::length(eulerAngles - eulerAnglesDelta);
|
||||
if (delta > 0.f)
|
||||
{
|
||||
Quat rotation = QuatFromEuler(eulerAnglesDelta.x, eulerAnglesDelta.y, eulerAnglesDelta.z);
|
||||
//component.SetLocalRotation(rotation);
|
||||
CompononentPropertyName("Translation");
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
Vector3 position = component.GetLocalPosition();
|
||||
ImGuiHelper::DrawVec3("Translation", &position);
|
||||
if (position != component.GetLocalPosition())
|
||||
component.SetLocalPosition(position);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0));
|
||||
std::string resetLabel = std::string(ICON_FA_UNDO) + "##ResetTranslation";
|
||||
if (ImGui::Button(resetLabel.c_str()))
|
||||
component.SetLocalPosition(Vector3(0, 0, 0));
|
||||
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0));
|
||||
std::string resetLabel = std::string(ICON_FA_UNDO) + "##ResetRotation";
|
||||
if (ImGui::Button(resetLabel.c_str()))
|
||||
{
|
||||
component.SetLocalRotation(Quat(1, 0, 0, 0));
|
||||
CompononentPropertyName("Rotation");
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
Vector3 eulerAngles = glm::eulerAngles(component.GetLocalRotation());
|
||||
Vector3 eulerDegrees = Vector3(glm::degrees(eulerAngles.x), glm::degrees(eulerAngles.y), glm::degrees(eulerAngles.z));
|
||||
ImGuiHelper::DrawVec3("Rotation", &eulerDegrees);
|
||||
Vector3 eulerAnglesDelta = Vector3(glm::radians(eulerDegrees.x), glm::radians(eulerDegrees.y), glm::radians(eulerDegrees.z));
|
||||
|
||||
float delta = glm::length(eulerAngles - eulerAnglesDelta);
|
||||
if (delta > 0.f)
|
||||
{
|
||||
Quat rotation = QuatFromEuler(eulerAnglesDelta.x, eulerAnglesDelta.y, eulerAnglesDelta.z);
|
||||
//component.SetLocalRotation(rotation);
|
||||
}
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0));
|
||||
std::string resetLabel = std::string(ICON_FA_UNDO) + "##ResetRotation";
|
||||
if (ImGui::Button(resetLabel.c_str()))
|
||||
{
|
||||
component.SetLocalRotation(Quat(1, 0, 0, 0));
|
||||
}
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
ImGui::TableNextColumn();
|
||||
{
|
||||
ImGui::Text("Scale");
|
||||
ImGui::TableNextColumn();
|
||||
{
|
||||
CompononentPropertyName("Scale");
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
Vector3 localScale = component.GetLocalScale();
|
||||
ImGuiHelper::DrawVec3("Scale", &localScale);
|
||||
Vector3 localScale = component.GetLocalScale();
|
||||
ImGuiHelper::DrawVec3("Scale", &localScale);
|
||||
|
||||
if (localScale != component.GetLocalScale())
|
||||
component.SetLocalScale(localScale);
|
||||
if (localScale != component.GetLocalScale())
|
||||
component.SetLocalScale(localScale);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0));
|
||||
std::string resetLabel = std::string(ICON_FA_UNDO) + "##ResetScale";
|
||||
if (ImGui::Button(resetLabel.c_str()))
|
||||
component.SetLocalScale(Vector3(1, 1, 1));
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0));
|
||||
std::string resetLabel = std::string(ICON_FA_UNDO) + "##ResetScale";
|
||||
if (ImGui::Button(resetLabel.c_str()))
|
||||
component.SetLocalScale(Vector3(1, 1, 1));
|
||||
|
||||
ImGui::PopStyleColor();
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
}
|
||||
ImGui::EndTable();
|
||||
}
|
||||
EndComponentTable();
|
||||
ImGui::PopStyleVar();
|
||||
ImGui::Unindent();
|
||||
}
|
||||
};
|
||||
@@ -428,7 +428,7 @@ namespace Nuake {
|
||||
{
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, ImVec2{ 0.0f, 0.0f });
|
||||
|
||||
ImGuiTreeNodeFlags base_flags = ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_FramePadding | ImGuiTreeNodeFlags_OpenOnDoubleClick | ImGuiTreeNodeFlags_SpanFullWidth;
|
||||
ImGuiTreeNodeFlags base_flags = ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_FramePadding | ImGuiTreeNodeFlags_OpenOnDoubleClick | ImGuiTreeNodeFlags_SpanAllColumns;
|
||||
|
||||
NameComponent& nameComponent = e.GetComponent<NameComponent>();
|
||||
std::string name = nameComponent.Name;
|
||||
@@ -1540,7 +1540,7 @@ namespace Nuake {
|
||||
{
|
||||
if (UI::PrimaryButton("Add Entity"))
|
||||
{
|
||||
ImGui::OpenPopup("create_entity_new_popup");
|
||||
ImGui::OpenPopup("create_entity_popup");
|
||||
}
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, { 8, 8 });
|
||||
@@ -1555,21 +1555,24 @@ namespace Nuake {
|
||||
ImGui::InputTextWithHint("##search", "Search entity", &searchQuery, 0, 0, 0);
|
||||
ImGui::PopItemWidth();
|
||||
|
||||
ImGui::Button("Empty", { 130, 130 });
|
||||
//ImGui::Button("Empty", { 130, 130 });
|
||||
auto textureManager = TextureManager::Get();
|
||||
ImVec2 buttonSize = { 120, 120 };
|
||||
ImGui::ImageButton((ImTextureID)textureManager->GetTexture("Resources/Images/cube.png")->GetID(), buttonSize, ImVec2(0, 1), ImVec2(1, 0));
|
||||
ImGui::SameLine();
|
||||
ImGui::Button("3D", { 130, 130 });
|
||||
ImGui::ImageButton((ImTextureID)textureManager->GetTexture("Resources/Images/cube.png")->GetID(), buttonSize, ImVec2(0, 1), ImVec2(1, 0));
|
||||
ImGui::SameLine();
|
||||
ImGui::Button("Lights", { 130, 130 });
|
||||
ImGui::ImageButton((ImTextureID)textureManager->GetTexture("Resources/Images/light.png")->GetID(), buttonSize, ImVec2(0, 1), ImVec2(1, 0));
|
||||
|
||||
ImGui::Button("Physics", { 130, 130 });
|
||||
ImGui::ImageButton((ImTextureID)textureManager->GetTexture("Resources/Images/physics.png")->GetID(), buttonSize, ImVec2(0, 1), ImVec2(1, 0));
|
||||
ImGui::SameLine();
|
||||
ImGui::Button("Shapes", { 130, 130 });
|
||||
ImGui::ImageButton((ImTextureID)textureManager->GetTexture("Resources/Images/shape.png")->GetID(), buttonSize, ImVec2(0, 1), ImVec2(1, 0));
|
||||
ImGui::SameLine();
|
||||
ImGui::Button("Scripts", { 130, 130 });
|
||||
ImGui::ImageButton((ImTextureID)textureManager->GetTexture("Resources/Images/code.png")->GetID(), buttonSize, ImVec2(0, 1), ImVec2(1, 0));
|
||||
|
||||
ImGui::Button("Prefabs", { 130, 130 });
|
||||
ImGui::ImageButton((ImTextureID)textureManager->GetTexture("Resources/Images/box.png")->GetID(), buttonSize, ImVec2(0, 1), ImVec2(1, 0));
|
||||
ImGui::SameLine();
|
||||
ImGui::Button("Utilities", { 130, 130 });
|
||||
ImGui::ImageButton((ImTextureID)textureManager->GetTexture("Resources/Images/wrench.png")->GetID(), buttonSize, ImVec2(0, 1), ImVec2(1, 0));
|
||||
ImGui::SameLine();
|
||||
|
||||
ImGui::BeginDisabled();
|
||||
|
||||
@@ -130,6 +130,49 @@ void EditorSelectionPanel::DrawEntity(Nuake::Entity entity)
|
||||
mCharacterControllerPanel.Draw(entity);
|
||||
mAudioEmitterPanel.Draw(entity);
|
||||
|
||||
using namespace Nuake;
|
||||
|
||||
float availWidth = ImGui::GetContentRegionAvail().x;
|
||||
const float buttonWidth = 200.f;
|
||||
float posX = (availWidth / 2.f) - (buttonWidth / 2.f);
|
||||
ImGui::SetCursorPosX(posX);
|
||||
|
||||
if (UI::PrimaryButton("Add Component", { buttonWidth, 32 }))
|
||||
{
|
||||
ImGui::OpenPopup("ComponentPopup");
|
||||
}
|
||||
|
||||
if (ImGui::BeginPopup("ComponentPopup"))
|
||||
{
|
||||
MenuItemComponent("Wren Script", WrenScriptComponent);
|
||||
MenuItemComponent("C# Script", NetScriptComponent);
|
||||
MenuItemComponent("Camera", CameraComponent);
|
||||
MenuItemComponent("Light", LightComponent);
|
||||
ImGui::Separator();
|
||||
MenuItemComponent("Model", ModelComponent);
|
||||
MenuItemComponent("Skinned Model", SkinnedModelComponent);
|
||||
MenuItemComponent("Bone", BoneComponent)
|
||||
ImGui::Separator();
|
||||
MenuItemComponent("Sprite", SpriteComponent)
|
||||
MenuItemComponent("Particle Emitter", ParticleEmitterComponent)
|
||||
ImGui::Separator();
|
||||
MenuItemComponent("Character Controller", CharacterControllerComponent)
|
||||
MenuItemComponent("Rigid body", RigidBodyComponent)
|
||||
ImGui::Separator();
|
||||
MenuItemComponent("Box collider", BoxColliderComponent)
|
||||
MenuItemComponent("Capsule collider", CapsuleColliderComponent)
|
||||
MenuItemComponent("Cylinder collider", CylinderColliderComponent)
|
||||
MenuItemComponent("Sphere collider", SphereColliderComponent)
|
||||
MenuItemComponent("Mesh collider", MeshColliderComponent)
|
||||
ImGui::Separator();
|
||||
MenuItemComponent("Quake map", QuakeMapComponent);
|
||||
ImGui::Separator();
|
||||
MenuItemComponent("Audio Emitter", AudioEmitterComponent);
|
||||
ImGui::Separator();
|
||||
MenuItemComponent("Path", AudioEmitterComponent);
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void EditorSelectionPanel::DrawAddComponentMenu(Nuake::Entity entity)
|
||||
@@ -139,42 +182,6 @@ void EditorSelectionPanel::DrawAddComponentMenu(Nuake::Entity entity)
|
||||
{
|
||||
auto& entityName = entity.GetComponent<NameComponent>().Name;
|
||||
ImGuiTextSTD("##Name", entityName);
|
||||
ImGui::SameLine();
|
||||
|
||||
if (ImGui::Button("Add Component"))
|
||||
ImGui::OpenPopup("ComponentPopup");
|
||||
|
||||
if (ImGui::BeginPopup("ComponentPopup"))
|
||||
{
|
||||
MenuItemComponent("Wren Script", WrenScriptComponent);
|
||||
MenuItemComponent("C# Script", NetScriptComponent);
|
||||
MenuItemComponent("Camera", CameraComponent);
|
||||
MenuItemComponent("Light", LightComponent);
|
||||
ImGui::Separator();
|
||||
MenuItemComponent("Model", ModelComponent);
|
||||
MenuItemComponent("Skinned Model", SkinnedModelComponent);
|
||||
MenuItemComponent("Bone", BoneComponent)
|
||||
ImGui::Separator();
|
||||
MenuItemComponent("Sprite", SpriteComponent)
|
||||
MenuItemComponent("Particle Emitter", ParticleEmitterComponent)
|
||||
ImGui::Separator();
|
||||
MenuItemComponent("Character Controller", CharacterControllerComponent)
|
||||
MenuItemComponent("Rigid body", RigidBodyComponent)
|
||||
ImGui::Separator();
|
||||
MenuItemComponent("Box collider", BoxColliderComponent)
|
||||
MenuItemComponent("Capsule collider", CapsuleColliderComponent)
|
||||
MenuItemComponent("Cylinder collider", CylinderColliderComponent)
|
||||
MenuItemComponent("Sphere collider", SphereColliderComponent)
|
||||
MenuItemComponent("Mesh collider", MeshColliderComponent)
|
||||
ImGui::Separator();
|
||||
MenuItemComponent("Quake map", QuakeMapComponent);
|
||||
ImGui::Separator();
|
||||
MenuItemComponent("Audio Emitter", AudioEmitterComponent);
|
||||
ImGui::Separator();
|
||||
MenuItemComponent("Path", AudioEmitterComponent);
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
ImGui::Separator();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -313,7 +313,7 @@ namespace Nuake
|
||||
colors[ImGuiCol_PopupBg] = ImVec4(0.08f, 0.08f, 0.08f, 0.94f);
|
||||
colors[ImGuiCol_Border] = ImVec4(0.11f, 0.11f, 0.11f, 1.00f);
|
||||
colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
|
||||
colors[ImGuiCol_FrameBg] = ImVec4(0.06f, 0.06f, 0.06f, 1.00f);
|
||||
colors[ImGuiCol_FrameBg] = ImVec4(0.08f, 0.08f, 0.08f, 1.00f);
|
||||
colors[ImGuiCol_FrameBgHovered] = ImVec4(0.09f, 0.09f, 0.09f, 1.00f);
|
||||
colors[ImGuiCol_FrameBgActive] = ImVec4(0.13f, 0.13f, 0.13f, 1.00f);
|
||||
colors[ImGuiCol_TitleBg] = ImVec4(0.08f, 0.08f, 0.08f, 1.00f);
|
||||
|
||||
Reference in New Issue
Block a user