davey: work in progress...
This commit is contained in:
@@ -1,15 +1,13 @@
|
||||
#include <entt/entity/registry.hpp>
|
||||
#include <imgui.h>
|
||||
#include <system/imgui_system.h>
|
||||
#include <entt/davey/davey.hpp>
|
||||
|
||||
namespace testbed {
|
||||
|
||||
void imgui_system(entt::registry ®istry) {
|
||||
void imgui_system(const entt::registry ®istry) {
|
||||
ImGui::Begin("testbed");
|
||||
|
||||
// ...
|
||||
static_cast<void>(registry);
|
||||
|
||||
entt::davey(registry);
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,6 @@
|
||||
|
||||
namespace testbed {
|
||||
|
||||
void imgui_system(entt::registry &);
|
||||
void imgui_system(const entt::registry &);
|
||||
|
||||
} // namespace testbed
|
||||
|
||||
@@ -1,7 +1,92 @@
|
||||
#ifndef ENTT_DAVEY_DAVEY_HPP
|
||||
#define ENTT_DAVEY_DAVEY_HPP
|
||||
|
||||
#include <string>
|
||||
#include <entt/entity/registry.hpp>
|
||||
#include <entt/entity/sparse_set.hpp>
|
||||
#include <entt/locator/locator.hpp>
|
||||
#include <entt/meta/context.hpp>
|
||||
#include <entt/meta/meta.hpp>
|
||||
#include <entt/meta/resolve.hpp>
|
||||
#include <imgui.h>
|
||||
#include "meta.hpp"
|
||||
|
||||
namespace entt {
|
||||
|
||||
namespace internal {
|
||||
|
||||
template<typename Entity, typename Allocator>
|
||||
static void present_entity(const meta_ctx &ctx, const entt::basic_registry<Entity, Allocator> ®istry, const Entity entt) {
|
||||
for([[maybe_unused]] auto [id, storage]: registry.storage()) {
|
||||
if(storage.contains(entt)) {
|
||||
if(auto type = entt::resolve(ctx, storage.type()); type) {
|
||||
if(const davey_data *info = type.custom(); ImGui::TreeNode(&storage.type(), "%s", info ? info->name : std::string{storage.type().name()}.c_str())) {
|
||||
// TODO
|
||||
ImGui::TreePop();
|
||||
}
|
||||
} else {
|
||||
const std::string name{storage.type().name()};
|
||||
ImGui::Text("%s", name.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Entity, typename Allocator>
|
||||
void storage_tab(const meta_ctx &ctx, const entt::basic_registry<Entity, Allocator> ®istry) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
template<typename Entity, typename Allocator>
|
||||
void entity_tab(const meta_ctx &ctx, const entt::basic_registry<Entity, Allocator> ®istry) {
|
||||
for(const auto [entt]: registry.storage<Entity>()->each()) {
|
||||
ImGui::PushID(static_cast<int>(entt::to_entity(entt)));
|
||||
|
||||
if(ImGui::TreeNode(&entt::type_id<entt::entity>(), "%d [%d/%d]", entt::to_integral(entt), entt::to_entity(entt), entt::to_version(entt))) {
|
||||
present_entity(ctx, registry, entt);
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
ImGui::PopID();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
|
||||
template<typename Entity, typename Allocator>
|
||||
void davey(const meta_ctx &ctx, const entt::basic_sparse_set<Entity, Allocator> &set) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
template<typename Entity, typename Allocator>
|
||||
void davey(const entt::basic_sparse_set<Entity, Allocator> &set) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
template<typename Entity, typename Allocator>
|
||||
void davey(const meta_ctx &ctx, const entt::basic_registry<Entity, Allocator> ®istry) {
|
||||
ImGui::Begin("Davey");
|
||||
ImGui::BeginTabBar("#tabs");
|
||||
|
||||
if(ImGui::BeginTabItem("Storage")) {
|
||||
internal::storage_tab(ctx, registry);
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
|
||||
if(ImGui::BeginTabItem("Entity")) {
|
||||
internal::entity_tab(ctx, registry);
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
|
||||
ImGui::EndTabBar();
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
template<typename Entity, typename Allocator>
|
||||
void davey(const entt::basic_registry<Entity, Allocator> ®istry) {
|
||||
davey(locator<meta_ctx>::value_or(), registry);
|
||||
}
|
||||
|
||||
} // namespace entt
|
||||
|
||||
#endif
|
||||
|
||||
12
tools/entt/davey/meta.hpp
Normal file
12
tools/entt/davey/meta.hpp
Normal file
@@ -0,0 +1,12 @@
|
||||
#ifndef ENTT_DAVEY_META_HPP
|
||||
#define ENTT_DAVEY_META_HPP
|
||||
|
||||
namespace entt {
|
||||
|
||||
struct davey_data {
|
||||
const char *name;
|
||||
};
|
||||
|
||||
} // namespace entt
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user