Status UI now has a log and some buttons.
This commit is contained in:
parent
3a6ba8445a
commit
bfe0d797c8
7 changed files with 61 additions and 17 deletions
27
guecs.hpp
27
guecs.hpp
|
@ -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;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue