|
|
@ -28,7 +28,7 @@ namespace sound { |
|
|
|
|
|
|
|
|
|
|
|
void init() { |
|
|
|
void init() { |
|
|
|
if(!initialized) { |
|
|
|
if(!initialized) { |
|
|
|
Config assets("assets/config.json"); |
|
|
|
Config assets("./assets/config.json"); |
|
|
|
|
|
|
|
|
|
|
|
for(auto& el : assets["sounds"].items()) { |
|
|
|
for(auto& el : assets["sounds"].items()) { |
|
|
|
load(el.key(), el.value()); |
|
|
|
load(el.key(), el.value()); |
|
|
@ -38,10 +38,11 @@ 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(Config::path_to(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
|
|
|
|
auto buffer = make_shared<sf::SoundBuffer>(sound_path); |
|
|
|
auto buffer = make_shared<sf::SoundBuffer>(Config::path_to(sound_path)); |
|
|
|
|
|
|
|
|
|
|
|
// set it on the sound and keep in the sound map
|
|
|
|
// set it on the sound and keep in the sound map
|
|
|
|
auto sound = make_shared<sf::Sound>(*buffer); |
|
|
|
auto sound = make_shared<sf::Sound>(*buffer); |
|
|
|