diff options
Diffstat (limited to 'public/matsys_controls')
21 files changed, 2249 insertions, 0 deletions
diff --git a/public/matsys_controls/QCGenerator.h b/public/matsys_controls/QCGenerator.h new file mode 100644 index 0000000..d6b69d2 --- /dev/null +++ b/public/matsys_controls/QCGenerator.h @@ -0,0 +1,155 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//============================================================================= + +#ifndef QCGENERATOR_H +#define QCGENERATOR_H +#ifdef _WIN32 +#pragma once +#endif + +#include "vgui_controls/EditablePanel.h" +#include "vgui_controls/Frame.h" +#include "vgui_controls/Button.h" +#include "tier1/utlstring.h" +#include "vgui_controls/TextEntry.h" + +class CQCGenerator; + +//----------------------------------------------------------------------------- +// Forward declarations +//----------------------------------------------------------------------------- +namespace vgui +{ + class Panel; +} + +class CBrowseButton : public vgui::Button +{ + DECLARE_CLASS_SIMPLE( CBrowseButton, vgui::Button ); + +public: + CBrowseButton( vgui::Panel *pParent ); + ~CBrowseButton(); + void InitBrowseInfo( int x, int y, const char *pszName, const char *pszDir, const char *pszFilter, const char *pszField ); + +private: + char *pszStartingDirectory; + char *pszFileFilter; + char *pszTargetField; + + char **GetStartingDirectory(){ return &pszStartingDirectory; } + char **GetFileFilter(){ return &pszFileFilter; } + char **GetTargetField(){ return &pszTargetField; } + void SetCharVar( char **pVar, const char *pszNewText ); + void SetActionMessage(); +}; + +struct LODInfo +{ + char pszFilename[MAX_PATH]; + int iLOD; +}; + +struct QCInfo +{ + CQCGenerator *pQCGenerator; + + char pszSMDPath[MAX_PATH]; + char pszCollisionPath[MAX_PATH]; + char pszSurfaceProperty[MAX_PATH]; + char pszMaterialPath[MAX_PATH]; + char pszSceneName[MAX_PATH]; + + bool bStaticProp; + bool bMostlyOpaque; + bool bDisableCollision; + bool bReferenceAsPhys; + bool bConcave; + bool bAutomass; + bool bNoAnimation; + + CUtlVector<LODInfo> LODs; + + float fScale; + float fMass; + void Init( CQCGenerator *pPanel ) + { + pQCGenerator = pPanel; + + V_strcpy_safe( pszSMDPath, "" ); + V_strcpy_safe( pszCollisionPath, "" ); + V_strcpy_safe( pszSurfaceProperty, "default" ); + bStaticProp = false; + bMostlyOpaque = false; + bDisableCollision = false; + bReferenceAsPhys = false; + bConcave = false; + bAutomass = false; + bNoAnimation = true; + + fScale = 1.0; + fMass = 10.0; + } + void SyncToControls(); + void SyncFromControls(); +}; + +//----------------------------------------------------------------------------- +// Purpose: Base class for generating QC files +//----------------------------------------------------------------------------- +class CQCGenerator : public vgui::EditablePanel +{ + DECLARE_CLASS_SIMPLE( CQCGenerator, vgui::EditablePanel ); + +public: + CQCGenerator( vgui::Panel *pParent, const char *pszPath, const char *pszScene ); + ~CQCGenerator(); + + // overridden frame functions +// virtual void Activate(); + + virtual void OnCommand( const char *command ); + + // Purpose: +// virtual void OnKeyCodeTyped( vgui::KeyCode code ); + + MESSAGE_FUNC( OnNewLODText, "TextNewLine" ); + MESSAGE_FUNC_PARAMS( OnBrowse, "browse", data ); + MESSAGE_FUNC_PARAMS( OnFileSelected, "FileSelected", data ); + MESSAGE_FUNC_PARAMS( OnDirectorySelected, "DirectorySelected", data ); + + bool GenerateQCFile(); +// void BrowseDirectory( KeyValues *data ); + void BrowseFile( KeyValues *data ); + + void DeleteLOD( ); + void EditLOD(); + virtual void OnKeyCodeTyped( vgui::KeyCode code); + void InitializeSMDPaths( const char *pszPath, const char *pszScene ); + +protected: + // Creates standard controls. Allows the derived class to + // add these controls to various splitter windows + void CreateStandardControls( vgui::Panel *pParent ); + +private: + + CBrowseButton *m_pCollisionBrowseButton; + char m_szTargetField[MAX_PATH]; + vgui::ListPanel *m_pLODPanel; + + vgui::TextEntry *m_pLODEdit; + + int m_nSelectedSequence; + int m_nSelectedColumn; + + QCInfo m_QCInfo_t; +}; + + + + +#endif // QCGENERATOR_H diff --git a/public/matsys_controls/assetpicker.h b/public/matsys_controls/assetpicker.h new file mode 100644 index 0000000..967fd2b --- /dev/null +++ b/public/matsys_controls/assetpicker.h @@ -0,0 +1,51 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//============================================================================= + +#ifndef ASSETPICKER_H +#define ASSETPICKER_H +#ifdef _WIN32 +#pragma once +#endif + +#include "matsys_controls/baseassetpicker.h" + + +//----------------------------------------------------------------------------- +// Forward declarations +//----------------------------------------------------------------------------- +namespace vgui +{ + class Panel; +} + + +//----------------------------------------------------------------------------- +// Purpose: Base class for choosing raw assets +//----------------------------------------------------------------------------- +class CAssetPicker : public CBaseAssetPicker +{ + DECLARE_CLASS_SIMPLE( CAssetPicker, CBaseAssetPicker ); + +public: + CAssetPicker( vgui::Panel *pParent, const char *pAssetType, + const char *pExt, const char *pSubDir, const char *pTextType ); +}; + + +//----------------------------------------------------------------------------- +// Purpose: Modal dialog for asset picker +//----------------------------------------------------------------------------- +class CAssetPickerFrame : public CBaseAssetPickerFrame +{ + DECLARE_CLASS_SIMPLE( CAssetPickerFrame, CBaseAssetPickerFrame ); + +public: + CAssetPickerFrame( vgui::Panel *pParent, const char *pTitle, + const char *pAssetType, const char *pExt, const char *pSubDir, const char *pTextType ); +}; + + +#endif // ASSETPICKER_H diff --git a/public/matsys_controls/baseassetpicker.h b/public/matsys_controls/baseassetpicker.h new file mode 100644 index 0000000..31cdcc9 --- /dev/null +++ b/public/matsys_controls/baseassetpicker.h @@ -0,0 +1,195 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//============================================================================= + +#ifndef BASEASSETPICKER_H +#define BASEASSETPICKER_H +#ifdef _WIN32 +#pragma once +#endif + +#include "vgui_controls/EditablePanel.h" +#include "vgui_controls/Frame.h" +#include "tier1/utlstring.h" +#include "tier1/utllinkedlist.h" +#include "filesystem.h" + + +//----------------------------------------------------------------------------- +// Forward declarations +//----------------------------------------------------------------------------- +class CAssetTreeView; +namespace vgui +{ + class Panel; +} +FORWARD_DECLARE_HANDLE( AssetList_t ); + +typedef unsigned short DirHandle_t; + + +//----------------------------------------------------------------------------- +// Purpose: Base class for choosing raw assets +//----------------------------------------------------------------------------- +class CBaseAssetPicker : public vgui::EditablePanel +{ + DECLARE_CLASS_SIMPLE( CBaseAssetPicker, vgui::EditablePanel ); + +public: + CBaseAssetPicker( vgui::Panel *pParent, const char *pAssetType, + const char *pExt, const char *pSubDir, const char *pTextType ); + ~CBaseAssetPicker(); + + // overridden frame functions + virtual void OnTick(); + virtual bool HasUserConfigSettings(); + virtual void ApplyUserConfigSettings( KeyValues *pUserConfig ); + virtual void GetUserConfigSettings( KeyValues *pUserConfig ); + virtual void OnCommand( const char *pCommand ); + + // Purpose: + virtual void OnKeyCodePressed( vgui::KeyCode code ); + + // Returns the selected asset name + int GetSelectedAssetCount(); + const char *GetSelectedAsset( int nAssetIndex = -1 ); + + // Is multiselect enabled? + bool IsMultiselectEnabled() const; + + // Sets the initial selected asset + void SetInitialSelection( const char *pAssetName ); + + // Set/get the filter + void SetFilter( const char *pFilter ); + const char *GetFilter(); + + // Purpose: refreshes the file tree + void RefreshFileTree(); + + virtual void Activate(); + +protected: + // Creates standard controls. Allows the derived class to + // add these controls to various splitter windows + void CreateStandardControls( vgui::Panel *pParent, bool bAllowMultiselect = false ); + + // Allows the picker to browse multiple asset types + void AddExtension( const char *pExtension ); + + // Derived classes have this called when the previewed asset changes + virtual void OnSelectedAssetPicked( const char *pAssetName ) {} + + // Derived classes have this called when the next selected asset is selected by default + virtual void OnNextSelectionIsDefault() {} + + // Request focus of the filter box + void RequestFilterFocus(); + + // Rescan assets + void RescanAssets(); + + const char *GetModPath( int nModIndex ); + + MESSAGE_FUNC_PARAMS( OnTextChanged, "TextChanged", kv ); + MESSAGE_FUNC_PARAMS( OnItemSelected, "ItemSelected", kv ); + MESSAGE_FUNC_PARAMS( OnCheckButtonChecked, "CheckButtonChecked", kv ); + MESSAGE_FUNC( OnFileSelected, "TreeViewItemSelected" ); + +protected: + struct AssetInfo_t + { + int m_nAssetIndex; + int m_nItemId; + }; + + void BuildAssetNameList(); + void RefreshAssetList( ); + int GetSelectedAssetModIndex( ); + + // Is a particular asset visible? + bool IsAssetVisible( int nAssetIndex ); + + // Recursively add all files matching the wildcard under this directory + void AddAssetToList( int nAssetIndex ); + + // Update column headers + void UpdateAssetColumnHeader( ); + + vgui::Splitter *m_pAssetSplitter; + CAssetTreeView* m_pFileTree; + vgui::CheckButton* m_pSubDirCheck; + vgui::TextEntry *m_pFilter; + vgui::ListPanel *m_pAssetBrowser; + vgui::TextEntry *m_pFullPath; + vgui::ComboBox *m_pModSelector; + vgui::Button *m_pRescanButton; + + AssetList_t m_hAssetList; + CUtlString m_FolderFilter; + CUtlString m_Filter; + CUtlString m_SelectedAsset; + CUtlVector< AssetInfo_t > m_AssetList; + const char *m_pAssetType; + const char *m_pAssetTextType; + const char *m_pAssetExt; + const char *m_pAssetSubDir; + CUtlVector< const char * > m_ExtraAssetExt; + bool m_bBuiltAssetList : 1; + bool m_bFirstAssetScan : 1; + bool m_bFinishedAssetListScan : 1; + int m_nCurrentModFilter; + int m_nMatchingAssets; + bool m_bSubDirCheck; + + friend class CBaseAssetPickerFrame; +}; + + +//----------------------------------------------------------------------------- +// Purpose: Modal dialog for asset picker +//----------------------------------------------------------------------------- +class CBaseAssetPickerFrame : public vgui::Frame +{ + DECLARE_CLASS_SIMPLE( CBaseAssetPickerFrame, vgui::Frame ); + +public: + CBaseAssetPickerFrame( vgui::Panel *pParent ); + ~CBaseAssetPickerFrame(); + + // Inherited from Frame + virtual void OnCommand( const char *pCommand ); + + // Purpose: Activate the dialog + // The message "AssetSelected" will be sent if an asset is picked + // Pass in optional keyvalues to add to the message + void DoModal( KeyValues *pContextKeyValues = NULL ); + + // Sets the initial selected asset + void SetInitialSelection( const char *pAssetName ); + + // Set/get the filter + void SetFilter( const char *pFilter ); + const char *GetFilter(); + +protected: + // Allows the derived class to create the picker + void SetAssetPicker( CBaseAssetPicker* pPicker ); + CBaseAssetPicker* GetAssetPicker() { return m_pPicker; } + + // Posts a message (passing the key values) + void PostMessageAndClose( KeyValues *pKeyValues ); + +private: + void CleanUpMessage(); + + CBaseAssetPicker *m_pPicker; + vgui::Button *m_pOpenButton; + vgui::Button *m_pCancelButton; + KeyValues *m_pContextKeyValues; +}; + + +#endif // BASEASSETPICKER_H diff --git a/public/matsys_controls/colorpickerpanel.h b/public/matsys_controls/colorpickerpanel.h new file mode 100644 index 0000000..6b79b17 --- /dev/null +++ b/public/matsys_controls/colorpickerpanel.h @@ -0,0 +1,163 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//============================================================================= + +#ifndef COLORPICKERPANEL_H +#define COLORPICKERPANEL_H + +#ifdef _WIN32 +#pragma once +#endif + + +#include "vgui_controls/EditablePanel.h" +#include "vgui_controls/Frame.h" +#include "vgui_controls/Button.h" +#include "bitmap/imageformat.h" +#include "mathlib/vector.h" + + +//----------------------------------------------------------------------------- +// Forward declarations +//----------------------------------------------------------------------------- +class CColorXYPreview; +class CColorZPreview; + +namespace vgui +{ + class RadioButton; + class TextEntry; + class IScheme; +} + + +//----------------------------------------------------------------------------- +// +// Color picker panel +// +//----------------------------------------------------------------------------- +class CColorPickerPanel : public vgui::EditablePanel +{ + DECLARE_CLASS_SIMPLE( CColorPickerPanel, vgui::EditablePanel ); + +public: + // constructor + CColorPickerPanel( vgui::Panel *pParent, const char *pName ); + void SetInitialColor( Color initialColor ); + void GetCurrentColor( Color *pColor ); + void GetInitialColor( Color *pColor ); + + // Inherited from Panel + virtual void ApplySchemeSettings( vgui::IScheme *pScheme ); + virtual void OnMousePressed( vgui::MouseCode code ); + +private: + MESSAGE_FUNC_PARAMS( OnRadioButtonChecked, "RadioButtonChecked", kv ); + MESSAGE_FUNC_PARAMS( OnTextChanged, "TextChanged", data ); + MESSAGE_FUNC_PARAMS( OnHSVSelected, "HSVSelected", data ); + MESSAGE_FUNC_PARAMS( OnColorSelected, "ColorSelected", data ); + + // Called when the color changes + void OnColorChanged( vgui::TextEntry *pChanged = NULL ); + + // Updates the preview colors + void UpdatePreviewColors(); + + CColorXYPreview *m_pColorXYPreview; + CColorZPreview *m_pColorZPreview; + vgui::RadioButton* m_pHueRadio; + vgui::RadioButton* m_pSaturationRadio; + vgui::RadioButton* m_pValueRadio; + vgui::RadioButton* m_pRedRadio; + vgui::RadioButton* m_pGreenRadio; + vgui::RadioButton* m_pBlueRadio; + vgui::TextEntry* m_pHueText; + vgui::TextEntry* m_pSaturationText; + vgui::TextEntry* m_pValueText; + vgui::TextEntry* m_pRedText; + vgui::TextEntry* m_pGreenText; + vgui::TextEntry* m_pBlueText; + vgui::Panel* m_pInitialColor; + vgui::Panel* m_pCurrentColor; + vgui::TextEntry* m_pAlphaText; + + RGB888_t m_InitialColor; + RGB888_t m_CurrentColor; + unsigned char m_InitialAlpha; + unsigned char m_CurrentAlpha; + Vector m_CurrentHSVColor; +}; + + +//----------------------------------------------------------------------------- +// Purpose: Modal dialog for picker +//----------------------------------------------------------------------------- +class CColorPickerFrame : public vgui::Frame +{ + DECLARE_CLASS_SIMPLE( CColorPickerFrame, vgui::Frame ); + +public: + CColorPickerFrame( vgui::Panel *pParent, const char *pTitle ); + ~CColorPickerFrame(); + + // Inherited from Frame + virtual void OnCommand( const char *pCommand ); + + // Purpose: Activate the dialog + // If a color is picked, the message 'ColorPickerPicked' is sent with the "color" field set to the color + // If cancel is hit, the message 'ColorPickerCancel' is sent + // If the color is changed in the preview, the message 'ColorPickerPreview' is sent with the "color" field set to the color + void DoModal( Color initialColor, KeyValues *pContextKeys = NULL ); + + // Gets the initial color + void GetInitialColor( Color *pColor ); + +private: + void CleanUpMessage(); + + CColorPickerPanel *m_pPicker; + vgui::Button *m_pOpenButton; + vgui::Button *m_pCancelButton; + KeyValues *m_pContextKeys; +}; + + +//----------------------------------------------------------------------------- +// Purpose: A button which brings up the color picker +//----------------------------------------------------------------------------- +class CColorPickerButton : public vgui::Button +{ + DECLARE_CLASS_SIMPLE( CColorPickerButton, vgui::Button ); + + /* + NOTE: Sends ColorPickerPicked message when a color is picked + color - picked color + Sends ColorPickerPreview message when a color is previewed + color - current preview color + Sends ColorPickerCancelled message when the cancel button was hit + startingColor - color before the picking occurred + */ + +public: + CColorPickerButton( vgui::Panel *pParent, const char *pName, vgui::Panel *pActionSignalTarget = NULL ); + ~CColorPickerButton(); + + virtual void ApplySchemeSettings( vgui::IScheme *pScheme ); + virtual void DoClick(); + + void SetColor( const Color& clr ); + void SetColor( int r, int g, int b, int a ); + Color GetColor( void ) { return m_CurrentColor; } + +private: + MESSAGE_FUNC_PARAMS( OnPicked, "ColorPickerPicked", data ); + MESSAGE_FUNC_PARAMS( OnPreview, "ColorPickerPreview", data ); + MESSAGE_FUNC( OnCancelled, "ColorPickerCancel" ); + + void UpdateButtonColor(); + Color m_CurrentColor; +}; + +#endif // COLORPICKERPANEL_H
\ No newline at end of file diff --git a/public/matsys_controls/curveeditorpanel.h b/public/matsys_controls/curveeditorpanel.h new file mode 100644 index 0000000..fb76369 --- /dev/null +++ b/public/matsys_controls/curveeditorpanel.h @@ -0,0 +1,67 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//============================================================================= + +#ifndef CURVEEDITORPANEL_H +#define CURVEEDITORPANEL_H + +#ifdef _WIN32 +#pragma once +#endif + + +#include "vgui_controls/Panel.h" + + +//----------------------------------------------------------------------------- +// Forward declarations +//----------------------------------------------------------------------------- +struct BGRA8888_t; + + +//----------------------------------------------------------------------------- +// +// Curve editor image panel +// +//----------------------------------------------------------------------------- +class CCurveEditorPanel : public vgui::Panel +{ + DECLARE_CLASS_SIMPLE( CCurveEditorPanel, vgui::Panel ); + +public: + // constructor + CCurveEditorPanel( vgui::Panel *pParent, const char *pName ); + ~CCurveEditorPanel(); + + virtual void Paint( void ); + virtual void PaintBackground( void ); + + virtual void OnCursorMoved( int x,int y ); + virtual void OnMousePressed( vgui::MouseCode code ); + virtual void OnMouseReleased( vgui::MouseCode code ); + virtual void OnKeyCodePressed( vgui::KeyCode code ); + +protected: + // Control points + values... + virtual int FindOrAddControlPoint( float flIn, float flTolerance, float flOut ) = 0; + virtual int FindControlPoint( float flIn, float flTolerance ) = 0; + virtual int ModifyControlPoint( int nPoint, float flIn, float flOut ) = 0; + virtual void RemoveControlPoint( int nPoint ) = 0; + virtual float GetValue( float flIn ) = 0; + virtual int ControlPointCount() = 0; + virtual void GetControlPoint( int nPoint, float *pIn, float *pOut ) = 0; + +private: + // Converts screen location to normalized values and back + void ScreenToValue( int x, int y, float *pIn, float *pOut ); + void ValueToScreen( float flIn, float flOut, int *x, int *y ); + + int m_nSelectedPoint; + int m_nHighlightedPoint; // Used when not selecting +}; + + + +#endif // CURVEEDITORPANEL_H diff --git a/public/matsys_controls/gamefiletreeview.h b/public/matsys_controls/gamefiletreeview.h new file mode 100644 index 0000000..a9563ce --- /dev/null +++ b/public/matsys_controls/gamefiletreeview.h @@ -0,0 +1,81 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//============================================================================= + +#ifndef GAMEFILETREEVIEW_H +#define GAMEFILETREEVIEW_H + +#ifdef _WIN32 +#pragma once +#endif + + +#include "tier1/utlstring.h" +#include "vgui_controls/TreeView.h" +#include "vgui_controls/ImageList.h" + + +//----------------------------------------------------------------------------- +// Forward declarations +//----------------------------------------------------------------------------- +namespace vgui +{ + class IScheme; +} + + +//----------------------------------------------------------------------------- +// Purpose: Handles file view for game files +//----------------------------------------------------------------------------- +class CGameFileTreeView : public vgui::TreeView +{ + DECLARE_CLASS_SIMPLE( CGameFileTreeView, vgui::TreeView ); + +public: + CGameFileTreeView( vgui::Panel *parent, const char *name, const char *pRootFolderName, const char *pRootDir, const char *pExtension = NULL ); + + // Inherited from base classes + virtual void GenerateChildrenOfNode( int itemIndex ); + virtual void GenerateContextMenu( int itemIndex, int x, int y ); + virtual void ApplySchemeSettings( vgui::IScheme *pScheme ); + + // Purpose: Refreshes the active file list + void RefreshFileList(); + + // Sets an item to be colored as if its a menu + void SetItemColorForDirectories( int itemID ); + + // Gets the number of root directories + int GetRootDirectoryCount(); + + // Gets the ith root directory + const char *GetRootDirectory( int nIndex ); + + // Selects the root folder + void SelectRoot(); + +private: + // Populate the root node (necessary since tree view can't have multiple roots) + void PopulateRootNode( int itemIndex ); + + // Populate the root node with directories + void AddDirectoriesOfNode( int itemIndex, const char *pFilePath ); + + // Populate the root node with directories + bool DoesDirectoryHaveSubdirectories( const char *pFilePath ); + + // Populate the root node with files + void AddFilesOfNode( int itemIndex, const char *pFilePath, const char *pExt ); + + CUtlString m_RootDir; + CUtlString m_Ext; + CUtlString m_RootFolderName; + vgui::ImageList m_Images; + bool m_bUseExt; // To differentiate "" from NULL in m_Ext +}; + + +#endif // GAMEFILETREEVIEW_H + diff --git a/public/matsys_controls/manipulator.h b/public/matsys_controls/manipulator.h new file mode 100644 index 0000000..f030509 --- /dev/null +++ b/public/matsys_controls/manipulator.h @@ -0,0 +1,129 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//============================================================================= + +#ifndef MANIPULATOR_H +#define MANIPULATOR_H +#ifdef _WIN32 +#pragma once +#endif + +#include "vgui_controls/Panel.h" +#include "mathlib/vector.h" + +//----------------------------------------------------------------------------- +// Manipulator interface +//----------------------------------------------------------------------------- +class IManipulator +{ +public: + virtual ~IManipulator(){} + virtual void OnBeginManipulation( void ) = 0; + virtual void OnAcceptManipulation( void ) = 0; + virtual void OnCancelManipulation( void ) = 0; + + virtual void OnTick( void ) = 0; + + virtual void OnCursorMoved( int x, int y ) = 0; + virtual void OnMousePressed( vgui::MouseCode code, int x, int y ) = 0; + virtual void OnMouseReleased( vgui::MouseCode code, int x, int y ) = 0; + virtual void OnMouseWheeled( int delta ) = 0; + + virtual void SetViewportSize( int w, int h ) = 0; +}; + + +//----------------------------------------------------------------------------- +// Base class helper for implementing manipulators +//----------------------------------------------------------------------------- +class CBaseManipulator : public IManipulator +{ +public: + CBaseManipulator() + { + m_nViewport[ 0 ] = m_nViewport[ 1 ] = 0; + } + + virtual void OnTick( void ) {}; + + virtual void OnBeginManipulation( void ) {} + virtual void OnAcceptManipulation( void ) {}; + virtual void OnCancelManipulation( void ) {}; + + virtual void OnCursorMoved( int x, int y ) {}; + virtual void OnMousePressed( vgui::MouseCode code, int x, int y ) {}; + virtual void OnMouseReleased( vgui::MouseCode code, int x, int y ) {}; + virtual void OnMouseWheeled( int delta ) {}; + + virtual void SetViewportSize( int w, int h ) + { + m_nViewport[ 0 ] = w; + m_nViewport[ 1 ] = h; + } + +protected: + int m_nViewport[ 2 ]; +}; + + +//----------------------------------------------------------------------------- +// Base class for manipulators which operate on transforms +//----------------------------------------------------------------------------- +class CTransformManipulator : public CBaseManipulator +{ +public: + CTransformManipulator( matrix3x4_t *pTransform ); + + void SetTransform( matrix3x4_t *transform ); + matrix3x4_t *GetTransform(); + +protected: + matrix3x4_t *m_pTransform; +}; + + +//----------------------------------------------------------------------------- +// Standard maya-like transform manipulator +//----------------------------------------------------------------------------- +class CPotteryWheelManip : public CTransformManipulator +{ +public: + CPotteryWheelManip( matrix3x4_t *pTransform ); + + virtual void OnBeginManipulation( void ); + virtual void OnAcceptManipulation( void ); + virtual void OnCancelManipulation( void ); + + virtual void OnTick( void ); + + virtual void OnCursorMoved( int x, int y ); + virtual void OnMousePressed( vgui::MouseCode code, int x, int y ); + virtual void OnMouseReleased( vgui::MouseCode code, int x, int y ); + virtual void OnMouseWheeled( int delta ); + + // Sets the zoom level + void SetZoom( float flZoom ); + +protected: + int m_lastx, m_lasty; + + float m_zoom; + float m_altitude, m_azimuth; + //vec3 m_lookat + + float m_prevZoom; + float m_prevAltitude, m_prevAzimuth; + + float m_flLastMouseTime; + float m_flLastTickTime; + float m_flSpin; + bool m_bSpin; + + void UpdateTransform( void ); + void UpdateZoom( float delta ); +}; + + +#endif // MANIPULATOR_H diff --git a/public/matsys_controls/matsyscontrols.h b/public/matsys_controls/matsyscontrols.h new file mode 100644 index 0000000..85fa580 --- /dev/null +++ b/public/matsys_controls/matsyscontrols.h @@ -0,0 +1,72 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef MATSYSCONTROLS_H +#define MATSYSCONTROLS_H + +#ifdef _WIN32 +#pragma once +#endif + +#include "tier1/interface.h" + + +//----------------------------------------------------------------------------- +// Forward declarations +//----------------------------------------------------------------------------- +class IMaterialSystem; +class IMaterialSystemHardwareConfig; +class IMDLCache; +class IMatSystemSurface; +class IStudioRender; + +namespace vgui +{ + +//----------------------------------------------------------------------------- +// handles the initialization of the vgui interfaces. +// NOTE: Calls into VGui_InitInterfacesList +// interfaces (listed below) are first attempted to be loaded from primaryProvider, then secondaryProvider +// moduleName should be the name of the module that this instance of the vgui_controls has been compiled into +//----------------------------------------------------------------------------- +bool VGui_InitMatSysInterfacesList( const char *moduleName, CreateInterfaceFn *factoryList, int numFactories ); + + +//----------------------------------------------------------------------------- +// set of accessor functions to matsys interfaces +// the appropriate header file for each is listed above the item +//----------------------------------------------------------------------------- + +// #include <materialsystem/imaterialsystem.h> +IMaterialSystem *MaterialSystem(); + +// #include <datacache/imdlcache.h> +IMDLCache *MDLCache(); + +// #include <VGuiMatSurface/IMatSystemSurface.h> +IMatSystemSurface *MatSystemSurface(); + +// #include <istudiorender.h" +IStudioRender *StudioRender(); + +// #include <materialsystem/imaterialsystemhardwareconfig.h> +IMaterialSystemHardwareConfig *MaterialSystemHardwareConfig(); + +} // end namespace vgui + + +//----------------------------------------------------------------------------- +// predeclare all the matsys control class names +//----------------------------------------------------------------------------- +class CMDLPanel; +class CMDLSequencePicker; +class CMDLPicker; +class CSequencePicker; +class CGameFileTreeView; + + +#endif // MATSYSCONTROLS_H diff --git a/public/matsys_controls/mdlpanel.h b/public/matsys_controls/mdlpanel.h new file mode 100644 index 0000000..b79979e --- /dev/null +++ b/public/matsys_controls/mdlpanel.h @@ -0,0 +1,158 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//============================================================================= + +#ifndef MDLPANEL_H +#define MDLPANEL_H + +#ifdef _WIN32 +#pragma once +#endif + + +#include "vgui_controls/Panel.h" +#include "datacache/imdlcache.h" +#include "materialsystem/MaterialSystemUtil.h" +#include "matsys_controls/potterywheelpanel.h" +#include "tier3/mdlutils.h" + + +//----------------------------------------------------------------------------- +// Forward declarations +//----------------------------------------------------------------------------- +namespace vgui +{ + class IScheme; +} + +// +struct MDLAnimEventState_t +{ + int m_nEventSequence; + float m_flPrevEventCycle; +}; + +//----------------------------------------------------------------------------- +// MDL Viewer Panel +//----------------------------------------------------------------------------- +class CMDLPanel : public CPotteryWheelPanel +{ + DECLARE_CLASS_SIMPLE( CMDLPanel, CPotteryWheelPanel ); + +public: + // constructor, destructor + CMDLPanel( vgui::Panel *pParent, const char *pName ); + virtual ~CMDLPanel(); + + // Overriden methods of vgui::Panel + virtual void ApplySchemeSettings( vgui::IScheme *pScheme ); + + virtual void OnTick(); + + virtual void Paint(); + + // Sets the current mdl + virtual void SetMDL( MDLHandle_t handle, void *pProxyData = NULL ); + virtual void SetMDL( const char *pMDLName, void *pProxyData = NULL ); + + // Sets the camera to look at the model + void LookAtMDL( ); + + // Sets the current LOD + void SetLOD( int nLOD ); + + // Sets the current sequence + void SetSequence( int nSequence, bool bResetSequence = false ); + + // Set the pose parameters + void SetPoseParameters( const float *pPoseParameters, int nCount ); + bool SetPoseParameterByName( const char *pszName, float fValue ); + + // Set the overlay sequence layers + void SetSequenceLayers( const MDLSquenceLayer_t *pSequenceLayers, int nCount ); + + void SetCollsionModel( bool bVisible ); + void SetGroundGrid( bool bVisible ); + void SetWireFrame( bool bVisible ); + void SetLockView( bool bLocked ); + void SetSkin( int nSkin ); + void SetLookAtCamera( bool bLookAtCamera ); + void SetIgnoreDoubleClick( bool bState ); + void SetThumbnailSafeZone( bool bVisible ); + + // Bounds. + bool GetBoundingBox( Vector &vecBoundsMin, Vector &vecBoundsMax ); + bool GetBoundingSphere( Vector &vecCenter, float &flRadius ); + + virtual void SetModelAnglesAndPosition( const QAngle &angRot, const Vector &vecPos ); + + // Attached models. + void SetMergeMDL( MDLHandle_t handle, void *pProxyData = NULL, int nSkin = -1 ); + MDLHandle_t SetMergeMDL( const char *pMDLName, void *pProxyData = NULL, int nSkin = -1 ); + int GetMergeMDLIndex( void *pProxyData ); + int GetMergeMDLIndex( MDLHandle_t handle ); + CMDL *GetMergeMDL(MDLHandle_t handle ); + void ClearMergeMDLs( void ); + + virtual void SetupFlexWeights( void ) { return; } + + // Events + void DoAnimationEvents(); + void DoAnimationEvents( CStudioHdr *pStudioHdr, int nSeqNum, float flTime, bool bNoLoop, MDLAnimEventState_t *pEventState ); + virtual void FireEvent( const char *pszEventName, const char *pszEventOptions ); + void ResetAnimationEventState( MDLAnimEventState_t *pEventState ); + +protected: + + virtual void SetupRenderState( int nDisplayWidth, int nDisplayHeight ) OVERRIDE; + + struct MDLData_t + { + CMDL m_MDL; + matrix3x4_t m_MDLToWorld; + bool m_bDisabled; + float m_flCycleStartTime; + }; + + MDLData_t m_RootMDL; + CUtlVector<MDLData_t> m_aMergeMDLs; + + static const int MAX_SEQUENCE_LAYERS = 8; + int m_nNumSequenceLayers; + MDLSquenceLayer_t m_SequenceLayers[ MAX_SEQUENCE_LAYERS ]; + + MDLAnimEventState_t m_EventState; + MDLAnimEventState_t m_SequenceLayerEventState[ MAX_SEQUENCE_LAYERS ]; + +private: + // paint it! + virtual void OnPaint3D(); + virtual void PrePaint3D( IMatRenderContext *pRenderContext ) { }; + virtual void PostPaint3D( IMatRenderContext *pRenderContext ) { }; + virtual void RenderingRootModel( IMatRenderContext *pRenderContext, CStudioHdr *pStudioHdr, MDLHandle_t mdlHandle, matrix3x4_t *pWorldMatrix ) { }; + virtual void RenderingMergedModel( IMatRenderContext *pRenderContext, CStudioHdr *pStudioHdr, MDLHandle_t mdlHandle, matrix3x4_t *pWorldMatrix ) { }; + virtual IMaterial* GetOverrideMaterial( MDLHandle_t mdlHandle ) { return NULL; } + + void OnMouseDoublePressed( vgui::MouseCode code ); + + void DrawCollisionModel(); + void UpdateStudioRenderConfig( void ); + + CTextureReference m_DefaultEnvCubemap; + CTextureReference m_DefaultHDREnvCubemap; + + bool m_bDrawCollisionModel : 1; + bool m_bGroundGrid : 1; + bool m_bLockView : 1; + bool m_bWireFrame : 1; + bool m_bLookAtCamera : 1; + bool m_bIgnoreDoubleClick : 1; + bool m_bThumbnailSafeZone : 1; + + float m_PoseParameters[ MAXSTUDIOPOSEPARAM ]; +}; + + +#endif // MDLPANEL_H diff --git a/public/matsys_controls/mdlpicker.h b/public/matsys_controls/mdlpicker.h new file mode 100644 index 0000000..fcacfc9 --- /dev/null +++ b/public/matsys_controls/mdlpicker.h @@ -0,0 +1,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 diff --git a/public/matsys_controls/mdlsequencepicker.h b/public/matsys_controls/mdlsequencepicker.h new file mode 100644 index 0000000..3150f16 --- /dev/null +++ b/public/matsys_controls/mdlsequencepicker.h @@ -0,0 +1,116 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//============================================================================= + +#ifndef MDLSEQUENCEPICKER_H +#define MDLSEQUENCEPICKER_H +#ifdef _WIN32 +#pragma once +#endif + +#include "vgui_controls/ImageList.h" +#include "vgui_controls/Frame.h" +#include "datacache/imdlcache.h" +#include "matsys_controls/mdlpanel.h" + + +//----------------------------------------------------------------------------- +// Forward declarations +//----------------------------------------------------------------------------- +namespace vgui +{ + class Splitter; + class Button; +} + +class CGameFileTreeView; + + +//----------------------------------------------------------------------------- +// Purpose: Main app window +//----------------------------------------------------------------------------- +class CMDLSequencePicker : public vgui::EditablePanel +{ + DECLARE_CLASS_SIMPLE( CMDLSequencePicker, vgui::EditablePanel ); +public: + CMDLSequencePicker( vgui::Panel *pParent ); + virtual ~CMDLSequencePicker(); + + // overridden frame functions + virtual void Activate(); + virtual void OnClose(); + virtual void PerformLayout(); + virtual void OnTick(); + + char const *GetModelName(); + char const *GetSequenceName(); + int GetSequenceNumber(); + +private: + void SelectMDL( const char *pMDLName ); + void RefreshFileList(); + void RefreshActivitiesAndSequencesList(); + + // Plays the selected activity + void PlaySelectedActivity( ); + + // Plays the selected sequence + void PlaySelectedSequence( ); + + MESSAGE_FUNC( OnFileSelected, "TreeViewItemSelected" ); + MESSAGE_FUNC_PTR_CHARPTR( OnTextChanged, "TextChanged", Panel, text ); + MESSAGE_FUNC_PARAMS( OnItemSelected, "ItemSelected", kv ); + MESSAGE_FUNC( OnPageChanged, "PageChanged" ); + + // changes +// MESSAGE_FUNC_INT( CloakFolder, "CloakFolder", item ); +// MESSAGE_FUNC_INT( OpenFileForEdit, "EditFile", item ); +// MESSAGE_FUNC_INT( OpenFileForDelete, "DeleteFile", item ); + + CMDLPanel *m_pMDLPreview; + vgui::ComboBox *m_pFilterList; + CGameFileTreeView *m_pFileTree; + vgui::ImageList m_Images; + vgui::Splitter* m_pMDLSplitter; + vgui::Splitter* m_pSequenceSplitter; + vgui::PropertySheet *m_pViewsSheet; + vgui::PropertyPage *m_pSequencesPage; + vgui::PropertyPage *m_pActivitiesPage; + + vgui::ListPanel *m_pSequencesList; + vgui::ListPanel *m_pActivitiesList; + + MDLHandle_t m_hSelectedMDL; + + friend class CMDLSequencePickerFrame; +}; + +//----------------------------------------------------------------------------- +// Model sequence picker frame +//----------------------------------------------------------------------------- +class CMDLSequencePickerFrame : public vgui::Frame +{ + DECLARE_CLASS_SIMPLE( CMDLSequencePickerFrame, vgui::Frame ); +public: + CMDLSequencePickerFrame( vgui::Panel *parent, char const *title ); + virtual ~CMDLSequencePickerFrame(); + + virtual void PerformLayout(); + +protected: + + virtual void OnTick(); + + MESSAGE_FUNC( OnOK, "OnOK" ); + MESSAGE_FUNC( OnCancel, "OnCancel" ); + +private: + CMDLSequencePicker *m_pMDLSequencePicker; + + vgui::Button *m_pOK; + vgui::Button *m_pCancel; +}; + +#endif // MDLSEQUENCEPICKER_H diff --git a/public/matsys_controls/picker.h b/public/matsys_controls/picker.h new file mode 100644 index 0000000..380e3bf --- /dev/null +++ b/public/matsys_controls/picker.h @@ -0,0 +1,133 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: An arbitrary picker +// +//============================================================================= + +#ifndef PICKER_H +#define PICKER_H +#ifdef _WIN32 +#pragma once +#endif + +#include "vgui_controls/EditablePanel.h" +#include "vgui_controls/Frame.h" +#include "tier1/utlstring.h" + + +//----------------------------------------------------------------------------- +// Forward declarations +//----------------------------------------------------------------------------- +namespace vgui +{ + class Panel; +} + + +//----------------------------------------------------------------------------- +// List of strings to appear in the picker +//----------------------------------------------------------------------------- +enum PickerChoiceType_t +{ + PICKER_CHOICE_STRING = 0, + PICKER_CHOICE_PTR, +}; + +struct PickerInfo_t +{ + const char *m_pChoiceString; // This is what displays in the dialog + union + { + const char *m_pChoiceValue; + void *m_pChoiceValuePtr; + }; +}; + +struct PickerList_t +{ + PickerList_t() : m_Type( PICKER_CHOICE_STRING ) {} + PickerList_t( int nGrowSize, int nInitSize ) : m_Choices( nGrowSize, nInitSize ), m_Type( PICKER_CHOICE_STRING ) {} + + int Count() const { return m_Choices.Count(); } + PickerInfo_t& operator[]( int i ) { return m_Choices[i]; } + const PickerInfo_t& operator[]( int i ) const { return m_Choices[i]; } + int AddToTail() { return m_Choices.AddToTail(); } + void RemoveAll() { return m_Choices.RemoveAll(); } + + PickerChoiceType_t m_Type; + CUtlVector< PickerInfo_t > m_Choices; +}; + + +//----------------------------------------------------------------------------- +// Purpose: Base class for choosing raw assets +//----------------------------------------------------------------------------- +class CPicker : public vgui::EditablePanel +{ + DECLARE_CLASS_SIMPLE( CPicker, vgui::EditablePanel ); + +public: + CPicker( vgui::Panel *pParent, const char *pColumnHeader, const char *pTextType ); + ~CPicker(); + + // Sets the list of strings to display + void SetStringList( const PickerList_t &list ); + + // Purpose: + virtual void OnKeyCodePressed( vgui::KeyCode code ); + + // Returns the selected string + PickerChoiceType_t GetSelectionType() const; + const char *GetSelectedString( ) const; + void *GetSelectedPtr( ) const; + + // Returns the index of the selected string + int GetSelectedIndex(); + +private: + void RefreshChoiceList( ); + MESSAGE_FUNC( OnTextChanged, "TextChanged" ); + + vgui::TextEntry *m_pFilterList; + vgui::ListPanel *m_pPickerBrowser; + CUtlString m_Filter; + const char *m_pPickerType; + const char *m_pPickerTextType; + const char *m_pPickerExt; + const char *m_pPickerSubDir; + PickerChoiceType_t m_Type; + + friend class CPickerFrame; +}; + + +//----------------------------------------------------------------------------- +// Purpose: Modal dialog for picker +//----------------------------------------------------------------------------- +class CPickerFrame : public vgui::Frame +{ + DECLARE_CLASS_SIMPLE( CPickerFrame, vgui::Frame ); + +public: + CPickerFrame( vgui::Panel *pParent, const char *pTitle, const char *pColumnHeader, const char *pTextType ); + ~CPickerFrame(); + + // Inherited from Frame + virtual void OnCommand( const char *pCommand ); + + // Purpose: Activate the dialog + // The message "Picked" will be sent if something is picked. + // You can pass in keyvalues to get added to the message also. + void DoModal( const PickerList_t &list, KeyValues *pContextKeyValues = NULL ); + +private: + void CleanUpMessage(); + + CPicker *m_pPicker; + vgui::Button *m_pOpenButton; + vgui::Button *m_pCancelButton; + KeyValues *m_pContextKeyValues; +}; + + +#endif // PICKER_H diff --git a/public/matsys_controls/potterywheelpanel.h b/public/matsys_controls/potterywheelpanel.h new file mode 100644 index 0000000..5da55e4 --- /dev/null +++ b/public/matsys_controls/potterywheelpanel.h @@ -0,0 +1,170 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//============================================================================= + +#ifndef POTTERYWHEELPANEL_H +#define POTTERYWHEELPANEL_H + +#ifdef _WIN32 +#pragma once +#endif + + +#include "vgui_controls/EditablePanel.h" +#include "materialsystem/MaterialSystemUtil.h" +#include "tier2/camerautils.h" + + +//----------------------------------------------------------------------------- +// Forward declarations +//----------------------------------------------------------------------------- +class IManipulator; +class CPotteryWheelManip; +class CBaseManipulator; +class CTransformManipulator; +class CDmxElement; + +namespace vgui +{ + class IScheme; +} + + +//----------------------------------------------------------------------------- +// Pottery wheel Panel +//----------------------------------------------------------------------------- +class CPotteryWheelPanel : public vgui::EditablePanel +{ + DECLARE_CLASS_SIMPLE( CPotteryWheelPanel, vgui::EditablePanel ); + +public: + // constructor, destructor + CPotteryWheelPanel( vgui::Panel *pParent, const char *pName ); + virtual ~CPotteryWheelPanel(); + + // Overriden methods of vgui::Panel + virtual void ApplySettings( KeyValues *inResourceData ); + virtual void Init( int x, int y, int wide, int tall ); + virtual void Paint(); + + virtual void OnKeyCodePressed ( vgui::KeyCode code ); + virtual void OnKeyCodeReleased( vgui::KeyCode code ); + virtual void OnMousePressed ( vgui::MouseCode code ); + virtual void OnMouseReleased( vgui::MouseCode code ); + virtual void OnCursorMoved( int x, int y ); + virtual void OnMouseWheeled( int delta ); + virtual void OnTick(); + + virtual void OnMouseCaptureLost(); + + // Sets the camera to look at the the thing we're spinning around + void LookAt( const Vector &vecCenter, float flRadius ); + void LookAt( float flRadius ); + + void ComputePanelPosition( const Vector &vecPosition, Vector2D *pPanelPos ); + + void SetBackgroundColor( int r, int g, int b ); + void SetBackgroundColor( const Color& c ); + const Color& GetBackgroundColor() const; + + // Light probe + void SetLightProbe( CDmxElement *pLightProbe ); + + // Camera. + int GetCameraFOV( void ); + void SetCameraFOV( float flFOV ); + void SetCameraPositionAndAngles( const Vector &vecPos, const QAngle &angDir, bool syncManipulators = true ); + void GetCameraPositionAndAngles( Vector &vecPos, QAngle &angDir ); + void SetCameraOffset( const Vector &vecOffset ); + void GetCameraOffset( Vector &vecOffset ); + void ResetCameraPivot( void ); + void ComputeCameraTransform( matrix3x4_t *pWorldToCamera ); + void UpdateCameraTransform(); + +private: + // Inherited classes must implement this + virtual void OnPaint3D() = 0; + +protected: + + enum + { + MAX_LIGHT_COUNT = 4 + }; + + struct LightInfo_t + { + LightDesc_t m_Desc; + matrix3x4_t m_LightToWorld; + }; + + + + enum ManipulationMode_t + { + CAMERA_ROTATE, + CAMERA_TRANSLATE, + CAMERA_ZOOM, + LIGHT_MODE, + }; + + virtual void EnterManipulationMode( ManipulationMode_t manipMode, bool bMouseCapture = true, vgui::MouseCode mouseCode = vgui::MouseCode( -1 ) ); + void Select(); + void AcceptManipulation( bool bReleaseMouseCapture = true ); + void CancelManipulation(); + void EnableMouseCapture( bool enable, vgui::MouseCode code = vgui::MouseCode( -1 ) ); + bool WarpMouse( int &x, int &y ); + IManipulator *m_pCurrentManip; + int m_nManipStartX, m_nManipStartY; + int m_nClickStartX, m_nClickStartY; + + // Re-apply the manipulators on a new model + void ApplyManipulation(); + + // Synchronize the manipulators with the current transform + void SyncManipulation(); + + bool HasLightProbe() const; + ITexture *GetLightProbeCubemap( bool bHDR ); + void DrawGrid(); + CMaterialReference m_Wireframe; + + bool m_bRenderToTexture; + + virtual void SetupRenderState( int nDisplayWidth, int nDisplayHeight ); + +private: + void CreateDefaultLights(); + void DestroyLights(); + void ParseLightsFromKV( KeyValues *pLightsKV ); + + CMaterialReference m_LightProbeBackground; + CMaterialReference m_LightProbeHDRBackground; + CTextureReference m_LightProbeCubemap; + CTextureReference m_LightProbeHDRCubemap; + + Camera_t m_Camera; + matrix3x4_t m_CameraPivot; + int m_nLightCount; + LightInfo_t m_Lights[MAX_LIGHT_COUNT]; + Vector4D m_vecAmbientCube[6]; + + Color m_ClearColor; + Vector m_vecCameraOffset; + CTransformManipulator *m_pCameraRotate; + CTransformManipulator *m_pCameraTranslate; + CBaseManipulator *m_pCameraZoom; + CPotteryWheelManip *m_pLightManip; + vgui::MouseCode m_nCaptureMouseCode; + + int m_xoffset, m_yoffset; + + bool m_bHasLightProbe : 1; + + CPanelAnimationVar( bool, m_bUseParentBG, "useparentbg", "0" ); +}; + + +#endif // SIMPLEPOTTERYWHEELPANEL_H diff --git a/public/matsys_controls/proceduraltexturepanel.h b/public/matsys_controls/proceduraltexturepanel.h new file mode 100644 index 0000000..3941be3 --- /dev/null +++ b/public/matsys_controls/proceduraltexturepanel.h @@ -0,0 +1,92 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//============================================================================= + +#ifndef PROCEDURALTEXTUREPANEL_H +#define PROCEDURALTEXTUREPANEL_H + +#ifdef _WIN32 +#pragma once +#endif + + +#include "materialsystem/itexture.h" +#include "materialsystem/MaterialSystemUtil.h" +#include "vgui_controls/EditablePanel.h" + + +//----------------------------------------------------------------------------- +// Forward declarations +//----------------------------------------------------------------------------- +struct BGRA8888_t; + + +//----------------------------------------------------------------------------- +// +// Procedural texture image panel +// +//----------------------------------------------------------------------------- +class CProceduralTexturePanel : public vgui::EditablePanel, public ITextureRegenerator +{ + DECLARE_CLASS_SIMPLE( CProceduralTexturePanel, vgui::EditablePanel ); + +public: + // constructor + CProceduralTexturePanel( vgui::Panel *pParent, const char *pName ); + ~CProceduralTexturePanel(); + + // Methods of ITextureRegenerator + virtual void Release() {} + virtual void RegenerateTextureBits( ITexture *pTexture, IVTFTexture *pVTFTexture, Rect_t *pRect ); + + // initialization, shutdown + virtual bool Init( int nWidth, int nHeight, bool bAllocateImageBuffer ); + virtual void Shutdown(); + + // Returns the image buffer + dimensions + BGRA8888_t *GetImageBuffer(); + int GetImageWidth() const; + int GetImageHeight() const; + + // Redownloads the procedural texture + void DownloadTexture(); + + // Sets the rectangle to paint. Use null to fill the entire panel + void SetPaintRect( const Rect_t *pPaintRect = NULL ); + + // Sets the texcoords to use with the procedural texture + void SetTextureSubRect( const Rect_t &subRect ); + + // Maintain proportions when drawing + void MaintainProportions( bool bEnable ); + + virtual void Paint( void ); + virtual void PaintBackground( void ) {} + +private: + void CleanUp(); + +protected: + // Image buffer + BGRA8888_t *m_pImageBuffer; + int m_nWidth; + int m_nHeight; + + // Paint rectangle + Rect_t m_PaintRect; + + // Texture coordinate rectangle + Rect_t m_TextureSubRect; + + CTextureReference m_ProceduralTexture; + CMaterialReference m_ProceduralMaterial; + + int m_nTextureID; + bool m_bMaintainProportions; + bool m_bUsePaintRect; +}; + + +#endif // PROCEDURALTEXTUREPANEL_H diff --git a/public/matsys_controls/sequencepicker.h b/public/matsys_controls/sequencepicker.h new file mode 100644 index 0000000..68e4729 --- /dev/null +++ b/public/matsys_controls/sequencepicker.h @@ -0,0 +1,111 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//============================================================================= + +#ifndef SEQUENCEPICKER_H +#define SEQUENCEPICKER_H +#ifdef _WIN32 +#pragma once +#endif + +#include "tier1/utlstring.h" +#include "vgui_controls/Frame.h" +#include "vgui_controls/EditablePanel.h" +#include "vgui_controls/ImageList.h" +#include "datacache/imdlcache.h" +#include "matsys_controls/mdlpanel.h" + + +//----------------------------------------------------------------------------- +// Forward declarations +//----------------------------------------------------------------------------- +namespace vgui +{ + class Splitter; +} + + +//----------------------------------------------------------------------------- +// Purpose: Sequence picker panel +//----------------------------------------------------------------------------- +class CSequencePicker : public vgui::EditablePanel +{ + DECLARE_CLASS_SIMPLE( CSequencePicker, vgui::EditablePanel ); + +public: + enum PickType_t + { + PICK_NONE = 0, + PICK_SEQUENCES = 0x1, + PICK_ACTIVITIES = 0x2, + PICK_ALL = 0xFFFFFFFF, + }; + + // Flags come from PickType_t + CSequencePicker( vgui::Panel *pParent, int nFlags = PICK_ALL ); + ~CSequencePicker(); + + // overridden frame functions + virtual void PerformLayout(); + + // Sets the MDL to preview sequences for + void SetMDL( const char *pMDLName ); + + // Gets the selected activity/sequence + PickType_t GetSelectedSequenceType(); + const char *GetSelectedSequenceName( ); + +private: + void RefreshActivitiesAndSequencesList(); + + // Plays the selected activity + void PlayActivity( const char *pActivityName ); + + // Plays the selected sequence + void PlaySequence( const char *pSequenceName ); + + MESSAGE_FUNC_PARAMS( OnItemSelected, "ItemSelected", kv ); + MESSAGE_FUNC( OnPageChanged, "PageChanged" ); + + CMDLPanel *m_pMDLPreview; + vgui::Splitter* m_pPreviewSplitter; + vgui::PropertySheet *m_pViewsSheet; + vgui::PropertyPage *m_pSequencesPage; + vgui::PropertyPage *m_pActivitiesPage; + vgui::ListPanel *m_pSequencesList; + vgui::ListPanel *m_pActivitiesList; + MDLHandle_t m_hSelectedMDL; + CUtlString m_Filter; + + friend class CSequencePickerFrame; +}; + + +//----------------------------------------------------------------------------- +// Purpose: Main app window +//----------------------------------------------------------------------------- +class CSequencePickerFrame : public vgui::Frame +{ + DECLARE_CLASS_SIMPLE( CSequencePickerFrame, vgui::Frame ); + +public: + CSequencePickerFrame( vgui::Panel *pParent, int nFlags ); + + // Inherited from Frame + virtual void OnCommand( const char *pCommand ); + + // Purpose: Activate the dialog + void DoModal( const char *pMDLName ); + +private: + MESSAGE_FUNC_PARAMS( OnSequencePreviewChanged, "SequencePreviewChanged", kv ); + + CSequencePicker *m_pPicker; + vgui::Button *m_pOpenButton; + vgui::Button *m_pCancelButton; +}; + + +#endif // SEQUENCEPICKER_H diff --git a/public/matsys_controls/tgapreviewpanel.h b/public/matsys_controls/tgapreviewpanel.h new file mode 100644 index 0000000..fc52adf --- /dev/null +++ b/public/matsys_controls/tgapreviewpanel.h @@ -0,0 +1,39 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//============================================================================= + +#ifndef TGAPREVIEWPANEL_H +#define TGAPREVIEWPANEL_H + +#ifdef _WIN32 +#pragma once +#endif + + +#include "matsys_controls/proceduraltexturepanel.h" +#include "tier1/utlstring.h" + + +//----------------------------------------------------------------------------- +// +// TGA Preview panel +// +//----------------------------------------------------------------------------- +class CTGAPreviewPanel : public CProceduralTexturePanel +{ + DECLARE_CLASS_SIMPLE( CTGAPreviewPanel, CProceduralTexturePanel ); + +public: + // constructor + CTGAPreviewPanel( vgui::Panel *pParent, const char *pName ); + void SetTGA( const char *pFullPath ); + const char *GetTGA() const; + +private: + CUtlString m_TGAName; +}; + + +#endif // TGAPREVIEWPANEL_H
\ No newline at end of file diff --git a/public/matsys_controls/vmtpanel.h b/public/matsys_controls/vmtpanel.h new file mode 100644 index 0000000..ee2e6cc --- /dev/null +++ b/public/matsys_controls/vmtpanel.h @@ -0,0 +1,91 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//===========================================================================// + +#ifndef VMTPANEL_H +#define VMTPANEL_H + +#ifdef _WIN32 +#pragma once +#endif + +#include "matsys_controls/potterywheelpanel.h" + + +//----------------------------------------------------------------------------- +// Forward declarations +//----------------------------------------------------------------------------- +class IMaterial; +class CMeshBuilder; +class Vector; + +namespace vgui +{ + class ScrollBar; + class IScheme; +} + + +//----------------------------------------------------------------------------- +// Material Viewer Panel +//----------------------------------------------------------------------------- +class CVMTPanel : public CPotteryWheelPanel +{ + DECLARE_CLASS_SIMPLE( CVMTPanel, CPotteryWheelPanel ); + +public: + // constructor, destructor + CVMTPanel( vgui::Panel *pParent, const char *pName ); + virtual ~CVMTPanel(); + + // Set the material to draw + void SetMaterial( IMaterial *pMaterial ); + + // Set rendering mode (stretch to full screen, or use actual size) + void RenderUsingActualSize( bool bEnable ); + + // performs the layout + virtual void PerformLayout(); + + virtual void ApplySchemeSettings( vgui::IScheme *pScheme ); + +private: + // paint it stretched to the window size + void DrawStretchedToPanel( CMeshBuilder &meshBuilder ); + + // paint it actual size + void DrawActualSize( CMeshBuilder &meshBuilder ); + + // Draw it on a sphere + void RenderSphere( const Vector &vCenter, float flRadius, int nTheta, int nPhi ); + + // paint it! + virtual void OnPaint3D(); + +private: + // The material to draw + IMaterial *m_pMaterial; + + // A texture to use for a lightmap + CTextureReference m_pLightmapTexture; + + // The default env_cubemap + CTextureReference m_DefaultEnvCubemap; + + // Are we using actual size or not? + bool m_bUseActualSize; + + // Scroll bars + vgui::ScrollBar *m_pHorizontalBar; + vgui::ScrollBar *m_pVerticalBar; + + // The viewable size + int m_iViewableWidth; + int m_iViewableHeight; +}; + +#endif // VMTPANEL_H +
\ No newline at end of file diff --git a/public/matsys_controls/vmtpicker.h b/public/matsys_controls/vmtpicker.h new file mode 100644 index 0000000..51499bf --- /dev/null +++ b/public/matsys_controls/vmtpicker.h @@ -0,0 +1,61 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//============================================================================= + +#ifndef VMTPICKER_H +#define VMTPICKER_H +#ifdef _WIN32 +#pragma once +#endif + +#include "matsys_controls/baseassetpicker.h" + + +//----------------------------------------------------------------------------- +// Forward declarations +//----------------------------------------------------------------------------- +class CVMTPreviewPanel; + +namespace vgui +{ + class Splitter; +} + + +//----------------------------------------------------------------------------- +// Purpose: Base class for choosing raw assets +//----------------------------------------------------------------------------- +class CVMTPicker : public CBaseAssetPicker +{ + DECLARE_CLASS_SIMPLE( CVMTPicker, CBaseAssetPicker ); + +public: + CVMTPicker( vgui::Panel *pParent, bool bAllowMultiselect = false ); + virtual ~CVMTPicker(); + +private: + // Derived classes have this called when the previewed asset changes + virtual void OnSelectedAssetPicked( const char *pAssetName ); + + CVMTPreviewPanel *m_pVMTPreview2D; + CVMTPreviewPanel *m_pVMTPreview3D; + vgui::Splitter *m_p2D3DSplitter; + vgui::Splitter *m_pPreviewSplitter; +}; + + +//----------------------------------------------------------------------------- +// Purpose: Modal dialog for asset picker +//----------------------------------------------------------------------------- +class CVMTPickerFrame : public CBaseAssetPickerFrame +{ + DECLARE_CLASS_SIMPLE( CVMTPickerFrame, CBaseAssetPickerFrame ); + +public: + CVMTPickerFrame( vgui::Panel *pParent, const char *pTitle, bool bAllowMultiselect = false ); +}; + + +#endif // VMTPICKER_H diff --git a/public/matsys_controls/vmtpreviewpanel.h b/public/matsys_controls/vmtpreviewpanel.h new file mode 100644 index 0000000..f080d6c --- /dev/null +++ b/public/matsys_controls/vmtpreviewpanel.h @@ -0,0 +1,81 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//============================================================================= + +#ifndef VMTPREVIEWPANEL_H +#define VMTPREVIEWPANEL_H + +#ifdef _WIN32 +#pragma once +#endif + + +#include "vgui_controls/Panel.h" +#include "tier1/utlstring.h" +#include "materialsystem/MaterialSystemUtil.h" +#include "mathlib/vector.h" + + +//----------------------------------------------------------------------------- +// Forward declarations +//----------------------------------------------------------------------------- + + +//----------------------------------------------------------------------------- +// +// VMT Preview panel +// +//----------------------------------------------------------------------------- +class CVMTPreviewPanel : public vgui::Panel +{ + DECLARE_CLASS_SIMPLE( CVMTPreviewPanel, vgui::Panel ); + +public: + // constructor + CVMTPreviewPanel( vgui::Panel *pParent, const char *pName ); + void SetVMT( const char *pMaterialName ); + const char *GetVMT() const; + + // Paints the texture + virtual void Paint( void ); + + // View it in 3D or 2D mode + void DrawIn3DMode( bool b3DMode ); + +private: + // Two different preview methods + void DrawSphere( void ); + void DrawRectangle( void ); + + // Set up a projection matrix for a 90 degree fov + void SetupProjectionMatrix( int nWidth, int nHeight ); + void SetupOrthoMatrix( int nWidth, int nHeight ); + + // Sets the camera to look at the the thing we're spinning around + void LookAt( const Vector &vecLookAt, float flRadius ); + + // Sets up lighting state + void SetupLightingState(); + + // Draw a sphere + void RenderSphere( const Vector &vCenter, float flRadius, int nTheta, int nPhi ); + + // Draw sprite-card based materials + void RenderSpriteCard( const Vector &vCenter, float flRadius ); + + CUtlString m_VMTName; + CMaterialReference m_Material; + CTextureReference m_pLightmapTexture; + CTextureReference m_DefaultEnvCubemap; + Vector m_LightDirection; + Color m_LightColor; + float m_flLightIntensity; + Vector m_vecCameraDirection; + float m_flLastRotationTime; + bool m_bDrawIn3DMode; +}; + + +#endif // VMTPREVIEWPANEL_H
\ No newline at end of file diff --git a/public/matsys_controls/vtfpicker.h b/public/matsys_controls/vtfpicker.h new file mode 100644 index 0000000..ce8478a --- /dev/null +++ b/public/matsys_controls/vtfpicker.h @@ -0,0 +1,59 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//============================================================================= + +#ifndef VTFPICKER_H +#define VTFPICKER_H +#ifdef _WIN32 +#pragma once +#endif + +#include "matsys_controls/baseassetpicker.h" + + +//----------------------------------------------------------------------------- +// Forward declarations +//----------------------------------------------------------------------------- +class CVTFPreviewPanel; + +namespace vgui +{ + class Splitter; +} + + +//----------------------------------------------------------------------------- +// Purpose: Base class for choosing raw assets +//----------------------------------------------------------------------------- +class CVTFPicker : public CBaseAssetPicker +{ + DECLARE_CLASS_SIMPLE( CVTFPicker, CBaseAssetPicker ); + +public: + CVTFPicker( vgui::Panel *pParent ); + virtual ~CVTFPicker(); + +private: + // Derived classes have this called when the previewed asset changes + virtual void OnSelectedAssetPicked( const char *pAssetName ); + + CVTFPreviewPanel *m_pVTFPreview; + vgui::Splitter *m_pPreviewSplitter; +}; + + +//----------------------------------------------------------------------------- +// Purpose: Modal dialog for asset picker +//----------------------------------------------------------------------------- +class CVTFPickerFrame : public CBaseAssetPickerFrame +{ + DECLARE_CLASS_SIMPLE( CVTFPickerFrame, CBaseAssetPickerFrame ); + +public: + CVTFPickerFrame( vgui::Panel *pParent, const char *pTitle ); +}; + + +#endif // VTFPICKER_H diff --git a/public/matsys_controls/vtfpreviewpanel.h b/public/matsys_controls/vtfpreviewpanel.h new file mode 100644 index 0000000..7fdccbc --- /dev/null +++ b/public/matsys_controls/vtfpreviewpanel.h @@ -0,0 +1,70 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//============================================================================= + +#ifndef VTFPREVIEWPANEL_H +#define VTFPREVIEWPANEL_H + +#ifdef _WIN32 +#pragma once +#endif + + +#include "vgui_controls/Panel.h" +#include "tier1/utlstring.h" +#include "materialsystem/MaterialSystemUtil.h" +#include "mathlib/vector.h" + + +//----------------------------------------------------------------------------- +// Forward declarations +//----------------------------------------------------------------------------- + + +//----------------------------------------------------------------------------- +// +// VTF Preview panel +// +//----------------------------------------------------------------------------- +class CVTFPreviewPanel : public vgui::Panel +{ + DECLARE_CLASS_SIMPLE( CVTFPreviewPanel, vgui::Panel ); + +public: + // constructor + CVTFPreviewPanel( vgui::Panel *pParent, const char *pName ); + virtual ~CVTFPreviewPanel(); + + void SetVTF( const char *pFullPath, bool bLoadImmediately = true ); + const char *GetVTF() const; + + // Paints the texture + virtual void Paint( void ); + +private: + void PaintNormalMapTexture( void ); + void PaintCubeTexture( void ); + void PaintStandardTexture( void ); + void PaintVolumeTexture( void ); + + // Set up a projection matrix for a 90 degree fov + void SetupProjectionMatrix( int nWidth, int nHeight ); + + // Sets the camera to look at the the thing we're spinning around + void LookAt( const Vector &vecLookAt, float flRadius ); + + // Draw a sphere + void RenderSphere( const Vector &vCenter, float flRadius, int nTheta, int nPhi ); + + CUtlString m_VTFName; + CTextureReference m_PreviewTexture; + CMaterialReference m_PreviewMaterial; + int m_nTextureID; + Vector m_vecCameraDirection; + float m_flLastRotationTime; +}; + + +#endif // VTFPREVIEWPANEL_H
\ No newline at end of file |