From 0010195ed52eb3f79d694391254a082f0b99725f Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 11 May 2017 19:59:36 +0300 Subject: Allow from screenshot command set screenshot file name without path. Before was only prefix. --- src/game.cpp | 46 +++++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/game.cpp b/src/game.cpp index cf43d4ea4..929d828d9 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -552,32 +552,40 @@ bool Game::saveScreenshot(SDL_Surface *const screenshot, const std::string serverName = settings.serverName; std::string screenShortStr; - if (serverName.empty()) + if (prefix.empty()) { - screenShortStr = strprintf("%s%s_Screenshot_%s_", - prefix.c_str(), - branding.getValue("appName", "ManaPlus").c_str(), - buffer); + if (serverName.empty()) + { + screenShortStr = strprintf("%s_Screenshot_%s_", + branding.getValue("appName", "ManaPlus").c_str(), + buffer); + } + else + { + screenShortStr = strprintf("%s_Screenshot_%s_%s_", + branding.getValue("appName", "ManaPlus").c_str(), + serverName.c_str(), buffer); + } + + do + { + screenshotCount++; + filename.str(""); + filename << screenshotDirectory << "/"; + filename << screenShortStr << screenshotCount << ".png"; + testExists.open(filename.str().c_str(), std::ios::in); + found = !testExists.is_open(); + testExists.close(); + } + while (!found); } else { - screenShortStr = strprintf("%s%s_Screenshot_%s_%s_", - prefix.c_str(), - branding.getValue("appName", "ManaPlus").c_str(), - serverName.c_str(), buffer); - } - - do - { - screenshotCount++; + screenShortStr = prefix; filename.str(""); filename << screenshotDirectory << "/"; - filename << screenShortStr << screenshotCount << ".png"; - testExists.open(filename.str().c_str(), std::ios::in); - found = !testExists.is_open(); - testExists.close(); + filename << screenShortStr; } - while (!found); const std::string fileNameStr = filename.str(); const bool success = ImageWriter::writePNG(screenshot, fileNameStr); -- cgit v1.2.3-60-g2f50