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
10
sound.cpp
10
sound.cpp
|
@ -37,7 +37,7 @@ namespace sound {
|
|||
}
|
||||
}
|
||||
|
||||
void load(const std::string name, const std::string sound_path) {
|
||||
void load(const std::string& name, const std::string& sound_path) {
|
||||
dbc::check(fs::exists(sound_path), fmt::format("sound file {} does not exist", sound_path));
|
||||
|
||||
// create the buffer and keep in the buffer map
|
||||
|
@ -51,7 +51,7 @@ namespace sound {
|
|||
SMGR.sounds.try_emplace(name, buffer, sound);
|
||||
}
|
||||
|
||||
void play(const std::string name, bool loop) {
|
||||
void play(const std::string& name, bool loop) {
|
||||
if(muted) return;
|
||||
auto& pair = get_sound_pair(name);
|
||||
pair.sound->setLooping(loop);
|
||||
|
@ -59,18 +59,18 @@ namespace sound {
|
|||
pair.sound->play();
|
||||
}
|
||||
|
||||
void stop(const std::string name) {
|
||||
void stop(const std::string& name) {
|
||||
auto& pair = get_sound_pair(name);
|
||||
pair.sound->stop();
|
||||
}
|
||||
|
||||
bool playing(const std::string name) {
|
||||
bool playing(const std::string& name) {
|
||||
auto& pair = get_sound_pair(name);
|
||||
auto status = pair.sound->getStatus();
|
||||
return status == sf::SoundSource::Status::Playing;
|
||||
}
|
||||
|
||||
void play_at(const std::string name, float x, float y, float z) {
|
||||
void play_at(const std::string& name, float x, float y, float z) {
|
||||
auto& pair = get_sound_pair(name);
|
||||
pair.sound->setPosition({x, y, z});
|
||||
pair.sound->play();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue