|
|
|
@ -13,7 +13,7 @@ namespace gui { |
|
|
|
|
"[*%(100,150)button_attack | *%(100,150)button_block | *%(100,150)button_evade | *%(100,150)button_heal]"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void CombatUI::make_button(std::string name, std::wstring label, Events::GUI event) { |
|
|
|
|
void CombatUI::make_button(std::string name, std::wstring label, Events::GUI event, int action) { |
|
|
|
|
auto button = $gui.entity(name); |
|
|
|
|
$gui.set<Sprite>(button, {"leather_pouch-128"}); |
|
|
|
|
$gui.set<Rectangle>(button, {}); |
|
|
|
@ -21,27 +21,22 @@ namespace gui { |
|
|
|
|
$gui.set<Label>(button, {label}); |
|
|
|
|
$gui.set<Effect>(button, {.duration=0.1f}); |
|
|
|
|
$gui.set<Clickable>(button, |
|
|
|
|
guecs::make_action(*$level.world, event)); |
|
|
|
|
guecs::make_action(*$level.world, event, {action})); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void CombatUI::init() { |
|
|
|
|
$gui.world().set_the<Background>({$gui.$parser, ColorValue::DARK_MID}); |
|
|
|
|
make_button("button_attack", L"Attack", Events::GUI::ATTACK); |
|
|
|
|
make_button("button_block", L"Block", Events::GUI::BLOCK); |
|
|
|
|
make_button("button_evade", L"Evade", Events::GUI::EVADE); |
|
|
|
|
make_button("button_heal", L"Heal", Events::GUI::HEAL); |
|
|
|
|
make_button("button_attack", L"Attack", Events::GUI::ATTACK, 1); |
|
|
|
|
make_button("button_block", L"Block", Events::GUI::ATTACK, 2); |
|
|
|
|
make_button("button_evade", L"Evade", Events::GUI::EVADE, 0); |
|
|
|
|
make_button("button_heal", L"Heal", Events::GUI::HEAL, 0); |
|
|
|
|
$gui.init(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void CombatUI::render(sf::RenderWindow& window) { |
|
|
|
|
auto& player_combat = $level.world->get<components::Combat>($level.player); |
|
|
|
|
set_damage(float(player_combat.hp) / float(player_combat.max_hp)); |
|
|
|
|
$gui.render(window); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void CombatUI::set_damage(float) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void CombatUI::update_level(GameLevel &level) { |
|
|
|
|
$level = level; |
|
|
|
|
init(); |
|
|
|
|