blob: 31ce5784f68be086f20729298c592fbee629657e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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);
}
|