Mostly working overlay to show when in combat or not.
This commit is contained in:
parent
30a7e1b2cc
commit
4a1a8a7d65
4 changed files with 66 additions and 32 deletions
|
@ -2,9 +2,11 @@
|
|||
#include "constants.hpp"
|
||||
#include "color.hpp"
|
||||
#include "events.hpp"
|
||||
#include <optional>
|
||||
|
||||
namespace gui {
|
||||
using namespace guecs;
|
||||
using std::string;
|
||||
|
||||
OverlayUI::OverlayUI(GameLevel level, TexturePack& textures) :
|
||||
$level(level),
|
||||
|
@ -33,36 +35,51 @@ namespace gui {
|
|||
$gui.render(window);
|
||||
}
|
||||
|
||||
void OverlayUI::show_damage(bool show) {
|
||||
auto middle = $gui.entity("middle");
|
||||
void OverlayUI::show_sprite(string region, string sprite_name) {
|
||||
auto ent = $gui.entity(region);
|
||||
Sprite blood{sprite_name};
|
||||
auto& cell = $gui.cell_for(ent);
|
||||
blood.init(cell, $textures);
|
||||
$gui.set<guecs::Sprite>(ent, blood);
|
||||
}
|
||||
|
||||
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);
|
||||
void OverlayUI::close_sprite(string region) {
|
||||
auto ent = $gui.entity(region);
|
||||
$gui.remove<guecs::Sprite>(ent);
|
||||
}
|
||||
|
||||
void OverlayUI::show_text(string region, string content) {
|
||||
auto ent = $gui.entity(region);
|
||||
auto &cell = $gui.cell_for(ent);
|
||||
Textual text{content, 20};
|
||||
text.init(cell, $gui.$font);
|
||||
text.text->setFillColor(ColorValue::LIGHT_MID);
|
||||
$gui.set<Textual>(ent, text);
|
||||
}
|
||||
|
||||
void OverlayUI::update_text(string region, string content) {
|
||||
auto ent = $gui.entity(region);
|
||||
if(auto text = $gui.get_if<Textual>(ent)) {
|
||||
text->text->setString(content);
|
||||
}
|
||||
}
|
||||
|
||||
void OverlayUI::init_stats() {
|
||||
auto top_left = $gui.entity("top_left");
|
||||
auto &cell = $gui.cell_for(top_left);
|
||||
Textual text{"", 20};
|
||||
void OverlayUI::close_text(string region) {
|
||||
auto ent = $gui.entity(region);
|
||||
$gui.remove<Textual>(ent);
|
||||
}
|
||||
|
||||
void OverlayUI::show_label(string region, string content) {
|
||||
auto ent = $gui.entity(region);
|
||||
auto &cell = $gui.cell_for(ent);
|
||||
Label text{content, 20};
|
||||
text.init(cell, $gui.$font);
|
||||
text.text->setFillColor(ColorValue::LIGHT_MID);
|
||||
$gui.set<Textual>(top_left, text);
|
||||
$gui.set<Label>(ent, text);
|
||||
}
|
||||
|
||||
void OverlayUI::draw_stats(std::string stats) {
|
||||
auto top_left = $gui.entity("top_left");
|
||||
auto& text = $gui.get<Textual>(top_left);
|
||||
text.text->setString(stats);
|
||||
}
|
||||
|
||||
void OverlayUI::close_stats() {
|
||||
auto top_left = $gui.entity("top_left");
|
||||
$gui.remove<Textual>(top_left);
|
||||
void OverlayUI::close_label(string region) {
|
||||
auto ent = $gui.entity(region);
|
||||
$gui.remove<Label>(ent);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue