aboutsummaryrefslogtreecommitdiff
path: root/sp/src/public/vgui_controls/perforcefilelistframe.h
blob: 7744bf23050ed9b665c7357ea6fdb8633eef31bf (plain) (blame)
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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// List of perforce files and operations
//
//=============================================================================

#ifndef PERFORCEFILELISTFRAME_H
#define PERFORCEFILELISTFRAME_H

#ifdef _WIN32
#pragma once
#endif

#include "vgui_controls/Frame.h"
#include "tier1/utlvector.h"
#include "tier1/utlstring.h"
#include "p4lib/ip4.h"


//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------


//-----------------------------------------------------------------------------
// Enumeration of operation dialog ids
//-----------------------------------------------------------------------------
enum
{
	OPERATION_DIALOG_ID_PERFORCE = 0,

	OPERATION_DIALOG_STANDARD_ID_COUNT,
	OPERATION_DIALOG_STANDARD_ID_MAX = OPERATION_DIALOG_STANDARD_ID_COUNT - 1,
};


//-----------------------------------------------------------------------------
// Purpose: Modal dialog for a list of files + an operation to perform
//-----------------------------------------------------------------------------
class COperationFileListFrame : public vgui::Frame
{
	DECLARE_CLASS_SIMPLE( COperationFileListFrame, vgui::Frame );

public:
	// NOTE: The dialog ID is used to allow dialogs to have different configurations saved 
	COperationFileListFrame( vgui::Panel *pParent, const char *pTitle, const char *pColumnHeader, bool bShowDescription, bool bShowOkOnly = false, int nDialogID = 1 );
	virtual ~COperationFileListFrame();

	// Command handler
	virtual void OnCommand( const char *pCommand );
	virtual void PerformLayout();

	// Adds files to the frame
	void ClearAllOperations();
	void AddOperation( const char *pOperation, const char *pFileName );
	void AddOperation( const char *pOperation, const char *pFileName, const Color& clr );

	// Resizes the operation column to fit the operation text
	void ResizeOperationColumnToContents();

	// Sets the column header for the 'operation' column
	void SetOperationColumnHeaderText( const char *pText );

	// Shows the panel
	void DoModal( KeyValues *pContextKeyValues = NULL, const char *pMessage = NULL );

	// Retrieves the number of files, the file names, and operations
	int GetOperationCount();
	const char *GetFileName( int i );
	const char *GetOperation( int i );

	// Retreives the description (only if it was shown)
	const char *GetDescription();

private:
	virtual bool PerformOperation() { return true; }
	const char *CompletionMessage();
	void CleanUpMessage();

	vgui::ListPanel *m_pFileBrowser;
	vgui::Splitter *m_pSplitter;
	vgui::TextEntry *m_pDescription;
	vgui::Button *m_pYesButton;
	vgui::Button *m_pNoButton;
	KeyValues *m_pContextKeyValues;
	CUtlString m_MessageName;
	char *m_pText;
};


//-----------------------------------------------------------------------------
// Purpose: Modal dialog for picker
//-----------------------------------------------------------------------------
enum PerforceAction_t
{
	PERFORCE_ACTION_NONE = -1,
	PERFORCE_ACTION_FILE_ADD = 0,
	PERFORCE_ACTION_FILE_EDIT,
	PERFORCE_ACTION_FILE_DELETE,
	PERFORCE_ACTION_FILE_REVERT,
	PERFORCE_ACTION_FILE_SUBMIT,
};

	
//-----------------------------------------------------------------------------
// Purpose: Modal dialog for picker
//-----------------------------------------------------------------------------
class CPerforceFileListFrame : public COperationFileListFrame
{
	DECLARE_CLASS_SIMPLE( CPerforceFileListFrame, COperationFileListFrame );

public:
	CPerforceFileListFrame( vgui::Panel *pParent, const char *pTitle, const char *pColumnHeader, PerforceAction_t action );
	virtual ~CPerforceFileListFrame();

	// Adds files to the frame
	void ClearAllFiles();
	void AddFile( const char *pFullPath );
	void AddFile( const char *pRelativePath, const char *pPathId );

	void DoModal( KeyValues *pContextKeys = NULL, const char *pMessage = NULL );

private:
	virtual bool PerformOperation();

	// Adds files for open, submit
	void AddFileForOpen( const char *pFullPath );
	void AddFileForSubmit( const char *pFullPath, P4FileState_t state );

	// Does the perforce operation
	void PerformPerforceAction( );

	PerforceAction_t m_Action;
	CUtlVector< P4File_t > m_OpenedFiles;
	CUtlString m_LastOpenedFilePathId;
};


//-----------------------------------------------------------------------------
// Show the perforce query dialog
// The specified keyvalues message will be sent either
//		1) If you open the file for add/edit
//		2) If you indicate to not add a file for add but don't hit cancel
// If a specific perforce action is specified, then the dialog will only
// be displayed if that action is appropriate
//-----------------------------------------------------------------------------
void ShowPerforceQuery( vgui::Panel *pParent, const char *pFileName, vgui::Panel *pActionSignalTarget, KeyValues *pKeyValues, PerforceAction_t actionFilter = PERFORCE_ACTION_NONE );


#endif // PERFORCEFILELISTFRAME_H