Have a basic little click sound going, but hover events will need some work. I'm doing those on every mouse move.
This commit is contained in:
parent
7186c2ecb0
commit
2ecef8d9f9
6 changed files with 36 additions and 11 deletions
15
guecs.cpp
15
guecs.cpp
|
@ -1,5 +1,6 @@
|
|||
#include "guecs.hpp"
|
||||
#include "shaders.hpp"
|
||||
#include "sound.hpp"
|
||||
|
||||
namespace guecs {
|
||||
|
||||
|
@ -58,6 +59,14 @@ namespace guecs {
|
|||
bar.init(cell);
|
||||
}
|
||||
|
||||
void Sound::play(bool hover) {
|
||||
if(hover) {
|
||||
// BUG: need to sort out how to make hover a one shot thing
|
||||
// sound::play(on_hover);
|
||||
} else {
|
||||
sound::play(on_click);
|
||||
}
|
||||
}
|
||||
|
||||
void Background::init() {
|
||||
sf::Vector2f size{float(w), float(h)};
|
||||
|
@ -232,6 +241,12 @@ namespace guecs {
|
|||
effect.run();
|
||||
}
|
||||
|
||||
if($world.has<Sound>(ent)) {
|
||||
auto& sound = $world.get<Sound>(ent);
|
||||
sound.play(hover);
|
||||
}
|
||||
|
||||
|
||||
if(hover) return; // kinda gross
|
||||
|
||||
if(auto action_data = get_if<ActionData>(ent)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue