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() {
|
void Background::init() {
|
||||||
sf::Vector2f size{float(w), float(h)};
|
sf::Vector2f size{float(w), float(h)};
|
||||||
if(shape == nullptr) shape = make_shared<sf::RectangleShape>(size);
|
if(shape == nullptr) shape = make_shared<sf::RectangleShape>(size);
|
||||||
|
@ -107,6 +113,10 @@ namespace guecs {
|
||||||
return $shader;
|
return $shader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Effect::stop() {
|
||||||
|
$active = false;
|
||||||
|
}
|
||||||
|
|
||||||
UI::UI() {
|
UI::UI() {
|
||||||
$font = make_shared<sf::Font>(FONT_FILE_NAME);
|
$font = make_shared<sf::Font>(FONT_FILE_NAME);
|
||||||
}
|
}
|
||||||
|
@ -242,7 +252,7 @@ namespace guecs {
|
||||||
sound.play(hover);
|
sound.play(hover);
|
||||||
});
|
});
|
||||||
|
|
||||||
if(hover) return; // kinda gross
|
if(hover) return;
|
||||||
|
|
||||||
if(auto action_data = get_if<ActionData>(ent)) {
|
if(auto action_data = get_if<ActionData>(ent)) {
|
||||||
clicked.action(ent, action_data->data);
|
clicked.action(ent, action_data->data);
|
||||||
|
@ -252,9 +262,14 @@ namespace guecs {
|
||||||
|
|
||||||
action_count++;
|
action_count++;
|
||||||
} else {
|
} else {
|
||||||
// via ORBLISHJ
|
do_if<Effect>(ent, [hover](auto& effect) {
|
||||||
// just reset the hover trigger for all that aren't hit
|
effect.stop();
|
||||||
// then in the ^^ positive branch play it and set it played
|
});
|
||||||
|
|
||||||
|
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