aboutsummaryrefslogtreecommitdiff
path: root/mp/src/public/matsys_controls/mdlpicker.h
blob: fcacfc9ccbcdaf59106cd2f1bac5c089fa00f345 (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
152
153
154
155
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
//=============================================================================

#ifndef MDLPICKER_H
#define MDLPICKER_H
#ifdef _WIN32
#pragma once
#endif

#include "tier1/utlstring.h"
#include "vgui_controls/Frame.h"
#include "matsys_controls/baseassetpicker.h"
#include "datacache/imdlcache.h"



//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
namespace vgui
{
	class Splitter;
}

class CMDLPanel;

const int MAX_SELECTED_MODELS = 2;

//-----------------------------------------------------------------------------
// Purpose: Main app window
//-----------------------------------------------------------------------------
class CMDLPicker : public CBaseAssetPicker
{
	DECLARE_CLASS_SIMPLE( CMDLPicker, CBaseAssetPicker );

public:

	enum PageType_t
	{
		PAGE_NONE	= 0,
		PAGE_RENDER  = 0x1,
		PAGE_SEQUENCES = 0x2,
		PAGE_ACTIVITIES = 0x4,
		PAGE_SKINS = 0x8,
		PAGE_INFO = 0x10,
		PAGE_SCREEN_CAPS = 0x20,
		PAGE_ALL	= 0xFFFFFFFF,
	};

	CMDLPicker( vgui::Panel *pParent, int nFlags = PAGE_ALL	);
	~CMDLPicker();

	// overridden frame functions
	virtual void PerformLayout();
	virtual void OnCommand( const char *pCommand );

	// Get current model
	void		GetSelectedMDLName( char *pBuffer, int nMaxLen );
	
	// get current selected options page
	int			GetSelectedPage();

	// Allows external apps to select a MDL
	void		SelectMDL( const char *pRelativePath, bool bDoLookAt = true, int nSelectSecondary = 0 );

	// Set/Get Sequence
	void		SelectSequence( const char *pSequenceName );
	const char *GetSelectedSequenceName();

	// Set/Get Activity
	void		SelectActivity( const char *pActivityName );
	const char *GetSelectedActivityName();

	void		SelectSkin( int nSkin );
	int			GetSelectedSkin();

private:
	MESSAGE_FUNC_PARAMS( OnAssetSelected, "AssetSelected", params );

	virtual void OnSelectedAssetPicked( const char *pMDLName );

	void RefreshActivitiesAndSequencesList();
	void RefreshRenderSettings();
	int	 UpdateSkinsList();
	void UpdateInfoTab();
	int  UpdatePropDataList( const char* pszPropData, bool &bIsStatic );

	// Plays the selected activity
	void PlaySelectedActivity( );

	// Plays the selected sequence
	void PlaySelectedSequence( );

	const char *CaptureModel( int nModIndex, const char *AssetName, const char *OutputPath, int Width, int Height, Color BackgroundColor, bool bSelectedOnly );
	void CaptureScreenCaps( void );
	void SaveCaps( const char *szFileName );
	bool RestoreCaps( const char *szFileName );

	void WriteBackbackVMTFiles( const char *assetName );
	void GenerateBackpackIcons( void );
	CUtlString GetOutputFileSuffix();

	MESSAGE_FUNC_PARAMS( OnCheckButtonChecked, "CheckButtonChecked", kv );
	MESSAGE_FUNC_PARAMS( OnItemSelected, "ItemSelected", kv );
	MESSAGE_FUNC( OnPageChanged, "PageChanged" );	
	MESSAGE_FUNC_CHARPTR( OnDirectorySelected, "DirectorySelected", dir );

	CMDLPanel *m_pMDLPreview;
	vgui::Splitter* m_pFileBrowserSplitter;
	vgui::Splitter* m_pPreviewSplitter;
	
	vgui::PropertySheet *m_pViewsSheet;
	vgui::PropertyPage *m_pRenderPage;
	vgui::PropertyPage *m_pSequencesPage;
	vgui::PropertyPage *m_pActivitiesPage;
	vgui::PropertyPage *m_pSkinsPage;
	vgui::PropertyPage *m_pInfoPage;
	vgui::PropertyPage *m_pScreenCapsPage;


	vgui::ListPanel *m_pSequencesList;
	vgui::ListPanel *m_pActivitiesList;
	vgui::ListPanel	*m_pSkinsList;
	vgui::ListPanel *m_pPropDataList;

	MDLHandle_t m_hSelectedMDL[ MAX_SELECTED_MODELS ];

	vgui::DHANDLE< vgui::DirectorySelectDialog > m_hDirectorySelectDialog;

	int m_nFlags;

	friend class CMDLPickerFrame;
};


//-----------------------------------------------------------------------------
// Purpose: Main app window
//-----------------------------------------------------------------------------
class CMDLPickerFrame : public CBaseAssetPickerFrame
{
	DECLARE_CLASS_SIMPLE( CMDLPickerFrame, CBaseAssetPickerFrame );

public:
	CMDLPickerFrame( vgui::Panel *pParent, const char *pTitle, int nFlags = CMDLPicker::PAGE_ALL );
	virtual ~CMDLPickerFrame();

	// Allows external apps to select a MDL
	void		SelectMDL( const char *pRelativePath );
};


#endif // MDLPICKER_H