10 auto ®istry = AScene::getRegistry();
12 registry.onComponentAdded(
13 [&renderer, ®istry](
const ecs::Entity e,
const std::type_info &type)
15 const auto *colorComp = registry.getComponent<
ecs::Color>(e);
16 const auto *fontComp = registry.getComponent<
ecs::Font>(e);
17 const auto *rectComp = registry.getComponent<
ecs::Rect>(e);
18 const auto *scaleComp = registry.getComponent<
ecs::Scale>(e);
19 const auto *textComp = registry.getComponent<
ecs::Text>(e);
20 const auto *textureComp = registry.getComponent<
ecs::Texture>(e);
25 if (textComp && transform && fontComp)
27 renderer->createFont(fontComp->
id, fontComp->path);
29 {.font_name = fontComp->
id,
30 .color = {.r = colorComp->r, .g = colorComp->g, .b = colorComp->b, .a = colorComp->a},
31 .content = textComp->content,
32 .size = textComp->font_size,
35 .name = textComp->
id});
40 const float scale_x = scaleComp ? scaleComp->x : 1.F;
41 const float scale_y = scaleComp ? scaleComp->y : 1.F;
43 renderer->createTexture(textureComp->
id, textureComp->path);
45 if (transform && textureComp)
49 renderer->createSprite(textureComp->
id + std::to_string(e), textureComp->
id, transform->x,
50 transform->y, scale_x, scale_y,
static_cast<int>(rectComp->pos_x),
51 static_cast<int>(rectComp->pos_y), rectComp->size_x, rectComp->size_y);
55 renderer->createSprite(textureComp->
id + std::to_string(e), textureComp->
id, transform->x,
63 registry.createEntity()
65 .with<ecs::Transform>(
"transform_title", 100.F, 60.F, 0.F)
68 .with<ecs::Text>(
"title", std::string(
"MULTIPLAYER"), 72U)
73 registry.createEntity()
75 .with<ecs::Transform>(
"transform_menu_" + std::to_string(i), 100.F, 200.F + i * 60.F, 0.F)