Got some buttons down now to make them do stuff.
This commit is contained in:
parent
be4d0d51de
commit
7eec67ffc8
2 changed files with 10 additions and 9 deletions
16
gui.cpp
16
gui.cpp
|
@ -7,7 +7,6 @@
|
||||||
#include <numbers>
|
#include <numbers>
|
||||||
#include "systems.hpp"
|
#include "systems.hpp"
|
||||||
#include "map_view.hpp"
|
#include "map_view.hpp"
|
||||||
#include <ftxui/dom/elements.hpp> // for hflow, paragraph, separator, hbox, vbox, filler, operator|, border, Element
|
|
||||||
#include <ftxui/dom/node.hpp> // for Render
|
#include <ftxui/dom/node.hpp> // for Render
|
||||||
#include <ftxui/screen/box.hpp> // for ftxui
|
#include <ftxui/screen/box.hpp> // for ftxui
|
||||||
#include <ftxui/component/loop.hpp>
|
#include <ftxui/component/loop.hpp>
|
||||||
|
@ -48,20 +47,19 @@ namespace gui {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CombatUI::create_render() {
|
void CombatUI::create_render() {
|
||||||
auto player = $level.world->get_the<Player>();
|
$attack1_button = Button("ATTACK1", []{ fmt::println("ATTACK1 clicked"); });
|
||||||
|
$attack2_button = Button("ATTACK2", []{ fmt::println("ATTACK2 clicked"); });
|
||||||
auto combat_rend = Renderer([&, player]{
|
|
||||||
const auto& player_combat = $level.world->get<Combat>(player.entity);
|
|
||||||
const auto& combat = $level.world->get<Combat>(player.entity);
|
|
||||||
|
|
||||||
|
auto combat_rend = Renderer([&]{
|
||||||
return hbox({
|
return hbox({
|
||||||
text(fmt::format("HP: {: >3} DMG: {: >3}",
|
$attack1_button->Render(),
|
||||||
player_combat.hp,
|
$attack2_button->Render()
|
||||||
combat.damage)) | flex_grow
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
set_renderer(combat_rend);
|
set_renderer(combat_rend);
|
||||||
|
add($attack1_button);
|
||||||
|
add($attack2_button);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
3
gui.hpp
3
gui.hpp
|
@ -7,6 +7,7 @@
|
||||||
#include "fsm.hpp"
|
#include "fsm.hpp"
|
||||||
#include "render.hpp"
|
#include "render.hpp"
|
||||||
#include "map_view.hpp"
|
#include "map_view.hpp"
|
||||||
|
#include <ftxui/dom/elements.hpp> // for hflow, paragraph, separator, hbox, vbox, filler, operator|, border, Element
|
||||||
|
|
||||||
namespace gui {
|
namespace gui {
|
||||||
class StatusUI : public Panel {
|
class StatusUI : public Panel {
|
||||||
|
@ -27,6 +28,8 @@ namespace gui {
|
||||||
class CombatUI : public Panel {
|
class CombatUI : public Panel {
|
||||||
public:
|
public:
|
||||||
GameLevel $level;
|
GameLevel $level;
|
||||||
|
Component $attack1_button;
|
||||||
|
Component $attack2_button;
|
||||||
|
|
||||||
CombatUI(GameLevel level) :
|
CombatUI(GameLevel level) :
|
||||||
Panel(RAY_VIEW_X, RAY_VIEW_HEIGHT, 89, 6, false),
|
Panel(RAY_VIEW_X, RAY_VIEW_HEIGHT, 89, 6, false),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue