summaryrefslogtreecommitdiff
path: root/src/T2DLL/T2PeopleInfoDialog.cpp
blob: 8356f713cfcfbe07cc5382d6448293f829589a4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
#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);
        }
    }
}