aboutsummaryrefslogtreecommitdiffstats
path: root/src/config.cpp
diff options
context:
space:
mode:
authordrumsetmonkey <abelleisle@roadrunner.com>2016-02-02 08:46:58 -0500
committerdrumsetmonkey <abelleisle@roadrunner.com>2016-02-02 08:46:58 -0500
commit783143974e36856e92be3fe1b13cc6a0d0b1faeb (patch)
tree4a6e0b56120874845027e96901c0eb89c106a64d /src/config.cpp
parented970399ee3865ac7c5682d8a81a6a8a2282dd4a (diff)
Better menus and config writing
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