mirror of
https://github.com/OpenMW/openmw.git
synced 2025-12-24 14:23:11 +00:00
Use vfs paths in MyGUI data manager
This commit is contained in:
parent
6e8b6ef48e
commit
d45f252f69
6 changed files with 33 additions and 24 deletions
|
|
@ -209,8 +209,9 @@ namespace MWGui
|
|||
SDL_GL_GetDrawableSize(window, &dw, &dh);
|
||||
|
||||
mScalingFactor = Settings::gui().mScalingFactor * (dw / w);
|
||||
constexpr VFS::Path::NormalizedView resourcePath("mygui");
|
||||
mGuiPlatform = std::make_unique<MyGUIPlatform::Platform>(viewer, guiRoot, resourceSystem->getImageManager(),
|
||||
resourceSystem->getVFS(), mScalingFactor, "mygui", logpath / "MyGUI.log");
|
||||
resourceSystem->getVFS(), mScalingFactor, resourcePath, logpath / "MyGUI.log");
|
||||
|
||||
mGui = std::make_unique<MyGUI::Gui>();
|
||||
mGui->initialise({});
|
||||
|
|
|
|||
|
|
@ -289,8 +289,9 @@ namespace Gui
|
|||
MyGUI::IntSize bookSize = getBookSize(layersStream.get());
|
||||
float bookScale = MyGUIPlatform::ScalingLayer::getScaleFactor(bookSize);
|
||||
|
||||
const auto oldDataPath = dataManager->getDataPath({});
|
||||
dataManager->setResourcePath("fonts");
|
||||
const VFS::Path::Normalized oldDataPath(dataManager->getResourcePath());
|
||||
constexpr VFS::Path::NormalizedView fonts("fonts");
|
||||
dataManager->setResourcePath(fonts);
|
||||
std::unique_ptr<MyGUI::IDataStream> dataStream(dataManager->getData(fileName));
|
||||
|
||||
MyGUI::xml::Document xmlDocument;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
#include <MyGUI_DataFileStream.h>
|
||||
|
||||
#include <components/files/conversion.hpp>
|
||||
#include <components/vfs/manager.hpp>
|
||||
|
||||
namespace
|
||||
|
|
@ -27,12 +26,17 @@ namespace
|
|||
namespace MyGUIPlatform
|
||||
{
|
||||
|
||||
void DataManager::setResourcePath(const std::filesystem::path& path)
|
||||
void DataManager::setResourcePath(VFS::Path::NormalizedView path)
|
||||
{
|
||||
mResourcePath = path;
|
||||
}
|
||||
|
||||
DataManager::DataManager(const std::string& resourcePath, const VFS::Manager* vfs)
|
||||
VFS::Path::NormalizedView DataManager::getResourcePath() const
|
||||
{
|
||||
return mResourcePath;
|
||||
}
|
||||
|
||||
DataManager::DataManager(VFS::Path::NormalizedView resourcePath, const VFS::Manager* vfs)
|
||||
: mResourcePath(resourcePath)
|
||||
, mVfs(vfs)
|
||||
{
|
||||
|
|
@ -40,7 +44,9 @@ namespace MyGUIPlatform
|
|||
|
||||
MyGUI::IDataStream* DataManager::getData(const std::string& name) const
|
||||
{
|
||||
return new DataStream(mVfs->get(Files::pathToUnicodeString(mResourcePath / name)));
|
||||
VFS::Path::Normalized path(mResourcePath);
|
||||
path /= name;
|
||||
return new DataStream(mVfs->get(path));
|
||||
}
|
||||
|
||||
void DataManager::freeData(MyGUI::IDataStream* data)
|
||||
|
|
@ -50,7 +56,9 @@ namespace MyGUIPlatform
|
|||
|
||||
bool DataManager::isDataExist(const std::string& name) const
|
||||
{
|
||||
return mVfs->exists(Files::pathToUnicodeString(mResourcePath / name));
|
||||
VFS::Path::Normalized path(mResourcePath);
|
||||
path /= name;
|
||||
return mVfs->exists(path);
|
||||
}
|
||||
|
||||
const MyGUI::VectorString& DataManager::getDataListNames(const std::string& /*pattern*/) const
|
||||
|
|
@ -60,15 +68,12 @@ namespace MyGUIPlatform
|
|||
|
||||
std::string DataManager::getDataPath(const std::string& name) const
|
||||
{
|
||||
if (name.empty())
|
||||
{
|
||||
return Files::pathToUnicodeString(mResourcePath);
|
||||
}
|
||||
|
||||
if (!isDataExist(name))
|
||||
VFS::Path::Normalized path(mResourcePath);
|
||||
path /= name;
|
||||
if (!mVfs->exists(path))
|
||||
return {};
|
||||
|
||||
return Files::pathToUnicodeString(mResourcePath / name);
|
||||
return path;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,9 +3,10 @@
|
|||
|
||||
#include <MyGUI_DataManager.h>
|
||||
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
|
||||
#include <components/vfs/pathutil.hpp>
|
||||
|
||||
namespace VFS
|
||||
{
|
||||
class Manager;
|
||||
|
|
@ -17,9 +18,10 @@ namespace MyGUIPlatform
|
|||
class DataManager : public MyGUI::DataManager
|
||||
{
|
||||
public:
|
||||
explicit DataManager(const std::string& path, const VFS::Manager* vfs);
|
||||
explicit DataManager(VFS::Path::NormalizedView path, const VFS::Manager* vfs);
|
||||
|
||||
void setResourcePath(const std::filesystem::path& path);
|
||||
void setResourcePath(VFS::Path::NormalizedView path);
|
||||
VFS::Path::NormalizedView getResourcePath() const;
|
||||
|
||||
/** Get data stream from specified resource name.
|
||||
@param name Resource name (usually file name).
|
||||
|
|
@ -48,7 +50,7 @@ namespace MyGUIPlatform
|
|||
std::string getDataPath(const std::string& name) const override;
|
||||
|
||||
private:
|
||||
std::filesystem::path mResourcePath;
|
||||
VFS::Path::Normalized mResourcePath;
|
||||
|
||||
const VFS::Manager* mVfs;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -4,17 +4,15 @@
|
|||
#include "myguiloglistener.hpp"
|
||||
#include "myguirendermanager.hpp"
|
||||
|
||||
#include "components/files/conversion.hpp"
|
||||
|
||||
namespace MyGUIPlatform
|
||||
{
|
||||
|
||||
Platform::Platform(osgViewer::Viewer* viewer, osg::Group* guiRoot, Resource::ImageManager* imageManager,
|
||||
const VFS::Manager* vfs, float uiScalingFactor, const std::filesystem::path& resourcePath,
|
||||
const VFS::Manager* vfs, float uiScalingFactor, VFS::Path::NormalizedView resourcePath,
|
||||
const std::filesystem::path& logName)
|
||||
: mLogFacility(logName.empty() ? nullptr : std::make_unique<LogFacility>(logName, false))
|
||||
, mLogManager(std::make_unique<MyGUI::LogManager>())
|
||||
, mDataManager(std::make_unique<DataManager>(Files::pathToUnicodeString(resourcePath), vfs))
|
||||
, mDataManager(std::make_unique<DataManager>(resourcePath, vfs))
|
||||
, mRenderManager(std::make_unique<RenderManager>(viewer, guiRoot, imageManager, uiScalingFactor))
|
||||
{
|
||||
if (mLogFacility != nullptr)
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@
|
|||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include <components/vfs/pathutil.hpp>
|
||||
|
||||
namespace osgViewer
|
||||
{
|
||||
class Viewer;
|
||||
|
|
@ -37,7 +39,7 @@ namespace MyGUIPlatform
|
|||
{
|
||||
public:
|
||||
Platform(osgViewer::Viewer* viewer, osg::Group* guiRoot, Resource::ImageManager* imageManager,
|
||||
const VFS::Manager* vfs, float uiScalingFactor, const std::filesystem::path& resourcePath,
|
||||
const VFS::Manager* vfs, float uiScalingFactor, VFS::Path::NormalizedView resourcePath,
|
||||
const std::filesystem::path& logName = "MyGUI.log");
|
||||
|
||||
~Platform();
|
||||
|
|
|
|||
Loading…
Reference in a new issue