aboutsummaryrefslogtreecommitdiffstats
path: root/src/config.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/config.cpp')
-rw-r--r--src/config.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/config.cpp b/src/config.cpp
new file mode 100644
index 0000000..31ce578
--- /dev/null
+++ b/src/config.cpp
@@ -0,0 +1,36 @@
+#include <config.h>
+
+using namespace tinyxml2;
+
+extern unsigned int HLINE;
+extern unsigned int SCREEN_WIDTH;
+extern unsigned int SCREEN_HEIGHT;
+extern bool FULLSCREEN;
+
+extern float VOLUME_MASTER;
+extern float VOLUME_MUSIC;
+
+XMLDocument xml;
+
+void readConfig(){
+ XMLElement *scr;
+ XMLElement *vol;
+ xml.LoadFile("config/settings.xml");
+ scr = xml.FirstChildElement("screen");
+ SCREEN_WIDTH = scr->UnsignedAttribute("width");
+ SCREEN_HEIGHT = scr->UnsignedAttribute("height");
+ FULLSCREEN = scr->BoolAttribute("fullscreen");
+ HLINE = xml.FirstChildElement("hline")->UnsignedAttribute("size");
+
+ vol = xml.FirstChildElement("volume");
+ VOLUME_MASTER = vol->FirstChildElement("master")->FloatAttribute("volume");
+ VOLUME_MUSIC = vol->FirstChildElement("music")->FloatAttribute("volume");
+
+}
+
+void updateConfig(){
+ XMLElement *vol = xml.FirstChildElement("volume")->FirstChildElement("master")->ToElement();
+ vol->SetAttribute("volume",VOLUME_MASTER);
+
+ xml.SaveFile("config/settings.xml", false);
+} \ No newline at end of file