2022-02-07 22:37:08 +00:00
|
|
|
#include "resources.hpp"
|
|
|
|
|
|
|
|
#include <components/vfs/manager.hpp>
|
2022-02-21 14:57:40 +00:00
|
|
|
#include <components/misc/stringops.hpp>
|
2022-02-07 22:37:08 +00:00
|
|
|
|
|
|
|
namespace LuaUi
|
|
|
|
{
|
|
|
|
std::shared_ptr<TextureResource> ResourceManager::registerTexture(TextureData data)
|
|
|
|
{
|
2022-02-26 11:10:55 +00:00
|
|
|
std::string normalizedPath = mVfs->normalizeFilename(data.mPath);
|
|
|
|
if (!mVfs->exists(normalizedPath))
|
2022-02-07 22:37:08 +00:00
|
|
|
{
|
2022-02-21 14:57:40 +00:00
|
|
|
auto error = Misc::StringUtils::format("Texture with path \"%s\" doesn't exist", data.mPath);
|
2022-02-07 22:37:08 +00:00
|
|
|
throw std::logic_error(error);
|
|
|
|
}
|
|
|
|
data.mPath = normalizedPath;
|
|
|
|
|
|
|
|
TextureResources& list = mTextures[normalizedPath];
|
|
|
|
list.push_back(std::make_shared<TextureResource>(data));
|
|
|
|
return list.back();
|
|
|
|
}
|
2022-02-26 11:10:55 +00:00
|
|
|
|
|
|
|
void ResourceManager::clear()
|
|
|
|
{
|
|
|
|
mTextures.clear();
|
|
|
|
}
|
2022-02-07 22:37:08 +00:00
|
|
|
}
|