#include "DbgEquipInfo.h" #include "LArray.h" #include "T2CrossEquipArray.h" #include "T2EquipDef.h" #include "T2FloorInfo.h" #include "T2Mover.h" #include "T2Tenant.h" #include "T2TowerDoc.h" #include "T2TowerMainView.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif DbgEquipInfo::DbgEquipInfo(CWnd *pParentWnd) : CDialog(160, pParentWnd) { } /*virtual*/ void DbgEquipInfo::DoDataExchange(CDataExchange *pDX) { CWnd::DoDataExchange(pDX); DDX_Control(pDX, 1014, mButton); DDX_Control(pDX, 1013, mList1); DDX_Control(pDX, 1011, mStatic1); DDX_Control(pDX, 1012, mStatic2); DDX_Control(pDX, 1010, mList2); } void DbgEquipInfo::SetEquip(T2Equip *inEquip) { mEquip = inEquip; } void DbgEquipInfo::SetDocument(T2TowerDoc *inDoc) { mDocument = inDoc; } void DbgEquipInfo::SetTowerMainView(T2TowerMainView *inView) { mTowerMainView = inView; } BEGIN_MESSAGE_MAP(DbgEquipInfo, CDialog) ON_NOTIFY(NM_CLICK, 1010, OnListClick) END_MESSAGE_MAP() /*virtual*/ BOOL DbgEquipInfo::OnInitDialog() { CDialog::OnInitDialog(); CString str; mStatic1.SetWindowText(mEquip->GetEquipDef()->mStr48); str.Format("%d", mEquip->mEquipID); mStatic2.SetWindowText(str); RECT rect; mList2.GetClientRect(&rect); int width = rect.right; mList2.InsertColumn(0, "ID", LVCFMT_LEFT, width / 3); mList2.InsertColumn(1, "Type", LVCFMT_LEFT, (width * 2) / 3); LArrayIterator iterator(*mEquip->mCEArray); unsigned int id; int index = 0; while (iterator.Next(&id)) { if (id >= 1000) { str.Format("%d", id); mList2.InsertItem(index, str); T2Tenant *tenant = mDocument->mFloorInfo->GetTenant(id); if (tenant) mList2.SetItemText(index, 1, tenant->GetEquipDef()->mStr48); else mList2.SetItemText(index, 1, "UNKNOWN"); } else if (id >= 1) { str.Format("%d", id); mList2.InsertItem(index, str); T2Mover *mover = mDocument->mFloorInfo->GetMover(id); if (mover) mList2.SetItemText(index, 1, mover->GetEquipDef()->mStr48); else mList2.SetItemText(index, 1, "UNKNOWN"); } index++; } mEquip->GetEquipDef()->DebugInfo(mButton, mList1, mEquip); return true; } void DbgEquipInfo::OnListClick(NMHDR *inHdr, LRESULT *outResult) { int item = mList2.GetNextItem(-1, LVNI_SELECTED); if (item != -1) mTowerMainView->SendMessage(WM_COMMAND, MAKELONG(10000 + item, 0), 0); *outResult = 0; }