Unravel Engine C++ Reference
Loading...
Searching...
No Matches
inspector_panel.cpp
Go to the documentation of this file.
1#include "inspector_panel.h"
2#include "../panels_defs.h"
4
12#include <uuid/uuid.h>
14#include <algorithm>
15#include <functional>
16
17namespace unravel
18{
19
20namespace
21{
22
23auto should_use_prefab_inspection(entt::meta_any& selected) -> bool
24{
25 if(selected.type() != entt::resolve<entt::handle>())
26 {
27 return false;
28 }
29
30 auto entity = selected.cast<entt::handle>();
31 if(!entity)
32 {
33 return false;
34 }
35
36 return true;
37}
38
44auto inspect_object_with_prefab_check(rtti::context& ctx, entt::meta_any& object) -> void
45{
46 auto& override_ctx = ctx.get_cached<prefab_override_context>();
47
48 // Check if this object should use prefab inspection
49 if(should_use_prefab_inspection(object))
50 {
51 auto entity = object.cast<entt::handle>();
52
53 if(override_ctx.begin_prefab_inspection(entity))
54 {
56 auto proxy = make_proxy(object, name);
57 auto result = inspect_var(ctx, object, proxy);
58
59 override_ctx.end_prefab_inspection();
60 return;
61 }
62 }
63
64 std::string name;
65 if(object.type() == entt::resolve<entt::handle>())
66 {
67 auto entity = object.cast<entt::handle>();
69 }
70
71 // Fall back to normal inspection (empty reference)
72 auto proxy = make_proxy(object, name);
73 auto result = inspect_var(ctx, object, proxy);
74}
75
76} // namespace
77
81
87
93
95{
97
98 if(ImGui::Begin(name, nullptr, ImGuiWindowFlags_MenuBar))
99 {
100 // ImGui::WindowTimeBlock block(ImGui::GetFont(ImGui::Font::Mono));
101
102 auto& em = ctx.get_cached<editing_manager>();
103 auto& selected = em.get_active_selection();
104
105 if(ImGui::BeginMenuBar())
106 {
107 bool locked = !!locked_object_;
108
109 if(ImGui::MenuItem(locked ? ICON_MDI_LOCK : ICON_MDI_LOCK_OPEN_VARIANT, nullptr, locked))
110 {
111 locked = !locked;
112
113 if(locked)
114 {
115 locked_object_ = selected;
116 }
117 else
118 {
119 locked_object_ = {};
120 }
121 }
122
123 ImGui::SetItemTooltipEx("%s", "Lock/Unlock Inspector");
124
125 if(ImGui::MenuItem(ICON_MDI_COGS, nullptr, debug_))
126 {
127 debug_ = !debug_;
128 }
129
130 ImGui::SetItemTooltipEx("%s", "Debug View");
131
132 ImGui::EndMenuBar();
133 }
134
135 if(debug_)
136 {
138 }
139
140 em.push_undo_stack_enabled(true);
141
142 auto selections_count = int(em.get_selections().size());
143
144 if(locked_object_)
145 {
146 inspect_object_with_prefab_check(ctx, locked_object_);
147 }
148 else if(em.get_selections().size() > 1)
149 {
150 ImGui::Text("%d Items Selected.", selections_count);
151 }
152 else if(selected)
153 {
154 inspect_object_with_prefab_check(ctx, selected);
155 }
156
157 if(debug_)
158 {
160 }
161
162 em.pop_undo_stack_enabled();
163 }
164 ImGui::End();
165}
166
167} // namespace unravel
manifold_type type
static auto get_entity_name(entt::handle entity) -> std::string
Gets the entity name from tag component.
void init(rtti::context &ctx)
inspector_panel(imgui_panels *parent)
void deinit(rtti::context &ctx)
std::string name
Definition hub.cpp:27
#define ICON_MDI_LOCK_OPEN_VARIANT
#define ICON_MDI_COGS
#define ICON_MDI_LOCK
void pop_debug_view()
Pops debug view mode (decreases debug view counter)
void push_debug_view()
Pushes debug view mode (increases debug view counter)
auto make_proxy(entt::meta_any &var, const std::string &name) -> meta_any_proxy
Creates a simple proxy for direct variable access.
auto inspect_var(rtti::context &ctx, entt::meta_any &var, const meta_any_proxy &var_proxy, const var_info &info, const entt::meta_custom &custom) -> inspect_result
Main entry point for inspecting any variable with automatic type resolution.
entt::entity entity
auto get_cached() -> T &
Definition context.hpp:49
auto add(Args &&... args) -> T &
Definition context.hpp:16
void remove()
Definition context.hpp:78
auto get_active_selection() const -> const entt::meta_any &
Registry for managing type-specific inspector instances.
Definition inspectors.h:19
Global context for tracking prefab override changes during inspection.
Definition inspectors.h:94