1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-05 15:55:45 +00:00
OpenMW/components/lua_ui/resources.cpp

28 lines
785 B
C++
Raw Normal View History

#include "resources.hpp"
#include <components/vfs/manager.hpp>
2022-02-21 14:57:40 +00:00
#include <components/misc/stringops.hpp>
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-21 14:57:40 +00:00
auto error = Misc::StringUtils::format("Texture with path \"%s\" doesn't exist", data.mPath);
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();
}
}