Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

616 lines
18 KiB

  1. //====== Copyright � 1996-2005, Valve Corporation, All rights reserved. =======//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. #include "dme_controls/filelistmanager.h"
  9. #include "vgui_controls/FileOpenDialog.h"
  10. #include "vgui_controls/menu.h"
  11. #include "vgui_controls/messagebox.h"
  12. #include "datamodel/idatamodel.h"
  13. #include "datamodel/dmelement.h"
  14. #include "datamodel/dmattribute.h"
  15. #include "datamodel/dmattributevar.h"
  16. #include "vgui/ISurface.h"
  17. #include <vgui/IInput.h>
  18. #include "vgui/mousecode.h"
  19. #include "tier1/strtools.h"
  20. #include "tier1/KeyValues.h"
  21. #include "tier2/tier2.h"
  22. #include "p4lib/ip4.h"
  23. #include "filesystem.h"
  24. #include "dme_controls/INotifyUI.h"
  25. // memdbgon must be the last include file in a .cpp file!!!
  26. #include "tier0/memdbgon.h"
  27. template < int C >
  28. int ListPanelStringSortFunc( vgui::ListPanel *pPanel, const vgui::ListPanelItem &item1, const vgui::ListPanelItem &item2 );
  29. struct ColumnInfo_t
  30. {
  31. char const *columnName;
  32. char const *columnText;
  33. int startingWidth;
  34. int flags;
  35. vgui::SortFunc *pfnSort;
  36. vgui::Label::Alignment alignment;
  37. };
  38. enum ColumnIndex_t
  39. {
  40. CI_FILENAME,
  41. CI_PATH,
  42. CI_LOADED,
  43. CI_NUMELEMENTS,
  44. CI_CHANGED,
  45. CI_INPERFORCE,
  46. CI_OPENFOREDIT,
  47. };
  48. const int baseflags = vgui::ListPanel::COLUMN_UNHIDABLE;
  49. const int fixedflags = vgui::ListPanel::COLUMN_UNHIDABLE | vgui::ListPanel::COLUMN_FIXEDSIZE;
  50. static ColumnInfo_t g_ColInfo[] =
  51. {
  52. { "filename", "#BxFileManager_Filename", 150, baseflags, ListPanelStringSortFunc< CI_FILENAME >, vgui::Label::a_west },
  53. { "path", "#BxFileManager_Path", 240, baseflags, ListPanelStringSortFunc< CI_PATH >, vgui::Label::a_west },
  54. { "loaded", "#BxFileManager_Loaded", 40, fixedflags, ListPanelStringSortFunc< CI_LOADED >, vgui::Label::a_center },
  55. { "numelements", "#BxFileManager_NumElements", 60, fixedflags, ListPanelStringSortFunc< CI_NUMELEMENTS >, vgui::Label::a_east },
  56. { "changed", "#BxFileManager_Changed", 50, fixedflags, ListPanelStringSortFunc< CI_CHANGED >, vgui::Label::a_center },
  57. { "in_perforce", "#BxFileManager_P4Exists", 35, fixedflags, ListPanelStringSortFunc< CI_INPERFORCE >, vgui::Label::a_center },
  58. { "open_for_edit", "#BxFileManager_P4Edit", 40, fixedflags, ListPanelStringSortFunc< CI_OPENFOREDIT >, vgui::Label::a_center },
  59. };
  60. const char *GetKey( ColumnIndex_t ci )
  61. {
  62. return g_ColInfo[ ci ].columnName;
  63. }
  64. template < int C >
  65. int ListPanelStringSortFunc( vgui::ListPanel *pPanel, const vgui::ListPanelItem &item1, const vgui::ListPanelItem &item2 )
  66. {
  67. NOTE_UNUSED( pPanel );
  68. const char *pKey = GetKey( ( ColumnIndex_t )C );
  69. const char *string1 = item1.kv->GetString( pKey );
  70. const char *string2 = item2.kv->GetString( pKey );
  71. return Q_stricmp( string1, string2 );
  72. }
  73. void AddColumn( CFileListManager *pFileManager, ColumnIndex_t ci )
  74. {
  75. pFileManager->AddColumnHeader( ci, g_ColInfo[ ci ].columnName, g_ColInfo[ ci ].columnText, g_ColInfo[ ci ].startingWidth, g_ColInfo[ ci ].flags );
  76. pFileManager->SetSortFunc( ci, g_ColInfo[ ci ].pfnSort );
  77. pFileManager->SetColumnTextAlignment( ci, g_ColInfo[ ci ].alignment );
  78. }
  79. CFileListManager::CFileListManager( vgui::Panel *parent ) : BaseClass( parent, "FileListManager" )
  80. {
  81. SetMultiselectEnabled( true );
  82. SetVisible( true );
  83. m_bRefreshRequired = false;
  84. SetSize( 800, 200 );
  85. SetPos( 100, 100 );
  86. AddColumn( this, CI_FILENAME );
  87. AddColumn( this, CI_PATH );
  88. AddColumn( this, CI_LOADED );
  89. AddColumn( this, CI_NUMELEMENTS );
  90. AddColumn( this, CI_CHANGED );
  91. AddColumn( this, CI_INPERFORCE );
  92. AddColumn( this, CI_OPENFOREDIT );
  93. SetSortColumn( 0 );
  94. Refresh();
  95. SetScheme( vgui::scheme()->LoadSchemeFromFile( "Resource/BoxRocket.res", "BoxRocket" ) );
  96. // LoadControlSettings( "resource/BxFileListManager.res" );
  97. }
  98. int CFileListManager::AddItem( DmFileId_t fileid, const char *pFilename, const char *pPath, bool bLoaded, int nElements, bool bChanged, bool bInPerforce, bool bOpenForEdit )
  99. {
  100. KeyValues *kv = new KeyValues( "", GetKey( CI_FILENAME ), pFilename, GetKey( CI_PATH ), pPath );
  101. kv->SetInt ( GetKey( CI_NUMELEMENTS ), nElements );
  102. kv->SetString( GetKey( CI_LOADED ), bLoaded ? "Y" : "N" );
  103. kv->SetString( GetKey( CI_CHANGED ), bChanged ? "Y" : "N" );
  104. kv->SetString( GetKey( CI_INPERFORCE ), bInPerforce ? "Y" : "N" );
  105. kv->SetString( GetKey( CI_OPENFOREDIT ), bOpenForEdit ? "Y" : "N" );
  106. int itemID = BaseClass::AddItem( kv, fileid, false, false );
  107. kv->deleteThis();
  108. return itemID;
  109. }
  110. void CFileListManager::SetLoaded( DmFileId_t fileid, bool bLoaded )
  111. {
  112. CNotifyScopeGuard notify( "CFileListManager::SetLoaded", NOTIFY_SOURCE_FILE_LIST_MANAGER, NOTIFY_SETDIRTYFLAG );
  113. if ( bLoaded )
  114. {
  115. const char *pFilename = g_pDataModel->GetFileName( fileid );
  116. Assert( pFilename );
  117. if ( !pFilename )
  118. return;
  119. CDisableUndoScopeGuard guard;
  120. CDmElement *pRoot = NULL;
  121. g_pDataModel->RestoreFromFile( pFilename, NULL, NULL, &pRoot, CR_DELETE_NEW );
  122. }
  123. else
  124. {
  125. CDisableUndoScopeGuard guard;
  126. g_pDataModel->UnloadFile( fileid );
  127. }
  128. }
  129. void CFileListManager::OnMousePressed( vgui::MouseCode code )
  130. {
  131. // determine where we were pressed
  132. int x, y, row, column;
  133. vgui::input()->GetCursorPos( x, y );
  134. GetCellAtPos( x, y, row, column );
  135. if ( code == MOUSE_LEFT )
  136. {
  137. bool bIsFakeToggleButton = column == CI_LOADED;
  138. if ( bIsFakeToggleButton && row >= 0 && row < GetItemCount() )
  139. {
  140. int itemID = GetItemIDFromRow( row );
  141. KeyValues *kv = GetItem( itemID );
  142. const char *pStr = kv->GetString( GetKey( ( ColumnIndex_t )column ), "" );
  143. Assert( *pStr == 'Y' || *pStr == 'N' );
  144. bool bSet = *pStr == 'N'; // bSet is the NEW state, not the old one
  145. kv->SetString( GetKey( ( ColumnIndex_t )column ), bSet ? "Y" : "N" );
  146. SetLoaded( ( DmFileId_t )GetItemUserData( itemID ), bSet );
  147. // get the key focus
  148. RequestFocus();
  149. return;
  150. }
  151. }
  152. else if ( code == MOUSE_RIGHT )
  153. {
  154. int itemID = -1;
  155. if ( row >= 0 && row < GetItemCount() )
  156. {
  157. itemID = GetItemIDFromRow( row );
  158. if ( !IsItemSelected( itemID ) )
  159. {
  160. SetSingleSelectedItem( itemID );
  161. }
  162. }
  163. KeyValues *kv = new KeyValues( "OpenContextMenu", "itemID", itemID );
  164. OnOpenContextMenu( kv );
  165. kv->deleteThis();
  166. return;
  167. }
  168. BaseClass::OnMousePressed( code );
  169. }
  170. int AddMenuItemHelper( vgui::Menu *pMenu, const char *pItemName, const char *pKVName, vgui::Panel *pTarget, bool bEnabled )
  171. {
  172. int id = pMenu->AddMenuItem( pItemName, new KeyValues( pKVName ), pTarget );
  173. pMenu->SetItemEnabled( id, bEnabled );
  174. return id;
  175. }
  176. void CFileListManager::OnOpenContextMenu( KeyValues *pParams )
  177. {
  178. if ( m_hContextMenu.Get() )
  179. {
  180. delete m_hContextMenu.Get();
  181. m_hContextMenu = NULL;
  182. }
  183. m_hContextMenu = new vgui::Menu( this, "ContextMenu" );
  184. int itemID = pParams->GetInt( "itemID", -1 );
  185. if ( itemID < 0 )
  186. {
  187. AddMenuItemHelper( m_hContextMenu, "Open File...", "open", this, true ); // Is this how we should load other files???
  188. }
  189. else
  190. {
  191. bool bP4Connected = p4->IsConnectedToServer();
  192. int nSelected = GetSelectedItemsCount();
  193. int nLoaded = 0;
  194. int nChanged = 0;
  195. int nOnDisk = 0;
  196. int nInPerforce = 0;
  197. int nOpenForEdit = 0;
  198. for ( int i = 0; i < nSelected; ++i )
  199. {
  200. int itemId = GetSelectedItem( i );
  201. DmFileId_t fileid = ( DmFileId_t )GetItemUserData( itemId );
  202. if ( g_pDataModel->IsFileLoaded( fileid ) )
  203. {
  204. ++nLoaded;
  205. ++nChanged; // TODO - find out for real
  206. }
  207. const char *pFilename = g_pDataModel->GetFileName( fileid );
  208. if ( g_pFullFileSystem->FileExists( pFilename ) )
  209. {
  210. ++nOnDisk;
  211. }
  212. if ( bP4Connected )
  213. {
  214. if ( p4->IsFileInPerforce( pFilename ) )
  215. {
  216. ++nInPerforce;
  217. if ( p4->GetFileState( pFilename ) != P4FILE_UNOPENED )
  218. {
  219. ++nOpenForEdit;
  220. }
  221. }
  222. }
  223. }
  224. AddMenuItemHelper( m_hContextMenu, "Load", "load", this, nLoaded < nSelected && nOnDisk > 0 );
  225. AddMenuItemHelper( m_hContextMenu, "Unload", "unload", this, nLoaded > 0 );
  226. AddMenuItemHelper( m_hContextMenu, "Save", "save", this, nChanged > 0 && nOnDisk == nSelected );
  227. AddMenuItemHelper( m_hContextMenu, "Save As...", "saveas", this, nLoaded == 1 && nSelected == 1 );
  228. AddMenuItemHelper( m_hContextMenu, "Add To Perforce", "p4add", this, nInPerforce < nSelected && nOnDisk > 0 );
  229. AddMenuItemHelper( m_hContextMenu, "Open For Edit", "p4edit", this, nOpenForEdit < nSelected && nOnDisk > 0 );
  230. }
  231. vgui::Menu::PlaceContextMenu( this, m_hContextMenu.Get() );
  232. }
  233. void CFileListManager::OnLoadFiles( KeyValues *pParams )
  234. {
  235. CNotifyScopeGuard notify( "CFileListManager::OnLoadFiles", NOTIFY_SOURCE_FILE_LIST_MANAGER, NOTIFY_SETDIRTYFLAG );
  236. int nSelected = GetSelectedItemsCount();
  237. for ( int i = 0; i < nSelected; ++i )
  238. {
  239. int itemId = GetSelectedItem( i );
  240. DmFileId_t fileid = ( DmFileId_t )GetItemUserData( itemId );
  241. if ( !g_pDataModel->IsFileLoaded( fileid ) )
  242. {
  243. SetLoaded( fileid, true );
  244. }
  245. }
  246. Refresh();
  247. }
  248. void CFileListManager::OnUnloadFiles( KeyValues *pParams )
  249. {
  250. CNotifyScopeGuard notify( "CFileListManager::OnUnloadFiles", NOTIFY_SOURCE_FILE_LIST_MANAGER, NOTIFY_SETDIRTYFLAG );
  251. int nSelected = GetSelectedItemsCount();
  252. for ( int i = 0; i < nSelected; ++i )
  253. {
  254. int itemId = GetSelectedItem( i );
  255. DmFileId_t fileid = ( DmFileId_t )GetItemUserData( itemId );
  256. if ( g_pDataModel->IsFileLoaded( fileid ) )
  257. {
  258. SetLoaded( fileid, false );
  259. }
  260. }
  261. Refresh();
  262. }
  263. void CFileListManager::OnSaveFiles( KeyValues *pParams )
  264. {
  265. int nSelected = GetSelectedItemsCount();
  266. for ( int i = 0; i < nSelected; ++i )
  267. {
  268. int itemId = GetSelectedItem( i );
  269. DmFileId_t fileid = ( DmFileId_t )GetItemUserData( itemId );
  270. if ( !g_pDataModel->IsFileLoaded( fileid ) )
  271. continue;
  272. const char *pFilename = g_pDataModel->GetFileName( fileid );
  273. Assert( pFilename );
  274. if ( !pFilename )
  275. continue;
  276. CDmElement *pRoot = GetElement< CDmElement >( g_pDataModel->GetFileRoot( fileid ) );
  277. Assert( pRoot );
  278. if ( !pRoot )
  279. continue;
  280. const char *pFileFormat = g_pDataModel->GetFileFormat( fileid );
  281. const char *pEncoding = g_pDataModel->GetDefaultEncoding( pFileFormat );
  282. g_pDataModel->SaveToFile( pFilename, NULL, pEncoding, pFileFormat, pRoot );
  283. }
  284. Refresh();
  285. }
  286. void CFileListManager::OnOpenFile( KeyValues *pParams )
  287. {
  288. KeyValues *pContextKeyValues = new KeyValues( "OnOpen" );
  289. vgui::FileOpenDialog *pFileOpenDialog = new vgui::FileOpenDialog( this, "Save .dmx File As", false, pContextKeyValues );
  290. pFileOpenDialog->AddFilter( "*.dmx", "DmElements File (*.dmx)", true );
  291. pFileOpenDialog->AddActionSignalTarget( this );
  292. pFileOpenDialog->DoModal( false );
  293. }
  294. void CFileListManager::OnSaveFileAs( KeyValues *pParams )
  295. {
  296. int nSelected = GetSelectedItemsCount();
  297. Assert( nSelected == 1 );
  298. if ( nSelected != 1 )
  299. return;
  300. KeyValues *pContextKeyValues = new KeyValues( "OnSaveAs" );
  301. pContextKeyValues->SetInt( "itemId", GetSelectedItem( 0 ) );
  302. DmFileId_t fileid = ( DmFileId_t )GetItemUserData( GetSelectedItem( 0 ) );
  303. const char *pFileFormat = g_pDataModel->GetFileFormat( fileid );
  304. vgui::FileOpenDialog *pFileOpenDialog = new vgui::FileOpenDialog( this, "Save .dmx File As", false, pContextKeyValues );
  305. // if this control is moved to vgui_controls, change the default format to "dmx", the generic dmx format
  306. pFileOpenDialog->AddFilter( "*.dmx", "Generic MovieObjects File (*.dmx)", false, "movieobjects" );
  307. if ( V_strcmp( pFileFormat, "movieobjects" ) != 0 )
  308. {
  309. char description[ 256 ];
  310. V_snprintf( description, sizeof( description ), "%s (*.dmx)", g_pDataModel->GetFormatDescription( pFileFormat ) );
  311. pFileOpenDialog->AddFilter( "*.dmx", description, true, pFileFormat );
  312. }
  313. pFileOpenDialog->AddActionSignalTarget( this );
  314. pFileOpenDialog->DoModal( false );
  315. }
  316. void CFileListManager::OnFileSelected( KeyValues *pParams )
  317. {
  318. const char *pFullPath = pParams->GetString( "fullpath" );
  319. if ( !pFullPath || !pFullPath[ 0 ] )
  320. return;
  321. KeyValues *pSaveAsKey = pParams->FindKey( "OnSaveAs" );
  322. if ( pSaveAsKey )
  323. {
  324. int itemId = pSaveAsKey->GetInt( "itemId", -1 );
  325. Assert( itemId != -1 );
  326. if ( itemId == -1 )
  327. return;
  328. DmFileId_t fileid = ( DmFileId_t )GetItemUserData( itemId );
  329. Assert( fileid != DMFILEID_INVALID );
  330. if ( fileid == DMFILEID_INVALID )
  331. return;
  332. CDmElement *pRoot = GetElement< CDmElement >( g_pDataModel->GetFileRoot( fileid ) );
  333. Assert( pRoot );
  334. if ( !pRoot )
  335. return;
  336. const char *pFormat = pParams->GetString( "filterinfo" );
  337. Assert( pFormat );
  338. if ( !pFormat )
  339. return;
  340. g_pDataModel->SetFileName( fileid, pFullPath );
  341. g_pDataModel->SaveToFile( pFullPath, NULL, g_pDataModel->GetDefaultEncoding( pFormat ), pFormat, pRoot );
  342. Refresh();
  343. return;
  344. }
  345. KeyValues *pOpenKey = pParams->FindKey( "OnOpen" );
  346. if ( pOpenKey )
  347. {
  348. CDmElement *pRoot = NULL;
  349. g_pDataModel->RestoreFromFile( pFullPath, NULL, NULL, &pRoot );
  350. Refresh();
  351. return;
  352. }
  353. }
  354. void CFileListManager::OnAddToPerforce( KeyValues *pParams )
  355. {
  356. int nFileCount = 0;
  357. int nSelected = GetSelectedItemsCount();
  358. const char **ppFileNames = ( const char** )_alloca( nSelected * sizeof( char* ) );
  359. for ( int i = 0; i < nSelected; ++i )
  360. {
  361. int itemId = GetSelectedItem( i );
  362. DmFileId_t fileid = ( DmFileId_t )GetItemUserData( itemId );
  363. const char *pFilename = g_pDataModel->GetFileName( fileid );
  364. Assert( pFilename );
  365. if ( !pFilename )
  366. continue;
  367. ++nFileCount;
  368. ppFileNames[ i ] = pFilename;
  369. }
  370. bool bSuccess = p4->OpenFilesForAdd( nFileCount, ppFileNames );
  371. if ( !bSuccess )
  372. {
  373. vgui::MessageBox *pError = new vgui::MessageBox( "Perforce Error!", p4->GetLastError(), GetParent() );
  374. pError->SetSmallCaption( true );
  375. pError->DoModal();
  376. }
  377. Refresh();
  378. }
  379. void CFileListManager::OnOpenForEdit( KeyValues *pParams )
  380. {
  381. int nFileCount = 0;
  382. int nSelected = GetSelectedItemsCount();
  383. const char **ppFileNames = ( const char** )_alloca( nSelected * sizeof( char* ) );
  384. for ( int i = 0; i < nSelected; ++i )
  385. {
  386. int itemId = GetSelectedItem( i );
  387. DmFileId_t fileid = ( DmFileId_t )GetItemUserData( itemId );
  388. const char *pFilename = g_pDataModel->GetFileName( fileid );
  389. Assert( pFilename );
  390. if ( !pFilename )
  391. continue;
  392. ++nFileCount;
  393. ppFileNames[ i ] = pFilename;
  394. }
  395. bool bSuccess = p4->OpenFilesForEdit( nFileCount, ppFileNames );
  396. if ( !bSuccess )
  397. {
  398. vgui::MessageBox *pError = new vgui::MessageBox( "Perforce Error!", p4->GetLastError(), GetParent() );
  399. pError->SetSmallCaption( true );
  400. pError->DoModal();
  401. }
  402. Refresh();
  403. }
  404. void CFileListManager::OnDataChanged( KeyValues *pParams )
  405. {
  406. int nNotifyFlags = pParams->GetInt( "notifyFlags" );
  407. if ( ( nNotifyFlags & NOTIFY_CHANGE_TOPOLOGICAL ) == 0 )
  408. return;
  409. int nNotifySource = pParams->GetInt( "source" );
  410. if ( nNotifySource == NOTIFY_SOURCE_FILE_LIST_MANAGER )
  411. return;
  412. if ( !IsVisible() )
  413. {
  414. m_bRefreshRequired = true;
  415. return;
  416. }
  417. int nCount = GetItemCount();
  418. int nFiles = g_pDataModel->NumFileIds();
  419. bool bPerformFullRefresh = ( nCount != nFiles );
  420. if ( !bPerformFullRefresh )
  421. {
  422. const char *pNameKey = GetKey( CI_FILENAME );
  423. for ( int i = 0; i < nCount; ++i )
  424. {
  425. DmFileId_t fileid = g_pDataModel->GetFileId( i );
  426. const char *pFileName = g_pDataModel->GetFileName( fileid );
  427. if ( !pFileName || !*pFileName )
  428. {
  429. bPerformFullRefresh = true;
  430. break;
  431. }
  432. pFileName = V_UnqualifiedFileName( pFileName );
  433. KeyValues *pKeyValues = GetItem( i );
  434. bPerformFullRefresh = ( fileid != (DmFileId_t)GetItemUserData(i) ) || Q_stricmp( pFileName, pKeyValues->GetString( pNameKey ) );
  435. if ( bPerformFullRefresh )
  436. break;
  437. pKeyValues->SetInt ( GetKey( CI_NUMELEMENTS ), g_pDataModel->NumElementsInFile( fileid ) );
  438. pKeyValues->SetString( GetKey( CI_LOADED ), g_pDataModel->IsFileLoaded( fileid ) ? "Y" : "N" );
  439. pKeyValues->SetString( GetKey( CI_CHANGED ), false ? "Y" : "N" );
  440. ApplyItemChanges( i );
  441. }
  442. }
  443. if ( bPerformFullRefresh )
  444. {
  445. Refresh();
  446. return;
  447. }
  448. }
  449. void CFileListManager::Refresh()
  450. {
  451. m_bRefreshRequired = false;
  452. RemoveAll();
  453. const bool bP4Connected = p4 ? p4->IsConnectedToServer() : false;
  454. int nFiles = g_pDataModel->NumFileIds();
  455. for ( int i = 0; i < nFiles; ++i )
  456. {
  457. DmFileId_t fileid = g_pDataModel->GetFileId( i );
  458. const char *pFileName = g_pDataModel->GetFileName( fileid );
  459. if ( !pFileName || !*pFileName )
  460. continue; // skip DMFILEID_INVALID and the default fileid ""
  461. bool bLoaded = g_pDataModel->IsFileLoaded( fileid );
  462. int nElements = g_pDataModel->NumElementsInFile( fileid );
  463. bool bChanged = false; // TODO - find out for real
  464. bool bInPerforce = bP4Connected && p4->IsFileInPerforce( pFileName );
  465. bool bOpenForEdit = bInPerforce && p4->GetFileState( pFileName ) != P4FILE_UNOPENED;
  466. char path[ 256 ];
  467. V_ExtractFilePath( pFileName, path, sizeof( path ) );
  468. AddItem( fileid, V_UnqualifiedFileName( pFileName ), path, bLoaded, nElements, bChanged, bInPerforce, bOpenForEdit );
  469. }
  470. }
  471. void CFileListManager::OnThink( )
  472. {
  473. BaseClass::OnThink();
  474. if ( m_bRefreshRequired && IsVisible() )
  475. {
  476. Refresh();
  477. }
  478. }
  479. void CFileListManager::OnCommand( const char *cmd )
  480. {
  481. // if ( !Q_stricmp( cmd, "foo" ) ) ...
  482. BaseClass::OnCommand( cmd );
  483. }
  484. //-----------------------------------------------------------------------------
  485. //
  486. // CFileManagerFrame methods
  487. //
  488. //-----------------------------------------------------------------------------
  489. CFileManagerFrame::CFileManagerFrame( vgui::Panel *parent ) : BaseClass( parent, "FileManagerFrame" )
  490. {
  491. SetTitle( "#BxFileManagerFrame", true );
  492. SetSizeable( true );
  493. SetCloseButtonVisible( false );
  494. SetMinimumSize( 200, 200 );
  495. SetVisible( true );
  496. SetSize( 800, 200 );
  497. SetPos( 100, 100 );
  498. m_pFileListManager = new CFileListManager( this );
  499. Refresh();
  500. SetScheme( vgui::scheme()->LoadSchemeFromFile( "Resource/BoxRocket.res", "BoxRocket" ) );
  501. }
  502. void CFileManagerFrame::Refresh()
  503. {
  504. m_pFileListManager->Refresh();
  505. }
  506. void CFileManagerFrame::OnCommand( const char *cmd )
  507. {
  508. BaseClass::OnCommand( cmd );
  509. m_pFileListManager->OnCommand( cmd );
  510. }
  511. void CFileManagerFrame::PerformLayout()
  512. {
  513. BaseClass::PerformLayout();
  514. int iWidth, iHeight;
  515. GetSize( iWidth, iHeight );
  516. m_pFileListManager->SetPos( 0, GetCaptionHeight() );
  517. m_pFileListManager->SetSize( iWidth, iHeight - GetCaptionHeight() );
  518. }