|
From: Markus R. <god...@us...> - 2009-11-13 16:10:23
|
Module: performous
Branch: master
Commit: 4a96b171395c8c5aa1004dc412cdfe0b244ef56f
Author: Markus Raab <un...@ma...>
Date: Fri Nov 13 17:09:31 2009 +0100
config path not hardcoded anymore
---
game/configuration.cc | 2 +-
game/fs.cc | 12 ++++++++++++
game/fs.hh | 3 +++
game/main.cc | 2 +-
4 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/game/configuration.cc b/game/configuration.cc
index 19cee2c..26d41b6 100644
--- a/game/configuration.cc
+++ b/game/configuration.cc
@@ -201,7 +201,7 @@ void ConfigItem::update(xmlpp::Element& elem, int mode) {
}
fs::path systemConfFile = "/etc/xdg/performous/config.xml";
-fs::path userConfFile = getHomeDir() / ".config" / "performous" / "config.xml";
+fs::path userConfFile = getConfigDir() / "config.xml";
void writeConfig(bool system) {
xmlpp::Document doc;
diff --git a/game/fs.cc b/game/fs.cc
index e1ace89..090e47e 100644
--- a/game/fs.cc
+++ b/game/fs.cc
@@ -18,6 +18,18 @@ fs::path getHomeDir() {
return dir;
}
+fs::path getConfigDir() {
+ static fs::path dir;
+ static bool initialized = false;
+ if (!initialized) {
+ initialized = true;
+ char const* conf = getenv("XDG_CONFIG_HOME");
+ if (conf) dir = fs::path(conf) / "performous";
+ else dir = getHomeDir() / ".config" / "performous";
+ }
+ return dir;
+}
+
fs::path pathMangle(fs::path const& dir) {
fs::path ret;
for (fs::path::const_iterator it = dir.begin(); it != dir.end(); ++it) {
diff --git a/game/fs.hh b/game/fs.hh
index fd63e86..2756e8d 100644
--- a/game/fs.hh
+++ b/game/fs.hh
@@ -8,6 +8,9 @@ namespace fs = boost::filesystem;
/** Get user's home folder **/
fs::path getHomeDir();
+/** Get the users configuration folder **/
+fs::path getConfigDir();
+
/** Do mangling to convert user-entered path into path suitable for use with stdlib etc. **/
fs::path pathMangle(fs::path const& dir);
diff --git a/game/main.cc b/game/main.cc
index 677d634..dcfa16a 100644
--- a/game/main.cc
+++ b/game/main.cc
@@ -140,7 +140,7 @@ void mainLoop(std::string const& songlist) {
Audio audio;
audioSetup(capture, audio);
Backgrounds backgrounds;
- Database database(getHomeDir() / ".config" / "performous" / "database.xml");
+ Database database(getConfigDir() / "database.xml");
Songs songs(database, songlist);
ScreenManager sm;
Window window(config["graphic/window_width"].i(), config["graphic/window_height"].i(), config["graphic/fullscreen"].b());
|