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
|
#include "CResFile.h"
#include "T2Archive.h"
#include "T2BitImage.h"
#include "T2Equip.h"
#include "T2EquipDef.h"
#include "T2EquipPlugin.h"
#include "T2ImageObj.h"
#include "T2InfoDialog.h"
#include "T2People.h"
#include "T2PeopleLinkIterator.h"
#include "T2Tenant.h"
#include "T2TowerDoc.h"
#include "T2WordDefArray.h"
#include "T2WorldDef.h"
#include "UT2Coordinate.h"
T2EquipDef::T2EquipDef(DWORD type, T2PluginSpecifier& specifier, CResFile* resFile, T2WorldDef* worldDef, T2EquipPlugin* plugin)
: T2ToolDef(type, specifier, resFile, worldDef, plugin)
{
unsigned long tmp;
*resFile >> mCapacity;
*resFile >> mStress;
*resFile >> tmp;
for (int j = 0; j < mValiationCount; j++) {
*resFile >> m154;
*resFile >> tmp;
*resFile >> tmp;
}
*resFile >> mOutSpan;
*resFile >> mInSpan;
*resFile >> mNumOfInMoney;
for (int i = 0; i < mNumOfInMoney; i++) {
if (i < 4) {
*resFile >> mInMoney[i];
} else {
int moneyTmp;
*resFile >> moneyTmp;
}
}
m124 = NULL;
m128 = NULL;
m130 = NULL;
m140 = 0;
if (mNumOfInMoney > 4)
mNumOfInMoney = 4;
try {
int outViewKind = worldDef->GetOutViewKind() + 1001;
m124 = new T2BitImage(mModuleHandle, outViewKind, 1);
mImageObj->AddObject(mModuleHandle, outViewKind, m124);
} catch (int e) {
}
try {
m128 = new T2BitImage(mModuleHandle, 1010, 1);
mImageObj->AddObject(mModuleHandle, 1010, m128);
} catch (int e) {
}
try {
m130 = new T2BitImage(mModuleHandle, 1100, 1);
mImageObj->AddObject(mModuleHandle, 1100, m130);
} catch (int e) {
}
mWordDefArray = MakeWordDefArray();
}
/*virtual*/ T2EquipDef::~T2EquipDef() {
if (m124)
delete m124;
if (m128)
delete m128;
if (m130)
delete m130;
if (mWordDefArray)
delete mWordDefArray;
}
/*virtual*/ BOOL T2EquipDef::InitObject(T2Object* object) {
object->SetUsed(true);
((T2Equip *) object)->mEquipType = GetEquipType();
((T2Equip *) object)->mCapacity = mCapacity;
((T2Equip *) object)->mAttribute = mAttribute;
((T2Equip *) object)->SetEquipDef(this);
return true;
}
/*virtual*/ int T2EquipDef::ClickProc(T2TowerDoc*, RECT*, unsigned int&) {
return 1;
}
/*virtual*/ int T2EquipDef::GetDestructPartProc(int, POINT, POINT, T2Equip*) {
return -1;
}
/*virtual*/ AREACHECKCODE T2EquipDef::AreaCheck(T2TowerDoc*, RECT&, unsigned int, int) {
return AreaCheckCode_0;
}
/*virtual*/ PARTCODE T2EquipDef::GetPartFromPoint(T2TowerDoc* towerDoc, T2Equip* equip, POINT pt, int*) {
UT2Coordinate::QDToUnit(pt, towerDoc->mZoomLevel);
if (PtInRect(&equip->mArea, pt))
return PartCode_2;
else
return PartCode_0;
}
/*virtual*/ void T2EquipDef::BuildFinish(T2TowerDoc* towerDoc, T2Equip* equip) {
towerDoc->towerDoc_vf170()->CalcOptionObj(towerDoc, equip);
}
/*virtual*/ unsigned long T2EquipDef::OptionProc(T2TowerDoc*, T2Equip*, void*) {
return 0;
}
/*virtual*/ void T2EquipDef::DebugInfo(CWnd&, CListCtrl&, T2Equip*) {
}
/*virtual*/ int T2EquipDef::FingerToolProc(T2TowerDoc*, T2Equip*, const POINT&, MOUSEEVENT) {
return 0;
}
/*virtual*/ T2InfoDialog* T2EquipDef::ShowInfoDialog(T2TowerDoc* towerDoc, T2Equip* equip) {
CRect rect;
AfxGetMainWnd()->GetWindowRect(rect);
T2DLGTEMPLATE tmpl;
tmpl.pt = rect.CenterPoint();
tmpl.moduleHandle = mModuleHandle;
tmpl.resID = GetInfoDialogID(towerDoc, equip);
T2InfoDialog *dialog = ConstructInfoDialog(equip);
dialog->Realize(this, &tmpl, towerDoc, mImageObj, NULL, true, NULL, 0, 1);
return dialog;
}
/*virtual*/ int T2EquipDef::GetInfoDialogID(T2TowerDoc*, const T2Equip*) const {
return 1000;
}
/*virtual*/ T2InfoDialog* T2EquipDef::ConstructInfoDialog(T2Equip* equip) {
return new T2InfoDialog(equip);
}
/*virtual*/ void T2EquipDef::DrawPeople(T2TowerDoc* inDoc, T2Equip* inEquip) {
T2Tenant *theTenant = (T2Tenant *) inEquip;
T2PeopleLinkIterator iterator(theTenant->mFirstPeople);
T2People *thePeople;
while (iterator.Next(&thePeople))
thePeople->Draw(inDoc, inEquip);
}
int T2EquipDef::GetInMoney(int i) {
int cost = 0;
if (i < mNumOfInMoney)
cost = mInMoney[i];
return cost;
}
/*virtual*/ void T2EquipDef::LoadExtraData(T2Archive& inArchive, T2TowerDoc*, T2HaveOutViewObject*) {
int size;
inArchive >> size;
for (int i = 0; i < size; i++) {
unsigned char b;
inArchive >> b;
}
}
/*virtual*/ void T2EquipDef::SaveExtraData(T2Archive& inArchive, T2HaveOutViewObject*) {
int size = 0;
inArchive << size;
}
T2WordDefArray* T2EquipDef::MakeWordDefArray() {
return new T2WordDefArray(mModuleHandle);
}
void T2EquipDef::GetWords(T2People*, CString&) const {
}
|