davey: davey_data is no longer required
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
#include <component/rect_component.h>
|
||||
#include <component/renderable_component.h>
|
||||
#include <entt/core/hashed_string.hpp>
|
||||
#include <entt/davey/meta.hpp>
|
||||
#include <entt/meta/factory.hpp>
|
||||
#include <meta/meta.h>
|
||||
|
||||
@@ -13,16 +12,13 @@ void meta_setup() {
|
||||
using namespace entt::literals;
|
||||
|
||||
entt::meta_factory<input_listener_component>()
|
||||
.custom<entt::davey_data>("input listener")
|
||||
.data<&input_listener_component::command>("command"_hs)
|
||||
.custom<entt::davey_data>("command");
|
||||
.type("input listener")
|
||||
.data<&input_listener_component::command>("command");
|
||||
|
||||
entt::meta_factory<position_component>()
|
||||
.custom<entt::davey_data>("position")
|
||||
.data<&SDL_FPoint::x>("x"_hs)
|
||||
.custom<entt::davey_data>("x")
|
||||
.data<&SDL_FPoint::y>("y"_hs)
|
||||
.custom<entt::davey_data>("y");
|
||||
.type("position")
|
||||
.data<&SDL_FPoint::x>("x")
|
||||
.data<&SDL_FPoint::y>("y");
|
||||
|
||||
// bind components...
|
||||
}
|
||||
|
||||
@@ -16,19 +16,18 @@
|
||||
#include <entt/meta/pointer.hpp>
|
||||
#include <entt/meta/resolve.hpp>
|
||||
#include <imgui.h>
|
||||
#include "meta.hpp"
|
||||
|
||||
namespace entt {
|
||||
|
||||
namespace internal {
|
||||
|
||||
#define DAVEY_OR(elem) info ? info->name : std::string{elem.info().name()}.data()
|
||||
#define DAVEY_OR(elem) label ? label : std::string{elem.info().name()}.data()
|
||||
|
||||
template<typename Entity, typename OnEntity>
|
||||
static void present_element(const entt::meta_any &obj, OnEntity on_entity) {
|
||||
for([[maybe_unused]] const auto [id, data]: obj.type().data()) {
|
||||
const auto elem = data.get(obj);
|
||||
const davey_data *info = data.custom();
|
||||
const char *label = data.name();
|
||||
|
||||
if(auto type = data.type(); type.info() == entt::type_id<const char *>()) {
|
||||
ImGui::Text("%s: %s", DAVEY_OR(type), elem.template cast<const char *>());
|
||||
@@ -145,7 +144,7 @@ static void present_entity(const meta_ctx &ctx, const Entity entt, const It from
|
||||
for(auto it = from; it != to; ++it) {
|
||||
if(const auto &storage = it->second; storage.contains(entt)) {
|
||||
if(auto type = entt::resolve(ctx, storage.info()); type) {
|
||||
if(const davey_data *info = type.custom(); ImGui::TreeNode(&storage.info(), "%s", DAVEY_OR(storage))) {
|
||||
if(const char *label = type.name(); ImGui::TreeNode(&storage.info(), "%s", DAVEY_OR(storage))) {
|
||||
if(const auto obj = type.from_void(storage.value(entt)); obj) {
|
||||
present_element<Entity>(obj, [&ctx, from, to](const char *name, const Entity other) {
|
||||
if(ImGui::TreeNode(name, "%s: %d [%d/%d]", name, entt::to_integral(other), entt::to_entity(other), entt::to_version(other))) {
|
||||
@@ -177,7 +176,7 @@ static void present_view(const meta_ctx &ctx, const entt::basic_view<get_t<Get..
|
||||
if(ImGui::TreeNode(&entt::type_id<typename view_type::entity_type>(), "%d [%d/%d]", entt::to_integral(entt), entt::to_entity(entt), entt::to_version(entt))) {
|
||||
for(const auto *storage: range) {
|
||||
if(auto type = entt::resolve(ctx, storage->info()); type) {
|
||||
if(const davey_data *info = type.custom(); ImGui::TreeNode(&storage->info(), "%s", DAVEY_OR((*storage)))) {
|
||||
if(const char *label = type.name(); ImGui::TreeNode(&storage->info(), "%s", DAVEY_OR((*storage)))) {
|
||||
if(const auto obj = type.from_void(storage->value(entt)); obj) {
|
||||
present_element<typename view_type::entity_type>(obj, [](const char *name, const typename view_type::entity_type entt) {
|
||||
ImGui::Text("%s: %d [%d/%d]", name, entt::to_integral(entt), entt::to_entity(entt), entt::to_version(entt));
|
||||
@@ -243,7 +242,7 @@ void davey(const meta_ctx &ctx, const entt::basic_registry<Entity, Allocator> &r
|
||||
|
||||
if(ImGui::BeginTabItem("Storage")) {
|
||||
for([[maybe_unused]] auto [id, storage]: registry.storage()) {
|
||||
if(const davey_data *info = entt::resolve(ctx, storage.info()).custom(); ImGui::TreeNode(&storage.info(), "%s (%zu)", DAVEY_OR(storage), storage.size())) {
|
||||
if(const char *label = entt::resolve(ctx, storage.info()).name(); ImGui::TreeNode(&storage.info(), "%s (%zu)", DAVEY_OR(storage), storage.size())) {
|
||||
internal::present_storage(ctx, storage);
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
#ifndef ENTT_DAVEY_META_HPP
|
||||
#define ENTT_DAVEY_META_HPP
|
||||
|
||||
namespace entt {
|
||||
|
||||
struct davey_data {
|
||||
davey_data(const char *value)
|
||||
: name{value} {}
|
||||
|
||||
const char *name;
|
||||
};
|
||||
|
||||
} // namespace entt
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user