Fix from ORBLISH suggestion to stop any component that's not hover/clicked on in the mouse handler.
This commit is contained in:
parent
8aeac5397a
commit
bc31750d9c
1 changed files with 19 additions and 4 deletions
23
guecs.cpp
23
guecs.cpp
|
@ -65,6 +65,12 @@ namespace guecs {
|
|||
}
|
||||
}
|
||||
|
||||
void Sound::stop(bool hover) {
|
||||
if(!hover) {
|
||||
sound::stop(on_click);
|
||||
}
|
||||
}
|
||||
|
||||
void Background::init() {
|
||||
sf::Vector2f size{float(w), float(h)};
|
||||
if(shape == nullptr) shape = make_shared<sf::RectangleShape>(size);
|
||||
|
@ -107,6 +113,10 @@ namespace guecs {
|
|||
return $shader;
|
||||
}
|
||||
|
||||
void Effect::stop() {
|
||||
$active = false;
|
||||
}
|
||||
|
||||
UI::UI() {
|
||||
$font = make_shared<sf::Font>(FONT_FILE_NAME);
|
||||
}
|
||||
|
@ -242,7 +252,7 @@ namespace guecs {
|
|||
sound.play(hover);
|
||||
});
|
||||
|
||||
if(hover) return; // kinda gross
|
||||
if(hover) return;
|
||||
|
||||
if(auto action_data = get_if<ActionData>(ent)) {
|
||||
clicked.action(ent, action_data->data);
|
||||
|
@ -252,9 +262,14 @@ namespace guecs {
|
|||
|
||||
action_count++;
|
||||
} else {
|
||||
// via ORBLISHJ
|
||||
// just reset the hover trigger for all that aren't hit
|
||||
// then in the ^^ positive branch play it and set it played
|
||||
do_if<Effect>(ent, [hover](auto& effect) {
|
||||
effect.stop();
|
||||
});
|
||||
|
||||
do_if<Sound>(ent, [hover](auto& sound) {
|
||||
// here set that it played then only play once
|
||||
sound.stop(hover);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue