This commit is contained in:
nephacks
2025-06-04 03:22:50 +02:00
parent f234f23848
commit f12416cffd
14243 changed files with 6446499 additions and 26 deletions
+131
View File
@@ -0,0 +1,131 @@
//======= Copyright © 1996-2008, Valve Corporation, All rights reserved. ======
//
// Purpose: A 2D Slider
//
//=============================================================================
#ifndef C2DSLIDER_H
#define C2DSLIDER_H
#include <vgui_controls/Panel.h>
class vgui::TextImage;
//-----------------------------------------------------------------------------
// Purpose: A 2D Slider
//-----------------------------------------------------------------------------
class C2DSlider : public vgui::Panel
{
DECLARE_CLASS_SIMPLE( C2DSlider, vgui::Panel );
public:
C2DSlider( Panel *pParent, const char *pName );
virtual ~C2DSlider();
// interface
virtual void SetValueX( float fValueX, bool bTriggerChangeMessage = true );
virtual float GetValueX() const;
virtual void SetValueY( float fValueY, bool bTriggerChangeMessage = true );
virtual float GetValueY() const;
virtual void SetValue( float fValueX, float fValueY, bool bTriggerChangeMessage = true );
virtual void GetValue( float &fValueX, float &fValueY ) const;
virtual void SetRange( float fMinX, float fMaxX, float fMinY, float fMaxY, bool bTriggerChangeMessage = true );
virtual void GetRange( float &fMinX, float &fMaxX, float &fMinY, float &fMaxY ) const;
virtual void SetLabelText( const char *pText );
virtual void SetLabelText( const wchar_t *pText );
virtual void GetLabelText( wchar_t *pBuffer, int nBufferLen ) const;
virtual void GetLabelUnlocalizedText( char *pBuffer, int nBufferLen ) const;
virtual void SetDrawLabel( bool bState );
virtual bool IsDrawingLabel() const;
virtual void GetNobPos( int &nX, int &nY );
virtual void OnCursorMoved( int x, int y );
virtual void OnMousePressed( vgui::MouseCode mouseCode );
virtual void OnMouseDoublePressed( vgui::MouseCode mouseCode );
virtual void OnMouseReleased( vgui::MouseCode mouseCode );
virtual void SetNobWidth( int nWidth );
virtual int GetNobWidth() const;
virtual void SetNobTall( int nTall );
virtual int GetNobTall() const;
virtual void SetNobSize( int nWidth, int nTall );
virtual void GetNobSize( int &nWidth, int &nTall ) const;
// If you click on the slider outside of the nob, the nob jumps
// to the click position, and if this setting is enabled, the nob
// is then draggable from the new position until the mouse is released
virtual void SetDragOnRepositionNob( bool bState );
virtual bool IsDragOnRepositionNob() const;
// Get if the slider nob is being dragged by user, usually the application
// should refuse from forcefully setting slider value if it is being dragged
// by user since the next frame the nob will pop back to mouse position
virtual bool IsDragged() const;
protected:
virtual void OnSizeChanged( int nWide, int nTall );
virtual void Paint();
virtual void PaintBackground();
virtual void PerformLayout();
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
virtual void ApplySettings( KeyValues *pInResourceData );
virtual void GetSettings( KeyValues *pOutResourceData );
virtual const char *GetDescription();
virtual void OnKeyCodeTyped( vgui::KeyCode nKeyCode );
virtual void DrawNob();
virtual void GetTrackRect( int &x, int &y, int &w, int &t );
virtual void MoveNobRelative( int nX, int nY );
virtual void RecomputeNobPosFromValue();
virtual void RecomputeValueFromNobPos( bool bTriggerChangeMessage = true );
virtual void SendSliderMovedMessage();
virtual void SendSliderDragStartMessage();
virtual void SendSliderDragEndMessage();
enum Axis_t
{
kXAxis = 0,
kYAxis = 1,
kAxisCount = 2
};
int m_nNobPos[ kAxisCount ]; // Position of the center of the nob in client space pixels
int m_nNobDragStartPos[ kAxisCount ];
int m_nDragStartPos[ kAxisCount ];
float m_fRange[ kAxisCount ][ 2 ];
float m_fValue[ kAxisCount ]; // the position of the Slider, in coordinates as specified by SetRange
vgui::IBorder *m_pNobBorder;
vgui::IBorder *m_pInsetBorder;
int m_nNobHalfSize[ kAxisCount ]; // The number of pixels on each side of the nob center, can be 0 for a 1x1 pixel nob. nob size = m_nNobHalfSize * 2 + 1
static Color s_TextColor;
static Color s_NobColor;
static Color s_TickColor;
static Color s_TickFillXColor;
static Color s_TickFillYColor;
static Color s_TickFillColor;
static Color s_TrackColor;
bool m_bDrawLabel : 1;
bool m_bIsDragOnRepositionNob : 1;
bool m_bDragging : 1;
vgui::TextImage *m_pLabel;
};
#endif // C2DSLIDER_H
+218
View File
@@ -0,0 +1,218 @@
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======
//
// Purpose:
//
//=============================================================================
#ifndef ASSETBUILDER_H
#define ASSETBUILDER_H
#ifdef _WIN32
#pragma once
#endif
#include "vgui_controls/Frame.h"
#include "vgui_controls/FileOpenStateMachine.h"
#include "vgui_controls/PHandle.h"
#include "datamodel/dmehandle.h"
#include "tier1/utlstack.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
namespace vgui
{
class IScheme;
class ListPanel;
class Menu;
class MenuButton;
class Splitter;
class FileOpenStateMachine;
class PropertySheet;
class PropertyPage;
}
class CDmePanel;
class CCompileStatusBar;
class CDmeMakefile;
class CDmeSource;
struct DmeMakefileType_t;
enum CompilationState_t;
//-----------------------------------------------------------------------------
// Purpose: Asset builder
//-----------------------------------------------------------------------------
class CAssetBuilder : public vgui::EditablePanel
{
DECLARE_CLASS_SIMPLE( CAssetBuilder, EditablePanel );
public:
CAssetBuilder( vgui::Panel *pParent, const char *pPanelName );
virtual ~CAssetBuilder();
// Inherited from vgui::Frame
virtual void OnCommand( const char *pCommand );
virtual void OnKeyCodeTyped( vgui::KeyCode code );
virtual void OnTick();
void SetRootMakefile( CDmeMakefile *pMakeFile );
void SetCurrentMakefile( CDmeMakefile *pMakeFile );
void SetDmeElement( CDmeMakefile *pMakeFile );
CDmeMakefile *GetMakeFile();
CDmeMakefile *GetRootMakeFile();
void Refresh();
// Default behavior is to destroy the makefile when we close
void DestroyMakefileOnClose( bool bEnable );
/*
messages sent:
"DmeElementChanged" The makefile has been changed
*/
private:
MESSAGE_FUNC_PARAMS( OnItemSelected, "ItemSelected", kv );
MESSAGE_FUNC_PARAMS( OnItemDeselected, "ItemDeselected", kv );
MESSAGE_FUNC_PARAMS( OnFileSelected, "FileSelected", kv );
MESSAGE_FUNC_PARAMS( OnOpenContextMenu, "OpenContextMenu", kv );
MESSAGE_FUNC_PARAMS( OnPicked, "Picked", kv );
MESSAGE_FUNC( SetDirty, "DmeElementChanged" );
MESSAGE_FUNC( OnAddSource, "AddSource" );
MESSAGE_FUNC( OnNewSourceFile, "NewSourceFile" );
MESSAGE_FUNC( OnLoadSourceFile, "LoadSourceFile" );
MESSAGE_FUNC( OnEditSourceFile, "EditSourceFile" );
MESSAGE_FUNC( OnRemoveSource, "RemoveSource" );
MESSAGE_FUNC( OnBrowseSourceFile, "BrowseSourceFile" );
MESSAGE_FUNC( OnZoomInSource, "ZoomInSource" );
MESSAGE_FUNC( OnZoomOutSource, "ZoomOutSource" );
void OnCompile();
void OnAbortCompile();
void OnPublish();
// Called to create a new makefile
void OnNewSourceFileSelected( const char *pFileName, KeyValues *pDialogKeys );
// Called when a list panel's selection changes
void OnSourceItemSelectionChanged( );
// Refresh the source list
void RefreshSourceList( );
// Refreshes the output list
void RefreshOutputList();
// Selects a particular source
void SelectSource( CDmeSource *pSource );
// Called when the source file name changes
void OnSourceFileNameChanged( const char *pFileName );
// Called when we're browsing for a source file and one was selected
void OnSourceFileAdded( const char *pFileName, const char *pTypeName );
// Shows the source file browser
void ShowSourceFileBrowser( const char *pTitle, DmeMakefileType_t *pSourceType, KeyValues *pDialogKeys );
// Make all outputs writeable
void MakeOutputsWriteable( );
// Cleans up the context menu
void CleanupContextMenu();
// Removes a makefile from memory
void CleanupMakefile();
// Builds a unique list of file IDs
void BuildFileIDList( CDmeMakefile *pMakeFile, CUtlVector<DmFileId_t> &fileIds );
// Selects a particular row of the source list
void SelectSourceListRow( int nRow );
// Returns the curerntly selected row
int GetSelectedRow( );
// Finishes compilation
void FinishCompilation( CompilationState_t state );
// Returns the selected source (if there's only 1 source selected)
CDmeSource *GetSelectedSource( );
KeyValues *GetSelectedSourceKeyvalues( );
vgui::PropertySheet *m_pInputOutputSheet;
vgui::PropertyPage *m_pInputPage;
vgui::PropertyPage *m_pOutputPage;
vgui::PropertyPage *m_pCompilePage;
vgui::PropertyPage *m_pOutputPreviewPage;
vgui::Splitter *m_pPropertiesSplitter;
vgui::ListPanel *m_pSourcesList;
vgui::ListPanel *m_pOutputList;
CDmePanel *m_pDmePanel;
CDmePanel *m_pOututPreviewPanel;
vgui::TextEntry *m_pCompileOutput;
vgui::Button *m_pCompile;
vgui::Button *m_pPublish;
vgui::Button *m_pAbortCompile;
vgui::DHANDLE< vgui::Menu > m_hContextMenu;
CCompileStatusBar *m_pCompileStatusBar;
CDmeHandle< CDmeMakefile > m_hRootMakefile;
CDmeHandle< CDmeMakefile > m_hMakefile;
CUtlStack< CDmeHandle< CDmeMakefile > > m_hMakefileStack;
bool m_bIsCompiling : 1;
bool m_bDestroyMakefileOnClose : 1;
};
//-----------------------------------------------------------------------------
// Purpose: Asset builder frame
//-----------------------------------------------------------------------------
class CAssetBuilderFrame : public vgui::Frame, public vgui::IFileOpenStateMachineClient
{
DECLARE_CLASS_SIMPLE( CAssetBuilderFrame, vgui::Frame );
public:
CAssetBuilderFrame( vgui::Panel *pParent, const char *pTitle );
virtual ~CAssetBuilderFrame();
// Inherited from IFileOpenStateMachineClient
virtual void SetupFileOpenDialog( vgui::FileOpenDialog *pDialog, bool bOpenFile, const char *pFileFormat, KeyValues *pContextKeyValues );
virtual bool OnReadFileFromDisk( const char *pFileName, const char *pFileFormat, KeyValues *pContextKeyValues );
virtual bool OnWriteFileToDisk( const char *pFileName, const char *pFileFormat, KeyValues *pContextKeyValues );
protected:
// Call to change the makefile
void Reset( CDmeMakefile *pMakefile );
CAssetBuilder *m_pAssetBuilder;
private:
MESSAGE_FUNC( OnDmeElementChanged, "DmeElementChanged" );
MESSAGE_FUNC( OnFileNew, "FileNew" );
MESSAGE_FUNC( OnFileOpen, "FileOpen" );
MESSAGE_FUNC( OnFileSave, "FileSave" );
MESSAGE_FUNC( OnFileSaveAs, "FileSaveAs" );
MESSAGE_FUNC_PARAMS( OnPicked, "Picked", kv );
MESSAGE_FUNC_PARAMS( OnFileSelected, "FileSelected", kv );
MESSAGE_FUNC_PARAMS( OnFileStateMachineFinished, "FileStateMachineFinished", kv );
MESSAGE_FUNC_PARAMS( OnPerformFileNew, "PerformFileNew", kv );
// Updates the file name
MESSAGE_FUNC( UpdateFileName, "UpdateFileName" );
// Shows a picker for creating a new asset
void ShowNewAssetPicker( );
// Marks the file dirty ( or not )
void SetDirty( bool bDirty );
bool IsDirty() const;
vgui::FileOpenStateMachine *m_pFileOpenStateMachine;
CUtlString m_TitleString;
};
#endif // ASSETBUILDER_H
@@ -0,0 +1,52 @@
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======//
//
// Purpose:
//
// $NoKeywords: $
//
//=============================================================================//
#ifndef ATTRIBUTEBASEPICKERPANEL_H
#define ATTRIBUTEBASEPICKERPANEL_H
#ifdef _WIN32
#pragma once
#endif
#include "dme_controls/AttributeTextPanel.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CDmElement;
namespace vgui
{
class Button;
}
//-----------------------------------------------------------------------------
// CAttributeBasePickerPanel
//-----------------------------------------------------------------------------
class CAttributeBasePickerPanel : public CAttributeTextPanel
{
DECLARE_CLASS_SIMPLE( CAttributeBasePickerPanel, CAttributeTextPanel );
public:
CAttributeBasePickerPanel( vgui::Panel *parent, const AttributeWidgetInfo_t &info );
// Inherited from Panel
virtual void OnCommand( const char *cmd );
virtual void PerformLayout();
private:
// Inherited classes must implement this
virtual void ShowPickerDialog() = 0;
vgui::Button *m_pOpen;
};
#endif // ATTRIBUTEBASEPICKERPANEL_H
@@ -0,0 +1,69 @@
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======//
//
// Purpose:
//
// $NoKeywords: $
//
//=============================================================================//
#ifndef ATTRIBUTEBOOLCHOICEPANEL_h
#define ATTRIBUTEBOOLCHOICEPANEL_h
#ifdef _WIN32
#pragma once
#endif
#include "dme_controls/BaseAttributeChoicePanel.h"
#include "movieobjects/dmeeditortypedictionary.h"
#include "vgui_controls/MessageMap.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
struct AttributeWidgetInfo_t;
namespace vgui
{
class Panel;
class ComboBox;
}
//-----------------------------------------------------------------------------
// Configuration for integer choices
//-----------------------------------------------------------------------------
class CDmeEditorBoolChoicesInfo : public CDmeEditorChoicesInfo
{
DEFINE_ELEMENT( CDmeEditorBoolChoicesInfo, CDmeEditorChoicesInfo );
public:
// Add a choice
void SetFalseChoice( const char *pChoiceString );
void SetTrueChoice( const char *pChoiceString );
// Gets the choices
const char *GetFalseChoiceString( ) const;
const char *GetTrueChoiceString( ) const;
};
//-----------------------------------------------------------------------------
// CAttributeBoolChoicePanel
//-----------------------------------------------------------------------------
class CAttributeBoolChoicePanel : public CBaseAttributeChoicePanel
{
DECLARE_CLASS_SIMPLE( CAttributeBoolChoicePanel, CBaseAttributeChoicePanel );
public:
CAttributeBoolChoicePanel( vgui::Panel *parent, const AttributeWidgetInfo_t &info );
private:
// Derived classes can re-implement this to fill the combo box however they like
virtual void PopulateComboBox( vgui::ComboBox *pComboBox );
virtual void SetAttributeFromComboBox( vgui::ComboBox *pComboBox, KeyValues *pKeyValues );
virtual void SetComboBoxFromAttribute( vgui::ComboBox *pComboBox );
};
#endif // ATTRIBUTEBOOLCHOICEPANEL_h
@@ -0,0 +1,57 @@
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======//
//
// Purpose:
//
// $NoKeywords: $
//
//=============================================================================//
#ifndef ATTRIBUTECOLORPICKERPANEL_H
#define ATTRIBUTECOLORPICKERPANEL_H
#ifdef _WIN32
#pragma once
#endif
#include "dme_controls/AttributeTextPanel.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CDmElement;
namespace vgui
{
class Button;
}
//-----------------------------------------------------------------------------
// CAttributeColorPickerPanel
//-----------------------------------------------------------------------------
class CAttributeColorPickerPanel : public CAttributeTextPanel
{
DECLARE_CLASS_SIMPLE( CAttributeColorPickerPanel, CAttributeTextPanel );
public:
CAttributeColorPickerPanel( vgui::Panel *parent, const AttributeWidgetInfo_t &info );
// Inherited from Panel
virtual void OnCommand( const char *cmd );
virtual void PerformLayout();
virtual void Refresh();
virtual void ApplySchemeSettings(IScheme *pScheme);
private:
MESSAGE_FUNC_PARAMS( OnPreview, "ColorPickerPreview", data );
MESSAGE_FUNC_PARAMS( OnPicked, "ColorPickerPicked", data );
MESSAGE_FUNC( OnCancelled, "ColorPickerCancel" );
void UpdateButtonColor();
vgui::Button *m_pOpen;
Color m_InitialColor;
};
#endif // ATTRIBUTECOLORPICKERPANEL_H
@@ -0,0 +1,63 @@
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======//
//
// Purpose:
//
// $NoKeywords: $
//
//=============================================================================//
#ifndef ATTRIBUTEELEMENTPANEL_H
#define ATTRIBUTEELEMENTPANEL_H
#ifdef _WIN32
#pragma once
#endif
#include "dme_controls/BaseAttributePanel.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CDmElement;
class CAttributeTextEntry;
namespace vgui
{
class Label;
}
//-----------------------------------------------------------------------------
// CAttributeElementPanel
//-----------------------------------------------------------------------------
class CAttributeElementPanel : public CBaseAttributePanel
{
DECLARE_CLASS_SIMPLE( CAttributeElementPanel, CBaseAttributePanel );
public:
CAttributeElementPanel( vgui::Panel *parent, const AttributeWidgetInfo_t &info );
virtual void PostConstructor();
virtual void Apply();
protected:
virtual vgui::Panel *GetDataPanel();
virtual void SetFont( HFont font );
virtual void OnCreateDragData( KeyValues *msg );
MESSAGE_FUNC(OnTextChanged, "TextChanged")
{
SetDirty( true );
}
private:
virtual void Refresh();
CAttributeTextEntry *m_pData;
bool m_bShowMemoryUsage;
bool m_bShowUniqueID;
};
#endif // ATTRIBUTEELEMENTPANEL_H
@@ -0,0 +1,62 @@
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======//
//
// Purpose:
//
// $NoKeywords: $
//
//=============================================================================//
#ifndef ATTRIBUTEELEMENTPICKERPANEL_H
#define ATTRIBUTEELEMENTPICKERPANEL_H
#ifdef _WIN32
#pragma once
#endif
#include "dme_controls/BaseAttributeChoicePanel.h"
#include "vgui_controls/phandle.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CDmElement;
class CAttributeTextEntry;
namespace vgui
{
class Label;
}
//-----------------------------------------------------------------------------
// CAttributeElementPickerPanel
//-----------------------------------------------------------------------------
class CAttributeElementPickerPanel : public CBaseAttributePanel
{
DECLARE_CLASS_SIMPLE( CAttributeElementPickerPanel, CBaseAttributePanel );
public:
CAttributeElementPickerPanel( vgui::Panel *parent, const AttributeWidgetInfo_t &info );
virtual void OnCommand( const char *cmd );
virtual void PerformLayout();
virtual void PostConstructor();
virtual void Apply();
private:
// Inherited classes must implement this
virtual Panel *GetDataPanel();
virtual void Refresh();
MESSAGE_FUNC_PARAMS( OnDmeSelected, "DmeSelected", kv );
virtual void ShowPickerDialog();
vgui::DHANDLE< vgui::Button > m_hEdit;
CAttributeTextEntry *m_pData;
bool m_bShowMemoryUsage;
bool m_bShowUniqueID;
};
#endif // ATTRIBUTEELEMENTPICKERPANEL_H
@@ -0,0 +1,81 @@
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======//
//
// Purpose:
//
// $NoKeywords: $
//
//=============================================================================//
#ifndef ATTRIBUTEFILEPICKERPANEL_H
#define ATTRIBUTEFILEPICKERPANEL_H
#ifdef _WIN32
#pragma once
#endif
#include "dme_controls/AttributeBasePickerPanel.h"
#include "vgui_controls/phandle.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CDmElement;
namespace vgui
{
class FileOpenDialog;
}
//-----------------------------------------------------------------------------
// CAttributeFilePickerPanel
//-----------------------------------------------------------------------------
class CAttributeFilePickerPanel : public CAttributeBasePickerPanel
{
DECLARE_CLASS_SIMPLE( CAttributeFilePickerPanel, CAttributeBasePickerPanel );
public:
CAttributeFilePickerPanel( vgui::Panel *parent, const AttributeWidgetInfo_t &info );
~CAttributeFilePickerPanel();
private:
MESSAGE_FUNC_CHARPTR( OnFileSelected, "FileSelected", fullpath );
virtual void ShowPickerDialog();
virtual void SetupFileOpenDialog( vgui::FileOpenDialog *pDialog ) = 0;
};
//-----------------------------------------------------------------------------
// Macro to quickly make new attribute types
//-----------------------------------------------------------------------------
#define DECLARE_ATTRIBUTE_FILE_PICKER( _className ) \
class _className : public CAttributeFilePickerPanel \
{ \
DECLARE_CLASS_SIMPLE( _className, CAttributeFilePickerPanel ); \
public: \
_className( vgui::Panel *parent, const AttributeWidgetInfo_t &info ) : \
BaseClass( parent, info ) {} \
private: \
virtual void SetupFileOpenDialog( vgui::FileOpenDialog *pDialog ); \
}
#define IMPLEMENT_ATTRIBUTE_FILE_PICKER( _className, _popupTitle, _assetType, _assetExt ) \
void _className::SetupFileOpenDialog( vgui::FileOpenDialog *pDialog ) \
{ \
pDialog->SetTitle( _popupTitle, true ); \
pDialog->AddFilter( "*." _assetExt, _assetType " (*." _assetExt ")", true ); \
pDialog->AddFilter( "*.*", "All Files (*.*)", false ); \
}
//-----------------------------------------------------------------------------
// File picker types
//-----------------------------------------------------------------------------
DECLARE_ATTRIBUTE_FILE_PICKER( CAttributeDmeFilePickerPanel );
DECLARE_ATTRIBUTE_FILE_PICKER( CAttributeAviFilePickerPanel );
DECLARE_ATTRIBUTE_FILE_PICKER( CAttributeShtFilePickerPanel );
DECLARE_ATTRIBUTE_FILE_PICKER( CAttributeRawFilePickerPanel );
#endif // ATTRIBUTEFILEPICKERPANEL_H
@@ -0,0 +1,67 @@
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======//
//
// Purpose:
//
// $NoKeywords: $
//
//=============================================================================//
#ifndef ATTRIBUTEINTCHOICEPANEL_h
#define ATTRIBUTEINTCHOICEPANEL_h
#ifdef _WIN32
#pragma once
#endif
#include "dme_controls/BaseAttributeChoicePanel.h"
#include "movieobjects/dmeeditortypedictionary.h"
#include "vgui_controls/MessageMap.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
struct AttributeWidgetInfo_t;
namespace vgui
{
class Panel;
class ComboBox;
}
//-----------------------------------------------------------------------------
// Configuration for integer choices
//-----------------------------------------------------------------------------
class CDmeEditorIntChoicesInfo : public CDmeEditorChoicesInfo
{
DEFINE_ELEMENT( CDmeEditorIntChoicesInfo, CDmeEditorChoicesInfo );
public:
// Add a choice
void AddChoice( int nValue, const char *pChoiceString );
// Gets the choices
int GetChoiceValue( int nIndex ) const;
};
//-----------------------------------------------------------------------------
// CAttributeIntChoicePanel
//-----------------------------------------------------------------------------
class CAttributeIntChoicePanel : public CBaseAttributeChoicePanel
{
DECLARE_CLASS_SIMPLE( CAttributeIntChoicePanel, CBaseAttributeChoicePanel );
public:
CAttributeIntChoicePanel( vgui::Panel *parent, const AttributeWidgetInfo_t &info );
private:
// Derived classes can re-implement this to fill the combo box however they like
virtual void PopulateComboBox( vgui::ComboBox *pComboBox );
virtual void SetAttributeFromComboBox( vgui::ComboBox *pComboBox, KeyValues *pKeyValues );
virtual void SetComboBoxFromAttribute( vgui::ComboBox *pComboBox );
};
#endif // ATTRIBUTEINTCHOICEPANEL_h
@@ -0,0 +1,49 @@
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======//
//
// Purpose:
//
// $NoKeywords: $
//
//=============================================================================//
#ifndef ATTRIBUTEINTERPOLATORTYPECHOICEPANEL_h
#define ATTRIBUTEINTERPOLATORTYPECHOICEPANEL_h
#ifdef _WIN32
#pragma once
#endif
#include "dme_controls/BaseAttributeDoubleChoicePanel.h"
#include "movieobjects/dmeeditortypedictionary.h"
#include "vgui_controls/MessageMap.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
struct AttributeWidgetInfo_t;
namespace vgui
{
class Panel;
class ComboBox;
}
//-----------------------------------------------------------------------------
// CAttributeInterpolatorChoicePanel
//-----------------------------------------------------------------------------
class CAttributeInterpolatorChoicePanel : public CBaseAttributeDoubleChoicePanel
{
DECLARE_CLASS_SIMPLE( CAttributeInterpolatorChoicePanel, CBaseAttributeDoubleChoicePanel );
public:
CAttributeInterpolatorChoicePanel( vgui::Panel *parent, const AttributeWidgetInfo_t &info );
private:
virtual void PopulateComboBoxes( vgui::ComboBox *pComboBox[2] );
virtual void SetAttributeFromComboBoxes( vgui::ComboBox *pComboBox[2], KeyValues *pKeyValues[ 2 ] );
virtual void SetComboBoxesFromAttribute( vgui::ComboBox *pComboBox[2] );
};
#endif // ATTRIBUTEINTERPOLATORTYPECHOICEPANEL_h
@@ -0,0 +1,43 @@
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======//
//
// Purpose:
//
// $NoKeywords: $
//
//=============================================================================//
#ifndef ATTRIBUTEMDLPICKERPANEL_H
#define ATTRIBUTEMDLPICKERPANEL_H
#ifdef _WIN32
#pragma once
#endif
#include "dme_controls/AttributeBasePickerPanel.h"
#include "vgui_controls/phandle.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CMDLPickerFrame;
//-----------------------------------------------------------------------------
// CAttributeMDLPickerPanel
//-----------------------------------------------------------------------------
class CAttributeMDLPickerPanel : public CAttributeBasePickerPanel
{
DECLARE_CLASS_SIMPLE( CAttributeMDLPickerPanel, CAttributeBasePickerPanel );
public:
CAttributeMDLPickerPanel( vgui::Panel *parent, const AttributeWidgetInfo_t &info );
~CAttributeMDLPickerPanel();
private:
MESSAGE_FUNC_PARAMS( OnMDLSelected, "AssetSelected", kv );
virtual void ShowPickerDialog();
};
#endif // ATTRIBUTEMDLPICKERPANEL_H
@@ -0,0 +1,46 @@
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======//
//
// Purpose:
//
// $NoKeywords: $
//
//=============================================================================//
#ifndef ATTRIBUTESEQUENCEPICKERPANEL_H
#define ATTRIBUTESEQUENCEPICKERPANEL_H
#ifdef _WIN32
#pragma once
#endif
#include "dme_controls/AttributeBasePickerPanel.h"
#include "vgui_controls/phandle.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CMDLPickerFrame;
class CSequencePickerFrame;
//-----------------------------------------------------------------------------
// CAttributeSequencePickerPanel
//-----------------------------------------------------------------------------
class CAttributeSequencePickerPanel : public CAttributeBasePickerPanel
{
DECLARE_CLASS_SIMPLE( CAttributeSequencePickerPanel, CAttributeBasePickerPanel );
public:
CAttributeSequencePickerPanel( vgui::Panel *parent, const AttributeWidgetInfo_t &info );
~CAttributeSequencePickerPanel();
private:
MESSAGE_FUNC_PARAMS( OnMDLSelected, "AssetSelected", kv );
MESSAGE_FUNC_PARAMS( OnSequenceSelected, "SequenceSelected", kv );
virtual void ShowPickerDialog();
void ShowSequencePickerDialog( const char *pMDLName );
};
#endif // ATTRIBUTESEQUENCEPICKERPANEL_H
@@ -0,0 +1,41 @@
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======//
//
// Purpose:
//
// $NoKeywords: $
//
//=============================================================================//
#ifndef ATTRIBUTESOUNDPICKERPANEL_H
#define ATTRIBUTESOUNDPICKERPANEL_H
#ifdef _WIN32
#pragma once
#endif
#include "dme_controls/AttributeBasePickerPanel.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// CAttributeSoundPickerPanel
//-----------------------------------------------------------------------------
class CAttributeSoundPickerPanel : public CAttributeBasePickerPanel
{
DECLARE_CLASS_SIMPLE( CAttributeSoundPickerPanel, CAttributeBasePickerPanel );
public:
CAttributeSoundPickerPanel( vgui::Panel *parent, const AttributeWidgetInfo_t &info );
~CAttributeSoundPickerPanel();
private:
MESSAGE_FUNC_PARAMS( OnSoundSelected, "SoundSelected", kv );
virtual void ShowPickerDialog();
};
#endif // ATTRIBUTESOUNDPICKERPANEL_H
@@ -0,0 +1,68 @@
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======//
//
// Purpose:
//
// $NoKeywords: $
//
//=============================================================================//
#ifndef ATTRIBUTESTRINGCHOICEPANEL_h
#define ATTRIBUTESTRINGCHOICEPANEL_h
#ifdef _WIN32
#pragma once
#endif
#include "dme_controls/BaseAttributeChoicePanel.h"
#include "movieobjects/dmeeditortypedictionary.h"
#include "vgui_controls/MessageMap.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
struct AttributeWidgetInfo_t;
namespace vgui
{
class Panel;
class ComboBox;
}
//-----------------------------------------------------------------------------
// Configuration for string choices
//-----------------------------------------------------------------------------
class CDmeEditorStringChoicesInfo : public CDmeEditorChoicesInfo
{
DEFINE_ELEMENT( CDmeEditorStringChoicesInfo, CDmeEditorChoicesInfo );
public:
// Add a choice
CDmElement *AddChoice( const char *pValueString, const char *pChoiceString );
// Gets the choices
const char *GetChoiceValue( int nIndex ) const;
};
//-----------------------------------------------------------------------------
// CAttributeStringChoicePanel
//-----------------------------------------------------------------------------
class CAttributeStringChoicePanel : public CBaseAttributeChoicePanel
{
DECLARE_CLASS_SIMPLE( CAttributeStringChoicePanel, CBaseAttributeChoicePanel );
public:
CAttributeStringChoicePanel( vgui::Panel *parent, const AttributeWidgetInfo_t &info );
private:
// Derived classes can re-implement this to fill the combo box however they like
virtual void PopulateComboBox( vgui::ComboBox *pComboBox );
virtual void SetAttributeFromComboBox( vgui::ComboBox *pComboBox, KeyValues *pKeyValues );
virtual void SetComboBoxFromAttribute( vgui::ComboBox *pComboBox );
};
// ----------------------------------------------------------------------------
#endif // ATTRIBUTESTRINGCHOICEPANEL_h
+89
View File
@@ -0,0 +1,89 @@
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======//
//
// Purpose:
//
// $NoKeywords: $
//
//=============================================================================//
#ifndef ATTRIBUTETEXTENTRY_H
#define ATTRIBUTETEXTENTRY_H
#ifdef _WIN32
#pragma once
#endif
#include "vgui_controls/TextEntry.h"
#include "tier1/utlvector.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CDmElement;
class CAttributeTextPanel;
class KeyValues;
namespace vgui
{
class IScheme;
class Label;
class Menu;
}
//-----------------------------------------------------------------------------
// CAttributeTextEntry
//-----------------------------------------------------------------------------
class CAttributeTextEntry : public vgui::TextEntry
{
DECLARE_CLASS_SIMPLE( CAttributeTextEntry, vgui::TextEntry );
public:
CAttributeTextEntry( Panel *parent, const char *panelName );
virtual bool GetSelectedRange(int& cx0,int& cx1)
{
return BaseClass::GetSelectedRange( cx0, cx1 );
}
protected:
CAttributeTextPanel *GetParentAttributePanel();
virtual void OnMouseWheeled( int delta );
// We'll only create an "undo" record if the values differ upon focus change
virtual void OnSetFocus();
virtual void OnKillFocus();
virtual void OnKeyCodeTyped( vgui::KeyCode code );
virtual void OnPanelDropped( CUtlVector< KeyValues * >& data );
virtual bool GetDropContextMenu( vgui::Menu *menu, CUtlVector< KeyValues * >& msglist );
virtual bool IsDroppable( CUtlVector< KeyValues * >& msglist );
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
MESSAGE_FUNC_PARAMS( OnTextChanged, "TextChanged", data );
private:
enum
{
MAX_TEXT_LENGTH = 1024
};
template<class T> void ApplyMouseWheel( T newValue, T originalValue );
void StoreInitialValue( bool bForce = false );
void WriteValueToAttribute();
void WriteInitialValueToAttribute();
bool m_bValueStored;
char m_szOriginalText[ MAX_TEXT_LENGTH ];
union
{
float m_flOriginalValue;
int m_nOriginalValue;
bool m_bOriginalValue;
};
};
// ----------------------------------------------------------------------------
#endif // ATTRIBUTETEXTENTRY_H
+62
View File
@@ -0,0 +1,62 @@
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======//
//
// Purpose:
//
// $NoKeywords: $
//
//=============================================================================//
#ifndef ATTRIBUTETEXTPANEL_H
#define ATTRIBUTETEXTPANEL_H
#ifdef _WIN32
#pragma once
#endif
#include "dme_controls/BaseAttributePanel.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CDmElement;
class CAttributeTextEntry;
namespace vgui
{
class Label;
}
//-----------------------------------------------------------------------------
// CAttributeTextPanel
//-----------------------------------------------------------------------------
class CAttributeTextPanel : public CBaseAttributePanel
{
DECLARE_CLASS_SIMPLE( CAttributeTextPanel, CBaseAttributePanel );
public:
CAttributeTextPanel( vgui::Panel *parent, const AttributeWidgetInfo_t &info );
virtual void SetFont( HFont font );
virtual void PostConstructor();
virtual void Apply();
virtual void Refresh();
// Returns the text type
const char *GetTextType();
protected:
virtual vgui::Panel *GetDataPanel();
MESSAGE_FUNC(OnTextChanged, "TextChanged")
{
SetDirty( true );
}
protected:
CAttributeTextEntry *m_pData;
bool m_bShowMemoryUsage;
};
#endif // ATTRIBUTETEXTPANEL_H
@@ -0,0 +1,94 @@
//====== Copyright © 1996-2004, Valve Corporation, All rights reserved. =======
//
// Purpose:
//
//=============================================================================
#ifndef ATTRIBUTEWIDGETFACTORY_H
#define ATTRIBUTEWIDGETFACTORY_H
#ifdef _WIN32
#pragma once
#endif
#include "tier0/platform.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CDmElement;
class CMovieDoc;
class IDmNotify;
class CDmeEditorAttributeInfo;
class CDmeEditorTypeDictionary;
class CDmAttribute;
namespace vgui
{
class EditablePanel;
class Panel;
}
//-----------------------------------------------------------------------------
// Info about the attribute being edited, and how the editor should look
//-----------------------------------------------------------------------------
struct AttributeWidgetInfo_t
{
AttributeWidgetInfo_t()
{
m_nArrayIndex = -1;
m_bShowUniqueID = true;
}
CDmElement *m_pElement;
const char *m_pAttributeName;
int m_nArrayIndex;
CDmeEditorTypeDictionary *m_pEditorTypeDictionary;
CDmeEditorAttributeInfo *m_pEditorInfo;
IDmNotify *m_pNotify;
bool m_bAutoApply;
bool m_bShowMemoryUsage;
bool m_bShowUniqueID;
};
//-----------------------------------------------------------------------------
// Interface used to create an attribute widget
//-----------------------------------------------------------------------------
class IAttributeWidgetFactory
{
public:
virtual vgui::Panel *Create( vgui::Panel *pParent, const AttributeWidgetInfo_t &info ) = 0;
};
//-----------------------------------------------------------------------------
// Templatized class used to create widget factories
//-----------------------------------------------------------------------------
class IAttributeWidgetFactoryList
{
public:
// Returns a named widget factory
virtual IAttributeWidgetFactory *GetWidgetFactory( const char *pWidgetName ) = 0;
// Returns a factory used to create widget for the attribute passed in
virtual IAttributeWidgetFactory *GetWidgetFactory( CDmElement *object, CDmAttribute *pAttribute, CDmeEditorTypeDictionary *pTypeDictionary ) = 0;
// Returns a factory used to create widgets for entries in an attribute array
virtual IAttributeWidgetFactory *GetArrayWidgetFactory( CDmElement *object, CDmAttribute *pAttribute, CDmeEditorTypeDictionary *pTypeDictionary ) = 0;
// Applies changes to a widget
virtual void ApplyChanges( vgui::Panel *pWidget, vgui::Panel *pSender = NULL ) = 0;
// Refreshes a widget when attributes change
virtual void Refresh( vgui::Panel *pWidget, vgui::Panel *pSender = NULL ) = 0;
};
extern IAttributeWidgetFactoryList *attributewidgetfactorylist;
#endif // ATTRIBUTEWIDGETFACTORY_H
@@ -0,0 +1,135 @@
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======
//
// Purpose:
//
//=============================================================================
#ifndef BASEANIMSETATTRIBUTESLIDERPANEL_H
#define BASEANIMSETATTRIBUTESLIDERPANEL_H
#ifdef _WIN32
#pragma once
#endif
#include "datamodel/dmehandle.h"
#include "dme_controls/BaseAnimationSetEditorController.h"
#include "vgui_controls/EditablePanel.h"
using namespace vgui;
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CBaseAnimationSetEditor;
class CBaseAnimationSetControl;
class CAttributeSlider;
class CDmElement;
class CDmeChannel;
class CDmeFilmClip;
class CDmeTimeSelection;
enum RecordingMode_t;
class DmeLog_TimeSelection_t;
class CPresetSideFilterSlider;
struct FaderPreview_t;
struct AttributeValue_t;
enum AnimationControlType_t;
enum
{
FADER_DRAG_CHANGED = ( 1<<0 ),
FADER_PREVIEW_KEY_CHANGED = ( 1<<1 ),
FADER_AMOUNT_CHANGED = ( 1<<2 ),
FADER_PRESET_CHANGED = ( 1<<3 ),
};
//-----------------------------------------------------------------------------
// CBaseAnimSetAttributeSliderPanel
//-----------------------------------------------------------------------------
class CBaseAnimSetAttributeSliderPanel : public vgui::EditablePanel, public IAnimationSetControlSelectionChangedListener
{
DECLARE_CLASS_SIMPLE( CBaseAnimSetAttributeSliderPanel, vgui::EditablePanel );
public:
CBaseAnimSetAttributeSliderPanel( vgui::Panel *parent, const char *className, CBaseAnimationSetEditor *editor );
public:
virtual void ChangeAnimationSetClip( CDmeFilmClip *pFilmClip );
virtual void OnControlsAddedOrRemoved();
CBaseAnimationSetEditor* GetEditor();
virtual CBaseAnimationSetControl* GetController() { return m_pController; }
virtual void ApplySchemeSettings( vgui::IScheme *scheme );
// These funcs only meaningful in derived/outer classes (SFM)
virtual void StampValueIntoLogs( CDmElement *control, AnimationControlType_t type, const float &flValue ) {}
virtual void StampValueIntoLogs( CDmElement *control, AnimationControlType_t type, const Vector &vecValue ) {}
virtual void StampValueIntoLogs( CDmElement *control, AnimationControlType_t type, const Quaternion &qValue ) {}
virtual void GetTypeInValueForControl( CDmElement *pControl, bool bOrientation, AttributeValue_t &controlValue, const AttributeValue_t &sliderValue );
virtual void UpdatePreview( char const *pchFormat, ... );
virtual void DispatchCurve( int nCurveType );
CAttributeSlider *FindSliderForControl( const CDmElement *control );
// Returns true if slider is visible
bool GetSliderValues( AttributeValue_t *pValue, int nIndex );
virtual void SetupForPreset( FaderPreview_t &fader );
float GetBalanceSliderValue();
// inherited from IAnimationSetControlSelectionChangedListener
virtual void OnControlSelectionChanged();
protected:
virtual void OnThink();
virtual void OnTick();
virtual void OnCommand( const char *pCommand );
virtual bool ApplySliderValues( bool force );
virtual void UpdateControlSetMode( bool changingvalues, bool previewing, CAttributeSlider *dragSlider ) {}
virtual void PerformLayout();
protected:
int FindSliderIndexForControl( const CDmElement *control );
void UpdateSliderDependencyFlags() const;
void RebuildSliderLists();
// these are just temporary accessors for the CBaseAnimationSetControl until more code is moved over
friend CBaseAnimationSetControl;
int GetSliderCount() const { return m_SliderList.Count(); }
CAttributeSlider *GetSlider( int i ) { return m_SliderList[ i ]; }
CAttributeSlider *AllocateSlider();
void FreeSlider( CAttributeSlider *slider );
void InitFreeSliderList( int nCount );
vgui::DHANDLE< CBaseAnimationSetEditor > m_hEditor;
// Visible slider list
vgui::DHANDLE< vgui::PanelListPanel > m_Sliders;
// All sliders
CUtlVector< CAttributeSlider * > m_SliderList;
vgui::Button *m_pLeftRightBoth[ 2 ];
CPresetSideFilterSlider *m_pPresetSideFilter;
CBaseAnimationSetControl *m_pController;
CUtlVector< CAttributeSlider * > m_FreeSliderList;
};
inline CBaseAnimationSetEditor* CBaseAnimSetAttributeSliderPanel::GetEditor()
{
return m_hEditor;
}
#endif // BASEANIMSETATTRIBUTESLIDERPANEL_H
@@ -0,0 +1,125 @@
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======
//
// Purpose:
//
//=============================================================================
#ifndef BASEANIMSETCONTROLGROUPPANEL_H
#define BASEANIMSETCONTROLGROUPPANEL_H
#ifdef _WIN32
#pragma once
#endif
#include "dme_controls/BaseAnimationSetEditorController.h"
#include "vgui_controls/EditablePanel.h"
#include "datamodel/dmehandle.h"
#include "tier1/utlntree.h"
#include "tier1/utldict.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CBaseAnimationSetEditor;
class CBaseAnimationSetControl;
class CDmeAnimationSet;
class CDmeChannel;
class CDmeControlGroup;
class CDmeDag;
class CDmElement;
class CAnimGroupTree;
namespace vgui
{
class TreeView;
class IScheme;
class Menu;
};
//-----------------------------------------------------------------------------
// Animation set editor control/group tree item types. These types represent
// the different types of items which can be added to the m_hGroupsTree. They
// are used in determining the action to be taken when an item is selected and
// to determine the content of the right click context menu for an item.
//-----------------------------------------------------------------------------
enum AnimTreeItemType_t
{
ANIMTREE_ITEM_ANIMSET,
ANIMTREE_ITEM_GROUP,
ANIMTREE_ITEM_CONTROL,
ANIMTREE_ITEM_COMPONENT,
};
//-----------------------------------------------------------------------------
// Panel which shows a tree of controls
//-----------------------------------------------------------------------------
class CBaseAnimSetControlGroupPanel : public vgui::EditablePanel, public IAnimationSetControlSelectionChangedListener
{
DECLARE_CLASS_SIMPLE( CBaseAnimSetControlGroupPanel, EditablePanel );
public:
CBaseAnimSetControlGroupPanel( vgui::Panel *parent, char const *className, CBaseAnimationSetEditor *editor, bool bControlStateInterface );
virtual ~CBaseAnimSetControlGroupPanel();
CBaseAnimationSetEditor *GetEditor() { return m_hEditor; }
void ChangeAnimationSetClip( CDmeFilmClip *pFilmClip );
void OnControlsAddedOrRemoved();
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
CDmeDag *GetWorkCameraParent();
// Rebuild the tree view from the current control selection hierarchy
void RebuildTree( bool bRestoreExpansion );
void UpdateSelection();
// inherited from IAnimationSetControlSelectionChangedListener
virtual void OnControlSelectionChanged();
virtual void ExpandTreeToControl( const CDmElement *pSelection, TransformComponent_t nComponentFlags );
// Create a new control group containing the selected controls
void CreateGroupFromSelectedControls();
protected:
MESSAGE_FUNC_INT_INT( OnTreeViewItemSelected, "TreeViewItemSelected", itemIndex, replaceSelection );
MESSAGE_FUNC_INT( OnTreeViewItemDeselected, "TreeViewItemDeselected", itemIndex );
MESSAGE_FUNC( OnTreeViewStartRangeSelection, "TreeViewStartRangeSelection" );
MESSAGE_FUNC( OnTreeViewFinishRangeSelection, "TreeViewFinishRangeSelection" );
MESSAGE_FUNC( OnTreeViewItemSelectionCleared, "TreeViewItemSelectionCleared" );
MESSAGE_FUNC_INT( OnTreeViewOpenContextMenu, "TreeViewOpenContextMenu", itemID );
protected:
void SelectAnimTreeItem( int itemIndex, ESelectionMode selectionMode );
struct ElementExpansion_t
{
CDmElement *m_pElement;
TransformComponent_t m_ComponentFlags;
};
// pre-order traversal so that we can ExpandItems linearly
void CollectExpandedItems( CUtlVector< ElementExpansion_t > &expandedNodes, int nParentIndex );
// assumes expandedNodes have parents before children (ie expandedNodes is a pre-order traversal)
void ExpandItems( const CUtlVector< ElementExpansion_t > &expandedNodes );
SelectionState_t UpdateSelection_R( int nParentIndex );
vgui::DHANDLE< CBaseAnimationSetEditor > m_hEditor;
vgui::DHANDLE< CAnimGroupTree > m_hGroups;
CBaseAnimationSetControl *m_pController;
Color m_FullSelectionColor;
Color m_PartialSelectionColor;
Color m_ContextMenuHighlightColor;
friend class CAnimGroupTree;
};
#endif // BASEANIMSETCONTROLGROUPPANEL_H
@@ -0,0 +1,207 @@
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======
//
// Purpose:
//
//=============================================================================
#ifndef BASEANIMSETPRESETFADERPANEL_H
#define BASEANIMSETPRESETFADERPANEL_H
#ifdef _WIN32
#pragma once
#endif
#include "movieobjects/animsetattributevalue.h"
#include "dme_controls/dmecontrols_utils.h"
#include "datamodel/dmehandle.h"
#include "movieobjects/proceduralpresets.h"
#include "vgui_controls/PropertyPage.h"
#include "vgui_controls/PropertySheet.h"
#include "vgui_controls/Slider.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CBaseAnimationSetControl;
class CPresetSlider;
class CBaseAnimationSetEditor;
class CSliderListPanel;
class CAddPresetDialog;
class CDmePreset;
class CDmePresetGroup;
class CDmePresetGroupEditorFrame;
namespace vgui
{
class InputDialog;
}
struct FaderPreview_t
{
FaderPreview_t() :
name( 0 ),
amount( 0 ),
isbeingdragged( false ),
holdingPreviewKey( false ),
values( 0 ),
nProceduralType( PROCEDURAL_PRESET_NOT )
{
}
const char *name;
float amount;
bool isbeingdragged;
bool holdingPreviewKey;
AttributeDict_t *values;
int nProceduralType;
};
CDmePresetGroup *FindAnyPresetGroup( CDmeFilmClip *pFilmClip, const char *pPresetGroupName );
CDmePreset *FindAnyPreset ( CDmeFilmClip *pFilmClip, const char *pPresetGroupName, const char *pPresetName );
//-----------------------------------------------------------------------------
// Base class for the preset fader panel
//-----------------------------------------------------------------------------
class CBaseAnimSetPresetFaderPanel : public vgui::EditablePanel
{
DECLARE_CLASS_SIMPLE( CBaseAnimSetPresetFaderPanel, vgui::EditablePanel );
public:
CBaseAnimSetPresetFaderPanel( vgui::Panel *parent, const char *className, CBaseAnimationSetEditor *editor );
void GetPreviewFader( FaderPreview_t& fader );
void UpdateProceduralPresetSlider( AttributeDict_t *values );
void UpdateControlValues( bool bVisibleOnly = true );
CBaseAnimationSetControl *GetController() { return m_pController; }
void OnDeletePreset( const char *pPresetName );
virtual void ApplySchemeSettings( vgui::IScheme *scheme );
virtual void DispatchCurve( int nCurveType );
CPresetSlider *FindPresetSlider( const char *pName );
void SetActivePresetSlider( CPresetSlider *pSlider );
CPresetSlider *GetActivePresetSlider();
protected:
MESSAGE_FUNC( OnShowAddPresetDialog, "ShowAddPresetDialog" );
MESSAGE_FUNC( OnPresetsChanged, "PresetsChanged" );
MESSAGE_FUNC( OnManagePresets, "ManagePresets" );
MESSAGE_FUNC_PARAMS( OnPresetNameSelected, "PresetNameSelected", params );
MESSAGE_FUNC( OnPageChanged, "PageChanged" );
protected:
CPresetSlider *GetSliderForRow( int nSlot );
void UpdateOrCreatePresetSlider( int nSlot, const char *pPresetGroupName, const char *pPresetName );
void RebuildPresetSliders( const char *pPresetGroupName, const CUtlVector< CUtlSymbolLarge > &presetNames );
void AddPreset( const char *pPresetGroupName, const char *pPresetName, bool bAnimated );
void PopulatePresetList( bool bChanged );
CBaseAnimationSetControl *m_pController;
vgui::PropertySheet *m_pSheet;
CUtlVector< vgui::PropertyPage* > m_presetGroupPages;
CSliderListPanel *m_pSliders;
CUtlVector< CPresetSlider* > m_presetSliders;
vgui::DHANDLE< CDmePresetGroupEditorFrame > m_hPresetEditor;
vgui::DHANDLE< CPresetSlider > m_hActivePresetSlider;
friend CBaseAnimationSetControl;
friend CPresetSlider;
};
//-----------------------------------------------------------------------------
//
// CPresetSlider: The actual preset slider itself!
//
//-----------------------------------------------------------------------------
class CPresetSlider : public vgui::Slider
{
DECLARE_CLASS_SIMPLE( CPresetSlider, vgui::Slider );
public:
CPresetSlider( vgui::Panel *parent, CBaseAnimSetPresetFaderPanel *pFaderPanel );
~CPresetSlider();
void Init( const char *pPresetGroupName, const char *pPresetName );
void Clear();
void SetControlValues( );
float GetCurrent();
void SetPos( float frac );
AttributeDict_t *GetAttributeDict();
bool IsDragging();
void IgnoreCursorMovedEvents( bool bIgnore );
void Deactivate();
const char *GetPresetName();
const char *GetPresetGroupName();
int GetProceduralPresetType() { return m_nProceduralType; }
protected:
virtual void Paint();
virtual void PaintBackground();
virtual void ApplySchemeSettings( vgui::IScheme *scheme );
virtual void GetTrackRect( int &x, int &y, int &w, int &h );
virtual void OnMousePressed(vgui::MouseCode code);
virtual void OnMouseReleased(vgui::MouseCode code);
virtual void OnCursorMoved( int x, int y );
virtual void OnCursorEntered();
virtual void OnCursorExited();
MESSAGE_FUNC( OnShowContextMenu, "OnShowContextMenu" );
MESSAGE_FUNC( OnRename, "OnRename" );
MESSAGE_FUNC( OnDelete, "OnDelete" );
MESSAGE_FUNC_PARAMS( OnInputCompleted, "InputCompleted", params );
MESSAGE_FUNC( OnDeleteConfirmed, "OnDeleteConfirmed" );
protected:
KEYBINDING_FUNC( ts_curve_1, KEY_1, 0, OnCurve1, "#ts_curve1_help", 0 );
KEYBINDING_FUNC( ts_curve_2, KEY_2, 0, OnCurve2, "#ts_curve2_help", 0 );
KEYBINDING_FUNC( ts_curve_3, KEY_3, 0, OnCurve3, "#ts_curve3_help", 0 );
KEYBINDING_FUNC( ts_curve_4, KEY_4, 0, OnCurve4, "#ts_curve4_help", 0 );
private:
void OnRenameCompleted( const char *pText, KeyValues *pContextKeyValues );
void UpdateTickPos( int x, int y );
CBaseAnimSetPresetFaderPanel *m_pPresetFaderPanel;
Color m_GradientColor;
Color m_ZeroColor;
Color m_TextColor;
Color m_TextColorFocus;
vgui::TextImage *m_pName;
vgui::DHANDLE< vgui::Menu > m_hContextMenu;
AttributeDict_t m_AttributeLookup;
CUtlSymbolLarge m_presetGroupName;
CUtlSymbolLarge m_presetName;
int m_nProceduralType;
bool m_bReadOnly;
bool m_bIgnoreCursorMovedEvents;
static bool s_bResetMousePosOnMouseUp;
static int s_nMousePosX;
static int s_nMousePosY;
};
#endif // BASEANIMSETPRESETFADERPANEL_H
@@ -0,0 +1,82 @@
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======
//
// Purpose:
//
//=============================================================================
#ifndef BASEANIMATIONSETEDITOR_H
#define BASEANIMATIONSETEDITOR_H
#ifdef _WIN32
#pragma once
#endif
#include "vgui_controls/EditablePanel.h"
#include "vgui_controls/ImageList.h"
#include "dme_controls/RecordingState.h"
#include "dme_controls/BaseAnimationSetEditorController.h"
#include "tier1/utlvector.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
struct LogPreview_t;
class CDmeAnimationSet;
class CDmeAnimationList;
class CDmeChannelsClip;
class CBaseAnimSetControlGroupPanel;
class CBaseAnimSetPresetFaderPanel;
class CBaseAnimSetAttributeSliderPanel;
//-----------------------------------------------------------------------------
// Base class for the panel for editing animation sets
//-----------------------------------------------------------------------------
class CBaseAnimationSetEditor : public vgui::EditablePanel
{
DECLARE_CLASS_SIMPLE( CBaseAnimationSetEditor, vgui::EditablePanel );
public:
enum EAnimSetLayout_t
{
LAYOUT_SPLIT = 0,
LAYOUT_VERTICAL,
LAYOUT_HORIZONTAL,
};
CBaseAnimationSetEditor( vgui::Panel *parent, char const *panelName, CBaseAnimationSetControl *pAnimationSetController );
virtual ~CBaseAnimationSetEditor();
virtual void CreateToolsSubPanels();
virtual void ChangeLayout( EAnimSetLayout_t newLayout );
virtual void OpenTreeViewContextMenu( KeyValues *pItemData );
CBaseAnimationSetControl *GetController();
CBaseAnimSetControlGroupPanel *GetControlGroup();
CBaseAnimSetPresetFaderPanel *GetPresetFader();
CBaseAnimSetAttributeSliderPanel *GetAttributeSlider();
void ChangeAnimationSetClip( CDmeFilmClip *pFilmClip );
void OnControlsAddedOrRemoved();
protected:
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
MESSAGE_FUNC_PARAMS( OnOpenContextMenu, "OpenContextMenu", params );
MESSAGE_FUNC_INT( OnChangeLayout, "OnChangeLayout", value );
protected:
EAnimSetLayout_t m_Layout;
vgui::DHANDLE< vgui::Splitter > m_Splitter;
vgui::DHANDLE< CBaseAnimSetControlGroupPanel > m_hControlGroup;
vgui::DHANDLE< CBaseAnimSetPresetFaderPanel > m_hPresetFader;
vgui::DHANDLE< CBaseAnimSetAttributeSliderPanel > m_hAttributeSlider;
vgui::DHANDLE< vgui::Menu > m_hContextMenu;
CBaseAnimationSetControl *m_pController;
};
#endif // BASEANIMATIONSETEDITOR_H
@@ -0,0 +1,391 @@
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======
//
// Purpose:
//
//=============================================================================
#ifndef BASEANIMATIONSETEDITORCONTROLLER_H
#define BASEANIMATIONSETEDITORCONTROLLER_H
#ifdef _WIN32
#pragma once
#endif
#include "datamodel/dmehandle.h"
#include "movieobjects/animsetattributevalue.h"
#include "dme_controls/dmecontrols_utils.h"
#include "dme_controls/RecordingState.h"
#include "tier1/utlvector.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
struct SelectionInfo_t;
class CDmeAnimationSet;
class CDmeAnimationList;
class CDmeChannelsClip;
class CDmeChannel;
class CBaseAnimationSetEditor;
class CAttributeSlider;
class CNotifyAnimationSetControlSelectionChangedScopeGuard;
struct AttributeValue_t;
enum ESelectionMode
{
SELECTION_SET,
SELECTION_ADD,
SELECTION_REMOVE,
SELECTION_TOGGLE,
};
// NOTE - these values were chosen specifically to allow bitwise or (|) to combine selection states together properly
enum SelectionState_t
{
SEL_EMPTY = 0,
SEL_NONE = 1,
SEL_ALL = 2,
SEL_SOME = 3,
};
inline SelectionState_t operator+( SelectionState_t a, SelectionState_t b )
{
return SelectionState_t( int( a ) | int( b ) );
}
inline SelectionState_t operator+=( SelectionState_t &a, SelectionState_t b )
{
return a = a + b;
}
enum TransformComponent_t
{
TRANSFORM_COMPONENT_NONE = 0,
TRANSFORM_COMPONENT_POSITION_X = ( 1 << 0 ),
TRANSFORM_COMPONENT_POSITION_Y = ( 1 << 1 ),
TRANSFORM_COMPONENT_POSITION_Z = ( 1 << 2 ),
TRANSFORM_COMPONENT_ROTATION_X = ( 1 << 3 ),
TRANSFORM_COMPONENT_ROTATION_Y = ( 1 << 4 ),
TRANSFORM_COMPONENT_ROTATION_Z = ( 1 << 5 ),
TRANSFORM_COMPONENT_POSITION = TRANSFORM_COMPONENT_POSITION_X | TRANSFORM_COMPONENT_POSITION_Y | TRANSFORM_COMPONENT_POSITION_Z,
TRANSFORM_COMPONENT_ROTATION = TRANSFORM_COMPONENT_ROTATION_X | TRANSFORM_COMPONENT_ROTATION_Y | TRANSFORM_COMPONENT_ROTATION_Z,
TRANSFORM_COMPONENT_ALL = TRANSFORM_COMPONENT_POSITION | TRANSFORM_COMPONENT_ROTATION
};
DEFINE_ENUM_BITWISE_OPERATORS( TransformComponent_t )
class IOverrideParentChangedListener
{
public:
virtual void OnOverrideParentChanged( CDmeDag *pChildDag ) = 0;
};
class IAnimationSetControlSelectionChangedListener
{
public:
virtual void OnControlSelectionChanged() {}
virtual void OnRebuildControlHierarchy() {}
virtual void ExpandTreeToControl( const CDmElement *pSelection, TransformComponent_t nComponentFlags ) {}
};
struct SelectionInfo_t
{
DECLARE_FIXEDSIZE_ALLOCATOR( SelectionInfo_t );
public:
SelectionInfo_t() : m_nComponentFlags( TRANSFORM_COMPONENT_NONE ) {}
SelectionInfo_t( CDmeAnimationSet *pAnimSet, CDmElement *pControl, TransformComponent_t nComponentFlags = TRANSFORM_COMPONENT_NONE )
: m_hAnimSet( pAnimSet ), m_hControl( pControl ), m_nComponentFlags( nComponentFlags )
{
}
bool IsPositionFullySelected() const
{
return ( ( m_nComponentFlags & TRANSFORM_COMPONENT_POSITION ) == TRANSFORM_COMPONENT_POSITION );
}
bool IsRotationFullySelected() const
{
return ( ( m_nComponentFlags & TRANSFORM_COMPONENT_ROTATION ) == TRANSFORM_COMPONENT_ROTATION );
}
bool AreAnyPositionComponentsSelected()
{
return ( ( m_nComponentFlags & TRANSFORM_COMPONENT_POSITION ) > 0 );
}
bool AreAnyOrientationComponentsSelected()
{
return ( ( m_nComponentFlags & TRANSFORM_COMPONENT_ROTATION ) > 0 );
}
static LogComponents_t ConvertTransformFlagsToLogFlags( TransformComponent_t nTransformFlags, bool bOrientation )
{
LogComponents_t nFlags = LOG_COMPONENTS_NONE;
if ( bOrientation )
{
nFlags |= ( ( nTransformFlags & TRANSFORM_COMPONENT_ROTATION_X ) > 0 ) ? LOG_COMPONENTS_X : LOG_COMPONENTS_NONE;
nFlags |= ( ( nTransformFlags & TRANSFORM_COMPONENT_ROTATION_Y ) > 0 ) ? LOG_COMPONENTS_Y : LOG_COMPONENTS_NONE;
nFlags |= ( ( nTransformFlags & TRANSFORM_COMPONENT_ROTATION_Z ) > 0 ) ? LOG_COMPONENTS_Z : LOG_COMPONENTS_NONE;
}
else
{
nFlags |= ( ( nTransformFlags & TRANSFORM_COMPONENT_POSITION_X ) > 0 ) ? LOG_COMPONENTS_X : LOG_COMPONENTS_NONE;
nFlags |= ( ( nTransformFlags & TRANSFORM_COMPONENT_POSITION_Y ) > 0 ) ? LOG_COMPONENTS_Y : LOG_COMPONENTS_NONE;
nFlags |= ( ( nTransformFlags & TRANSFORM_COMPONENT_POSITION_Z ) > 0 ) ? LOG_COMPONENTS_Z : LOG_COMPONENTS_NONE;
}
return nFlags;
}
static TransformComponent_t ConvertLogFlagsToTransformFlags( LogComponents_t nLogFlags, bool bOrientation )
{
TransformComponent_t nFlags = TRANSFORM_COMPONENT_NONE;
if ( bOrientation )
{
nFlags |= ( ( nLogFlags & LOG_COMPONENTS_X ) > 0 ) ? TRANSFORM_COMPONENT_ROTATION_X : TRANSFORM_COMPONENT_NONE;
nFlags |= ( ( nLogFlags & LOG_COMPONENTS_Y ) > 0 ) ? TRANSFORM_COMPONENT_ROTATION_Y : TRANSFORM_COMPONENT_NONE;
nFlags |= ( ( nLogFlags & LOG_COMPONENTS_Z ) > 0 ) ? TRANSFORM_COMPONENT_ROTATION_Z : TRANSFORM_COMPONENT_NONE;
}
else
{
nFlags |= ( ( nLogFlags & LOG_COMPONENTS_X ) > 0 ) ? TRANSFORM_COMPONENT_POSITION_X : TRANSFORM_COMPONENT_NONE;
nFlags |= ( ( nLogFlags & LOG_COMPONENTS_Y ) > 0 ) ? TRANSFORM_COMPONENT_POSITION_Y : TRANSFORM_COMPONENT_NONE;
nFlags |= ( ( nLogFlags & LOG_COMPONENTS_Z ) > 0 ) ? TRANSFORM_COMPONENT_POSITION_Z : TRANSFORM_COMPONENT_NONE;
}
return nFlags;
}
CDmeHandle< CDmeAnimationSet > m_hAnimSet;
CDmeHandle< CDmElement > m_hControl;
TransformComponent_t m_nComponentFlags;
};
template < class T >
void RebuildControlList( CUtlVector< T* > &controlList, CDmeFilmClip *pFilmClip )
{
int nControls = controlList.Count();
for ( int i = 0; i < nControls; ++i )
{
delete controlList[ i ];
}
controlList.RemoveAll();
CAnimSetGroupAnimSetTraversal traversal( pFilmClip );
while ( CDmeAnimationSet *pAnimSet = traversal.Next() )
{
CDmaElementArray< CDmElement > &controls = pAnimSet->GetControls();
int nControls = controls.Count();
for ( int i = 0; i < nControls; ++i )
{
CDmElement *pControl = controls[ i ];
if ( !pControl )
continue;
controlList.AddToTail( new T( pAnimSet, pControl, TRANSFORM_COMPONENT_NONE ) );
}
}
}
template < class T >
T *FindSelectionInfoForControl( CUtlVector< T* > &controlList, const CDmElement *pControl )
{
if ( !pControl )
return NULL;
int nControls = controlList.Count();
for ( int i = 0; i < nControls; ++i )
{
T *pT = controlList[ i ];
if ( pT->m_hControl.Get() == pControl )
return pT;
}
return NULL;
}
template < class T >
void RemoveNullControls( CUtlVector< T* > &controlList )
{
int nControls = controlList.Count();
for ( int i = nControls-1; i >= 0; --i )
{
if ( controlList[ i ]->m_hControl )
continue; // TODO - are there other conditions that could cause a control to exist, but not want to be part of the full list?
delete controlList[ i ];
controlList.Remove( i );
}
}
template < class T >
void AddMissingControls( CUtlVector< T* > &controlList, CDmeFilmClip *pFilmClip )
{
CAnimSetGroupAnimSetTraversal traversal( pFilmClip );
while ( CDmeAnimationSet *pAnimSet = traversal.Next() )
{
CDmaElementArray< CDmElement > &controls = pAnimSet->GetControls();
int nControls = controls.Count();
for ( int i = 0; i < nControls; ++i )
{
CDmElement *pControl = controls[ i ];
if ( !pControl )
continue;
if ( FindSelectionInfoForControl( controlList, pControl ) )
continue;
controlList.AddToTail( new T( pAnimSet, pControl, TRANSFORM_COMPONENT_NONE ) );
}
}
}
//-----------------------------------------------------------------------------
// Base class for the panel for editing animation sets
//-----------------------------------------------------------------------------
class CBaseAnimationSetControl
{
public:
CBaseAnimationSetControl();
~CBaseAnimationSetControl();
void SetAnimationSetEditorPanel( CBaseAnimationSetEditor *pEditor ) { m_pEditor = pEditor; }
virtual void ChangeAnimationSetClip( CDmeFilmClip *pFilmClip );
virtual void OnControlsAddedOrRemoved();
virtual RecordingState_t GetRecordingState() const { return AS_PREVIEW; }
CDmeFilmClip *GetAnimationSetClip();
virtual void OnSliderRangeRemapped() {}
void AddOverrideParentChangedListener( IOverrideParentChangedListener *pListener );
void RemoveOverrideParentChangedListener( IOverrideParentChangedListener *pListener );
void AddControlSelectionChangedListener ( IAnimationSetControlSelectionChangedListener *listener );
void RemoveControlSelectionChangedListener( IAnimationSetControlSelectionChangedListener *listener );
void ClearSelection();
SelectionState_t GetSelectionState( CDmeAnimationSet *pAnimSet ) const;
SelectionState_t GetSelectionState( CDmeControlGroup *pControlGroup ) const;
SelectionState_t GetSelectionState( CDmElement *pControl, TransformComponent_t componentFlags = TRANSFORM_COMPONENT_ALL ) const;
void SetRangeSelectionState( bool bInRangeSelection );
void SelectAnimationSet( CDmeAnimationSet *pAnimSet, ESelectionMode selectionMode = SELECTION_ADD );
void SelectControlGroup( CDmeControlGroup *pControlGroup, ESelectionMode selectionMode = SELECTION_ADD );
void SelectControlForDag( const CDmeDag *pDag, ESelectionMode selectionMode = SELECTION_ADD );
bool SelectControl( const CDmElement *pControl, ESelectionMode selectionMode = SELECTION_ADD, TransformComponent_t componentFlags = TRANSFORM_COMPONENT_ALL, bool bExpandTree = false );
void SaveSelection( CUtlVector< SelectionInfo_t > &selection ) const;
void RestoreSelection( const CUtlVector< SelectionInfo_t > &selection );
void DeselectHiddenControls();
CDmElement *GetMostRecentlySelectedControl();
bool IsControlSelected( CDmElement *pControl ) const;
TransformComponent_t GetSelectionComponentFlags( CDmElement *pControl ) const;
virtual void ProceduralPreset_UpdateCrossfade( AttributeDict_t *values, int nPresetType );
void SetWorkCameraParent( CDmeDag *pWorkCameraParent );
CDmeDag *GetWorkCameraParent();
void SetPresetFromControls( const char *pPresetGroupName, const char *pPresetName );
void AddPreset( const char *pPresetGroupName, const char *pPresetName, bool bAnimated );
void UpdatePreviewSliderValues();
void UpdatePreviewSliderTimes();
bool IsPresetFaderBeingDragged() const;
void UpdateDominantSliderStartValues( bool restoreSliderValues );
void GetDominantSliderValues( float &flDomStart, float &flDomValue );
void ApplyPreset( float flScale, AttributeDict_t& values );
bool ApplySliderValues( bool force );
void SetActiveAttributeSlider( CAttributeSlider *pSlider );
CAttributeSlider *GetActiveAttributeSlider() { return m_ActiveAttributeSlider; }
// HACK - these should be removed after creating the CAnimationSetControl,
// and CAnimSetAttributeSliderPanel::ApplySliderValues is moved to there
float GetPreviousPresetAmount() const { return m_flPreviousPresetAmount; }
bool WasPreviouslyHoldingPresetPreviewKey() const { return m_bPreviouslyHoldingPresetPreviewKey; }
bool HasPresetSliderChanged() const { return m_bPresetSliderChanged; }
float GetDominantSliderStartValue( int nSliderIndex, AnimationControlType_t type );
int GetDominantSliderIndex() const { return m_nDominantSlider; }
// Can the control be snapped to
bool IsControlSnapTarget( const CDmElement *pControl ) const;
// Is the control selectable in the viewport
bool IsControlSelectable( const CDmElement *pControl ) const;
// Determine if the specified control is visible
bool IsControlVisible( const CDmElement *pControl ) const;
// Determine if the specified control group is visible
bool IsControlGroupVisible( const CDmeControlGroup *pGroup ) const;
// Return the state indicating if hidden controls are being displayed
bool IsShowingHiddenControls() const { return m_bShowHiddenControls; }
// Set the state indicating if hidden controls are to be displayed
void SetShowHiddenControls( bool showHidden ) { m_bShowHiddenControls = showHidden; }
protected:
void AddPreset( CDmeAnimationSet *pAnimSet, const char *pPresetGroupName, const char *pPresetName, bool bAnimated );
virtual void GetAnimatedPresetTimeParameters( DmeTime_t &tHead, DmeTime_t &tStart, DmeTime_t &tEnd );
// from CBaseAnimSetControlGroupPanel:
void FireOverrideParentChangedListeners( CDmeDag *pChildDag );
virtual void FireControlSelectionChangedListeners();
virtual void FireRebuildControlHierarchyListeners();
template< class T >
void ApplyTransformSliderValue( CAttributeSlider *pSlider, CDmeTransformControl *pControl, bool bUsePreviewValue, bool bForce, bool &valuesChanged, AnimationControlType_t type );
void ApplySliderValueWithDominance( CAttributeSlider *pSlider, int si, float flDomStart, float flDomValue, CDmElement *pControl, bool bUsePreviewValue, bool bForce, bool &valuesChanged, AnimationControlType_t type, const char *pChannelAttrName, const char *pValueAttrName );
virtual SelectionInfo_t *FindSelectionInfoForControl( const CDmElement *pControl ) = 0;
void EnsureCrossfadePresetControlValues( int nCount );
protected:
// from CBaseAnimationSetEditor:
CDmeHandle< CDmeFilmClip > m_hFilmClip;
CBaseAnimationSetEditor *m_pEditor;
// from CBaseAnimSetControlGroupPanel:
CUtlLinkedList< SelectionInfo_t* > m_SelectionHistory;
CDmeHandle< CDmeDag > m_hWorkCameraParent;
CUtlVector< IOverrideParentChangedListener * > m_OverrideParentChangedListeners;
CUtlVector< IAnimationSetControlSelectionChangedListener * > m_ControlSelectionChangedListeners;
// from CBaseAnimSetAttributeSliderPanel:
CUtlString m_PreviousPresetSlider;
float m_flPreviousPresetAmount;
bool m_bPresetPreviouslyDragged : 1;
bool m_bPreviouslyHoldingPresetPreviewKey : 1;
bool m_bPresetSliderChanged : 1;
vgui::DHANDLE< CAttributeSlider > m_ActiveAttributeSlider;
CUtlVector< AttributeValue_t > m_DominantSliderStartValues; // Values of all sliders at start of drag of dominant slider
int m_nDominantSlider;
// Flag indicating if hidden controls are to be displayed
bool m_bShowHiddenControls;
CUtlVector< CDmElement* > m_crossfadePresetControlValues;
friend CBaseAnimationSetEditor;
friend CNotifyAnimationSetControlSelectionChangedScopeGuard;
};
#endif // BASEANIMATIONSETEDITORCONTROLLER_H
@@ -0,0 +1,65 @@
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======//
//
// Purpose:
//
// $NoKeywords: $
//
//=============================================================================//
#ifndef BASEATTRIBUTECHOICEPANEL_h
#define BASEATTRIBUTECHOICEPANEL_h
#ifdef _WIN32
#pragma once
#endif
#include "dme_controls/BaseAttributePanel.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CDmElement;
struct AttributeWidgetInfo_t;
namespace vgui
{
class IScheme;
class Panel;
class Label;
class ComboBox;
}
//-----------------------------------------------------------------------------
// CBaseAttributeChoicePanel
//-----------------------------------------------------------------------------
class CBaseAttributeChoicePanel : public CBaseAttributePanel
{
DECLARE_CLASS_SIMPLE( CBaseAttributeChoicePanel, CBaseAttributePanel );
public:
CBaseAttributeChoicePanel( vgui::Panel *parent, const AttributeWidgetInfo_t &info );
virtual void PostConstructor();
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
protected:
virtual void Refresh();
private:
// Derived classes can re-implement this to fill the combo box however they like
virtual void PopulateComboBox( vgui::ComboBox *pComboBox ) = 0;
virtual void SetAttributeFromComboBox( vgui::ComboBox *pComboBox, KeyValues *pKeyValues ) = 0;
virtual void SetComboBoxFromAttribute( vgui::ComboBox *pComboBox ) = 0;
MESSAGE_FUNC_PTR( OnTextChanged, "TextChanged", panel );
virtual void Apply();
virtual vgui::Panel *GetDataPanel();
vgui::ComboBox *m_pData;
};
#endif // BASEATTRIBUTECHOICEPANEL_h
@@ -0,0 +1,83 @@
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======//
//
// Purpose:
//
// $NoKeywords: $
//
//=============================================================================//
#ifndef BASEATTRIBUTEDOUBLECHOICEPANEL_H
#define BASEATTRIBUTEDOUBLECHOICEPANEL_H
#ifdef _WIN32
#pragma once
#endif
#include "dme_controls/BaseAttributePanel.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CDmElement;
struct AttributeWidgetInfo_t;
namespace vgui
{
class IScheme;
class Panel;
class Label;
class ComboBox;
}
//-----------------------------------------------------------------------------
// Purpose: Helper to horizontally lay out the two child combo boxes used by
// CBaseAttributeDoubleChoicePanel below
//-----------------------------------------------------------------------------
class CDoubleComboBoxContainerPanel : public vgui::Panel
{
DECLARE_CLASS_SIMPLE( CDoubleComboBoxContainerPanel, vgui::Panel );
public:
CDoubleComboBoxContainerPanel( vgui::Panel *parent, char const *name );
void AddComboBox( int slot, vgui::ComboBox *box );
private:
virtual void PerformLayout();
vgui::ComboBox *m_pBoxes[ 2 ];
};
//-----------------------------------------------------------------------------
// CBaseAttributeDoubleChoicePanel (similar to CBaseAttributeChoicePanel, but with side by side combo boxes)
//-----------------------------------------------------------------------------
class CBaseAttributeDoubleChoicePanel : public CBaseAttributePanel
{
DECLARE_CLASS_SIMPLE( CBaseAttributeDoubleChoicePanel, CBaseAttributePanel );
public:
CBaseAttributeDoubleChoicePanel( vgui::Panel *parent, const AttributeWidgetInfo_t &info );
virtual void PostConstructor();
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
protected:
virtual void Refresh();
private:
// Derived classes can re-implement this to fill the combo box however they like
virtual void PopulateComboBoxes( vgui::ComboBox *pComboBox[2] ) = 0;
virtual void SetAttributeFromComboBoxes( vgui::ComboBox *pComboBox[2], KeyValues *pKeyValues[ 2 ] ) = 0;
virtual void SetComboBoxesFromAttribute( vgui::ComboBox *pComboBox[2] ) = 0;
MESSAGE_FUNC_PTR( OnTextChanged, "TextChanged", panel );
virtual void Apply();
virtual vgui::Panel *GetDataPanel();
CDoubleComboBoxContainerPanel *m_pContainerPanel;
vgui::ComboBox *m_pData[2];
};
#endif // BASEATTRIBUTEDOUBLECHOICEPANEL_H
+308
View File
@@ -0,0 +1,308 @@
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======//
//
// Purpose: base class for all element attribute panels
// An attribute panel is a one line widget that can be used by a list
// or tree control.
//
// $NoKeywords: $
//
//=============================================================================//
#ifndef BASEATTRIBUTEPANEL_H
#define BASEATTRIBUTEPANEL_H
#ifdef _WIN32
#pragma once
#endif
#include "datamodel/dmattribute.h"
#include "datamodel/dmattributevar.h"
#include "vgui_controls/Panel.h"
#include "datamodel/dmehandle.h"
#include "tier1/fmtstr.h"
#define FirstColumnWidth 30
#define TypeColumnWidth 75
#define ColumnBorderWidth 2
#define PickerWidth 25
#define PickerHeight 13
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CDmElement;
class IDmNotify;
class IElementPropertiesChoices;
struct AttributeWidgetInfo_t;
class CDmeEditorAttributeInfo;
class CDmeEditorTypeDictionary;
namespace vgui
{
class Label;
}
using namespace vgui;
//-----------------------------------------------------------------------------
// CBaseAttributePanel
//-----------------------------------------------------------------------------
class CBaseAttributePanel : public vgui::Panel
{
DECLARE_CLASS_SIMPLE( CBaseAttributePanel, vgui::Panel );
public:
CBaseAttributePanel( vgui::Panel *pParent, const AttributeWidgetInfo_t &info );
virtual void PostConstructor();
virtual void PerformLayout();
virtual void SetFont( HFont font );
virtual void ApplySchemeSettings( IScheme *pScheme );
virtual void OnCreateDragData( KeyValues *msg );
void SetDirty( bool dirty );
bool GetDirty() const;
bool IsAutoApply() const;
// Sets/gets the attribute value
template< class T >
void SetAttributeValue( const T& value );
void SetAttributeValue( const char *pValue );
template< class T >
const T& GetAttributeValue( );
// Helper to get/set the attribute value for elements
CDmElement *GetAttributeValueElement();
void SetAttributeValueElement( CDmElement *pElement );
void SetAttributeValueFromString( const char *pString );
bool GetAttributeValueAsString( char *pBuf, int nLength );
// Returns the attribute type to edit
DmAttributeType_t GetAttributeType() const;
CDmAttribute *GetAttribute();
// Returns the editor info
CDmeEditorTypeDictionary *GetEditorTypeDictionary();
CDmeEditorAttributeInfo *GetEditorInfo();
// Call this when the data changed
IDmNotify *GetNotify();
protected:
enum
{
HIDETYPE = 0x01,
HIDEVALUE = 0x02,
READONLY = 0x04,
DIRTY = 0x08,
AUTOAPPLY = 0x10,
};
// Inherited classes must implement this
virtual Panel *GetDataPanel() = 0;
virtual void Apply() = 0;
virtual void Refresh() = 0;
// Methods to get/set column size
int GetSizeForColumn( Panel *panel );
void SetColumnSize( Panel *panel, int width );
virtual void GetPickerBounds( int *x, int *y, int *w, int *h );
// Returns the element being edited by the panel
CDmElement *GetPanelElement();
const CDmElement *GetPanelElement() const;
// Returns the attribute name
const char* GetAttributeName() const;
// Does the element have the attribute we're attempting to reference?
bool HasAttribute() const;
// Returns the attribute array count
int GetAttributeArrayCount() const;
// Are we editing an entry in an attribute array?
bool IsArrayEntry() const;
// Is a particular flag set?
bool HasFlag( int flagMask ) const;
private:
struct colinfo_t
{
Panel *panel;
int width;
};
// Set a flag
void SetFlag( int flagMask, bool bOn );
// Used to sort the column list
static bool ColInfoLessFunc( const colinfo_t& lhs, const colinfo_t& rhs );
// Initializes flags from the attribute editor info
void InitializeFlags( const AttributeWidgetInfo_t &info );
// Called when the OK / Apply button is pressed. Changed data should be written into document.
MESSAGE_FUNC( OnApplyChanges, "ApplyChanges" );
MESSAGE_FUNC( OnRefresh, "Refresh" );
protected:
Label *m_pType;
private:
CDmeHandle< CDmElement > m_hObject;
CDmeHandle< CDmeEditorAttributeInfo > m_hEditorInfo;
CDmeHandle< CDmeEditorTypeDictionary > m_hEditorTypeDict;
char m_szAttributeName[ 256 ];
int m_nArrayIndex;
DmAttributeType_t m_AttributeType;
IDmNotify *m_pNotify;
int m_nFlags;
CUtlRBTree< colinfo_t, int > m_ColumnSize;
HFont m_hFont;
};
//-----------------------------------------------------------------------------
// Inline methods
//-----------------------------------------------------------------------------
inline bool CBaseAttributePanel::HasFlag( int flagMask ) const
{
return ( m_nFlags & flagMask ) ? true : false;
}
inline void CBaseAttributePanel::SetFlag( int flagMask, bool bOn )
{
if ( bOn )
{
m_nFlags |= flagMask;
}
else
{
m_nFlags &= ~flagMask;
}
}
inline bool CBaseAttributePanel::GetDirty() const
{
return HasFlag( DIRTY );
}
inline bool CBaseAttributePanel::IsAutoApply() const
{
return HasFlag( AUTOAPPLY );
}
inline DmAttributeType_t CBaseAttributePanel::GetAttributeType() const
{
return m_AttributeType;
}
inline IDmNotify *CBaseAttributePanel::GetNotify()
{
return m_pNotify;
}
inline const char* CBaseAttributePanel::GetAttributeName() const
{
return m_szAttributeName;
}
inline bool CBaseAttributePanel::IsArrayEntry() const
{
return ( m_nArrayIndex >= 0 );
}
template< class T > inline const T& GetArrayAttributeValue( CDmElement *pElement, const char *pAttribute, int nArrayIndex )
{
const CDmrArray<T> array( pElement, pAttribute );
return array[ nArrayIndex ];
}
template<> inline const DmElementHandle_t& GetArrayAttributeValue<DmElementHandle_t>( CDmElement *pElement, const char *pAttribute, int nArrayIndex )
{
const CDmrElementArray<> array( pElement, pAttribute );
return array.GetHandle( nArrayIndex );
}
template< class T > inline void SetArrayAttributeValue( CDmElement *pElement, const char *pAttribute, int nArrayIndex, const T& value )
{
CDmrArray<T> array( pElement, pAttribute );
array.Set( nArrayIndex, value );
}
template<> inline void SetArrayAttributeValue<DmElementHandle_t>( CDmElement *pElement, const char *pAttribute, int nArrayIndex, const DmElementHandle_t& value )
{
CDmrElementArray<> array( pElement, pAttribute );
array.SetHandle( nArrayIndex, value );
}
//-----------------------------------------------------------------------------
// Sets/gets the attribute value
//-----------------------------------------------------------------------------
template< class T >
void CBaseAttributePanel::SetAttributeValue( const T& value )
{
CUndoScopeGuard sg( CFmtStr( "Set %s", m_szAttributeName ) );
if ( !IsArrayEntry() )
{
GetPanelElement()->SetValue( m_szAttributeName, value );
}
else
{
SetArrayAttributeValue<T>( GetPanelElement(), m_szAttributeName, m_nArrayIndex, value );
}
}
inline void CBaseAttributePanel::SetAttributeValue( const char *pValue )
{
CUndoScopeGuard sg( CFmtStr( "Set %s", m_szAttributeName ) );
if ( !IsArrayEntry() )
{
GetPanelElement()->SetValue( m_szAttributeName, pValue );
}
else
{
CUtlSymbolLarge symbol = g_pDataModel->GetSymbol( pValue );
SetArrayAttributeValue<CUtlSymbolLarge>( GetPanelElement(), m_szAttributeName, m_nArrayIndex, symbol );
}
}
template< class T >
const T& CBaseAttributePanel::GetAttributeValue( )
{
CDmElement *pPanelElement = GetPanelElement();
if ( !pPanelElement )
{
static T temp;
CDmAttributeInfo<T>::SetDefaultValue( temp );
return temp;
}
if ( !IsArrayEntry() )
return pPanelElement->GetValue<T>( m_szAttributeName );
return GetArrayAttributeValue<T>( pPanelElement, m_szAttributeName, m_nArrayIndex );
}
//-----------------------------------------------------------------------------
// Returns the panel element
//-----------------------------------------------------------------------------
inline CDmElement *CBaseAttributePanel::GetPanelElement()
{
return m_hObject;
}
inline const CDmElement *CBaseAttributePanel::GetPanelElement() const
{
return m_hObject;
}
#endif // BASEATTRIBUTEPANEL_H
+89
View File
@@ -0,0 +1,89 @@
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================//
#ifndef CHANNELGRAPHPANEL_H
#define CHANNELGRAPHPANEL_H
#ifdef _WIN32
#pragma once
#endif
#include <vgui_controls/Panel.h>
#include <vgui_controls/Frame.h>
#include "UtlLinkedList.h"
#include "UtlVector.h"
#include "movieobjects/dmechannel.h"
#include "datamodel/dmehandle.h"
namespace vgui
{
typedef DmeTime_t (*TimeAccessor_t)();
//-----------------------------------------------------------------------------
// Purpose: Holds and displays a chart of dmechannel data
//-----------------------------------------------------------------------------
class CChannelGraphPanel : public Panel
{
DECLARE_CLASS_SIMPLE( CChannelGraphPanel, Panel );
public:
CChannelGraphPanel( Panel *parent, const char *name );
void SetChannel( CDmeChannel *pChannel );
// input messages
virtual void OnCursorMoved( int mx, int my );
virtual void OnMousePressed( MouseCode code );
virtual void OnMouseReleased( MouseCode code );
virtual void OnMouseWheeled( int delta );
virtual void OnSizeChanged( int newWide, int newTall ); // called after the size of a panel has been changed
protected:
virtual void Paint();
virtual void PerformLayout();
virtual void ApplySchemeSettings( IScheme *pScheme );
int TimeToPixel( DmeTime_t time );
int ValueToPixel( float flValue );
private:
CDmeHandle< CDmeChannel > m_hChannel;
HFont m_font;
TimeAccessor_t m_timeFunc;
DmeTime_t m_graphMinTime, m_graphMaxTime;
float m_graphMinValue, m_graphMaxValue;
int m_nMouseStartX, m_nMouseStartY;
int m_nMouseLastX, m_nMouseLastY;
int m_nTextBorder;
int m_nGraphOriginX;
int m_nGraphOriginY;
float m_flTimeToPixel;
float m_flValueToPixel;
};
//-----------------------------------------------------------------------------
// CChannelGraphFrame
//-----------------------------------------------------------------------------
class CChannelGraphFrame : public Frame
{
DECLARE_CLASS_SIMPLE( CChannelGraphFrame, Frame );
public:
CChannelGraphFrame( Panel *parent, const char *pTitle );
void SetChannel( CDmeChannel *pChannel );
virtual void OnCommand( const char *cmd );
virtual void PerformLayout();
protected:
CChannelGraphPanel *m_pChannelGraph;
};
} // namespace vgui
#endif // CHANNELGRAPHPANEL_H
@@ -0,0 +1,93 @@
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======
//
// Purpose:
//
//=============================================================================
#ifndef DMESOURCEDCCFILEPANEL_H
#define DMESOURCEDCCFILEPANEL_H
#ifdef _WIN32
#pragma once
#endif
#include "vgui_controls/EditablePanel.h"
#include "datamodel/dmehandle.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
namespace vgui
{
class TextEntry;
}
class CDmeSourceDCCFile;
//-----------------------------------------------------------------------------
// Purpose: Asset builder
//-----------------------------------------------------------------------------
class CDmeSourceDCCFilePanel : public vgui::EditablePanel
{
DECLARE_CLASS_SIMPLE( CDmeSourceDCCFilePanel, EditablePanel );
public:
CDmeSourceDCCFilePanel( vgui::Panel *pParent, const char *pPanelName );
virtual ~CDmeSourceDCCFilePanel();
// Inherited from Panel
virtual void OnCommand( const char *pCommand );
virtual void OnKeyCodeTyped( vgui::KeyCode code );
void SetDmeElement( CDmeSourceDCCFile *pSourceDCCFile );
/*
messages sent:
"DmeElementChanged" The element has been changed
*/
private:
MESSAGE_FUNC_PARAMS( OnTextNewLine, "TextNewLine", kv );
MESSAGE_FUNC_PARAMS( OnInputCompleted, "InputCompleted", kv );
MESSAGE_FUNC_PARAMS( OnItemSelected, "ItemSelected", kv );
MESSAGE_FUNC_PARAMS( OnItemDeselected, "ItemDeselected", kv );
// Shows the DCC object browser (once we have one)
void ShowDCCObjectBrowser( const char *pTitle, const char *pPrompt, KeyValues *pDialogKeys );
// Called when we're browsing for a DCC object and one was selected
void OnDCCObjectAdded( const char *pDCCObjectName, KeyValues *pContextKeys );
// Refresh the source list
void RefreshDCCObjectList( );
// Called when the source file name changes
bool CheckForDuplicateNames( const char *pDCCObjectName, int nDCCObjectSkipIndex = -1 );
void OnBrowseDCCObject();
void OnAddDCCObject();
void OnRemoveDCCObject();
void OnDCCObjectNameChanged();
// Selects a particular DCC object
void SelectDCCObject( int nDCCObjectIndex );
// Called when a list panel's selection changes
void OnItemSelectionChanged( );
// Marks the file as dirty
void SetDirty( );
vgui::ListPanel *m_pRootDCCObjects;
vgui::Button *m_pDCCObjectBrowser;
vgui::Button *m_pAddDCCObject;
vgui::Button *m_pRemoveDCCObject;
vgui::Button *m_pApplyChanges;
vgui::TextEntry *m_pDCCObjectName;
CDmeHandle< CDmeSourceDCCFile > m_hSourceDCCFile;
};
#endif // DMESOURCEDCCFILEPANEL_H
+62
View File
@@ -0,0 +1,62 @@
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======
//
// Purpose:
//
//=============================================================================
#ifndef DMESOURCESKINPANEL_H
#define DMESOURCESKINPANEL_H
#ifdef _WIN32
#pragma once
#endif
#include "vgui_controls/EditablePanel.h"
#include "datamodel/dmehandle.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
namespace vgui
{
class TextEntry;
class CheckButton;
}
class CDmeSourceSkin;
//-----------------------------------------------------------------------------
// Purpose: Asset builder
//-----------------------------------------------------------------------------
class CDmeSourceSkinPanel : public vgui::EditablePanel
{
DECLARE_CLASS_SIMPLE( CDmeSourceSkinPanel, EditablePanel );
public:
CDmeSourceSkinPanel( vgui::Panel *pParent, const char *pPanelName );
virtual ~CDmeSourceSkinPanel();
void SetDmeElement( CDmeSourceSkin *pSourceSkin );
/*
messages sent:
"DmeElementChanged" The element has been changed
*/
private:
MESSAGE_FUNC_PARAMS( OnTextChanged, "TextChanged", kv );
MESSAGE_FUNC_INT( OnCheckButtonChecked, "CheckButtonChecked", state );
// Marks the file as dirty
void SetDirty( );
vgui::TextEntry *m_pSkinName;
vgui::TextEntry *m_pScale;
vgui::CheckButton *m_pFlipTriangles;
CDmeHandle< CDmeSourceSkin > m_hSourceSkin;
};
#endif // DMESOURCESKINPANEL_H
+505
View File
@@ -0,0 +1,505 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef ELEMENTPROPERTIESTREE_H
#define ELEMENTPROPERTIESTREE_H
#ifdef _WIN32
#pragma once
#endif
#include "vgui_controls/Frame.h"
#include "dme_controls/AttributeWidgetFactory.h"
#include "vgui_controls/TreeView.h"
#include "vgui_controls/TreeViewListControl.h"
#include "datamodel/dmelement.h"
#include "datamodel/dmattribute.h"
#include "datamodel/dmattributevar.h"
#include "datamodel/dmehandle.h"
#include "datamodel/dmattributevar.h"
#include "tier1/utlntree.h"
#include "tier1/utlstring.h"
#include "tier1/utlvector.h"
#include "vgui_controls/InputDialog.h"
#include "vgui/KeyCode.h"
#include "dme_controls/inotifyui.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CDmElement;
class IDmNotify;
class CDocAllElements;
class IAttributeWidgetFactory;
class CDmeEditorTypeDictionary;
class CPropertiesTreeToolbar;
namespace vgui
{
class TextEntry;
class ComboBox;
class Button;
class PanelListPanel;
class Menu;
}
//-----------------------------------------------------------------------------
// CElementTreeViewListControl
//-----------------------------------------------------------------------------
class CElementTreeViewListControl : public vgui::CTreeViewListControl
{
DECLARE_CLASS_SIMPLE( CElementTreeViewListControl, CTreeViewListControl );
public:
CElementTreeViewListControl( Panel *pParent, const char *pName );
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
virtual int AddItem( KeyValues *data, bool allowLabelEditing, int parentItemIndex, CUtlVector< vgui::Panel * >& columnPanels );
virtual void RemoveItem( int nItemIndex );
virtual void PerformLayout();
virtual void RemoveAll();
virtual vgui::HFont GetFont( int size );
virtual void SetFont( vgui::HFont font );
virtual int GetFontSize();
virtual void SetFontSize( int size );
virtual void Paint();
virtual void PostChildPaint();
virtual void ExpandItem( int itemIndex, bool bExpand );
virtual bool IsItemExpanded( int itemIndex );
virtual bool IsItemSelected( int itemIndex );
virtual KeyValues *GetItemData( int itemIndex );
virtual int GetTreeColumnWidth();
virtual void SetTreeColumnWidth( int w );
virtual void OnCursorMoved( int x, int y );
virtual void OnMousePressed( vgui::MouseCode code );
virtual void OnMouseReleased( vgui::MouseCode code );
virtual void OnMouseDoublePressed( vgui::MouseCode code );
virtual void OnMouseWheeled( int delta );
virtual int GetScrollBarSize();
virtual void ToggleDrawGrid();
virtual bool IsDrawingGrid();
virtual void ToggleDrawAlternatingRowColors();
virtual bool IsDrawingAlternatingRowColors();
virtual bool IsHidingTypeSubColumn();
virtual void ToggleHideSubColumn();
void ResizeTreeToExpandedWidth();
private:
struct ColumnPanels_t
{
ColumnPanels_t() :
treeViewItem( -1 )
{
}
ColumnPanels_t( const ColumnPanels_t& src )
{
treeViewItem = src.treeViewItem;
int i, c;
c = src.m_Columns.Count();
for ( i = 0; i < c; ++i )
{
m_Columns.AddToTail( src.m_Columns[ i ] );
}
}
void SetList( CUtlVector< vgui::Panel * >& list )
{
m_Columns.RemoveAll();
int c = list.Count();
for ( int i = 0; i < c; ++i )
{
m_Columns.AddToTail( list[ i ] );
}
}
int treeViewItem;
CUtlVector< vgui::Panel * > m_Columns;
};
// Removes an item from the tree recursively
void RemoveItem_R( int nItemIndex );
void HideAll();
static bool PanelsLessFunc( const ColumnPanels_t& lhs, const ColumnPanels_t& rhs )
{
return lhs.treeViewItem < rhs.treeViewItem;
}
int m_iTreeColumnWidth;
int m_iFontSize; // 1 = verySmall, small, normal, large, verylarge
bool m_bMouseLeftIsDown;
bool m_bMouseIsDragging;
bool m_bDrawGrid;
bool m_bDrawAlternatingRowColors;
bool m_bHideTypeSubColumn;
CUtlRBTree< ColumnPanels_t, int > m_Panels;
};
//-----------------------------------------------------------------------------
// CElementPropertiesTreeInternal
//-----------------------------------------------------------------------------
class CElementPropertiesTreeInternal : public vgui::EditablePanel
{
DECLARE_CLASS_SIMPLE( CElementPropertiesTreeInternal, vgui::EditablePanel );
public:
enum RefreshType_t
{
REFRESH_REBUILD = 0, // Close the entire tree
REFRESH_VALUES_ONLY, // Tree topology hasn't changed; only update values
REFRESH_TREE_VIEW, // Tree topology changed; some attributes may be added or removed
};
CElementPropertiesTreeInternal( vgui::Panel *parent, IDmNotify *pNotify,
CDmElement *pObject, bool autoApply = true, CDmeEditorTypeDictionary *pDict = NULL );
~CElementPropertiesTreeInternal();
virtual void Init( );
virtual void Refresh( RefreshType_t rebuild = REFRESH_TREE_VIEW, bool preservePrevSelectedItem = false );
virtual void ApplyChanges();
virtual void GenerateChildrenOfNode( int itemIndex );
virtual void GenerateContextMenu( int itemIndex, int x, int y );
virtual void GenerateDragDataForItem( int itemIndex, KeyValues *msg );
virtual void OnLabelChanged( int itemIndex, char const *oldString, char const *newString );
virtual bool IsItemDroppable( int itemIndex, bool bInsertBefore, CUtlVector< KeyValues * >& msglist );
virtual void OnItemDropped( int itemIndex, bool bInsertBefore, CUtlVector< KeyValues * >& msglist );
virtual bool GetItemDropContextMenu( int itemIndex, vgui::Menu *menu, CUtlVector< KeyValues * >& msglist );
virtual vgui::HCursor GetItemDropCursor( int itemIndex, CUtlVector< KeyValues * >& msglist );
virtual void SetObject( CDmElement *object );
virtual void OnCommand( const char *cmd );
MESSAGE_FUNC( OnToggleShowMemoryUsage, "OnToggleShowMemoryUsage" );
MESSAGE_FUNC( OnToggleShowUniqueID, "OnToggleShowUniqueID" );
virtual bool IsShowingMemoryUsage();
virtual bool IsShowingUniqueID();
CDmElement *GetObject();
bool IsLabelBeingEdited() const;
bool HasItemsSelected() const;
enum
{
DME_PROPERTIESTREE_MENU_BACKWARD = 0,
DME_PROPERTIESTREE_MENU_FORWARD,
DME_PROPERTIESTREE_MENU_SEARCHHSITORY,
DME_PROPERTIESTREE_MENU_UP,
};
virtual void PopulateHistoryMenu( int whichMenu, vgui::Menu *menu );
virtual int GetHistoryMenuItemCount( int whichMenu );
void AddToSearchHistory( char const *str );
void SetTypeDictionary( CDmeEditorTypeDictionary *pDict );
void SetSortAttributesByName( bool bSortAttributesByName );
MESSAGE_FUNC_CHARPTR( OnNavSearch, "OnNavigateSearch", text );
protected:
KeyValues *GetTreeItemData( int itemIndex );
protected:
struct AttributeWidgets_t
{
vgui::Panel *m_pValueWidget;
bool operator==( const AttributeWidgets_t &src ) const
{
return m_pValueWidget == src.m_pValueWidget;
}
};
enum
{
EP_EXPANDED = (1<<0),
EP_SELECTED = (1<<1),
};
struct TreeItem_t
{
TreeItem_t() :
m_pElement( 0 ),
m_pAttributeName(),
m_pArrayElement( 0 )
{
}
CDmElement *m_pElement;
CUtlString m_pAttributeName;
CDmElement *m_pArrayElement; // points to the element referenced in an element array
};
// Used to build a list of open element for refresh
struct TreeInfo_t
{
TreeInfo_t() :
m_nFlags( 0 )
{
}
TreeItem_t m_Item; // points to the element referenced in an element array
int m_nFlags;
TreeItem_t m_Preserved;
};
typedef CUtlNTree< TreeInfo_t, int > OpenItemTree_t;
struct SearchResult_t
{
CDmeHandle< CDmElement > handle;
CUtlString attributeName;
bool operator == ( const SearchResult_t &other ) const
{
if ( &other == this )
return true;
if ( other.handle != handle )
return false;
if ( other.attributeName != attributeName )
return false;
return true;
}
};
bool BuildExpansionListToFindElement_R( CUtlRBTree< CDmElement *, int >& visited, int depth, SearchResult_t& sr, CDmElement *owner, CDmElement *element, char const *attributeName, int arrayIndex, CUtlVector< int >& expandIndices );
void FindMatchingElements_R( CUtlRBTree< CDmElement *, int >& visited, char const *searchstr, const DmObjectId_t *pSearchId, CDmElement *root, CUtlVector< SearchResult_t >& list );
void NavigateToSearchResult();
void SpewOpenItems( int depth, OpenItemTree_t &tree, int nOpenTreeIndex, int nItemIndex );
// Finds the tree index of a child matching the particular element + attribute
int FindTreeItem( int nParentIndex, const TreeItem_t &info );
// Expands all items in the open item tree if they exist
void ExpandOpenItems( OpenItemTree_t &tree, int nOpenTreeIndex, int nItemIndex, bool makeVisible );
// Builds a list of open items
void BuildOpenItemList( OpenItemTree_t &tree, int nParent, int nItemIndex, bool preservePrevSelectedItem );
void FillInDataForItem( TreeItem_t &item, int nItemIndex );
// Removes an item from the tree
void RemoveItem( int nItemIndex );
// Removes an item recursively
void RemoveItem_R( int nItemIndex );
// Adds a single entry into the tree
void CreateTreeEntry( int parentNodeIndex, CDmElement* obj, CDmAttribute *pAttribute, int nArrayIndex, AttributeWidgets_t &entry );
// populate the menu with the element hierarchy of "element_<elementtype>" commands
void PopulateMenuWithElementHierarchy_R( vgui::Menu *pMenu, const char *pElementType, CDmElementFactoryHelper *pChildFactory = NULL );
void PopulateMenuWithElementHierarchy_R( vgui::Menu *pMenu, CDmElementFactoryHelper *pFactory );
// Sets up the attribute widget init info for a particular attribute
virtual void SetupWidgetInfo( AttributeWidgetInfo_t *pInfo, CDmElement *obj, CDmAttribute *pAttribute, int nArrayIndex = -1 );
// Creates an attribute data widget using a specifically requested widget
vgui::Panel *CreateAttributeDataWidget( CDmElement *pElement, const char *pWidgetName, CDmElement *obj, CDmAttribute *pAttribute, int nArrayIndex = -1 );
void UpdateTree();
void InsertAttributes( int parentNodeIndex, CDmElement *obj );
void InsertAttributeArrayMembers( int parentNodeIndex, CDmElement *obj, CDmAttribute *array );
// Adds a single editable attribute of the element to the tree
void InsertSingleAttribute( int parentNodeIndex, CDmElement *obj, CDmAttribute *pAttribute, int nArrayIndex = -1 );
// Refreshes the tree view
void RefreshTreeView( bool preservePrevSelectedItem = false );
// Gets tree view text
void GetTreeViewText( CDmElement* obj, CDmAttribute *pAttribute, int nArrayIndex, char *pBuffer, int nMaxLen, bool& editableText );
void RemoveSelected( bool selectLeft );
void AddToHistory( CDmElement *element );
void ValidateHistory();
void SpewHistory();
void JumpToHistoryItem();
void UpdateButtonState();
void UpdateReferences();
KEYBINDING_FUNC( ondelete, KEY_DELETE, 0, OnKeyDelete, "#elementpropertiestree_ondelete_help", 0 );
KEYBINDING_FUNC( onbackspace, KEY_BACKSPACE, 0, OnKeyBackspace, "#elementpropertiestree_ondelete_help", 0 );
KEYBINDING_FUNC_NODECLARE( onrefresh, KEY_F5, 0, OnRefresh, "#elementpropertiestree_onrefresh_help", 0 );
MESSAGE_FUNC( OnEstimateMemory, "OnEstimateMemory" );
MESSAGE_FUNC( OnRename, "OnRename" );
MESSAGE_FUNC( OnRemove, "OnRemove" );
MESSAGE_FUNC( OnClear, "OnClear" );
MESSAGE_FUNC( OnSortByName, "OnSortByName" );
MESSAGE_FUNC( OnCut, "OnCut" );
MESSAGE_FUNC( OnCopy, "OnCopy" );
MESSAGE_FUNC( OnPaste, "OnPaste" );
MESSAGE_FUNC( OnPasteReference, "OnPasteReference" );
MESSAGE_FUNC( OnPasteInsert, "OnPasteInsert" );
MESSAGE_FUNC_INT( OnElementChangedExternally, "ElementChangedExternally", valuesOnly );
MESSAGE_FUNC_INT( OnNavUp, "OnNavigateUp", item );
MESSAGE_FUNC_INT( OnNavBack, "OnNavigateBack", item );
MESSAGE_FUNC_INT( OnNavForward, "OnNavigateForward", item );
MESSAGE_FUNC_INT( OnNavigateSearchAgain, "OnNavigateSearchAgain", direction );
MESSAGE_FUNC( OnShowSearchResults, "OnShowSearchResults" );
MESSAGE_FUNC( OnRefresh, "OnRefresh" );
protected:
MESSAGE_FUNC_PARAMS( OnInputCompleted, "InputCompleted", params );
MESSAGE_FUNC( OnAddItem, "OnAddItem" );
MESSAGE_FUNC_PARAMS( OnSetShared, "OnSetShared", pParams );
MESSAGE_FUNC_PARAMS( OnChangeFile, "OnChangeFile", pParams );
MESSAGE_FUNC_PARAMS( OnShowFileDialog, "OnShowFileDialog", pParams );
MESSAGE_FUNC_PARAMS( OnFileSelected, "FileSelected", params );
enum DropOperation_t
{
DO_MOVE,
DO_LINK,
DO_COPY,
DO_UNKNOWN,
};
DropOperation_t GetDropOperation( int itemIndex, CUtlVector< KeyValues * >& msglist );
void DropItemsIntoArray( CDmrElementArray<> &array,
CUtlVector< KeyValues* > &msglist,
CUtlVector< CDmElement* > &list,
int nArrayIndex, DropOperation_t op );
bool OnRemoveFromData( CUtlVector< KeyValues * >& list );
bool OnRemoveFromData( KeyValues *item );
void OnPaste_( bool reference );
bool ShowAddAttributeDialog( CDmElement *pElement, const char *pAttributeType );
void AddAttribute( const char *pAttributeName, KeyValues *pContext );
bool ShowSetElementAttributeDialog( CDmElement *pOwner, const char *pAttributeName, int nArrayItem, const char *pElementType );
void SetElementAttribute( const char *pElementName, KeyValues *pContext );
void OnImportElement( const char *pFullPath, KeyValues *pContext );
void OnExportElement( const char *pFullPath, KeyValues *pContext );
template < class C >
void CollectSelectedElements( C &container );
void GetPathToItem( CUtlVector< TreeItem_t > &path, int itemIndex );
int OpenPath( const CUtlVector< TreeItem_t > &path );
// Refreshes the color state of the tree
void RefreshTreeItemState( int nItemID );
// Refreshes the color state of the tree
void SetTreeItemColor( int nItemID, CDmElement *pEntryElement, bool bIsElementArrayItem, bool bEditableLabel );
CDmeHandle< CDmeEditorTypeDictionary > m_hTypeDictionary;
CUtlVector< AttributeWidgets_t > m_AttributeWidgets;
IDmNotify *m_pNotify;
CDmeHandle< CDmElement > m_hObject;
CElementTreeViewListControl *m_pTree;
bool m_bAutoApply;
bool m_bShowMemoryUsage;
bool m_bShowUniqueID;
vgui::DHANDLE< vgui::Menu > m_hContextMenu;
CPropertiesTreeToolbar *m_pToolBar; // Forward/backward navigation and search fields
enum
{
DME_PROPERTIESTREE_MAXHISTORYITEMS = 32,
DME_PROPERTIESTREE_MAXSEARCHHISTORYITEMS = 32,
};
// Most recent are at the head
CUtlVector< CDmeHandle< CDmElement > > m_hHistory;
int m_nCurrentHistoryPosition;
bool m_bSuppressHistoryUpdates;
char m_szSearchStr[ 128 ];
CUtlVector< SearchResult_t > m_SearchResults;
int m_nCurrentSearchResult;
CUtlVector< CUtlString > m_SearchHistory;
CDmeHandle< CDmElement > m_SearchResultsRoot;
vgui::HCursor m_hDragCopyCursor;
vgui::HCursor m_hDragLinkCursor;
vgui::HCursor m_hDragMoveCursor;
bool m_bSortAttributesByName;
CUtlVector< CDmeHandle< CDmElement > > m_vecDmeReferencesToObject;
};
//-----------------------------------------------------------------------------
// CElementPropertiesTree
//-----------------------------------------------------------------------------
class CElementPropertiesTree : public vgui::Frame
{
DECLARE_CLASS_SIMPLE( CElementPropertiesTree, vgui::Frame );
public:
CElementPropertiesTree( vgui::Panel *parent, IDmNotify *pNotify, CDmElement *pObject, CDmeEditorTypeDictionary *pDict = NULL );
virtual void Init( );
virtual void Refresh( CElementPropertiesTreeInternal::RefreshType_t rebuild = CElementPropertiesTreeInternal::REFRESH_REBUILD, bool preservePrevSelectedItem = false );
virtual void GenerateChildrenOfNode( int itemIndex );
virtual void SetObject( CDmElement *object );
virtual void OnCommand( const char *cmd );
virtual void ActivateBuildMode();
CElementPropertiesTreeInternal *GetInternal();
protected:
CElementPropertiesTreeInternal *m_pProperties;
vgui::Button *m_pOK;
vgui::Button *m_pApply;
vgui::Button *m_pCancel;
};
//-----------------------------------------------------------------------------
// Inline methods
//-----------------------------------------------------------------------------
inline CElementPropertiesTreeInternal *CElementPropertiesTree::GetInternal()
{
return m_pProperties;
}
//-----------------------------------------------------------------------------
// Wrapper panel to hook into DmePanels
//-----------------------------------------------------------------------------
class CDmeElementPanel : public CElementPropertiesTreeInternal, public IDmNotify
{
DECLARE_CLASS_SIMPLE( CDmeElementPanel, CElementPropertiesTreeInternal );
public:
CDmeElementPanel( vgui::Panel *pParent, const char *pPanelName );
void SetDmeElement( CDmElement *pElement );
// Inherited from IDmNotify
virtual void NotifyDataChanged( const char *pReason, int nNotifySource, int nNotifyFlags );
};
#endif // ELEMENTPROPERTIESTREE_H
+84
View File
@@ -0,0 +1,84 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef FILELISTMANAGER_H
#define FILELISTMANAGER_H
#ifdef _WIN32
#pragma once
#endif
#include "datamodel/idatamodel.h"
#include "vgui_controls/listpanel.h"
#include "vgui_controls/frame.h"
#include "vgui/KeyCode.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
namespace vgui
{
class CheckButtonList;
}
//-----------------------------------------------------------------------------
// CFileListManager
//-----------------------------------------------------------------------------
class CFileListManager : public vgui::ListPanel
{
DECLARE_CLASS_SIMPLE( CFileListManager , vgui::ListPanel );
public:
CFileListManager( vgui::Panel *parent );
virtual void Refresh();
virtual void OnCommand( const char *cmd );
virtual void OnThink();
virtual void OnMousePressed( vgui::MouseCode code );
protected:
MESSAGE_FUNC_PARAMS( OnOpenContextMenu, "OpenContextMenu", pParams );
MESSAGE_FUNC_PARAMS( OnOpenFile, "open", pParams );
MESSAGE_FUNC_PARAMS( OnLoadFiles, "load", pParams );
MESSAGE_FUNC_PARAMS( OnUnloadFiles, "unload", pParams );
MESSAGE_FUNC_PARAMS( OnSaveFiles, "save", pParams );
MESSAGE_FUNC_PARAMS( OnSaveFileAs, "saveas", pParams );
MESSAGE_FUNC_PARAMS( OnAddToPerforce, "p4add", pParams );
MESSAGE_FUNC_PARAMS( OnOpenForEdit, "p4edit", pParams );
MESSAGE_FUNC_PARAMS( OnFileSelected, "FileSelected", pParams );
MESSAGE_FUNC_PARAMS( OnDataChanged, "DataChanged", pParams );
int AddItem( DmFileId_t fileid, const char *pFilename, const char *pPath, bool bLoaded, int nElements, bool bChanged, bool bInPerforce, bool bOpenForEdit );
void SetLoaded( DmFileId_t fileid, bool bLoaded );
vgui::CheckButtonList *m_pFileList;
bool m_bRefreshRequired;
vgui::DHANDLE< vgui::Menu > m_hContextMenu;
};
//-----------------------------------------------------------------------------
// CFileListManagerFrame
//-----------------------------------------------------------------------------
class CFileManagerFrame : public vgui::Frame
{
DECLARE_CLASS_SIMPLE( CFileManagerFrame, vgui::Frame );
public:
CFileManagerFrame( vgui::Panel *parent );
virtual void Refresh();
virtual void OnCommand( const char *cmd );
virtual void PerformLayout();
protected:
CFileListManager *m_pFileListManager;
};
#endif // FILELISTMANAGER_H
+25
View File
@@ -0,0 +1,25 @@
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======
//
// Purpose:
//
//=============================================================================
#ifndef RECORDINGSTATE_H
#define RECORDINGSTATE_H
#ifdef _WIN32
#pragma once
#endif
// Animation set editor recording states
enum RecordingState_t
{
AS_OFF = 0,
AS_PREVIEW,
AS_RECORD,
AS_PLAYBACK,
AS_CURVEEDIT,
NUM_AS_RECORDING_STATES,
};
#endif // RECORDINGSTATE_H
@@ -0,0 +1,105 @@
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======//
//
// Purpose:
//
// $NoKeywords: $
//
//=============================================================================//
#ifndef ATTRIBUTEASSETPICKERPANEL_H
#define ATTRIBUTEASSETPICKERPANEL_H
#ifdef _WIN32
#pragma once
#endif
#include "dme_controls/AttributeBasePickerPanel.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CBaseAssetPickerFrame;
//-----------------------------------------------------------------------------
// CAttributeAssetPickerPanel
//-----------------------------------------------------------------------------
class CAttributeAssetPickerPanel : public CAttributeBasePickerPanel
{
DECLARE_CLASS_SIMPLE( CAttributeAssetPickerPanel, CAttributeBasePickerPanel );
public:
CAttributeAssetPickerPanel( vgui::Panel *parent, const AttributeWidgetInfo_t &info );
~CAttributeAssetPickerPanel();
protected:
virtual CBaseAssetPickerFrame *CreateAssetPickerFrame() = 0;
MESSAGE_FUNC_PARAMS( OnAssetSelected, "AssetSelected", kv );
virtual void ShowPickerDialog();
};
//-----------------------------------------------------------------------------
// Macro to quickly make new attribute types
//-----------------------------------------------------------------------------
#define DECLARE_ATTRIBUTE_ASSET_PICKER( _className ) \
class _className : public CAttributeAssetPickerPanel \
{ \
DECLARE_CLASS_SIMPLE( _className, CAttributeAssetPickerPanel ); \
public: \
_className( vgui::Panel *parent, const AttributeWidgetInfo_t &info ) : \
BaseClass( parent, info ) {} \
private: \
virtual CBaseAssetPickerFrame *CreateAssetPickerFrame(); \
}
#define IMPLEMENT_ATTRIBUTE_ASSET_PICKER( _className, _popupTitle, _assetType, _assetExt, _assetSubDir, _assetTextType ) \
CBaseAssetPickerFrame *_className::CreateAssetPickerFrame() \
{ \
return new CAssetPickerFrame( this, _popupTitle, _assetType, _assetExt, _assetSubDir, _assetTextType ); \
}
//-----------------------------------------------------------------------------
// Macro to quickly make new attribute types
//-----------------------------------------------------------------------------
#define DECLARE_ATTRIBUTE_ASSET_PREVIEW_PICKER( _className ) \
class _className : public CAttributeAssetPickerPanel \
{ \
DECLARE_CLASS_SIMPLE( _className, CAttributeAssetPickerPanel ); \
public: \
_className( vgui::Panel *parent, const AttributeWidgetInfo_t &info ) : \
BaseClass( parent, info ) {} \
private: \
virtual CBaseAssetPickerFrame *CreateAssetPickerFrame(); \
}
#define IMPLEMENT_ATTRIBUTE_ASSET_PREVIEW_PICKER( _className, _pickerClassName, _popupTitle ) \
CBaseAssetPickerFrame *_className::CreateAssetPickerFrame() \
{ \
return new _pickerClassName( this, _popupTitle ); \
}
//-----------------------------------------------------------------------------
// Assets
//-----------------------------------------------------------------------------
DECLARE_ATTRIBUTE_ASSET_PICKER( CAttributeBspPickerPanel );
DECLARE_ATTRIBUTE_ASSET_PREVIEW_PICKER( CAttributeVtfPickerPanel );
DECLARE_ATTRIBUTE_ASSET_PREVIEW_PICKER( CAttributeTgaPickerPanel );
class CAttributeVmtPickerPanel : public CAttributeAssetPickerPanel
{
DECLARE_CLASS_SIMPLE( CAttributeVmtPickerPanel, CAttributeAssetPickerPanel );
public:
CAttributeVmtPickerPanel( vgui::Panel *parent, const AttributeWidgetInfo_t &info ) :
BaseClass( parent, info ) {}
private:
virtual CBaseAssetPickerFrame *CreateAssetPickerFrame();
MESSAGE_FUNC_PARAMS( OnAssetSelected, "AssetSelected", kv );
};
#endif // ATTRIBUTEASSETPICKERPANEL_H
@@ -0,0 +1,30 @@
//============ Copyright (c) Valve Corporation, All rights reserved. ============
#ifndef ATTRIBUTEBOOLEANPANEL_H
#define ATTRIBUTEBOOLEANPANEL_H
#ifdef _WIN32
#pragma once
#endif
#include "dme_controls/AttributeTextPanel.h"
//-----------------------------------------------------------------------------
class CAttributeBooleanPanel : public CAttributeTextPanel
{
DECLARE_CLASS_SIMPLE( CAttributeBooleanPanel, CAttributeTextPanel );
public:
CAttributeBooleanPanel( vgui::Panel *parent, const AttributeWidgetInfo_t &info );
MESSAGE_FUNC_INT( OnCheckButtonChecked, "CheckButtonChecked", state );
virtual void PerformLayout();
virtual void Refresh();
virtual void ApplySchemeSettings(IScheme *pScheme);
protected:
vgui::CheckButton *m_pValueButton;
};
#endif // ATTRIBUTEBOOLEANPANEL_H
@@ -0,0 +1,47 @@
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======//
//
// Purpose:
//
// $NoKeywords: $
//
//=============================================================================//
#ifndef ATTRIBUTEDETAILTYPEPICKERPANEL_H
#define ATTRIBUTEDETAILTYPEPICKERPANEL_H
#ifdef _WIN32
#pragma once
#endif
#include "dme_controls/AttributeBasePickerPanel.h"
#include "matsys_controls/Picker.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CPickerFrame;
//-----------------------------------------------------------------------------
// CAttributeDetailTypePickerPanel
//-----------------------------------------------------------------------------
class CAttributeDetailTypePickerPanel : public CAttributeBasePickerPanel
{
DECLARE_CLASS_SIMPLE( CAttributeDetailTypePickerPanel, CAttributeBasePickerPanel );
public:
CAttributeDetailTypePickerPanel( vgui::Panel *parent, const AttributeWidgetInfo_t &info );
~CAttributeDetailTypePickerPanel();
private:
// Reads the detail types
void AddDetailTypesToList( PickerList_t &list );
MESSAGE_FUNC_PARAMS( OnPicked, "Picked", kv );
virtual void ShowPickerDialog();
};
#endif // ATTRIBUTEDETAILTYPEPICKERPANEL_H
@@ -0,0 +1,43 @@
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======//
//
// Purpose:
//
// $NoKeywords: $
//
//=============================================================================//
#ifndef ATTRIBUTESHADERPICKERPANEL_H
#define ATTRIBUTESHADERPICKERPANEL_H
#ifdef _WIN32
#pragma once
#endif
#include "dme_controls/AttributeBasePickerPanel.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CPickerFrame;
//-----------------------------------------------------------------------------
// CAttributeShaderPickerPanel
//-----------------------------------------------------------------------------
class CAttributeShaderPickerPanel : public CAttributeBasePickerPanel
{
DECLARE_CLASS_SIMPLE( CAttributeShaderPickerPanel, CAttributeBasePickerPanel );
public:
CAttributeShaderPickerPanel( vgui::Panel *parent, const AttributeWidgetInfo_t &info );
~CAttributeShaderPickerPanel();
private:
MESSAGE_FUNC_PARAMS( OnPicked, "Picked", kv );
virtual void ShowPickerDialog();
};
#endif // ATTRIBUTESHADERPICKERPANEL_H
@@ -0,0 +1,58 @@
//======= Copyright (c) 1996-2009, Valve Corporation, All rights reserved. ======
//
// CAttributeSheetSequencePickerPanel - Panel for editing int attributes that select a sprite sheet sequence
//
//===============================================================================
#ifndef ATTRIBUTESHEETSEQUENCEPICKERPANEL_H
#define ATTRIBUTESHEETSEQUENCEPICKERPANEL_H
#ifdef _WIN32
#pragma once
#endif
#include "dme_controls/AttributeTextPanel.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CSheetSequencePanel;
namespace vgui
{
class MenuButton;
}
//-----------------------------------------------------------------------------
// CAttributeSheetSequencePickerPanel
//-----------------------------------------------------------------------------
class CAttributeSheetSequencePickerPanel : public CAttributeTextPanel
{
DECLARE_CLASS_SIMPLE( CAttributeSheetSequencePickerPanel, CAttributeTextPanel );
public:
CAttributeSheetSequencePickerPanel( vgui::Panel *parent, const AttributeWidgetInfo_t &info );
~CAttributeSheetSequencePickerPanel();
virtual void PerformLayout();
void UpdateSheetPanel();
private:
MESSAGE_FUNC_INT( OnSheetSequenceSelected, "SheetSequenceSelected", nSequenceNumber );
vgui::MenuButton *m_pSequenceSelection;
CSheetSequencePanel *m_pSheetPanel;
bool m_bIsSecondView;
};
// Like the picker panel, except shows the color channel for dual-sequence VMTs
class CAttributeSheetSequencePickerPanel_Secondary : public CAttributeSheetSequencePickerPanel
{
DECLARE_CLASS_SIMPLE( CAttributeSheetSequencePickerPanel_Secondary, CAttributeSheetSequencePickerPanel );
CAttributeSheetSequencePickerPanel_Secondary( vgui::Panel *parent, const AttributeWidgetInfo_t &info );
};
#endif // ATTRIBUTEMDLPICKERPANEL_H
+289
View File
@@ -0,0 +1,289 @@
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======
//
// Purpose:
//
//=============================================================================
#ifndef ATTRIBUTESLIDER_H
#define ATTRIBUTESLIDER_H
#ifdef _WIN32
#pragma once
#endif
#include "vgui_controls/EditablePanel.h"
#include "movieobjects/animsetattributevalue.h"
#include "movieobjects/dmelog.h"
#include "datamodel/dmehandle.h"
using namespace vgui;
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CBaseAnimSetAttributeSliderPanel;
class CDmElement;
class CAttributeSliderTextEntry;
class CSubRectImage;
//-----------------------------------------------------------------------------
// CAttributeSlider
//-----------------------------------------------------------------------------
// THIS CODE IS KIND OF A MESS WRT THE VARIOUS STATES WE CAN BE IN:
// we can be driven by the preset pane or by dragging on any individual control
// we can also be driven by ctrl hovering over the preset pane or an individual control
// if we move from control to control in the preset or here, we need to be able to decay into/out of the various individual sliders
class CAttributeSlider : public EditablePanel
{
DECLARE_CLASS_SIMPLE( CAttributeSlider, EditablePanel );
// Overridden methods of EditablePanel
public:
virtual void Paint();
virtual void PaintBackground();
virtual void ApplySchemeSettings( IScheme *scheme );
virtual void PerformLayout();
virtual void OnCursorMoved(int x, int y);
virtual void OnMousePressed(MouseCode code);
virtual void OnMouseDoublePressed(MouseCode code);
virtual void OnMouseReleased(MouseCode code);
virtual void OnCursorEntered();
virtual void OnCursorExited();
virtual void OnKeyCodeTyped( KeyCode code );
// Other public methods
public:
CAttributeSlider( CBaseAnimSetAttributeSliderPanel *parent );
virtual ~CAttributeSlider();
void Init( CDmElement *control, bool bOrientation );
// Things that rely on a specific type
void SetValue( AnimationControlType_t type, float flValue );
void SetValue( AnimationControlType_t type, const Vector &vec );
void SetValue( AnimationControlType_t type, const Quaternion &quat );
float GetValue( AnimationControlType_t type ) const;
void GetValue( AnimationControlType_t type, Vector &vec ) const;
void GetValue( AnimationControlType_t type, Quaternion &quat ) const;
float GetPreview( AnimationControlType_t type ) const;
void GetPreview( AnimationControlType_t type, Vector &vec ) const;
void GetPreview( AnimationControlType_t type, Quaternion &quat ) const;
// Estimates the value of the control given a local coordinate
float EstimateValueAtPos( int nLocalX, int nLocalY ) const;
// Returns the control we're modifying
CDmElement *GetControl();
const CDmElement *GetControl() const;
// sets internal state to dme control's value
void InitControls();
// Gets/sets the slider value.
// NOTE: This may not match the value pushed into the control because of fading
void SetValue( const AttributeValue_t& value );
const AttributeValue_t& GetValue() const;
// Is this slider manipulating a transform control?
// [NOTE: This is a utility method; the control contains these states]
bool IsTransform() const;
bool IsOrientation() const;
bool IsStereo() const;
// Are we dragging?
bool IsDragging() const;
// Are we in text entry mode?
bool IsInTextEntry() const;
void SetPreview( const AttributeValue_t &value, const AttributeValue_t &full );
const AttributeValue_t &GetPreview() const;
const AttributeValue_t &GetPreviewFull() const;
void UpdateFaderAmount( float amount );
void SetVisibleComponents( LogComponents_t componentFlags );
LogComponents_t VisibleComponents() const;
// Slider dependency functions, provide information about which other sliders on which the function of this slider depends
void ClearDependencies();
bool AddDependency( const CAttributeSlider* pSlider );
bool IsDependent( const CAttributeSlider* pSlider ) const;
void SetDependent( bool dependent );
MESSAGE_FUNC( OnSetToDefault, "SetToDefault" );
MESSAGE_FUNC( OnEditMinMaxDefault, "EditMinMaxDefault" );
MESSAGE_FUNC_PARAMS( OnInputCompleted, "InputCompleted", params );
protected:
KEYBINDING_FUNC( ts_curve_1, KEY_1, 0, OnCurve1, "#ts_curve1_help", 0 );
KEYBINDING_FUNC( ts_curve_2, KEY_2, 0, OnCurve2, "#ts_curve2_help", 0 );
KEYBINDING_FUNC( ts_curve_3, KEY_3, 0, OnCurve3, "#ts_curve3_help", 0 );
KEYBINDING_FUNC( ts_curve_4, KEY_4, 0, OnCurve4, "#ts_curve4_help", 0 );
private:
// Various slider modes
enum SliderMode_t
{
SLIDER_MODE_NONE,
SLIDER_MODE_TEXT,
SLIDER_MODE_DRAG_VALUE, // scalar, position or orientation
};
private:
// Things that rely on type
// Called by the text entry code to enter the value into the logs
void StampValueIntoLogs( AnimationControlType_t type, float flValue );
void StampValueIntoLogs( AnimationControlType_t type, const Vector &vecValue );
void StampValueIntoLogs( AnimationControlType_t type, const Quaternion &qValue );
void DrawValueLabel();
// Other stuff
void ActivateControl( AnimationControlType_t type, bool bActive );
// Returns the location of a particular control
void GetControlRect( Rect_t *pRect ) const;
// Methods related to rendering
void DrawMidpoint( int x, int ty, int ttall );
void DrawTick( const Color& clr, const AttributeValue_t &value, int width, int inset );
void DrawNameLabel();
void PaintSliderBackGround();
float GetPreviewAlphaScale() const;
// Methods related to text entry mode
void EnterTextEntryMode( bool bRelatchValues );
void AcceptTextEntryValue();
void DiscardTextEntryValue();
void SetupTextFieldForTextEntryMode( CAttributeSliderTextEntry *&pTextField, const char *pText, bool bRequestFocus );
void SetToDefault();
private:
CBaseAnimSetAttributeSliderPanel *m_pParent;
TextImage *m_pName;
TextImage *m_pValues[ 4 ];
// This is the control we're modifying
CDmeHandle< CDmElement > m_hControl;
// The current mode of the slider
SliderMode_t m_SliderMode;
// The slider value; it may not match the control attribute value due to blending
AttributeValue_t m_Control;
// Info used when in text entry mode
AttributeValue_t m_InitialTextEntryValue;
CAttributeSliderTextEntry *m_pTextField; // if this is a stereo control, then this will be the left text field
CAttributeSliderTextEntry *m_pRightTextField;
AttributeValue_t m_PreviewCurrent;
AttributeValue_t m_PreviewFull;
float m_flFaderAmount;
// Fields used to help with drag
int m_nDragStartPosition[2]; // Where was the mouse clicked?
int m_nAccum[2]; // What's the total mouse movement during the drag?
AttributeValue_t m_dragStartValues; // What was the value of the slider before the drag started?
LogComponents_t m_nVisibleComponents; // Flags used to specify specific components that are visible
bool m_bTransform : 1;
bool m_bOrientation : 1;
bool m_bStereo : 1;
bool m_bDependent : 1;
CUtlVector< const CAttributeSlider* > m_Dependenices; // List of sliders that the operation of this slider depends on
vgui::DHANDLE< vgui::Menu > m_hContextMenu;
friend class CAttributeSliderTextEntry;
};
/*
class CAttributeSliderData
{
// CDmeHandle< CDmElement > m_hControl;
int m_nIndex; // its index, the control's index, and the slider's index
AttributeValue_t m_Control;
AttributeValue_t m_InitialTextEntryValue;
AttributeValue_t m_dragStartValues;
AttributeValue_t m_PreviewCurrent;
AttributeValue_t m_PreviewFull;
AttributeValue_t m_CurrentValue;
AttributeValue_t m_SavedValue;
AttributeValue_t m_FullPresetValue;
float m_flFaderAmount;
unsigned int m_nVisibleComponents;
CUtlVector< const CAttributeSliderData* > m_Dependenices;
};
*/
//-----------------------------------------------------------------------------
// Inline methods
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Returns the control
//-----------------------------------------------------------------------------
inline CDmElement *CAttributeSlider::GetControl()
{
return m_hControl;
}
inline const CDmElement *CAttributeSlider::GetControl() const
{
return m_hControl;
}
//-----------------------------------------------------------------------------
// Returns information about the control
//-----------------------------------------------------------------------------
inline bool CAttributeSlider::IsTransform() const
{
return m_bTransform;
}
inline bool CAttributeSlider::IsOrientation() const
{
return m_bOrientation;
}
inline bool CAttributeSlider::IsStereo() const
{
return m_bStereo;
}
//-----------------------------------------------------------------------------
// Are we dragging?
//-----------------------------------------------------------------------------
inline bool CAttributeSlider::IsDragging() const
{
return m_SliderMode == SLIDER_MODE_DRAG_VALUE;
}
//-----------------------------------------------------------------------------
// Are we in text entry mode?
//-----------------------------------------------------------------------------
inline bool CAttributeSlider::IsInTextEntry() const
{
return m_SliderMode == SLIDER_MODE_TEXT;
}
#endif // ATTRIBUTESLIDER_H
@@ -0,0 +1,47 @@
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======//
//
// Purpose:
//
// $NoKeywords: $
//
//=============================================================================//
#ifndef ATTRIBUTESURFACEPROPERTYPICKERPANEL_H
#define ATTRIBUTESURFACEPROPERTYPICKERPANEL_H
#ifdef _WIN32
#pragma once
#endif
#include "dme_controls/AttributeBasePickerPanel.h"
#include "matsys_controls/Picker.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CPickerFrame;
//-----------------------------------------------------------------------------
// CAttributeSurfacePropertyPickerPanel
//-----------------------------------------------------------------------------
class CAttributeSurfacePropertyPickerPanel : public CAttributeBasePickerPanel
{
DECLARE_CLASS_SIMPLE( CAttributeSurfacePropertyPickerPanel, CAttributeBasePickerPanel );
public:
CAttributeSurfacePropertyPickerPanel( vgui::Panel *parent, const AttributeWidgetInfo_t &info );
~CAttributeSurfacePropertyPickerPanel();
private:
// Reads the surface properties
void AddSurfacePropertiesToList( PickerList_t &list );
MESSAGE_FUNC_PARAMS( OnPicked, "Picked", kv );
virtual void ShowPickerDialog();
};
#endif // ATTRIBUTESURFACEPROPERTYPICKERPANEL_H
@@ -0,0 +1,93 @@
//========= Copyright © 1996-2001, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef DMECOMBINATIONSYSTEMEDITORPANEL_H
#define DMECOMBINATIONSYSTEMEDITORPANEL_H
#ifdef _WIN32
#pragma once
#endif
#include "tier1/utlvector.h"
#include "vgui_controls/Frame.h"
#include "datamodel/dmehandle.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CDmeCombinationControlsPanel;
class CDmeCombinationDominationRulesPanel;
class CDmeCombinationOperator;
class CDmeElementPanel;
namespace vgui
{
class PropertySheet;
class PropertyPage;
class Button;
}
//-----------------------------------------------------------------------------
// Dag editor panel
//-----------------------------------------------------------------------------
class CDmeCombinationSystemEditorPanel : public vgui::EditablePanel
{
DECLARE_CLASS_SIMPLE( CDmeCombinationSystemEditorPanel, vgui::EditablePanel );
public:
// constructor, destructor
CDmeCombinationSystemEditorPanel( vgui::Panel *pParent, const char *pName );
virtual ~CDmeCombinationSystemEditorPanel();
// Sets the current scene + animation list
void SetDmeElement( CDmeCombinationOperator *pComboSystem );
CDmeCombinationOperator *GetDmeElement();
private:
// Called when the selection changes moves
MESSAGE_FUNC( OnPageChanged, "PageChanged" );
MESSAGE_FUNC_PARAMS( OnDmeElementChanged, "DmeElementChanged", kv );
vgui::PropertySheet *m_pEditorSheet;
vgui::PropertyPage *m_pControlsPage;
vgui::PropertyPage *m_pDominationRulesPage;
vgui::PropertyPage *m_pPropertiesPage;
CDmeCombinationControlsPanel *m_pControlsPanel;
CDmeCombinationDominationRulesPanel *m_pDominationRulesPanel;
CDmeElementPanel *m_pPropertiesPanel;
};
//-----------------------------------------------------------------------------
// Frame for combination system
//-----------------------------------------------------------------------------
class CDmeCombinationSystemEditorFrame : public vgui::Frame
{
DECLARE_CLASS_SIMPLE( CDmeCombinationSystemEditorFrame, vgui::Frame );
public:
CDmeCombinationSystemEditorFrame( vgui::Panel *pParent, const char *pTitle );
~CDmeCombinationSystemEditorFrame();
// Sets the current scene + animation list
void SetCombinationOperator( CDmeCombinationOperator *pComboSystem );
// Inherited from Frame
virtual void OnCommand( const char *pCommand );
private:
MESSAGE_FUNC( OnDmeElementChanged, "DmeElementChanged" );
CDmeCombinationSystemEditorPanel *m_pEditor;
vgui::Button *m_pOpenButton;
vgui::Button *m_pCancelButton;
};
#endif // DMECOMBINATIONSYSTEMEDITORPANEL_H
+73
View File
@@ -0,0 +1,73 @@
//===== Copyright © 1996-2005, Valve Corporation, All rights reserved. ======//
//
// Purpose:
//
// $NoKeywords: $
//===========================================================================//
#ifndef DMECONTROLS_H
#define DMECONTROLS_H
#ifdef _WIN32
#pragma once
#endif
#include "tier1/interface.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class ISoundEmitterSystemBase;
class IEngineTool;
class IPhysicsCollision;
class IElementPropertiesChoices;
namespace vgui
{
//-----------------------------------------------------------------------------
// handles the initialization of the vgui interfaces.
// NOTE: Calls into VGui_InitMatSysInterfacesList
// 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_InitDmeInterfacesList( 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 "soundemittersystem/isoundemittersystembase.h"
ISoundEmitterSystemBase *SoundEmitterSystem();
// #include "toolsframework/ienginetool.h"
IEngineTool *EngineTool();
// #include "vphysics_interface.h"
IPhysicsCollision *PhysicsCollision();
// #include "dme_controls/INotifyUI.h"
IElementPropertiesChoices *ElementPropertiesChoices();
void SetElementPropertiesChoices( IElementPropertiesChoices *pChoices );
} // end namespace vgui
//-----------------------------------------------------------------------------
// predeclare all the matsys control class names
//-----------------------------------------------------------------------------
class CDmeMDLPanel;
class CMDLSequencePicker;
class CMDLPicker;
class CParticlePicker;
class CSequencePicker;
class CDmePicker;
class CSoundPicker;
class CFilterComboBox;
class CGameFileTreeView;
#endif // DMECONTROLS_H
+262
View File
@@ -0,0 +1,262 @@
//===== Copyright © 1996-2005, Valve Corporation, All rights reserved. ======//
//
// Purpose:
//
// $NoKeywords: $
//===========================================================================//
#ifndef DMECONTROLS_UTILS_H
#define DMECONTROLS_UTILS_H
#ifdef _WIN32
#pragma once
#endif
#include "tier1/keyvalues.h"
#include "tier1/fmtstr.h"
#include "tier1/utlbufferutil.h"
#include "tier1/utlsymbollarge.h"
#include "datamodel/dmelement.h"
#include "datamodel/dmattribute.h"
#include "datamodel/dmattributevar.h"
#include "movieobjects/dmegamemodel.h"
#include "movieobjects/dmeclip.h"
#include "movieobjects/dmechannel.h"
#include "movieobjects/dmeanimationset.h"
#include "vgui_controls/TextEntry.h"
#include "vgui_controls/InputDialog.h"
#include "vgui_controls/Menu.h"
inline int AddCheckableMenuItem( vgui::Menu *pMenu, const char *pItemName, KeyValues *pKeyValues, vgui::Panel *pTarget, bool bState, bool bEnabled = true )
{
int id = pMenu->AddCheckableMenuItem( pItemName, pKeyValues, pTarget );
pMenu->SetMenuItemChecked( id, bState );
pMenu->SetItemEnabled( id, bEnabled );
return id;
}
inline int AddCheckableMenuItem( vgui::Menu *pMenu, const char *pItemName, const char *pKVName, vgui::Panel *pTarget, bool bState, bool bEnabled = true )
{
return AddCheckableMenuItem( pMenu, pItemName, new KeyValues( pKVName ), pTarget, bState, bEnabled );
}
//-----------------------------------------------------------------------------
// Helper method to insert + extract DmElement handles into keyvalues
//-----------------------------------------------------------------------------
inline void SetElementKeyValue( KeyValues *pKeyValues, const char *pName, CDmElement *pElement )
{
pKeyValues->SetInt( pName, pElement ? pElement->GetHandle() : DMELEMENT_HANDLE_INVALID );
}
template< class T >
T* GetElementKeyValue( KeyValues *pKeyValues, const char *pName )
{
DmElementHandle_t h = (DmElementHandle_t)pKeyValues->GetInt( pName, DMELEMENT_HANDLE_INVALID );
return GetElement<T>( h );
}
inline KeyValues *CreateElementKeyValues( const char *pName, const char *pKey, CDmElement *pElement )
{
return new KeyValues( pName, pKey, pElement ? ( int )pElement->GetHandle() : DMELEMENT_HANDLE_INVALID );
}
inline void AddStandardElementKeys( KeyValues *pKeyValues, CDmElement *pElement )
{
SetElementKeyValue( pKeyValues, "dmeelement", pElement );
if ( pElement )
{
char buf[ 256 ];
UniqueIdToString( pElement->GetId(), buf, sizeof( buf ) );
pKeyValues->SetString( "text", buf );
pKeyValues->SetString( "type", pElement->GetTypeString() );
}
}
inline void SetMatrixKeyValue( KeyValues *pKeyValues, const char *pName, const VMatrix &mat )
{
CUtlBuffer buf;
buf.SetBufferType( true, false );
Serialize( buf, mat );
pKeyValues->SetString( pName, ( char* )buf.Base() );
}
inline void GetMatrixKeyValue( KeyValues *pKeyValues, const char *pName, VMatrix &mat )
{
const char *pMatrixString = pKeyValues->GetString( pName );
CUtlBuffer buf( pMatrixString, V_strlen( pMatrixString ) + 1, CUtlBuffer::TEXT_BUFFER | CUtlBuffer::READ_ONLY );
Unserialize( buf, mat );
}
//-----------------------------------------------------------------------------
// Helper method to insert + extract DmeTime_t into keyvalues
//-----------------------------------------------------------------------------
inline void SetDmeTimeKeyValue( KeyValues *pKeyValues, const char *pName, DmeTime_t t )
{
pKeyValues->SetInt( pName, t.GetTenthsOfMS() );
}
inline DmeTime_t GetDmeTimeKeyValue( KeyValues *pKeyValues, const char *pName, DmeTime_t defaultTime = DMETIME_ZERO )
{
return DmeTime_t( pKeyValues->GetInt( pName, defaultTime.GetTenthsOfMS() ) );
}
inline bool ElementTree_IsArrayItem( KeyValues *itemData )
{
return !itemData->IsEmpty( "arrayIndex" );
}
inline CDmAttribute *ElementTree_GetAttribute( KeyValues *itemData )
{
CDmElement *pOwner = GetElementKeyValue< CDmElement >( itemData, "ownerelement" );
if ( !pOwner )
return NULL;
const char *pAttributeName = itemData->GetString( "attributeName", "" );
return pOwner->GetAttribute( pAttributeName );
}
inline DmAttributeType_t ElementTree_GetAttributeType( KeyValues *itemData )
{
CDmElement *pOwner = GetElementKeyValue< CDmElement >( itemData, "ownerelement" );
if ( !pOwner )
return AT_UNKNOWN;
const char *pAttributeName = itemData->GetString( "attributeName", "" );
CDmAttribute *pAttribute = pOwner->GetAttribute( pAttributeName );
if ( !pAttribute )
return AT_UNKNOWN;
return pAttribute->GetType();
}
inline bool ElementTree_GetDroppableItems( CUtlVector< KeyValues * >& msglist, const char *elementType, CUtlVector< CDmElement * >& list )
{
int c = msglist.Count();
for ( int i = 0; i < c; ++i )
{
KeyValues *data = msglist[ i ];
CDmElement *e = GetElementKeyValue<CDmElement>( data, "dmeelement" );
if ( !e )
{
continue;
}
//if ( !e->IsA( elementType ) )
//{
// continue;
//}
list.AddToTail( e );
}
return list.Count() != 0;
}
inline void ElementTree_RemoveListFromArray( CDmAttribute *pArrayAttribute, CUtlVector< CDmElement * >& list )
{
CDmrElementArray<> array( pArrayAttribute );
int c = array.Count();
for ( int i = c - 1 ; i >= 0 ; --i )
{
CDmElement *element = array[ i ];
if ( list.Find( element ) != list.InvalidIndex() )
{
array.Remove( i );
}
}
}
struct PresetGroupInfo_t
{
PresetGroupInfo_t( CUtlSymbolLarge group = UTL_INVAL_SYMBOL_LARGE ) : presetGroupSym( group ) {}
CUtlSymbolLarge presetGroupSym;
bool bGroupShared;
bool bGroupReadOnly;
bool bGroupVisible;
friend bool operator==( const PresetGroupInfo_t &lhs, const PresetGroupInfo_t &rhs ) { return lhs.presetGroupSym == rhs.presetGroupSym; }
friend bool operator!=( const PresetGroupInfo_t &lhs, const PresetGroupInfo_t &rhs ) { return lhs.presetGroupSym != rhs.presetGroupSym; }
};
inline void CollectPresetGroupInfo( CDmeFilmClip *pFilmClip, CUtlVector< PresetGroupInfo_t > &presetInfo, bool bSkipReadOnly = false, bool bSkipInvisible = false )
{
CAnimSetGroupAnimSetTraversal traversal( pFilmClip );
while ( CDmeAnimationSet *pAnimSet = traversal.Next() )
{
const CDmrElementArray< CDmePresetGroup > presetGroups = pAnimSet->GetPresetGroups();
int nPresetGroups = presetGroups.Count();
for ( int i = 0; i < nPresetGroups; ++i )
{
CDmePresetGroup *pPresetGroup = presetGroups[ i ];
if ( !pPresetGroup )
continue;
if ( bSkipReadOnly && pPresetGroup->m_bIsReadOnly )
continue;
if ( bSkipInvisible && !pPresetGroup->m_bIsVisible )
continue;
PresetGroupInfo_t info( g_pDataModel->GetSymbol( pPresetGroup->GetName() ) );
info.bGroupReadOnly = pPresetGroup->m_bIsReadOnly;
info.bGroupVisible = pPresetGroup->m_bIsVisible;
info.bGroupShared = pPresetGroup->IsShared();
int idx = presetInfo.Find( info );
if ( idx != presetInfo.InvalidIndex() )
continue;
presetInfo.AddToTail( info );
}
}
}
inline void CollectProceduralPresetNames( CUtlVector< CUtlSymbolLarge > &presetNames )
{
static const CUtlSymbolLarge proceduralPresetGroupNameSymbol = g_pDataModel->GetSymbol( PROCEDURAL_PRESET_GROUP_NAME );
int idx = presetNames.AddMultipleToTail( NUM_PROCEDURAL_PRESET_TYPES - 1 );
for ( int i = 1; i < NUM_PROCEDURAL_PRESET_TYPES; ++i, ++idx ) // skip PROCEDURAL_PRESET_NOT
{
presetNames[ idx ] = g_pDataModel->GetSymbol( GetProceduralPresetName( i ) );
}
}
inline void CollectPresetNamesForGroup( CDmeFilmClip *pFilmClip, const char *pPresetGroupName, CUtlVector< CUtlSymbolLarge > &presetNames )
{
CAnimSetGroupAnimSetTraversal traversal( pFilmClip );
while ( CDmeAnimationSet *pAnimSet = traversal.Next() )
{
CDmePresetGroup *pPresetGroup = pAnimSet->FindPresetGroup( pPresetGroupName );
if ( !pPresetGroup )
continue;
CDmrElementArray< CDmePreset > presets = pPresetGroup->GetPresets();
int cp = presets.Count();
for ( int j = 0; j < cp; ++j )
{
CDmePreset *pPreset = presets[ j ];
Assert( pPreset );
if ( !pPreset )
continue;
CUtlSymbolLarge symPresetName = g_pDataModel->GetSymbol( pPreset->GetName() );
if ( presetNames.Find( symPresetName ) != presetNames.InvalidIndex() )
continue;
presetNames.AddToTail( symPresetName );
}
}
}
#endif // DMECONTROLS_UTILS_H
+96
View File
@@ -0,0 +1,96 @@
//========= Copyright © 1996-2001, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef DMEDAGEDITPANEL_H
#define DMEDAGEDITPANEL_H
#ifdef _WIN32
#pragma once
#endif
#include "tier1/utlvector.h"
#include "vgui_controls/editablepanel.h"
#include "datamodel/dmehandle.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CDmeDagRenderPanel;
class CDmeAnimationList;
class CDmeChannelsClip;
class CDmeSourceSkin;
class CDmeSourceAnimation;
class CDmeDCCMakefile;
class CDmeCombinationOperatorPanel;
class CDmeCombinationOperator;
class CDmeAnimationListPanel;
class CBaseAnimationSetEditor;
class CDmeAnimationSet;
class CDmeDag;
namespace vgui
{
class Splitter;
class PropertySheet;
class PropertyPage;
class ScrollableEditablePanel;
}
//-----------------------------------------------------------------------------
// Dag editor panel
//-----------------------------------------------------------------------------
class CDmeDagEditPanel : public vgui::EditablePanel
{
DECLARE_CLASS_SIMPLE( CDmeDagEditPanel, vgui::EditablePanel );
public:
// constructor, destructor
CDmeDagEditPanel( vgui::Panel *pParent, const char *pName );
virtual ~CDmeDagEditPanel();
// Overriden methods of vgui::Panel
virtual void Paint();
// Sets the current scene + animation list
virtual void SetDmeElement( CDmeDag *pScene );
void SetAnimationList( CDmeAnimationList *pAnimationList );
void SetVertexAnimationList( CDmeAnimationList *pAnimationList );
void SetCombinationOperator( CDmeCombinationOperator *pComboOp );
void RefreshCombinationOperator();
CDmeDag *GetDmeElement();
// Other methods which hook into DmePanel
void SetDmeElement( CDmeSourceSkin *pSkin );
void SetDmeElement( CDmeSourceAnimation *pAnimation );
void SetDmeElement( CDmeDCCMakefile *pDCCMakefile );
protected:
// Called when the selection changes moves
MESSAGE_FUNC( OnPageChanged, "PageChanged" );
MESSAGE_FUNC_PARAMS( OnAnimationSelected, "AnimationSelected", kv );
MESSAGE_FUNC_PARAMS( OnAnimationDeselected, "AnimationDeselected", kv );
// Sets up the various panels in the dag editor
void SetMakefileRootElement( CDmElement *pRoot );
vgui::PropertySheet *m_pEditorSheet;
vgui::PropertyPage *m_pAnimationPage;
vgui::PropertyPage *m_pVertexAnimationPage;
vgui::PropertyPage *m_pCombinationPage;
vgui::Splitter *m_pPropertiesSplitter;
CDmeDagRenderPanel *m_pDagRenderPanel;
CDmeAnimationListPanel *m_pAnimationListPanel;
CDmeAnimationListPanel *m_pVertexAnimationListPanel;
CDmeCombinationOperatorPanel *m_pCombinationPanel;
};
#endif // DMEDAGEDITPANEL_H
+160
View File
@@ -0,0 +1,160 @@
//========= Copyright © 1996-2001, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef DMEDAGRENDERPANEL_H
#define DMEDAGRENDERPANEL_H
#ifdef _WIN32
#pragma once
#endif
#include "tier1/utlvector.h"
#include "matsys_controls/PotteryWheelPanel.h"
#include "datamodel/dmehandle.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CDmeDag;
class CDmeModel;
class CDmeAnimationList;
class CDmeChannelsClip;
class CDmeSourceSkin;
class CDmeSourceAnimation;
class CDmeDCCMakefile;
class CDmeDrawSettings;
class vgui::MenuBar;
namespace vgui
{
class IScheme;
}
//-----------------------------------------------------------------------------
// Material Viewer Panel
//-----------------------------------------------------------------------------
class CDmeDagRenderPanel : public CPotteryWheelPanel
{
DECLARE_CLASS_SIMPLE( CDmeDagRenderPanel, CPotteryWheelPanel );
public:
// constructor, destructor
CDmeDagRenderPanel( vgui::Panel *pParent, const char *pName );
virtual ~CDmeDagRenderPanel();
// Overriden methods of vgui::Panel
virtual void PerformLayout();
virtual void Paint();
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
// Sets the current scene + animation list
void SetDmeElement( CDmeDag *pScene );
void SetAnimationList( CDmeAnimationList *pAnimationList );
void SetVertexAnimationList( CDmeAnimationList *pAnimationList );
void DrawJoints( bool bDrawJoint );
void DrawJointNames( bool bDrawJointNames );
void DrawGrid( bool bDrawGrid );
void DrawAxis( bool bDrawAxis );
void ModelInEngineCoordinates( bool bModelInEngineCoordinates );
void ModelZUp( bool bModelZUp );
CDmeDag *GetDmeElement();
// Other methods which hook into DmePanel
void SetDmeElement( CDmeSourceSkin *pSkin );
void SetDmeElement( CDmeSourceAnimation *pAnimation );
void SetDmeElement( CDmeDCCMakefile *pDCCMakefile );
// Select animation by name
void SelectAnimation( const char *pAnimName );
void SelectVertexAnimation( const char *pAnimName );
private:
// Select animation by index
void SelectAnimation( int nIndex );
void SelectVertexAnimation( int nIndex );
// paint it!
void OnPaint3D();
void OnMouseDoublePressed( vgui::MouseCode code );
virtual void OnKeyCodePressed( vgui::KeyCode code );
MESSAGE_FUNC( OnSmoothShade, "SmoothShade" );
MESSAGE_FUNC( OnFlatShade, "FlatShade" );
MESSAGE_FUNC( OnWireframe, "Wireframe" );
MESSAGE_FUNC( OnBoundingBox, "BoundingBox" );
MESSAGE_FUNC( OnNormals, "Normals" );
MESSAGE_FUNC( OnWireframeOnShaded, "WireframeOnShaded" );
MESSAGE_FUNC( OnBackfaceCulling, "BackfaceCulling" );
MESSAGE_FUNC( OnXRay, "XRay" );
MESSAGE_FUNC( OnGrayShade, "GrayShade" );
MESSAGE_FUNC( OnFrame, "Frame" );
// Draw joint names
void DrawJointNames( CDmeDag *pRoot, CDmeDag *pDag, const matrix3x4_t& parentToWorld );
// Draw highlighted vertices
void DrawHighlightPoints();
// Draw the coordinate axis
void DrawAxis();
// Rebuilds the list of operators
void RebuildOperatorList();
// Update Menu Status
void UpdateMenu();
CTextureReference m_DefaultEnvCubemap;
CTextureReference m_DefaultHDREnvCubemap;
vgui::HFont m_hFont;
CMaterialReference m_axisMaterial;
bool m_bDrawJointNames : 1;
bool m_bDrawJoints : 1;
bool m_bDrawGrid : 1;
bool m_bDrawAxis : 1;
// NOTE: m_bModelInEngineCoordinates overrides m_bZUp
bool m_bModelInEngineCoordinates : 1; // Is the model already in engine coordinates
// Note: m_bZUp implies the data is in Z Up coordinates with -Y as the forward axis
bool m_bModelZUp : 1; // Is the model Z Up?
// NOTE: If neither m_bModelInEngineCoordinates nor m_bModelZUp is true then
// the model is in Y Up coordinates with Z as the forward axis
CDmeHandle< CDmeAnimationList > m_hAnimationList;
CDmeHandle< CDmeAnimationList > m_hVertexAnimationList;
CDmeHandle< CDmeChannelsClip > m_hCurrentAnimation;
CDmeHandle< CDmeChannelsClip > m_hCurrentVertexAnimation;
CUtlVector< IDmeOperator* > m_operators;
float m_flStartTime;
CDmeHandle< CDmeDag > m_hDag;
CDmeDrawSettings *m_pDrawSettings;
CDmeHandle< CDmeDrawSettings, HT_STRONG > m_hDrawSettings;
vgui::MenuBar *m_pMenuBar;
// Menu item numbers
vgui::Menu *m_pShadingMenu;
int m_nMenuSmoothShade;
int m_nMenuFlatShade;
int m_nMenuWireframe;
int m_nMenuBoundingBox;
int m_nMenuNormals;
int m_nMenuWireframeOnShaded;
int m_nMenuBackfaceCulling;
int m_nMenuXRay;
int m_nMenuGrayShade;
};
#endif // DMEDAGRENDERPANEL_H
+169
View File
@@ -0,0 +1,169 @@
//====== Copyright © 1996-2003, Valve Corporation, All rights reserved. =======
//
// Purpose:
//
//=============================================================================
#ifndef DMELOGEDITPANEL_H
#define DMELOGEDITPANEL_H
#ifdef _WIN32
#pragma once
#endif
#include "vgui_controls/frame.h"
#include "matsys_controls/curveeditorpanel.h"
#include "datamodel/dmehandle.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CDmeLog;
namespace vgui
{
class ComboBox;
}
//-----------------------------------------------------------------------------
//
// Curve editor for float DmeLogs
//
//-----------------------------------------------------------------------------
class CDmeLogEditPanel : public CCurveEditorPanel
{
DECLARE_CLASS_SIMPLE( CDmeLogEditPanel, CCurveEditorPanel );
public:
enum LogField_t
{
FIELD_X = 0x1,
FIELD_Y = 0x2,
FIELD_Z = 0x4,
FIELD_W = 0x8,
FIELD_R = 0x1,
FIELD_G = 0x2,
FIELD_B = 0x4,
FIELD_A = 0x8,
FIELD_ALL = 0xF,
};
// constructor
CDmeLogEditPanel( vgui::Panel *pParent, const char *pName );
~CDmeLogEditPanel();
// Sets the log to edit
void SetDmeLog( CDmeLog *pLog );
void SetMask( int nMask );
// Sets the time range on the view in ms
void SetTimeRange( DmeTime_t startTime, DmeTime_t endTime );
// Sets the vertical range on the view
void SetVerticalRange( float flMin, float flMax );
protected:
// Control points + values...
virtual int FindOrAddControlPoint( float flIn, float flTolerance, float flOut );
virtual int FindControlPoint( float flIn, float flTolerance );
virtual int ModifyControlPoint( int nPoint, float flIn, float flOut );
virtual void RemoveControlPoint( int nPoint );
virtual float GetValue( float flIn );
virtual int ControlPointCount();
virtual void GetControlPoint( int nPoint, float *pIn, float *pOut );
private:
// Converts normalized values to int time
DmeTime_t NormalizedToTime( float flIn );
DmeTime_t NormalizedToDuration( float flDuration );
float TimeToNormalized( DmeTime_t time );
float NormalizedToValue( float flValue );
float ValueToNormalized( float flNormalized );
template< class T > int FindOrAddKey( DmeTime_t time, DmeTime_t tolerance, int nComps, float flValue );
template< class T > int ModifyKey( int nPoint, DmeTime_t initialTime, DmeTime_t time, int nComps, float flValue );
CDmeHandle<CDmeLog> m_hLog;
int m_LogFieldMask;
int m_nFieldIndex;
DmeTime_t m_minTime;
DmeTime_t m_maxTime;
float m_flMinVertical;
float m_flMaxVertical;
};
//-----------------------------------------------------------------------------
// Finds or adds a key
//-----------------------------------------------------------------------------
template< class T >
int CDmeLogEditPanel::FindOrAddKey( DmeTime_t time, DmeTime_t tolerance, int nComps, float flValue )
{
T vec = CastElement< CDmeTypedLog<T> >( m_hLog )->GetValue( time );
for ( int i = 0; i < nComps; ++i )
{
if ( m_LogFieldMask & (1 << i) )
{
vec[i] = flValue;
}
}
return CastElement< CDmeTypedLog<T> >( m_hLog )->FindOrAddKey( time, tolerance, vec );
}
//-----------------------------------------------------------------------------
// Modifies an existing key
//-----------------------------------------------------------------------------
template< class T >
int CDmeLogEditPanel::ModifyKey( int nPoint, DmeTime_t initialTime, DmeTime_t time, int nComps, float flValue )
{
T vec = CastElement< CDmeTypedLog<T> >( m_hLog )->GetValue( initialTime );
for ( int i = 0; i < nComps; ++i )
{
if ( m_LogFieldMask & (1 << i) )
{
vec[i] = flValue;
}
}
RemoveControlPoint( nPoint );
return CastElement< CDmeTypedLog<T> >( m_hLog )->FindOrAddKey( time, DmeTime_t( 0 ), vec );
}
//-----------------------------------------------------------------------------
// Purpose: Main app window
//-----------------------------------------------------------------------------
class CDmeLogEditFrame : public vgui::Frame
{
DECLARE_CLASS_SIMPLE( CDmeLogEditFrame, vgui::Frame );
public:
CDmeLogEditFrame( vgui::Panel *pParent, const char *pTitle );
~CDmeLogEditFrame();
// Inherited from Frame
virtual void OnCommand( const char *pCommand );
// Purpose: Activate the dialog
// the message "LogEdited" will be sent if ok was hit
// Pass in a message to add as a subkey to the DmeSelected message
void DoModal( CDmeLog *pLog, DmeTime_t startTime, DmeTime_t endTime, KeyValues *pContextKeyValues = NULL );
private:
MESSAGE_FUNC( OnTextChanged, "TextChanged" );
void CleanUpMessage();
CDmeLogEditPanel *m_pCurveEditor;
vgui::Button *m_pOkButton;
vgui::Button *m_pCancelButton;
vgui::ComboBox *m_pFilter;
KeyValues *m_pContextKeyValues;
};
#endif // DMELOGEDITPANEL_H
+38
View File
@@ -0,0 +1,38 @@
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======
//
// Purpose:
//
//=============================================================================
#ifndef DMEMDLPANEL_H
#define DMEMDLPANEL_H
#ifdef _WIN32
#pragma once
#endif
#include "matsys_controls/mdlpanel.h"
class CDmeMDLMakefile;
//-----------------------------------------------------------------------------
// MDL Viewer Panel (hooked into DMEPanel)
//-----------------------------------------------------------------------------
class CDmeMDLPanel : public CMDLPanel
{
DECLARE_CLASS_SIMPLE( CDmeMDLPanel, CMDLPanel );
public:
// constructor, destructor
CDmeMDLPanel( vgui::Panel *pParent, const char *pName );
virtual ~CDmeMDLPanel();
// DMEPanel..
void SetDmeElement( CDmeMDLMakefile *pMDLMakefile );
};
#endif // DMEMDLPANEL_H
+280
View File
@@ -0,0 +1,280 @@
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======
//
// Purpose:
//
//=============================================================================
#ifndef DMEPANEL_H
#define DMEPANEL_H
#ifdef _WIN32
#pragma once
#endif
#include "tier0/basetypes.h"
#include "tier1/utlstringmap.h"
#include "vgui_controls/editablepanel.h"
#include "datamodel/dmelement.h"
#include "datamodel/dmehandle.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CDmElement;
class CBaseDmePanelFactory;
namespace vgui
{
class Panel;
class EditablePanel;
class ComboBox;
class IScheme;
}
//-----------------------------------------------------------------------------
// Dme Panel factory iteration handle
//-----------------------------------------------------------------------------
DECLARE_POINTER_HANDLE( DmeFactoryHandle_t );
#define DMEFACTORY_HANDLE_INVALID ((DmeFactoryHandle_t)0)
//-----------------------------------------------------------------------------
// Dme Panel: used for editing arbitrary dme elements
//-----------------------------------------------------------------------------
class CDmePanel : public vgui::EditablePanel
{
DECLARE_CLASS_SIMPLE( CDmePanel, vgui::EditablePanel );
public:
// constructor, destructor
CDmePanel( vgui::Panel *pParent, const char *pPanelName, bool bComboBoxVisible = true );
virtual ~CDmePanel();
virtual void PerformLayout();
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
void SetDmeElement( CDmElement *pDmeElement, bool bForce = false, const char *pPanelName = NULL );
// Switch to a new editor
void SetEditor( const char *pEditorName );
// Drag/drop
bool IsDroppable( CUtlVector< KeyValues * >& msglist );
void OnPanelDropped( CUtlVector< KeyValues * >& msglist );
// Refreshes the current panel owing to external change
// Values only means no topological change
void Refresh( bool bValuesOnly );
// Sets the default editor type
void SetDefaultEditorType( const char *pEditorType );
private:
struct EditorPanelMap_t
{
vgui::EditablePanel *m_pEditorPanel;
CBaseDmePanelFactory *m_pFactory;
};
MESSAGE_FUNC( OnTextChanged, "TextChanged" );
MESSAGE_FUNC( OnDmeElementChanged, "DmeElementChanged" );
MESSAGE_FUNC_PARAMS( OnViewedElementChanged, "NotifyViewedElementChanged", kv );
// Copy/paste support
MESSAGE_FUNC( OnCut, "OnCut" );
MESSAGE_FUNC( OnCopy, "OnCopy" );
MESSAGE_FUNC( OnPaste, "OnPaste" );
MESSAGE_FUNC( OnPasteReference, "OnPasteReference" );
MESSAGE_FUNC( OnPasteInsert, "OnPasteInsert" );
MESSAGE_FUNC( OnEditDelete, "OnEditDelete" );
// Context menu support
MESSAGE_FUNC_PARAMS( OnOpenContextMenu, "OpenContextMenu", params );
// Delete cached panels
void DeleteCachedPanels();
// Populate editor name combo box
void PopulateEditorNames( const char *pPanelName = NULL );
// Deactivates the current editor
void DeactivateCurrentEditor();
// Post message to the dme panel
void PostMessageToDmePanel( const char *pMessage );
static bool CreateDmePanel( vgui::Panel *pParent, const char *pPanelName, CDmElement *pElement, const char *pEditorName, EditorPanelMap_t *pMap );
vgui::ComboBox *m_pEditorNames;
CDmeHandle< CDmElement > m_hElement;
CUtlStringMap< CUtlString > m_LastUsedEditorType;
CUtlStringMap< CUtlVector< EditorPanelMap_t > > m_EditorPanelCache;
vgui::EditablePanel *m_pDmeEditorPanel;
CUtlString m_CurrentEditorName;
CUtlString m_DefaultEditorType;
};
//-----------------------------------------------------------------------------
// Dme Panel factory methods
//-----------------------------------------------------------------------------
class CBaseDmePanelFactory
{
public:
virtual vgui::EditablePanel *CreateDmePanel( vgui::Panel *pParent, const char *pPanelName, CDmElement *pElement ) = 0;
virtual void SetDmeElement( vgui::EditablePanel *pPanel, CDmElement *pElement ) = 0;
protected:
// Constructor, protected because these should never be instanced directly
CBaseDmePanelFactory( const char *pElementType, const char *pEditorName, const char *pEditorDisplayName, bool bIsDefault, bool bIsOverride );
public:
const char *m_pElementType;
const char *m_pEditorName;
const char *m_pEditorDisplayName;
bool m_bIsDefault : 1;
bool m_bIsOverride : 1;
CBaseDmePanelFactory *m_pNext;
static CBaseDmePanelFactory* s_pFirstDmePanelFactory;
};
template< class PanelType, class ElementType >
class CDmePanelFactory : public CBaseDmePanelFactory
{
typedef CBaseDmePanelFactory BaseClass;
public:
// Constructor
CDmePanelFactory( const char *pElementType, const char *pEditorName, const char *pEditorDisplayName, bool bIsDefault, bool bIsOverride ) :
BaseClass( pElementType, pEditorName, pEditorDisplayName, bIsDefault, bIsOverride )
{
}
virtual vgui::EditablePanel *CreateDmePanel( vgui::Panel *pParent, const char *pPanelName, CDmElement *pElement )
{
ElementType *pTypedElement = CastElement<ElementType>( pElement );
Assert( pTypedElement && pElement->IsA( m_pElementType ) );
// NOTE: The panel factory assumes T contains the following method:
// void SetDmeElement( ElementType *pElement );
// You'll get compile errors about 'SetDmeElement' not being defined if not
PanelType *pPanel = new PanelType( pParent, pPanelName );
pPanel->SetDmeElement( pTypedElement );
return pPanel;
}
virtual void SetDmeElement( vgui::EditablePanel *pPanel, CDmElement *pElement )
{
PanelType *pTypedPanel = static_cast< PanelType* >( pPanel );
ElementType *pTypedElement = static_cast< ElementType* >( pElement );
pTypedPanel->SetDmeElement( pTypedElement );
}
};
template< class PanelType, class ElementType, class DisplayType >
class CDmePanelConverterFactory : public CBaseDmePanelFactory
{
typedef CBaseDmePanelFactory BaseClass;
public:
// Constructor
CDmePanelConverterFactory( const char *pElementType, const char *pDisplayType, const char *pEditorName, const char *pEditorDisplayName, bool bIsDefault, bool bIsOverride ) :
BaseClass( pElementType, pEditorName, pEditorDisplayName, bIsDefault, bIsOverride )
{
m_pDisplayType = pDisplayType;
}
virtual vgui::EditablePanel *CreateDmePanel( vgui::Panel *pParent, const char *pPanelName, CDmElement *pElement )
{
ElementType *pTypedElement = CastElement<ElementType>( pElement );
Assert( pTypedElement && pElement->IsA( m_pElementType ) );
// NOTE: To use the converter factory, the element must implement a method
// CDmElement *GetDmePanelElement( const char *pDisplayType );
DisplayType *pDisplayElement = CastElement<DisplayType>( pTypedElement->GetDmePanelElement( m_pDisplayType ) );
// NOTE: The panel factory assumes T contains the following method:
// void SetDmeElement( ElementType *pElement );
// You'll get compile errors about 'SetDmeElement' not being defined if not
PanelType *pPanel = new PanelType( pParent, pPanelName );
pPanel->SetDmeElement( pDisplayElement );
return pPanel;
}
virtual void SetDmeElement( vgui::EditablePanel *pPanel, CDmElement *pElement )
{
PanelType *pTypedPanel = static_cast< PanelType* >( pPanel );
ElementType *pTypedElement = static_cast< ElementType* >( pElement );
DisplayType *pDisplayElement = CastElement<DisplayType>( pTypedElement->GetDmePanelElement( m_pDisplayType ) );
pTypedPanel->SetDmeElement( pDisplayElement );
}
private:
const char *m_pDisplayType;
};
//-----------------------------------------------------------------------------
// Helper macro to create the panel factory
// IMPLEMENT_DMEPANEL_FACTORY_OVERRIDE is used by applications to override
// DmePanels implemented in libraries
//-----------------------------------------------------------------------------
#define IMPLEMENT_DMEPANEL_FACTORY( _panelClassName, _dmeLookupName, _editorName, _editorDisplayName, _isDefault ) \
CDmePanelFactory< _panelClassName, C##_dmeLookupName > g_##_panelClassName##_##_dmeLookupName##_Factory( #_dmeLookupName, _editorName, _editorDisplayName, _isDefault, false ); \
_panelClassName *g_##_panelClassName##_##_dmeLookupName##LinkerHack = NULL;
#define IMPLEMENT_DMEPANEL_FACTORY_OVERRIDE( _panelClassName, _dmeLookupName, _editorName, _editorDisplayName, _isDefault ) \
CDmePanelFactory< _panelClassName, C##_dmeLookupName > g_##_panelClassName##_##_dmeLookupName##_Factory( #_dmeLookupName, _editorName, _editorDisplayName, _isDefault, true ); \
_panelClassName *g_##_panelClassName##_##_dmeLookupName##LinkerHack = NULL;
#define USING_DMEPANEL_FACTORY( _panelClassName, _dmeLookupName )\
class _panelClassName; \
extern _panelClassName *g_##_panelClassName##_##_dmeLookupName##LinkerHack; \
_panelClassName *g_##_panelClassName##_##_dmeLookupName##PullInModule = g_##_panelClassName##_##_dmeLookupName##LinkerHack;
//-----------------------------------------------------------------------------
// Helper macro to create the converter panel factory
// IMPLEMENT_DMEPANEL_CONVERSION_FACTORY_OVERRIDE is used by applications to override
// DmePanels implemented in libraries
//-----------------------------------------------------------------------------
#define IMPLEMENT_DMEPANEL_CONVERSION_FACTORY( _panelClassName, _dmeLookupName, _dmeDisplayName, _editorName, _editorDisplayName, _isDefault ) \
CDmePanelConverterFactory< _panelClassName, C##_dmeLookupName, C##_dmeDisplayName > g_##_panelClassName##_##_dmeLookupName##_Factory( #_dmeLookupName, #_dmeDisplayName, _editorName, _editorDisplayName, _isDefault, false ); \
_panelClassName *g_##_panelClassName##_##_dmeLookupName##LinkerHack = NULL;
#define IMPLEMENT_DMEPANEL_CONVERSION_FACTORY_OVERRIDE( _panelClassName, _dmeLookupName, _dmeDisplayName, _editorName, _editorDisplayName, _isDefault ) \
CDmePanelConverterFactory< _panelClassName, C##_dmeLookupName, C##_dmeDisplayName > g_##_panelClassName##_##_dmeLookupName##_Factory( #_dmeLookupName, #_dmeDisplayName, _editorName, _editorDisplayName, _isDefault, true ); \
_panelClassName *g_##_panelClassName##_##_dmeLookupName##LinkerHack = NULL;
#define USING_DMEPANEL_CONVERSION_FACTORY( _panelClassName, _dmeLookupName ) \
class _panelClassName; \
extern _panelClassName *g_##_panelClassName##_##_dmeLookupName##LinkerHack; \
_panelClassName *g_##_panelClassName##_##_dmeLookupName##PullInModule = g_##_panelClassName##_##_dmeLookupName##LinkerHack;
//-----------------------------------------------------------------------------
// Get Dme Factories for a particular element type
//-----------------------------------------------------------------------------
DmeFactoryHandle_t DmePanelFirstFactory( CDmElement *pElement = NULL );
DmeFactoryHandle_t DmePanelNextFactory( DmeFactoryHandle_t h, CDmElement *pElement = NULL );
const char *DmePanelFactoryName( DmeFactoryHandle_t h );
const char *DmePanelFactoryDisplayName( DmeFactoryHandle_t h );
const char *DmePanelFactoryElementType( DmeFactoryHandle_t h );
bool DmePanelFactoryIsDefault( DmeFactoryHandle_t h );
//-----------------------------------------------------------------------------
// Dme Panel factory methods
//-----------------------------------------------------------------------------
vgui::EditablePanel *CreateDmePanel( vgui::Panel *pParent, const char *pPanelName, CDmElement *pElement, const char *pEditorName = NULL );
#endif // DMEPANEL_H
+101
View File
@@ -0,0 +1,101 @@
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======
//
// Purpose:
//
//=============================================================================
#ifndef DMEPICKER_H
#define DMEPICKER_H
#ifdef _WIN32
#pragma once
#endif
#include "vgui_controls/EditablePanel.h"
#include "vgui_controls/Frame.h"
#include "datamodel/dmehandle.h"
#include "tier1/utlstring.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
namespace vgui
{
class Panel;
class TextEntry;
}
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
struct DmePickerInfo_t
{
DmElementHandle_t m_hElement;
const char *m_pChoiceString;
};
//-----------------------------------------------------------------------------
// Purpose: Main app window
//-----------------------------------------------------------------------------
class CDmePicker : public vgui::EditablePanel
{
DECLARE_CLASS_SIMPLE( CDmePicker, vgui::EditablePanel );
public:
CDmePicker( vgui::Panel *pParent );
~CDmePicker();
// overridden frame functions
virtual void Activate( const CUtlVector< DmePickerInfo_t >& vec );
// Forward arrow keys to the list
virtual void OnKeyCodeTyped( vgui::KeyCode code );
// Returns the selceted DmElement
CDmElement *GetSelectedDme( );
private:
void RefreshDmeList();
MESSAGE_FUNC( OnTextChanged, "TextChanged" );
vgui::TextEntry *m_pFilterList;
vgui::ListPanel *m_pDmeBrowser;
CUtlString m_Filter;
friend class CDmePickerFrame;
};
//-----------------------------------------------------------------------------
// Purpose: Main app window
//-----------------------------------------------------------------------------
class CDmePickerFrame : public vgui::Frame
{
DECLARE_CLASS_SIMPLE( CDmePickerFrame, vgui::Frame );
public:
CDmePickerFrame( vgui::Panel *pParent, const char *pTitle );
~CDmePickerFrame();
// Inherited from Frame
virtual void OnCommand( const char *pCommand );
// Purpose: Activate the dialog
// the message "DmeSelected" will be sent if one was picked
// Pass in a message to add as a subkey to the DmeSelected message
void DoModal( const CUtlVector< DmePickerInfo_t >& vec, KeyValues *pContextKeyValues = NULL );
private:
void CleanUpMessage();
CDmePicker *m_pPicker;
vgui::Button *m_pOpenButton;
vgui::Button *m_pCancelButton;
KeyValues *m_pContextKeyValues;
};
#endif // DMEPICKER_H
@@ -0,0 +1,172 @@
//========= Copyright © 1996-2001, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef PRESETGROUPEDITORPANEL_H
#define PRESETGROUPEDITORPANEL_H
#ifdef _WIN32
#pragma once
#endif
#include "tier1/utlvector.h"
#include "vgui_controls/Frame.h"
#include "datamodel/dmehandle.h"
#include "vgui_controls/fileopenstatemachine.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CDmeFilmClip;
class CDmePresetListPanel;
class CDmePresetGroupListPanel;
class CDmePresetGroup;
class CDmePreset;
namespace vgui
{
class PropertySheet;
class PropertyPage;
class Button;
}
//-----------------------------------------------------------------------------
// Dag editor panel
//-----------------------------------------------------------------------------
class CDmePresetGroupEditorPanel : public vgui::EditablePanel, public vgui::IFileOpenStateMachineClient
{
DECLARE_CLASS_SIMPLE( CDmePresetGroupEditorPanel, vgui::EditablePanel );
public:
// constructor, destructor
CDmePresetGroupEditorPanel( vgui::Panel *pParent, const char *pName );
virtual ~CDmePresetGroupEditorPanel();
void SetAnimationSetClip( CDmeFilmClip *pFilmClip );
CDmeFilmClip *GetAnimationSetClip();
void RefreshAnimationSet();
void NotifyDataChanged();
// Returns selected presets/groups
const char* GetSelectedPresetGroupName();
const char* GetSelectedPresetName();
// Drag/drop reordering of preset groups
void MovePresetGroupInFrontOf( const char *pDragGroupName, const char *pDropGroupName );
// Drag/drop reordering of presets
void MovePresetInFrontOf( const char *pDragPresetName, const char *pDropPresetName );
// Drag/drop preset moving
void MovePresetIntoGroup( const char *pPresetName, const char *pSrcGroupName, const char *pDstGroupName );
// Toggle group visibility
void ToggleGroupVisibility( const char *pPresetGroupName );
MESSAGE_FUNC( OnMovePresetUp, "MovePresetUp" );
MESSAGE_FUNC( OnMovePresetDown, "MovePresetDown" );
MESSAGE_FUNC( OnMoveGroupUp, "MoveGroupUp" );
MESSAGE_FUNC( OnMoveGroupDown, "MoveGroupDown" );
MESSAGE_FUNC( OnRemoveGroup, "RemoveGroup" );
MESSAGE_FUNC( OnRemovePreset, "RemovePreset" );
// Inherited from IFileOpenStateMachineClient
virtual void SetupFileOpenDialog( vgui::FileOpenDialog *pDialog, bool bOpenFile, const char *pFileFormat, KeyValues *pContextKeyValues );
virtual bool OnReadFileFromDisk( const char *pFileName, const char *pFileFormat, KeyValues *pContextKeyValues );
virtual bool OnWriteFileToDisk( const char *pFileName, const char *pFileFormat, KeyValues *pContextKeyValues );
private:
MESSAGE_FUNC_PARAMS( OnOpenContextMenu, "OpenContextMenu", kv );
MESSAGE_FUNC_PARAMS( OnInputCompleted, "InputCompleted", kv );
MESSAGE_FUNC( OnAddGroup, "AddGroup" );
MESSAGE_FUNC( OnAddPhonemeGroup, "AddPhonemeGroup" );
MESSAGE_FUNC( OnRenameGroup, "RenameGroup" );
MESSAGE_FUNC( OnRemoveDefaultControls, "RemoveDefaultControls" );
MESSAGE_FUNC( OnRenamePreset, "RenamePreset" );
MESSAGE_FUNC( OnToggleGroupVisibility, "ToggleGroupVisibility" );
MESSAGE_FUNC( OnToggleGroupSharing, "ToggleGroupSharing" );
MESSAGE_FUNC_PARAMS( OnItemSelected, "ItemSelected", kv );
MESSAGE_FUNC_PARAMS( OnItemDeselected, "ItemDeselected", kv );
MESSAGE_FUNC( OnImportPresets, "ImportPresets" );
MESSAGE_FUNC( OnExportPresets, "ExportPresets" );
MESSAGE_FUNC( OnImportPresetGroups, "ImportPresetGroups" );
MESSAGE_FUNC( OnExportPresetGroups, "ExportPresetGroups" );
MESSAGE_FUNC( OnExportPresetGroupToVFE, "ExportPresetGroupsToVFE" );
MESSAGE_FUNC( OnExportPresetGroupToTXT, "ExportPresetGroupsToTXT" );
MESSAGE_FUNC_PARAMS( OnPresetPicked, "PresetPicked", params );
MESSAGE_FUNC_PARAMS( OnPresetPickCancelled, "PresetPickCancelled", params );
MESSAGE_FUNC_PARAMS( OnFileStateMachineFinished, "FileStateMachineFinished", params );
// Cleans up the context menu
void CleanupContextMenu();
// If it finds a duplicate group/preset name, reports an error message and returns it found one
bool HasDuplicatePresetName( const char *pPresetName, const char *pIgnorePresetName = NULL );
bool HasDuplicateGroupName ( const char *pGroupName, const char *pIgnorePresetGroupName = NULL );
// Refreshes the list of presets
void RefreshPresetNames( );
// Called by OnInputCompleted after we get a new group or preset name
void PerformAddGroup( const char *pNewGroupName );
void PerformAddPhonemeGroup( const char *pNewGroupName );
void PerformRenameGroup( const char *pNewGroupName );
void PerformRenamePreset( const char *pNewPresetName );
// Called to open a context-sensitive menu for a particular preset
void OnOpenPresetContextMenu( );
// Gets/sets a selected preset
void SetSelectedPreset( const char* pPresetName );
// Selects a particular preset group
void SetSelectedPresetGroup( const char* pPresetGroupName );
// Imports presets
void ImportPresets( CUtlVector< const char * >& presetNames, CDmElement *pRoot );
CDmeHandle< CDmeFilmClip > m_hFilmClip;
vgui::Splitter *m_pSplitter;
CDmePresetGroupListPanel *m_pPresetGroupList;
CDmePresetListPanel *m_pPresetList;
vgui::DHANDLE< vgui::Menu > m_hContextMenu;
vgui::DHANDLE< vgui::FileOpenStateMachine > m_hFileOpenStateMachine;
};
//-----------------------------------------------------------------------------
// Frame for combination system
//-----------------------------------------------------------------------------
class CDmePresetGroupEditorFrame : public vgui::Frame, public IDmNotify
{
DECLARE_CLASS_SIMPLE( CDmePresetGroupEditorFrame, vgui::Frame );
public:
CDmePresetGroupEditorFrame( vgui::Panel *pParent, const char *pTitle );
~CDmePresetGroupEditorFrame();
// Inherited from IDmNotify
virtual void NotifyDataChanged( const char *pReason, int nNotifySource, int nNotifyFlags );
void SetAnimationSetClip( CDmeFilmClip *pClip ) { m_pEditor->SetAnimationSetClip( pClip ); }
void RefreshAnimationSet() { m_pEditor->RefreshAnimationSet(); }
private:
MESSAGE_FUNC( OnPresetsChanged, "PresetsChanged" );
KEYBINDING_FUNC( undo, KEY_Z, vgui::MODIFIER_CONTROL, OnUndo, "#undo_help", 0 );
KEYBINDING_FUNC( redo, KEY_Z, vgui::MODIFIER_CONTROL | vgui::MODIFIER_SHIFT, OnRedo, "#redo_help", 0 );
// Inherited from Frame
virtual void OnCommand( const char *pCommand );
CDmePresetGroupEditorPanel *m_pEditor;
vgui::Button *m_pOkButton;
};
#endif // PRESETGROUPEDITORPANEL_H
+32
View File
@@ -0,0 +1,32 @@
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======
//
// Purpose:
//
//=============================================================================
#ifndef FILTERCOMBOBOX_H
#define FILTERCOMBOBOX_H
#ifdef _WIN32
#pragma once
#endif
#include "vgui_controls/combobox.h"
//-----------------------------------------------------------------------------
// Combo box that adds entry to its history when focus is lost
//-----------------------------------------------------------------------------
class CFilterComboBox : public vgui::ComboBox
{
DECLARE_CLASS_SIMPLE( CFilterComboBox, vgui::ComboBox );
public:
CFilterComboBox( Panel *parent, const char *panelName, int numLines, bool allowEdit );
virtual void OnKillFocus();
};
#endif // FILTERCOMBOBOX_H
+134
View File
@@ -0,0 +1,134 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef INOTIFYUI_H
#define INOTIFYUI_H
#ifdef _WIN32
#pragma once
#endif
#include "tier1/utlvector.h"
#include "datamodel/idatamodel.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CDmElement;
//-----------------------------------------------------------------------------
// Interface used to allow tools to deal with dynamic choice lists
//-----------------------------------------------------------------------------
struct IntChoice_t
{
int m_nValue;
const char *m_pChoiceString;
};
struct StringChoice_t
{
const char *m_pValue;
const char *m_pChoiceString;
};
struct ElementChoice_t
{
ElementChoice_t() {}
ElementChoice_t( CDmElement *pValue, const char *pChoiceString = NULL ) : m_pValue( pValue ), m_pChoiceString( pChoiceString ) {}
CDmElement *m_pValue;
const char *m_pChoiceString;
};
typedef CUtlVector<IntChoice_t> IntChoiceList_t;
typedef CUtlVector<StringChoice_t> StringChoiceList_t;
typedef CUtlVector<ElementChoice_t> ElementChoiceList_t;
//-----------------------------------------------------------------------------
// Interface used to call back out of the element properties panels
// to communicate with external systems
//-----------------------------------------------------------------------------
enum DmeControlsNotifySource_t
{
NOTIFY_SOURCE_PROPERTIES_TREE = NOTIFY_SOURCE_FIRST_DME_CONTROL_SOURCE,
NOTIFY_SOURCE_FILE_LIST_MANAGER,
NOTIFY_SOURCE_PRESET_GROUP_EDITOR,
};
//-----------------------------------------------------------------------------
// Utility scope guards
//-----------------------------------------------------------------------------
DEFINE_SOURCE_UNDO_SCOPE_GUARD( ElementTree, NOTIFY_SOURCE_PROPERTIES_TREE );
DEFINE_SOURCE_NOTIFY_SCOPE_GUARD( ElementTree, NOTIFY_SOURCE_PROPERTIES_TREE );
class IElementPropertiesChoices
{
public:
// For boolean choice lists. Return false if it's an unknown choice list type
// Element, attribute specifies the attribute we're editing.
// bArray element is true if the attribute is an array attribute and we're editing one of its elements
virtual bool GetBoolChoiceList( const char *pChoiceListType, CDmElement *pElement,
const char *pAttributeName, bool bArrayElement, const char *pChoiceStrings[2] ) = 0;
// For integer choice lists. Return false if it's an unknown choice list type
virtual bool GetIntChoiceList( const char *pChoiceListType, CDmElement *pElement,
const char *pAttributeName, bool bArrayElement, IntChoiceList_t &list ) = 0;
// For string choice lists. Return false if it's an unknown choice list type
virtual bool GetStringChoiceList( const char *pChoiceListType, CDmElement *pElement,
const char *pAttributeName, bool bArrayElement, StringChoiceList_t &list ) = 0;
// For element choice lists. Return false if it's an unknown choice list type
virtual bool GetElementChoiceList( const char *pChoiceListType, CDmElement *pElement,
const char *pAttributeName, bool bArrayElement, ElementChoiceList_t &list ) = 0;
virtual const char *GetElementChoiceString( const char *pChoiceListType, CDmElement *pElement,
const char *pAttributeName, bool bArrayElement, CDmElement *pValue ) = 0;
};
//-----------------------------------------------------------------------------
// Default implementation of IElementPropertiesChoices
//-----------------------------------------------------------------------------
class CBaseElementPropertiesChoices : public IElementPropertiesChoices
{
public:
virtual bool GetBoolChoiceList( const char *pChoiceListType, CDmElement *pElement,
const char *pAttributeName, bool bArrayElement, const char *pChoiceStrings[2] )
{
return false;
}
virtual bool GetIntChoiceList( const char *pChoiceListType, CDmElement *pElement,
const char *pAttributeName, bool bArrayElement, IntChoiceList_t &list )
{
return false;
}
virtual bool GetStringChoiceList( const char *pChoiceListType, CDmElement *pElement,
const char *pAttributeName, bool bArrayElement, StringChoiceList_t &list )
{
return false;
}
virtual bool GetElementChoiceList( const char *pChoiceListType, CDmElement *pElement,
const char *pAttributeName, bool bArrayElement, ElementChoiceList_t &list )
{
return false;
}
virtual const char *GetElementChoiceString( const char *pChoiceListType, CDmElement *pElement,
const char *pAttributeName, bool bArrayElement, CDmElement *pValue )
{
return NULL;
}
};
#endif // INOTIFYUI_H
+219
View File
@@ -0,0 +1,219 @@
//===== Copyright © 1996-2005, Valve Corporation, All rights reserved. ======//
//
// Purpose:
//
// $NoKeywords: $
//===========================================================================//
#ifndef DMEPARTICLEPANEL_H
#define DMEPARTICLEPANEL_H
#ifdef _WIN32
#pragma once
#endif
#include "matsys_controls/potterywheelpanel.h"
#include "datamodel/dmattributetypes.h"
#include "particles/particles.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class IMaterial;
class CMeshBuilder;
class Vector;
class CParticleCollection;
class CColorPickerButton;
class CDmeParticleSystemDefinition;
class CDmeParticleFunction;
class CControlPointPage;
namespace vgui
{
class ScrollBar;
class IScheme;
class PropertyPage;
class PropertySheet;
class Splitter;
class Label;
class TextEntry;
}
//-----------------------------------------------------------------------------
// Particle System Viewer Panel
//-----------------------------------------------------------------------------
class CParticleSystemPanel : public CPotteryWheelPanel
{
DECLARE_CLASS_SIMPLE( CParticleSystemPanel, CPotteryWheelPanel );
public:
// constructor, destructor
CParticleSystemPanel( vgui::Panel *pParent, const char *pName );
virtual ~CParticleSystemPanel();
// Set the particle system to draw
void SetParticleSystem( CDmeParticleSystemDefinition *pDef );
void SetDmeElement( CDmeParticleSystemDefinition *pDef );
void SetParticleSystem( const char* szParticleSystemName );
CParticleCollection *GetParticleSystem();
//Indicates that the grid should be drawn
void RenderGrid( bool bEnable );
// Indicates that bounds should be drawn
void RenderBounds( bool bEnable );
// Indicates that cull sphere should be drawn
void RenderCullBounds( bool bEnable );
// Indicates that helpers should be drawn
void RenderHelpers( bool bEnable );
// Indicates that control points should be drawn
void RenderControlPoints( bool bEnable );
// Stops effect and plays endcap effect
void StopEffect();
// Indicates which helper to draw
void SetRenderedHelper( CDmeParticleFunction *pOp );
virtual void OnTick();
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
// Accessor for control point values
const Vector& GetControlPointValue( int nControlPoint ) const;
void SetControlPointValue( int nControlPoint, const Vector &value );
// Allow a parent panel to drive the ticking for this panel
void SetSelfSimulation(bool bSelfSimulate );
void Simulate();
virtual void ResetView();
// tells the panel to automatically find a good view of the particle system
void EnableAutoViewing( bool bEnable );
protected:
virtual void EnterManipulationMode( ManipulationMode_t manipMode, bool bMouseCapture, vgui::MouseCode mouseCode );
private:
// Shutdown, startup particle collection
void StartupParticleCollection();
void ShutdownParticleCollection();
// Draw bounds
void DrawBounds();
void DrawCullBounds();
void UseAutoView();
// paint it!
virtual void OnPaint3D();
private:
bool m_bRenderGrid : 1;
bool m_bRenderBounds : 1;
bool m_bRenderCullBounds : 1;
bool m_bRenderHelpers : 1;
bool m_bPerformNameBasedLookup : 1;
bool m_bRenderControlPoints : 1;
bool m_bTickMyself : 1;
bool m_bAutoView : 1;
bool m_bSuppressAutoView : 1;
Vector m_pControlPointValue[MAX_PARTICLE_CONTROL_POINTS];
Vector m_BestViewBoundsMin, m_BestViewBoundsMax;
DmObjectId_t m_RenderHelperId;
float m_flLastTime;
// Stores the id or name of the particle system being viewed
DmObjectId_t m_ParticleSystemId;
CUtlString m_ParticleSystemName;
// The particle system to draw
CParticleCollection *m_pParticleSystem;
// A texture to use for a lightmap
CTextureReference m_pLightmapTexture;
// The default env_cubemap
CTextureReference m_DefaultEnvCubemap;
};
//-----------------------------------------------------------------------------
// Accessor for control point values
//-----------------------------------------------------------------------------
inline const Vector& CParticleSystemPanel::GetControlPointValue( int nControlPoint ) const
{
return m_pControlPointValue[nControlPoint];
}
inline void CParticleSystemPanel::SetControlPointValue( int nControlPoint, const Vector &value )
{
m_pControlPointValue[nControlPoint] = value;
}
//-----------------------------------------------------------------------------
// This panel has a particle system viewer as well as controls
//-----------------------------------------------------------------------------
class CParticleSystemPreviewPanel : public vgui::EditablePanel
{
DECLARE_CLASS_SIMPLE( CParticleSystemPreviewPanel, vgui::EditablePanel );
public:
// constructor, destructor
CParticleSystemPreviewPanel( vgui::Panel *pParent, const char *pName );
virtual ~CParticleSystemPreviewPanel();
// Set the material to draw
void SetParticleSystem( CDmeParticleSystemDefinition *pDef, bool bOverrideLock );
void SetParticleFunction( CDmeParticleFunction *pFunction );
void SetDmeElement( CDmeParticleSystemDefinition *pDef );
virtual void OnCommand( const char *pCommand );
void StopEffect();
virtual void OnThink();
void ClearParticleSystemLock();
private:
MESSAGE_FUNC_PARAMS( OnCheckButtonChecked, "CheckButtonChecked", params );
MESSAGE_FUNC_PARAMS( OnBackgroundColorChanged, "ColorPickerPicked", params );
MESSAGE_FUNC_PARAMS( OnBackgroundColorPreview, "ColorPickerPreview", params );
MESSAGE_FUNC_PARAMS( OnBackgroundColorCancel, "ColorPickerCancel", params );
MESSAGE_FUNC( OnParticleSystemReconstructed, "ParticleSystemReconstructed" );
vgui::Splitter *m_Splitter;
CParticleSystemPanel *m_pParticleSystemPanel;
vgui::PropertySheet *m_pControlSheet;
vgui::PropertyPage *m_pRenderPage;
CControlPointPage *m_pControlPointPage;
vgui::CheckButton *m_pRenderCullBounds;
vgui::CheckButton *m_pRenderBounds;
vgui::CheckButton *m_pRenderControlPoints;
vgui::CheckButton *m_pRenderHelpers;
vgui::CheckButton *m_pRenderGrid;
vgui::CheckButton *m_pLockPreview;
CColorPickerButton *m_pBackgroundColor;
vgui::Button *m_pStopEffect;
vgui::Label *m_pParticleCount;
CDmeParticleSystemDefinition* m_pUnlockSystem;
};
#endif // DMEPARTICLEPANEL_H
@@ -0,0 +1,89 @@
//===== Copyright © 1996-2005, Valve Corporation, All rights reserved. ======//
//
// Purpose: Dialog used to edit properties of a particle system definition
//
//===========================================================================//
#ifndef PARTICLESYSTEMPROPERTIESPANEL_H
#define PARTICLESYSTEMPROPERTIESPANEL_H
#ifdef _WIN32
#pragma once
#endif
#include "vgui_controls/editablepanel.h"
#include "tier1/utlstring.h"
#include "datamodel/dmehandle.h"
#include "particles/particles.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CDmeParticleSystemDefinition;
class CParticleFunctionBrowser;
class CDmeElementPanel;
namespace vgui
{
class Splitter;
class ComboBox;
}
//-----------------------------------------------------------------------------
// Used by the panel to discover the list of known particle system definitions
//-----------------------------------------------------------------------------
class IParticleSystemPropertiesPanelQuery
{
public:
virtual void GetKnownParticleDefinitions( CUtlVector< CDmeParticleSystemDefinition* > &definitions ) = 0;
};
//-----------------------------------------------------------------------------
// Panel used to edit a particle system definition
//-----------------------------------------------------------------------------
class CParticleSystemPropertiesPanel : public vgui::EditablePanel
{
DECLARE_CLASS_SIMPLE( CParticleSystemPropertiesPanel, vgui::EditablePanel );
// Sends the message 'ParticleSystemModified' when the particle system was modified in any way
// Sends the message 'ParticleFunctionSelChanged' when the selected particle function changed
// -- stores the selected CDmeParticleFunction in a subkey called 'function'
public:
CParticleSystemPropertiesPanel( IParticleSystemPropertiesPanelQuery *pQuery, vgui::Panel* pParent ); // standard constructor
// Sets the particle system to look at
void SetParticleSystem( CDmeParticleSystemDefinition *pParticleSystem );
CDmeParticleSystemDefinition *GetParticleSystem( );
// Refreshes display
void Refresh( bool bValuesOnly = true );
void DeleteSelectedFunctions( );
private:
// For inheriting classes to get notified without having to listen to messages
virtual void OnParticleSystemModified() {}
MESSAGE_FUNC_PARAMS( OnDmeElementChanged, "DmeElementChanged", params );
MESSAGE_FUNC( OnParticleSystemModifiedInternal, "ParticleSystemModified" );
MESSAGE_FUNC_PARAMS( OnParticleFunctionSelChanged, "ParticleFunctionSelChanged", params );
MESSAGE_FUNC( OnPasteFuncs, "PasteFuncs" );
MESSAGE_FUNC( OnCopy, "OnCopy" );
KEYBINDING_FUNC_NODECLARE( edit_copy, KEY_C, vgui::MODIFIER_CONTROL, OnCopy, "#edit_copy_help", 0 );
IParticleSystemPropertiesPanelQuery *m_pQuery;
vgui::Splitter *m_pSplitter;
vgui::EditablePanel *m_pFunctionBrowserArea;
CParticleFunctionBrowser *m_pParticleFunctionBrowser;
CDmeElementPanel *m_pParticleFunctionProperties;
CDmeHandle< CDmeParticleSystemDefinition > m_hParticleSystem;
};
#endif // PARTICLESYSTEMPROPERTIESPANEL_H
+55
View File
@@ -0,0 +1,55 @@
//===== Copyright © 1996-2005, Valve Corporation, All rights reserved. ======//
//
// Purpose: Dialog used to edit properties of a particle system definition
//
//===========================================================================//
#ifndef PRESETPICKER_H
#define PRESETPICKER_H
#ifdef _WIN32
#pragma once
#endif
#include "vgui_controls/frame.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CDmElement;
using namespace vgui;
//-----------------------------------------------------------------------------
//
// Purpose: Picker for animation set presets
//
//-----------------------------------------------------------------------------
class CPresetPickerFrame : public vgui::Frame
{
DECLARE_CLASS_SIMPLE( CPresetPickerFrame, vgui::Frame );
public:
CPresetPickerFrame( vgui::Panel *pParent, const char *pTitle, bool bAllowMultiSelect = true );
~CPresetPickerFrame();
// Shows the modal dialog
void DoModal( CDmElement *pPresetGroup, bool bSelectAll, KeyValues *pContextKeyValues );
// Inherited from Frame
virtual void OnCommand( const char *pCommand );
private:
// Refreshes the list of presets
void RefreshPresetList( CDmElement *pPresetGroup, bool bSelectAll );
void CleanUpMessage();
vgui::ListPanel *m_pPresetList;
vgui::Button *m_pOpenButton;
vgui::Button *m_pCancelButton;
KeyValues *m_pContextKeyValues;
};
#endif // PRESETPICKER_H
+57
View File
@@ -0,0 +1,57 @@
//======= Copyright (c) 1996-2009, Valve Corporation, All rights reserved. ======
//
// CSheetEditorPanel - Tool panel for editing sprite sheet information
//
//===============================================================================
#ifndef SHEETEDITORPANEL_H
#define SHEETEDITORPANEL_H
#ifdef _WIN32
#pragma once
#endif
#include "vgui_controls/EditablePanel.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CDmeParticleSystemDefinition;
class CSheet;
class CVMTPicker;
class CVMTPreviewPanel;
namespace vgui
{
class IScheme;
class Label;
class TextEntry;
class IScheme;
}
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
class CSheetEditorPanel : public vgui::EditablePanel
{
DECLARE_CLASS_SIMPLE( CSheetEditorPanel, vgui::EditablePanel );
public:
// constructor, destructor
CSheetEditorPanel( vgui::Panel *pParent, const char *pName );
virtual ~CSheetEditorPanel();
void SetParticleSystem( CDmeParticleSystemDefinition *pParticleSystem );
virtual void ApplySchemeSettings(vgui::IScheme *pScheme);
private:
vgui::Label *m_pTitleLabel;
vgui::ListPanel *m_pTestList;
CVMTPreviewPanel *m_pVMTPreview;
CVMTPicker* m_pVMTPicker;
CSheet *m_pSheetInfo;
};
#endif // SHEETEDITORPANEL_H
+125
View File
@@ -0,0 +1,125 @@
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======
//
// Purpose:
//
//=============================================================================
#ifndef SOUNDPICKER_H
#define SOUNDPICKER_H
#ifdef _WIN32
#pragma once
#endif
#include "matsys_controls/BaseAssetPicker.h"
#include "vgui_controls/Frame.h"
#include "datamodel/dmehandle.h"
#include "tier1/utlstring.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
namespace vgui
{
class Panel;
}
//-----------------------------------------------------------------------------
// Purpose: Sound picker panel
//-----------------------------------------------------------------------------
class CSoundPicker : public CBaseAssetPicker
{
DECLARE_CLASS_SIMPLE( CSoundPicker, CBaseAssetPicker );
public:
enum PickType_t
{
PICK_NONE = 0,
PICK_GAMESOUNDS = 0x1,
PICK_WAVFILES = 0x2,
PICK_ALL = 0x7FFFFFFF,
ALLOW_MULTISELECT = 0x80000000,
};
CSoundPicker( vgui::Panel *pParent, int nFlags );
// overridden frame functions
virtual void Activate();
// Forward arrow keys to the list
virtual void OnKeyCodeTyped( vgui::KeyCode code );
// Sets the current sound choice
void SetSelectedSound( PickType_t type, const char *pSoundName );
// Returns the selceted sound name
PickType_t GetSelectedSoundType();
const char *GetSelectedSoundName( int nSelectionIndex = -1 );
int GetSelectedSoundCount();
void StopSoundPreview( );
private:
// Purpose: Called when a page is shown
void RequestGameSoundFilterFocus( );
// Updates the column header in the chooser
void UpdateGameSoundColumnHeader( int nMatchCount, int nTotalCount );
void BuildGameSoundList();
void RefreshGameSoundList();
void PlayGameSound( const char *pSoundName );
void PlayWavSound( const char *pSoundName );
void OnGameSoundFilterTextChanged( );
// Derived classes have this called when the previewed asset changes
void OnSelectedAssetPicked( const char *pAssetName );
// Don't play a sound when the next selection is a default selection
void OnNextSelectionIsDefault();
// Purpose: builds the gamesound list
bool IsGameSoundVisible( int hGameSound );
MESSAGE_FUNC_PARAMS( OnTextChanged, "TextChanged", kv );
MESSAGE_FUNC_PARAMS( OnItemSelected, "ItemSelected", kv );
MESSAGE_FUNC( OnPageChanged, "PageChanged" );
vgui::TextEntry *m_pGameSoundFilter;
vgui::PropertySheet *m_pViewsSheet;
vgui::PropertyPage *m_pGameSoundPage;
vgui::PropertyPage *m_pWavPage;
vgui::ListPanel *m_pGameSoundList;
CUtlString m_GameSoundFilter;
int m_nPlayingSound;
unsigned char m_nSoundSuppressionCount;
friend class CSoundPickerFrame;
};
//-----------------------------------------------------------------------------
// Purpose: Modal sound picker window
//-----------------------------------------------------------------------------
class CSoundPickerFrame : public CBaseAssetPickerFrame
{
DECLARE_CLASS_SIMPLE( CSoundPickerFrame, CBaseAssetPickerFrame );
public:
CSoundPickerFrame( vgui::Panel *pParent, const char *pTitle, int nFlags );
virtual ~CSoundPickerFrame();
virtual void OnClose();
// Purpose: Activate the dialog
// The message "SoundSelected" will be sent if a sound is picked
// Pass in optional context keyvalues to be added to any messages sent by the sound picker
void DoModal( CSoundPicker::PickType_t initialType, const char *pInitialValue, KeyValues *pContextKeyValues = NULL );
virtual void OnCommand( const char *pCommand );
};
#endif // SOUNDPICKER_H
+66
View File
@@ -0,0 +1,66 @@
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======
//
// Purpose:
//
//=============================================================================
#ifndef SOUNDRECORDPANEL_H
#define SOUNDRECORDPANEL_H
#ifdef _WIN32
#pragma once
#endif
#include "vgui_controls/Frame.h"
#include "tier1/utlstring.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
namespace vgui
{
class Button;
}
//-----------------------------------------------------------------------------
// Purpose: Modal sound picker window
//-----------------------------------------------------------------------------
class CSoundRecordPanel : public vgui::Frame
{
DECLARE_CLASS_SIMPLE( CSoundRecordPanel, vgui::Frame );
public:
CSoundRecordPanel( vgui::Panel *pParent, const char *pTitle );
~CSoundRecordPanel();
// Inherited from Frame
virtual void OnCommand( const char *pCommand );
virtual void OnTick();
// Purpose: Activate the dialog
// The message "SoundRecorded" will be sent if a sound is recorded
void DoModal( const char *pFileName );
private:
void StopSoundPreview( );
void PlaySoundPreview( );
// Updates sound record time during recording
void UpdateTimeRecorded();
vgui::Button *m_pRecordButton;
vgui::Button *m_pPlayButton;
vgui::Button *m_pOkButton;
vgui::Button *m_pCancelButton;
vgui::TextEntry *m_pRecordTime;
vgui::TextEntry *m_pFileName;
CUtlString m_FileName;
CUtlString m_EngineFileName;
int m_nPlayingSound;
float m_flRecordStartTime;
bool m_bIsRecording;
};
#endif // SOUNDRECORDPANEL_H