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
94{
99
101 std::function<bool(const hpp::uuid& entity_uuid, const std::string& component_path)> is_path_overridden_callback;
102
107
109 entt::handle prefab_root_entity;
111 entt::handle entity;
112
114 scene prefab_scene{"prefab_diff_scene"};
116 uintptr_t prefab_version{};
117
119 bool is_active = false;
120
125 void set_entity_uuid(const hpp::uuid& uuid);
126
132 void set_component_type(const std::string& type, const std::string& pretty_type);
133
139 void push_segment(const std::string& segment, const std::string& pretty_segment);
140
144 void pop_segment();
145
151 auto begin_prefab_inspection(entt::handle entity) -> bool;
152
157
165 auto record_override() -> bool;
166
178
184 static auto find_prefab_root_entity(entt::handle entity) -> entt::handle;
185
191 static auto get_entity_prefab_uuid(entt::handle entity) -> hpp::uuid;
192
201 static void mark_transform_as_changed(entt::handle entity, bool position, bool rotation, bool scale, bool skew);
202 static void mark_transform_global_as_changed(entt::handle entity, bool position, bool rotation, bool scale, bool skew);
203
208 static void mark_active_as_changed(entt::handle entity);
209
214 static void mark_text_area_as_changed(entt::handle entity);
215
220 static void mark_material_as_changed(entt::handle entity);
221
228 static void mark_property_as_changed(entt::handle entity,
229 const entt::meta_type& component_type,
230 const std::string& property_path);
231
239 static void mark_property_as_changed(entt::handle entity,
240 const std::string& component_type_name,
241 const std::string& component_pretty_type_name,
242 const std::string& property_path);
243
253 static auto exists_in_prefab(scene& cache_scene,
255 hpp::uuid entity_uuid,
256 const std::string& component_type,
257 const std::string& property_path) -> bool;
258
263 static void mark_entity_as_removed(entt::handle entity);
264};
265
267 prefab_override_context& override_ctx,
268 inspect_result& result,
269 const meta_any_proxy& var_proxy,
270 const entt::meta_any& old_var,
271 const entt::meta_any& new_var,
272 const entt::meta_custom& custom);
276void push_debug_view();
277
281void pop_debug_view();
282
287auto is_debug_view() -> bool;
288
298auto inspect_var(rtti::context& ctx,
299 entt::meta_any& var,
300 const meta_any_proxy& var_proxy,
301 const var_info& info = {},
302 const entt::meta_custom& custom = {}) -> inspect_result;
303
314 entt::meta_any& var,
315 const meta_any_proxy& var_proxy,
316 const var_info& info = {},
317 const entt::meta_custom& custom = {}) -> inspect_result;
318
330 entt::meta_any& var,
331 const meta_any_proxy& var_proxy,
332 const entt::meta_data& prop,
333 const var_info& info = {},
334 const entt::meta_custom& custom = {}) -> inspect_result;
335
348 entt::meta_any& var,
349 const meta_any_proxy& var_proxy,
350 const std::string& name,
351 const std::string& tooltip,
352 const var_info& info = {},
353 const entt::meta_custom& custom = {}) -> inspect_result;
354
366 entt::meta_any& var,
367 const meta_any_proxy& var_proxy,
368 const entt::meta_data& prop,
369 const var_info& info = {},
370 const entt::meta_custom& custom = {}) -> inspect_result;
371
381 entt::meta_any& var,
382 const meta_any_proxy& var_proxy,
383 const var_info& info = {}) -> inspect_result;
384
392template<typename T>
394{
395 entt::meta_any var = entt::forward_as_meta(obj);
396 return inspect_var(ctx, var, make_proxy(var));
397}
398
399} // namespace unravel
manifold_type type
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.
float scale
Definition hub.cpp:25
std::string name
Definition hub.cpp:27
const char * tooltip
void pop_debug_view()
Pops debug view mode (decreases debug view counter)
auto inspect(rtti::context &ctx, T &obj) -> inspect_result
Convenience template function for inspecting objects of known type.
Definition inspectors.h:393
void add_property_action(rtti::context &ctx, prefab_override_context &override_ctx, inspect_result &result, const meta_any_proxy &var_proxy, const entt::meta_any &old_var, const entt::meta_any &new_var, const entt::meta_custom &custom)
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 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.
Represents a handle to an asset, providing access and management functions.
Result of an inspection operation indicating what changes occurred.
Definition inspector.h:146
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:94
void end_prefab_inspection()
End prefab inspection context and clean up state.
scene prefab_scene
Temporary scene for prefab comparison operations.
Definition inspectors.h:114
entt::handle prefab_root_entity
The prefab root entity that contains the prefab_component.
Definition inspectors.h:109
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:101
property_path_context pretty_path_context
Current property path context for human-readable paths.
Definition inspectors.h:106
entt::handle entity
The specific entity currently being inspected.
Definition inspectors.h:111
auto is_path_overridden() const -> bool
Check if the current property path is already overridden.
Definition inspectors.h:171
prefab_override_context()=default
Default constructor.
static void mark_property_as_changed(entt::handle entity, const entt::meta_type &component_type, const std::string &property_path)
Marks a specific property as changed using component type.
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:116
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:104
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:119
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_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 generic prefab with a buffer for serialized data.
Definition prefab.h:18
Represents a scene in the ACE framework, managing entities and their relationships.
Definition scene.h:21