Unravel Engine C++ Reference
Loading...
Searching...
No Matches
ui_document_component.cpp
Go to the documentation of this file.
4
7
8namespace unravel
9{
11{
12 // Register ui_document_component class with entt
13 entt::meta_factory<ui_document_component>{}
14 .type("ui_document_component"_hs)
16 entt::attribute{"name", "ui_document_component"},
17 entt::attribute{"category", "UI"},
18 entt::attribute{"pretty_name", "UI Document"},
19 })
20 .func<&component_meta<ui_document_component>::exists>("component_exists"_hs)
21 .func<&component_meta<ui_document_component>::add>("component_add"_hs)
22 .func<&component_meta<ui_document_component>::remove>("component_remove"_hs)
23 .func<&component_meta<ui_document_component>::save>("component_save"_hs)
24 .func<&component_meta<ui_document_component>::load>("component_load"_hs)
26 .custom<entt::attributes>(entt::attributes{
27 entt::attribute{"name", "enabled"},
28 entt::attribute{"pretty_name", "Enabled"},
29 })
30 .data<&ui_document_component::asset>("asset"_hs)
32 entt::attribute{"name", "asset"},
33 entt::attribute{"pretty_name", "Asset"},
34 })
35 ;
36}
37
39{
40 bool enabled = obj.is_enabled();
41 try_save(ar, ser20::make_nvp("enabled", enabled));
42 try_save(ar, ser20::make_nvp("asset", obj.asset));
43
44}
47
49{
50 bool enabled = true;
51 try_load(ar, ser20::make_nvp("enabled", enabled));
52 obj.set_enabled(enabled);
53 try_load(ar, ser20::make_nvp("asset", obj.asset));
54}
57
58} // namespace unravel
attributes::value_type attribute
Definition reflection.h:19
std::map< std::string, meta_any > attributes
Definition reflection.h:18
BinaryInputArchive iarchive_binary_t
simd::JSONOutputArchive oarchive_associative_t
BinaryOutputArchive oarchive_binary_t
simd::JSONInputArchive iarchive_associative_t
#define REFLECT(cls)
Definition reflection.h:133
#define SAVE_INSTANTIATE(cls, Archive)
#define LOAD(cls)
auto try_save(Archive &ar, ser20::NameValuePair< T > &&t, const hpp::source_location &loc=hpp::source_location::current()) -> bool
#define LOAD_INSTANTIATE(cls, Archive)
#define SAVE(cls)
auto try_load(Archive &ar, ser20::NameValuePair< T > &&t, const hpp::source_location &loc=hpp::source_location::current()) -> bool
Component that holds a reference to a UI document for RmlUi rendering.
void set_enabled(bool enabled)
Set the enabled state of the document.
auto is_enabled() const -> bool
Check if document is currently enabled.