-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtext_intent.h
More file actions
42 lines (37 loc) · 1.48 KB
/
text_intent.h
File metadata and controls
42 lines (37 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#pragma once
namespace Game::Render
{
template<typename T>
void text_intent([[maybe_unused]] T &syscall, System::ECS::Query<Text, IntentHandle> &query)
{
for (auto &[id, comps]: query)
{
const size_t &intent_id = comps.get<IntentHandle>().handle_id;
std::optional<System::Render::DrawIntent> &intent = System::Render::IntentStorage::get_intent(intent_id);
const Text &text_component = comps.get<Text>();
if (!intent.has_value())
{
intent = System::Render::DrawIntent{};
}
switch (intent.value().kind)
{
case System::Render::DrawKind::KIND_UNKNOWN:
intent.value().kind = System::Render::DrawKind::KIND_TEXT;
case System::Render::DrawKind::KIND_TEXT:
break;
default:
return;
}
if (!std::holds_alternative<System::Render::TextDrawDesc>(intent.value().special))
{
intent.value().special = System::Render::TextDrawDesc{};
}
auto &[text, font_name, font_size, x, y, anchor_x, anchor_y] = std::get<System::Render::TextDrawDesc>(intent.value().special);
text = std::string_view(text_component.text);
font_name = text_component.font_name;
font_size = text_component.font_size;
x = text_component.x;
y = text_component.y;
}
}
} // namespace Game::Render