forked from mblaine/Diamonds
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSettings.cpp
More file actions
39 lines (31 loc) · 830 Bytes
/
Settings.cpp
File metadata and controls
39 lines (31 loc) · 830 Bytes
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
#include "Settings.h"
#include <wx/fileconf.h>
#include <wx/filefn.h>
#include <wx/wfstream.h>
Settings::Settings(const char* filename)
{
this->filename = filename;
//defaults
soundon = true;
levelset = wxT("Diamonds.txt");
if(wxFileExists(this->filename))
{
wxFileInputStream infile(this->filename);
settings = new wxFileConfig(infile);
settings->Read(wxT("soundon"), &soundon);
settings->Read(wxT("levelset"), &levelset);
}
else
{
settings = new wxFileConfig();
}
}
Settings::~Settings()
{
settings->Write(wxT("soundon"), soundon);
settings->Write(wxT("levelset"), levelset);
wxFileOutputStream outfile(filename);
if(outfile.IsOk())
settings->Save(outfile);
delete settings;
}