diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 4d10b47963..2b9206354a 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -521,6 +521,7 @@ void OMW::Engine::setDataDirs (const Files::PathContainer& dataDirs) { mDataDirs = dataDirs; mDataDirs.insert(mDataDirs.begin(), (mResDir / "vfs")); + mDataDirs.insert(mDataDirs.begin(), (mResDir / "mygui")); mFileCollections = Files::Collections (mDataDirs, !mFSStrict); } @@ -825,7 +826,7 @@ void OMW::Engine::prepareEngine() mWindowManager = std::make_unique(mWindow, mViewer, guiRoot, mResourceSystem.get(), mWorkQueue.get(), mCfgMgr.getLogPath().string() + std::string("/"), myguiResources, mScriptConsoleMode, mTranslationDataStorage, mEncoding, mExportFonts, - Version::getOpenmwVersionDescription(mResDir.string()), mCfgMgr.getUserConfigPath().string(), shadersSupported); + Version::getOpenmwVersionDescription(mResDir.string()), shadersSupported); mEnvironment.setWindowManager(*mWindowManager); mInputManager = std::make_unique(mWindow, mViewer, mScreenCaptureHandler, diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 382f489e20..5141736204 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -129,7 +129,7 @@ namespace MWGui WindowManager::WindowManager( SDL_Window* window, osgViewer::Viewer* viewer, osg::Group* guiRoot, Resource::ResourceSystem* resourceSystem, SceneUtil::WorkQueue* workQueue, const std::string& logpath, const std::string& resourcePath, bool consoleOnlyScripts, Translation::Storage& translationDataStorage, - ToUTF8::FromType encoding, bool exportFonts, const std::string& versionDescription, const std::string& userDataPath, bool useShaders) + ToUTF8::FromType encoding, bool exportFonts, const std::string& versionDescription, bool useShaders) : mOldUpdateMask(0) , mOldCullMask(0) , mStore(nullptr) @@ -205,7 +205,7 @@ namespace MWGui MyGUI::LanguageManager::getInstance().eventRequestTag = MyGUI::newDelegate(this, &WindowManager::onRetrieveTag); // Load fonts - mFontLoader = std::make_unique(encoding, resourceSystem->getVFS(), userDataPath, mScalingFactor); + mFontLoader = std::make_unique(encoding, resourceSystem->getVFS(), mScalingFactor); mFontLoader->loadBitmapFonts(exportFonts); //Register own widgets with MyGUI diff --git a/apps/openmw/mwgui/windowmanagerimp.hpp b/apps/openmw/mwgui/windowmanagerimp.hpp index 2367470223..083ecc6992 100644 --- a/apps/openmw/mwgui/windowmanagerimp.hpp +++ b/apps/openmw/mwgui/windowmanagerimp.hpp @@ -136,7 +136,7 @@ namespace MWGui WindowManager(SDL_Window* window, osgViewer::Viewer* viewer, osg::Group* guiRoot, Resource::ResourceSystem* resourceSystem, SceneUtil::WorkQueue* workQueue, const std::string& logpath, const std::string& cacheDir, bool consoleOnlyScripts, Translation::Storage& translationDataStorage, - ToUTF8::FromType encoding, bool exportFonts, const std::string& versionDescription, const std::string& localPath, bool useShaders); + ToUTF8::FromType encoding, bool exportFonts, const std::string& versionDescription, bool useShaders); virtual ~WindowManager(); /// Set the ESMStore to use for retrieving of GUI-related strings. diff --git a/components/fontloader/fontloader.cpp b/components/fontloader/fontloader.cpp index d7d16f0aa1..fca8346e19 100644 --- a/components/fontloader/fontloader.cpp +++ b/components/fontloader/fontloader.cpp @@ -151,9 +151,8 @@ namespace namespace Gui { - FontLoader::FontLoader(ToUTF8::FromType encoding, const VFS::Manager* vfs, const std::string& userDataPath, float scalingFactor) + FontLoader::FontLoader(ToUTF8::FromType encoding, const VFS::Manager* vfs, float scalingFactor) : mVFS(vfs) - , mUserDataPath(userDataPath) , mFontHeight(std::clamp(Settings::Manager::getInt("font size", "GUI"), 12, 20)) , mScalingFactor(scalingFactor) { @@ -214,15 +213,11 @@ namespace Gui return; } - dataManager->setUseVfs(true); - for (const auto& name : mVFS->getRecursiveDirectoryIterator("Fonts/")) { if (Misc::getFileExtension(name) == "omwfont") MyGUI::ResourceManager::getInstance().load(name); } - - dataManager->setUseVfs(false); } typedef struct diff --git a/components/fontloader/fontloader.hpp b/components/fontloader/fontloader.hpp index 652f9bdf43..eb705fdd4a 100644 --- a/components/fontloader/fontloader.hpp +++ b/components/fontloader/fontloader.hpp @@ -25,7 +25,7 @@ namespace Gui class FontLoader { public: - FontLoader (ToUTF8::FromType encoding, const VFS::Manager* vfs, const std::string& userDataPath, float scalingFactor); + FontLoader (ToUTF8::FromType encoding, const VFS::Manager* vfs, float scalingFactor); ~FontLoader(); /// @param exportToFile export the converted fonts (Images and XML with glyph metrics) to files? @@ -41,7 +41,6 @@ namespace Gui private: ToUTF8::FromType mEncoding; const VFS::Manager* mVFS; - std::string mUserDataPath; int mFontHeight; float mScalingFactor; diff --git a/components/myguiplatform/myguidatamanager.cpp b/components/myguiplatform/myguidatamanager.cpp index d3edb82ae5..c06532a9f4 100644 --- a/components/myguiplatform/myguidatamanager.cpp +++ b/components/myguiplatform/myguidatamanager.cpp @@ -18,34 +18,16 @@ void DataManager::setResourcePath(const std::string &path) mResourcePath = path; } -void DataManager::setUseVfs(bool useVfs) -{ - mUseVfs = useVfs; -} - MyGUI::IDataStream *DataManager::getData(const std::string &name) const { - if (mUseVfs) - { - // Note: MyGUI is supposed to read/free input steam itself, - // so copy data from VFS stream to the string stream and pass it to MyGUI. - Files::IStreamPtr streamPtr = mVfs->get(name); - std::istream* fileStream = streamPtr.get(); - std::unique_ptr dataStream; - dataStream.reset(new std::stringstream); - *dataStream << fileStream->rdbuf(); - return new MyGUI::DataStream(dataStream.release()); - } - - std::string fullpath = getDataPath(name); - auto stream = std::make_unique(); - stream->open(fullpath, std::ios::binary); - if (stream->fail()) - { - Log(Debug::Error) << "DataManager::getData: Failed to open '" << name << "'"; - return nullptr; - } - return new MyGUI::DataFileStream(stream.release()); + // Note: MyGUI is supposed to read/free input steam itself, + // so copy data from VFS stream to the string stream and pass it to MyGUI. + Files::IStreamPtr streamPtr = mVfs->get(name); + std::istream* fileStream = streamPtr.get(); + std::unique_ptr dataStream; + dataStream.reset(new std::stringstream); + *dataStream << fileStream->rdbuf(); + return new MyGUI::DataStream(dataStream.release()); } void DataManager::freeData(MyGUI::IDataStream *data) @@ -55,10 +37,7 @@ void DataManager::freeData(MyGUI::IDataStream *data) bool DataManager::isDataExist(const std::string &name) const { - if (mUseVfs) return mVfs->exists(name); - - std::string fullpath = mResourcePath + "/" + name; - return std::filesystem::exists(fullpath); + return mVfs->exists(name); } void DataManager::setVfs(const VFS::Manager* vfs) @@ -68,26 +47,12 @@ void DataManager::setVfs(const VFS::Manager* vfs) const MyGUI::VectorString &DataManager::getDataListNames(const std::string &pattern) const { - // TODO: pattern matching (unused?) - static MyGUI::VectorString strings; - strings.clear(); - strings.push_back(getDataPath(pattern)); - return strings; + throw std::runtime_error("DataManager::getDataListNames is not implemented - VFS is used"); } const std::string &DataManager::getDataPath(const std::string &name) const { - // FIXME: in theory, we should use the VFS here too, but it does not provide the real path to data files. - // In some cases there is no real path at all (when the requested MyGUI file is in BSA archive, for example). - // Currently it should not matter since we use this virtual function only to setup fonts for profilers. - static std::string result; - result.clear(); - if (!isDataExist(name)) - { - return result; - } - result = mResourcePath + "/" + name; - return result; + throw std::runtime_error("DataManager::getDataPath is not implemented - VFS is used"); } } diff --git a/components/myguiplatform/myguidatamanager.hpp b/components/myguiplatform/myguidatamanager.hpp index a859ce99c1..47203e1634 100644 --- a/components/myguiplatform/myguidatamanager.hpp +++ b/components/myguiplatform/myguidatamanager.hpp @@ -18,8 +18,6 @@ public: void setResourcePath(const std::string& path); - void setUseVfs(bool useVfs); - void setVfs(const VFS::Manager* vfs); /** Get data stream from specified resource name. @@ -52,8 +50,6 @@ private: std::string mResourcePath; const VFS::Manager* mVfs; - - bool mUseVfs{false}; }; }