Status UI now has a log and some buttons.

This commit is contained in:
Zed A. Shaw 2025-02-18 23:58:13 -05:00
parent 3a6ba8445a
commit bfe0d797c8
7 changed files with 61 additions and 17 deletions

View file

@ -12,15 +12,15 @@
namespace guecs {
using std::shared_ptr, std::make_shared;
struct Textual {
struct Label {
std::string label;
unsigned int size = 30;
shared_ptr<sf::Font> font = nullptr;
shared_ptr<sf::Text> text = nullptr;
void init(lel::Cell &cell, shared_ptr<sf::Font> font_ptr) {
font = font_ptr;
text = make_shared<sf::Text>(*font, label);
if(font == nullptr) font = font_ptr;
if(text == nullptr) text = make_shared<sf::Text>(*font, label, size);
auto bounds = text->getLocalBounds();
auto text_cell = lel::center(bounds.size.x, bounds.size.y, cell);
// this stupid / 2 is because SFML renders from baseline rather than from the claimed bounding box
@ -28,6 +28,25 @@ namespace guecs {
}
};
struct Textual {
std::string content;
unsigned int size = 30;
shared_ptr<sf::Font> font = nullptr;
shared_ptr<sf::Text> text = nullptr;
void init(lel::Cell &cell, shared_ptr<sf::Font> font_ptr) {
if(font == nullptr) font = font_ptr;
if(text == nullptr) text = make_shared<sf::Text>(*font, content, size);
text->setPosition({float(cell.x + 6), float(cell.y + 6)});
text->setCharacterSize(size);
}
void update(std::string& new_content) {
content = new_content;
text->setString(content);
}
};
struct Clickable {
std::function<void(DinkyECS::Entity ent, std::string &name)> action;
};