diff --git a/headers/enduro2d/high/_all.hpp b/headers/enduro2d/high/_all.hpp index 6713b383..e5cb7372 100644 --- a/headers/enduro2d/high/_all.hpp +++ b/headers/enduro2d/high/_all.hpp @@ -37,6 +37,7 @@ #include "components/events.hpp" #include "components/flipbook_player.hpp" #include "components/label.hpp" +#include "components/layout.hpp" #include "components/model_renderer.hpp" #include "components/named.hpp" #include "components/renderer.hpp" @@ -50,6 +51,7 @@ #include "systems/frame_system.hpp" #include "systems/gizmos_system.hpp" #include "systems/label_system.hpp" +#include "systems/layout_system.hpp" #include "systems/render_system.hpp" #include "systems/script_system.hpp" #include "systems/spine_system.hpp" diff --git a/headers/enduro2d/high/_high.hpp b/headers/enduro2d/high/_high.hpp index 9e60b7e4..1349b5c7 100644 --- a/headers/enduro2d/high/_high.hpp +++ b/headers/enduro2d/high/_high.hpp @@ -57,6 +57,7 @@ namespace e2d class events; class flipbook_player; class label; + class layout; class model_renderer; class named; class renderer; @@ -70,6 +71,7 @@ namespace e2d class frame_system; class gizmos_system; class label_system; + class layout_system; class render_system; class script_system; class spine_system; diff --git a/headers/enduro2d/high/components/layout.hpp b/headers/enduro2d/high/components/layout.hpp new file mode 100644 index 00000000..f9839db7 --- /dev/null +++ b/headers/enduro2d/high/components/layout.hpp @@ -0,0 +1,76 @@ +/******************************************************************************* + * This file is part of the "Enduro2D" + * For conditions of distribution and use, see copyright notice in LICENSE.md + * Copyright (C) 2018-2020, by Matvey Cherevko (blackmatov@gmail.com) + ******************************************************************************/ + +#pragma once + +#include "_components.hpp" + +namespace e2d +{ + class layout final { + public: + layout() = default; + }; + + class layout_item final { + public: + layout_item() = default; + }; +} + +namespace e2d +{ + template <> + class factory_loader final : factory_loader<> { + public: + static const char* schema_source; + + bool operator()( + layout& component, + const fill_context& ctx) const; + + bool operator()( + asset_dependencies& dependencies, + const collect_context& ctx) const; + }; + + template <> + class factory_loader final : factory_loader<> { + public: + static const char* schema_source; + + bool operator()( + layout_item& component, + const fill_context& ctx) const; + + bool operator()( + asset_dependencies& dependencies, + const collect_context& ctx) const; + }; +} + +namespace e2d +{ + template <> + class component_inspector final : component_inspector<> { + public: + static const char* title; + + void operator()(gcomponent& c) const; + }; + + template <> + class component_inspector final : component_inspector<> { + public: + static const char* title; + + void operator()(gcomponent& c) const; + }; +} + +namespace e2d +{ +} diff --git a/headers/enduro2d/high/systems/layout_system.hpp b/headers/enduro2d/high/systems/layout_system.hpp new file mode 100644 index 00000000..de5d0e0c --- /dev/null +++ b/headers/enduro2d/high/systems/layout_system.hpp @@ -0,0 +1,26 @@ +/******************************************************************************* + * This file is part of the "Enduro2D" + * For conditions of distribution and use, see copyright notice in LICENSE.md + * Copyright (C) 2018-2020, by Matvey Cherevko (blackmatov@gmail.com) + ******************************************************************************/ + +#pragma once + +#include "_systems.hpp" + +namespace e2d +{ + class layout_system final + : public ecs::system> { + public: + layout_system(); + ~layout_system() noexcept final; + + void process( + ecs::registry& owner, + const ecs::after& trigger) override; + private: + class internal_state; + std::unique_ptr state_; + }; +} diff --git a/samples/bin/library/scripts/emmy/components/layout.lua b/samples/bin/library/scripts/emmy/components/layout.lua new file mode 100644 index 00000000..68587b7c --- /dev/null +++ b/samples/bin/library/scripts/emmy/components/layout.lua @@ -0,0 +1,13 @@ +---@class layout +local layout = { +} + +---@class layout_item +local layout_item = { +} + +---@type layout +_G.layout = _G.layout or layout + +---@type layout_item +_G.layout_item = _G.layout_item or layout_item diff --git a/samples/bin/library/scripts/emmy/high/gobject.lua b/samples/bin/library/scripts/emmy/high/gobject.lua index 91452682..5e5917cc 100644 --- a/samples/bin/library/scripts/emmy/high/gobject.lua +++ b/samples/bin/library/scripts/emmy/high/gobject.lua @@ -30,6 +30,12 @@ local gobject = { ---@type label label = nil, + ---@type layout + layout = nil, + + ---@type layout_item + layout_item = nil, + ---@type model_renderer model_renderer = nil, diff --git a/sources/enduro2d/high/bindings/high_binds/_high_binds.hpp b/sources/enduro2d/high/bindings/high_binds/_high_binds.hpp index d53571e0..e4dfeb30 100644 --- a/sources/enduro2d/high/bindings/high_binds/_high_binds.hpp +++ b/sources/enduro2d/high/bindings/high_binds/_high_binds.hpp @@ -24,6 +24,7 @@ namespace e2d::bindings::high void bind_colliders(sol::state& l); void bind_flipbook_player(sol::state& l); void bind_label(sol::state& l); + void bind_layout(sol::state& l); void bind_model_renderer(sol::state& l); void bind_named(sol::state& l); void bind_renderer(sol::state& l); @@ -50,6 +51,7 @@ namespace e2d::bindings high::bind_colliders(l); high::bind_flipbook_player(l); high::bind_label(l); + high::bind_layout(l); high::bind_model_renderer(l); high::bind_named(l); high::bind_renderer(l); diff --git a/sources/enduro2d/high/bindings/high_binds/components/layout_binds.cpp b/sources/enduro2d/high/bindings/high_binds/components/layout_binds.cpp new file mode 100644 index 00000000..a8298271 --- /dev/null +++ b/sources/enduro2d/high/bindings/high_binds/components/layout_binds.cpp @@ -0,0 +1,23 @@ +/******************************************************************************* + * This file is part of the "Enduro2D" + * For conditions of distribution and use, see copyright notice in LICENSE.md + * Copyright (C) 2018-2020, by Matvey Cherevko (blackmatov@gmail.com) + ******************************************************************************/ + +#include "../_high_binds.hpp" + +#include +#include + +namespace e2d::bindings::high +{ + void bind_layout(sol::state& l) { + l.new_usertype>("layout", + sol::no_constructor + ); + + l.new_usertype>("layout_item", + sol::no_constructor + ); + } +} diff --git a/sources/enduro2d/high/components/layout.cpp b/sources/enduro2d/high/components/layout.cpp new file mode 100644 index 00000000..6d4aac77 --- /dev/null +++ b/sources/enduro2d/high/components/layout.cpp @@ -0,0 +1,77 @@ +/******************************************************************************* + * This file is part of the "Enduro2D" + * For conditions of distribution and use, see copyright notice in LICENSE.md + * Copyright (C) 2018-2020, by Matvey Cherevko (blackmatov@gmail.com) + ******************************************************************************/ + +#include + +namespace e2d +{ + const char* factory_loader::schema_source = R"json({ + "type" : "object", + "required" : [], + "additionalProperties" : false, + "properties" : {} + })json"; + + bool factory_loader::operator()( + layout& 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* factory_loader::schema_source = R"json({ + "type" : "object", + "required" : [], + "additionalProperties" : false, + "properties" : {} + })json"; + + bool factory_loader::operator()( + layout_item& 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 = ICON_FA_BARS " layout"; + + void component_inspector::operator()(gcomponent& c) const { + E2D_UNUSED(c); + } +} + +namespace e2d +{ + const char* component_inspector::title = ICON_FA_GRIP_LINES " layout_item"; + + void component_inspector::operator()(gcomponent& c) const { + E2D_UNUSED(c); + } +} diff --git a/sources/enduro2d/high/starter.cpp b/sources/enduro2d/high/starter.cpp index 835875b4..6c798c42 100644 --- a/sources/enduro2d/high/starter.cpp +++ b/sources/enduro2d/high/starter.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -35,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -69,6 +71,8 @@ namespace .add_system()) .feature(ecs::feature() .add_system()) + .feature(ecs::feature() + .add_system()) .feature(ecs::feature() .add_system()) .feature(ecs::feature() @@ -193,6 +197,8 @@ namespace e2d .register_component("flipbook_player") .register_component