You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.1 KiB
48 lines
1.1 KiB
#include "overlay_ui.hpp"
|
|
#include "constants.hpp"
|
|
#include "color.hpp"
|
|
#include "events.hpp"
|
|
|
|
namespace gui {
|
|
using namespace guecs;
|
|
|
|
OverlayUI::OverlayUI(GameLevel level, TexturePack& textures) :
|
|
$level(level),
|
|
$textures(textures)
|
|
{
|
|
$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() {
|
|
auto &world = $gui.world();
|
|
for(auto &[name, cell] : $gui.cells()) {
|
|
auto region = $gui.entity(name);
|
|
world.set<lel::Cell>(region, cell);
|
|
}
|
|
$gui.init($textures);
|
|
}
|
|
|
|
void OverlayUI::draw(sf::RenderWindow& window) {
|
|
$gui.render(window);
|
|
}
|
|
|
|
void OverlayUI::show_damage(bool show) {
|
|
auto middle = $gui.entity("middle");
|
|
|
|
if(show) {
|
|
Sprite blood{"blood_splatter"};
|
|
auto& cell = $gui.cell_for(middle);
|
|
blood.init(cell, $textures);
|
|
$gui.set<guecs::Sprite>(middle, blood);
|
|
} else {
|
|
$gui.remove<guecs::Sprite>(middle);
|
|
}
|
|
}
|
|
}
|
|
|