Slight rework so that config can have a base dir but the program can start in another one.
This commit is contained in:
parent
d1c2352237
commit
3d4ddde96e
8 changed files with 32 additions and 13 deletions
|
@ -28,7 +28,7 @@ namespace sound {
|
|||
|
||||
void init() {
|
||||
if(!initialized) {
|
||||
Config assets("assets/config.json");
|
||||
Config assets("./assets/config.json");
|
||||
|
||||
for(auto& el : assets["sounds"].items()) {
|
||||
load(el.key(), el.value());
|
||||
|
@ -38,10 +38,11 @@ namespace sound {
|
|||
}
|
||||
|
||||
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
|
||||
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
|
||||
auto sound = make_shared<sf::Sound>(*buffer);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue