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
|
#include "T2PluginLoader.h"
#include "T2PluginSpecifier.h"
#include "T2SysInfoDlg.h"
#include "T2TowerDoc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
T2SysInfoDlg::T2SysInfoDlg(CWnd *pParentWnd)
: CDialog(159, pParentWnd)
{
}
/*virtual*/ void T2SysInfoDlg::DoDataExchange(CDataExchange *pDX) {
CWnd::DoDataExchange(pDX);
DDX_Control(pDX, 1009, mUsedMemory);
DDX_Control(pDX, 1008, mFreeMemory);
DDX_Control(pDX, 1007, mPluginList);
}
BEGIN_MESSAGE_MAP(T2SysInfoDlg, CDialog)
ON_NOTIFY(LVN_COLUMNCLICK, 1007, OnColumnClick)
END_MESSAGE_MAP()
void T2SysInfoDlg::SetDocument(T2TowerDoc *inDoc) {
mDocument = inDoc;
}
BOOL T2SysInfoDlg::OnInitDialog() {
CDialog::OnInitDialog();
MEMORYSTATUS theGlobalMemStats;
theGlobalMemStats.dwLength = sizeof(theGlobalMemStats);
GlobalMemoryStatus(&theGlobalMemStats);
CString str;
str.Format("%d", theGlobalMemStats.dwAvailPageFile >> 10);
mFreeMemory.SetWindowText(str);
str.Format("%d", (theGlobalMemStats.dwTotalVirtual - theGlobalMemStats.dwAvailVirtual) >> 10);
mUsedMemory.SetWindowText(str);
RECT rect;
mPluginList.GetClientRect(&rect);
int width = rect.right;
mPluginList.InsertColumn(0, "Name", LVCFMT_LEFT, (width * 6) / 20);
mPluginList.InsertColumn(1, "Type", LVCFMT_LEFT, (width * 3) / 20);
mPluginList.InsertColumn(2, "Lv", LVCFMT_LEFT, width / 20);
mPluginList.InsertColumn(3, "Stat", LVCFMT_LEFT, (width * 3) / 20);
mPluginList.InsertColumn(4, "File", LVCFMT_LEFT, width);
POSITION pos;
T2PluginSpecifier *specifier;
mDocument->mT2PluginLoader->SetTypeFilter(pos, 0);
while ((specifier = mDocument->mT2PluginLoader->GetNext(pos))) {
int index = mPluginList.InsertItem(0, specifier->mPluginName);
CString text;
text = (char) ((specifier->mType >> 24) & 0xFF);
text += (char) ((specifier->mType >> 16) & 0xFF);
text += (char) ((specifier->mType >> 8) & 0xFF);
text += (char) (specifier->mType & 0xFF);
mPluginList.SetItemText(index, 1, text);
text.Format("%d", specifier->mGameLevel);
mPluginList.SetItemText(index, 2, text);
CString stat;
if (specifier->mIsLoaded)
stat = "Loaded";
mPluginList.SetItemText(index, 3, stat);
mPluginList.SetItemText(index, 4, specifier->mPath);
mPluginList.SetItemData(index, (DWORD) specifier);
}
return true;
}
int CALLBACK doCompare(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) {
T2PluginSpecifier *specifierL = (T2PluginSpecifier *) lParam1;
T2PluginSpecifier *specifierR = (T2PluginSpecifier *) lParam2;
int compare = 0;
if (lParamSort == 0)
compare = strcmp(specifierL->mPluginName, specifierR->mPluginName);
else if (lParamSort == 1)
compare = specifierL->mType - specifierR->mType;
else if (lParamSort == 2)
compare = specifierR->mIsLoaded - specifierL->mIsLoaded;
else if (lParamSort == 3)
compare = strcmp(specifierL->mPath, specifierR->mPath);
return compare;
}
void T2SysInfoDlg::OnColumnClick(NMHDR *pHdr, LRESULT *pResult) {
NMLISTVIEW *pnmv = (NMLISTVIEW *) pHdr;
mPluginList.SortItems(doCompare, pnmv->iSubItem);
*pResult = 0;
}
|