From 9f2b625b1d5832d8e7c51f0cc3e61a2e90effd0c Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 13 Jan 2014 20:46:44 +0300 Subject: allow create screenshot before connecting to game. --- src/game.cpp | 19 +++++++++++-------- src/input/keyboarddata.h | 2 +- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/game.cpp b/src/game.cpp index a2f389626..8d11d222c 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -488,9 +488,12 @@ Game::~Game() bool Game::createScreenshot() { + if (!mainGraphics) + return false; + SDL_Surface *screenshot = nullptr; - if (!config.getBoolValue("showip")) + if (!config.getBoolValue("showip") && gui) { mainGraphics->setSecure(true); mainGraphics->prepareScreenshot(); @@ -512,7 +515,6 @@ bool Game::createScreenshot() bool Game::saveScreenshot(SDL_Surface *const screenshot) { std::string screenshotDirectory = client->getScreenshotDirectory(); - if (mkdir_r(screenshotDirectory.c_str()) != 0) { logger->log("Directory %s doesn't exist and can't be created! " @@ -554,12 +556,14 @@ bool Game::saveScreenshot(SDL_Surface *const screenshot) if (success) { - std::stringstream chatlogentry; - // TRANSLATORS: save file message - chatlogentry << strprintf(_("Screenshot saved as %s"), - filenameSuffix.str().c_str()); if (localChatTab) - localChatTab->chatLog(chatlogentry.str(), BY_SERVER); + { + std::stringstream chatlogentry; + // TRANSLATORS: save file message + std::string str = strprintf(_("Screenshot saved as %s"), + filenameSuffix.str().c_str()); + localChatTab->chatLog(str, BY_SERVER); + } } else { @@ -573,7 +577,6 @@ bool Game::saveScreenshot(SDL_Surface *const screenshot) } MSDL_FreeSurface(screenshot); - return success; } diff --git a/src/input/keyboarddata.h b/src/input/keyboarddata.h index 0de9c871e..da0d22fee 100644 --- a/src/input/keyboarddata.h +++ b/src/input/keyboarddata.h @@ -187,7 +187,7 @@ static const KeyData keyData[Input::KEY_TOTAL] = { Input::GRP_DEFAULT, &ActionManager::screenshot, Input::KEY_NO_VALUE, 50, - COND_GAME | COND_NOTARGET}, + COND_NOTARGET}, {"keyTrade", INPUT_KEYBOARD, SDLK_r, INPUT_UNKNOWN, Input::KEY_NO_VALUE, -- cgit v1.2.3-70-g09d2