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
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: Implements a dialog for showing the input connections of an entity
//
// $NoKeywords: $
//=============================================================================//
#include "stdafx.h"
#include "GlobalFunctions.h"
#include "MapDoc.h"
#include "MapEntity.h"
#include "MapWorld.h"
#include "ObjectProperties.h"
#include "OP_Input.h"
#include "MainFrm.h"
#include "Selection.h"
// memdbgon must be the last include file in a .cpp file!!!
#include <tier0/memdbgon.h>
//
// Column indices for the list control.
//
const int ICON_COLUMN = 0;
const int SOURCE_NAME_COLUMN = 1;
const int OUTPUT_NAME_COLUMN = 2;
const int INPUT_NAME_COLUMN = 3;
const int PARAMETER_COLUMN = 4;
const int DELAY_COLUMN = 5;
const int ONLY_ONCE_COLUMN = 6;
#define ICON_CONN_BAD 0
#define ICON_CONN_GOOD 1
#define ICON_CONN_BAD_GREY 2
#define ICON_CONN_GOOD_GREY 3
IMPLEMENT_DYNCREATE(COP_Input, CObjectPage)
BEGIN_MESSAGE_MAP(COP_Input, CObjectPage)
//{{AFX_MSG_MAP(COP_Input)
ON_BN_CLICKED(IDC_MARK, OnMark)
ON_WM_SIZE()
ON_WM_DESTROY()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
//-----------------------------------------------------------------------------
// Static vars
//-----------------------------------------------------------------------------
CImageList* COP_Input::m_pImageList = NULL;
//-----------------------------------------------------------------------------
// Purpose: Constructor.
//-----------------------------------------------------------------------------
COP_Input::COP_Input(void)
: CObjectPage(COP_Input::IDD)
{
m_pObjectList = NULL;
m_pEntityList = new CMapEntityList;
m_pEditObjectRuntimeClass = RUNTIME_CLASS(editCMapClass);
m_nSortColumn = OUTPUT_NAME_COLUMN;
//
// All columns initially sort in ascending order.
//
for (int i = 0; i < OUTPUT_LIST_NUM_COLUMNS; i++)
{
m_eSortDirection[i] = Sort_Ascending;
}
}
//-----------------------------------------------------------------------------
// Purpose: Destructor.
//-----------------------------------------------------------------------------
COP_Input::~COP_Input(void)
{
// Delete my list
delete m_pEntityList;
}
//-----------------------------------------------------------------------------
// Purpose: Compares by delays. Used as a secondary sort by all other columns.
//-----------------------------------------------------------------------------
static int CALLBACK InputCompareDelaysSecondary(CInputConnection *pInputConn1, CInputConnection *pInputConn2, SortDirection_t eDirection)
{
CEntityConnection *pConn1 = pInputConn1->m_pConnection;
CEntityConnection *pConn2 = pInputConn2->m_pConnection;
return(CEntityConnection::CompareDelaysSecondary(pConn1,pConn2,eDirection));
}
//-----------------------------------------------------------------------------
// Purpose: Compares by delays, does a secondary compare by output name.
//-----------------------------------------------------------------------------
static int CALLBACK InputCompareDelays(CInputConnection *pInputConn1, CInputConnection *pInputConn2, SortDirection_t eDirection)
{
CEntityConnection *pConn1 = pInputConn1->m_pConnection;
CEntityConnection *pConn2 = pInputConn2->m_pConnection;
return(CEntityConnection::CompareDelays(pConn1, pConn2,eDirection));
}
//-----------------------------------------------------------------------------
// Purpose: Compares by output name, does a secondary compare by delay.
//-----------------------------------------------------------------------------
static int CALLBACK InputCompareOutputNames(CInputConnection *pInputConn1, CInputConnection *pInputConn2, SortDirection_t eDirection)
{
CEntityConnection *pConn1 = pInputConn1->m_pConnection;
CEntityConnection *pConn2 = pInputConn2->m_pConnection;
return(CEntityConnection::CompareOutputNames(pConn1,pConn2,eDirection));
}
//-----------------------------------------------------------------------------
// Purpose: Compares by input name, does a secondary compare by delay.
//-----------------------------------------------------------------------------
static int CALLBACK InputCompareInputNames(CInputConnection *pInputConn1, CInputConnection *pInputConn2, SortDirection_t eDirection)
{
CEntityConnection *pConn1 = pInputConn1->m_pConnection;
CEntityConnection *pConn2 = pInputConn2->m_pConnection;
return(CEntityConnection::CompareInputNames(pConn1,pConn2,eDirection));
}
//-----------------------------------------------------------------------------
// Purpose: Compares by source name, does a secondary compare by delay.
//-----------------------------------------------------------------------------
static int CALLBACK InputCompareSourceNames(CInputConnection *pInputConn1, CInputConnection *pInputConn2, SortDirection_t eDirection)
{
CEntityConnection *pConn1 = pInputConn1->m_pConnection;
CEntityConnection *pConn2 = pInputConn2->m_pConnection;
return(CEntityConnection::CompareSourceNames(pConn1,pConn2,eDirection));
}
//-----------------------------------------------------------------------------
// Purpose: Compares by target name, does a secondary compare by delay.
//-----------------------------------------------------------------------------
static int CALLBACK InputCompareTargetNames(CInputConnection *pInputConn1, CInputConnection *pInputConn2, SortDirection_t eDirection)
{
CEntityConnection *pConn1 = pInputConn1->m_pConnection;
CEntityConnection *pConn2 = pInputConn2->m_pConnection;
return(CEntityConnection::CompareTargetNames(pConn1,pConn2,eDirection));
}
//------------------------------------------------------------------------------
// Purpose : Returns true if given item number from list control is a valid
// connection type
// Input :
// Output :
//------------------------------------------------------------------------------
bool COP_Input::ValidateConnections(int nItem)
{
CInputConnection *pInputConn = (CInputConnection *)m_ListCtrl.GetItemData(nItem);
// Early out
if (!pInputConn)
{
return false;
}
CEntityConnection *pConnection = pInputConn->m_pConnection;
if (pConnection != NULL)
{
// Validate input
if (!MapEntityList_HasInput(m_pEntityList, pConnection->GetInputName()))
{
return false;
}
// Validate output
CMapEntity *pEntity = pInputConn->m_pEntity;
if (!CEntityConnection::ValidateOutput(pEntity,pConnection->GetOutputName()))
{
return false;
}
}
return true;
}
//------------------------------------------------------------------------------
// Purpose : Updates the validity flag on the given item in the list control
// Input :
// Output :
//------------------------------------------------------------------------------
void COP_Input::UpdateItemValidity(int nItem)
{
int nIcon;
if (ValidateConnections(nItem))
{
nIcon = (m_bMultipleTargetNames ? ICON_CONN_GOOD_GREY : ICON_CONN_GOOD);
}
else
{
nIcon = (m_bMultipleTargetNames ? ICON_CONN_BAD_GREY : ICON_CONN_BAD);
}
m_ListCtrl.SetItem(nItem,0,LVIF_IMAGE, 0, nIcon, 0, 0, 0 );
}
//-----------------------------------------------------------------------------
// Purpose:
// Input : pEntity -
// bFirst -
//-----------------------------------------------------------------------------
void COP_Input::AddEntityConnections(const char *pTargetName, CMapEntity *pTestEntity)
{
int nConnCount = pTestEntity->Connections_GetCount();
if (nConnCount != 0)
{
int nItemCount = m_ListCtrl.GetItemCount();
m_ListCtrl.SetItemCount(nItemCount + nConnCount);
for (int i = 0; i < nConnCount; i++)
{
CEntityConnection *pConnection = pTestEntity->Connections_Get(i);
if (pConnection != NULL && !CompareEntityNames(pConnection->GetTargetName(), pTargetName))
{
// Update source name for correct sorting
const char *pszTestName = pTestEntity->GetKeyValue("targetname");
if (pszTestName == NULL)
{
pszTestName = pTestEntity->GetClassName();
}
pConnection->SetSourceName(pszTestName);
m_ListCtrl.InsertItem(LVIF_IMAGE, nItemCount, "", 0, 0, ICON_CONN_GOOD, 0);
m_ListCtrl.SetItemText(nItemCount, OUTPUT_NAME_COLUMN, pConnection->GetOutputName());
m_ListCtrl.SetItemText(nItemCount, SOURCE_NAME_COLUMN, pConnection->GetSourceName());
m_ListCtrl.SetItemText(nItemCount, INPUT_NAME_COLUMN, pConnection->GetInputName());
// Build the string for the delay.
float fDelay = pConnection->GetDelay();
char szTemp[MAX_PATH];
sprintf(szTemp, "%.2f", fDelay);
m_ListCtrl.SetItemText(nItemCount, DELAY_COLUMN, szTemp);
m_ListCtrl.SetItemText(nItemCount, ONLY_ONCE_COLUMN, (pConnection->GetTimesToFire() == EVENT_FIRE_ALWAYS) ? "No" : "Yes");
m_ListCtrl.SetItemText(nItemCount, PARAMETER_COLUMN, pConnection->GetParam());
// Set list ctrl data
CInputConnection *pInputConn = new CInputConnection;
pInputConn->m_pConnection = pConnection;
pInputConn->m_pEntity = pTestEntity;
m_ListCtrl.SetItemData(nItemCount, (DWORD)pInputConn);
nItemCount++;
}
}
}
}
//-----------------------------------------------------------------------------
// Purpose:
// Input : pDX -
//-----------------------------------------------------------------------------
void COP_Input::DoDataExchange(CDataExchange *pDX)
{
CObjectPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(COP_Input)
DDX_Control(pDX, IDC_LIST, m_ListCtrl);
//}}AFX_DATA_MAP
}
//------------------------------------------------------------------------------
// Purpose : Take the user to the output page of the selected entity that
// targets me.
// Input :
// Output :
//------------------------------------------------------------------------------
void COP_Input::OnMark(void)
{
// This should always be 1 as dialog is set up to be single select
if (m_ListCtrl.GetSelectedCount() == 1)
{
int nCount = m_ListCtrl.GetItemCount();
CMapDoc *pDoc = CMapDoc::GetActiveMapDoc();
if (nCount > 0 && pDoc)
{
for (int nItem = nCount - 1; nItem >= 0; nItem--)
{
if (m_ListCtrl.GetItemState(nItem, LVIS_SELECTED) & LVIS_SELECTED)
{
CInputConnection *pInputConn = (CInputConnection *)m_ListCtrl.GetItemData(nItem);
CMapEntity *pEntity = pInputConn->m_pEntity;
CEntityConnection *pConnection = pInputConn->m_pConnection;
// Shouldn't happen but just in case
if (!pEntity || !pConnection)
{
return;
}
// Switch to object selection mode so we only select the entity.
pDoc->GetSelection()->SetMode(selectObjects);
// Now switch to the output page with the selected connection
CMapObjectList Select;
Select.AddToTail(pEntity);
pDoc->SelectObjectList(&Select);
// (a bit squirly way of doing this)
GetMainWnd()->pObjectProperties->SetPageToOutput(pConnection);
pDoc->Center2DViewsOnSelection();
return;
}
}
}
}
}
//-----------------------------------------------------------------------------
// Purpose: Sets up the list view columns, initial sort column.
//-----------------------------------------------------------------------------
BOOL COP_Input::OnInitDialog(void)
{
CObjectPage::OnInitDialog();
m_ListCtrl.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_HEADERDRAGDROP);
m_ListCtrl.InsertColumn(ICON_COLUMN, "", LVCFMT_CENTER, 20);
m_ListCtrl.InsertColumn(SOURCE_NAME_COLUMN, "Source", LVCFMT_LEFT, 70);
m_ListCtrl.InsertColumn(OUTPUT_NAME_COLUMN, "Output", LVCFMT_LEFT, 70);
m_ListCtrl.InsertColumn(INPUT_NAME_COLUMN, "My Input", LVCFMT_LEFT, 70);
m_ListCtrl.InsertColumn(DELAY_COLUMN, "Delay", LVCFMT_LEFT, 70);
m_ListCtrl.InsertColumn(ONLY_ONCE_COLUMN, "Once", LVCFMT_LEFT, 70);
m_ListCtrl.InsertColumn(PARAMETER_COLUMN, "Parameter", LVCFMT_LEFT, 70);
UpdateConnectionList();
SetSortColumn(m_nSortColumn, m_eSortDirection[m_nSortColumn]);
// Force an update of the column header text so that the sort indicator is shown.
UpdateColumnHeaderText(m_nSortColumn, true, m_eSortDirection[m_nSortColumn]);
if (m_ListCtrl.GetItemCount() > 0)
{
m_ListCtrl.SetColumnWidth(OUTPUT_NAME_COLUMN, LVSCW_AUTOSIZE);
m_ListCtrl.SetColumnWidth(SOURCE_NAME_COLUMN, LVSCW_AUTOSIZE);
m_ListCtrl.SetColumnWidth(INPUT_NAME_COLUMN, LVSCW_AUTOSIZE);
m_ListCtrl.SetColumnWidth(DELAY_COLUMN, LVSCW_AUTOSIZE_USEHEADER);
m_ListCtrl.SetColumnWidth(ONLY_ONCE_COLUMN, LVSCW_AUTOSIZE_USEHEADER);
m_ListCtrl.SetColumnWidth(PARAMETER_COLUMN, LVSCW_AUTOSIZE);
}
// Create image list. Is deleted automatically when listctrl is deleted
if (!m_pImageList)
{
CWinApp *pApp = AfxGetApp();
m_pImageList = new CImageList();
Assert(m_pImageList != NULL); // serious allocation failure checking
m_pImageList->Create(16, 16, TRUE, 1, 0);
m_pImageList->Add(pApp->LoadIcon( IDI_INPUTBAD ));
m_pImageList->Add(pApp->LoadIcon( IDI_INPUT ));
m_pImageList->Add(pApp->LoadIcon( IDI_INPUTBAD_GREY ));
m_pImageList->Add(pApp->LoadIcon( IDI_INPUT_GREY ));
}
m_ListCtrl.SetImageList(m_pImageList, LVSIL_SMALL );
CAnchorDef anchorDefs[] =
{
CAnchorDef( IDC_LIST, k_eSimpleAnchorAllSides ),
CAnchorDef( IDC_MARK, k_eSimpleAnchorBottomSide ),
CAnchorDef( IDC_INFO_TEXT, k_eSimpleAnchorBottomSide )
};
m_AnchorMgr.Init( GetSafeHwnd(), anchorDefs, ARRAYSIZE( anchorDefs ) );
return(TRUE);
}
//-----------------------------------------------------------------------------
// Purpose:
// Input : wParam -
// lParam -
// pResult -
// Output : Returns TRUE on success, FALSE on failure.
//-----------------------------------------------------------------------------
BOOL COP_Input::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT *pResult)
{
NMHDR *pnmh = (NMHDR *)lParam;
if (pnmh->idFrom == IDC_LIST)
{
switch (pnmh->code)
{
case LVN_COLUMNCLICK:
{
NMLISTVIEW *pnmv = (NMLISTVIEW *)lParam;
if (pnmv->iSubItem < OUTPUT_LIST_NUM_COLUMNS)
{
SortDirection_t eSortDirection = m_eSortDirection[pnmv->iSubItem];
//
// If they clicked on the current sort column, reverse the sort direction.
//
if (pnmv->iSubItem == m_nSortColumn)
{
if (m_eSortDirection[m_nSortColumn] == Sort_Ascending)
{
eSortDirection = Sort_Descending;
}
else
{
eSortDirection = Sort_Ascending;
}
}
//
// Update the sort column and sort the list.
//
SetSortColumn(pnmv->iSubItem, eSortDirection);
}
return(TRUE);
}
case NM_DBLCLK:
{
OnMark();
return(TRUE);
}
}
}
return(CObjectPage::OnNotify(wParam, lParam, pResult));
}
//-----------------------------------------------------------------------------
// Purpose: Empties the contents of the connections list control, freeing the
// connection list hanging off of each row.
//-----------------------------------------------------------------------------
void COP_Input::RemoveAllEntityConnections(void)
{
int nCount = m_ListCtrl.GetItemCount();
if (nCount > 0)
{
for (int nItem = nCount - 1; nItem >= 0; nItem--)
{
CInputConnection *pInputConnection = (CInputConnection *)m_ListCtrl.GetItemData(nItem);
m_ListCtrl.DeleteItem(nItem);
delete pInputConnection;
}
}
}
//-----------------------------------------------------------------------------
// Purpose:
// Input : Mode -
// pData -
//-----------------------------------------------------------------------------
void COP_Input::UpdateData( int Mode, PVOID pData, bool bCanEdit )
{
__super::UpdateData( Mode, pData, bCanEdit );
if (!IsWindow(m_hWnd))
{
return;
}
switch (Mode)
{
case LoadFirstData:
{
// m_ListCtrl.DeleteAllItems();
// UpdateConnectionList();
break;
}
case LoadData:
{
// m_ListCtrl.DeleteAllItems();
// UpdateConnectionList();
break;
}
case LoadFinished:
{
m_ListCtrl.DeleteAllItems();
UpdateConnectionList();
SortListByColumn(m_nSortColumn, m_eSortDirection[m_nSortColumn]);
}
}
}
//-----------------------------------------------------------------------------
// Purpose:
// Input : nColumn -
// eDirection -
//-----------------------------------------------------------------------------
void COP_Input::SetSortColumn(int nColumn, SortDirection_t eDirection)
{
Assert(nColumn < OUTPUT_LIST_NUM_COLUMNS);
//
// If the sort column changed, update the old sort column header text.
//
if (m_nSortColumn != nColumn)
{
UpdateColumnHeaderText(m_nSortColumn, false, eDirection);
}
//
// If the sort column or direction changed, update the new sort column header text.
//
if ((m_nSortColumn != nColumn) || (m_eSortDirection[m_nSortColumn] != eDirection))
{
UpdateColumnHeaderText(nColumn, true, eDirection);
}
m_nSortColumn = nColumn;
m_eSortDirection[m_nSortColumn] = eDirection;
SortListByColumn(m_nSortColumn, m_eSortDirection[m_nSortColumn]);
}
//-----------------------------------------------------------------------------
// Purpose: Sorts the outputs list by column.
// Input : nColumn - Index of column by which to sort.
//-----------------------------------------------------------------------------
void COP_Input::SortListByColumn(int nColumn, SortDirection_t eDirection)
{
PFNLVCOMPARE pfnSort = NULL;
switch (nColumn)
{
case ONLY_ONCE_COLUMN:
{
// No sort
break;
}
case PARAMETER_COLUMN:
{
// No sort
break;
}
case OUTPUT_NAME_COLUMN:
{
pfnSort = (PFNLVCOMPARE)InputCompareOutputNames;
break;
}
case SOURCE_NAME_COLUMN:
{
pfnSort = (PFNLVCOMPARE)InputCompareSourceNames;
break;
}
case INPUT_NAME_COLUMN:
{
pfnSort = (PFNLVCOMPARE)InputCompareInputNames;
break;
}
case DELAY_COLUMN:
{
pfnSort = (PFNLVCOMPARE)InputCompareDelays;
break;
}
default:
{
Assert(FALSE);
break;
}
}
if (pfnSort != NULL)
{
m_ListCtrl.SortItems(pfnSort, (DWORD)eDirection);
}
}
//------------------------------------------------------------------------------
// Purpose : Generates list of map entites that are being edited from the
// m_pObject list
// Input :
// Output :
//------------------------------------------------------------------------------
void COP_Input::UpdateEntityList()
{
// Clear old entity list
m_pEntityList->RemoveAll();
if (m_pObjectList != NULL)
{
FOR_EACH_OBJ( *m_pObjectList, pos )
{
CMapClass *pObject = m_pObjectList->Element(pos);
if ((pObject != NULL) && (pObject->IsMapClass(MAPCLASS_TYPE(CMapEntity))))
{
CMapEntity *pEntity = (CMapEntity *)pObject;
m_pEntityList->AddToTail(pEntity);
}
}
}
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void COP_Input::UpdateConnectionList(void)
{
UpdateEntityList();
RemoveAllEntityConnections();
m_bMultipleTargetNames = false;
const char *pszTargetName = NULL;
FOR_EACH_OBJ( *m_pEntityList, pos )
{
CMapEntity *pInEntity = m_pEntityList->Element(pos);
if (!pszTargetName)
{
pszTargetName = pInEntity->GetKeyValue("targetname");
}
else if (pszTargetName != pInEntity->GetKeyValue("targetname"))
{
pszTargetName = pInEntity->GetKeyValue("targetname");
m_bMultipleTargetNames = true;
}
if (pszTargetName)
{
CMapDoc *pDoc = CMapDoc::GetActiveMapDoc();
CMapWorld *pWorld = pDoc->GetMapWorld();
const CMapEntityList *pEntityList = pWorld->EntityList_GetList();
FOR_EACH_OBJ( *pEntityList, pos2 )
{
CMapEntity *pTestEntity = pEntityList->Element(pos2);
if (pTestEntity != NULL)
{
AddEntityConnections(pszTargetName, pTestEntity);
}
}
}
}
// Update validity flag on all items
for (int nItem = 0; nItem < m_ListCtrl.GetItemCount(); nItem++)
{
UpdateItemValidity(nItem);
}
m_ListCtrl.EnableWindow(true);
}
//-----------------------------------------------------------------------------
// Purpose: Adds or removes the little 'V' or '^' sort indicator as appropriate.
// Input : nColumn - Index of column to update.
// bSortColumn - true if this column is the sort column, false if not.
// eDirection - Direction of sort, Sort_Ascending or Sort_Descending.
//-----------------------------------------------------------------------------
void COP_Input::UpdateColumnHeaderText(int nColumn, bool bIsSortColumn, SortDirection_t eDirection)
{
char szHeaderText[MAX_PATH];
LVCOLUMN Column;
memset(&Column, 0, sizeof(Column));
Column.mask = LVCF_TEXT;
Column.pszText = szHeaderText;
Column.cchTextMax = sizeof(szHeaderText);
m_ListCtrl.GetColumn(nColumn, &Column);
int nMarker = 0;
if (szHeaderText[0] != '\0')
{
nMarker = strlen(szHeaderText) - 1;
char chMarker = szHeaderText[nMarker];
if ((chMarker == '>') || (chMarker == '<'))
{
nMarker -= 2;
}
else
{
nMarker++;
}
}
if (bIsSortColumn)
{
if (nMarker != 0)
{
szHeaderText[nMarker++] = ' ';
szHeaderText[nMarker++] = ' ';
}
szHeaderText[nMarker++] = (eDirection == Sort_Ascending) ? '>' : '<';
}
szHeaderText[nMarker] = '\0';
m_ListCtrl.SetColumn(nColumn, &Column);
}
//-----------------------------------------------------------------------------
// Purpose: Called when our window is being destroyed.
//-----------------------------------------------------------------------------
void COP_Input::OnDestroy(void)
{
RemoveAllEntityConnections();
}
//------------------------------------------------------------------------------
// Purpose: Set the selected item in the listbox
// Input : pConnection
//------------------------------------------------------------------------------
void COP_Input::SetSelectedConnection(CEntityConnection *pConnection)
{
m_ListCtrl.SetRedraw(FALSE);
// Set selected item to be active and all others to false
int nItemCount = m_ListCtrl.GetItemCount();
for (int nItem = 0; nItem < nItemCount; nItem++)
{
CInputConnection *pOutputConn = (CInputConnection *)m_ListCtrl.GetItemData(nItem);
if ( pOutputConn->m_pConnection == pConnection)
{
m_ListCtrl.SetItemState(nItem,LVIS_SELECTED,LVIS_SELECTED);
}
else
{
m_ListCtrl.SetItemState(nItem, (unsigned int)~LVIS_SELECTED, (unsigned int)LVIS_SELECTED);
}
}
m_ListCtrl.SetRedraw(TRUE);
}
void COP_Input::OnSize( UINT nType, int cx, int cy )
{
m_AnchorMgr.OnSize();
}
|