From 0741fe5b800278b11e2a34bb878116a38c21eee1 Mon Sep 17 00:00:00 2001 From: p4r4digm Date: Mon, 20 Apr 2020 09:22:50 -0700 Subject: [PATCH] removed path configuration and made screenshots just save in a folder --- apps/openmw/engine.cpp | 2 +- components/files/configurationmanager.cpp | 20 ++++++++++---------- components/files/configurationmanager.hpp | 3 ++- files/settings-default.cfg | 3 --- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 5b0bd491f5..3d609259f0 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -686,7 +686,7 @@ void OMW::Engine::go() #endif mScreenCaptureOperation = new WriteScreenshotToFileOperation( - mCfgMgr.getScreenshotPath(Settings::Manager::getString("screenshot path", "General")).string(), + mCfgMgr.getScreenshotPath().string(), Settings::Manager::getString("screenshot format", "General")); mScreenCaptureHandler = new osgViewer::ScreenCaptureHandler(mScreenCaptureOperation); diff --git a/components/files/configurationmanager.cpp b/components/files/configurationmanager.cpp index 231401c08b..0ba2d15193 100644 --- a/components/files/configurationmanager.cpp +++ b/components/files/configurationmanager.cpp @@ -32,6 +32,14 @@ ConfigurationManager::ConfigurationManager(bool silent) boost::filesystem::create_directories(mFixedPath.getUserDataPath()); mLogPath = mFixedPath.getUserConfigPath(); + + mScreenshotPath = mFixedPath.getUserDataPath() / "screenshots"; + + // probably not necessary but validate the creation of the screenshots directory and fallback to the original behavior if it fails + boost::system::error_code dirErr; + if (!boost::filesystem::create_directories(mScreenshotPath, dirErr) && !boost::filesystem::is_directory(mScreenshotPath)) { + mScreenshotPath = mFixedPath.getUserDataPath(); + } } ConfigurationManager::~ConfigurationManager() @@ -196,17 +204,9 @@ const boost::filesystem::path& ConfigurationManager::getLogPath() const return mLogPath; } -const boost::filesystem::path ConfigurationManager::getScreenshotPath(std::string const& screenshotSettings) const +const boost::filesystem::path& ConfigurationManager::getScreenshotPath() const { - boost::filesystem::path ssPath = screenshotSettings; - if (ssPath.is_relative()) { - ssPath = mFixedPath.getUserDataPath() / ssPath; - } - boost::system::error_code dirErr; - if (!boost::filesystem::create_directories(ssPath, dirErr) && !boost::filesystem::is_directory(ssPath)) { - ssPath = mFixedPath.getUserDataPath(); - } - return ssPath; + return mScreenshotPath; } } /* namespace Cfg */ diff --git a/components/files/configurationmanager.hpp b/components/files/configurationmanager.hpp index 1c6123b846..446abd4dc5 100644 --- a/components/files/configurationmanager.hpp +++ b/components/files/configurationmanager.hpp @@ -41,7 +41,7 @@ struct ConfigurationManager const boost::filesystem::path& getCachePath() const; const boost::filesystem::path& getLogPath() const; - const boost::filesystem::path getScreenshotPath(std::string const& screenshotSetting) const; + const boost::filesystem::path& getScreenshotPath() const; private: typedef Files::FixedPath<> FixedPathType; @@ -58,6 +58,7 @@ struct ConfigurationManager FixedPathType mFixedPath; boost::filesystem::path mLogPath; + boost::filesystem::path mScreenshotPath; TokensMappingContainer mTokensMapping; diff --git a/files/settings-default.cfg b/files/settings-default.cfg index 08a520ca01..06950e50df 100644 --- a/files/settings-default.cfg +++ b/files/settings-default.cfg @@ -284,9 +284,6 @@ anisotropy = 4 # File format for screenshots. (jpg, png, tga, and possibly more). screenshot format = png -# Directory to store screenshots in. Supports relative and absolute paths. Relative paths will be to the user data folder. -screenshot path =./ - # Texture magnification filter type. (nearest or linear). texture mag filter = linear