1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-06 00:55:50 +00:00

Use StringUtils::format

This commit is contained in:
uramer 2022-02-21 15:57:40 +01:00
parent e7474490a1
commit a7bb87d8a1
2 changed files with 7 additions and 7 deletions

View File

@ -1,6 +1,7 @@
#include "resources.hpp"
#include <components/vfs/manager.hpp>
#include <components/misc/stringops.hpp>
namespace LuaUi
{
@ -9,9 +10,7 @@ namespace LuaUi
std::string normalizedPath = vfs()->normalizeFilename(data.mPath);
if (!vfs()->exists(normalizedPath))
{
std::string error("Texture with path \"");
error += data.mPath;
error += "\" doesn't exist";
auto error = Misc::StringUtils::format("Texture with path \"%s\" doesn't exist", data.mPath);
throw std::logic_error(error);
}
data.mPath = normalizedPath;

View File

@ -27,14 +27,16 @@ namespace LuaUi
public:
TextureResource(TextureData data)
: mData(data)
{}
{}
const TextureData& data() { return mData; }
private:
TextureData mData;
};
class ResourceManager {
class ResourceManager
{
public:
ResourceManager(const VFS::Manager* vfs)
: mVfs(vfs)
@ -42,10 +44,9 @@ namespace LuaUi
std::shared_ptr<TextureResource> registerTexture(TextureData data);
protected:
private:
const VFS::Manager* vfs() const { return mVfs; }
private:
const VFS::Manager* mVfs;
using TextureResources = std::vector<std::shared_ptr<TextureResource>>;
std::unordered_map<std::string, TextureResources> mTextures;