Major refactoring but now centering text and sprites works. See Issue #16 for why only those and not anything else yet.
This commit is contained in:
parent
2c22da022f
commit
9e9b9620c9
6 changed files with 47 additions and 92 deletions
|
|
@ -82,21 +82,13 @@ namespace guecs {
|
|||
}
|
||||
});
|
||||
|
||||
query<lel::Cell, Textual>([this](auto, auto& cell, auto& text) {
|
||||
text.init(cell, $font);
|
||||
});
|
||||
|
||||
query<lel::Cell, Label>([this](auto, auto& cell, auto& text) {
|
||||
query<lel::Cell, Text>([this](auto, auto& cell, auto& text) {
|
||||
text.init(cell, $font);
|
||||
});
|
||||
|
||||
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) {
|
||||
|
|
@ -142,17 +134,7 @@ 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<Label>([&](auto ent, auto& text) {
|
||||
auto shader_ptr = find_shader(ent, false);
|
||||
text.render(window, shader_ptr);
|
||||
});
|
||||
|
||||
query<Textual>([&](auto ent, auto& text) {
|
||||
query<Text>([&](auto ent, auto& text) {
|
||||
auto shader_ptr = find_shader(ent, false);
|
||||
text.render(window, shader_ptr);
|
||||
});
|
||||
|
|
@ -209,13 +191,13 @@ namespace guecs {
|
|||
void UI::show_text(const string& region, const wstring& content) {
|
||||
auto ent = entity(region);
|
||||
|
||||
if(auto tc = get_if<Textual>(ent)) {
|
||||
if(auto tc = get_if<Text>(ent)) {
|
||||
tc->text->setString(content);
|
||||
} else {
|
||||
auto &cell = cell_for(ent);
|
||||
Textual to_set{content, THEME.TEXT_SIZE};
|
||||
Text to_set{content, THEME.TEXT_SIZE};
|
||||
to_set.init(cell, $font);
|
||||
set<Textual>(ent, to_set);
|
||||
set<Text>(ent, to_set);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -240,20 +222,6 @@ namespace guecs {
|
|||
}
|
||||
}
|
||||
|
||||
void UI::show_label(const string& region, const wstring& content) {
|
||||
auto ent = entity(region);
|
||||
|
||||
if(auto tc = get_if<Label>(ent)) {
|
||||
tc->text->setString(content);
|
||||
} else {
|
||||
auto &cell = cell_for(ent);
|
||||
Label to_set{content, THEME.LABEL_SIZE};
|
||||
to_set.init(cell, $font);
|
||||
to_set.text->setFillColor(THEME.TEXT_COLOR);
|
||||
set<Label>(ent, to_set);
|
||||
}
|
||||
}
|
||||
|
||||
wstring to_wstring(const string& str) {
|
||||
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> $converter;
|
||||
return $converter.from_bytes(str);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue