25#include "guillaume/systems/text_render.hpp"
28#include "guillaume/text_renderable.hpp"
29#include "guillaume/theme/typescale.hpp"
34 std::shared_ptr<utility::RessourceProvider> ressourceProvider,
35 utility::Engine &engine)
38 , _ressourceProvider(ressourceProvider)
40 , _defaultFontPath(
"fonts/Roboto-Regular.ttf")
62 <<
"Updating TextRender system for entity " << entityIdentifier;
69 const auto &transformComponent =
71 const auto &textComponent =
73 const auto &colorComponent =
83 <<
"Rendering text for entity " << entityIdentifier
84 <<
" (content: '" << textComponent.getContent() <<
"')";
88 auto renderable = std::make_shared<TextRenderable>(
89 _ressourceProvider, transformComponent.getPose(),
90 colorComponent.getColor(), textComponent.getContent(),
91 textComponent.getFontSize(),
95 if (handle ==
nullptr) {
96 size_t objectId = _engine.createObject(renderable);
100 if (!_engine.updateObject(renderable, handle->
objectId)) {
101 handle->
objectId = _engine.createObject(renderable);
std::size_t Identifier
The key under which an entity's components are stored. Systems and components refer to entities by th...
SystemFiller(Phase phase)
ComponentType & getComponent(const ecs::Entity::Identifier &entityIdentifier)
Get a component of an entity from the bound registry, to read or modify it.
bool requireComponent(const ecs::Entity::Identifier &entityIdentifier)
Tell whether an entity has a component, and log a warning naming the entity and the component when it...
void insert(const ecs::Entity::Identifier &identifier, RenderHandle handle)
Store the handle of an entity, replacing the one it had.
void markAllUnused(void)
Clear the used flag of every handle. Call it from the system's prepare(), before any entity is drawn.
void clear(void)
Forget every handle without calling utility::Engine::removeObject. Use it only when the engine object...
void removeUnused(utility::Engine &engine)
Remove from the engine, then from the map, every handle whose used flag is still false....
RenderHandle * find(const ecs::Entity::Identifier &identifier)
Look up the handle of an entity.
void prepare(void) override
Mark every text as not drawn yet. Called once per frame before the entities are visited.
void cleanup(void) override
Remove the engine objects of the entities that were not drawn this frame. Called once per frame after...
TextRender(std::shared_ptr< utility::RessourceProvider > ressourceProvider, utility::Engine &engine)
Create the system in the Render phase.
~TextRender(void)
Forget the engine objects without removing them from the engine.
virtual void update(const ecs::Entity::Identifier &entityIdentifier) override
Build the renderable of one text from its current components and upload it, creating the engine objec...
State. Every class here is plain data attached to an entity.
The entity-component-system core, independent of any widget.
Rules. Every class here runs each frame on the entities that have the components it declares.
const std::string & fontPath(FontWeight weight)
Get the font file shipped with the library for a weight.
Mesh builders shared by the shape render systems.
bool isInvisible(const utility::graphic::Color32Bit &color)
Whether a color draws nothing.
What a render system remembers about the engine object it created for one entity.
bool used
Whether the entity was drawn this frame.
std::shared_ptr< utility::graphic::Renderable > renderable
Renderable uploaded last for this object.
size_t objectId
Identifier given by the engine.