summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-05-11 18:58:18 +0300
committerAndrei Karas <akaras@inbox.ru>2017-05-11 19:11:45 +0300
commit85576f6d4fa83a0151ea08e2684f7babdfcfc707 (patch)
treea152a34c6bef6734ac63d251bc638004f11565a7 /src
parent37eac088655e2d4f5cd9e511058eead078bbf497 (diff)
downloadplus-85576f6d4fa83a0151ea08e2684f7babdfcfc707.tar.gz
plus-85576f6d4fa83a0151ea08e2684f7babdfcfc707.tar.bz2
plus-85576f6d4fa83a0151ea08e2684f7babdfcfc707.tar.xz
plus-85576f6d4fa83a0151ea08e2684f7babdfcfc707.zip
Allow set image name prefix in chat command /screenshot.
Diffstat (limited to 'src')
-rw-r--r--src/actions/actions.cpp4
-rw-r--r--src/game.cpp13
-rw-r--r--src/game.h5
-rw-r--r--src/gui/windows/tradewindow.cpp2
4 files changed, 14 insertions, 10 deletions
diff --git a/src/actions/actions.cpp b/src/actions/actions.cpp
index 78ebe6406..8de4f8793 100644
--- a/src/actions/actions.cpp
+++ b/src/actions/actions.cpp
@@ -687,9 +687,9 @@ impHandler0(sit)
return false;
}
-impHandler0(screenshot)
+impHandler(screenshot)
{
- Game::createScreenshot();
+ Game::createScreenshot(event.args);
return true;
}
diff --git a/src/game.cpp b/src/game.cpp
index cf58a1930..cf43d4ea4 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -498,7 +498,7 @@ void Game::addWatermark()
100, 50);
}
-bool Game::createScreenshot()
+bool Game::createScreenshot(const std::string &prefix)
{
if (!mainGraphics || !screenshortHelper)
return false;
@@ -523,10 +523,11 @@ bool Game::createScreenshot()
if (!screenshot)
return false;
- return saveScreenshot(screenshot);
+ return saveScreenshot(screenshot, prefix);
}
-bool Game::saveScreenshot(SDL_Surface *const screenshot)
+bool Game::saveScreenshot(SDL_Surface *const screenshot,
+ const std::string &prefix)
{
std::string screenshotDirectory = settings.screenshotDir;
if (mkdir_r(screenshotDirectory.c_str()) != 0)
@@ -553,13 +554,15 @@ bool Game::saveScreenshot(SDL_Surface *const screenshot)
std::string screenShortStr;
if (serverName.empty())
{
- screenShortStr = strprintf("%s_Screenshot_%s_",
+ screenShortStr = strprintf("%s%s_Screenshot_%s_",
+ prefix.c_str(),
branding.getValue("appName", "ManaPlus").c_str(),
buffer);
}
else
{
- screenShortStr = strprintf("%s_Screenshot_%s_%s_",
+ screenShortStr = strprintf("%s%s_Screenshot_%s_%s_",
+ prefix.c_str(),
branding.getValue("appName", "ManaPlus").c_str(),
serverName.c_str(), buffer);
}
diff --git a/src/game.h b/src/game.h
index b80f9c3ee..50c52736a 100644
--- a/src/game.h
+++ b/src/game.h
@@ -122,11 +122,12 @@ class Game final
static void moveInDirection(const unsigned char direction);
- static bool createScreenshot();
+ static bool createScreenshot(const std::string &prefix);
static void addWatermark();
- static bool saveScreenshot(SDL_Surface *const screenshot);
+ static bool saveScreenshot(SDL_Surface *const screenshot,
+ const std::string &prefix);
void updateHistory(const SDL_Event &event);
diff --git a/src/gui/windows/tradewindow.cpp b/src/gui/windows/tradewindow.cpp
index 982f2dafd..de89eeca3 100644
--- a/src/gui/windows/tradewindow.cpp
+++ b/src/gui/windows/tradewindow.cpp
@@ -308,7 +308,7 @@ void TradeWindow::receivedOk(const bool own)
void TradeWindow::completeTrade()
{
if (config.getBoolValue("tradescreenshot"))
- Game::createScreenshot();
+ Game::createScreenshot(std::string());
setVisible(Visible_false);
reset();
}