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