Updated the SFML support stuff to use the Config that can be oriented at a BASE_DIR to find stuff relative to the config file.
This commit is contained in:
parent
4d71f552aa
commit
de0d957c66
6 changed files with 28 additions and 8 deletions
|
@ -14,7 +14,9 @@ namespace textures {
|
|||
Config assets("assets/config.json");
|
||||
|
||||
for(auto& [name, settings] : assets["sprites"].items()) {
|
||||
auto texture = make_shared<sf::Texture>(settings["path"]);
|
||||
auto file_name = settings["path"];
|
||||
auto file_path = Config::path_to(file_name);
|
||||
auto texture = make_shared<sf::Texture>(file_path);
|
||||
|
||||
texture->setSmooth(assets["graphics"]["smooth_textures"]);
|
||||
auto sprite = make_shared<sf::Sprite>(*texture);
|
||||
|
@ -51,7 +53,8 @@ namespace textures {
|
|||
|
||||
sf::Image load_image(const std::string& filename) {
|
||||
sf::Image texture;
|
||||
bool good = texture.loadFromFile(filename);
|
||||
auto file_path = Config::path_to(filename);
|
||||
bool good = texture.loadFromFile(file_path);
|
||||
assert(good && "failed to load image file");
|
||||
return texture;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue