#include "StdAfx.h" #include "DbgEquipInfo.h" #include "T2DLL/LArray.h" #include "T2DLL/T2CrossEquipArray.h" #include "T2DLL/T2FloorInfo.h" #include "T2DLL/T2Mover.h" #include "T2DLL/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 *pParent) : CDialog(IDD, pParent) { //{{AFX_DATA_INIT(DbgEquipInfo) //}}AFX_DATA_INIT } /*virtual*/ void DbgEquipInfo::DoDataExchange(CDataExchange *pDX) { CWnd::DoDataExchange(pDX); //{{AFX_DATA_MAP(DbgEquipInfo) DDX_Control(pDX, IDC_DEBUG_INFO, mDebugInfoButton); DDX_Control(pDX, IDC_DEBUG_INFO_LIST, mDebugInfoList); DDX_Control(pDX, IDC_EQUIP_NAME, mEquipName); DDX_Control(pDX, IDC_EQUIP_ID, mEquipID); DDX_Control(pDX, IDC_CROSS_EQUIP_LIST, mCrossEquipList); //}}AFX_DATA_MAP } 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) //{{AFX_MSG_MAP(DbgEquipInfo) ON_NOTIFY(NM_CLICK, IDC_CROSS_EQUIP_LIST, OnListClick) //}}AFX_MSG_MAP END_MESSAGE_MAP() /*virtual*/ BOOL DbgEquipInfo::OnInitDialog() { CDialog::OnInitDialog(); CString str; mEquipName.SetWindowText(mEquip->GetEquipDef()->mStr48); str.Format("%d", mEquip->mEquipID); mEquipID.SetWindowText(str); RECT rect; mCrossEquipList.GetClientRect(&rect); int width = rect.right; mCrossEquipList.InsertColumn(0, "ID", LVCFMT_LEFT, width / 3); mCrossEquipList.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); mCrossEquipList.InsertItem(index, str); T2Tenant *tenant = mDocument->mFloorInfo->GetTenant(id); if (tenant) mCrossEquipList.SetItemText(index, 1, tenant->GetEquipDef()->mStr48); else mCrossEquipList.SetItemText(index, 1, "UNKNOWN"); } else if (id >= 1) { str.Format("%d", id); mCrossEquipList.InsertItem(index, str); T2Mover *mover = mDocument->mFloorInfo->GetMover(id); if (mover) mCrossEquipList.SetItemText(index, 1, mover->GetEquipDef()->mStr48); else mCrossEquipList.SetItemText(index, 1, "UNKNOWN"); } index++; } mEquip->GetEquipDef()->DebugInfo(mDebugInfoButton, mDebugInfoList, mEquip); return true; } void DbgEquipInfo::OnListClick(NMHDR *inHdr, LRESULT *outResult) { int item = mCrossEquipList.GetNextItem(-1, LVNI_SELECTED); if (item != -1) mTowerMainView->SendMessage(WM_COMMAND, MAKELONG(10000 + item, 0), 0); *outResult = 0; }