From 2b54e6216b4b8773d3b7481684540849ac5a5e82 Mon Sep 17 00:00:00 2001 From: p4r4digm Date: Sun, 19 Apr 2020 16:34:00 -0700 Subject: [PATCH] Added setting to change the directory screenshots are stored in --- apps/openmw/engine.cpp | 4 ++-- components/files/configurationmanager.cpp | 13 +++++++++++++ components/files/configurationmanager.hpp | 1 + files/settings-default.cfg | 3 +++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index ec8c1e3059..5b0bd491f5 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -657,7 +657,6 @@ private: }; // Initialise and enter main loop. - void OMW::Engine::go() { assert (!mContentFiles.empty()); @@ -686,7 +685,8 @@ void OMW::Engine::go() mViewer->setUseConfigureAffinity(false); #endif - mScreenCaptureOperation = new WriteScreenshotToFileOperation(mCfgMgr.getUserDataPath().string(), + mScreenCaptureOperation = new WriteScreenshotToFileOperation( + mCfgMgr.getScreenshotPath(Settings::Manager::getString("screenshot path", "General")).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 3bc6e17729..231401c08b 100644 --- a/components/files/configurationmanager.cpp +++ b/components/files/configurationmanager.cpp @@ -196,4 +196,17 @@ const boost::filesystem::path& ConfigurationManager::getLogPath() const return mLogPath; } +const boost::filesystem::path ConfigurationManager::getScreenshotPath(std::string const& screenshotSettings) 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; +} + } /* namespace Cfg */ diff --git a/components/files/configurationmanager.hpp b/components/files/configurationmanager.hpp index df131e6714..1c6123b846 100644 --- a/components/files/configurationmanager.hpp +++ b/components/files/configurationmanager.hpp @@ -41,6 +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; private: typedef Files::FixedPath<> FixedPathType; diff --git a/files/settings-default.cfg b/files/settings-default.cfg index 06950e50df..08a520ca01 100644 --- a/files/settings-default.cfg +++ b/files/settings-default.cfg @@ -284,6 +284,9 @@ 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