summaryrefslogtreecommitdiff
path: root/src/T2DLL/T2Name.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/T2DLL/T2Name.cpp147
1 files changed, 137 insertions, 10 deletions
diff --git a/src/T2DLL/T2Name.cpp b/src/T2DLL/T2Name.cpp
index ab183e3..7cee408 100644
--- a/src/T2DLL/T2Name.cpp
+++ b/src/T2DLL/T2Name.cpp
@@ -1,37 +1,164 @@
+#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&) {
+T2Name::T2Name(T2Archive& archive) {
+ 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, T2Tenant*, int) {
+T2Name::T2Name(CString str, T2Tenant* tenant, BOOL favorite) {
+ mName = str;
+ mType = kTenantNameType;
+ mID = tenant->GetEquipID();
+ mFavorite = favorite;
}
-T2Name::T2Name(CString, T2People*, int) {
+T2Name::T2Name(CString str, T2People* people, BOOL favorite) {
+ mName = str;
+ mType = kPeopleNameType;
+ mID = people->mMatterID;
+ mFavorite = favorite;
}
-T2Name::T2Name(CString, T2Mover*, int) {
+T2Name::T2Name(CString str, T2Mover* mover, BOOL favorite) {
+ mName = str;
+ mType = kMoverNameType;
+ mID = mover->GetEquipID();
+ mFavorite = favorite;
}
-T2Name::T2Name(CString, T2MoverModule*, int) {
+T2Name::T2Name(CString str, T2MoverModule* moverModule, BOOL favorite) {
+ mName = str;
+ mType = kMoverModuleNameType;
+ mID = moverModule->GetModuleID();
+ mFavorite = favorite;
}
/*virtual*/ T2Name::~T2Name() {
}
-short T2Name::GetName(CString&, unsigned int&) {
+short T2Name::GetName(CString& outName, unsigned int& outID) {
+ if (!mName.IsEmpty()) {
+ outName = mName;
+ outID = mID;
+ }
+ return mType;
}
-void T2Name::SetName(CString) {
+void T2Name::SetName(CString name) {
+ mName = name;
}
-void T2Name::MakeFullName(T2TowerDoc*, CString&) {
+void T2Name::MakeFullName(T2TowerDoc* towerDoc, CString& outStr) {
+ if (mName != NULL) {
+ switch (GetType()) {
+ case kTenantNameType:
+ if (towerDoc && towerDoc->towerDoc_vf12C()) {
+ T2FloorInfo *theFloorInfo = towerDoc->towerDoc_vf12C();
+ T2Tenant *theTenant = theFloorInfo->GetTenant(GetID());
+ if (theTenant) {
+ CString str;
+ int roomNumber = theTenant->GetRoomNumber(theFloorInfo);
+ UT2Utils::GetRoomNumberString(roomNumber, str);
+ str += "\x8D\x86\x8E\xBA"; // "号室"
+ outStr = str + mName;
+ }
+ }
+ break;
+
+ case kPeopleNameType:
+ if (towerDoc && towerDoc->towerDoc_vf12C() && towerDoc->mPeopleArrayList) {
+ T2People *thePeople = towerDoc->mPeopleArrayList->FindPeople(GetID());
+ if (thePeople) {
+ T2FloorInfo *theFloorInfo = towerDoc->towerDoc_vf12C();
+ int tenantID = (thePeople->GetWorkTenant() > 1) ? thePeople->GetWorkTenant() : (thePeople->GetHomeTenant() > 1) ? thePeople->GetHomeTenant() : 1;
+
+ CString str;
+ T2Tenant *theTenant = theFloorInfo->GetTenant(tenantID);
+ if (theTenant) {
+ int roomNumber = theTenant->GetRoomNumber(theFloorInfo);
+ UT2Utils::GetRoomNumberString(roomNumber, str);
+ str += "\x8D\x86\x8E\xBA"; // "号室"
+ } else {
+ str = "\x83\x65\x83\x69\x83\x93\x83\x67\x82\xC8\x82\xB5"; // "テナントなし"
+ }
+ outStr = str + mName;
+ }
+ }
+ }
+ }
}
-int T2Name::operator==(const CString&) const {
+BOOL T2Name::operator==(const CString& str) const {
+ BOOL result = false;
+
+ if (!mName.IsEmpty())
+ result = (str.Compare(mName) == 0);
+
+ return result;
}
-void T2Name::Write(T2Archive&) const {
+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);
}