-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathTmxReaderSetting.cpp
More file actions
61 lines (53 loc) · 1.08 KB
/
TmxReaderSetting.cpp
File metadata and controls
61 lines (53 loc) · 1.08 KB
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
#include "TmxReaderSetting.h"
#include "wx/stdpaths.h"
#include "wx/string.h"
#include "wx/file.h"
#include "wx/filename.h"
unsigned short TmxReaderSetting::Port = 26543;
namespace
{
wxString GetSettingFilePath()
{
wxString path;
path = wxStandardPaths::Get().GetExecutablePath();
path = wxFileName::FileName(path).GetPath(wxPATH_GET_VOLUME) + wxT("/resource/TmxReadHelper/PortSetting");
return path;
}
}
unsigned short TmxReaderSetting::GetPort()
{
return Port;
}
void TmxReaderSetting::SetPortValue(unsigned short port)
{
Port = port;
}
void TmxReaderSetting::LoadConfing()
{
wxString path = GetSettingFilePath();
if(wxFile::Exists(path))
{
long port = (long)Port;
wxFile file;
file.Open(path);
if(file.IsOpened())
{
wxString txt;
file.ReadAll(&txt);
txt.ToLong(&port);
Port = (unsigned short)port;
}
}
}
void TmxReaderSetting::SaveConfig()
{
wxString path = GetSettingFilePath();
wxString sPort = wxString::Format(wxFormatString(wxT("%u")),Port);
wxFile out;
out.Create(path, true);
if(out.IsOpened())
{
out.Write(sPort);
out.Close();
}
}