Now have sounds and shaders working on the button for each of the different elements.
This commit is contained in:
parent
eb350698aa
commit
2fb1687997
7 changed files with 32 additions and 22 deletions
|
@ -19,7 +19,10 @@
|
||||||
"pickup": "assets/sounds/pickup.ogg",
|
"pickup": "assets/sounds/pickup.ogg",
|
||||||
"ambient_1": "assets/sounds/ambient_1.ogg",
|
"ambient_1": "assets/sounds/ambient_1.ogg",
|
||||||
"ui_click": "assets/sounds/ui_click.ogg",
|
"ui_click": "assets/sounds/ui_click.ogg",
|
||||||
"ui_hover": "assets/sounds/ui_hover.ogg"
|
"ui_hover": "assets/sounds/ui_hover.ogg",
|
||||||
|
"punch_cartoony": "assets/sounds/punch_cartoony.ogg",
|
||||||
|
"electric_shock_01": "assets/sounds/electric_shock_01.ogg",
|
||||||
|
"fireball_01": "assets/sounds/fireball_01.ogg"
|
||||||
},
|
},
|
||||||
"sprites": {
|
"sprites": {
|
||||||
"gold_savior":
|
"gold_savior":
|
||||||
|
|
BIN
assets/sounds/electric_shock_01.ogg
Normal file
BIN
assets/sounds/electric_shock_01.ogg
Normal file
Binary file not shown.
BIN
assets/sounds/fireball_01.ogg
Normal file
BIN
assets/sounds/fireball_01.ogg
Normal file
Binary file not shown.
BIN
assets/sounds/punch_cartoony.ogg
Normal file
BIN
assets/sounds/punch_cartoony.ogg
Normal file
Binary file not shown.
|
@ -15,31 +15,20 @@ 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, const std::string &icon_name) {
|
DinkyECS::Entity CombatUI::make_button(std::string name, std::wstring label, Events::GUI event, int action, const std::string &icon_name,
|
||||||
|
const std::string &sound, const std::string &effect_name)
|
||||||
|
{
|
||||||
(void)label;
|
(void)label;
|
||||||
auto button = $gui.entity(name);
|
auto button = $gui.entity(name);
|
||||||
$gui.set<Sprite>(button, {icon_name});
|
$gui.set<Sprite>(button, {icon_name});
|
||||||
// $gui.set<Rectangle>(button, {});
|
// $gui.set<Rectangle>(button, {});
|
||||||
$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<Sound>(button, {sound});
|
||||||
|
$gui.set<Effect>(button, {.duration=1.0f, .name=effect_name});
|
||||||
$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) {
|
return button;
|
||||||
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() {
|
||||||
|
@ -51,8 +40,24 @@ namespace gui {
|
||||||
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);
|
||||||
auto& ritual = the_belt.get(slot);
|
auto& ritual = the_belt.get(slot);
|
||||||
make_button(name, label, Events::GUI::ATTACK, slot,
|
|
||||||
temp_pick_icon_for_element(ritual));
|
|
||||||
|
|
||||||
|
using enum combat::RitualElement;
|
||||||
|
|
||||||
|
switch(ritual.element) {
|
||||||
|
case FIRE:
|
||||||
|
make_button(name, label, Events::GUI::ATTACK,
|
||||||
|
slot, "broken_yoyo-64", "fireball_01", "flame");
|
||||||
|
break;
|
||||||
|
case LIGHTNING:
|
||||||
|
make_button(name, label, Events::GUI::ATTACK,
|
||||||
|
slot, "stone_doll_cursed-64", "electric_shock_01", "lightning");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
make_button(name, label, Events::GUI::ATTACK,
|
||||||
|
slot, "severed_finger-64", "punch_cartoony", "ui_shader");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,8 @@ 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, const std::string &icon_name);
|
DinkyECS::Entity make_button(std::string name, std::wstring label,
|
||||||
|
Events::GUI event, int action, const std::string &icon_name,
|
||||||
|
const std::string &sound, const std::string &effect_name);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -213,7 +213,7 @@ namespace guecs {
|
||||||
if($world.has<Effect>(ent)) {
|
if($world.has<Effect>(ent)) {
|
||||||
auto& shader = $world.get<Effect>(ent);
|
auto& shader = $world.get<Effect>(ent);
|
||||||
|
|
||||||
if(shader.$active) {
|
if(shader.$active && !is_shape) {
|
||||||
auto ptr = shader.checkout_ptr();
|
auto ptr = shader.checkout_ptr();
|
||||||
ptr->setUniform("is_shape", is_shape);
|
ptr->setUniform("is_shape", is_shape);
|
||||||
// NOTE: this is needed because SFML doesn't handle shared_ptr
|
// NOTE: this is needed because SFML doesn't handle shared_ptr
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue