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
|
#include "StdAfx.h"
#include "CFilePluginList.h"
#include "CResFile.h"
#include "CResourcePlugin.h"
#include "T2AdvertisePlugin.h"
#include "T2BitImage.h"
#include "T2DateTime.h"
#include "T2HaveOutViewObject.h"
#include "T2ImageObj.h"
#include "T2ToolDef.h"
#include "T2ToolPlugin.h"
#include "T2WorldDef.h"
#include "UT2Coordinate.h"
T2ToolDef::T2ToolDef(DWORD type, T2PluginSpecifier& specifier, CResFile* resFile, T2WorldDef* worldDef, T2ToolPlugin* plugin)
: T2TemplatePlugin(type, specifier, resFile, plugin)
{
mToolIcon = new T2BitImage(mModuleHandle, 100, 1);
worldDef->m1D0->AddObject(mModuleHandle, 100, mToolIcon);
mEC = new T2BitImage(mModuleHandle, 1000, 1);
mImageObj->AddObject(mModuleHandle, 1000, mEC);
mToolQuietUntil = NULL;
mCategoryQuietUntil = NULL;
mSettlement = 0;
mCurBuildCount = 0;
mMaxBuildCount = 0;
mSubPluginList = NULL;
unsigned long tmp;
*resFile >> mToolType;
*resFile >> mWidth;
*resFile >> mHeight;
*resFile >> mLevel;
*resFile >> mAttribute;
*resFile >> mCategoryCommentString;
*resFile >> mCategoryName;
*resFile >> mCategoryNo;
*resFile >> mToolNo;
*resFile >> tmp; // mAfterCategoryNo
*resFile >> tmp; // mAfterToolNo
*resFile >> mSubPluginType;
*resFile >> tmp; // mCategoryIcon res ID
*resFile >> tmp; // mCategoryHelpResID
*resFile >> mValiationCount;
for (int i = 0; i < mValiationCount; i++) {
mPriceString[i] = new CString;
*resFile >> *mPriceString[i];
mOutMoneyString[i] = new CString;
*resFile >> *mOutMoneyString[i];
mCommentString[i] = new CString;
*resFile >> *mCommentString[i];
mToolName[i] = new CString;
*resFile >> *mToolName[i];
mName[i] = new CString;
*resFile >> *mName[i];
*resFile >> mPrice[i];
*resFile >> mOutMoney[i];
*resFile >> tmp; // id2
*resFile >> tmp; // offscreen res ID
*resFile >> tmp; // tool help res ID
*resFile >> mConsumptionPower[i];
}
}
/*virtual*/ T2ToolDef::~T2ToolDef() {
for (int i = 0; i < mValiationCount; i++) {
delete mPriceString[i];
delete mOutMoneyString[i];
delete mCommentString[i];
delete mToolName[i];
delete mName[i];
}
if (mToolIcon)
delete mToolIcon;
if (mEC)
delete mEC;
if (mToolQuietUntil)
delete mToolQuietUntil;
if (mSubPluginList)
delete mSubPluginList;
}
/*virtual*/ int T2ToolDef::GetSortKey() {
int key = mCategoryNo << 16;
key += mToolNo;
return key;
}
/*virtual*/ CURSORTYPE T2ToolDef::QueryCursor(T2TowerDoc* inDoc, POINT inPt, CString& outSpriteName, RECT& outRect, POINT& outPt, int inZoomLevel, unsigned int inValiation, int) {
outSpriteName = "Csr";
inPt.x -= ((mWidth * UT2Coordinate::UnitHSize(inZoomLevel)) / 2 - UT2Coordinate::UnitHSize(inZoomLevel) / 2);
inPt.y -= ((mHeight * UT2Coordinate::UnitVSize(inZoomLevel)) / 2 - UT2Coordinate::UnitVSize(inZoomLevel) / 2);
UT2Coordinate::QDToUnit(inPt, inZoomLevel);
SetRect(&outRect, inPt.x, inPt.y, inPt.x + mWidth, inPt.y + mHeight);
outPt.x = outRect.left;
outPt.y = outRect.top;
UT2Coordinate::UnitToQD(outRect, inZoomLevel);
return CursorType_0;
}
CString T2ToolDef::CalcSoundID(int id) const {
CString s;
s.Format("%d:%d", mToolType, id);
return s;
}
void T2ToolDef::GetName(CString& outStr, int id) {
outStr = *mName[id];
}
/*virtual*/ int T2ToolDef::CalcMentenanceCostProc(const T2HaveOutViewObject* obj) const {
int cost = 0;
T2ToolDef *objToolDef = obj->GetToolDef();
if (objToolDef->IsSetAttribute(kToolAttrNormalMenteCost))
cost = GetOutMoney(obj->GetValiation());
return cost;
}
int T2ToolDef::GetOutMoney(unsigned int id) const {
int money = 0;
if (id < kMaxValiation)
money = mOutMoney[id];
return money;
}
void T2ToolDef::SetOutMoney(unsigned int id, int money) {
if (id < kMaxValiation)
mOutMoney[id] = money;
}
/*virtual*/ void T2ToolDef::Add(CResourcePlugin* plugin) {
DWORD type = GetSubPluginType();
if (plugin->GetType() == type) {
if (!mSubPluginList)
mSubPluginList = new CFilePluginList(type);
if (mSubPluginList)
mSubPluginList->Add(plugin);
}
}
/*virtual*/ void T2ToolDef::Add(T2AdvertisePlugin* plugin) {
DWORD type = GetSubPluginType();
if (plugin->GetSubType() == type) {
if (!mSubPluginList)
mSubPluginList = new CFilePluginList(type);
if (mSubPluginList)
mSubPluginList->Add(plugin);
}
}
/*virtual*/ PROCCODE T2ToolDef::DoDestructProc(T2TowerDoc*, T2HaveOutViewObject*, POINT, RECT&) {
return ProcCode_0;
}
|