mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-27 03:40:24 +00:00
Use VFS::Path::Normalized for fx::Technique file path
This commit is contained in:
parent
ffbeb5ab98
commit
cc35df9409
2 changed files with 22 additions and 14 deletions
|
@ -37,11 +37,22 @@ namespace
|
||||||
|
|
||||||
namespace fx
|
namespace fx
|
||||||
{
|
{
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
VFS::Path::Normalized makeFilePath(std::string_view name)
|
||||||
|
{
|
||||||
|
std::string fileName(name);
|
||||||
|
fileName += Technique::sExt;
|
||||||
|
VFS::Path::Normalized result(Technique::sSubdir);
|
||||||
|
result /= fileName;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Technique::Technique(const VFS::Manager& vfs, Resource::ImageManager& imageManager, std::string name, int width,
|
Technique::Technique(const VFS::Manager& vfs, Resource::ImageManager& imageManager, std::string name, int width,
|
||||||
int height, bool ubo, bool supportsNormals)
|
int height, bool ubo, bool supportsNormals)
|
||||||
: mName(std::move(name))
|
: mName(std::move(name))
|
||||||
, mFileName(Files::pathToUnicodeString(
|
, mFilePath(makeFilePath(mName))
|
||||||
(Files::pathFromUnicodeString(Technique::sSubdir) / (mName + Technique::sExt))))
|
|
||||||
, mLastModificationTime(std::filesystem::file_time_type::clock::now())
|
, mLastModificationTime(std::filesystem::file_time_type::clock::now())
|
||||||
, mWidth(width)
|
, mWidth(width)
|
||||||
, mHeight(height)
|
, mHeight(height)
|
||||||
|
@ -98,9 +109,9 @@ namespace fx
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
|
|
||||||
if (!mVFS.exists(mFileName))
|
if (!mVFS.exists(mFilePath))
|
||||||
{
|
{
|
||||||
Log(Debug::Error) << "Could not load technique, file does not exist '" << mFileName << "'";
|
Log(Debug::Error) << "Could not load technique, file does not exist '" << mFilePath << "'";
|
||||||
|
|
||||||
mStatus = Status::File_Not_exists;
|
mStatus = Status::File_Not_exists;
|
||||||
return false;
|
return false;
|
||||||
|
@ -167,7 +178,7 @@ namespace fx
|
||||||
mStatus = Status::Parse_Error;
|
mStatus = Status::Parse_Error;
|
||||||
|
|
||||||
mLastError = "Failed parsing technique '" + getName() + "' " + e.what();
|
mLastError = "Failed parsing technique '" + getName() + "' " + e.what();
|
||||||
;
|
|
||||||
Log(Debug::Error) << mLastError;
|
Log(Debug::Error) << mLastError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,11 +190,6 @@ namespace fx
|
||||||
return mName;
|
return mName;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Technique::getFileName() const
|
|
||||||
{
|
|
||||||
return mFileName;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Technique::setLastModificationTime(std::filesystem::file_time_type timeStamp)
|
bool Technique::setLastModificationTime(std::filesystem::file_time_type timeStamp)
|
||||||
{
|
{
|
||||||
const bool isDirty = timeStamp != mLastModificationTime;
|
const bool isDirty = timeStamp != mLastModificationTime;
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
#include <osg/StateSet>
|
#include <osg/StateSet>
|
||||||
#include <osg/Texture2D>
|
#include <osg/Texture2D>
|
||||||
|
|
||||||
|
#include <components/vfs/pathutil.hpp>
|
||||||
|
|
||||||
#include "lexer.hpp"
|
#include "lexer.hpp"
|
||||||
#include "pass.hpp"
|
#include "pass.hpp"
|
||||||
#include "types.hpp"
|
#include "types.hpp"
|
||||||
|
@ -103,8 +105,8 @@ namespace fx
|
||||||
using UniformMap = std::vector<std::shared_ptr<Types::UniformBase>>;
|
using UniformMap = std::vector<std::shared_ptr<Types::UniformBase>>;
|
||||||
using RenderTargetMap = std::unordered_map<std::string_view, Types::RenderTarget>;
|
using RenderTargetMap = std::unordered_map<std::string_view, Types::RenderTarget>;
|
||||||
|
|
||||||
inline static std::string sExt = ".omwfx";
|
static constexpr std::string_view sExt = ".omwfx";
|
||||||
inline static std::string sSubdir = "shaders";
|
static constexpr std::string_view sSubdir = "shaders";
|
||||||
|
|
||||||
enum class Status
|
enum class Status
|
||||||
{
|
{
|
||||||
|
@ -128,7 +130,7 @@ namespace fx
|
||||||
|
|
||||||
std::string getName() const;
|
std::string getName() const;
|
||||||
|
|
||||||
std::string getFileName() const;
|
const VFS::Path::Normalized& getFileName() const { return mFilePath; }
|
||||||
|
|
||||||
bool setLastModificationTime(std::filesystem::file_time_type timeStamp);
|
bool setLastModificationTime(std::filesystem::file_time_type timeStamp);
|
||||||
|
|
||||||
|
@ -251,7 +253,7 @@ namespace fx
|
||||||
|
|
||||||
std::string mShared;
|
std::string mShared;
|
||||||
std::string mName;
|
std::string mName;
|
||||||
std::string mFileName;
|
VFS::Path::Normalized mFilePath;
|
||||||
std::string_view mBlockName;
|
std::string_view mBlockName;
|
||||||
std::string_view mAuthor;
|
std::string_view mAuthor;
|
||||||
std::string_view mDescription;
|
std::string_view mDescription;
|
||||||
|
|
Loading…
Reference in a new issue