From d0aa4879eb857039538d18adf624ec99b47d18fa Mon Sep 17 00:00:00 2001 From: Steve Date: Sat, 23 Apr 2016 08:09:15 +0100 Subject: [PATCH] Allow saving of screenshots by pressing F12. --- src/draw/draw.c | 5 +++++ src/main.c | 11 +++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/draw/draw.c b/src/draw/draw.c index 2ab53f8..324b61b 100644 --- a/src/draw/draw.c +++ b/src/draw/draw.c @@ -214,4 +214,9 @@ void saveScreenshot(void) SDL_RenderReadPixels(app.renderer, NULL, SDL_PIXELFORMAT_ARGB8888, sshot->pixels, sshot->pitch); SDL_SaveBMP(sshot, filename); SDL_FreeSurface(sshot); + + if (!dev.takeScreenshots) + { + printf("Saved '%s'\n", filename); + } } diff --git a/src/main.c b/src/main.c index 30feb82..37b276a 100644 --- a/src/main.c +++ b/src/main.c @@ -46,6 +46,8 @@ int main(int argc, char *argv[]) initGameSystem(); + createScreenshotFolder(); + handleArguments(argc, argv); dev.fps = frames = td = 0; @@ -133,6 +135,13 @@ int main(int argc, char *argv[]) } } + if (app.keyboard[SDL_SCANCODE_F12]) + { + saveScreenshot(); + + app.keyboard[SDL_SCANCODE_F12] = 0; + } + if (SDL_GetTicks() > expireTextTimer) { expireTexts(0); @@ -169,8 +178,6 @@ static void handleArguments(int argc, char *argv[]) { dev.debug = 1; - createScreenshotFolder(); - SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_DEBUG); }