#include "StdAfx.h" #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() { #pragma var_order(item1040, item1012, item7090, favName, item1030, item1010, item1020, item1011, pplEvalGage, theName, str1, nonFavName, theWorldDef, stressGage, hasAnyName, str2, theTowerDoc, theSilhouettePane, theNameID) T2TowerDoc *theTowerDoc = mTowerDoc; T2WorldDef *theWorldDef = GetCurrentT2TowerDoc()->GetWorldDef(); 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) { #pragma var_order(item1010, nameStr, workTenant, workTenantName, theNameID) 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() == kDemandType3) { // "観光客" - 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"; } #pragma var_order(item1040, item1012, item7090, favName, item1030, item1010, item1020, item1011, pplEvalGage, theName, str1, nonFavName, theWorldDef, stressGage, hasAnyName, str2, theTowerDoc, theSilhouettePane, theNameID) // 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(120); 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 resultName = ""; unsigned int tenantID = inTenantID; if (tenantID == 1) { // "ロビー" - lobby resultName = "\x83\x8D\x83\x72\x81\x5B"; } else { CString roomNum; T2Tenant *theTenant = towerDoc->mFloorInfo->GetTenant(tenantID); T2Name *theName = towerDoc->mNameDB->Search(theTenant, false); UT2Utils::GetRoomNumberString(theTenant->GetFloorNumber(towerDoc->mFloorInfo), resultName); UT2Utils::GetRoomNumberString(theTenant->GetRoomNumber(towerDoc->mFloorInfo), roomNum); // "階" + roomNum + "号室" - floor + ... + room number resultName = resultName + "\x8A\x4B" + roomNum + "\x8D\x86\x8E\xBA "; CString nameStr; unsigned int id; if (theName) theName->GetName(nameStr, id); if (nameStr == "") { T2ToolDef *toolDef = (T2ToolDef *) theTenant->GetEquipDef(); if (toolDef) toolDef->GetName(nameStr, 0); } resultName += nameStr; } return resultName; } /*virtual*/ void T2PeopleInfoDialog::CreateDlgItem(CTokenizer& tokenizer, T2DialogDef& def) { if (!_stricmp(tokenizer.Current(), "SILH")) { RECT theItemRect; int theID = tokenizer.NextInteger(); theItemRect.left = tokenizer.NextInteger(); theItemRect.top = tokenizer.NextInteger(); theItemRect.right = tokenizer.NextInteger(); theItemRect.bottom = tokenizer.NextInteger(); T2SilhouettePane *item = new T2SilhouettePane(mTowerDoc, mImageObj, mPalette); item->Create("", def.flags, theItemRect, this, theID); if (mCurrentFont >= 0) item->SetFont(*mFonts[mCurrentFont]); } else if (!_stricmp(tokenizer.Current(), "PPLEV")) { RECT theItemRect; int theID = tokenizer.NextInteger(); theItemRect.left = tokenizer.NextInteger(); theItemRect.top = tokenizer.NextInteger(); theItemRect.right = tokenizer.NextInteger(); theItemRect.bottom = tokenizer.NextInteger(); T2DlgItemPPLEvalGage *item = new T2DlgItemPPLEvalGage(mTowerDoc, mImageObj, mPalette); item->Create("", def.flags, theItemRect, this, theID); if (mCurrentFont >= 0) item->SetFont(*mFonts[mCurrentFont]); } else { T2Dialog::CreateDlgItem(tokenizer, def); } } /*virtual*/ void T2PeopleInfoDialog::OnT2Destroy() { } /*virtual*/ BOOL T2PeopleInfoDialog::OnT2DialogCommand(WPARAM inWParam, LPARAM inLParam) { WORD code = HIWORD(inWParam); WORD id = LOWORD(inWParam); if (id == IDOK && code == 0) { // nothing } else if (id == IDCANCEL && code == 0) { // wtf is going on here? compiler uses a different register DestroyWindow(); } else if (id == 7090 && code == 0) { m104 = true; GetT2DlgItem(7090)->EnableWindow(false); T2DlgItem *item = (T2DlgItem *) GetDlgItem(1010); CString text; item->GetDescriptor(text); if (text == "") 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 *name = mTowerDoc->mNameDB->Search(mPeople, false); if (name) { name->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->RemoveFavoritePeople(mPeople, false); mTowerDoc->AddFavoritePeople(mPeople); } } }