#include "StdAfx.h" #include "MoverSearchDlg.h" #include "T2DlgItemListBox.h" #include "T2FloorInfo.h" #include "T2Mover.h" #include "T2MoverArrayList.h" #include "T2Name.h" #include "T2NameList.h" #include "../T2TowerDoc.h" #include "T2WorldDef.h" #include "UT2Utils.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif MoverSearchDlg::MoverSearchDlg() { mDeleteOnClose = true; } /*virtual*/ MoverSearchDlg::~MoverSearchDlg() { } void MoverSearchDlg::Create(T2TowerDoc *inDoc, HINSTANCE inInstance, CWnd *inParentWnd, const POINT &inPt) { mDocument = inDoc; T2DLGTEMPLATE tmpl; tmpl.resID = 7130; tmpl.pt = inPt; tmpl.moduleHandle = inInstance; Realize(inParentWnd, &tmpl, inDoc, NULL, inDoc->mWorldDef->GetPalette(), false, inParentWnd, 112, true); ShowWindow(SW_HIDE); } void MoverSearchDlg::DoFind() { T2DlgItemListBox *listBox = (T2DlgItemListBox *) GetDlgItem(1000); int sel = listBox->GetCurSel(); if (sel == -1) return; T2Name *theName = (T2Name *) listBox->GetItemDataPtr(sel); mDocument->DoFind(theName); } void MoverSearchDlg::DoDelete() { T2DlgItemListBox *listBox = (T2DlgItemListBox *) GetDlgItem(1000); int sel = listBox->GetCurSel(); if (sel == -1) return; T2Name *theName = (T2Name *) listBox->GetItemDataPtr(sel); mDocument->mNameDB->RemoveName(theName); listBox->DeleteString(sel); } /*virtual*/ void MoverSearchDlg::OnT2Create() { T2DlgItemListBox *listBox = (T2DlgItemListBox *) GetDlgItem(1000); T2MoverArrayList *theMoverArrayList = mDocument->mFloorInfo->GetMoverArrayList(); if (!listBox) return; if (!theMoverArrayList) return; HFONT theFont = GetFont(); if (theFont) listBox->SetFont(theFont); listBox->ResetContent(); T2NameList *theNameList = mDocument->mNameDB; T2Name *theName; LArrayIterator iter(*theNameList); while (iter.Next(&theName)) { int type = theName->GetType(); if (type == kMoverNameType) { CString name; unsigned int id; theName->GetName(name, id); int index = listBox->AddString(name); listBox->SetItemDataPtr(index, theName); } } }