#include "StdAfx.h" #include "T2Archive.h" #include "T2FloorInfo.h" #include "T2Mover.h" #include "T2MoverModule.h" #include "T2Name.h" #include "T2People.h" #include "T2PeopleArrayList.h" #include "T2Tenant.h" #include "../T2TowerDoc.h" #include "UT2Utils.h" T2Name::T2Name() { mName.Empty(); mType = 0; mID = 0; mFavorite = false; } T2Name::T2Name(T2Archive& archive) { #pragma var_order(valUChar, valUShort, valInt, str) unsigned short valUShort; unsigned char valUChar; int valInt; char str[4]; archive >> valUShort; mType = valUShort; archive >> mID; archive >> valUChar; mFavorite = (valUChar != 0); archive >> valInt; if (valInt == 2 || valInt == 4) { archive >> valUChar; if ((valInt - 1) != valUChar) { valInt--; str[valInt] = 0; valInt--; str[valInt] = valUChar; while (valInt > 0) { valInt--; archive >> str[valInt]; } char tmp; archive >> tmp; } else { int i; for (i = 0; i < (valInt - 1); i++) archive >> str[i]; str[i] = 0; } mName = str; } else { archive.ReadPStr(mName); } } T2Name::T2Name(CString str, T2Tenant* tenant, BOOL favorite) { mName = str; mType = kTenantNameType; mID = tenant->GetEquipID(); mFavorite = favorite; } T2Name::T2Name(CString str, T2People* people, BOOL favorite) { mName = str; mType = kPeopleNameType; mID = people->mMatterID; mFavorite = favorite; } T2Name::T2Name(CString str, T2Mover* mover, BOOL favorite) { mName = str; mType = kMoverNameType; mID = mover->GetEquipID(); mFavorite = favorite; } T2Name::T2Name(CString str, T2MoverModule* moverModule, BOOL favorite) { mName = str; mType = kMoverModuleNameType; mID = moverModule->GetModuleID(); mFavorite = favorite; } /*virtual*/ T2Name::~T2Name() { } short T2Name::GetName(CString& outName, unsigned int& outID) { if (!mName.IsEmpty()) { outName = mName; outID = mID; } return mType; } void T2Name::SetName(CString name) { mName = name; } void T2Name::MakeFullName(T2TowerDoc* inDoc, CString& outStr) { if (mName != NULL) { switch (GetType()) { case kTenantNameType: if (inDoc && inDoc->GetFloorInfo()) { T2FloorInfo *theFloorInfo = inDoc->GetFloorInfo(); T2Tenant *theTenant = theFloorInfo->GetTenant(GetID()); if (theTenant) { CString str; int theRoomNumber = theTenant->GetRoomNumber(theFloorInfo); UT2Utils::GetRoomNumberString(theRoomNumber, str); str += "\x8D\x86\x8E\xBA"; // "号室" outStr = str + mName; } } break; case kPeopleNameType: if (inDoc && inDoc->GetFloorInfo() && inDoc->mPeopleArrayList) { T2People *thePeople = inDoc->mPeopleArrayList->FindPeople(GetID()); if (thePeople) { T2FloorInfo *theFloorInfo = inDoc->GetFloorInfo(); int theTenantID = (thePeople->GetWorkTenant() > 1) ? thePeople->GetWorkTenant() : (thePeople->GetHomeTenant() > 1) ? thePeople->GetHomeTenant() : 1; CString str; T2Tenant *theTenant = theFloorInfo->GetTenant(theTenantID); if (theTenant) { int theRoomNumber = theTenant->GetRoomNumber(theFloorInfo); UT2Utils::GetRoomNumberString(theRoomNumber, str); str += "\x8D\x86\x8E\xBA"; // "号室" } else { str = "\x83\x65\x83\x69\x83\x93\x83\x67\x82\xC8\x82\xB5"; // "テナントなし" } outStr = str + mName; } } } } } BOOL T2Name::operator==(const CString& str) const { BOOL result = false; if (!mName.IsEmpty()) result = (str.Compare(mName) == 0); return result; } void T2Name::Write(T2Archive& archive) const { archive << (unsigned short) mType; archive << mID; unsigned char valUChar = mFavorite ? 1 : 0; archive << valUChar; int len = strlen(mName) + 1; archive << len; archive.WritePStr(mName); }