diff options
Diffstat (limited to 'src/DbgEventList.cpp')
-rw-r--r-- | src/DbgEventList.cpp | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/src/DbgEventList.cpp b/src/DbgEventList.cpp index e1548e1..107f33f 100644 --- a/src/DbgEventList.cpp +++ b/src/DbgEventList.cpp @@ -1,2 +1,98 @@ #include "DbgEventList.h" +#include "GlobalFunc.h" +#include "LArray.h" +#include "T2EventItem.h" +#include "T2TowerDoc.h" +#include "T2TowerEvent.h" +#include "T2WorldDef.h" +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +DbgEventList::DbgEventList(CWnd *pParentWnd) + : CDialog(182, pParentWnd) +{ +} + +/*virtual*/ void DbgEventList::DoDataExchange(CDataExchange *pDX) { + CWnd::DoDataExchange(pDX); + DDX_Control(pDX, 1020, mList); +} + +BEGIN_MESSAGE_MAP(DbgEventList, CDialog) + ON_COMMAND(1021, OnEventStart) +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(); +} |