Making Icons a thing again since it's convenient.

This commit is contained in:
Zed A. Shaw 2025-07-23 13:49:16 -04:00
parent 7e64879f78
commit 4c019048d0
4 changed files with 35 additions and 1 deletions

View file

@ -89,6 +89,10 @@ namespace guecs {
query<lel::Cell, Sprite>([&](auto, auto &cell, auto &sprite) {
sprite.init(cell);
});
query<lel::Cell, Icon>([&](auto, auto &cell, auto &icon) {
icon.init(cell);
});
}
void UI::debug_layout(sf::RenderWindow& window) {
@ -134,6 +138,11 @@ namespace guecs {
sprite.render(window, shader_ptr);
});
query<Icon>([&](auto ent, auto& icon) {
auto shader_ptr = find_shader(ent, false);
icon.render(window, shader_ptr);
});
query<Text>([&](auto ent, auto& text) {
auto shader_ptr = find_shader(ent, false);
text.render(window, shader_ptr);
@ -188,6 +197,16 @@ namespace guecs {
}
}
void UI::show_icon(const string& region, const string& sprite_name) {
auto ent = entity(region);
if(auto sprite = get_if<Icon>(ent)) {
sprite->update(sprite_name);
} else {
set_init<Icon>(ent, {sprite_name});
}
}
void UI::show_text(const string& region, const wstring& content) {
auto ent = entity(region);