Combat UI now uses different icons for different attack elements.
This commit is contained in:
parent
30997cbff5
commit
eb709930f5
2 changed files with 26 additions and 6 deletions
|
@ -15,17 +15,35 @@ namespace gui {
|
||||||
"[*%(100,150)button_0 | *%(100,150)button_1 | *%(100,150)button_2 | *%(100,150)button_3]");
|
"[*%(100,150)button_0 | *%(100,150)button_1 | *%(100,150)button_2 | *%(100,150)button_3]");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CombatUI::make_button(std::string name, std::wstring label, Events::GUI event, int action) {
|
void CombatUI::make_button(std::string name, std::wstring label, Events::GUI event, int action, const std::string &icon_name) {
|
||||||
|
(void)label;
|
||||||
auto button = $gui.entity(name);
|
auto button = $gui.entity(name);
|
||||||
$gui.set<Sprite>(button, {"leather_pouch-128"});
|
$gui.set<Sprite>(button, {icon_name});
|
||||||
$gui.set<Rectangle>(button, {});
|
// $gui.set<Rectangle>(button, {});
|
||||||
$gui.set<Sound>(button, {"ui_click"});
|
$gui.set<Sound>(button, {"ui_click"});
|
||||||
$gui.set<Label>(button, {label});
|
// $gui.set<Label>(button, {label});
|
||||||
$gui.set<Effect>(button, {.duration=0.1f});
|
$gui.set<Effect>(button, {.duration=0.1f});
|
||||||
$gui.set<Clickable>(button,
|
$gui.set<Clickable>(button,
|
||||||
guecs::make_action(*$level.world, event, {action}));
|
guecs::make_action(*$level.world, event, {action}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline std::string temp_pick_icon_for_element(combat::RitualAction& ritual) {
|
||||||
|
using enum combat::RitualElement;
|
||||||
|
|
||||||
|
switch(ritual.element) {
|
||||||
|
case FIRE:
|
||||||
|
return "broken_yoyo-64";
|
||||||
|
break;
|
||||||
|
case LIGHTNING:
|
||||||
|
return "stone_doll_cursed-64";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return "severed_finger-64";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void CombatUI::init() {
|
void CombatUI::init() {
|
||||||
$gui.world().set_the<Background>({$gui.$parser, ColorValue::DARK_MID});
|
$gui.world().set_the<Background>({$gui.$parser, ColorValue::DARK_MID});
|
||||||
auto& the_belt = $level.world->get<combat::RitualBelt>($level.player);
|
auto& the_belt = $level.world->get<combat::RitualBelt>($level.player);
|
||||||
|
@ -34,7 +52,9 @@ namespace gui {
|
||||||
if(the_belt.has(slot)) {
|
if(the_belt.has(slot)) {
|
||||||
std::string name = fmt::format("button_{}", slot);
|
std::string name = fmt::format("button_{}", slot);
|
||||||
std::wstring label = fmt::format(L"Attack {}", slot+1);
|
std::wstring label = fmt::format(L"Attack {}", slot+1);
|
||||||
make_button(name, label, Events::GUI::ATTACK, slot);
|
auto& ritual = the_belt.get(slot);
|
||||||
|
make_button(name, label, Events::GUI::ATTACK, slot,
|
||||||
|
temp_pick_icon_for_element(ritual));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,6 @@ namespace gui {
|
||||||
void render(sf::RenderWindow& window);
|
void render(sf::RenderWindow& window);
|
||||||
void update_level(GameLevel &level);
|
void update_level(GameLevel &level);
|
||||||
bool mouse(float x, float y, bool hover);
|
bool mouse(float x, float y, bool hover);
|
||||||
void make_button(std::string name, std::wstring label, Events::GUI event, int action);
|
void make_button(std::string name, std::wstring label, Events::GUI event, int action, const std::string &icon_name);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue