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
|
#include "StdAfx.h"
#include "T2CtrlPalette.h"
#include "T2DLL/T2ImageObj.h"
#include "T2MWControl.h"
#include "T2TowerDoc.h"
#include "T2DLL/T2WorldDef.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
// T2.exe 44795C
/*static*/ int T2CtrlPalette::sUnknown = 0;
T2CtrlPalette::T2CtrlPalette() {
#line 19
mPauseControl = new T2MWControl;
mInViewControl = new T2MWControl;
mOutViewControl = new T2MWControl;
mMaintControl = new T2MWControl;
mEvalControl = new T2MWControl;
mTransControl = new T2MWControl;
mPriceControl = new T2MWControl;
mSliderControl = new T2MWControl;
mDocument = NULL;
mWorldDef = NULL;
sUnknown = 0;
mIsSetUp = false;
}
/*virtual*/ T2CtrlPalette::~T2CtrlPalette() {
delete mPauseControl;
delete mInViewControl;
delete mOutViewControl;
delete mMaintControl;
delete mEvalControl;
delete mTransControl;
delete mPriceControl;
delete mSliderControl;
}
BEGIN_MESSAGE_MAP(T2CtrlPalette, CFrameWnd)
//{{AFX_MSG_MAP(T2CtrlPalette)
ON_WM_CREATE()
ON_WM_QUERYNEWPALETTE()
ON_WM_ERASEBKGND()
ON_WM_CLOSE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/*virtual*/ void T2CtrlPalette::SetDocument(T2TowerDoc *inDoc) {
mDocument = inDoc;
mWorldDef = inDoc->mWorldDef;
mE4 = AfxRegisterWndClass(CS_NOCLOSE, NULL, (HBRUSH) GetStockObject(WHITE_BRUSH));
RECT rect;
mWorldDef->mImageObj->GetObjectImage(mWorldDef->mImageObj->FindObject("Pause", 0), rect);
mPauseControl->Create(mE4, "", WS_CHILD | WS_VISIBLE, rect, this, 2000);
mWorldDef->mImageObj->GetObjectImage(mWorldDef->mImageObj->FindObject("InView", 0), rect);
mInViewControl->Create(mE4, "", WS_CHILD | WS_VISIBLE, rect, this, 2001);
mWorldDef->mImageObj->GetObjectImage(mWorldDef->mImageObj->FindObject("OutView", 0), rect);
mOutViewControl->Create(mE4, "", WS_CHILD | WS_VISIBLE, rect, this, 2006);
mWorldDef->mImageObj->GetObjectImage(mWorldDef->mImageObj->FindObject("Maint", 0), rect);
mMaintControl->Create(mE4, "", WS_CHILD | WS_VISIBLE, rect, this, 2004);
mWorldDef->mImageObj->GetObjectImage(mWorldDef->mImageObj->FindObject("Eval", 0), rect);
mEvalControl->Create(mE4, "", WS_CHILD | WS_VISIBLE, rect, this, 2003);
mWorldDef->mImageObj->GetObjectImage(mWorldDef->mImageObj->FindObject("Trans", 0), rect);
mTransControl->Create(mE4, "", WS_CHILD | WS_VISIBLE, rect, this, 2005);
mWorldDef->mImageObj->GetObjectImage(mWorldDef->mImageObj->FindObject("Price", 0), rect);
mPriceControl->Create(mE4, "", WS_CHILD | WS_VISIBLE, rect, this, 2002);
mWorldDef->mImageObj->GetObjectImage(mWorldDef->mImageObj->FindObject("Slider", 0), rect);
mSliderControl->Create(mE4, "", WS_CHILD | WS_VISIBLE, rect, this, 2007);
mPauseControl->Setup(inDoc);
mInViewControl->Setup(inDoc);
mOutViewControl->Setup(inDoc);
mMaintControl->Setup(inDoc);
mEvalControl->Setup(inDoc);
mTransControl->Setup(inDoc);
mPriceControl->Setup(inDoc);
mSliderControl->Setup(inDoc);
mIsSetUp = true;
InvalidateRect(NULL);
}
/*virtual*/ void T2CtrlPalette::vf100(int inViewMode) {
mInViewControl->SetData(0);
mOutViewControl->SetData(0);
mMaintControl->SetData(0);
mEvalControl->SetData(0);
mTransControl->SetData(0);
mPriceControl->SetData(0);
int walkRate = mDocument->GetWalkRate();
if (walkRate == -1)
walkRate = 0;
else
walkRate = 7 - walkRate;
mSliderControl->SetData(walkRate);
switch (inViewMode) {
case kInView:
mInViewControl->SetData(100);
break;
case kOutView:
mOutViewControl->SetData(100);
break;
case kMaintView:
mMaintControl->SetData(100);
break;
case kEvalView:
mEvalControl->SetData(100);
break;
case kTransView:
mTransControl->SetData(100);
break;
case kPriceView:
mPriceControl->SetData(100);
break;
}
InvalidateRect(NULL);
}
/*virtual*/ void T2CtrlPalette::vf104(int inViewMode) {
#pragma var_order(windowRect, y, clientRect, flag)
RECT windowRect;
RECT clientRect;
int flag = 0;
int y;
switch (inViewMode) {
case kInView:
case ViewMode_6:
y = 0;
break;
case kOutView:
y = 0;
flag = 1;
break;
case kMaintView:
y = 21;
mE0 = "Maint";
break;
case kEvalView:
y = 21;
mE0 = "Eval";
break;
case kTransView:
y = 21;
mE0 = "Trans";
break;
case kPriceView:
y = 21;
mE0 = "Price";
break;
}
GetWindowRect(&windowRect);
GetClientRect(&clientRect);
SetWindowPos(
NULL,
0, 0,
windowRect.right - windowRect.left - clientRect.right + 123,
windowRect.bottom - windowRect.top - clientRect.bottom + 51 + y,
SWP_NOMOVE | SWP_NOZORDER
);
InvalidateRect(NULL);
}
afx_msg int T2CtrlPalette::OnCreate(LPCREATESTRUCT lpCreateStruct) {
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
RECT windowRect;
RECT clientRect;
GetWindowRect(&windowRect);
GetClientRect(&clientRect);
SetWindowPos(
NULL,
0, 0,
windowRect.right - windowRect.left - clientRect.right + 123,
windowRect.bottom - windowRect.top - clientRect.bottom + 51,
SWP_NOMOVE | SWP_NOZORDER
);
return 0;
}
afx_msg BOOL T2CtrlPalette::OnQueryNewPalette() {
return CFrameWnd::OnQueryNewPalette();
}
afx_msg BOOL T2CtrlPalette::OnEraseBkgnd(CDC* pDC) {
if (!mDocument)
return CFrameWnd::OnEraseBkgnd(pDC);
pDC->SaveDC();
pDC->SelectPalette(mWorldDef->GetPalette(), false);
RECT rect;
int objectID = mWorldDef->mImageObj->FindObject("CtrlPal");
SetRect(&rect, 0, 0, 123, 51);
mWorldDef->mImageObj->DrawObject(pDC, objectID, rect);
objectID = mWorldDef->mImageObj->FindObject(mE0, 1000);
if (objectID >= 0) {
SetRect(&rect, 0, 51, 123, 72);
mWorldDef->mImageObj->DrawObject(pDC, objectID, rect);
}
pDC->RealizePalette();
pDC->RestoreDC(-1);
return true;
}
afx_msg void T2CtrlPalette::OnClose() {
if (!mDocument)
return;
mDocument->towerDoc_vf198(kControlWindow);
}
|