Separate out the major UIs to get ready for their development, and enable debug button.
This commit is contained in:
parent
7eec67ffc8
commit
9b3b81683a
11 changed files with 154 additions and 116 deletions
48
status_ui.cpp
Normal file
48
status_ui.cpp
Normal file
|
@ -0,0 +1,48 @@
|
|||
#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);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue