summaryrefslogtreecommitdiff
path: root/src/client.cpp
diff options
context:
space:
mode:
authorBernd Wachter <bwachter-tmw@lart.info>2010-02-26 01:11:03 +0100
committerBernd Wachter <bwachter-tmw@lart.info>2010-02-26 01:11:03 +0100
commit81c9926450abe3635ffc9c976571415c8c1873ef (patch)
treeb8f43f3e67d6887c2dd5ed04507f873ffa314c8a /src/client.cpp
parent5ff79d2bff559624de5fc23cbba2703fbe5fc936 (diff)
downloadmana-81c9926450abe3635ffc9c976571415c8c1873ef.tar.gz
mana-81c9926450abe3635ffc9c976571415c8c1873ef.tar.bz2
mana-81c9926450abe3635ffc9c976571415c8c1873ef.tar.xz
mana-81c9926450abe3635ffc9c976571415c8c1873ef.zip
Use MYPICTURES on windows, add config parameter for screenshot directory
Under Windows try to place the screenshots in the `My Pictures' directory, and use Desktop as a fallback. On all platforms, add a Suffix to the screenshot directory path to avoid cluttering the Desktop/... Usage of suffix/suffix content/path are configurable. Create the screenshot directory if it does not exist, and fall back to saving screenshots in the users home directory if it could not be created. Reviewed-by: Jared Adams
Diffstat (limited to 'src/client.cpp')
-rw-r--r--src/client.cpp56
1 files changed, 47 insertions, 9 deletions
diff --git a/src/client.cpp b/src/client.cpp
index eca63ce4..cd40615b 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -215,7 +215,6 @@ Client::Client(const Options &options):
}
initHomeDir(options);
- initScreenshotDir(options.screenshotDir);
// Configure logger
logger->setLogFile(localDataDir + std::string("/mana.log"));
@@ -224,6 +223,8 @@ Client::Client(const Options &options):
logger->log("Mana %s", FULL_VERSION);
initConfiguration(options);
+ initScreenshotDir(options.screenshotDir);
+
logger->setLogToStandardOut(config.getValue("logToStandardOut", 0));
// Initialize SDL
@@ -1037,6 +1038,7 @@ void Client::initConfiguration(const Options &options)
"http://updates.themanaworld.org");
config.setValue("updatehost", defaultUpdateHost);
config.setValue("customcursor", true);
+ config.setValue("useScreenshotDirectorySuffix", true);
config.setValue("ChatLogLength", 128);
// Checking if the configuration file exists... otherwise create it with
@@ -1146,16 +1148,52 @@ void Client::initUpdatesDir()
void Client::initScreenshotDir(const std::string &dir)
{
- if (dir.empty())
+ if (!dir.empty())
+ screenshotDir = dir;
+ else
+ {
+ std::string configScreenshotDir =
+ config.getValue("screenshotDirectory", "");
+ if (!configScreenshotDir.empty())
+ screenshotDir = configScreenshotDir;
+ else
+ {
+#ifdef WIN32
+ screenshotDir = getSpecialFolderLocation(CSIDL_MYPICTURES);
+ if (screenshotDir.empty())
+ screenshotDir = getSpecialFolderLocation(CSIDL_DESKTOP);
+#else
+ 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());
+#endif
+ }
+ config.setValue("screenshotDirectory", screenshotDir);
+
+ if (config.getValue("useScreenshotDirectorySuffix", true))
+ {
+ std::string configScreenshotSuffix =
+ config.getValue("screenshotDirectorySuffix",
+ branding.getValue("appShort", "Mana"));
+
+ if (!configScreenshotSuffix.empty())
+ {
+ screenshotDir += "/" + configScreenshotSuffix;
+ config.setValue("screenshotDirectorySuffix",
+ configScreenshotSuffix);
+ }
+ }
+ }
+
+ if (mkdir_r(screenshotDir.c_str()))
{
- 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());
+ logger->log("Directory %s doesn't exist and can't be created! "
+ "Setting screenshot directory to home.",
+ screenshotDir.c_str());
+ screenshotDir = std::string(PHYSFS_getUserDir());
}
- else
- screenshotDir = dir;
}
void Client::accountLogin(LoginData *loginData)