diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/client/client.cpp | 13 | ||||
-rw-r--r-- | src/defaultsettings.cpp | 2 |
2 files changed, 13 insertions, 2 deletions
diff --git a/src/client/client.cpp b/src/client/client.cpp index c6d28ce80..e15391dde 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -1780,13 +1780,24 @@ void Client::makeScreenshot() char timetstamp_c[64]; strftime(timetstamp_c, sizeof(timetstamp_c), "%Y%m%d_%H%M%S", tm); - std::string filename_base = g_settings->get("screenshot_path") + std::string screenshot_dir; + + if (fs::IsPathAbsolute(g_settings->get("screenshot_path"))) + screenshot_dir = g_settings->get("screenshot_path"); + else + screenshot_dir = porting::path_user + DIR_DELIM + g_settings->get("screenshot_path"); + + std::string filename_base = screenshot_dir + DIR_DELIM + std::string("screenshot_") + std::string(timetstamp_c); std::string filename_ext = "." + g_settings->get("screenshot_format"); std::string filename; + // Create the directory if it doesn't already exist. + // Otherwise, saving the screenshot would fail. + fs::CreateDir(screenshot_dir); + u32 quality = (u32)g_settings->getS32("screenshot_quality"); quality = MYMIN(MYMAX(quality, 0), 100) / 100.0 * 255; diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index 472522bf4..b6b1ce1f2 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -48,7 +48,7 @@ void set_default_settings(Settings *settings) settings->setDefault("pitch_move", "false"); settings->setDefault("fast_move", "false"); settings->setDefault("noclip", "false"); - settings->setDefault("screenshot_path", "."); + settings->setDefault("screenshot_path", "screenshots"); settings->setDefault("screenshot_format", "png"); settings->setDefault("screenshot_quality", "0"); settings->setDefault("client_unload_unused_data_timeout", "600"); |