add GraphicsComponent reflection and factorize code
This commit is contained in:
parent
538b63c09f
commit
05b4386588
|
|
@ -47,6 +47,16 @@ namespace Nz
|
|||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
class TypeReflect<GraphicsComponent>
|
||||
{
|
||||
public:
|
||||
template <typename TPropertyEnumerator>
|
||||
static void Reflect(TPropertyEnumerator& p, GraphicsComponent& obj)
|
||||
{
|
||||
p.AddProperty([&obj]() { return obj.IsVisible(); }, [&obj](bool v) { obj.Show(v); }, "Is Visible", "Toggles mesh visibility");
|
||||
}
|
||||
};
|
||||
|
||||
namespace EditorImgui
|
||||
{
|
||||
|
|
@ -57,23 +67,9 @@ namespace Nz
|
|||
|
||||
inline void End(Nz::LightComponent::LightEntry&) {
|
||||
}
|
||||
|
||||
inline bool Begin(Nz::LightComponent& /*obj*/, const std::string& /*name*/, const std::string& /*tooltip*/)
|
||||
{
|
||||
return ImGui::TreeNodeEx("LightComponent", ImGuiTreeNodeFlags_Framed);
|
||||
}
|
||||
|
||||
inline void End(Nz::LightComponent&) {
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
inline bool Begin(Nz::CameraComponent& /*obj*/, const std::string& /*name*/, const std::string& /*tooltip*/)
|
||||
{
|
||||
return ImGui::TreeNodeEx("CameraComponent", ImGuiTreeNodeFlags_Framed);
|
||||
}
|
||||
|
||||
inline void End(Nz::CameraComponent&) {
|
||||
ImGui::TreePop();
|
||||
}
|
||||
}
|
||||
|
||||
COMPONENT_IMGUI_FUNCS(LightComponent);
|
||||
COMPONENT_IMGUI_FUNCS(CameraComponent);
|
||||
COMPONENT_IMGUI_FUNCS(GraphicsComponent);
|
||||
}
|
||||
|
|
@ -24,4 +24,17 @@ namespace Nz
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define COMPONENT_IMGUI_FUNCS(ComponentType) \
|
||||
namespace EditorImgui \
|
||||
{ \
|
||||
inline bool Begin(Nz::ComponentType& /*obj*/, const std::string& /*name*/, const std::string& /*tooltip*/) \
|
||||
{ \
|
||||
return ImGui::TreeNodeEx(#ComponentType, ImGuiTreeNodeFlags_Framed); \
|
||||
} \
|
||||
\
|
||||
inline void End(Nz::ComponentType&) { \
|
||||
ImGui::TreePop(); \
|
||||
} \
|
||||
}
|
||||
}
|
||||
|
|
@ -43,6 +43,9 @@ int WinMain(int argc, char* argv[])
|
|||
entt::meta<Nz::LightComponent>()
|
||||
.type(entt::type_hash<Nz::LightComponent>::value())
|
||||
.func<&Nz::ReflectComponent<Nz::EditorPropertyInspector<Nz::EditorRenderer>, Nz::LightComponent>>(entt::hashed_string("Reflect"));
|
||||
entt::meta<Nz::GraphicsComponent>()
|
||||
.type(entt::type_hash<Nz::GraphicsComponent>::value())
|
||||
.func<&Nz::ReflectComponent<Nz::EditorPropertyInspector<Nz::EditorRenderer>, Nz::GraphicsComponent>>(entt::hashed_string("Reflect"));
|
||||
entt::meta<Nz::EditorNameComponent>()
|
||||
.type(entt::type_hash<Nz::EditorNameComponent>::value())
|
||||
.func<&Nz::ReflectComponent<Nz::EditorPropertyInspector<Nz::EditorRenderer>, Nz::EditorNameComponent>>(entt::hashed_string("Reflect"));
|
||||
|
|
|
|||
Loading…
Reference in New Issue