summaryrefslogtreecommitdiff
path: root/src/T2DLL/TenantSearchDlg.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/T2DLL/TenantSearchDlg.cpp')
-rw-r--r--src/T2DLL/TenantSearchDlg.cpp99
1 files changed, 99 insertions, 0 deletions
diff --git a/src/T2DLL/TenantSearchDlg.cpp b/src/T2DLL/TenantSearchDlg.cpp
new file mode 100644
index 0000000..5ff4c03
--- /dev/null
+++ b/src/T2DLL/TenantSearchDlg.cpp
@@ -0,0 +1,99 @@
+#include "T2DlgItemListBox.h"
+#include "T2FloorInfo.h"
+#include "T2Name.h"
+#include "T2NameList.h"
+#include "T2Tenant.h"
+#include "T2TenantArrayList.h"
+#include "T2TowerDoc.h"
+#include "T2WorldDef.h"
+#include "TenantSearchDlg.h"
+#include "UT2Utils.h"
+
+TenantSearchDlg::TenantSearchDlg() {
+ mDeleteOnClose = true;
+}
+
+/*virtual*/ TenantSearchDlg::~TenantSearchDlg() {
+}
+
+void TenantSearchDlg::Create(T2TowerDoc *inDoc, HINSTANCE inInstance, CWnd *inParentWnd, const POINT &inPt) {
+ mDocument = inDoc;
+
+ T2DLGTEMPLATE tmpl;
+ tmpl.resID = 7120;
+ tmpl.pt = inPt;
+ tmpl.moduleHandle = inInstance;
+
+ Realize(inParentWnd, &tmpl, inDoc, NULL, inDoc->mWorldDef->GetPalette(), false, inParentWnd, 111, true);
+ ShowWindow(SW_HIDE);
+}
+
+void TenantSearchDlg::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 TenantSearchDlg::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 TenantSearchDlg::OnT2Create() {
+ T2DlgItemListBox *theListBox = (T2DlgItemListBox *) GetDlgItem(1000);
+ T2TenantArrayList *theList = mDocument->mFloorInfo->GetTenantArrayList();
+
+ if (!theListBox)
+ return;
+ if (!theList)
+ 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 == kTenantNameType) {
+ CString nameStr;
+ unsigned int tenantID;
+ theName->GetName(nameStr, tenantID);
+
+ CString str;
+ CString roomNumberStr;
+
+ T2Tenant *theTenant = theList->GetTenantByID(tenantID);
+ 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);
+ }
+ }
+}