diff --git a/backend.cpp b/backend.cpp index 8330a6a..c174ae7 100644 --- a/backend.cpp +++ b/backend.cpp @@ -2,6 +2,7 @@ #include "shaders.hpp" #include "sound.hpp" #include "textures.hpp" +#include "config.hpp" namespace sfml { guecs::SpriteTexture Backend::texture_get(const string& name) { @@ -59,7 +60,7 @@ namespace sfml { theme.BG_COLOR = theme.MID; theme.BORDER_COLOR = theme.LIGHT_DARK; theme.BG_COLOR_DARK = theme.BLACK; - theme.FONT_FILE_NAME = "assets/text.ttf"; + theme.FONT_FILE_NAME = Config::path_to("assets/text.ttf").string(); return theme; } diff --git a/shaders.cpp b/shaders.cpp index 25ae16e..55405b1 100644 --- a/shaders.cpp +++ b/shaders.cpp @@ -1,5 +1,5 @@ -#include "guecs/sfml/shaders.hpp" -#include "guecs/sfml/config.hpp" +#include "shaders.hpp" +#include "config.hpp" #include "dbc.hpp" #include #include @@ -17,9 +17,10 @@ namespace shaders { } bool load_shader(std::string name, nlohmann::json& settings) { - std::string file_name = settings["file_name"]; + auto file_name = settings["file_name"]; + auto file_path = Config::path_to(file_name); auto ptr = std::make_shared(); - bool good = ptr->loadFromFile(file_name, sf::Shader::Type::Fragment); + bool good = ptr->loadFromFile(file_path, sf::Shader::Type::Fragment); if(good) { configure_shader_defaults(ptr); diff --git a/sound.cpp b/sound.cpp index 783b724..5e7ee02 100644 --- a/sound.cpp +++ b/sound.cpp @@ -1,5 +1,5 @@ -#include "guecs/sfml/sound.hpp" -#include "guecs/sfml/config.hpp" +#include "sound.hpp" +#include "config.hpp" #include "dbc.hpp" #include @@ -31,14 +31,14 @@ namespace sound { Config assets("assets/config.json"); for(auto& el : assets["sounds"].items()) { - load(el.key(), el.value()); + load(el.key(), Config::path_to(el.value())); } initialized = true; } } - 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)); + void load(const std::string& name, const std::filesystem::path& sound_path) { + dbc::check(fs::exists(sound_path), fmt::format("sound file {} does not exist", sound_path.string())); // create the buffer and keep in the buffer map auto buffer = make_shared(sound_path); diff --git a/sound.hpp b/sound.hpp index 3dc21cc..80241cf 100644 --- a/sound.hpp +++ b/sound.hpp @@ -16,7 +16,7 @@ namespace sound { }; void init(); - void load(const std::string& name, const std::string& path); + void load(const std::string& name, const std::filesystem::path& path); void play(const std::string& name, bool loop=false); void play_at(const std::string& name, float x, float y, float z); void stop(const std::string& name); diff --git a/textures.cpp b/textures.cpp index 27b46b5..bf6e4b3 100644 --- a/textures.cpp +++ b/textures.cpp @@ -15,7 +15,9 @@ namespace textures { Config assets("assets/config.json"); for(auto& [name, settings] : assets["sprites"].items()) { - auto texture = make_shared(settings["path"]); + auto file_name = settings["path"]; + auto file_path = Config::path_to(file_name); + auto texture = make_shared(file_path); texture->setSmooth(assets["graphics"]["smooth_textures"]); auto sprite = make_shared(*texture); @@ -52,8 +54,9 @@ namespace textures { sf::Image load_image(const std::string& filename) { sf::Image texture; - bool good = texture.loadFromFile(filename); - dbc::check(good, fmt::format("failed to load {}", filename)); + auto file_path = Config::path_to(filename); + bool good = texture.loadFromFile(file_path); + dbc::check(good, fmt::format("failed to load {}", file_path.string())); return texture; } };