Got some buttons down now to make them do stuff.

master
Zed A. Shaw 4 weeks ago
parent be4d0d51de
commit 7eec67ffc8
  1. 16
      gui.cpp
  2. 3
      gui.hpp

@ -7,7 +7,6 @@
#include <numbers>
#include "systems.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/screen/box.hpp> // for ftxui
#include <ftxui/component/loop.hpp>
@ -48,20 +47,19 @@ namespace gui {
}
void CombatUI::create_render() {
auto player = $level.world->get_the<Player>();
auto combat_rend = Renderer([&, player]{
const auto& player_combat = $level.world->get<Combat>(player.entity);
const auto& combat = $level.world->get<Combat>(player.entity);
$attack1_button = Button("ATTACK1", []{ fmt::println("ATTACK1 clicked"); });
$attack2_button = Button("ATTACK2", []{ fmt::println("ATTACK2 clicked"); });
auto combat_rend = Renderer([&]{
return hbox({
text(fmt::format("HP: {: >3} DMG: {: >3}",
player_combat.hp,
combat.damage)) | flex_grow
$attack1_button->Render(),
$attack2_button->Render()
});
});
set_renderer(combat_rend);
add($attack1_button);
add($attack2_button);
}

@ -7,6 +7,7 @@
#include "fsm.hpp"
#include "render.hpp"
#include "map_view.hpp"
#include <ftxui/dom/elements.hpp> // for hflow, paragraph, separator, hbox, vbox, filler, operator|, border, Element
namespace gui {
class StatusUI : public Panel {
@ -27,6 +28,8 @@ namespace gui {
class CombatUI : public Panel {
public:
GameLevel $level;
Component $attack1_button;
Component $attack2_button;
CombatUI(GameLevel level) :
Panel(RAY_VIEW_X, RAY_VIEW_HEIGHT, 89, 6, false),

Loading…
Cancel
Save