#include "StdAfx.h" #include "DbgEventList.h" #include "T2DLL/GlobalFunc.h" #include "T2DLL/LArray.h" #include "T2DLL/T2EventItem.h" #include "T2TowerDoc.h" #include "T2DLL/T2TowerEvent.h" #include "T2DLL/T2WorldDef.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif DbgEventList::DbgEventList(CWnd *pParent) : CDialog(IDD, pParent) { //{{AFX_DATA_INIT(DbgEventList) //}}AFX_DATA_INIT } /*virtual*/ void DbgEventList::DoDataExchange(CDataExchange *pDX) { CWnd::DoDataExchange(pDX); //{{AFX_DATA_MAP(DbgEventList) DDX_Control(pDX, IDC_EVENT_LIST, mList); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(DbgEventList, CDialog) //{{AFX_MSG_MAP(DbgEventList) ON_COMMAND(IDC_EVENT_START, OnEventStart) //}}AFX_MSG_MAP END_MESSAGE_MAP() /*virtual*/ BOOL DbgEventList::OnInitDialog() { CDialog::OnInitDialog(); RECT rect; mList.GetClientRect(&rect); int width = rect.right; mList.InsertColumn(0, "Type", LVCFMT_LEFT, width / 6); mList.InsertColumn(1, "ID", LVCFMT_LEFT, width / 6); mList.InsertColumn(2, "Mode", LVCFMT_LEFT, width / 6); mList.InsertColumn(3, "Status", LVCFMT_LEFT, width / 6); mList.InsertColumn(4, "Start", LVCFMT_LEFT, width / 6); mList.InsertColumn(5, "End", LVCFMT_LEFT, width / 6); mTowerEvent = GetCurrentT2TowerDoc()->GetWorldDef()->GetTowerEvent(); RefreshEvents(); return true; } void DbgEventList::RefreshEvents() { mList.DeleteAllItems(); AddEvents(mTowerEvent->mStandby, "Standby"); AddEvents(mTowerEvent->mWaiting, "Waiting"); AddEvents(mTowerEvent->mRunning, "Running"); } void DbgEventList::AddEvents(LArray &array, const char *mode) { LArrayIterator iterator(array); CString str; T2EventItem *eventItem; while (iterator.Next(&eventItem)) { DWORD id = eventItem->GetID(); str.Format("%c%c%c%c", ((BYTE *) &id)[3], ((BYTE *) &id)[2], ((BYTE *) &id)[1], ((BYTE *) &id)[0]); int index = mList.InsertItem(0, str); str.Format("%d", eventItem->GetSubID()); mList.SetItemText(index, 1, str); str = mode; if (eventItem->mForceStart) str += "!"; mList.SetItemText(index, 2, str); str.Format("%d", eventItem->GetStatus()); mList.SetItemText(index, 3, str); str.Format("%d", eventItem->GetBeginTime()); mList.SetItemText(index, 4, str); str.Format("%d", eventItem->GetEndTime()); mList.SetItemText(index, 5, str); mList.SetItemData(index, (DWORD) eventItem); } } void DbgEventList::OnEventStart() { int numOfItems = mList.GetItemCount(); for (int index = 0; index < numOfItems; index++) { if (mList.GetItemState(index, LVIS_SELECTED)) { T2EventItem *eventItem = (T2EventItem *) mList.GetItemData(index); eventItem->mForceStart = true; } } mTowerEvent->Idle(GetCurrentT2TowerDoc()); RefreshEvents(); }