summaryrefslogtreecommitdiff
path: root/src/T2SysInfoDlg.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/T2SysInfoDlg.cpp')
-rw-r--r--src/T2SysInfoDlg.cpp107
1 files changed, 107 insertions, 0 deletions
diff --git a/src/T2SysInfoDlg.cpp b/src/T2SysInfoDlg.cpp
index b77a596..04377a6 100644
--- a/src/T2SysInfoDlg.cpp
+++ b/src/T2SysInfoDlg.cpp
@@ -1,2 +1,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;
+}