From a281bcaf909de7a5519b88005b8851c3d828b38a Mon Sep 17 00:00:00 2001 From: elsid Date: Mon, 18 Jul 2022 20:44:57 +0200 Subject: [PATCH] Remove redundant Platform::initialize function --- apps/openmw/mwgui/windowmanagerimp.cpp | 5 +++-- components/myguiplatform/myguiplatform.cpp | 19 ++++++------------- components/myguiplatform/myguiplatform.hpp | 6 +++--- 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 717e8375b0..60dd282d1c 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -194,8 +194,9 @@ namespace MWGui , mWindowVisible(true) { mScalingFactor = std::clamp(Settings::Manager::getFloat("scaling factor", "GUI"), 0.5f, 8.f); - mGuiPlatform = new osgMyGUI::Platform(viewer, guiRoot, resourceSystem->getImageManager(), resourceSystem->getVFS(), mScalingFactor); - mGuiPlatform->initialise("mygui", (std::filesystem::path(logpath) / "MyGUI.log").generic_string()); + mGuiPlatform = new osgMyGUI::Platform(viewer, guiRoot, resourceSystem->getImageManager(), + resourceSystem->getVFS(), mScalingFactor, "mygui", + (std::filesystem::path(logpath) / "MyGUI.log").generic_string()); mGui = new MyGUI::Gui; mGui->initialise(""); diff --git a/components/myguiplatform/myguiplatform.cpp b/components/myguiplatform/myguiplatform.cpp index 69c61554c0..05394b4c17 100644 --- a/components/myguiplatform/myguiplatform.cpp +++ b/components/myguiplatform/myguiplatform.cpp @@ -7,24 +7,15 @@ namespace osgMyGUI { -Platform::Platform(osgViewer::Viewer *viewer, osg::Group *guiRoot, Resource::ImageManager *imageManager, - const VFS::Manager* vfs, float uiScalingFactor) - : mLogFacility(nullptr) +Platform::Platform(osgViewer::Viewer *viewer, osg::Group* guiRoot, Resource::ImageManager* imageManager, + const VFS::Manager* vfs, float uiScalingFactor, const std::string& resourcePath, const std::string& logName) + : mLogFacility(logName.empty() ? nullptr : std::make_unique(logName, false)) , mLogManager(std::make_unique()) , mDataManager(std::make_unique(vfs)) , mRenderManager(std::make_unique(viewer, guiRoot, imageManager, uiScalingFactor)) { -} - -Platform::~Platform() {} - -void Platform::initialise(const std::string &resourcePath, const std::string &_logName) -{ - if (!_logName.empty() && !mLogFacility) - { - mLogFacility = std::make_unique(_logName, false); + if (mLogFacility != nullptr) mLogManager->addLogSource(mLogFacility->getSource()); - } mDataManager->setResourcePath(resourcePath); @@ -32,6 +23,8 @@ void Platform::initialise(const std::string &resourcePath, const std::string &_l mDataManager->initialise(); } +Platform::~Platform() = default; + void Platform::shutdown() { mRenderManager->shutdown(); diff --git a/components/myguiplatform/myguiplatform.hpp b/components/myguiplatform/myguiplatform.hpp index b360ca50d0..2428412dc3 100644 --- a/components/myguiplatform/myguiplatform.hpp +++ b/components/myguiplatform/myguiplatform.hpp @@ -33,12 +33,12 @@ namespace osgMyGUI class Platform { public: - Platform(osgViewer::Viewer* viewer, osg::Group* guiRoot, Resource::ImageManager* imageManager, const VFS::Manager* vfs, float uiScalingFactor); + Platform(osgViewer::Viewer* viewer, osg::Group* guiRoot, Resource::ImageManager* imageManager, + const VFS::Manager* vfs, float uiScalingFactor, const std::string& resourcePath, + const std::string& logName = "MyGUI.log"); ~Platform(); - void initialise(const std::string& resourcePath, const std::string& _logName = "MyGUI.log"); - void shutdown(); RenderManager* getRenderManagerPtr();