diff --git a/desktop_version/src/FileSystemUtils.cpp b/desktop_version/src/FileSystemUtils.cpp index f23f86d3..5643182d 100644 --- a/desktop_version/src/FileSystemUtils.cpp +++ b/desktop_version/src/FileSystemUtils.cpp @@ -270,6 +270,19 @@ int FILESYSTEM_init(char *argvZero, char* baseDir, char *assetsPath, char* langD mkdir(screenshotDir, 0777); vlog_info("Screenshot directory: %s", screenshotDir); + /* We also need to make the subdirectories */ + { + char temp[MAX_PATH]; + SDL_snprintf(temp, sizeof(temp), "%s%s%s", + screenshotDir, "1x", pathSep + ); + mkdir(temp, 0777); + SDL_snprintf(temp, sizeof(temp), "%s%s%s", + screenshotDir, "2x", pathSep + ); + mkdir(temp, 0777); + } + basePath = SDL_GetBasePath(); if (basePath == NULL) diff --git a/desktop_version/src/GraphicsResources.cpp b/desktop_version/src/GraphicsResources.cpp index be87f821..4410085f 100644 --- a/desktop_version/src/GraphicsResources.cpp +++ b/desktop_version/src/GraphicsResources.cpp @@ -1,5 +1,6 @@ #include "GraphicsResources.h" +#include #include #include "Alloc.h" @@ -516,8 +517,17 @@ bool SaveScreenshot(void) vlog_error("Could not take screenshot"); return false; } - // TODO: Timestamp in filename - success = SaveImage(graphics.tempScreenshot, "screenshots/test.png"); + + const time_t now = time(NULL); + const tm* date = localtime(&now); + + char timestamp[32]; + strftime(timestamp, sizeof(timestamp), "%Y-%m-%d_%H-%M-%S", date); + + char filename[64]; + SDL_snprintf(filename, sizeof(filename), "screenshots/1x/%s_1x.png", timestamp); + + success = SaveImage(graphics.tempScreenshot, filename); if (!success) { return false; @@ -530,12 +540,14 @@ bool SaveScreenshot(void) return false; } - success = SaveImage(graphics.tempScreenshot2x, "screenshots/test2x.png"); + SDL_snprintf(filename, sizeof(filename), "screenshots/2x/%s_2x.png", timestamp); + + success = SaveImage(graphics.tempScreenshot2x, filename); if (!success) { return false; } - vlog_info("Saved screenshot"); + vlog_info("Saved screenshot %s", timestamp); return true; }