|
|
@ -5,16 +5,20 @@ |
|
|
|
#include "config.hpp" |
|
|
|
#include "config.hpp" |
|
|
|
#include "constants.hpp" |
|
|
|
#include "constants.hpp" |
|
|
|
#include <memory> |
|
|
|
#include <memory> |
|
|
|
|
|
|
|
#include <filesystem> |
|
|
|
|
|
|
|
|
|
|
|
namespace textures { |
|
|
|
namespace textures { |
|
|
|
using std::shared_ptr, std::make_shared, nlohmann::json, std::string; |
|
|
|
using std::shared_ptr, std::make_shared, nlohmann::json, std::string; |
|
|
|
|
|
|
|
namespace fs = std::filesystem; |
|
|
|
|
|
|
|
|
|
|
|
static TextureManager TMGR; |
|
|
|
static TextureManager TMGR; |
|
|
|
static bool initialized = false; |
|
|
|
static bool initialized = false; |
|
|
|
|
|
|
|
|
|
|
|
void load_sprite_textures(SpriteTextureMap &mapping, json &config, bool smooth) { |
|
|
|
void load_sprite_textures(SpriteTextureMap &mapping, json &config, bool smooth) { |
|
|
|
for(auto& [name, settings] : config.items()) { |
|
|
|
for(auto& [name, settings] : config.items()) { |
|
|
|
auto texture = make_shared<sf::Texture>(settings["path"]); |
|
|
|
const string& path = settings["path"]; |
|
|
|
|
|
|
|
dbc::check(fs::exists(path), fmt::format("texture at {} doesn't exist", path)); |
|
|
|
|
|
|
|
auto texture = make_shared<sf::Texture>(path); |
|
|
|
|
|
|
|
|
|
|
|
texture->setSmooth(smooth); |
|
|
|
texture->setSmooth(smooth); |
|
|
|
auto sprite = make_shared<sf::Sprite>(*texture); |
|
|
|
auto sprite = make_shared<sf::Sprite>(*texture); |
|
|
|