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.3 KiB
48 lines
1.3 KiB
#include "status_ui.hpp"
|
|
#include <ftxui/dom/node.hpp> // for Render
|
|
#include <ftxui/screen/box.hpp> // for ftxui
|
|
#include <ftxui/component/loop.hpp>
|
|
#include <ftxui/screen/color.hpp>
|
|
#include <ftxui/dom/table.hpp>
|
|
#include "components.hpp"
|
|
#include "color.hpp"
|
|
|
|
namespace gui {
|
|
using namespace components;
|
|
using namespace ftxui;
|
|
|
|
StatusUI::StatusUI(GameLevel level) :
|
|
Panel(STATUS_UI_X, STATUS_UI_Y, STATUS_UI_WIDTH, STATUS_UI_HEIGHT, false),
|
|
$level(level)
|
|
{
|
|
default_bg = ColorValue::DARK_MID;
|
|
}
|
|
|
|
void StatusUI::create_render() {
|
|
auto player = $level.world->get_the<Player>();
|
|
|
|
auto status_rend = Renderer([&, player]{
|
|
const auto& player_combat = $level.world->get<Combat>(player.entity);
|
|
const auto& combat = $level.world->get<Combat>(player.entity);
|
|
|
|
std::vector<Element> log_list;
|
|
log_list.push_back(text("Log messages here."));
|
|
|
|
auto log_box = vbox(log_list) | yflex_grow;
|
|
|
|
return hbox({
|
|
hflow(
|
|
vbox(
|
|
text(fmt::format("HP: {: >3} DMG: {: >3}",
|
|
player_combat.hp,
|
|
combat.damage)),
|
|
separator(),
|
|
log_box
|
|
) | flex_grow
|
|
)
|
|
});
|
|
});
|
|
|
|
set_renderer(status_rend);
|
|
}
|
|
}
|
|
|