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
|
@ -10,16 +10,32 @@ namespace gui {
|
|||
$level(level)
|
||||
{
|
||||
$gui.position(STATUS_UI_X, STATUS_UI_Y, STATUS_UI_WIDTH, STATUS_UI_HEIGHT);
|
||||
$gui.layout("[log_view]");
|
||||
$gui.layout(
|
||||
"[*%(100,200)log_view]"
|
||||
"[_]"
|
||||
"[button1 | button2 | button3]"
|
||||
"[button4 | button5 | button6]"
|
||||
);
|
||||
}
|
||||
|
||||
void StatusUI::render(TexturePack &textures) {
|
||||
auto& world = $gui.world();
|
||||
auto& cell = $gui.cells().at("log_view");
|
||||
$log_to = $gui.entity("log_view");
|
||||
world.set<lel::Cell>($log_to, cell);
|
||||
world.set<Rectangle>($log_to, {});
|
||||
world.set<Textual>($log_to, {"TEST"});
|
||||
|
||||
for(auto& [name, cell] : $gui.cells()) {
|
||||
if(name == "log_view") {
|
||||
$log_to = $gui.entity("log_view");
|
||||
world.set<lel::Cell>($log_to, cell);
|
||||
world.set<Rectangle>($log_to, {});
|
||||
world.set<Textual>($log_to, {"Welcome to the Game!", 20});
|
||||
} else {
|
||||
auto button = $gui.entity(name);
|
||||
world.set<lel::Cell>(button, cell);
|
||||
world.set<Rectangle>(button, {});
|
||||
world.set<Label>(button, {name});
|
||||
world.set<Clickable>(button,
|
||||
guecs::make_action(*$level.world, Events::GUI::NOOP));
|
||||
}
|
||||
}
|
||||
|
||||
$gui.init(textures);
|
||||
}
|
||||
|
@ -28,13 +44,10 @@ namespace gui {
|
|||
auto &world = $gui.world();
|
||||
auto &text = world.get<Textual>($log_to);
|
||||
std::string log;
|
||||
|
||||
for(auto msg : $messages) {
|
||||
log += msg + "\n";
|
||||
}
|
||||
|
||||
text.label = log;
|
||||
|
||||
text.update(log);
|
||||
$gui.render(window);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue