new named component

This commit is contained in:
2019-10-30 19:51:54 +07:00
parent c74d63863a
commit a1b30761ce
6 changed files with 115 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
/*******************************************************************************
* This file is part of the "Enduro2D"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#include <enduro2d/high/components/named.hpp>
namespace e2d
{
const char* factory_loader<named>::schema_source = R"json({
"type" : "object",
"required" : [],
"additionalProperties" : false,
"properties" : {
"name" : { "$ref": "#/common_definitions/name" }
}
})json";
bool factory_loader<named>::operator()(
named& component,
const fill_context& ctx) const
{
if ( ctx.root.HasMember("name") ) {
str name = component.name();
if ( !json_utils::try_parse_value(ctx.root["name"], name) ) {
the<debug>().error("NAMED: Incorrect formatting of 'name' property");
return false;
}
component.name(name);
}
return true;
}
bool factory_loader<named>::operator()(
asset_dependencies& dependencies,
const collect_context& ctx) const
{
E2D_UNUSED(dependencies, ctx);
return true;
}
}

View File

@@ -17,6 +17,7 @@
#include <enduro2d/high/components/flipbook_player.hpp>
#include <enduro2d/high/components/label.hpp>
#include <enduro2d/high/components/model_renderer.hpp>
#include <enduro2d/high/components/named.hpp>
#include <enduro2d/high/components/renderer.hpp>
#include <enduro2d/high/components/scene.hpp>
#include <enduro2d/high/components/spine_player.hpp>
@@ -183,6 +184,7 @@ namespace e2d
.register_component<label>("label")
.register_component<label::dirty>("label.dirty")
.register_component<model_renderer>("model_renderer")
.register_component<named>("named")
.register_component<renderer>("renderer")
.register_component<scene>("scene")
.register_component<spine_player>("spine_player")