diff options
author | Stefan Dombrowski <stefan@uni-bonn.de> | 2009-12-09 17:51:17 +0100 |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2009-12-09 18:13:14 +0100 |
commit | e356eb91b4edb860bb567cbcd467a43ef011c86f (patch) | |
tree | 0430d6c0f42b56b801a664cf6413b717b43fa0e7 /src/game.cpp | |
parent | 782b3d32ba1f713750bc4555ab7d28fd808b28e0 (diff) | |
download | mana-e356eb91b4edb860bb567cbcd467a43ef011c86f.tar.gz mana-e356eb91b4edb860bb567cbcd467a43ef011c86f.tar.bz2 mana-e356eb91b4edb860bb567cbcd467a43ef011c86f.tar.xz mana-e356eb91b4edb860bb567cbcd467a43ef011c86f.zip |
Unifying the default folder for screenshots and making it configurable
For all operating systems screenshots are now saved in ~/Desktop.
If this folder does not exist, then the user's home is used.
The players can change this with the new option --screenshot-dir.
This patch is for http://mantis.themanaworld.org/view.php?id=969
Diffstat (limited to 'src/game.cpp')
-rw-r--r-- | src/game.cpp | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/game.cpp b/src/game.cpp index 83dff9d9..a91fdc23 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -85,6 +85,10 @@ #include <guichan/exception.hpp> #include <guichan/focushandler.hpp> +#include "physfs.h" + +#include <sys/stat.h> + #include <fstream> #include <sstream> #include <string> @@ -134,6 +138,8 @@ EffectManager *effectManager = NULL; ChatTab *localChatTab = NULL; +std::string screenshotDir = ""; + /** * Tells the max tick value, * setting it back to zero (and start again). @@ -367,6 +373,20 @@ Game::~Game() SDL_RemoveTimer(mSecondsCounterId); } +void setScreenshotDir(const std::string &dir) +{ + if (dir.empty()) + { + screenshotDir = std::string(PHYSFS_getUserDir()) + "Desktop"; + // If ~/Desktop does not exist, we save screenshots in the user's home. + struct stat statbuf; + if (stat(screenshotDir.c_str(), &statbuf)) + screenshotDir = std::string(PHYSFS_getUserDir()); + } + else + screenshotDir = dir; +} + static bool saveScreenshot() { static unsigned int screenshotCount = 0; @@ -383,12 +403,7 @@ static bool saveScreenshot() screenshotCount++; filenameSuffix.str(""); filename.str(""); -#if (defined __USE_UNIX98 || defined __FreeBSD__) - filename << getHomeDirectory() << "/"; -#elif defined __APPLE__ - filename << PHYSFS_getUserDir(); - filename << "Desktop/"; -#endif + filename << screenshotDir << "/"; filenameSuffix << "Mana_Screenshot_" << screenshotCount << ".png"; filename << filenameSuffix.str(); testExists.open(filename.str().c_str(), std::ios::in); |