-
Notifications
You must be signed in to change notification settings - Fork 0
/
Preferences.cpp
executable file
·136 lines (101 loc) · 3.63 KB
/
Preferences.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#include "Preferences.h"
//////////////////////////////////////////////////////////////////////
CPreferences* g_Prefs;
//////////////////////////////////////////////////////////////////////
bool InitPrefs(void)
{
wchar_t wszSelfPath[MAX_PATH];
GetModuleFileName(hModSelf, wszSelfPath, MAX_PATH);
try {
std::ci_wstring wscSelfPath = wszSelfPath;
wscSelfPath.erase(wscSelfPath.find_last_of(L'\\') + 1);
g_Prefs = new CPreferences;
if(!g_Prefs)
throw "new CPreferences.";
g_Prefs->Init(wscSelfPath);
}
CATCH(L"InitPrefs", return false)
return true;
}
//////////////////////////////////////////////////////////////////////
void UnloadPrefs(void)
{
delete g_Prefs;
}
//////////////////////////////////////////////////////////////////////
CPreferences::CPreferences()
{
bAddServers_ = false;
bHRLODs_ =
bHRAsteroids_ =
bHRGFX_ = false;
bLogChat_ = false;
Ignores_.clear();
dwUniverseChatFont_ =
dwGroupChatFont_ =
dwSystemChatFont_ =
dwPrivateChatFont_ = 0;
bHugeChatWindowLog_ =
bDecOnScreenChatTime_ =
bDecOnScreenChatLines_ =
bDisableOnScreenChat_ = false;
}
//////////////////////////////////////////////////////////////////////
void CPreferences::Init(const std::ci_wstring& wscSelfDir)
{
wscModulePath_ = wscSelfDir;
Ini_.Init((wscModulePath_ + L"EG_client.ini").c_str());
Load();
}
//////////////////////////////////////////////////////////////////////
void CPreferences::Load(void)
{
Ini_.SetSection(L"General");
bAddServers_ = Ini_.GetBool(L"AddServers");
Ini_.SetSection(L"HighRangeView");
bHRLODs_ = Ini_.GetBool(L"HighRangeLODs");
bHRAsteroids_ = Ini_.GetBool(L"HighRangeAsteroids");
bHRGFX_ = Ini_.GetBool(L"HighRangeGFX");
Ini_.SetSection(L"Chat");
bLogChat_ = Ini_.GetBool(L"LogChat");
wscChatLogPath_ = wscModulePath_ + L"EG_chat.log";
LoadIgnores();
dwUniverseChatFont_ = Ini_.GetInt(L"UniverseChatFont");
if(dwUniverseChatFont_ > 0xFF) dwUniverseChatFont_ = 0;
dwGroupChatFont_ = Ini_.GetInt(L"GroupChatFont");
if(dwGroupChatFont_ > 0xFF) dwGroupChatFont_ = 0;
dwSystemChatFont_ = Ini_.GetInt(L"SystemChatFont");
if(dwSystemChatFont_ > 0xFF) dwSystemChatFont_ = 0;
dwPrivateChatFont_ = Ini_.GetInt(L"PrivateChatFont");
if(dwPrivateChatFont_ > 0xFF) dwPrivateChatFont_ = 0;
bHugeChatWindowLog_ = Ini_.GetBool(L"HugeChatWindowLog");
bDecOnScreenChatTime_ = Ini_.GetBool(L"DecOnScreenChatTime");
bDecOnScreenChatLines_ = Ini_.GetBool(L"DecOnScreenChatLines", false);
bDisableOnScreenChat_ = Ini_.GetBool(L"DisableOnScreenChat", false);
wscExceptionLogFilename_ = wscModulePath_ + L"EG_client.log";
}
//////////////////////////////////////////////////////////////////////
void CPreferences::LoadIgnores(void)
{
Ini_.SetSection(L"Chat");
CIgnoreList::size_type stIgnoresCount = Ini_.GetInt(L"IgnoresCount", 32);
Ignores_.clear();
Ignores_.reserve(stIgnoresCount);
for(CIgnoreList::size_type i = 0; i < stIgnoresCount; i++)
{
wchar_t wszOrd[128];
swprintf(wszOrd, L"Ignore%u", i);
std::ci_wstring wscIgnore = Ini_.GetString(wszOrd);
if(wscIgnore.empty())
continue;
std::ci_wstring::size_type stDivider = wscIgnore.find(L' ');
if(stDivider == std::ci_wstring::npos)
continue;
std::ci_wstring wscINick = wscIgnore.substr(0, stDivider);
DWORD dwIFlags = ToUINT(wscIgnore.substr(stDivider+1).c_str());
if((dwIFlags >= 0x4) || wscINick.empty())
continue;
Ignores_.push_back(CIgnoreList::value_type(wscINick, dwIFlags));
}
}
///////////////////////////////////////////////////////////////////////////////////////////