Started the overlay UI but need to make it possible to add/remove components to it.

This commit is contained in:
Zed A. Shaw 2025-02-20 02:33:09 -05:00
parent 59d10a4506
commit 70a9420c11
8 changed files with 91 additions and 43 deletions

36
overlay_ui.cpp Normal file
View file

@ -0,0 +1,36 @@
#include "overlay_ui.hpp"
#include "constants.hpp"
#include "color.hpp"
#include "events.hpp"
namespace gui {
using namespace guecs;
OverlayUI::OverlayUI(GameLevel level) :
$level(level)
{
$gui.position(RAY_VIEW_X, RAY_VIEW_Y, RAY_VIEW_WIDTH, RAY_VIEW_HEIGHT);
$gui.layout(
"[top_left|top|top_right]"
"[*%(300,300)middle|_|_]"
"[_|_|_]"
"[_|_|_]"
"[bottom_left|bottom|bottom_right]"
);
}
void OverlayUI::render(TexturePack &textures) {
auto &world = $gui.world();
for(auto &[name, cell] : $gui.cells()) {
auto region = $gui.entity(name);
$name_ents.insert_or_assign(name, region);
world.set<lel::Cell>(region, cell);
}
$gui.init(textures);
}
void OverlayUI::draw(sf::RenderWindow& window) {
$gui.render(window);
}
}