#include "CTokenizer.h" #include "GlobalFunc.h" #include "T2DlgItemPPLEvalGage.h" #include "T2DlgItemStressGage.h" #include "T2FloorInfo.h" #include "T2Name.h" #include "T2NameList.h" #include "T2People.h" #include "T2PeopleInfoDialog.h" #include "T2SilhouettePane.h" #include "T2TemplatePluginList.h" #include "T2Tenant.h" #include "T2TenantDef.h" #include "T2ToolDef.h" #include "T2TowerDoc.h" #include "T2WorldDef.h" #include "UT2Utils.h" T2PeopleInfoDialog::T2PeopleInfoDialog(T2People* people) : T2InfoDialog(people) { mPeople = people; m104 = 0; } /*virtual*/ T2PeopleInfoDialog::~T2PeopleInfoDialog() { } /*virtual*/ void T2PeopleInfoDialog::OnT2Create() { T2TowerDoc *theTowerDoc = mTowerDoc; T2WorldDef *theWorldDef = GetCurrentT2TowerDoc()->towerDoc_vf170(); if (mPeople) mPeopleDef = (T2PeopleDef *) mPeople->GetMatterDef(); else return; CString str1; CString str2; T2Name *theName = theTowerDoc->mNameDB->Search(mPeople, false); unsigned int theNameID; if (theName) theName->GetName(m108, theNameID); else mPeople->GetName(m108); T2DlgItem *item1010 = (T2DlgItem *) GetDlgItem(1010); T2DlgItem *item1011 = (T2DlgItem *) GetDlgItem(1011); T2DlgItem *item1012 = (T2DlgItem *) GetDlgItem(1012); // 7090 - favourite button T2DlgItem *item7090 = GetT2DlgItem(7090); item1010->SetDescriptor(m108); item1012->SetDescriptor(m108); T2SilhouettePane *theSilhouettePane = (T2SilhouettePane *) GetDlgItem(2010); theSilhouettePane->SetPeople(mPeople); // 1020 - money T2DlgItem *item1020 = (T2DlgItem *) GetDlgItem(1020); str1.Format("%d", theWorldDef->ExchangeMoney(theWorldDef->GetCashAmount(mPeople->GetEconoType()))); item1020->SetDescriptor(str1); // 1030 - where they're going from T2DlgItem *item1030 = (T2DlgItem *) GetDlgItem(1030); if (mPeople->GetWorkTenant() > 1) { T2Tenant *workTenant = theTowerDoc->mFloorInfo->GetTenant(mPeople->GetWorkTenant()); T2Name *workTenantName = theTowerDoc->mNameDB->Search(workTenant, false); UT2Utils::GetRoomNumberString(workTenant->GetFloorNumber(theTowerDoc->mFloorInfo), str1); UT2Utils::GetRoomNumberString(workTenant->GetRoomNumber(theTowerDoc->mFloorInfo), str2); // "階" + str + "号室\r\n" str1 = str1 + "\x8A\x4B" + str2 + "\x8D\x86\x8E\xBA\r\n"; CString nameStr; unsigned int theNameID; if (workTenantName) workTenantName->GetName(nameStr, theNameID); if (nameStr == "") { T2ToolDef *toolDef = (T2ToolDef *) workTenant->GetEquipDef(); if (toolDef) toolDef->GetName(nameStr, 0); } str1 += nameStr; item1030->SetDescriptor(str1); T2DlgItem *item1010 = (T2DlgItem *) GetDlgItem(1010); if (mPeople->IsVIP()) { item1010->ShowWindow(SW_HIDE); item7090->EnableWindow(false); } else { item1011->ShowWindow(SW_HIDE); item1012->ShowWindow(SW_HIDE); } } else { T2PeopleType *thePeopleType = mPeople->GetPeopleType(); if (thePeopleType) { if (thePeopleType->GetDemandType() == 3) { // "観光客" - tourist str1 = "\x8A\xCF\x8C\xF5\x8B\x71"; } else { // "一般客" - general customer str1 = "\x88\xEA\x94\xCA\x8B\x71"; } } item1030->SetDescriptor(str1); item1010->ShowWindow(SW_HIDE); item7090->EnableWindow(false); } if (mPeople->IsSetDestination()) { str1 = ""; int prevTenantType = mPeople->GetPrevTenantType(); if (prevTenantType == -1) { // "ロビー から\n" - from the lobby str1 = "\x83\x8D\x83\x72\x81\x5B \x82\xA9\x82\xE7\n"; } else { T2TenantDef *prevTenantDef = theTowerDoc->mTenantTemplates->FindTenantDef(prevTenantType); if (prevTenantDef) { str1 = prevTenantDef->mStr48; // " から\n" - from str1 += " \x82\xA9\x82\xE7\n"; } } str1 += GetTenantName(theTowerDoc, mPeople->GetDestination()); // " へ移動中" - moving to str1 += " \x82\xD6\x88\xDA\x93\xAE\x92\x86"; } else { // "なし" - none str1 = "\x82\xC8\x82\xB5"; } // 1040 - where they're going to T2DlgItem *item1040 = (T2DlgItem *) GetDlgItem(1040); item1040->SetDescriptor(str1); T2DlgItemStressGage *stressGage = (T2DlgItemStressGage *) GetDlgItem(110); stressGage->SetPeople(mPeople); T2DlgItemPPLEvalGage *pplEvalGage = (T2DlgItemPPLEvalGage *) GetDlgItem(126); pplEvalGage->SetPeople(mPeople); BOOL hasAnyName = false; T2Name *nonFavName = mTowerDoc->mNameDB->Search(mPeople, false); if (nonFavName) hasAnyName = true; T2Name *favName = mTowerDoc->mNameDB->Search(mPeople, true); if (favName) hasAnyName = true; if (hasAnyName) item7090->EnableWindow(false); if (!mPeople->IsMaru() && !mPeople->IsReggae()) { CString interview; if (mPeople->GetInterviewWords(theTowerDoc, interview)) { ((T2DlgItem *) GetDlgItem(1060))->SetDescriptor(interview); } } } CString T2PeopleInfoDialog::GetTenantName(T2TowerDoc* towerDoc, unsigned int inTenantID) { CString result = ""; unsigned int tenantID = inTenantID; if (tenantID == 1) { // "ロビー" - lobby result = "\x83\x8D\x83\x72\x81\x5B"; } else { CString str; T2Tenant *theTenant = towerDoc->mFloorInfo->GetTenant(tenantID); T2Name *theName = towerDoc->mNameDB->Search(theTenant, false); UT2Utils::GetRoomNumberString(theTenant->GetFloorNumber(towerDoc->mFloorInfo), result); UT2Utils::GetRoomNumberString(theTenant->GetRoomNumber(towerDoc->mFloorInfo), str); // "階" + str + "号室" - floor + ... + room number result = result + "\x8A\x4B" + str + "\x8D\x86\x8E\xBA "; CString nameStr; unsigned int theNameID; if (theName) theName->GetName(nameStr, theNameID); if (nameStr == "") { T2ToolDef *toolDef = (T2ToolDef *) theTenant->GetEquipDef(); if (toolDef) toolDef->GetName(nameStr, 0); } result += nameStr; } return result; } /*virtual*/ void T2PeopleInfoDialog::CreateDlgItem(CTokenizer& tokenizer, T2DialogDef& def) { if (!_stricmp(tokenizer.Current(), "SILH")) { RECT rect; int id = tokenizer.NextInteger(); rect.left = tokenizer.NextInteger(); rect.top = tokenizer.NextInteger(); rect.right = tokenizer.NextInteger(); rect.bottom = tokenizer.NextInteger(); T2SilhouettePane *silhouettePane = new T2SilhouettePane(mTowerDoc, mImageObj, mPalette); silhouettePane->Create("", def.flags, rect, this, id); if (mCurrentFont >= 0) silhouettePane->SetFont(*mFonts[mCurrentFont]); } else if (!_stricmp(tokenizer.Current(), "PPLEV")) { RECT rect; int id = tokenizer.NextInteger(); rect.left = tokenizer.NextInteger(); rect.top = tokenizer.NextInteger(); rect.right = tokenizer.NextInteger(); rect.bottom = tokenizer.NextInteger(); T2DlgItemPPLEvalGage *pplEvalGage = new T2DlgItemPPLEvalGage(mTowerDoc, mImageObj, mPalette); pplEvalGage->Create("", def.flags, rect, this, id); if (mCurrentFont >= 0) pplEvalGage->SetFont(*mFonts[mCurrentFont]); } else { T2Dialog::CreateDlgItem(tokenizer, def); } } /*virtual*/ void T2PeopleInfoDialog::OnT2Destroy() { } /*virtual*/ BOOL T2PeopleInfoDialog::OnT2DialogCommand(UINT cmd, long data) { WORD hi = HIWORD(cmd); WORD lo = LOWORD(cmd); if (lo == 1 && hi == 0) { // nothing } else if (lo == 2 && hi == 0) { // wtf is going on here? compiler uses a different register DestroyWindow(); } else if (lo == 7090 && hi == 0) { m104 = true; GetT2DlgItem(7090)->EnableWindow(false); T2DlgItem *item = (T2DlgItem *) GetDlgItem(1010); CString str; item->GetDescriptor(str); if (str == "") item->SetDescriptor(m108); } return false; } /*virtual*/ BOOL T2PeopleInfoDialog::OnT2EraseBkgnd(CDC* dc) { return true; } /*virtual*/ void T2PeopleInfoDialog::OnT2OK() { CString nameStr; ((T2DlgItem *) GetDlgItem(1010))->GetDescriptor(nameStr); if (nameStr == "") nameStr = m108; if (m108 != nameStr || m104 == 1) { T2Name *nonFavName = mTowerDoc->mNameDB->Search(mPeople, false); if (nonFavName) { nonFavName->SetName(nameStr); } else { T2Name *newName = new T2Name(nameStr, mPeople, false); mTowerDoc->mNameDB->Add(newName); mPeople->SetColor(13); } T2Name *favName = mTowerDoc->mNameDB->Search(mPeople, true); if (favName) { mTowerDoc->towerDoc_vf1C4(mPeople, false); mTowerDoc->towerDoc_vf1B8(mPeople); } } }