add NameComponent and rework level and inspector windows
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include <NazaraEditor/Core/Application/Action.hpp>
|
||||
#include <NazaraEditor/Core/Application/BaseApplication.hpp>
|
||||
#include <NazaraEditor/Core/Application/Level.hpp>
|
||||
#include <NazaraEditor/Core/Components/NameComponent.hpp>
|
||||
#include <NazaraEditor/Core/UI/Window.hpp>
|
||||
#include <NazaraEditor/Core/Reflection/Math.hpp>
|
||||
#include <NazaraEditor/Core/Reflection/Core.hpp>
|
||||
|
||||
37
include/NazaraEditor/Core/Components/NameComponent.hpp
Normal file
37
include/NazaraEditor/Core/Components/NameComponent.hpp
Normal file
@@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
#include <NazaraEditor/Core/Config.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
enum EditorEntityFlags : uint64_t
|
||||
{
|
||||
EditorEntityFlags_None = 0,
|
||||
|
||||
EditorEntityFlags_Hidden = 1 << 1,
|
||||
};
|
||||
|
||||
class NAZARAEDITOR_CORE_API EditorNameComponent
|
||||
{
|
||||
public:
|
||||
EditorNameComponent() = default;
|
||||
EditorNameComponent(const EditorNameComponent&) = delete;
|
||||
EditorNameComponent(EditorNameComponent&&) = default;
|
||||
~EditorNameComponent() = default;
|
||||
|
||||
EditorNameComponent& operator=(const EditorNameComponent&) = delete;
|
||||
EditorNameComponent& operator=(EditorNameComponent&&) = default;
|
||||
|
||||
void SetName(const std::string& name) { m_name = name; }
|
||||
const std::string& GetName() const { return m_name; }
|
||||
|
||||
void SetFlags(const uint64_t flags) { m_flags = flags; }
|
||||
uint64_t GetFlags() const { return m_flags; }
|
||||
|
||||
private:
|
||||
std::string m_name;
|
||||
uint64_t m_flags;
|
||||
};
|
||||
}
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <imgui.h>
|
||||
#include <imgui_stdlib.h>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
@@ -44,6 +45,18 @@ namespace Nz
|
||||
inline void End(Color&) {}
|
||||
}
|
||||
|
||||
namespace EditorImgui
|
||||
{
|
||||
inline bool Begin(std::string& obj, const std::string& name, const std::string& tooltip)
|
||||
{
|
||||
ImGui::InputText(name.c_str(), &obj);
|
||||
Tooltip(tooltip);
|
||||
return false;
|
||||
}
|
||||
|
||||
inline void End(std::string&) {}
|
||||
}
|
||||
|
||||
// Wrapper for array values
|
||||
template <typename T>
|
||||
struct ArrayEntry
|
||||
@@ -126,8 +139,7 @@ namespace Nz
|
||||
{
|
||||
inline bool Begin(entt::handle& /*obj*/, const std::string& name, const std::string& /*tooltip*/)
|
||||
{
|
||||
std::string n = "Entity " + name;
|
||||
return ImGui::TreeNode(n.c_str());
|
||||
return ImGui::TreeNode(name.c_str());
|
||||
}
|
||||
|
||||
inline void End(entt::handle&) {
|
||||
|
||||
@@ -5,12 +5,33 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
template <>
|
||||
class TypeReflect<EditorNameComponent>
|
||||
{
|
||||
public:
|
||||
template <typename TPropertyEnumerator>
|
||||
static void Reflect(TPropertyEnumerator& p, EditorNameComponent& obj)
|
||||
{
|
||||
p.AddProperty([&obj]() { return obj.GetName(); }, [&obj](const std::string& v) { obj.SetName(v); }, "Name", "Entity Name");
|
||||
}
|
||||
};
|
||||
|
||||
namespace EditorImgui
|
||||
{
|
||||
inline bool Begin(Nz::EditorNameComponent& /*obj*/, const std::string& /*name*/, const std::string& /*tooltip*/) { return true; }
|
||||
|
||||
inline void End(Nz::EditorNameComponent& /*obj*/) { }
|
||||
}
|
||||
|
||||
template <typename TPropertyDetail>
|
||||
struct EditorPropertyInspector
|
||||
{
|
||||
template <typename T>
|
||||
void AddProperty(T& prop, const std::string& name, const std::string& tooltip);
|
||||
|
||||
template <typename T>
|
||||
void AddPropertyNoWrapper(T& prop, const std::string& name, const std::string& tooltip);
|
||||
|
||||
/*template <typename T, typename U, typename V>
|
||||
void AddProperty(T& parent, V(U::* Getter)() const, void(U::*Setter(const V&))(), const std::string& name, const std::string& tooltip)
|
||||
{
|
||||
|
||||
@@ -12,4 +12,10 @@ namespace Nz
|
||||
}
|
||||
}
|
||||
|
||||
template <typename TPropertyDetail>
|
||||
template <typename T> void EditorPropertyInspector<TPropertyDetail>::AddPropertyNoWrapper(T& prop, const std::string& name, const std::string& tooltip)
|
||||
{
|
||||
TypeReflect<T>::Reflect(*this, prop);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -42,7 +42,7 @@ namespace Nz
|
||||
|
||||
inline bool Begin(Nz::LightComponent& /*obj*/, const std::string& /*name*/, const std::string& /*tooltip*/)
|
||||
{
|
||||
return ImGui::TreeNode("LightComponent");
|
||||
return ImGui::TreeNodeEx("LightComponent", ImGuiTreeNodeFlags_Framed);
|
||||
}
|
||||
|
||||
inline void End(Nz::LightComponent&) {
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Nz
|
||||
{
|
||||
inline bool Begin(Nz::NodeComponent& /*obj*/, const std::string& /*name*/, const std::string& /*tooltip*/)
|
||||
{
|
||||
return ImGui::TreeNode("NodeComponent");
|
||||
return ImGui::TreeNodeEx("NodeComponent", ImGuiTreeNodeFlags_Framed);
|
||||
}
|
||||
|
||||
inline void End(Nz::NodeComponent& /*obj*/) {
|
||||
|
||||
Reference in New Issue
Block a user