summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/configuration.cpp27
-rw-r--r--src/configuration.h4
-rw-r--r--src/graphicsmanager.cpp1
3 files changed, 30 insertions, 2 deletions
diff --git a/src/configuration.cpp b/src/configuration.cpp
index 3b8aa6a92..a9c4037e9 100644
--- a/src/configuration.cpp
+++ b/src/configuration.cpp
@@ -317,9 +317,10 @@ ConfigurationObject::~ConfigurationObject()
Configuration::Configuration() :
ConfigurationObject(),
- mConfigPath(""),
+ mConfigPath(),
mDefaultsData(nullptr),
- mDirectory("")
+ mDirectory(),
+ mUseResManager(false)
{
#ifdef DEBUG_CONFIG
mLogKeys = false;
@@ -690,6 +691,8 @@ void Configuration::init(const std::string &filename, const bool useResManager)
{
mDefaultsData = nullptr;
XML::Document doc(filename, useResManager);
+ mFilename = filename;
+ mUseResManager = useResManager;
if (useResManager)
{
@@ -721,6 +724,26 @@ void Configuration::init(const std::string &filename, const bool useResManager)
initFromXML(rootNode);
}
+void Configuration::reInit()
+{
+ XML::Document doc(mFilename, mUseResManager);
+ if (!doc.rootNode())
+ {
+ logger->log("Couldn't open configuration file: %s", mFilename.c_str());
+ return;
+ }
+
+ const XmlNodePtr rootNode = doc.rootNode();
+
+ if (!rootNode || !xmlNameEqual(rootNode, "configuration"))
+ {
+ logger->log("Warning: No configuration file (%s)", mFilename.c_str());
+ return;
+ }
+
+ initFromXML(rootNode);
+}
+
void ConfigurationObject::writeToXML(const XmlTextWriterPtr writer)
{
for (Options::const_iterator i = mOptions.begin(), i_end = mOptions.end();
diff --git a/src/configuration.h b/src/configuration.h
index 5a843e468..46ba4165a 100644
--- a/src/configuration.h
+++ b/src/configuration.h
@@ -238,6 +238,8 @@ class Configuration final : public ConfigurationObject
void init(const std::string &filename,
const bool useResManager = false);
+ void reInit();
+
/**
* Set the default values for each keys.
*
@@ -334,6 +336,8 @@ class Configuration final : public ConfigurationObject
DefaultsData *mDefaultsData; /**< Defaults of value
for a given key */
std::string mDirectory;
+ std::string mFilename;
+ bool mUseResManager;
};
extern Configuration branding;
diff --git a/src/graphicsmanager.cpp b/src/graphicsmanager.cpp
index 7b56498dc..8e41f4666 100644
--- a/src/graphicsmanager.cpp
+++ b/src/graphicsmanager.cpp
@@ -168,6 +168,7 @@ bool GraphicsManager::detectGraphics()
config.setValue("opengl", mode);
config.setValue("videoconfigured", true);
+ config.write();
logger->log("detection complete");
return true;