-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProjectCfg.cpp
More file actions
115 lines (98 loc) · 3.46 KB
/
ProjectCfg.cpp
File metadata and controls
115 lines (98 loc) · 3.46 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
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
// ProjectCfg.cpp: implementation of the CProjectCfg class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "APMAlert.h"
#include "ProjectCfg.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CProjectCfg* CProjectCfg::m_Cfg;
//CProjectCfg::CProjectCfg(): CCfg(NULL)
//{
//}
CProjectCfg::CProjectCfg(char* ini) : CCfg(ini)
{
Reset();
}
CProjectCfg::~CProjectCfg()
{
}
void CProjectCfg::Reset()
{
m_IsPlaySound = TRUE;
m_SoundFile = "";
m_MinAPM = 60;
m_IsShowLiveAPM = TRUE;
m_IsShowAllLiveAPM = TRUE;
m_LiveAPM_X = 4;
m_LiveAPM_Y = 2;
m_IsShowLocalClock = TRUE;
m_LocalClock_X = 14;
m_LocalClock_Y = 284;
m_IsShowGameClock = TRUE;
m_GameClock_X = 286;
m_GameClock_Y = 2;
}
bool CProjectCfg::LoadCfg()
{
HKEY openkey;
LONG ret = RegOpenKeyEx(HKEY_CURRENT_USER, "SOFTWARE\\BWProgrammers\\APMAlert\\APM", 0, KEY_QUERY_VALUE, &openkey);
if (ret == ERROR_SUCCESS)
{
m_IsPlaySound = RegReadInt(openkey, "IsPlaySound", 0);
m_SoundFile = RegReadString(openkey, "SoundFile", "");
m_MinAPM = RegReadInt(openkey, "MinAPM", 0);
m_IsShowLiveAPM = RegReadInt(openkey, "IsShowLiveAPM", 1);
m_IsShowAllLiveAPM = RegReadInt(openkey, "IsShowAllLiveAPM", 1);
m_LiveAPM_X = RegReadInt(openkey, "LiveAPM_X", 0);
m_LiveAPM_Y = RegReadInt(openkey, "LiveAPM_Y", 0);
RegCloseKey(openkey);
}
ret = RegOpenKeyEx(HKEY_CURRENT_USER, "SOFTWARE\\BWProgrammers\\APMAlert\\Clock", 0, KEY_QUERY_VALUE, &openkey);
if (ret == ERROR_SUCCESS)
{
m_IsShowLocalClock = RegReadInt(openkey, "IsShowLocalClock", 0);
m_LocalClock_X = RegReadInt(openkey, "LocalClock_X", 0);
m_LocalClock_Y = RegReadInt(openkey, "LocalClock_Y", 0);
m_IsShowGameClock = RegReadInt(openkey, "IsShowGameClock", 0);
m_GameClock_X = RegReadInt(openkey, "GameClock_X", 0);
m_GameClock_Y = RegReadInt(openkey, "GameClock_Y", 0);
RegCloseKey(openkey);
}
return true;
}
bool CProjectCfg::SaveCfg()
{
HKEY openkey;
LONG ret = RegCreateKeyEx(HKEY_CURRENT_USER, "SOFTWARE\\BWProgrammers\\APMAlert\\APM", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &openkey, NULL);
if (ret == ERROR_SUCCESS)
{
RegWriteInt(openkey, "IsPlaySound", m_IsPlaySound);
DWORD dw = GetLastError();
RegWriteString(openkey, "SoundFile", m_SoundFile.c_str(), m_SoundFile.size() + 1);
RegWriteInt(openkey, "MinAPM", m_MinAPM);
RegWriteInt(openkey, "IsShowLiveAPM", m_IsShowLiveAPM);
RegWriteInt(openkey, "IsShowAllLiveAPM", m_IsShowAllLiveAPM);
RegWriteInt(openkey, "LiveAPM_X", m_LiveAPM_X);
RegWriteInt(openkey, "LiveAPM_Y", m_LiveAPM_Y);
RegCloseKey(openkey);
}
ret = RegCreateKeyEx(HKEY_CURRENT_USER, "SOFTWARE\\BWProgrammers\\APMAlert\\Clock", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &openkey, NULL);
if (ret == ERROR_SUCCESS)
{
RegWriteInt(openkey, "IsShowLocalClock", m_IsShowLocalClock);
RegWriteInt(openkey, "LocalClock_X", m_LocalClock_X);
RegWriteInt(openkey, "LocalClock_Y", m_LocalClock_Y);
RegWriteInt(openkey, "IsShowGameClock", m_IsShowGameClock);
RegWriteInt(openkey, "GameClock_X", m_GameClock_X);
RegWriteInt(openkey, "GameClock_Y", m_GameClock_Y);
RegCloseKey(openkey);
}
return true;
}