9 auto ®istry = AScene::getRegistry();
11 registry.onComponentAdded(
12 [&renderer, ®istry](
const ecs::Entity e,
const std::type_info &type)
14 const auto *colorComp = registry.getComponent<
ecs::Color>(e);
15 const auto *fontComp = registry.getComponent<
ecs::Font>(e);
16 const auto *rectComp = registry.getComponent<
ecs::Rect>(e);
17 const auto *scaleComp = registry.getComponent<
ecs::Scale>(e);
18 const auto *textComp = registry.getComponent<
ecs::Text>(e);
19 const auto *textureComp = registry.getComponent<
ecs::Texture>(e);
24 if (textComp && transform && fontComp)
26 renderer->createFont(fontComp->
id, fontComp->path);
28 {.font_name = fontComp->
id,
29 .color = {.r = colorComp->r, .g = colorComp->g, .b = colorComp->b, .a = colorComp->a},
30 .content = textComp->content,
31 .size = textComp->font_size,
34 .name = textComp->
id});
39 const float scale_x = scaleComp ? scaleComp->x : 1.F;
40 const float scale_y = scaleComp ? scaleComp->y : 1.F;
42 renderer->createTexture(textureComp->
id, textureComp->path);
44 if (transform && textureComp)
48 renderer->createSprite(textureComp->
id + std::to_string(e), textureComp->
id, transform->x,
49 transform->y, scale_x, scale_y,
static_cast<int>(rectComp->pos_x),
50 static_cast<int>(rectComp->pos_y), rectComp->size_x, rectComp->size_y);
54 renderer->createSprite(textureComp->
id + std::to_string(e), textureComp->
id, transform->x,
62 registry.createEntity()
64 .with<ecs::Transform>(
"transform_title", 100.F, 60.F, 0.F)
67 .with<ecs::Text>(
"id", std::string(
"RTYPE"), 72U)
72 registry.createEntity()
74 .with<ecs::Transform>(
"transform_menu", 100.F, 200.F + i * 60.F, 0.F)
82 std::string contributorsText =
"Contributors ";
88 contributorsText +=
" ";
92 registry.createEntity()
94 .with<ecs::Transform>(
"transform_contributors", renderer->getWindowSize().width * 0.9F,
95 renderer->getWindowSize().height * 0.9F)
99 .with<
ecs::Text>(
"contributors_text", contributorsText, 24U)
107 auto ® = getRegistry();
111 m_animationTime += dt;
112 m_titlePulseTime += dt;
114 if (
auto *titleColor = reg.getComponent<
ecs::Color>(m_titleEntity))
116 const float pulse = (std::sin(m_titlePulseTime * 1.2f) + 1.0f) * 0.5f;
122 if (
auto *titleTransform = reg.getComponent<
ecs::Transform>(m_titleEntity))
124 titleTransform->y = 60.0f + std::sin(m_titlePulseTime * 0.8f) * 2.0f;
129 for (
auto &[entity, text] : texts)
131 if (text.content ==
"Solo" || text.content ==
"Multi" || text.content ==
"Settings")
133 auto &color = colors.at(entity);
135 if (i == m_selectedIndex)
137 const float glowIntensity = std::sin(m_animationTime * 2.5f);
139 color.g =
static_cast<unsigned char>(191U + (glowIntensity * 50));
152 m_contributorsOffset += dt * 50.0f;
153 if (
auto *contributorsTransform = reg.getComponent<
ecs::Transform>(m_contributorsEntity))
155 contributorsTransform->x = (size.
width * 0.9f) - m_contributorsOffset;
157 if (contributorsTransform->x < -(size.
width * 0.9F))
159 m_contributorsOffset = 0.0f;
160 contributorsTransform->x = size.
width * 0.9f;