From 33ae34f25d189548614cddfebafa12a44054ca83 Mon Sep 17 00:00:00 2001 From: Larry Fenn Date: Wed, 5 Jan 2022 23:39:41 -0500 Subject: [PATCH] Change: Automatic screenshot numbering Invoking the `screenshot` console command with a filename ending in %d will cause it to be numbered automatically. --- src/screenshot.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/screenshot.cpp b/src/screenshot.cpp index 4c66cd30d3..874400add7 100644 --- a/src/screenshot.cpp +++ b/src/screenshot.cpp @@ -701,8 +701,18 @@ static const char *MakeScreenshotName(const char *default_fn, const char *ext, b } } - /* Add extension to screenshot file */ size_t len = strlen(_screenshot_name); + + /* Handle user-specified filenames ending in %d with automatic numbering */ + if (len >= 2) { + if (_screenshot_name[len - 2] == '%' && _screenshot_name[len - 1] == 'd') { + generate = true; + len -= 2; + _screenshot_name[len] = '\0'; + } + } + + /* Add extension to screenshot file */ seprintf(&_screenshot_name[len], lastof(_screenshot_name), ".%s", ext); const char *screenshot_dir = crashlog ? _personal_dir.c_str() : FiosGetScreenshotDir();