summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-05-11 19:59:36 +0300
committerAndrei Karas <akaras@inbox.ru>2017-05-11 20:07:49 +0300
commit0010195ed52eb3f79d694391254a082f0b99725f (patch)
tree9aa4ac43a12e0500395f7cb4d42b00171aac56cf /src
parent1acf25d5d11780010164a092f529beca423fe45b (diff)
downloadplus-0010195ed52eb3f79d694391254a082f0b99725f.tar.gz
plus-0010195ed52eb3f79d694391254a082f0b99725f.tar.bz2
plus-0010195ed52eb3f79d694391254a082f0b99725f.tar.xz
plus-0010195ed52eb3f79d694391254a082f0b99725f.zip
Allow from screenshot command set screenshot file name without path.
Before was only prefix.
Diffstat (limited to 'src')
-rw-r--r--src/game.cpp46
1 files changed, 27 insertions, 19 deletions
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);