diff --git a/headers/enduro2d/high/components/camera.hpp b/headers/enduro2d/high/components/camera.hpp index 48162e6c..8ce8e40c 100644 --- a/headers/enduro2d/high/components/camera.hpp +++ b/headers/enduro2d/high/components/camera.hpp @@ -15,6 +15,8 @@ namespace e2d { class camera final { + public: + class gizmos final {}; public: camera() = default; @@ -53,6 +55,20 @@ namespace e2d asset_dependencies& dependencies, const collect_context& ctx) const; }; + + template <> + class factory_loader final : factory_loader<> { + public: + static const char* schema_source; + + bool operator()( + camera::gizmos& component, + const fill_context& ctx) const; + + bool operator()( + asset_dependencies& dependencies, + const collect_context& ctx) const; + }; } namespace e2d diff --git a/headers/enduro2d/high/components/label.hpp b/headers/enduro2d/high/components/label.hpp index 139030ed..3afcb8dc 100644 --- a/headers/enduro2d/high/components/label.hpp +++ b/headers/enduro2d/high/components/label.hpp @@ -18,8 +18,7 @@ namespace e2d { class label final { public: - class dirty final { - }; + class dirty final {}; public: ENUM_HPP_CLASS_DECL(haligns, u8, (left) diff --git a/samples/bin/library/prefabs/camera_prefab.json b/samples/bin/library/prefabs/camera_prefab.json index ae6043da..8ebbb405 100644 --- a/samples/bin/library/prefabs/camera_prefab.json +++ b/samples/bin/library/prefabs/camera_prefab.json @@ -1,7 +1,11 @@ { "components" : { + "named" : { + "name" : "camera" + }, "camera" : { "background" : [1.0, 0.4, 0.0, 1.0] - } + }, + "camera.gizmos" : {} } } diff --git a/samples/bin/library/scenes/sample_04.json b/samples/bin/library/scenes/sample_04.json index 84f48cb3..9ca55ed6 100644 --- a/samples/bin/library/scenes/sample_04.json +++ b/samples/bin/library/scenes/sample_04.json @@ -3,12 +3,7 @@ "scene" : {} }, "children" : [{ - "prototype" : "../prefabs/camera_prefab.json", - "components" : { - "named" : { - "name" : "camera" - } - } + "prototype" : "../prefabs/camera_prefab.json" },{ "prototype" : "../prefabs/gnome_prefab.json", "components" : { diff --git a/samples/bin/library/scenes/sample_06.json b/samples/bin/library/scenes/sample_06.json index 3bdff06b..44fa4f7e 100644 --- a/samples/bin/library/scenes/sample_06.json +++ b/samples/bin/library/scenes/sample_06.json @@ -3,12 +3,7 @@ "scene" : {} }, "children" : [{ - "prototype" : "../prefabs/camera_prefab.json", - "components" : { - "named" : { - "name" : "camera" - } - } + "prototype" : "../prefabs/camera_prefab.json" },{ "prototype" : "../prefabs/coin_prefab.json", "components" : { diff --git a/sources/enduro2d/high/components/camera.cpp b/sources/enduro2d/high/components/camera.cpp index 4ce0952d..1523f91e 100644 --- a/sources/enduro2d/high/components/camera.cpp +++ b/sources/enduro2d/high/components/camera.cpp @@ -76,11 +76,47 @@ namespace e2d } } +namespace e2d +{ + const char* factory_loader::schema_source = R"json({ + "type" : "object", + "required" : [], + "additionalProperties" : false, + "properties" : {} + })json"; + + bool factory_loader::operator()( + camera::gizmos& component, + const fill_context& ctx) const + { + E2D_UNUSED(component, ctx); + return true; + } + + bool factory_loader::operator()( + asset_dependencies& dependencies, + const collect_context& ctx) const + { + E2D_UNUSED(dependencies, ctx); + return true; + } +} + namespace e2d { const char* component_inspector::title = "camera"; void component_inspector::operator()(gcomponent& c) const { + if ( bool gizmos = c.owner().component().exists(); + ImGui::Checkbox("gizmos", &gizmos) ) + { + if ( gizmos ) { + c.owner().component().ensure(); + } else { + c.owner().component().remove(); + } + } + if ( i32 depth = c->depth(); ImGui::DragInt("depth", &depth) ) { diff --git a/sources/enduro2d/high/starter.cpp b/sources/enduro2d/high/starter.cpp index 9790f8b6..251ede53 100644 --- a/sources/enduro2d/high/starter.cpp +++ b/sources/enduro2d/high/starter.cpp @@ -178,6 +178,7 @@ namespace e2d .register_component("actor") .register_component("behaviour") .register_component("camera") + .register_component("camera.gizmos") .register_component("flipbook_player") .register_component