mirror of
https://github.com/nillerusr/source-engine.git
synced 2026-08-08 01:39:36 +00:00
1
This commit is contained in:
@@ -0,0 +1,599 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Singleton dialog that generates and presents the entity report.
|
||||
//
|
||||
//===========================================================================//
|
||||
|
||||
#include "particlesystemdefinitionbrowser.h"
|
||||
#include "tier1/KeyValues.h"
|
||||
#include "tier1/utlbuffer.h"
|
||||
#include "iregistry.h"
|
||||
#include "vgui/ivgui.h"
|
||||
#include "vgui_controls/listpanel.h"
|
||||
#include "vgui_controls/inputdialog.h"
|
||||
#include "vgui_controls/messagebox.h"
|
||||
#include "petdoc.h"
|
||||
#include "pettool.h"
|
||||
#include "datamodel/dmelement.h"
|
||||
#include "vgui/keycode.h"
|
||||
#include "dme_controls/dmecontrols_utils.h"
|
||||
#include "dme_controls/particlesystempanel.h"
|
||||
#include "filesystem.h"
|
||||
#include "vgui_controls/FileOpenDialog.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include <tier0/memdbgon.h>
|
||||
|
||||
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Sort by particle system definition name
|
||||
//-----------------------------------------------------------------------------
|
||||
static int __cdecl ParticleSystemNameSortFunc( vgui::ListPanel *pPanel, const ListPanelItem &item1, const ListPanelItem &item2 )
|
||||
{
|
||||
const char *string1 = item1.kv->GetString("name");
|
||||
const char *string2 = item2.kv->GetString("name");
|
||||
return Q_stricmp( string1, string2 );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CParticleSystemDefinitionBrowser::CParticleSystemDefinitionBrowser( CPetDoc *pDoc, vgui::Panel* pParent, const char *pName )
|
||||
: BaseClass( pParent, pName ), m_pDoc( pDoc )
|
||||
{
|
||||
SetKeyBoardInputEnabled( true );
|
||||
SetPaintBackgroundEnabled( true );
|
||||
|
||||
m_pParticleSystemsDefinitions = new vgui::ListPanel( this, "ParticleSystems" );
|
||||
m_pParticleSystemsDefinitions->AddColumnHeader( 0, "name", "Name", 52, ListPanel::COLUMN_RESIZEWITHWINDOW );
|
||||
m_pParticleSystemsDefinitions->SetColumnSortable( 0, true );
|
||||
m_pParticleSystemsDefinitions->SetEmptyListText( "No Particle System Definitions" );
|
||||
m_pParticleSystemsDefinitions->AddActionSignalTarget( this );
|
||||
m_pParticleSystemsDefinitions->SetSortFunc( 0, ParticleSystemNameSortFunc );
|
||||
m_pParticleSystemsDefinitions->SetSortColumn( 0 );
|
||||
|
||||
LoadControlSettingsAndUserConfig( "resource/particlesystemdefinitionbrowser.res" );
|
||||
|
||||
UpdateParticleSystemList();
|
||||
}
|
||||
|
||||
CParticleSystemDefinitionBrowser::~CParticleSystemDefinitionBrowser()
|
||||
{
|
||||
SaveUserConfig();
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Gets the ith selected particle system
|
||||
//-----------------------------------------------------------------------------
|
||||
CDmeParticleSystemDefinition* CParticleSystemDefinitionBrowser::GetSelectedParticleSystem( int i )
|
||||
{
|
||||
int iSel = m_pParticleSystemsDefinitions->GetSelectedItem( i );
|
||||
KeyValues *kv = m_pParticleSystemsDefinitions->GetItem( iSel );
|
||||
return GetElementKeyValue< CDmeParticleSystemDefinition >( kv, "particleSystem" );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Deletes the marked objects.
|
||||
//-----------------------------------------------------------------------------
|
||||
void CParticleSystemDefinitionBrowser::DeleteParticleSystems()
|
||||
{
|
||||
int iSel = m_pParticleSystemsDefinitions->GetSelectedItem( 0 );
|
||||
int nRow = m_pParticleSystemsDefinitions->GetItemCurrentRow( iSel ) - 1;
|
||||
{
|
||||
// This is undoable
|
||||
CAppUndoScopeGuard guard( NOTIFY_SETDIRTYFLAG, "Delete Particle Systems", "Delete Particle Systems" );
|
||||
|
||||
//
|
||||
// Build a list of objects to delete.
|
||||
//
|
||||
CUtlVector< CDmeParticleSystemDefinition* > itemsToDelete;
|
||||
int nCount = m_pParticleSystemsDefinitions->GetSelectedItemsCount();
|
||||
for (int i = 0; i < nCount; i++)
|
||||
{
|
||||
CDmeParticleSystemDefinition *pParticleSystem = GetSelectedParticleSystem( i );
|
||||
if ( pParticleSystem )
|
||||
{
|
||||
itemsToDelete.AddToTail( pParticleSystem );
|
||||
}
|
||||
}
|
||||
|
||||
nCount = itemsToDelete.Count();
|
||||
for ( int i = 0; i < nCount; ++i )
|
||||
{
|
||||
m_pDoc->DeleteParticleSystemDefinition( itemsToDelete[i] );
|
||||
}
|
||||
}
|
||||
|
||||
// Update the list box selection.
|
||||
if ( m_pParticleSystemsDefinitions->GetItemCount() > 0 )
|
||||
{
|
||||
if ( nRow < 0 )
|
||||
{
|
||||
nRow = 0;
|
||||
}
|
||||
else if ( nRow >= m_pParticleSystemsDefinitions->GetItemCount() )
|
||||
{
|
||||
nRow = m_pParticleSystemsDefinitions->GetItemCount() - 1;
|
||||
}
|
||||
|
||||
iSel = m_pParticleSystemsDefinitions->GetItemIDFromRow( nRow );
|
||||
m_pParticleSystemsDefinitions->SetSingleSelectedItem( iSel );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pParticleSystemsDefinitions->ClearSelectedItems();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void CParticleSystemDefinitionBrowser::LoadKVSection( CDmeParticleSystemDefinition *pNew, KeyValues *pOverridesKv, ParticleFunctionType_t eType )
|
||||
{
|
||||
// Operator KV
|
||||
KeyValues *pOperator = pOverridesKv->FindKey( GetParticleFunctionTypeName(eType), NULL );
|
||||
if ( !pOperator )
|
||||
return;
|
||||
|
||||
// Function
|
||||
FOR_EACH_TRUE_SUBKEY( pOperator, pFunctionBlock )
|
||||
{
|
||||
int iFunction = pNew->FindFunction( eType, pFunctionBlock->GetName() );
|
||||
if ( iFunction >= 0 )
|
||||
{
|
||||
CDmeParticleFunction *pDmeFunction = pNew->GetParticleFunction( eType, iFunction );
|
||||
// Elements
|
||||
FOR_EACH_SUBKEY( pFunctionBlock, pAttributeItem )
|
||||
{
|
||||
CDmAttribute *pAttribute = pDmeFunction->GetAttribute( pAttributeItem->GetName() );
|
||||
if ( !pAttribute )
|
||||
{
|
||||
Warning( "Unable to Find Attribute [%s] in Function [%s] in Operator [%s] for Definition [%s]\n", pAttributeItem->GetName(), pFunctionBlock->GetName(), GetParticleFunctionTypeName(eType), pNew->GetName() );
|
||||
}
|
||||
else
|
||||
{
|
||||
pAttribute->SetValueFromString( pAttributeItem->GetString() );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Warning( "Function [%s] not found under Operator [%s] for Definition [%s]\n", pFunctionBlock->GetName(), GetParticleFunctionTypeName(eType), pNew->GetName() );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Given a KV, create, add and return an effect
|
||||
//-----------------------------------------------------------------------------
|
||||
CDmeParticleSystemDefinition* CParticleSystemDefinitionBrowser::CreateParticleFromKV( KeyValues *pKeyValue )
|
||||
{
|
||||
CDmeParticleSystemDefinition* pBaseParticleDef = NULL;
|
||||
|
||||
// Get the Base Particle Effect Def
|
||||
const char* pBaseParticleName = pKeyValue->GetString( "base_effect", "" );
|
||||
for ( int i = 0; i < m_pParticleSystemsDefinitions->GetItemCount(); ++i )
|
||||
{
|
||||
KeyValues *kv = m_pParticleSystemsDefinitions->GetItem( i );
|
||||
if ( !V_strcmp( kv->GetString( "name", "" ), pBaseParticleName ) )
|
||||
{
|
||||
//
|
||||
pBaseParticleDef = GetElementKeyValue< CDmeParticleSystemDefinition >( kv, "particleSystem" );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Base Particle could not be found, end;
|
||||
if ( !pBaseParticleDef )
|
||||
{
|
||||
Warning( "Unable to to find base particle system [%s]", pBaseParticleName );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Create a Copy of the Base Effect
|
||||
const char *pszNewParticleName = pKeyValue->GetName();
|
||||
//CAppUndoScopeGuard guard( NOTIFY_SETDIRTYFLAG, "Copy Particle System", "Copy Particle System" );
|
||||
CDmeParticleSystemDefinition *pNew = CastElement<CDmeParticleSystemDefinition>( pBaseParticleDef->Copy() );
|
||||
pNew->SetName( pszNewParticleName );
|
||||
|
||||
// Overrides
|
||||
//
|
||||
//"properties"
|
||||
KeyValues *pProperties = pKeyValue->FindKey( "Properties", NULL );
|
||||
if ( pProperties )
|
||||
{
|
||||
FOR_EACH_SUBKEY( pProperties, pProperty )
|
||||
{
|
||||
CDmAttribute *pAttribute = pNew->GetAttribute( pProperty->GetName() );
|
||||
if ( !pAttribute )
|
||||
{
|
||||
Warning( "Unable to Find Attribute [%s] in Function [%s]\n", pProperty->GetName(), "Properties" );
|
||||
}
|
||||
else
|
||||
{
|
||||
pAttribute->SetValueFromString( pProperty->GetString() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LoadKVSection( pNew, pKeyValue, FUNCTION_RENDERER );
|
||||
LoadKVSection( pNew, pKeyValue, FUNCTION_OPERATOR );
|
||||
LoadKVSection( pNew, pKeyValue, FUNCTION_INITIALIZER );
|
||||
LoadKVSection( pNew, pKeyValue, FUNCTION_EMITTER );
|
||||
LoadKVSection( pNew, pKeyValue, FUNCTION_FORCEGENERATOR );
|
||||
LoadKVSection( pNew, pKeyValue, FUNCTION_CONSTRAINT );
|
||||
|
||||
// Remove copied children
|
||||
int iChildrenCount = pNew->GetParticleFunctionCount( FUNCTION_CHILDREN );
|
||||
for ( int i = iChildrenCount - 1; i >= 0; i-- )
|
||||
{
|
||||
pNew->RemoveFunction( FUNCTION_CHILDREN, i );
|
||||
}
|
||||
|
||||
// Search Children
|
||||
KeyValues *pChildren = pKeyValue->FindKey( "Children", NULL );
|
||||
if ( pChildren )
|
||||
{
|
||||
FOR_EACH_TRUE_SUBKEY( pChildren, pChild )
|
||||
{
|
||||
// each Child is its own effect so we need to add it and return it
|
||||
CDmeParticleSystemDefinition* pChildEffect = CreateParticleFromKV( pChild );
|
||||
if ( pChildEffect )
|
||||
{
|
||||
pNew->AddChild( pChildEffect );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_pDoc->ReplaceParticleSystemDefinition( pNew );
|
||||
m_pDoc->UpdateAllParticleSystems();
|
||||
return pNew;
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
// Create from KV
|
||||
void CParticleSystemDefinitionBrowser::CreateParticleSystemsFromKV( const char *pFileName )
|
||||
{
|
||||
//
|
||||
//const char * pFileName = "particles\\_weapon_prefab_override_kv.txt";
|
||||
|
||||
CUtlBuffer bufRawData;
|
||||
bool bReadFileOK = g_pFullFileSystem->ReadFile( pFileName, "MOD", bufRawData );
|
||||
if ( !bReadFileOK )
|
||||
{
|
||||
Warning( "Unable to Open KV file [%s]\n", pFileName );
|
||||
return;
|
||||
}
|
||||
|
||||
// Wrap it with a text buffer reader
|
||||
CUtlBuffer bufText( bufRawData.Base(), bufRawData.TellPut(), CUtlBuffer::READ_ONLY | CUtlBuffer::TEXT_BUFFER );
|
||||
|
||||
KeyValues *pBaseKeyValue = NULL;
|
||||
pBaseKeyValue = new KeyValues( "CCreateParticlesFromKV" );
|
||||
|
||||
if ( !pBaseKeyValue->LoadFromBuffer( NULL, bufText ) )
|
||||
{
|
||||
Warning( "Unable to Read KV file [%s]\n", pFileName );
|
||||
pBaseKeyValue->deleteThis();
|
||||
return;
|
||||
}
|
||||
|
||||
FOR_EACH_TRUE_SUBKEY( pBaseKeyValue, pKVOver )
|
||||
{
|
||||
CreateParticleFromKV( pKVOver );
|
||||
}
|
||||
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CParticleSystemDefinitionBrowser::OnKeyCodeTyped( vgui::KeyCode code )
|
||||
{
|
||||
if ( code == KEY_DELETE )
|
||||
{
|
||||
DeleteParticleSystems();
|
||||
}
|
||||
else
|
||||
{
|
||||
BaseClass::OnKeyCodeTyped( code );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void CParticleSystemDefinitionBrowser::OnFileSelected(const char *fullpath)
|
||||
{
|
||||
CreateParticleSystemsFromKV( fullpath );
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
// Called when the selection changes
|
||||
//-----------------------------------------------------------------------------
|
||||
void CParticleSystemDefinitionBrowser::UpdateParticleSystemSelection()
|
||||
{
|
||||
if ( m_pParticleSystemsDefinitions->GetSelectedItemsCount() == 1 )
|
||||
{
|
||||
CDmeParticleSystemDefinition *pParticleSystem = GetSelectedParticleSystem( 0 );
|
||||
g_pPetTool->SetCurrentParticleSystem( pParticleSystem, false );
|
||||
}
|
||||
else
|
||||
{
|
||||
g_pPetTool->SetCurrentParticleSystem( NULL, false );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Item selection/deselection
|
||||
//-----------------------------------------------------------------------------
|
||||
void CParticleSystemDefinitionBrowser::OnItemSelected( void )
|
||||
{
|
||||
UpdateParticleSystemSelection();
|
||||
}
|
||||
|
||||
void CParticleSystemDefinitionBrowser::OnItemDeselected( void )
|
||||
{
|
||||
UpdateParticleSystemSelection();
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Select a particular node
|
||||
//-----------------------------------------------------------------------------
|
||||
void CParticleSystemDefinitionBrowser::SelectParticleSystem( CDmeParticleSystemDefinition *pFind )
|
||||
{
|
||||
m_pParticleSystemsDefinitions->ClearSelectedItems();
|
||||
for ( int nItemID = m_pParticleSystemsDefinitions->FirstItem(); nItemID != m_pParticleSystemsDefinitions->InvalidItemID(); nItemID = m_pParticleSystemsDefinitions->NextItem( nItemID ) )
|
||||
{
|
||||
KeyValues *kv = m_pParticleSystemsDefinitions->GetItem( nItemID );
|
||||
CDmeParticleSystemDefinition *pParticleSystem = GetElementKeyValue<CDmeParticleSystemDefinition>( kv, "particleSystem" );
|
||||
if ( pParticleSystem == pFind )
|
||||
{
|
||||
m_pParticleSystemsDefinitions->AddSelectedItem( nItemID );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Called when buttons are clicked
|
||||
//-----------------------------------------------------------------------------
|
||||
void CParticleSystemDefinitionBrowser::OnInputCompleted( KeyValues *pKeyValues )
|
||||
{
|
||||
const char *pText = pKeyValues->GetString( "text", NULL );
|
||||
if ( m_pDoc->IsParticleSystemDefined( pText ) )
|
||||
{
|
||||
char pBuf[1024];
|
||||
Q_snprintf( pBuf, sizeof(pBuf), "Particle System \"%s\" already exists!\n", pText );
|
||||
vgui::MessageBox *pMessageBox = new vgui::MessageBox( "Duplicate Particle System Name!\n", pBuf, g_pPetTool->GetRootPanel() );
|
||||
pMessageBox->DoModal( );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( pKeyValues->FindKey( "create" ) )
|
||||
{
|
||||
CDmeParticleSystemDefinition *pParticleSystem = m_pDoc->AddNewParticleSystemDefinition( pText );
|
||||
g_pPetTool->SetCurrentParticleSystem( pParticleSystem );
|
||||
}
|
||||
else if ( pKeyValues->FindKey( "copy" ) )
|
||||
{
|
||||
int nCount = m_pParticleSystemsDefinitions->GetSelectedItemsCount();
|
||||
if ( nCount )
|
||||
{
|
||||
CDmeParticleSystemDefinition *pParticleSystem = GetSelectedParticleSystem( 0 );
|
||||
CAppUndoScopeGuard guard( NOTIFY_SETDIRTYFLAG, "Copy Particle System",
|
||||
"Copy Particle System" );
|
||||
CDmeParticleSystemDefinition * pNew =
|
||||
CastElement<CDmeParticleSystemDefinition>( pParticleSystem->Copy( ) );
|
||||
pNew->SetName( pText );
|
||||
m_pDoc->AddNewParticleSystemDefinition( pNew, guard );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copy to clipboard
|
||||
//-----------------------------------------------------------------------------
|
||||
void CParticleSystemDefinitionBrowser::CopyToClipboard( )
|
||||
{
|
||||
int nCount = m_pParticleSystemsDefinitions->GetSelectedItemsCount();
|
||||
|
||||
CUtlVector< KeyValues * > list;
|
||||
CUtlRBTree< CDmeParticleSystemDefinition* > defs( 0, 0, DefLessFunc( CDmeParticleSystemDefinition* ) );
|
||||
for ( int i = 0; i < nCount; ++i )
|
||||
{
|
||||
CDmeParticleSystemDefinition *pParticleSystem = GetSelectedParticleSystem( i );
|
||||
|
||||
CUtlBuffer buf( 0, 0, CUtlBuffer::TEXT_BUFFER );
|
||||
if ( g_pDataModel->Serialize( buf, "keyvalues2", "pcf", pParticleSystem->GetHandle() ) )
|
||||
{
|
||||
KeyValues *pData = new KeyValues( "Clipboard" );
|
||||
pData->SetString( "pcf", (char*)buf.Base() );
|
||||
list.AddToTail( pData );
|
||||
}
|
||||
}
|
||||
|
||||
if ( list.Count() )
|
||||
{
|
||||
g_pDataModel->SetClipboardData( list );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Paste from clipboard
|
||||
//-----------------------------------------------------------------------------
|
||||
void CParticleSystemDefinitionBrowser::ReplaceDef_r( CUndoScopeGuard& guard, CDmeParticleSystemDefinition *pDef )
|
||||
{
|
||||
if ( !pDef )
|
||||
return;
|
||||
|
||||
m_pDoc->ReplaceParticleSystemDefinition( pDef );
|
||||
int nChildCount = pDef->GetParticleFunctionCount( FUNCTION_CHILDREN );
|
||||
for ( int i = 0; i < nChildCount; ++i )
|
||||
{
|
||||
CDmeParticleChild *pChildFunction = static_cast< CDmeParticleChild* >( pDef->GetParticleFunction( FUNCTION_CHILDREN, i ) );
|
||||
CDmeParticleSystemDefinition* pChild = pChildFunction->m_Child;
|
||||
ReplaceDef_r( guard, pChild );
|
||||
}
|
||||
}
|
||||
|
||||
void CParticleSystemDefinitionBrowser::PasteFromClipboard( )
|
||||
{
|
||||
// This is undoable
|
||||
CAppUndoScopeGuard guard( NOTIFY_SETDIRTYFLAG, "Paste From Clipboard", "Paste From Clipboard" );
|
||||
|
||||
bool bRefreshAll = false;
|
||||
CUtlVector< KeyValues * > list;
|
||||
g_pDataModel->GetClipboardData( list );
|
||||
int nItems = list.Count();
|
||||
for ( int i = 0; i < nItems; ++i )
|
||||
{
|
||||
const char *pData = list[i]->GetString( "pcf" );
|
||||
if ( !pData )
|
||||
continue;
|
||||
|
||||
int nLen = Q_strlen( pData );
|
||||
CUtlBuffer buf( pData, nLen, CUtlBuffer::TEXT_BUFFER | CUtlBuffer::READ_ONLY );
|
||||
|
||||
DmElementHandle_t hRoot;
|
||||
if ( !g_pDataModel->Unserialize( buf, "keyvalues2", "pcf", NULL, "paste", CR_FORCE_COPY, hRoot ) )
|
||||
continue;
|
||||
|
||||
CDmeParticleSystemDefinition *pDef = GetElement<CDmeParticleSystemDefinition>( hRoot );
|
||||
if ( !pDef )
|
||||
continue;
|
||||
|
||||
ReplaceDef_r( guard, pDef );
|
||||
bRefreshAll = true;
|
||||
}
|
||||
|
||||
guard.Release();
|
||||
|
||||
if ( bRefreshAll )
|
||||
{
|
||||
m_pDoc->UpdateAllParticleSystems();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Called when buttons are clicked
|
||||
//-----------------------------------------------------------------------------
|
||||
void CParticleSystemDefinitionBrowser::OnCommand( const char *pCommand )
|
||||
{
|
||||
if ( !Q_stricmp( pCommand, "create" ) )
|
||||
{
|
||||
vgui::InputDialog *pInputDialog = new vgui::InputDialog( g_pPetTool->GetRootPanel(), "Enter Particle System Name", "Name:", "" );
|
||||
pInputDialog->SetSmallCaption( true );
|
||||
pInputDialog->SetMultiline( false );
|
||||
pInputDialog->AddActionSignalTarget( this );
|
||||
pInputDialog->DoModal( new KeyValues("create") );
|
||||
return;
|
||||
}
|
||||
if ( !Q_stricmp( pCommand, "copy" ) )
|
||||
{
|
||||
vgui::InputDialog *pInputDialog = new vgui::InputDialog( g_pPetTool->GetRootPanel(), "Enter Particle System Name", "Name:", "" );
|
||||
pInputDialog->SetSmallCaption( true );
|
||||
pInputDialog->SetMultiline( false );
|
||||
pInputDialog->AddActionSignalTarget( this );
|
||||
pInputDialog->DoModal( new KeyValues("copy") );
|
||||
return;
|
||||
}
|
||||
if ( !Q_stricmp( pCommand, "Create From KeyValue" ) )
|
||||
{
|
||||
vgui::FileOpenDialog *pDialog = new vgui::FileOpenDialog( g_pPetTool->GetRootPanel(), "Select KV File", vgui::FOD_OPEN );
|
||||
pDialog->SetTitle( "Choose KeyValue File", true );
|
||||
pDialog->AddFilter( "*.txt", "KeyValue File (*.txt)", true );
|
||||
pDialog->AddActionSignalTarget( this );
|
||||
|
||||
char szParticlesDir[MAX_PATH];
|
||||
pDialog->SetStartDirectory( g_pFullFileSystem->RelativePathToFullPath( "particles", "MOD", szParticlesDir, sizeof(szParticlesDir) ) );
|
||||
pDialog->DoModal( new KeyValues( "Create From KeyValue" ) );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !Q_stricmp( pCommand, "delete" ) )
|
||||
{
|
||||
DeleteParticleSystems();
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !Q_stricmp( pCommand, "Save" ) )
|
||||
{
|
||||
g_pPetTool->Save();
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !Q_stricmp( pCommand, "SaveAndTest" ) )
|
||||
{
|
||||
g_pPetTool->SaveAndTest();
|
||||
return;
|
||||
}
|
||||
|
||||
BaseClass::OnCommand( pCommand );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CParticleSystemDefinitionBrowser::UpdateParticleSystemList(void)
|
||||
{
|
||||
const CDmrParticleSystemList particleSystemList = m_pDoc->GetParticleSystemDefinitionList();
|
||||
if ( !particleSystemList.IsValid() )
|
||||
return;
|
||||
|
||||
// Maintain selection if possible
|
||||
CUtlVector< CUtlString > selectedItems;
|
||||
int nCount = m_pParticleSystemsDefinitions->GetSelectedItemsCount();
|
||||
for ( int i = 0; i < nCount; ++i )
|
||||
{
|
||||
CDmeParticleSystemDefinition *pParticleSystem = GetSelectedParticleSystem( i );
|
||||
if ( pParticleSystem )
|
||||
{
|
||||
selectedItems.AddToTail( pParticleSystem->GetName() );
|
||||
}
|
||||
}
|
||||
|
||||
m_pParticleSystemsDefinitions->RemoveAll();
|
||||
int nSelectedItemCount = selectedItems.Count();
|
||||
nCount = particleSystemList.Count();
|
||||
for ( int i = 0; i < nCount; ++i )
|
||||
{
|
||||
CDmeParticleSystemDefinition *pParticleSystem = particleSystemList[i];
|
||||
if ( !pParticleSystem )
|
||||
continue;
|
||||
|
||||
const char *pName = pParticleSystem->GetName();
|
||||
if ( !pName || !pName[0] )
|
||||
{
|
||||
pName = "<no name>";
|
||||
}
|
||||
|
||||
KeyValues *kv = new KeyValues( "node" );
|
||||
kv->SetString( "name", pName );
|
||||
SetElementKeyValue( kv, "particleSystem", pParticleSystem );
|
||||
|
||||
int nItemID = m_pParticleSystemsDefinitions->AddItem( kv, 0, false, false );
|
||||
|
||||
for ( int j = 0; j < nSelectedItemCount; ++j )
|
||||
{
|
||||
if ( Q_stricmp( selectedItems[j], pName ) )
|
||||
continue;
|
||||
|
||||
m_pParticleSystemsDefinitions->AddSelectedItem( nItemID );
|
||||
selectedItems.FastRemove(j);
|
||||
--nSelectedItemCount;
|
||||
break;
|
||||
}
|
||||
}
|
||||
m_pParticleSystemsDefinitions->SortList();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef PARTICLESYSTEMDEFINITIONBROWSER_H
|
||||
#define PARTICLESYSTEMDEFINITIONBROWSER_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "vgui_controls/editablepanel.h"
|
||||
#include "tier1/utlstring.h"
|
||||
#include "particles/particles.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Forward declarations
|
||||
//-----------------------------------------------------------------------------
|
||||
class CPetDoc;
|
||||
class CDmeParticleSystemDefinition;
|
||||
class CUndoScopeGuard;
|
||||
namespace vgui
|
||||
{
|
||||
class ComboBox;
|
||||
class Button;
|
||||
class TextEntry;
|
||||
class ListPanel;
|
||||
class CheckButton;
|
||||
class RadioButton;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Panel that shows all entities in the level
|
||||
//-----------------------------------------------------------------------------
|
||||
class CParticleSystemDefinitionBrowser : public vgui::EditablePanel
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CParticleSystemDefinitionBrowser, vgui::EditablePanel );
|
||||
|
||||
public:
|
||||
CParticleSystemDefinitionBrowser( CPetDoc *pDoc, vgui::Panel* pParent, const char *pName ); // standard constructor
|
||||
virtual ~CParticleSystemDefinitionBrowser();
|
||||
|
||||
// Inherited from Panel
|
||||
virtual void OnCommand( const char *pCommand );
|
||||
virtual void OnKeyCodeTyped( vgui::KeyCode code );
|
||||
MESSAGE_FUNC_CHARPTR( OnFileSelected, "FileSelected", fullpath );
|
||||
// Methods related to updating the listpanel
|
||||
void UpdateParticleSystemList();
|
||||
|
||||
// Select a particular node
|
||||
void SelectParticleSystem( CDmeParticleSystemDefinition *pParticleSystem );
|
||||
|
||||
// Copy, paste.
|
||||
void CopyToClipboard( );
|
||||
void PasteFromClipboard( );
|
||||
|
||||
private:
|
||||
// Messages handled
|
||||
MESSAGE_FUNC( OnItemDeselected, "ItemDeselected" );
|
||||
MESSAGE_FUNC( OnItemSelected, "ItemSelected" );
|
||||
MESSAGE_FUNC_PARAMS( OnInputCompleted, "InputCompleted", kv );
|
||||
|
||||
void ReplaceDef_r( CUndoScopeGuard& guard, CDmeParticleSystemDefinition *pDef );
|
||||
|
||||
// Gets the ith selected particle system
|
||||
CDmeParticleSystemDefinition* GetSelectedParticleSystem( int i );
|
||||
|
||||
// Called when the selection changes
|
||||
void UpdateParticleSystemSelection();
|
||||
|
||||
// Deletes selected particle systems
|
||||
void DeleteParticleSystems();
|
||||
|
||||
// Create from KV
|
||||
void LoadKVSection( CDmeParticleSystemDefinition *pNew, KeyValues *pOverridesKv, ParticleFunctionType_t eType );
|
||||
CDmeParticleSystemDefinition* CreateParticleFromKV( KeyValues *pKeyValue );
|
||||
void CreateParticleSystemsFromKV( const char *pFilepath );
|
||||
|
||||
// Shows the most recent selected object in properties window
|
||||
void OnProperties();
|
||||
|
||||
CPetDoc *m_pDoc;
|
||||
vgui::ListPanel *m_pParticleSystemsDefinitions;
|
||||
};
|
||||
|
||||
|
||||
#endif // PARTICLESYSTEMDEFINITIONBROWSER_H
|
||||
@@ -0,0 +1,73 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Dialog used to edit properties of a particle system definition
|
||||
//
|
||||
//===========================================================================//
|
||||
|
||||
#include "ParticleSystemPropertiesContainer.h"
|
||||
#include "petdoc.h"
|
||||
#include "pettool.h"
|
||||
#include "datamodel/dmelement.h"
|
||||
#include "movieobjects/dmeparticlesystemdefinition.h"
|
||||
#include "dme_controls/dmecontrols_utils.h"
|
||||
#include "dme_controls/particlesystempanel.h"
|
||||
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include <tier0/memdbgon.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
#pragma warning (disable:4355)
|
||||
CParticleSystemPropertiesContainer::CParticleSystemPropertiesContainer( CPetDoc *pDoc, vgui::Panel* pParent ) :
|
||||
BaseClass( this, pParent ), m_pDoc( pDoc )
|
||||
{
|
||||
}
|
||||
#pragma warning (default:4355)
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Refreshes the list of raw controls
|
||||
//-----------------------------------------------------------------------------
|
||||
void CParticleSystemPropertiesContainer::GetKnownParticleDefinitions( CUtlVector< CDmeParticleSystemDefinition* > &definitions )
|
||||
{
|
||||
definitions.RemoveAll();
|
||||
|
||||
CDmrParticleSystemList particleSystemList = g_pPetTool->GetDocument()->GetParticleSystemDefinitionList();
|
||||
if ( !particleSystemList.IsValid() )
|
||||
return;
|
||||
|
||||
int nCount = particleSystemList.Count();
|
||||
definitions.EnsureCapacity( nCount );
|
||||
for ( int i = 0; i < nCount; ++i )
|
||||
{
|
||||
CDmeParticleSystemDefinition *pParticleSystem = particleSystemList[i];
|
||||
definitions.AddToTail( pParticleSystem );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Called when the base class changes anything at all in the particle system
|
||||
//-----------------------------------------------------------------------------
|
||||
void CParticleSystemPropertiesContainer::OnParticleSystemModified()
|
||||
{
|
||||
CAppNotifyScopeGuard sg( "CParticleSystemPropertiesContainer::OnParticleSystemModified", NOTIFY_SETDIRTYFLAG );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Called when the selected particle function changes
|
||||
//-----------------------------------------------------------------------------
|
||||
void CParticleSystemPropertiesContainer::OnParticleFunctionSelChanged( KeyValues *pParams )
|
||||
{
|
||||
if ( g_pPetTool->GetParticlePreview() )
|
||||
{
|
||||
CDmeParticleFunction *pFunction = GetElementKeyValue<CDmeParticleFunction>( pParams, "function" );
|
||||
g_pPetTool->GetParticlePreview()->SetParticleFunction( pFunction );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Dialog used to edit properties of a particle system definition
|
||||
//
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef PARTICLESYSTEMPROPERTIESCONTAINER_H
|
||||
#define PARTICLESYSTEMPROPERTIESCONTAINER_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "dme_controls/particlesystempropertiespanel.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Forward declarations
|
||||
//-----------------------------------------------------------------------------
|
||||
class CPetDoc;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Panel used to edit a particle system definition
|
||||
//-----------------------------------------------------------------------------
|
||||
class CParticleSystemPropertiesContainer : public CParticleSystemPropertiesPanel, public IParticleSystemPropertiesPanelQuery
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CParticleSystemPropertiesContainer, CParticleSystemPropertiesPanel );
|
||||
|
||||
public:
|
||||
CParticleSystemPropertiesContainer( CPetDoc *pDoc, vgui::Panel* pParent ); // standard constructor
|
||||
|
||||
// Inherited from IParticleSystemPropertiesPanelQuery
|
||||
virtual void GetKnownParticleDefinitions( CUtlVector< CDmeParticleSystemDefinition* > &definitions );
|
||||
|
||||
private:
|
||||
MESSAGE_FUNC_PARAMS( OnParticleFunctionSelChanged, "ParticleFunctionSelChanged", params );
|
||||
|
||||
// For inheriting classes to get notified without having to listen to messages
|
||||
virtual void OnParticleSystemModified();
|
||||
|
||||
CPetDoc *m_pDoc;
|
||||
};
|
||||
|
||||
|
||||
#endif // PARTICLESYSTEMPROPERTIESCONTAINER_H
|
||||
@@ -0,0 +1,64 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// PET.VPC
|
||||
//
|
||||
// Project Script
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
$Macro SRCDIR "..\.."
|
||||
$Macro OUTBINDIR "$SRCDIR\..\game\bin\tools"
|
||||
|
||||
$Include "$SRCDIR\vpc_scripts\source_dll_base.vpc"
|
||||
|
||||
$Configuration
|
||||
{
|
||||
$Compiler
|
||||
{
|
||||
$AdditionalIncludeDirectories "$BASE,.\,$SRCDIR\game\shared"
|
||||
$PreprocessorDefinitions "$BASE;PET_EXPORTS"
|
||||
}
|
||||
|
||||
$Linker
|
||||
{
|
||||
$AdditionalDependencies "$BASE Psapi.lib"
|
||||
}
|
||||
}
|
||||
|
||||
$Project "Pet"
|
||||
{
|
||||
$Folder "Source Files"
|
||||
{
|
||||
$File "$SRCDIR\public\interpolatortypes.cpp"
|
||||
$File "particlesystemdefinitionbrowser.cpp"
|
||||
$File "particlesystempropertiescontainer.cpp"
|
||||
$File "petdoc.cpp"
|
||||
$File "pettool.cpp"
|
||||
$File "$SRCDIR\public\registry.cpp"
|
||||
$File "$SRCDIR\public\vgui_controls\vgui_controls.cpp"
|
||||
}
|
||||
|
||||
$Folder "Header Files"
|
||||
{
|
||||
$File "$SRCDIR\public\mathlib\mathlib.h"
|
||||
$File "particlesystemdefinitionbrowser.h"
|
||||
$File "particlesystempropertiescontainer.h"
|
||||
$File "petdoc.h"
|
||||
$File "pettool.h"
|
||||
}
|
||||
|
||||
$Folder "Link Libraries"
|
||||
{
|
||||
$Lib datamodel
|
||||
$Lib dme_controls
|
||||
$Lib dmserializers
|
||||
$Lib dmxloader
|
||||
$Lib mathlib
|
||||
$Lib matsys_controls
|
||||
$Lib movieobjects
|
||||
$Lib particles
|
||||
$Lib sfmobjects
|
||||
$Lib tier2
|
||||
$Lib tier3
|
||||
$Lib toolutils
|
||||
$Lib vgui_controls
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,536 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#include "petdoc.h"
|
||||
#include "tier1/KeyValues.h"
|
||||
#include "tier1/utlbuffer.h"
|
||||
#include "toolutils/enginetools_int.h"
|
||||
#include "filesystem.h"
|
||||
#include "pettool.h"
|
||||
#include "toolframework/ienginetool.h"
|
||||
#include "movieobjects/dmeparticlesystemdefinition.h"
|
||||
#include "datamodel/idatamodel.h"
|
||||
#include "toolutils/attributeelementchoicelist.h"
|
||||
#include "particlesystemdefinitionbrowser.h"
|
||||
#include "vgui_controls/messagebox.h"
|
||||
#include "particles/particles.h"
|
||||
#include "particlesystempropertiescontainer.h"
|
||||
#include "dme_controls/particlesystempanel.h"
|
||||
#include "dme_controls/dmecontrols.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CPetDoc::CPetDoc( IPetDocCallback *pCallback ) : m_pCallback( pCallback )
|
||||
{
|
||||
m_hRoot = NULL;
|
||||
m_pFileName[0] = 0;
|
||||
m_bDirty = false;
|
||||
g_pDataModel->InstallNotificationCallback( this );
|
||||
SetElementPropertiesChoices( this );
|
||||
}
|
||||
|
||||
CPetDoc::~CPetDoc()
|
||||
{
|
||||
if ( m_hRoot.Get() )
|
||||
{
|
||||
g_pDataModel->RemoveFileId( m_hRoot->GetFileId() );
|
||||
m_hRoot = NULL;
|
||||
}
|
||||
g_pDataModel->RemoveNotificationCallback( this );
|
||||
SetElementPropertiesChoices( NULL );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Inherited from INotifyUI
|
||||
//-----------------------------------------------------------------------------
|
||||
void CPetDoc::NotifyDataChanged( const char *pReason, int nNotifySource, int nNotifyFlags )
|
||||
{
|
||||
OnDataChanged( pReason, nNotifySource, nNotifyFlags );
|
||||
}
|
||||
|
||||
|
||||
bool CPetDoc::GetIntChoiceList( const char *pChoiceListType, CDmElement *pElement,
|
||||
const char *pAttributeName, bool bArrayElement, IntChoiceList_t &list )
|
||||
{
|
||||
if ( !Q_stricmp( pChoiceListType, "particlefield" ) )
|
||||
{
|
||||
for ( int i = 0; i < MAX_PARTICLE_ATTRIBUTES; ++i )
|
||||
{
|
||||
const char *pName = g_pParticleSystemMgr->GetParticleFieldName( i );
|
||||
if ( pName )
|
||||
{
|
||||
int j = list.AddToTail();
|
||||
list[j].m_nValue = i;
|
||||
list[j].m_pChoiceString = pName;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( !Q_stricmp( pChoiceListType, "particlefield_scalar" ) )
|
||||
{
|
||||
for ( int i = 0; i < MAX_PARTICLE_ATTRIBUTES; ++i )
|
||||
{
|
||||
if ( ( ATTRIBUTES_WHICH_ARE_VEC3S_MASK & ( 1 << i ) ) != 0 )
|
||||
continue;
|
||||
|
||||
const char *pName = g_pParticleSystemMgr->GetParticleFieldName( i );
|
||||
if ( pName )
|
||||
{
|
||||
int j = list.AddToTail();
|
||||
list[j].m_nValue = i;
|
||||
list[j].m_pChoiceString = pName;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( !Q_stricmp( pChoiceListType, "particlefield_vector" ) )
|
||||
{
|
||||
for ( int i = 0; i < MAX_PARTICLE_ATTRIBUTES; ++i )
|
||||
{
|
||||
if ( ( ATTRIBUTES_WHICH_ARE_VEC3S_MASK & ( 1 << i ) ) == 0 )
|
||||
continue;
|
||||
|
||||
const char *pName = g_pParticleSystemMgr->GetParticleFieldName( i );
|
||||
if ( pName )
|
||||
{
|
||||
int j = list.AddToTail();
|
||||
list[j].m_nValue = i;
|
||||
list[j].m_pChoiceString = pName;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Gets the file name
|
||||
//-----------------------------------------------------------------------------
|
||||
const char *CPetDoc::GetFileName()
|
||||
{
|
||||
return m_pFileName;
|
||||
}
|
||||
|
||||
void CPetDoc::SetFileName( const char *pFileName )
|
||||
{
|
||||
Q_strncpy( m_pFileName, pFileName, sizeof( m_pFileName ) );
|
||||
Q_FixSlashes( m_pFileName );
|
||||
SetDirty( true );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Dirty bits
|
||||
//-----------------------------------------------------------------------------
|
||||
void CPetDoc::SetDirty( bool bDirty )
|
||||
{
|
||||
m_bDirty = bDirty;
|
||||
}
|
||||
|
||||
bool CPetDoc::IsDirty() const
|
||||
{
|
||||
return m_bDirty;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Creates the root element
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CPetDoc::CreateRootElement()
|
||||
{
|
||||
Assert( !m_hRoot.Get() );
|
||||
|
||||
DmFileId_t fileid = g_pDataModel->FindOrCreateFileId( GetFileName() );
|
||||
|
||||
// Create the main element
|
||||
m_hRoot = g_pDataModel->CreateElement( "DmElement", GetFileName(), fileid );
|
||||
if ( m_hRoot == DMELEMENT_HANDLE_INVALID )
|
||||
return false;
|
||||
|
||||
g_pDataModel->SetFileRoot( fileid, m_hRoot );
|
||||
|
||||
// We need to create an element array attribute storing particle system definitions
|
||||
m_hRoot->AddAttribute( "particleSystemDefinitions", AT_ELEMENT_ARRAY );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Creates a new document
|
||||
//-----------------------------------------------------------------------------
|
||||
void CPetDoc::CreateNew()
|
||||
{
|
||||
Assert( !m_hRoot.Get() );
|
||||
|
||||
// This is not undoable
|
||||
CDisableUndoScopeGuard guard;
|
||||
|
||||
Q_strncpy( m_pFileName, "untitled", sizeof( m_pFileName ) );
|
||||
|
||||
// Create the main element
|
||||
if ( !CreateRootElement() )
|
||||
return;
|
||||
|
||||
SetDirty( false );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Saves/loads from file
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CPetDoc::LoadFromFile( const char *pFileName )
|
||||
{
|
||||
Assert( !m_hRoot.Get() );
|
||||
|
||||
CAppDisableUndoScopeGuard guard( "CPetDoc::LoadFromFile", NOTIFY_CHANGE_OTHER );
|
||||
SetDirty( false );
|
||||
|
||||
if ( !pFileName[0] )
|
||||
return false;
|
||||
|
||||
Q_strncpy( m_pFileName, pFileName, sizeof( m_pFileName ) );
|
||||
|
||||
CDmElement *pRoot = NULL;
|
||||
DmFileId_t fileid = g_pDataModel->RestoreFromFile( pFileName, NULL, NULL, &pRoot, CR_DELETE_OLD );
|
||||
|
||||
if ( fileid == DMFILEID_INVALID )
|
||||
{
|
||||
m_pFileName[0] = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
m_hRoot = pRoot;
|
||||
|
||||
SetDirty( false );
|
||||
return true;
|
||||
}
|
||||
|
||||
void CPetDoc::SaveToFile( )
|
||||
{
|
||||
if ( m_hRoot.Get() && m_pFileName && m_pFileName[0] )
|
||||
{
|
||||
g_pDataModel->SaveToFile( m_pFileName, NULL, "binary", PET_FILE_FORMAT, m_hRoot );
|
||||
}
|
||||
|
||||
SetDirty( false );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Returns the root object
|
||||
//-----------------------------------------------------------------------------
|
||||
CDmElement *CPetDoc::GetRootObject()
|
||||
{
|
||||
return m_hRoot;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Returns the root object fileid
|
||||
//-----------------------------------------------------------------------------
|
||||
DmFileId_t CPetDoc::GetFileId()
|
||||
{
|
||||
return m_hRoot.Get() ? m_hRoot->GetFileId() : DMFILEID_INVALID;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Returns the particle system definition list
|
||||
//-----------------------------------------------------------------------------
|
||||
CDmAttribute *CPetDoc::GetParticleSystemDefinitionList()
|
||||
{
|
||||
CDmrElementArray<> array( m_hRoot, "particleSystemDefinitions" );
|
||||
return array.GetAttribute();
|
||||
}
|
||||
|
||||
|
||||
void CPetDoc::AddNewParticleSystemDefinition( CDmeParticleSystemDefinition *pNew, CUndoScopeGuard &Guard )
|
||||
{
|
||||
CDmrParticleSystemList particleSystemList( GetParticleSystemDefinitionList() );
|
||||
|
||||
particleSystemList.AddToTail( pNew );
|
||||
Guard.Release();
|
||||
|
||||
// Force a resolve to get the particle created
|
||||
g_pDmElementFramework->Operate( true );
|
||||
g_pDmElementFramework->BeginEdit();
|
||||
|
||||
UpdateParticleDefinition( pNew );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Adds a new particle system definition
|
||||
//-----------------------------------------------------------------------------
|
||||
CDmeParticleSystemDefinition* CPetDoc::AddNewParticleSystemDefinition( const char *pName )
|
||||
{
|
||||
if ( !pName || !pName[0] )
|
||||
{
|
||||
pName = "New Particle System";
|
||||
}
|
||||
|
||||
CDmeParticleSystemDefinition *pParticleSystem;
|
||||
{
|
||||
CAppUndoScopeGuard guard( NOTIFY_SETDIRTYFLAG, "Add Particle System", "Add Particle System" );
|
||||
|
||||
pParticleSystem = CreateElement<CDmeParticleSystemDefinition>( pName, GetFileId() );
|
||||
AddNewParticleSystemDefinition( pParticleSystem, guard );
|
||||
}
|
||||
|
||||
return pParticleSystem;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Refresh all particle definitions
|
||||
//-----------------------------------------------------------------------------
|
||||
void CPetDoc::UpdateAllParticleSystems( )
|
||||
{
|
||||
// Force a resolve to get the particle created
|
||||
g_pDmElementFramework->Operate( true );
|
||||
g_pDmElementFramework->BeginEdit();
|
||||
|
||||
CDmrParticleSystemList particleSystemList( GetParticleSystemDefinitionList() );
|
||||
int nCount = particleSystemList.Count();
|
||||
for ( int i = 0; i < nCount; ++i )
|
||||
{
|
||||
UpdateParticleDefinition( particleSystemList[i] );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Deletes a particle system definition
|
||||
//-----------------------------------------------------------------------------
|
||||
void CPetDoc::DeleteParticleSystemDefinition( CDmeParticleSystemDefinition *pParticleSystem )
|
||||
{
|
||||
if ( !pParticleSystem )
|
||||
return;
|
||||
|
||||
CDmrParticleSystemList particleSystemList( GetParticleSystemDefinitionList() );
|
||||
int nCount = particleSystemList.Count();
|
||||
for ( int i = 0; i < nCount; ++i )
|
||||
{
|
||||
if ( pParticleSystem == particleSystemList[i] )
|
||||
{
|
||||
CAppUndoScopeGuard guard( NOTIFY_SETDIRTYFLAG, "Delete Particle System", "Delete Particle System" );
|
||||
particleSystemList.FastRemove( i );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Find all CDmeParticleChilds referring to this function
|
||||
CUtlVector< CDmeParticleChild* > children;
|
||||
FindAncestorsReferencingElement( pParticleSystem, children );
|
||||
int nChildCount = children.Count();
|
||||
for ( int i = 0; i < nChildCount; ++i )
|
||||
{
|
||||
CDmeParticleChild *pChildReference = children[i];
|
||||
CDmeParticleSystemDefinition *pParent = FindReferringElement<CDmeParticleSystemDefinition>( pChildReference, "children" );
|
||||
if ( !pParent )
|
||||
continue;
|
||||
|
||||
pParent->RemoveFunction( FUNCTION_CHILDREN, pChildReference );
|
||||
DestroyElement( pChildReference, TD_NONE );
|
||||
}
|
||||
|
||||
DestroyElement( pParticleSystem, TD_DEEP );
|
||||
}
|
||||
|
||||
|
||||
CDmeParticleSystemDefinition *CPetDoc::FindParticleSystemDefinition( const char *pName )
|
||||
{
|
||||
CDmrParticleSystemList particleSystemList( GetParticleSystemDefinitionList() );
|
||||
int nCount = particleSystemList.Count();
|
||||
for ( int i = 0; i < nCount; ++i )
|
||||
{
|
||||
CDmeParticleSystemDefinition* pParticleSystem = particleSystemList[i];
|
||||
if ( !Q_stricmp( pName, pParticleSystem->GetName() ) )
|
||||
return pParticleSystem;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Deletes a particle system definition
|
||||
//-----------------------------------------------------------------------------
|
||||
void CPetDoc::ReplaceParticleSystemDefinition( CDmeParticleSystemDefinition *pParticleSystem )
|
||||
{
|
||||
if ( !pParticleSystem )
|
||||
return;
|
||||
|
||||
CDmrParticleSystemList particleSystemList( GetParticleSystemDefinitionList() );
|
||||
int nCount = particleSystemList.Count();
|
||||
int nFoundIndex = -1;
|
||||
for ( int i = 0; i < nCount; ++i )
|
||||
{
|
||||
if ( !particleSystemList[i] )
|
||||
continue;
|
||||
|
||||
if ( !Q_stricmp( particleSystemList[i]->GetName(), pParticleSystem->GetName() ) )
|
||||
{
|
||||
nFoundIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( nFoundIndex < 0 )
|
||||
{
|
||||
CAppUndoScopeGuard guard( NOTIFY_SETDIRTYFLAG, "Replace Particle System", "Replace Particle System" );
|
||||
CDmrParticleSystemList particleSystemList( GetParticleSystemDefinitionList() );
|
||||
pParticleSystem->SetFileId( m_hRoot->GetFileId(), TD_ALL );
|
||||
particleSystemList.AddToTail( pParticleSystem );
|
||||
return;
|
||||
}
|
||||
|
||||
CDmeParticleSystemDefinition *pOldParticleSystem = particleSystemList[nFoundIndex];
|
||||
|
||||
// This can happen if we unserialized w/ replace
|
||||
if ( pOldParticleSystem == pParticleSystem )
|
||||
return;
|
||||
|
||||
CAppUndoScopeGuard guard( NOTIFY_SETDIRTYFLAG, "Replace Particle System", "Replace Particle System" );
|
||||
|
||||
particleSystemList.Set( nFoundIndex, pParticleSystem );
|
||||
pParticleSystem->SetFileId( m_hRoot->GetFileId(), TD_ALL );
|
||||
|
||||
// Find all CDmeParticleChilds referring to this function
|
||||
CUtlVector< CDmeParticleChild* > children;
|
||||
FindAncestorsReferencingElement( pOldParticleSystem, children );
|
||||
int nChildCount = children.Count();
|
||||
for ( int i = 0; i < nChildCount; ++i )
|
||||
{
|
||||
CDmeParticleChild *pChildReference = children[i];
|
||||
pChildReference->m_Child = pParticleSystem;
|
||||
}
|
||||
|
||||
DestroyElement( pOldParticleSystem, TD_SHALLOW );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Does a particle system exist already?
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CPetDoc::IsParticleSystemDefined( const char *pName )
|
||||
{
|
||||
return FindParticleSystemDefinition( pName ) != NULL;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Updates a specific particle defintion
|
||||
//-----------------------------------------------------------------------------
|
||||
void CPetDoc::UpdateParticleDefinition( CDmeParticleSystemDefinition *pDef )
|
||||
{
|
||||
if ( !pDef )
|
||||
return;
|
||||
|
||||
CUtlBuffer buf;
|
||||
g_pDataModel->Serialize( buf, "binary", PET_FILE_FORMAT, pDef->GetHandle() );
|
||||
|
||||
// Tell the game about the new definitions
|
||||
if ( clienttools )
|
||||
{
|
||||
clienttools->ReloadParticleDefintions( GetFileName(), buf.Base(), buf.TellMaxPut() );
|
||||
}
|
||||
if ( servertools )
|
||||
{
|
||||
servertools->ReloadParticleDefintions( GetFileName(), buf.Base(), buf.TellMaxPut() );
|
||||
}
|
||||
|
||||
// Let the other tools know
|
||||
KeyValues *pMessage = new KeyValues( "ParticleSystemUpdated" );
|
||||
pMessage->SetPtr( "definitionBits", buf.Base() );
|
||||
pMessage->SetInt( "definitionSize", buf.TellMaxPut() );
|
||||
g_pPetTool->PostMessageToAllTools( pMessage );
|
||||
pMessage->deleteThis();
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Populate string choice lists
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CPetDoc::GetStringChoiceList( const char *pChoiceListType, CDmElement *pElement,
|
||||
const char *pAttributeName, bool bArrayElement, StringChoiceList_t &list )
|
||||
{
|
||||
if ( !Q_stricmp( pChoiceListType, "particleSystemDefinitions" ) )
|
||||
{
|
||||
CDmrParticleSystemList particleSystemList( GetParticleSystemDefinitionList() );
|
||||
|
||||
StringChoice_t sChoice;
|
||||
sChoice.m_pValue = "";
|
||||
sChoice.m_pChoiceString = "";
|
||||
list.AddToTail( sChoice );
|
||||
|
||||
int nCount = particleSystemList.Count();
|
||||
for ( int i = 0; i < nCount; ++i )
|
||||
{
|
||||
CDmeParticleSystemDefinition *pParticleSystem = particleSystemList[ i ];
|
||||
|
||||
StringChoice_t sChoice;
|
||||
sChoice.m_pValue = pParticleSystem->GetName();
|
||||
sChoice.m_pChoiceString = pParticleSystem->GetName();
|
||||
list.AddToTail( sChoice );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Populate element choice lists
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CPetDoc::GetElementChoiceList( const char *pChoiceListType, CDmElement *pElement,
|
||||
const char *pAttributeName, bool bArrayElement, ElementChoiceList_t &list )
|
||||
{
|
||||
if ( !Q_stricmp( pChoiceListType, "allelements" ) )
|
||||
{
|
||||
AddElementsRecursively( m_hRoot, list );
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( !Q_stricmp( pChoiceListType, "particleSystemDefinitions" ) )
|
||||
{
|
||||
CDmrParticleSystemList particleSystemList( GetParticleSystemDefinitionList() );
|
||||
|
||||
int nCount = particleSystemList.Count();
|
||||
for ( int i = 0; i < nCount; ++i )
|
||||
{
|
||||
CDmeParticleSystemDefinition *pParticleSystem = particleSystemList[ i ];
|
||||
ElementChoice_t sChoice;
|
||||
sChoice.m_pValue = pParticleSystem;
|
||||
sChoice.m_pChoiceString = pParticleSystem->GetName();
|
||||
list.AddToTail( sChoice );
|
||||
}
|
||||
return ( nCount > 0 );
|
||||
}
|
||||
|
||||
// by default, try to treat the choice list type as a Dme element type
|
||||
AddElementsRecursively( m_hRoot, list, pChoiceListType );
|
||||
|
||||
return list.Count() > 0;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Called when data changes
|
||||
//-----------------------------------------------------------------------------
|
||||
void CPetDoc::OnDataChanged( const char *pReason, int nNotifySource, int nNotifyFlags )
|
||||
{
|
||||
SetDirty( nNotifyFlags & NOTIFY_SETDIRTYFLAG ? true : false );
|
||||
m_pCallback->OnDocChanged( pReason, nNotifySource, nNotifyFlags );
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef PETDOC_H
|
||||
#define PETDOC_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
#include "dme_controls/inotifyui.h"
|
||||
#include "datamodel/dmehandle.h"
|
||||
#include "datamodel/dmelement.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Forward declarations
|
||||
//-----------------------------------------------------------------------------
|
||||
class IPetDocCallback;
|
||||
class CPetDoc;
|
||||
class CDmeParticleSystemDefinition;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// The file format for particle system definitions
|
||||
//-----------------------------------------------------------------------------
|
||||
#define PET_FILE_FORMAT "pcf"
|
||||
|
||||
|
||||
typedef CDmrElementArray<CDmeParticleSystemDefinition> CDmrParticleSystemList;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Contains all editable state
|
||||
//-----------------------------------------------------------------------------
|
||||
class CPetDoc : public IDmNotify, CBaseElementPropertiesChoices
|
||||
{
|
||||
public:
|
||||
CPetDoc( IPetDocCallback *pCallback );
|
||||
~CPetDoc();
|
||||
|
||||
// Inherited from INotifyUI
|
||||
virtual void NotifyDataChanged( const char *pReason, int nNotifySource, int nNotifyFlags );
|
||||
virtual bool GetIntChoiceList( const char *pChoiceListType, CDmElement *pElement,
|
||||
const char *pAttributeName, bool bArrayElement, IntChoiceList_t &list );
|
||||
|
||||
// Sets/Gets the file name
|
||||
const char *GetFileName();
|
||||
void SetFileName( const char *pFileName );
|
||||
|
||||
// Dirty bits (has it changed since the last time it was saved?)
|
||||
void SetDirty( bool bDirty );
|
||||
bool IsDirty() const;
|
||||
|
||||
// Creates a new document
|
||||
void CreateNew();
|
||||
|
||||
// Saves/loads from file
|
||||
bool LoadFromFile( const char *pFileName );
|
||||
void SaveToFile( );
|
||||
|
||||
// Returns the root object
|
||||
CDmElement *GetRootObject();
|
||||
|
||||
// Returns the root object fileid
|
||||
DmFileId_t GetFileId();
|
||||
|
||||
// Called when data changes (see INotifyUI for flags)
|
||||
void OnDataChanged( const char *pReason, int nNotifySource, int nNotifyFlags );
|
||||
|
||||
// Returns the particle system definition list
|
||||
CDmAttribute *GetParticleSystemDefinitionList();
|
||||
|
||||
// add a new definition we've created
|
||||
void AddNewParticleSystemDefinition( CDmeParticleSystemDefinition *pNew,
|
||||
CUndoScopeGuard &Guard );
|
||||
|
||||
// Adds a new particle system definition
|
||||
CDmeParticleSystemDefinition *AddNewParticleSystemDefinition( const char *pName );
|
||||
|
||||
// Deletes a particle system definition
|
||||
void DeleteParticleSystemDefinition( CDmeParticleSystemDefinition *pParticleSystem );
|
||||
|
||||
// find particle system def by name
|
||||
CDmeParticleSystemDefinition *FindParticleSystemDefinition( const char *pName );
|
||||
|
||||
// Replace any particle system with the same name as the passed-in definition
|
||||
// with the passed-in definition
|
||||
void ReplaceParticleSystemDefinition( CDmeParticleSystemDefinition *pParticleSystem );
|
||||
|
||||
// Does a particle system exist already?
|
||||
bool IsParticleSystemDefined( const char *pName );
|
||||
|
||||
// For element 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 );
|
||||
virtual bool GetElementChoiceList( const char *pChoiceListType, CDmElement *pElement,
|
||||
const char *pAttributeName, bool bArrayElement, ElementChoiceList_t &list );
|
||||
|
||||
// Updates a specific particle defintion
|
||||
void UpdateParticleDefinition( CDmeParticleSystemDefinition *pDef );
|
||||
|
||||
// Update all particle definitions
|
||||
void UpdateAllParticleSystems( );
|
||||
|
||||
private:
|
||||
// Creates the root element
|
||||
bool CreateRootElement();
|
||||
|
||||
IPetDocCallback *m_pCallback;
|
||||
CDmeHandle< CDmElement > m_hRoot;
|
||||
char m_pFileName[MAX_PATH];
|
||||
bool m_bDirty;
|
||||
};
|
||||
|
||||
|
||||
#endif // PETDOC_H
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,209 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: P.E.T. (Particle Editing Tool); main UI smarts class
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#ifndef PETTOOL_H
|
||||
#define PETTOOL_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "tier0/platform.h"
|
||||
#include "toolutils/basetoolsystem.h"
|
||||
#include "toolutils/recentfilelist.h"
|
||||
#include "toolutils/toolmenubar.h"
|
||||
#include "toolutils/toolswitchmenubutton.h"
|
||||
#include "toolutils/tooleditmenubutton.h"
|
||||
#include "toolutils/toolfilemenubutton.h"
|
||||
#include "toolutils/toolmenubutton.h"
|
||||
#include "datamodel/dmelement.h"
|
||||
#include "datamodel/dmehandle.h"
|
||||
#include "toolframework/ienginetool.h"
|
||||
#include "toolutils/enginetools_int.h"
|
||||
#include "toolutils/savewindowpositions.h"
|
||||
#include "toolutils/toolwindowfactory.h"
|
||||
#include "movieobjects/dmeparticlesystemdefinition.h"
|
||||
#include "particles/particles.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Forward declarations
|
||||
//-----------------------------------------------------------------------------
|
||||
class CDmElement;
|
||||
class CPetDoc;
|
||||
class CParticleSystemPropertiesContainer;
|
||||
class CParticleSystemDefinitionBrowser;
|
||||
class CParticleSystemPreviewPanel;
|
||||
class CDmeParticleSystemDefinition;
|
||||
enum ParticleFunctionType_t;
|
||||
|
||||
namespace vgui
|
||||
{
|
||||
class Panel;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Allows the doc to call back into the CommEdit editor tool
|
||||
//-----------------------------------------------------------------------------
|
||||
abstract_class IPetDocCallback
|
||||
{
|
||||
public:
|
||||
// Called by the doc when the data changes
|
||||
virtual void OnDocChanged( const char *pReason, int nNotifySource, int nNotifyFlags ) = 0;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Global methods of the commedit tool
|
||||
//-----------------------------------------------------------------------------
|
||||
abstract_class IPetTool
|
||||
{
|
||||
public:
|
||||
// Gets at the rool panel (for modal dialogs)
|
||||
virtual vgui::Panel *GetRootPanel() = 0;
|
||||
|
||||
// Gets the registry name (for saving settings)
|
||||
virtual const char *GetRegistryName() = 0;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Implementation of the CommEdit tool
|
||||
//-----------------------------------------------------------------------------
|
||||
class CPetTool : public CBaseToolSystem, public IFileMenuCallbacks, public IPetDocCallback, public IPetTool
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CPetTool, CBaseToolSystem );
|
||||
|
||||
public:
|
||||
CPetTool();
|
||||
|
||||
// Inherited from IToolSystem
|
||||
virtual const char *GetToolName() { return "Particle Editor"; }
|
||||
virtual bool Init( );
|
||||
virtual void Shutdown();
|
||||
virtual bool CanQuit();
|
||||
virtual void OnToolActivate();
|
||||
virtual void OnToolDeactivate();
|
||||
virtual void Think( bool finalTick );
|
||||
|
||||
// Inherited from IFileMenuCallbacks
|
||||
virtual int GetFileMenuItemsEnabled( );
|
||||
virtual void AddRecentFilesToMenu( vgui::Menu *menu );
|
||||
virtual bool GetPerforceFileName( char *pFileName, int nMaxLen );
|
||||
|
||||
// Inherited from IPetDocCallback
|
||||
virtual void OnDocChanged( const char *pReason, int nNotifySource, int nNotifyFlags );
|
||||
virtual vgui::Panel *GetRootPanel() { return this; }
|
||||
|
||||
// Inherited from CBaseToolSystem
|
||||
virtual vgui::HScheme GetToolScheme();
|
||||
virtual vgui::Menu *CreateActionMenu( vgui::Panel *pParent );
|
||||
virtual void OnCommand( const char *cmd );
|
||||
virtual const char *GetRegistryName() { return "PetTool"; }
|
||||
virtual const char *GetBindingsContextFile() { return "cfg/Pet.kb"; }
|
||||
virtual vgui::MenuBar *CreateMenuBar( CBaseToolSystem *pParent );
|
||||
|
||||
MESSAGE_FUNC( Save, "OnSave" );
|
||||
void SaveAndTest();
|
||||
|
||||
public:
|
||||
MESSAGE_FUNC( OnRestartLevel, "RestartLevel" );
|
||||
MESSAGE_FUNC( OnNew, "OnNew" );
|
||||
MESSAGE_FUNC( OnOpen, "OnOpen" );
|
||||
MESSAGE_FUNC( OnSaveAs, "OnSaveAs" );
|
||||
MESSAGE_FUNC( OnClose, "OnClose" );
|
||||
MESSAGE_FUNC( OnCloseNoSave, "OnCloseNoSave" );
|
||||
MESSAGE_FUNC( OnMarkNotDirty, "OnMarkNotDirty" );
|
||||
MESSAGE_FUNC( OnExit, "OnExit" );
|
||||
MESSAGE_FUNC( OnCopy, "OnCopy" );
|
||||
MESSAGE_FUNC( OnPaste, "OnPaste" );
|
||||
|
||||
// Commands related to the edit menu
|
||||
void OnDescribeUndo();
|
||||
|
||||
// Methods related to the view menu
|
||||
MESSAGE_FUNC( OnToggleProperties, "OnToggleProperties" );
|
||||
MESSAGE_FUNC( OnToggleParticleSystemBrowser, "OnToggleParticleSystemBrowser" );
|
||||
MESSAGE_FUNC( OnToggleParticlePreview, "OnToggleParticlePreview" );
|
||||
MESSAGE_FUNC( OnDefaultLayout, "OnDefaultLayout" );
|
||||
|
||||
// Keybindings
|
||||
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 );
|
||||
KEYBINDING_FUNC_NODECLARE( edit_copy, KEY_C, vgui::MODIFIER_CONTROL, OnCopy, "#edit_copy_help", 0 );
|
||||
KEYBINDING_FUNC_NODECLARE( edit_paste, KEY_V, vgui::MODIFIER_CONTROL, OnPaste, "#edit_paste_help", 0 );
|
||||
|
||||
void PerformNew();
|
||||
void OpenFileFromHistory( int slot );
|
||||
void OpenSpecificFile( const char *pFileName );
|
||||
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 );
|
||||
virtual void OnFileOperationCompleted( const char *pFileType, bool bWroteFile, vgui::FileOpenStateMachine::CompletionState_t state, KeyValues *pContextKeyValues );
|
||||
|
||||
// returns the document
|
||||
CPetDoc *GetDocument();
|
||||
|
||||
// Gets at tool windows
|
||||
CParticleSystemPropertiesContainer *GetProperties();
|
||||
CParticleSystemDefinitionBrowser *GetParticleSystemDefinitionBrowser();
|
||||
CParticleSystemPreviewPanel *GetParticlePreview();
|
||||
|
||||
void SetCurrentParticleSystem( CDmeParticleSystemDefinition *pParticleSystem, bool bForceBrowserSelection = true );
|
||||
CDmeParticleSystemDefinition* GetCurrentParticleSystem( void );
|
||||
|
||||
private:
|
||||
// Creates a new document
|
||||
void NewDocument( );
|
||||
|
||||
// Loads up a new document
|
||||
bool LoadDocument( const char *pDocName );
|
||||
|
||||
// Updates the menu bar based on the current file
|
||||
void UpdateMenuBar( );
|
||||
|
||||
virtual const char *GetLogoTextureName();
|
||||
|
||||
// Creates, destroys tools
|
||||
void CreateTools( CPetDoc *doc );
|
||||
void DestroyTools();
|
||||
|
||||
// Initializes the tools
|
||||
void InitTools();
|
||||
|
||||
// Shows, toggles tool windows
|
||||
void ToggleToolWindow( Panel *tool, char const *toolName );
|
||||
void ShowToolWindow( Panel *tool, char const *toolName, bool visible );
|
||||
|
||||
// Kills all tool windows
|
||||
void DestroyToolContainers();
|
||||
|
||||
private:
|
||||
// Document
|
||||
CPetDoc *m_pDoc;
|
||||
|
||||
// The menu bar
|
||||
CToolFileMenuBar *m_pMenuBar;
|
||||
|
||||
// Element properties for editing material
|
||||
vgui::DHANDLE< CParticleSystemPropertiesContainer > m_hProperties;
|
||||
|
||||
// The entity report
|
||||
vgui::DHANDLE< CParticleSystemDefinitionBrowser > m_hParticleSystemDefinitionBrowser;
|
||||
|
||||
// Particle preview window
|
||||
vgui::DHANDLE< CParticleSystemPreviewPanel > m_hParticlePreview;
|
||||
|
||||
// The currently viewed entity
|
||||
CDmeHandle< CDmeParticleSystemDefinition > m_hCurrentParticleSystem;
|
||||
|
||||
// Separate undo context for the act busy tool
|
||||
CToolWindowFactory< ToolWindow > m_ToolWindowFactory;
|
||||
};
|
||||
|
||||
extern CPetTool *g_pPetTool;
|
||||
|
||||
#endif // PETTOOL_H
|
||||
Reference in New Issue
Block a user