Use normalized path in LuaUi::TextureData

This commit is contained in:
elsid 2025-09-07 15:54:57 +02:00
parent a79e121df6
commit bc219b6a1e
No known key found for this signature in database
GPG Key ID: B845CB9FEE18AB40
3 changed files with 5 additions and 6 deletions

View File

@ -231,7 +231,7 @@ namespace MWLua
LuaUi::TextureData data;
sol::object path = LuaUtil::getFieldOrNil(options, "path");
if (path.is<std::string>())
data.mPath = path.as<std::string>();
data.mPath = VFS::Path::Normalized(path.as<std::string>());
if (data.mPath.empty())
throw std::logic_error("Invalid texture path");
sol::object offset = LuaUtil::getFieldOrNil(options, "offset");

View File

@ -6,8 +6,6 @@ namespace LuaUi
{
std::shared_ptr<TextureResource> ResourceManager::registerTexture(TextureData data)
{
VFS::Path::normalizeFilenameInPlace(data.mPath);
TextureResources& list = mTextures[data.mPath];
list.push_back(std::make_shared<TextureResource>(data));
return list.back();

View File

@ -2,12 +2,13 @@
#define OPENMW_LUAUI_RESOURCES
#include <memory>
#include <string>
#include <unordered_map>
#include <vector>
#include <osg/Vec2f>
#include <components/vfs/pathutil.hpp>
namespace VFS
{
class Manager;
@ -17,7 +18,7 @@ namespace LuaUi
{
struct TextureData
{
std::string mPath;
VFS::Path::Normalized mPath;
osg::Vec2f mOffset;
osg::Vec2f mSize;
};
@ -33,7 +34,7 @@ namespace LuaUi
private:
using TextureResources = std::vector<std::shared_ptr<TextureResource>>;
std::unordered_map<std::string, TextureResources> mTextures;
std::unordered_map<VFS::Path::Normalized, TextureResources, VFS::Path::Hash> mTextures;
};
}