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
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
|
#include "T2.h"
#include "T2DLL.h"
#include "T2ImageObj.h"
#include "T2MainWindow.h"
#include "T2TemplatePluginList.h"
#include "T2ToolDef.h"
#include "T2ToolWindow.h"
#include "T2TowerDoc.h"
#include "T2WorldDef.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#line 16
IMPLEMENT_DYNCREATE(T2ToolWindow, CFrameWnd);
T2ToolWindow::T2ToolWindow() {
#line 20
mToolIconList = new T2ToolIconList;
mDocument = NULL;
mWorldDef = NULL;
mSel = -1;
mListCtrl = NULL;
mTimerID = 0;
for (int i = 0; i < 16; i++)
_D8[i] = NULL;
_118 = 1;
}
/*virtual*/ T2ToolWindow::~T2ToolWindow() {
delete mToolIconList;
}
/*virtual*/ void T2ToolWindow::SetDocument(T2TowerDoc* inDoc) {
mDocument = inDoc;
mWorldDef = inDoc->mWorldDef;
}
BEGIN_MESSAGE_MAP(T2ToolWindow, CFrameWnd)
ON_WM_QUERYNEWPALETTE()
ON_WM_ERASEBKGND()
ON_WM_CREATE()
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_MOUSEMOVE()
ON_WM_LBUTTONDBLCLK()
ON_WM_TIMER()
ON_WM_SIZE()
ON_WM_DESTROY()
ON_WM_CLOSE()
END_MESSAGE_MAP()
afx_msg BOOL T2ToolWindow::OnQueryNewPalette() {
if (!mDocument || !mDocument->mWorldDef)
return CFrameWnd::OnQueryNewPalette();
CDC *pDC = GetDC();
pDC->SaveDC();
pDC->SelectPalette(mDocument->mWorldDef->GetPalette(), false);
pDC->RealizePalette();
pDC->RestoreDC(-1);
ReleaseDC(pDC);
return true;
}
afx_msg int T2ToolWindow::OnCreate(LPCREATESTRUCT lpCreateStruct) {
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
return OnCreateProc(lpCreateStruct);
}
/*virtual*/ int T2ToolWindow::GetSel() {
return mSel;
}
/*virtual*/ void T2ToolWindow::SetSel(int inID) {
if (SearchID(inID))
SelChange(inID);
}
/*virtual*/ CString* T2ToolWindow::GetIconName(int inID) {
static CString defaultName = "";
POSITION pos = SearchID(inID);
if (!pos)
return &defaultName;
return &mToolIconList->GetAt(pos)->mName;
}
/*virtual*/ T2TemplatePlugin* T2ToolWindow::GetIconPlugin(int inID) {
POSITION pos = SearchID(inID);
if (!pos)
return NULL;
return mToolIconList->GetAt(pos)->mPlugin;
}
/*virtual*/ DWORD T2ToolWindow::GetIconOption(int inID) {
POSITION pos = SearchID(inID);
if (!pos)
return 0;
return mToolIconList->GetAt(pos)->mOption;
}
/*virtual*/ unsigned int T2ToolWindow::GetIconValiation(int inID) {
POSITION pos = SearchID(inID);
if (!pos)
return 0;
return mToolIconList->GetAt(pos)->mValiation;
}
/*virtual*/ void T2ToolWindow::AddIcon(const char* inName, char* inStr2, unsigned int inValiation, DWORD inOption, T2ToolDef* inToolDef, int inFld18, unsigned short inSomeMask, T2ToolCallback* inToolCallback) {
T2ToolIconItem *theToolIconItem;
POSITION position = mToolIconList->GetHeadPosition();
while (position) {
theToolIconItem = mToolIconList->GetNext(position);
if (theToolIconItem->mName == inName && theToolIconItem->mValiation == inValiation)
return;
}
#line 145
T2ToolIconItem *theItem = new T2ToolIconItem;
theItem->mID = AssignNewID();
theItem->mName = inName;
theItem->mValiation = inValiation;
theItem->mOption = inOption;
theItem->m18 = inFld18;
theItem->m1C = inSomeMask;
theItem->mToolCallback = inToolCallback;
theItem->mToolDef = inToolDef;
unsigned short mask = 1;
if (mDocument->mViewMode == kOutView)
mask = 2;
if (inSomeMask & mask)
theItem->m30 = 1;
else
theItem->m30 = 0;
if (inStr2)
theItem->m2C = inStr2;
if (RefreshItem(theItem)) {
mToolIconList->AddTail(theItem);
ListUpdated();
}
}
/*virtual*/ void T2ToolWindow::AddIcon(const char* inName, unsigned short inSomeMask, char* inStr2, T2ToolCallback* inToolCallback) {
AddIcon(inName, inStr2, 0, kToolOption0, NULL, 0, inSomeMask, inToolCallback);
}
/*virtual*/ void T2ToolWindow::RemoveIcon(const char* inName, unsigned int inValiation) {
T2ToolIconItem *theToolIconItem;
POSITION prevPos;
POSITION pos = mToolIconList->GetHeadPosition();
while (pos) {
prevPos = pos;
theToolIconItem = mToolIconList->GetNext(pos);
if (theToolIconItem->mName == inName && theToolIconItem->mValiation == inValiation) {
RemoveItem(prevPos);
mToolIconList->RemoveAt(prevPos);
delete theToolIconItem;
ListUpdated();
break;
}
}
}
/*virtual*/ void T2ToolWindow::RemoveAll() {
delete mToolIconList;
#line 204
mToolIconList = new T2ToolIconList;
ListUpdated();
SelChange(1);
}
/*virtual*/ int T2ToolWindow::GetID(const char* inName, unsigned int inValiation) {
T2ToolIconItem *theToolIconItem;
POSITION pos = mToolIconList->GetHeadPosition();
while (pos) {
theToolIconItem = mToolIconList->GetNext(pos);
if (theToolIconItem->mName == inName && theToolIconItem->mValiation == inValiation)
return theToolIconItem->mID;
}
return -1;
}
/*virtual*/ T2ToolIconItem* T2ToolWindow::GetItem(const char* inName, unsigned int inValiation) {
T2ToolIconItem *theToolIconItem;
POSITION pos = mToolIconList->GetHeadPosition();
while (pos) {
theToolIconItem = mToolIconList->GetNext(pos);
if (theToolIconItem->mName == inName && theToolIconItem->mValiation == inValiation)
return theToolIconItem;
}
return NULL;
}
/*virtual*/ T2ToolIconItem* T2ToolWindow::GetItem(int inID) {
T2ToolIconItem *theToolIconItem;
POSITION pos = mToolIconList->GetHeadPosition();
while (pos) {
theToolIconItem = mToolIconList->GetNext(pos);
if (theToolIconItem->mID == inID)
return theToolIconItem;
}
return NULL;
}
/*virtual*/ void T2ToolWindow::Refresh() {
POSITION pos = mToolIconList->GetHeadPosition();
while (pos) {
while (pos) {
T2ToolIconItem *theToolIconItem = mToolIconList->GetNext(pos);
if (!RefreshItem(theToolIconItem)) {
pos = mToolIconList->GetHeadPosition();
break;
}
}
}
Updated();
}
/*virtual*/ BOOL T2ToolWindow::RefreshItem(T2ToolIconItem* inItem) {
#line 269
_ASSERT(mWorldDef != NULL);
_ASSERT(mDocument != NULL);
inItem->mPlugin = NULL;
if (mDocument->mTenantTemplates)
inItem->mPlugin = SearchPlugin(mDocument->mTenantTemplates, inItem->mName);
if (!inItem->mPlugin && mDocument->mMoverTemplates)
inItem->mPlugin = SearchPlugin(mDocument->mMoverTemplates, inItem->mName);
if (!inItem->mPlugin && mDocument->mOuterObjTemplates)
inItem->mPlugin = SearchPlugin(mDocument->mOuterObjTemplates, inItem->mName);
if (!inItem->mPlugin && mWorldDef->m1D0->FindObject(inItem->mName) != -1)
inItem->mPlugin = mWorldDef;
if (!inItem->mPlugin) {
POSITION pos = mToolIconList->Find(inItem);
if (pos) {
RemoveItem(pos);
mToolIconList->RemoveAt(pos);
}
delete inItem;
return false;
}
return true;
}
/*virtual*/ T2TemplatePlugin* T2ToolWindow::SearchPlugin(T2TemplatePluginList* inList, CString& inName) {
LArrayIterator iterator(*inList);
T2TemplatePlugin *thePlugin;
while (iterator.Next(&thePlugin)) {
if (thePlugin->mStr48 == inName)
return thePlugin;
}
return NULL;
}
/*virtual*/ POSITION T2ToolWindow::SearchID(int inID) {
T2ToolIconItem *theToolIconItem;
POSITION prevPos;
POSITION pos = mToolIconList->GetHeadPosition();
while (pos) {
prevPos = pos;
theToolIconItem = mToolIconList->GetNext(pos);
if (theToolIconItem->mID == inID)
return prevPos;
}
return NULL;
}
/*virtual*/ int T2ToolWindow::AssignNewID() {
for (int id = 0; id < 10000; id++) {
if (!SearchID(id))
return id;
}
return -1;
}
/*virtual*/ void T2ToolWindow::RemoveItem(POSITION inPos) {
#line 334
_ASSERT(inPos != NULL);
T2ToolIconItem *theToolIconItem = mToolIconList->GetAt(inPos);
if (theToolIconItem->mID == mSel) {
theToolIconItem = mToolIconList->GetAt(mToolIconList->GetHeadPosition());
ListUpdated();
SelChange(theToolIconItem->mID);
}
}
/*virtual*/ void T2ToolWindow::SelChange(int inID) {
mSel = inID;
Updated();
}
/*virtual*/ BOOL T2ToolWindow::EnableIcon(const char* inName, unsigned int inValiation, BOOL inFlag) {
T2ToolIconItem *theToolIconItem;
POSITION pos = mToolIconList->GetHeadPosition();
while (pos) {
theToolIconItem = mToolIconList->GetNext(pos);
if (theToolIconItem->mName == inName && theToolIconItem->mValiation == inValiation) {
if (inFlag)
theToolIconItem->mEnableCount--;
else
theToolIconItem->mEnableCount++;
RedrawButton();
return true;
}
}
return false;
}
/*virtual*/ void T2ToolWindow::EnableIcon(BOOL inFlag) {
T2ToolIconItem *theToolIconItem;
POSITION pos = mToolIconList->GetHeadPosition();
while (pos) {
theToolIconItem = mToolIconList->GetNext(pos);
if (inFlag) {
if (theToolIconItem->mEnableCount)
theToolIconItem->mEnableCount--;
} else {
theToolIconItem->mEnableCount++;
}
}
RedrawButton();
}
/*virtual*/ T2ToolIconItem* T2ToolWindow::EnableIcon(unsigned short inMask) {
T2ToolIconItem *theToolIconItem;
T2ToolIconItem *oldSelectedItem = NULL;
T2ToolIconItem *selectedItem = NULL;
POSITION pos = mToolIconList->GetHeadPosition();
while (pos) {
theToolIconItem = mToolIconList->GetNext(pos);
unsigned int flag = 0;
if (theToolIconItem->m1C & inMask)
flag = 1;
theToolIconItem->m30 = flag;
if (theToolIconItem->m24) {
if (theToolIconItem->mOption == kToolOption4 || theToolIconItem->mOption == kToolOption0) {
_D8[_118] = theToolIconItem;
if (!flag)
oldSelectedItem = theToolIconItem;
}
}
}
for (unsigned short what = 1; what < 16; what++) {
if ((what & inMask) && _D8[what]) {
theToolIconItem = _D8[what];
if (theToolIconItem->mOption == kToolOption4 || theToolIconItem->mOption == kToolOption0) {
if (theToolIconItem->m30 && !theToolIconItem->m18) {
theToolIconItem->m24 = true;
selectedItem = theToolIconItem;
if (oldSelectedItem) {
oldSelectedItem->m24 = false;
oldSelectedItem = NULL;
}
}
}
}
}
if (oldSelectedItem && oldSelectedItem->mOption == kToolOption4) {
pos = mToolIconList->GetHeadPosition();
while (pos) {
theToolIconItem = mToolIconList->GetNext(pos);
if (theToolIconItem->m30 && theToolIconItem->mOption == kToolOption4 && !theToolIconItem->m18) {
theToolIconItem->m24 = true;
selectedItem = theToolIconItem;
oldSelectedItem->m24 = false;
oldSelectedItem = NULL;
break;
}
}
}
if (oldSelectedItem) {
pos = mToolIconList->GetHeadPosition();
while (pos) {
theToolIconItem = mToolIconList->GetNext(pos);
if (theToolIconItem->m30 && theToolIconItem->mOption == kToolOption0) {
theToolIconItem->m24 = true;
selectedItem = theToolIconItem;
oldSelectedItem->m24 = false;
oldSelectedItem = NULL;
break;
}
}
}
if (selectedItem)
SelChange(selectedItem->mID);
RedrawButton();
Updated();
_118 = inMask & 0xF;
return selectedItem;
}
/*virtual*/ void T2ToolWindow::RedrawButton() {
}
/*virtual*/ void T2ToolWindow::Updated() {
}
/*virtual*/ void T2ToolWindow::ListUpdated() {
if (mListCtrl) {
mListCtrl->DeleteAllItems();
POSITION pos = mToolIconList->GetHeadPosition();
T2ToolIconItem *theToolIconItem;
int row = 0;
CString text;
while (pos) {
theToolIconItem = mToolIconList->GetNext(pos);
mListCtrl->InsertItem(row, theToolIconItem->mName);
text.Format("%d", theToolIconItem->mValiation);
mListCtrl->SetItemText(row, 1, text);
text.Format("%d", theToolIconItem->mID);
mListCtrl->SetItemText(row, 2, text);
mListCtrl->SetItemText(row, 3, theToolIconItem->mPlugin->mStr48);
mListCtrl->SetItemData(row, (DWORD) theToolIconItem->mID);
row++;
}
}
}
void T2ToolWindow::StartTimer(UINT inDelay) {
if (mTimerID)
KillTimer(mTimerID);
mTimerID = SetTimer(1, inDelay, NULL);
}
void T2ToolWindow::StopTimer() {
if (mTimerID)
KillTimer(mTimerID);
mTimerID = 0;
}
afx_msg BOOL T2ToolWindow::OnEraseBkgnd(CDC* pDC) {
return OnEraseBkgndProc(pDC);
}
afx_msg void T2ToolWindow::OnLButtonDown(UINT nFlags, CPoint point) {
OnLButtonDownProc(nFlags, point);
}
afx_msg void T2ToolWindow::OnLButtonUp(UINT nFlags, CPoint point) {
OnLButtonUpProc(nFlags, point);
}
afx_msg void T2ToolWindow::OnMouseMove(UINT nFlags, CPoint point) {
CWinApp *theApp = AfxGetApp();
HCURSOR cursor = theApp->LoadStandardCursor(IDC_ARROW);
if (cursor)
SetCursor(cursor);
OnMouseMoveProc(nFlags, point);
}
afx_msg void T2ToolWindow::OnLButtonDblClk(UINT nFlags, CPoint point) {
OnLButtonDblClkProc(nFlags, point);
}
afx_msg void T2ToolWindow::OnTimer(UINT nIDEvent) {
if (nIDEvent == 1)
OnTimerProc(nIDEvent);
CWnd::OnTimer(nIDEvent);
}
afx_msg void T2ToolWindow::OnSize(UINT nType, int cx, int cy) {
OnSizeProc(nType, cx, cy);
ListUpdated();
}
afx_msg void T2ToolWindow::OnDestroy() {
StopTimer();
if (mListCtrl) {
mListCtrl->DestroyWindow();
delete mListCtrl;
}
if (gT2App->mMainWindow)
gT2App->mMainWindow->mToolWindow = NULL;
CFrameWnd::OnDestroy();
}
/*virtual*/ int T2ToolWindow::OnCreateProc(LPCREATESTRUCT lpCreateStruct) {
CRect listArea;
listArea.SetRect(0, 0, 300, 400);
CRect windowArea, clientArea;
GetWindowRect(windowArea);
GetClientRect(clientArea);
SetWindowPos(
NULL,
0,
100,
listArea.Width() + windowArea.Width() - clientArea.Width(),
listArea.Height() + windowArea.Height() - clientArea.Height(),
SWP_NOZORDER
);
#line 615
mListCtrl = new CListCtrl;
mListCtrl->Create(
LVS_REPORT | LVS_SINGLESEL | WS_VSCROLL | WS_VISIBLE | WS_CHILD,
listArea,
this,
100
);
mListCtrl->InsertColumn(0, "Name", LVCFMT_LEFT, 100);
mListCtrl->InsertColumn(1, "Val", LVCFMT_LEFT, 40);
mListCtrl->InsertColumn(2, "ID", LVCFMT_LEFT, 40);
mListCtrl->InsertColumn(3, "Plugin", LVCFMT_LEFT, 120);
Updated();
return 0;
}
/*virtual*/ BOOL T2ToolWindow::OnEraseBkgndProc(CDC* pDC) {
return CFrameWnd::OnEraseBkgnd(pDC);
}
/*virtual*/ void T2ToolWindow::OnLButtonDownProc(UINT nFlags, CPoint point) {
CWnd::OnLButtonDown(nFlags, point);
}
/*virtual*/ void T2ToolWindow::OnLButtonUpProc(UINT nFlags, CPoint point) {
CWnd::OnLButtonUp(nFlags, point);
}
/*virtual*/ void T2ToolWindow::OnMouseMoveProc(UINT nFlags, CPoint point) {
CWnd::OnMouseMove(nFlags, point);
}
/*virtual*/ void T2ToolWindow::OnLButtonDblClkProc(UINT nFlags, CPoint point) {
CWnd::OnLButtonDblClk(nFlags, point);
}
/*virtual*/ void T2ToolWindow::OnTimerProc(UINT nIDEvent) {
}
/*virtual*/ void T2ToolWindow::OnSizeProc(UINT nType, int cx, int cy) {
}
afx_msg void T2ToolWindow::OnClose() {
if (!mDocument)
return;
mDocument->towerDoc_vf198(kToolWindow);
}
/*virtual*/ BOOL T2ToolWindow::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) {
if (wParam == 100 && ((LPNMHDR) lParam)->code == LVN_ITEMCHANGED && mListCtrl->GetSelectedCount() == 1) {
int row, count;
count = mListCtrl->GetItemCount();
for (row = 0; row < count; row++) {
if (mListCtrl->GetItemState(row, LVIS_SELECTED))
break;
}
SelChange(row);
}
return CWnd::OnNotify(wParam, lParam, pResult);
}
T2ToolIconItem::T2ToolIconItem() {
mPlugin = NULL;
mName = "";
mValiation = 0;
mOption = kToolOption0;
mID = -1;
m24 = false;
mEnableCount = 0;
m30 = 1;
}
/*virtual*/ T2ToolIconItem::~T2ToolIconItem() {
}
T2ToolIconList::T2ToolIconList() {
}
/*virtual*/ T2ToolIconList::~T2ToolIconList() {
T2ToolIconItem *theToolIconItem;
POSITION pos = GetHeadPosition();
while (pos) {
theToolIconItem = GetNext(pos);
delete theToolIconItem;
}
}
|