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
|
#include "stdafx.h"
CMOption<bool> g_AAAEnabled(MODULENAME, AAAMODULENAME "_enabled", true);
CMOption<bool> g_KSEnabled(MODULENAME, KSMODULENAME "_enabled", true);
CMOption<bool> g_SSEnabled(MODULENAME, SSMODULENAME "_enabled", true);
/////////////////////////////////////////////////////////////////////////////////////////
class CSubPluginsOptionsDlg : public CDlgBase
{
CCtrlCheck m_enableKeepStatus;
CCtrlCheck m_enableStartupStatus;
CCtrlCheck m_enableAdvancedAutoAway;
public:
CSubPluginsOptionsDlg() :
CDlgBase(g_plugin, IDD_OPT_SUBPLUGINS),
m_enableKeepStatus(this, IDC_ENABLE_KEEPSTATUS),
m_enableStartupStatus(this, IDC_ENABLE_STARTUPSTATUS),
m_enableAdvancedAutoAway(this, IDC_ENABLE_ADVANCEDAUTOAWAY)
{
CreateLink(m_enableKeepStatus, g_KSEnabled);
CreateLink(m_enableStartupStatus, g_SSEnabled);
CreateLink(m_enableAdvancedAutoAway, g_AAAEnabled);
}
void OnApply() override
{
bool bEnabled = m_enableKeepStatus.GetState();
if (bEnabled != g_KSEnabled) {
if (bEnabled)
KeepStatusLoad();
else
KeepStatusUnload();
}
bEnabled = m_enableStartupStatus.GetState();
if (bEnabled != g_SSEnabled) {
if (bEnabled)
StartupStatusLoad();
else
StartupStatusUnload();
}
bEnabled = m_enableAdvancedAutoAway.GetState();
if (bEnabled != g_AAAEnabled) {
if (bEnabled)
AdvancedAutoAwayLoad();
else
AdvancedAutoAwayUnload();
}
}
};
int OnCommonOptionsInit(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = { 0 };
odp.hInstance = g_plugin.getInst();
odp.flags = ODPF_BOLDGROUPS | ODPF_UNICODE;
odp.szGroup.w = LPGENW("Status");
odp.szTitle.w = LPGENW("Status manager");
odp.pDialog = new CSubPluginsOptionsDlg();
g_plugin.addOptions(wParam, &odp);
return 0;
}
/////////////////////////////////////////////////////////////////////////////////////////
static bool IsSubPluginEnabled(const char *name)
{
// Check if this plugin was disabled as separate dll
CMStringA dllName(FORMAT, "%s.dll", name);
dllName.MakeLower();
bool res = !db_get_b(0, "PluginDisable", dllName);
db_unset(0, "PluginDisable", dllName);
return res;
}
void InitCommonOptions()
{
// if this options dialog was never filled, apply default options
if (db_get_b(0, MODULENAME, AAAMODULENAME "_enabled", -1) == -1) {
g_AAAEnabled = IsSubPluginEnabled(AAAMODULENAME);
g_KSEnabled = IsSubPluginEnabled(KSMODULENAME);
g_SSEnabled = IsSubPluginEnabled(SSMODULENAME);
}
}
|