parent
7eec67ffc8
commit
9b3b81683a
@ -1,14 +1,14 @@ |
|||||||
#pragma once |
#pragma once |
||||||
|
|
||||||
namespace ColorValue { |
namespace ColorValue { |
||||||
const sf::Color BLACK{1, 4, 2}; |
const sf::Color BLACK{0, 0, 0}; |
||||||
const sf::Color DARK_DARK{9, 29, 16}; |
const sf::Color DARK_DARK{10, 10, 10}; |
||||||
const sf::Color DARK_MID{14, 50, 26}; |
const sf::Color DARK_MID{30, 30, 30}; |
||||||
const sf::Color DARK_LIGHT{0, 109, 44}; |
const sf::Color DARK_LIGHT{60, 60, 60}; |
||||||
const sf::Color MID{63, 171, 92}; |
const sf::Color MID{100, 100, 100}; |
||||||
const sf::Color LIGHT_DARK{161, 217, 155}; |
const sf::Color LIGHT_DARK{150, 150, 150}; |
||||||
const sf::Color LIGHT_MID{199, 233, 192}; |
const sf::Color LIGHT_MID{200, 200, 200}; |
||||||
const sf::Color LIGHT_LIGHT{229, 245, 224}; |
const sf::Color LIGHT_LIGHT{230, 230, 230}; |
||||||
const sf::Color WHITE{255, 255, 255}; |
const sf::Color WHITE{255, 255, 255}; |
||||||
const sf::Color TRANSPARENT = sf::Color::Transparent; |
const sf::Color TRANSPARENT = sf::Color::Transparent; |
||||||
} |
} |
||||||
|
@ -0,0 +1,35 @@ |
|||||||
|
#include "combat_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 "constants.hpp" |
||||||
|
#include "color.hpp" |
||||||
|
|
||||||
|
namespace gui { |
||||||
|
using namespace ftxui; |
||||||
|
|
||||||
|
CombatUI::CombatUI(GameLevel level) : |
||||||
|
Panel(COMBAT_UI_X, COMBAT_UI_Y, COMBAT_UI_WIDTH, COMBAT_UI_HEIGHT, false), |
||||||
|
$level(level) |
||||||
|
{ |
||||||
|
default_bg = {0,0,0}; |
||||||
|
} |
||||||
|
|
||||||
|
void CombatUI::create_render() { |
||||||
|
$attack1_button = Button("ATTACK1", []{ fmt::println("ATTACK1 clicked"); }); |
||||||
|
$attack2_button = Button("ATTACK2", []{ fmt::println("ATTACK2 clicked"); }); |
||||||
|
|
||||||
|
auto combat_rend = Renderer([&]{ |
||||||
|
return hbox({ |
||||||
|
$attack1_button->Render(), |
||||||
|
$attack2_button->Render() |
||||||
|
}); |
||||||
|
}); |
||||||
|
|
||||||
|
set_renderer(combat_rend); |
||||||
|
add($attack1_button); |
||||||
|
add($attack2_button); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,18 @@ |
|||||||
|
#pragma once |
||||||
|
#include "panel.hpp" |
||||||
|
#include "levelmanager.hpp" |
||||||
|
#include <ftxui/component/component.hpp> |
||||||
|
|
||||||
|
namespace gui { |
||||||
|
class CombatUI : public Panel { |
||||||
|
public: |
||||||
|
GameLevel $level; |
||||||
|
Component $attack1_button; |
||||||
|
Component $attack2_button; |
||||||
|
|
||||||
|
CombatUI(GameLevel level); |
||||||
|
|
||||||
|
void create_render(); |
||||||
|
void update_level(GameLevel &level) { $level = level; } |
||||||
|
}; |
||||||
|
} |
@ -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); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,14 @@ |
|||||||
|
#pragma once |
||||||
|
#include "panel.hpp" |
||||||
|
#include "levelmanager.hpp" |
||||||
|
#include "constants.hpp" |
||||||
|
|
||||||
|
namespace gui { |
||||||
|
class StatusUI : public Panel { |
||||||
|
public: |
||||||
|
GameLevel $level; |
||||||
|
StatusUI(GameLevel level); |
||||||
|
void create_render(); |
||||||
|
void update_level(GameLevel &level) { $level = level; } |
||||||
|
}; |
||||||
|
} |
Loading…
Reference in new issue