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
|
#include "T2Archive.h"
#include "T2FloorInfo.h"
#include "T2OutObj.h"
#include "T2OuterObjDef.h"
#include "T2TemplatePluginList.h"
#include "T2TowerDoc.h"
#include "T2TowerMainView.h"
T2OutObj::T2OutObj() {
mID = 0;
SetRect(&mOutObjArea, 0, 0, 0, 0);
mToolType = 0;
mToolDef = NULL;
mRefCon = 0;
mSubPlugin = NULL;
}
/*virtual*/ T2OutObj::~T2OutObj() {
}
/*virtual*/ void T2OutObj::Draw(T2TowerDoc* towerDoc, const CRect& rect) {
T2ToolDef *theToolDef = GetToolDef();
theToolDef->DrawProc(this, rect, towerDoc);
}
/*virtual*/ PROCCODE T2OutObj::DoDestruct(T2TowerDoc* towerDoc, int, CPoint pt1, CPoint, CRect& rect) {
PROCCODE result = ProcCode_0;
if (GetToolDef())
result = GetToolDef()->DoDestructProc(towerDoc, this, pt1, rect);
else
result = Destruct(towerDoc, rect);
return result;
}
/*virtual*/ PROCCODE T2OutObj::Destruct(T2TowerDoc* towerDoc, RECT& rect) {
GetOutObjArea(rect);
T2FloorInfo *theFloorInfo = towerDoc->GetFloorInfo();
if (theFloorInfo) {
theFloorInfo->FillOutObjID(rect, 0);
if (GetToolDef())
GetToolDef()->DestructFinish(towerDoc, this);
}
SetUsed(false);
return ProcCode_1;
}
/*virtual*/ void T2OutObj::GetOutObjArea(RECT& rect) const {
rect = mOutObjArea;
}
/*virtual*/ unsigned int T2OutObj::Idle(T2TowerDoc* towerDoc) {
unsigned int result = 0;
if (GetToolDef())
result = GetToolDef()->IdleProc(this, towerDoc);
if (result)
towerDoc->GetMainView()->InvalUnitRect(mOutObjArea);
return result;
}
/*virtual*/ int T2OutObj::InitOutObj(T2OuterObjDef* def, const RECT& outObjArea, unsigned int valiation) {
int result = 0;
mSubPlugin = NULL;
if (def) {
mToolType = def->GetToolType();
mToolDef = def;
}
mOutObjArea = outObjArea;
mValiation = valiation;
mRefCon = 0;
mStatus = kOutObjStatus0;
SetUsed(true);
return result;
}
/*virtual*/ void T2OutObj::LoadSelf(T2Archive& archive, T2TowerDoc* towerDoc) {
T2Object::LoadSelf(archive, towerDoc);
if (IsUsed()) {
unsigned short us;
short s;
archive >> us;
mID = us;
archive.ReadSRect(mOutObjArea);
archive >> mValiation;
archive >> s;
mToolType = s;
mToolDef = towerDoc->mOuterObjTemplates->FindOutObjDef(mToolType);
if (mToolDef) {
mToolDef->LoadExtraData(archive, towerDoc, this);
} else {
char tmp;
int len;
archive >> len;
for (int i = 0; i < len; i++) {
archive >> tmp;
}
}
}
}
/*virtual*/ void T2OutObj::SaveSelf(T2Archive& archive) {
T2Object::SaveSelf(archive);
if (IsUsed()) {
archive << (unsigned short) mID;
archive.WriteSRect(mOutObjArea);
archive << mValiation;
archive << (short) mToolType;
if (mToolDef) {
mToolDef->SaveExtraData(archive, this);
} else {
int count = 0;
archive << count;
}
}
}
/*virtual*/ void T2OutObj::StartBuild(T2TowerDoc* towerDoc) {
mStatus = kOutObjStatus1;
}
/*virtual*/ T2InfoDialog* T2OutObj::ShowInfoDialog(T2TowerDoc* towerDoc) {
return ((T2OuterObjDef *) mToolDef)->ShowInfoDialog(towerDoc, this);
}
/*virtual*/ void T2OutObj::DrawHitMask(T2TowerDoc* towerDoc) {
CRect rect = mOutObjArea;
Draw(towerDoc, rect);
}
|