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
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================//
#include "cbase.h"
#include <windows.h>
#include "resource.h"
#include "vcdbrowser.h"
#include "SoundEmitterSystem/isoundemittersystembase.h"
#include "filesystem.h"
#include "tabwindow.h"
#include "inputproperties.h"
#include "choreowidgetdrawhelper.h"
#include "UtlBuffer.h"
#include "ChoreoEvent.h"
#include "ChoreoView.h"
CVCDBrowser *g_pVCDBrowser = NULL;
enum
{
// Controls
IDC_VB_LISTVIEW = 101,
IDC_VB_FILETREE,
// Messages
IDC_VB_OPENVCD = 1000,
};
enum
{
COL_VCD = 0,
};
class CVCDList : public mxListView
{
public:
CVCDList( mxWindow *parent, int id = 0 )
: mxListView( parent, 0, 0, 0, 0, id )
{
// Add column headers
insertTextColumn( COL_VCD, 700, "VCD" );
}
};
class CUtlSymbolTree : public mxTreeView
{
public:
CUtlSymbolTree( mxWindow *parent, int id = 0 ) : mxTreeView( parent, 0, 0, 0, 0, id ),
m_Paths( 0, 0, FileTreeLessFunc )
{
}
void Clear()
{
removeAll();
m_Paths.RemoveAll();
}
void FindOrAddSubdirectory( char const *subdir )
{
FileTreePath fp;
Q_strcpy( fp.path, subdir );
if ( m_Paths.Find( fp ) != m_Paths.InvalidIndex() )
return;
m_Paths.Insert( fp );
}
mxTreeViewItem *FindOrAddChildItem( mxTreeViewItem *parent, char const *child )
{
mxTreeViewItem *p = getFirstChild( parent );
if ( !p )
{
return add( parent, child );
}
while ( p )
{
if ( !Q_stricmp( getLabel( p ), child ) )
return p;
p = getNextChild( p );
}
return add( parent, child );
}
void _PopulateTree( int pathId, char const *path )
{
char sz[ 512 ];
Q_strcpy( sz, path );
char *p = sz;
// Start at root
mxTreeViewItem *cur = NULL;
// Tokenize path
while ( p && p[0] )
{
char *slash = Q_strstr( p, "/" );
if ( !slash )
{
slash = Q_strstr( p, "\\" );
}
char *check = p;
if ( slash )
{
*slash = 0;
// see if a child of current already exists with this name
p = slash + 1;
}
else
{
p = NULL;
}
Assert( check );
cur = FindOrAddChildItem( cur, check );
}
setUserData( cur, (void *)pathId );
}
char const *GetSelectedPath( void )
{
mxTreeViewItem *tvi = getSelectedItem();
unsigned int id = (unsigned int)getUserData( tvi );
if ( id < 0 || id >= m_Paths.Count() )
{
Assert( 0 );
return "";
}
return m_Paths[ id ].path;
}
void PopulateTree()
{
int i;
for ( i = m_Paths.FirstInorder(); i != m_Paths.InvalidIndex(); i = m_Paths.NextInorder( i ) )
{
_PopulateTree( i, m_Paths[ i ].path );
}
mxTreeViewItem *p = getFirstChild( NULL );
setOpen( p, true );
}
struct FileTreePath
{
char path[ MAX_PATH ];
};
static bool FileTreeLessFunc( const FileTreePath &lhs, const FileTreePath &rhs )
{
return Q_stricmp( lhs.path, rhs.path ) < 0;
}
CUtlRBTree< FileTreePath, int > m_Paths;
};
#pragma optimize( "", off )
class CVCDOptionsWindow : public mxWindow
{
typedef mxWindow BaseClass;
public:
enum
{
IDC_OPENFILE = 1000,
IDC_SEARCH,
IDC_CANCELSEARCH,
};
CVCDOptionsWindow( CVCDBrowser *browser ) : BaseClass( browser, 0, 0, 0, 0 ), m_pBrowser( browser )
{
FacePoser_AddWindowStyle( this, WS_CLIPSIBLINGS | WS_CLIPCHILDREN );
m_szSearchString[0]=0;
m_pOpen = new mxButton( this, 0, 0, 0, 0, "Open", IDC_OPENFILE );
m_pSearch = new mxLineEdit( this, 0, 0, 0, 0, "", IDC_SEARCH );
m_pCancelSearch = new mxButton( this, 0, 0, 0, 0, "Cancel", IDC_CANCELSEARCH );
}
bool PaintBackground( void )
{
redraw();
return false;
}
virtual void redraw()
{
CChoreoWidgetDrawHelper drawHelper( this, GetSysColor( COLOR_BTNFACE ) );
}
virtual int handleEvent( mxEvent *event )
{
int iret = 0;
switch ( event->event )
{
default:
break;
case mxEvent::Size:
{
iret = 1;
int split = 120;
int x = 1;
m_pOpen->setBounds( x, 1, split, h2() - 2 );
x += split + 10;
m_pCancelSearch->setBounds( x, 1, split, h2() - 2 );
x += split + 10;
m_pSearch->setBounds( x, 0, split * 3, h2() - 1 );
x += split * 3 + 10;
}
break;
case mxEvent::KeyDown:
switch ( event->action )
{
default:
break;
case IDC_SEARCH:
{
if ( event->event == mxEvent::KeyDown )
{
OnSearch();
}
iret = 1;
};
break;
}
break;
case mxEvent::Action:
{
switch ( event->action )
{
case IDC_SEARCH:
iret = 1;
break;
case IDC_OPENFILE:
{
iret = 1;
m_pBrowser->OnOpen();
}
break;
case IDC_CANCELSEARCH:
{
iret = 1;
OnCancelSearch();
}
break;
default:
break;
}
}
break;
}
return iret;
}
char const *GetSearchString()
{
return m_szSearchString;
}
void OnSearch()
{
m_pSearch->getText( m_szSearchString, sizeof( m_szSearchString ) );
m_pBrowser->OnSearch();
}
void OnCancelSearch()
{
m_szSearchString[ 0 ] = 0;
m_pSearch->clear();
m_pBrowser->OnCancelSearch();
}
private:
mxButton *m_pOpen;
mxLineEdit *m_pSearch;
mxButton *m_pCancelSearch;
CVCDBrowser *m_pBrowser;
char m_szSearchString[ 256 ];
};
#pragma optimize( "", on )
//-----------------------------------------------------------------------------
// Purpose:
// Input : *parent -
//-----------------------------------------------------------------------------
CVCDBrowser::CVCDBrowser( mxWindow *parent )
: IFacePoserToolWindow( "VCDBrowser", "VCDs" ), mxWindow( parent, 0, 0, 0, 0 )
{
SetAutoProcess( false );
m_bTextSearch = false;
m_nPrevProcessed = -1;
m_pListView = new CVCDList( this, IDC_VB_LISTVIEW );
m_pOptions = new CVCDOptionsWindow( this );
m_pFileTree = new CUtlSymbolTree( this, IDC_VB_FILETREE );
//HIMAGELIST list = CreateImageList();
// Associate the image list with the tree-view control.
//m_pListView->setImageList( (void *)list );
LoadAllSounds();
PopulateTree( NULL );
}
#define CX_ICON 16
#define CY_ICON 16
HIMAGELIST CVCDBrowser::CreateImageList()
{
HIMAGELIST list;
list = ImageList_Create( CX_ICON, CY_ICON,
FALSE, VCD_NUM_IMAGES, 0 );
// Load the icon resources, and add the icons to the image list.
HICON hicon;
int slot;
#if defined( DBGFLAG_ASSERT )
int c = 0;
#endif
hicon = LoadIcon(GetModuleHandle( 0 ), MAKEINTRESOURCE(IDI_VCD));
slot = ImageList_AddIcon(list, hicon);
Assert( slot == c++ );
DeleteObject( hicon );
return list;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CVCDBrowser::OnDelete()
{
RemoveAllSounds();
}
//-----------------------------------------------------------------------------
// Purpose:
// Input : *event -
// Output : int
//-----------------------------------------------------------------------------
int CVCDBrowser::handleEvent( mxEvent *event )
{
int iret = 0;
if ( HandleToolEvent( event ) )
{
return iret;
}
switch ( event->event )
{
default:
break;
case mxEvent::Action:
{
iret = 1;
switch ( event->action )
{
default:
{
iret = 0;
}
break;
case IDC_VB_LISTVIEW:
{
SetActiveTool( this );
bool rightmouse = ( event->flags == mxEvent::RightClicked ) ? true : false;
bool doubleclicked = ( event->flags == mxEvent::DoubleClicked ) ? true : false;
if ( rightmouse )
{
ShowContextMenu();
}
else if ( doubleclicked )
{
if ( m_pListView->getNumSelected() == 1 )
{
int index = m_pListView->getNextSelectedItem( -1 );
if ( index >= 0 )
{
FileNameHandle_t vcd = (FileNameHandle_t)m_pListView->getUserData( index, 0 );
OpenVCD( vcd );
}
}
}
}
break;
case IDC_VB_FILETREE:
{
SetActiveTool( this );
PopulateTree( m_pFileTree->GetSelectedPath() );
}
break;
case IDC_VB_OPENVCD:
{
OnOpen();
}
break;
}
}
break;
case mxEvent::Size:
{
int optionsh = 20;
m_pOptions->setBounds( 0, 0, w2(), optionsh );
int filetreewidth = 175;
m_pFileTree->setBounds( 0, optionsh, filetreewidth, h2() - optionsh );
m_pListView->setBounds( filetreewidth, optionsh, w2() - filetreewidth, h2() - optionsh );
iret = 1;
}
break;
case mxEvent::Close:
{
iret = 1;
}
break;
}
return iret;
}
bool CVCDBrowser::CNameLessFunc::Less( const FileNameHandle_t &name1, const FileNameHandle_t &name2, void *pContext )
{
if ( name1 < name2 )
return true;
return false;
}
void CVCDBrowser::OpenVCD( const FileNameHandle_t& handle )
{
char fn[ 512 ];
if ( filesystem->String( handle, fn, sizeof( fn ) ) )
{
char pFullPath[MAX_PATH];
const char *pFileName = filesystem->RelativePathToFullPath( fn, "GAME", pFullPath, sizeof(pFullPath) );
if ( !pFileName )
{
pFileName = fn;
}
g_pChoreoView->LoadSceneFromFile( pFileName );
}
}
#define SCENES_PREFIX_LEN 0
//-----------------------------------------------------------------------------
// Finds all .vcd files in a particular directory
//-----------------------------------------------------------------------------
bool CVCDBrowser::LoadVCDsFilesInDirectory( CUtlSortVector< FileNameHandle_t, CNameLessFunc >& soundlist, char const* pDirectoryName, int nDirectoryNameLen )
{
char *pWildCard;
pWildCard = ( char * )stackalloc( nDirectoryNameLen + 7 );
Q_snprintf( pWildCard, nDirectoryNameLen + 7, "%s/*.vcd", pDirectoryName );
if ( !filesystem )
{
return false;
}
FileFindHandle_t findHandle;
const char *pFileName = filesystem->FindFirst( pWildCard, &findHandle );
while( pFileName )
{
if( !filesystem->FindIsDirectory( findHandle ) )
{
// Strip off the 'sound/' part of the name.
char *pFileNameWithPath;
int nAllocSize = nDirectoryNameLen + Q_strlen(pFileName) + 2;
pFileNameWithPath = (char *)stackalloc( nAllocSize );
Q_snprintf( pFileNameWithPath, nAllocSize, "%s/%s", &pDirectoryName[ SCENES_PREFIX_LEN ], pFileName );
Q_strnlwr( pFileNameWithPath, nAllocSize );
FileNameHandle_t vcd;
vcd = filesystem->FindOrAddFileName( pFileNameWithPath );
soundlist.InsertNoSort( vcd );
}
pFileName = filesystem->FindNext( findHandle );
}
m_pFileTree->FindOrAddSubdirectory( &pDirectoryName[ SCENES_PREFIX_LEN ] );
filesystem->FindClose( findHandle );
return true;
}
bool CVCDBrowser::InitDirectoryRecursive( CUtlSortVector< FileNameHandle_t, CNameLessFunc >& soundlist, char const* pDirectoryName )
{
// Compute directory name length
int nDirectoryNameLen = Q_strlen( pDirectoryName );
if (!LoadVCDsFilesInDirectory( soundlist, pDirectoryName, nDirectoryNameLen ) )
return false;
char *pWildCard = ( char * )stackalloc( nDirectoryNameLen + 4 );
strcpy(pWildCard, pDirectoryName);
strcat(pWildCard, "/*.");
int nPathStrLen = nDirectoryNameLen + 1;
FileFindHandle_t findHandle;
const char *pFileName = filesystem->FindFirst( pWildCard, &findHandle );
while( pFileName )
{
if ((pFileName[0] != '.') || (pFileName[1] != '.' && pFileName[1] != 0))
{
if( filesystem->FindIsDirectory( findHandle ) )
{
int fileNameStrLen = Q_strlen( pFileName );
char *pFileNameWithPath = ( char * )stackalloc( nPathStrLen + fileNameStrLen + 1 );
memcpy( pFileNameWithPath, pWildCard, nPathStrLen );
pFileNameWithPath[nPathStrLen] = '\0';
strcat( pFileNameWithPath, pFileName );
if (!InitDirectoryRecursive( soundlist, pFileNameWithPath ))
return false;
}
}
pFileName = filesystem->FindNext( findHandle );
}
return true;
}
void CVCDBrowser::LoadAllSounds()
{
RemoveAllSounds();
Con_Printf( "Building list of all .vcds in sound/ folder\n" );
InitDirectoryRecursive( m_AllVCDs, "scenes" );
m_AllVCDs.RedoSort();
m_pFileTree->PopulateTree();
}
void CVCDBrowser::RemoveAllSounds()
{
m_AllVCDs.Purge();
m_Scripts.RemoveAll();
m_CurrentSelection.RemoveAll();
m_pFileTree->Clear();
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CVCDBrowser::PopulateTree( char const *subdirectory )
{
char subdir[ 512 ];
subdir[ 0 ] = 0;
int i;
CUtlSortVector< FileNameHandle_t, CNameLessFunc > sorted( 0, 0 );
char const *texttofind = NULL;
if ( m_bTextSearch )
{
subdirectory = NULL;
texttofind = GetSearchString();
}
int len = 0;
if ( subdirectory )
{
len = Q_strlen( subdirectory );
Q_strncpy( subdir, subdirectory, sizeof( subdir ) );
Q_strlower( subdir );
Q_FixSlashes( subdir );
}
int c = m_AllVCDs.Count();
for ( i = 0; i < c; i++ )
{
const FileNameHandle_t &vcd = m_AllVCDs[ i ];
char name[ 512 ];
if ( !filesystem->String( vcd, name, sizeof( name ) ) )
continue;
if ( subdirectory )
{
if ( Q_strnicmp( subdir, name, len ) )
continue;
}
if ( m_bTextSearch && texttofind )
{
if ( !Q_stristr( name, texttofind ) )
continue;
}
sorted.InsertNoSort( vcd );
}
sorted.RedoSort();
char prevSelectedName[ 512 ];
prevSelectedName[ 0 ] = 0;
if ( m_pListView->getNumSelected() == 1 )
{
int selectedItem = m_pListView->getNextSelectedItem( 0 );
if ( selectedItem >= 0 )
{
// Grab name of previously selected item
Q_strcpy( prevSelectedName, m_pListView->getLabel( selectedItem, 0 ) );
}
}
// Repopulate tree
m_pListView->removeAll();
int loadcount = 0;
m_pListView->setDrawingEnabled( false );
int selectedSlot = -1;
for ( i = 0; i < sorted.Count(); ++i )
{
const FileNameHandle_t &vcd = sorted[ i ];
char name[ 512 ];
if ( !filesystem->String( vcd, name, sizeof( name ) ) )
continue;
int slot = m_pListView->add( name );
m_pListView->setUserData( slot, COL_VCD, (void *)vcd );
if ( !Q_stricmp( prevSelectedName, name ) )
{
selectedSlot = slot;
}
++loadcount;
}
m_pListView->setDrawingEnabled( true );
if ( selectedSlot != -1 )
{
m_pListView->setSelected( selectedSlot, true );
m_pListView->scrollToItem( selectedSlot );
}
}
void CVCDBrowser::RepopulateTree()
{
PopulateTree( m_pFileTree->GetSelectedPath() );
}
void CVCDBrowser::BuildSelectionList( CUtlVector< FileNameHandle_t >& selected )
{
selected.RemoveAll();
int idx = -1;
do
{
idx = m_pListView->getNextSelectedItem( idx );
if ( idx != -1 )
{
FileNameHandle_t vcd = (FileNameHandle_t)m_pListView->getUserData( idx, 0 );
selected.AddToTail( vcd );
}
} while ( idx != -1 );
}
void CVCDBrowser::ShowContextMenu( void )
{
SetActiveTool( this );
BuildSelectionList( m_CurrentSelection );
if ( m_CurrentSelection.Count() <= 0 )
return;
POINT pt;
GetCursorPos( &pt );
ScreenToClient( (HWND)getHandle(), &pt );
mxPopupMenu *pop = new mxPopupMenu();
if ( m_CurrentSelection.Count() == 1 && m_CurrentSelection[ 0 ] )
{
char sz[ 512 ];
char name[ 512 ];
if ( filesystem->String( m_CurrentSelection[ 0 ], name, sizeof( name ) ) )
{
Q_snprintf( sz, sizeof( sz ), "&Open '%s'", name );
pop->add ( sz, IDC_VB_OPENVCD );
}
}
pop->popup( this, pt.x, pt.y );
}
void CVCDBrowser::OnOpen()
{
SetActiveTool( this );
BuildSelectionList( m_CurrentSelection );
if ( m_CurrentSelection.Count() == 1 )
{
FileNameHandle_t& vcd = m_CurrentSelection[ 0 ];
OpenVCD( vcd );
}
}
static void SplitFileName( char const *in, char *path, int maxpath, char *filename, int maxfilename )
{
char drive[_MAX_DRIVE];
char dir[_MAX_DIR];
char fname[_MAX_FNAME];
char ext[_MAX_EXT];
_splitpath( in, drive, dir, fname, ext );
if ( dir[0] )
{
Q_snprintf( path, maxpath, "\\%s", dir );
}
else
{
path[0] = 0;
}
Q_snprintf( filename, maxfilename, "%s%s", fname, ext );
}
//-----------------------------------------------------------------------------
// Purpose:
// Input : *se -
//-----------------------------------------------------------------------------
void CVCDBrowser::JumpToItem( const FileNameHandle_t& vcd )
{
SetActiveTool( this );
char path[ 256 ];
char filename[ 256 ];
char vcdfile[ 512 ];
if ( !filesystem->String( vcd, vcdfile, sizeof( vcdfile ) ) )
return;
SplitFileName( vcdfile, path, sizeof( path ), filename, sizeof( filename ) );
char *usepath = path + Q_strlen( "/scenes/" );
PopulateTree( usepath );
int idx = 0;
int c = m_pListView->getItemCount();
for ( ; idx < c; idx++ )
{
FileNameHandle_t item = (FileNameHandle_t)m_pListView->getUserData( idx, 0 );
if ( item == vcd )
{
break;
}
}
if ( idx < c )
{
m_pListView->scrollToItem( idx );
}
}
int CVCDBrowser::GetVCDCount() const
{
return m_AllVCDs.Count();
}
FileNameHandle_t CVCDBrowser::GetVCD( int index )
{
if ( index < 0 || index >= (int)m_AllVCDs.Count() )
return NULL;
return m_AllVCDs[ index ];
}
void CVCDBrowser::OnSearch()
{
if ( !GetSearchString()[ 0 ] )
{
OnCancelSearch();
return;
}
SetActiveTool( this );
m_bTextSearch = true;
PopulateTree( GetSearchString());
}
void CVCDBrowser::OnCancelSearch()
{
SetActiveTool( this );
m_bTextSearch = false;
PopulateTree( m_pFileTree->GetSelectedPath() );
}
char const *CVCDBrowser::GetSearchString()
{
return m_pOptions->GetSearchString();
}
void CVCDBrowser::SetCurrent( char const *filename )
{
// Get sound name and look up .vcd from it
char const *p = filename;
if ( p &&
( !Q_strnicmp( p, "sound/", 6 ) || !Q_strnicmp( p, "sound\\", 6 ) ) )
{
p += 6;
}
char fn[ 512 ];
Q_strncpy( fn, p, sizeof( fn ) );
Q_FixSlashes( fn );
int i;
int c = m_pListView->getItemCount();
for ( i = 0; i < c; ++i )
{
FileNameHandle_t vcd = (FileNameHandle_t)( m_pListView->getUserData( i, COL_VCD ) );
char fixed[ 512 ];
if ( !filesystem->String( vcd, fixed, sizeof( fixed ) ) )
continue;
Q_FixSlashes( fixed );
if ( !Q_stricmp( fixed, fn ) )
{
m_pListView->scrollToItem( i );
m_pListView->setSelected( i, true );
}
else
{
m_pListView->setSelected( i, false );
}
}
}
|