summaryrefslogtreecommitdiff
path: root/src/T2DLL/PeopleSearchDlg.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/T2DLL/PeopleSearchDlg.cpp')
-rw-r--r--src/T2DLL/PeopleSearchDlg.cpp102
1 files changed, 102 insertions, 0 deletions
diff --git a/src/T2DLL/PeopleSearchDlg.cpp b/src/T2DLL/PeopleSearchDlg.cpp
new file mode 100644
index 0000000..1e73ef2
--- /dev/null
+++ b/src/T2DLL/PeopleSearchDlg.cpp
@@ -0,0 +1,102 @@
+#include "PeopleSearchDlg.h"
+#include "T2DlgItemListBox.h"
+#include "T2FloorInfo.h"
+#include "T2Name.h"
+#include "T2NameList.h"
+#include "T2People.h"
+#include "T2PeopleArrayList.h"
+#include "T2Tenant.h"
+#include "T2TowerDoc.h"
+#include "T2WorldDef.h"
+#include "UT2Utils.h"
+
+PeopleSearchDlg::PeopleSearchDlg() {
+ mDeleteOnClose = true;
+}
+
+/*virtual*/ PeopleSearchDlg::~PeopleSearchDlg() {
+}
+
+void PeopleSearchDlg::Create(T2TowerDoc *inDoc, HINSTANCE inInstance, CWnd *inParentWnd, const POINT &inPt) {
+ mDocument = inDoc;
+
+ T2DLGTEMPLATE tmpl;
+ tmpl.resID = 7110;
+ tmpl.pt = inPt;
+ tmpl.moduleHandle = inInstance;
+
+ Realize(inParentWnd, &tmpl, inDoc, NULL, inDoc->mWorldDef->GetPalette(), false, inParentWnd, 110, true);
+ ShowWindow(SW_HIDE);
+}
+
+void PeopleSearchDlg::DoFind() {
+ T2DlgItemListBox *theListBox = (T2DlgItemListBox *) GetDlgItem(1000);
+ if (!theListBox)
+ return;
+
+ int curSel = theListBox->GetCurSel();
+ if (curSel == -1)
+ return;
+
+ T2Name *theName = (T2Name *) theListBox->GetItemDataPtr(curSel);
+ mDocument->towerDoc_vf238(theName);
+}
+
+void PeopleSearchDlg::DoDelete() {
+ T2DlgItemListBox *theListBox = (T2DlgItemListBox *) GetDlgItem(1000);
+ if (!theListBox)
+ return;
+
+ int curSel = theListBox->GetCurSel();
+ if (curSel == -1)
+ return;
+
+ T2Name *theName = (T2Name *) theListBox->GetItemDataPtr(curSel);
+ mDocument->mNameDB->RemoveName(theName);
+ theListBox->DeleteString(curSel);
+}
+
+/*virtual*/ void PeopleSearchDlg::OnT2Create() {
+ T2DlgItemListBox *theListBox = (T2DlgItemListBox *) GetDlgItem(1000);
+
+ if (!theListBox)
+ return;
+
+ HFONT theFont = GetFont();
+ if (theFont)
+ theListBox->SetFont(theFont);
+
+ theListBox->ResetContent();
+
+ T2NameList *theNameDB = mDocument->mNameDB;
+ T2Name *theName;
+ LArrayIterator iterator(*theNameDB);
+
+ while (iterator.Next(&theName)) {
+ int type = theName->GetType();
+ if (type == kPeopleNameType) {
+ CString nameStr;
+ unsigned int peopleID;
+ theName->GetName(nameStr, peopleID);
+
+ T2People *thePeople = mDocument->mPeopleArrayList->FindPeople(peopleID);
+ if (thePeople) {
+ CString roomNumberStr;
+ CString str;
+
+ if (thePeople->GetWorkTenant() > 1) {
+ T2Tenant *theTenant = mDocument->mFloorInfo->GetTenant(thePeople->GetWorkTenant());
+ if (theTenant)
+ UT2Utils::GetRoomNumberString(theTenant->GetRoomNumber(mDocument->mFloorInfo), roomNumberStr);
+ }
+
+ roomNumberStr += " ";
+ str = roomNumberStr.Left(7);
+ str += nameStr;
+
+ int theIndex = theListBox->AddString(str);
+ theListBox->SetItemDataPtr(theIndex, theName);
+ }
+ }
+ }
+}