Unravel Engine C++ Reference
Loading...
Searching...
No Matches
inspectors.h
Go to the documentation of this file.
1#pragma once
2
3#include "entt/core/fwd.hpp"
4#include "inspector.h"
6#include <context/context.hpp>
8
9namespace unravel
10{
19{
27
29 std::unordered_map<entt::id_type, std::shared_ptr<inspector>> type_map;
30};
31
40{
42 std::string pretty_path;
44 std::string serialization_path;
45
50
57 static auto create(const std::string& pretty, const std::string& serialization) -> prefab_property_override
58 {
60 override.pretty_path = pretty;
61 override.serialization_path = serialization;
62 return override;
63 }
64
70 auto operator==(const prefab_property_override& other) const -> bool
71 {
72 return serialization_path == other.serialization_path;
73 }
74
80 auto operator<(const prefab_property_override& other) const -> bool
81 {
82 return serialization_path < other.serialization_path;
83 }
84};
85
87{
88 entt::registry* inspected_registry{};
89};
90
99{
104
106 std::function<bool(const hpp::uuid& entity_uuid, const std::string& component_path)> is_path_overridden_callback;
107
112
114 entt::handle prefab_root_entity;
116 entt::handle entity;
117
119 scene prefab_scene{"prefab_diff_scene"};
121 uintptr_t prefab_version{};
122
124 bool is_active = false;
125
130 void set_entity_uuid(const hpp::uuid& uuid);
131
137 void set_component_type(const std::string& type, const std::string& pretty_type);
138
144 void push_segment(const std::string& segment, const std::string& pretty_segment);
145
149 void pop_segment();
150
156 auto begin_prefab_inspection(entt::handle entity) -> bool;
157
162
170 auto record_override() -> bool;
171
172 auto reset_override() -> bool;
173
185
191 static auto find_prefab_root_entity(entt::handle entity) -> entt::handle;
192
198 static auto get_entity_prefab_uuid(entt::handle entity) -> hpp::uuid;
199
208 static void mark_transform_as_changed(entt::handle entity, bool position, bool rotation, bool scale, bool skew);
209 static void mark_transform_global_as_changed(entt::handle entity, bool position, bool rotation, bool scale, bool skew);
210
215 static void mark_active_as_changed(entt::handle entity);
216
221 static void mark_text_area_as_changed(entt::handle entity);
222 static void mark_ui_document_size_as_changed(entt::handle entity);
227 static void mark_material_as_changed(entt::handle entity);
228
235 static void mark_property_as_changed(entt::handle entity,
236 const entt::meta_type& component_type,
237 const std::string& property_path,
238 const std::string& property_pretty_path = {});
239
247 static void mark_property_as_changed(entt::handle entity,
248 const std::string& component_type_name,
249 const std::string& component_pretty_type_name,
250 const std::string& property_path,
251 const std::string& property_pretty_path = {});
252
262 static auto exists_in_prefab(scene& cache_scene,
263 const asset_handle<prefab>& prefab,
264 hpp::uuid entity_uuid,
265 const std::string& component_type,
266 const std::string& property_path) -> bool;
267
272 static void mark_entity_as_removed(entt::handle entity);
273};
274
276 prefab_override_context& override_ctx,
277 inspect_result& result,
278 meta_any_proxy& var_proxy,
279 const entt::meta_any& old_var,
280 const entt::meta_any& new_var,
281 const entt::meta_custom& custom) -> bool;
285void push_debug_view();
286
290void pop_debug_view();
291
296auto is_debug_view() -> bool;
297
307auto inspect_var(rtti::context& ctx,
308 entt::meta_any& var,
309 const meta_any_proxy& var_proxy,
310 const var_info& info = {},
311 const entt::meta_custom& custom = {}) -> inspect_result;
312
323 entt::meta_any& var,
324 const meta_any_proxy& var_proxy,
325 const var_info& info = {},
326 const entt::meta_custom& custom = {}) -> inspect_result;
327
339 entt::meta_any& var,
340 const meta_any_proxy& var_proxy,
341 const entt::meta_data& prop,
342 const var_info& info = {},
343 const entt::meta_custom& custom = {}) -> inspect_result;
344
357 entt::meta_any& var,
358 const meta_any_proxy& var_proxy,
359 const std::string& name,
360 const std::string& tooltip,
361 const var_info& info = {},
362 const entt::meta_custom& custom = {}) -> inspect_result;
363
375 entt::meta_any& var,
376 const meta_any_proxy& var_proxy,
377 const entt::meta_data& prop,
378 const var_info& info = {},
379 const entt::meta_custom& custom = {}) -> inspect_result;
380
390 entt::meta_any& var,
391 const meta_any_proxy& var_proxy,
392 const var_info& info = {}) -> inspect_result;
393
401template<typename T>
402auto inspect(rtti::context& ctx, T& obj, const std::string& name = {}) -> inspect_result
403{
404 entt::meta_any var = entt::forward_as_meta(obj);
405 return inspect_var(ctx, var, make_proxy(var, name));
406}
407
408} // namespace unravel
Context holder for tracking the current property path during inspection.
auto get_current_path_with_component_type() const -> std::string
auto get_entity_uuid() const -> hpp::uuid
Get the entity UUID.
math::vec3 position
Definition defaults.cpp:52
std::string name
Definition hub.cpp:33
const char * tooltip
texture_job_type type
const aiScene * scene
auto add_property_action(rtti::context &ctx, prefab_override_context &override_ctx, inspect_result &result, meta_any_proxy &var_proxy, const entt::meta_any &old_var, const entt::meta_any &new_var, const entt::meta_custom &custom) -> bool
void pop_debug_view()
Pops debug view mode (decreases debug view counter)
auto inspect_associative_container(rtti::context &ctx, entt::meta_any &var, const meta_any_proxy &var_proxy, const entt::meta_data &prop, const var_info &info, const entt::meta_custom &custom) -> inspect_result
Inspects associative containers like maps and sets.
auto inspect_var_properties(rtti::context &ctx, entt::meta_any &var, const meta_any_proxy &var_proxy, const var_info &info, const entt::meta_custom &custom) -> inspect_result
Inspects all properties of a complex object recursively.
void push_debug_view()
Pushes debug view mode (increases debug view counter)
auto inspect(rtti::context &ctx, T &obj, const std::string &name={}) -> inspect_result
Convenience template function for inspecting objects of known type.
Definition inspectors.h:402
auto is_debug_view() -> bool
Checks if currently in debug view mode.
auto make_proxy(entt::meta_any &var, const std::string &name) -> meta_any_proxy
Creates a simple proxy for direct variable access.
auto inspect_array(rtti::context &ctx, entt::meta_any &var, const meta_any_proxy &var_proxy, const entt::meta_data &prop, const var_info &info, const entt::meta_custom &custom) -> inspect_result
Inspects array-like containers with add/remove functionality.
auto inspect_enum(rtti::context &ctx, entt::meta_any &var, const meta_any_proxy &var_proxy, const var_info &info) -> inspect_result
Inspects enumeration types with dropdown selection.
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.
std::vector< float > scale
std::vector< math::quat > rotation
Thread-safe handle to an asset.
entt::registry * inspected_registry
Definition inspectors.h:88
Registry for managing type-specific inspector instances.
Definition inspectors.h:19
inspector_registry()
Constructor that auto-discovers and registers all inspector types.
std::unordered_map< entt::id_type, std::shared_ptr< inspector > > type_map
Map from type ID to inspector instance for fast lookup.
Definition inspectors.h:29
Global context for tracking prefab override changes during inspection.
Definition inspectors.h:99
void end_prefab_inspection()
End prefab inspection context and clean up state.
scene prefab_scene
Temporary scene for prefab comparison operations.
Definition inspectors.h:119
entt::handle prefab_root_entity
The prefab root entity that contains the prefab_component.
Definition inspectors.h:114
static auto exists_in_prefab(scene &cache_scene, const asset_handle< prefab > &prefab, hpp::uuid entity_uuid, const std::string &component_type, const std::string &property_path) -> bool
Checks if a property exists in the original prefab.
void set_entity_uuid(const hpp::uuid &uuid)
Sets the entity UUID for both path contexts.
std::function< bool(const hpp::uuid &entity_uuid, const std::string &component_path)> is_path_overridden_callback
Callback function to check if a specific property path is already overridden.
Definition inspectors.h:106
property_path_context pretty_path_context
Current property path context for human-readable paths.
Definition inspectors.h:111
entt::handle entity
The specific entity currently being inspected.
Definition inspectors.h:116
auto is_path_overridden() const -> bool
Check if the current property path is already overridden.
Definition inspectors.h:178
prefab_override_context()=default
Default constructor.
static void mark_transform_global_as_changed(entt::handle entity, bool position, bool rotation, bool scale, bool skew)
uintptr_t prefab_version
Version tracking for prefab changes.
Definition inspectors.h:121
static auto find_prefab_root_entity(entt::handle entity) -> entt::handle
Finds the prefab root entity by traversing up the parent hierarchy.
static void mark_material_as_changed(entt::handle entity)
Marks material as changed in prefab override system.
static void mark_text_area_as_changed(entt::handle entity)
Marks text area as changed in prefab override system.
property_path_context path_context
Current property path context for serialization paths.
Definition inspectors.h:109
void set_component_type(const std::string &type, const std::string &pretty_type)
Sets the component type for both path contexts.
auto record_override() -> bool
Record a property override when a change is detected.
static void mark_entity_as_removed(entt::handle entity)
Marks an entity as removed from the prefab instance.
bool is_active
Whether we're currently inspecting a prefab instance.
Definition inspectors.h:124
static void mark_ui_document_size_as_changed(entt::handle entity)
void push_segment(const std::string &segment, const std::string &pretty_segment)
Pushes a new path segment onto both contexts and applies override styling.
static void mark_property_as_changed(entt::handle entity, const entt::meta_type &component_type, const std::string &property_path, const std::string &property_pretty_path={})
Marks a specific property as changed using component type.
static void mark_active_as_changed(entt::handle entity)
Marks entity active state as changed in prefab override system.
static void mark_transform_as_changed(entt::handle entity, bool position, bool rotation, bool scale, bool skew)
Marks transform properties as changed in prefab override system.
void pop_segment()
Pops the last path segment and removes override styling if needed.
static auto get_entity_prefab_uuid(entt::handle entity) -> hpp::uuid
Gets the prefab UUID of an entity from its prefab_id_component.
auto begin_prefab_inspection(entt::handle entity) -> bool
Initialize context for inspecting a prefab instance.
Stores both pretty and serialization paths for a prefab override.
Definition inspectors.h:40
static auto create(const std::string &pretty, const std::string &serialization) -> prefab_property_ override
Creates override from pretty path and serialization path.
Definition inspectors.h:57
auto operator<(const prefab_property_override &other) const -> bool
Less-than comparison for sorting based on serialization path.
Definition inspectors.h:80
auto operator==(const prefab_property_override &other) const -> bool
Equality comparison based on serialization path.
Definition inspectors.h:70
std::string pretty_path
Human-readable path for inspector display (e.g., "Transform/Position/X")
Definition inspectors.h:42
std::string serialization_path
Technical path for deserialization matching (e.g., "entities[0]/components/Transform/local_transform/...
Definition inspectors.h:44
prefab_property_override()=default
Default constructor.
Represents a scene in the ACE framework, managing entities and their relationships.
Definition scene.h:70