-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGESettings.cpp
77 lines (64 loc) · 1.7 KB
/
GESettings.cpp
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//////////////////////////////////////////////////////////////////
//
// Arturo Cepeda Pérez
// Game Engine
//
// Core
//
// --- GESettings.cpp ---
//
//////////////////////////////////////////////////////////////////
#include "GESettings.h"
#include "GEDevice.h"
#include "Content/GEContentData.h"
using namespace GE;
using namespace GE::Core;
using namespace GE::Content;
Settings::Settings()
: Serializable("Settings")
, mTargetFPS(0u)
, mFullscreen(false)
, mVSync(false)
, mFullscreenSizeX(0u)
, mFullscreenSizeY(0u)
, mWindowSizeX(0u)
, mWindowSizeY(0u)
, mErrorPopUps(false)
, mDumpLogs(false)
{
mLanguage[0] = '\0';
// General
GERegisterProperty(UInt, TargetFPS);
GERegisterProperty(String, Language);
// Video
GERegisterProperty(Bool, Fullscreen);
GERegisterProperty(Bool, VSync);
GERegisterProperty(UInt, FullscreenSizeX);
GERegisterProperty(UInt, FullscreenSizeY);
GERegisterProperty(UInt, WindowSizeX);
GERegisterProperty(UInt, WindowSizeY);
// Development
GERegisterProperty(Bool, ErrorPopUps);
GERegisterProperty(Bool, DumpLogs);
}
Settings::~Settings()
{
}
void Settings::load()
{
const bool userSettingsLoaded = SerializableIO::loadFromXmlFile(this, ".", "settings");
if(!userSettingsLoaded)
{
ContentData settingsData;
Device::readContentFile(ContentType::GenericTextData, ".", "settings", "xml", &settingsData);
pugi::xml_document xml;
xml.load_buffer(settingsData.getData(), settingsData.getDataSize());
pugi::xml_node xmlSettings = xml.child("Settings");
loadFromXml(xmlSettings);
save();
}
}
void Settings::save()
{
SerializableIO::saveToXmlFile(this, ".", "settings");
}