Team Fortress 2 Source Code as on 22/4/2020
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.

114 lines
3.3 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Contains a list of files, determines their perforce status
  4. //
  5. // $NoKeywords: $
  6. //===========================================================================//
  7. #ifndef PERFORCEFILELIST_H
  8. #define PERFORCEFILELIST_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "tier1/utlstring.h"
  13. #include "tier1/UtlStringMap.h"
  14. #include "vgui_controls/ListPanel.h"
  15. //-----------------------------------------------------------------------------
  16. // Forward declarations
  17. //-----------------------------------------------------------------------------
  18. struct P4File_t;
  19. namespace vgui
  20. {
  21. class ListPanel;
  22. }
  23. namespace vgui
  24. {
  25. //-----------------------------------------------------------------------------
  26. // Contains a list of files, determines their perforce status
  27. //-----------------------------------------------------------------------------
  28. class PerforceFileList : public vgui::ListPanel
  29. {
  30. DECLARE_CLASS_SIMPLE( PerforceFileList, ListPanel );
  31. public:
  32. // The context keyvalues are added to all messages sent by this dialog if they are specified
  33. PerforceFileList( Panel *parent, const char *pPanelName );
  34. ~PerforceFileList();
  35. // Add a file to the file list. Note that this file may exist on disk or not
  36. // and it may exist in perforce or not. It's specified as a full path on disk though.
  37. // In the case where a file doesn't exist on disk, but it does exist in perforce
  38. // specify where that file would appear on disk.
  39. // This function returns the itemID of the added file
  40. // If you already know the file exists or is a directory (or not), specify that in the call.
  41. // -1 means autodetect whether the file exists or is a directory
  42. int AddFile( const char *pFullPath, int nFileExists = -1, int nIsDirectory = -1 );
  43. // Is a file already in the list?
  44. bool IsFileInList( const char *pFullPath );
  45. // Find the item ID associated with a particular file
  46. int FindFile( const char *pFullPath );
  47. // Remove all files from the list
  48. void RemoveAllFiles();
  49. // Refresh perforce information
  50. void Refresh();
  51. // Refresh perforce information manually
  52. void RefreshPerforceState( int nItemID, bool bFileExists, P4File_t *pFileInfo );
  53. // Is a particular list item a directory?
  54. bool IsDirectoryItem( int nItemID );
  55. // Returns the file associated with a particular item ID
  56. const char *GetFile( int nItemID );
  57. // Toggle showing deleted files or not
  58. void ShowDeletedFiles( bool bShowDeletedFiles );
  59. // Inherited from vgui::EditablePanel
  60. virtual void ApplySchemeSettings( IScheme *pScheme );
  61. virtual void OnMouseDoublePressed( MouseCode code );
  62. /*
  63. messages sent:
  64. "ItemDoubleClicked" // Called when an item is double-clicked
  65. */
  66. protected:
  67. struct DirectoryInfo_t
  68. {
  69. CUtlString m_ClientSpec;
  70. CUtlVector< int > m_ItemIDs;
  71. };
  72. // Add a file to the file list.
  73. int AddFileToFileList( const char *pFullPath, bool bExistsOnDisk );
  74. // Add a directory to the file list.
  75. int AddDirectoryToFileList( const char *pFullPath, bool bExistsOnDisk );
  76. // Add a directory to the directory list, returns client spec
  77. void AddItemToDirectoryList( const char *pFullPath, int nItemID, bool bIsDirectory );
  78. // Used to look up directories -> client specs
  79. CUtlStringMap< DirectoryInfo_t > m_Directories;
  80. // Show deleted files?
  81. bool m_bShowDeletedFiles;
  82. };
  83. } // namespace vgui
  84. #endif // PERFORCEFILELIST_H