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.

151 lines
4.9 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // List of perforce files and operations
  4. //
  5. //=============================================================================
  6. #ifndef PERFORCEFILELISTFRAME_H
  7. #define PERFORCEFILELISTFRAME_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "vgui_controls/Frame.h"
  12. #include "tier1/utlvector.h"
  13. #include "tier1/utlstring.h"
  14. #include "p4lib/ip4.h"
  15. //-----------------------------------------------------------------------------
  16. // Forward declarations
  17. //-----------------------------------------------------------------------------
  18. //-----------------------------------------------------------------------------
  19. // Enumeration of operation dialog ids
  20. //-----------------------------------------------------------------------------
  21. enum
  22. {
  23. OPERATION_DIALOG_ID_PERFORCE = 0,
  24. OPERATION_DIALOG_STANDARD_ID_COUNT,
  25. OPERATION_DIALOG_STANDARD_ID_MAX = OPERATION_DIALOG_STANDARD_ID_COUNT - 1,
  26. };
  27. //-----------------------------------------------------------------------------
  28. // Purpose: Modal dialog for a list of files + an operation to perform
  29. //-----------------------------------------------------------------------------
  30. class COperationFileListFrame : public vgui::Frame
  31. {
  32. DECLARE_CLASS_SIMPLE( COperationFileListFrame, vgui::Frame );
  33. public:
  34. // NOTE: The dialog ID is used to allow dialogs to have different configurations saved
  35. COperationFileListFrame( vgui::Panel *pParent, const char *pTitle, const char *pColumnHeader, bool bShowDescription, bool bShowOkOnly = false, int nDialogID = 1 );
  36. virtual ~COperationFileListFrame();
  37. // Command handler
  38. virtual void OnCommand( const char *pCommand );
  39. virtual void PerformLayout();
  40. // Adds files to the frame
  41. void ClearAllOperations();
  42. void AddOperation( const char *pOperation, const char *pFileName );
  43. void AddOperation( const char *pOperation, const char *pFileName, const Color& clr );
  44. // Resizes the operation column to fit the operation text
  45. void ResizeOperationColumnToContents();
  46. // Sets the column header for the 'operation' column
  47. void SetOperationColumnHeaderText( const char *pText );
  48. // Shows the panel
  49. void DoModal( KeyValues *pContextKeyValues = NULL, const char *pMessage = NULL );
  50. // Retrieves the number of files, the file names, and operations
  51. int GetOperationCount();
  52. const char *GetFileName( int i );
  53. const char *GetOperation( int i );
  54. // Retreives the description (only if it was shown)
  55. const char *GetDescription();
  56. private:
  57. virtual bool PerformOperation() { return true; }
  58. const char *CompletionMessage();
  59. void CleanUpMessage();
  60. vgui::ListPanel *m_pFileBrowser;
  61. vgui::Splitter *m_pSplitter;
  62. vgui::TextEntry *m_pDescription;
  63. vgui::Button *m_pYesButton;
  64. vgui::Button *m_pNoButton;
  65. KeyValues *m_pContextKeyValues;
  66. CUtlString m_MessageName;
  67. char *m_pText;
  68. };
  69. //-----------------------------------------------------------------------------
  70. // Purpose: Modal dialog for picker
  71. //-----------------------------------------------------------------------------
  72. enum PerforceAction_t
  73. {
  74. PERFORCE_ACTION_NONE = -1,
  75. PERFORCE_ACTION_FILE_ADD = 0,
  76. PERFORCE_ACTION_FILE_EDIT,
  77. PERFORCE_ACTION_FILE_DELETE,
  78. PERFORCE_ACTION_FILE_REVERT,
  79. PERFORCE_ACTION_FILE_SUBMIT,
  80. };
  81. //-----------------------------------------------------------------------------
  82. // Purpose: Modal dialog for picker
  83. //-----------------------------------------------------------------------------
  84. class CPerforceFileListFrame : public COperationFileListFrame
  85. {
  86. DECLARE_CLASS_SIMPLE( CPerforceFileListFrame, COperationFileListFrame );
  87. public:
  88. CPerforceFileListFrame( vgui::Panel *pParent, const char *pTitle, const char *pColumnHeader, PerforceAction_t action );
  89. virtual ~CPerforceFileListFrame();
  90. // Adds files to the frame
  91. void ClearAllFiles();
  92. void AddFile( const char *pFullPath );
  93. void AddFile( const char *pRelativePath, const char *pPathId );
  94. void DoModal( KeyValues *pContextKeys = NULL, const char *pMessage = NULL );
  95. private:
  96. virtual bool PerformOperation();
  97. // Adds files for open, submit
  98. void AddFileForOpen( const char *pFullPath );
  99. void AddFileForSubmit( const char *pFullPath, P4FileState_t state );
  100. // Does the perforce operation
  101. void PerformPerforceAction( );
  102. PerforceAction_t m_Action;
  103. CUtlVector< P4File_t > m_OpenedFiles;
  104. CUtlString m_LastOpenedFilePathId;
  105. };
  106. //-----------------------------------------------------------------------------
  107. // Show the perforce query dialog
  108. // The specified keyvalues message will be sent either
  109. // 1) If you open the file for add/edit
  110. // 2) If you indicate to not add a file for add but don't hit cancel
  111. // If a specific perforce action is specified, then the dialog will only
  112. // be displayed if that action is appropriate
  113. //-----------------------------------------------------------------------------
  114. void ShowPerforceQuery( vgui::Panel *pParent, const char *pFileName, vgui::Panel *pActionSignalTarget, KeyValues *pKeyValues, PerforceAction_t actionFilter = PERFORCE_ACTION_NONE );
  115. #endif // PERFORCEFILELISTFRAME_H