Now have a body damage UI to show damage to each body part.

This commit is contained in:
Zed A. Shaw 2026-03-29 14:43:05 -04:00
parent 36a49ef768
commit ae0d205037
5 changed files with 81 additions and 10 deletions

52
src/gui/body_ui.cpp Normal file
View file

@ -0,0 +1,52 @@
#include "gui/body_ui.hpp"
#include "game/components.hpp"
#include <guecs/ui.hpp>
#include "algos/rand.hpp"
#include <fmt/xchar.h>
#include "gui/guecstra.hpp"
#include "game/systems.hpp"
#include "game/inventory.hpp"
#include "game/level.hpp"
namespace gui {
using namespace guecs;
using std::any, std::any_cast, std::string, std::make_any;
void BodyUI::init(size_t x, size_t y, size_t width, size_t height) {
$gui.position(x, y, width, height);
$gui.layout(
"[body_head]"
"[body_chest]"
"[body_right_arm]"
"[body_left_arm]"
"[body_stomach]"
"[body_left_leg]"
"[body_right_leg]");
$gui.set<Background>($gui.MAIN, {$gui.$parser, });
for(auto& [name, cell] : $gui.cells()) {
auto gui_id = $gui.entity(name);
$gui.set<Text>(gui_id, {guecs::to_wstring(name)});
$gui.set<Meter>(gui_id, {1.0f, THEME.DARK_MID, {}});
}
$gui.init();
update();
}
bool BodyUI::mouse(float x, float y, guecs::Modifiers mods) {
return $gui.mouse(x, y, mods);
}
void BodyUI::update() {
auto world = GameDB::current_world();
auto player = world->get_the<components::Player>();
}
void BodyUI::render(sf::RenderWindow &window) {
$gui.render(window);
// $gui.debug_layout(window);
}
}