forked from Mirrorlandia_minetest/minetest
Allow relative directories for screenshot_path
, tweak default path (#9122)
This will likely be more intuitive for users and should play better with sandboxed distributions such as Flatpak. In addition, the screenshot directory will now be created if it doesn't exist already.
This commit is contained in:
parent
661b4a1837
commit
f45ba78a72
@ -903,8 +903,9 @@ fallback_font_shadow_alpha (Fallback font shadow alpha) int 128 0 255
|
|||||||
# This font will be used for certain languages or if the default font is unavailable.
|
# This font will be used for certain languages or if the default font is unavailable.
|
||||||
fallback_font_path (Fallback font path) filepath fonts/DroidSansFallbackFull.ttf
|
fallback_font_path (Fallback font path) filepath fonts/DroidSansFallbackFull.ttf
|
||||||
|
|
||||||
# Path to save screenshots at.
|
# Path to save screenshots at. Can be an absolute or relative path.
|
||||||
screenshot_path (Screenshot folder) path
|
# The folder will be created if it doesn't already exist.
|
||||||
|
screenshot_path (Screenshot folder) path screenshots
|
||||||
|
|
||||||
# Format of screenshots.
|
# Format of screenshots.
|
||||||
screenshot_format (Screenshot format) enum png png,jpg,bmp,pcx,ppm,tga
|
screenshot_format (Screenshot format) enum png png,jpg,bmp,pcx,ppm,tga
|
||||||
|
@ -1780,13 +1780,24 @@ void Client::makeScreenshot()
|
|||||||
char timetstamp_c[64];
|
char timetstamp_c[64];
|
||||||
strftime(timetstamp_c, sizeof(timetstamp_c), "%Y%m%d_%H%M%S", tm);
|
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
|
+ DIR_DELIM
|
||||||
+ std::string("screenshot_")
|
+ std::string("screenshot_")
|
||||||
+ std::string(timetstamp_c);
|
+ std::string(timetstamp_c);
|
||||||
std::string filename_ext = "." + g_settings->get("screenshot_format");
|
std::string filename_ext = "." + g_settings->get("screenshot_format");
|
||||||
std::string filename;
|
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");
|
u32 quality = (u32)g_settings->getS32("screenshot_quality");
|
||||||
quality = MYMIN(MYMAX(quality, 0), 100) / 100.0 * 255;
|
quality = MYMIN(MYMAX(quality, 0), 100) / 100.0 * 255;
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ void set_default_settings(Settings *settings)
|
|||||||
settings->setDefault("pitch_move", "false");
|
settings->setDefault("pitch_move", "false");
|
||||||
settings->setDefault("fast_move", "false");
|
settings->setDefault("fast_move", "false");
|
||||||
settings->setDefault("noclip", "false");
|
settings->setDefault("noclip", "false");
|
||||||
settings->setDefault("screenshot_path", ".");
|
settings->setDefault("screenshot_path", "screenshots");
|
||||||
settings->setDefault("screenshot_format", "png");
|
settings->setDefault("screenshot_format", "png");
|
||||||
settings->setDefault("screenshot_quality", "0");
|
settings->setDefault("screenshot_quality", "0");
|
||||||
settings->setDefault("client_unload_unused_data_timeout", "600");
|
settings->setDefault("client_unload_unused_data_timeout", "600");
|
||||||
|
Loading…
Reference in New Issue
Block a user