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

View File

@@ -0,0 +1,58 @@
// ----------------------------------------- //
// File generated by VPC //
// ----------------------------------------- //
Source file: F:\csgo_64\cstrike15_src\common\debug_dll_check.cpp
Debug output file: F:\csgo_64\cstrike15_src\common\debug_dll_check.cpp
Release output file: F:\csgo_64\cstrike15_src\common\debug_dll_check.cpp
Containing unity file:
PCH file:
Source file: F:\csgo_64\cstrike15_src\public\interpolatortypes.cpp
Debug output file: F:\csgo_64\cstrike15_src\public\interpolatortypes.cpp
Release output file: F:\csgo_64\cstrike15_src\public\interpolatortypes.cpp
Containing unity file:
PCH file:
Source file: F:\csgo_64\cstrike15_src\public\tier0\memoverride.cpp
Debug output file: F:\csgo_64\cstrike15_src\public\tier0\memoverride.cpp
Release output file: F:\csgo_64\cstrike15_src\public\tier0\memoverride.cpp
Containing unity file:
PCH file:
Source file: F:\csgo_64\cstrike15_src\tools\pet\particlesystemdefinitionbrowser.cpp
Debug output file: F:\csgo_64\cstrike15_src\tools\pet\particlesystemdefinitionbrowser.cpp
Release output file: F:\csgo_64\cstrike15_src\tools\pet\particlesystemdefinitionbrowser.cpp
Containing unity file:
PCH file:
Source file: F:\csgo_64\cstrike15_src\tools\pet\particlesystempropertiescontainer.cpp
Debug output file: F:\csgo_64\cstrike15_src\tools\pet\particlesystempropertiescontainer.cpp
Release output file: F:\csgo_64\cstrike15_src\tools\pet\particlesystempropertiescontainer.cpp
Containing unity file:
PCH file:
Source file: F:\csgo_64\cstrike15_src\tools\pet\petdoc.cpp
Debug output file: F:\csgo_64\cstrike15_src\tools\pet\petdoc.cpp
Release output file: F:\csgo_64\cstrike15_src\tools\pet\petdoc.cpp
Containing unity file:
PCH file:
Source file: F:\csgo_64\cstrike15_src\tools\pet\pettool.cpp
Debug output file: F:\csgo_64\cstrike15_src\tools\pet\pettool.cpp
Release output file: F:\csgo_64\cstrike15_src\tools\pet\pettool.cpp
Containing unity file:
PCH file:
Source file: F:\csgo_64\cstrike15_src\public\registry.cpp
Debug output file: F:\csgo_64\cstrike15_src\public\registry.cpp
Release output file: F:\csgo_64\cstrike15_src\public\registry.cpp
Containing unity file:
PCH file:
Source file: F:\csgo_64\cstrike15_src\public\vgui_controls\vgui_controls.cpp
Debug output file: F:\csgo_64\cstrike15_src\public\vgui_controls\vgui_controls.cpp
Release output file: F:\csgo_64\cstrike15_src\public\vgui_controls\vgui_controls.cpp
Containing unity file:
PCH file:

View File

@@ -0,0 +1,513 @@
//===== Copyright © 1996-2005, 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 "matsys_controls/particlepicker.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_pSystemGrid = new CParticleSnapshotGrid( this, "SnapshotGrid" );
m_pSystemGrid->AddActionSignalTarget(this);
CBoxSizer *pBaseSizer = new CBoxSizer( ESLD_HORIZONTAL );
{
CBoxSizer *pDefinitionSizer = new CBoxSizer( ESLD_VERTICAL );
pDefinitionSizer->AddPanel( new Label( this, "ParticleSystemsLabel", "Particle System Definitions:" ), SizerAddArgs_t() );
pDefinitionSizer->AddPanel( m_pSystemGrid, SizerAddArgs_t().Expand( 1.0f ) );
{
CBoxSizer *pBottomRowSizer = new CBoxSizer( ESLD_HORIZONTAL );
pBottomRowSizer->AddPanel( new Button( this, "SaveButton", "Save", this, "save" ), SizerAddArgs_t() );
pBottomRowSizer->AddPanel( new Button( this, "SaveAndTestButton", "Save and Test", this, "SaveAndTest" ), SizerAddArgs_t() );
pDefinitionSizer->AddSizer( pBottomRowSizer, SizerAddArgs_t() );
}
pBaseSizer->AddSizer( pDefinitionSizer, SizerAddArgs_t().Expand( 1.0f ) );
}
{
CBoxSizer *pButtonColSizer = new CBoxSizer( ESLD_VERTICAL );
m_pCreateButton = new Button( this, "CreateButton", "Create", this, "Create" );
pButtonColSizer->AddPanel( m_pCreateButton, SizerAddArgs_t() );
m_pDeleteButton = new Button( this, "DeleteButton", "Delete", this, "Delete" );
m_pDeleteButton->SetEnabled(false);
pButtonColSizer->AddPanel( m_pDeleteButton, SizerAddArgs_t() );
m_pCopyButton = new Button( this, "CopyButton", "Duplicate", this, "Copy" );
m_pCopyButton->SetEnabled(false);
pButtonColSizer->AddPanel( m_pCopyButton, SizerAddArgs_t() );
pBaseSizer->AddSizer( pButtonColSizer, SizerAddArgs_t() );
}
SetSizer( pBaseSizer );
UpdateParticleSystemList();
}
CParticleSystemDefinitionBrowser::~CParticleSystemDefinitionBrowser()
{
SaveUserConfig();
}
//-----------------------------------------------------------------------------
// Gets the ith selected particle system
//-----------------------------------------------------------------------------
CDmeParticleSystemDefinition* CParticleSystemDefinitionBrowser::GetSelectedParticleSystem( int i )
{
if ( i < 0 || i >= m_pSystemGrid->GetSelectedSystemCount() )
return NULL;
int iSel = m_pSystemGrid->GetSelectedSystemId(i);
return m_pDoc->GetParticleSystem(iSel);
}
//-----------------------------------------------------------------------------
// Purpose: Deletes the marked objects.
//-----------------------------------------------------------------------------
void CParticleSystemDefinitionBrowser::DeleteParticleSystems()
{
{
// This is undoable
CAppUndoScopeGuard guard( NOTIFY_SETDIRTYFLAG|NOTIFY_FLAG_PARTICLESYS_ADDED_OR_REMOVED, "Delete Particle Systems", "Delete Particle Systems" );
//
// Build a list of objects to delete.
//
CUtlVector< CDmeParticleSystemDefinition* > itemsToDelete;
int nCount = m_pSystemGrid->GetSelectedSystemCount();
for (int i = 0; i < nCount; i++)
{
CDmeParticleSystemDefinition *pParticleSystem = GetSelectedParticleSystem( i );
if ( pParticleSystem )
{
itemsToDelete.AddToTail( pParticleSystem );
}
}
m_pSystemGrid->DeselectAll();
nCount = itemsToDelete.Count();
for ( int i = 0; i < nCount; ++i )
{
m_pDoc->DeleteParticleSystemDefinition( itemsToDelete[i] );
}
g_pPetTool->SetCurrentParticleSystem( NULL, true );
}
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CParticleSystemDefinitionBrowser::OnKeyCodeTyped( vgui::KeyCode code )
{
if ( code == KEY_DELETE )
{
DeleteParticleSystems();
}
else
{
BaseClass::OnKeyCodeTyped( code );
}
}
//-----------------------------------------------------------------------------
// Called when the selection changes
//-----------------------------------------------------------------------------
void CParticleSystemDefinitionBrowser::UpdateParticleSystemSelection()
{
if ( m_pSystemGrid->GetSelectedSystemCount() == 1 )
{
g_pPetTool->SetCurrentParticleSystem( m_pDoc->GetParticleSystem( m_pSystemGrid->GetSelectedSystemId(0) ), false );
}
else
{
g_pPetTool->SetCurrentParticleSystem( NULL, false );
}
}
void CParticleSystemDefinitionBrowser::OnParticleSystemSelectionChanged( )
{
UpdateParticleSystemSelection();
bool bAnySelected = ( m_pSystemGrid->GetSelectedSystemCount() > 0 );
m_pDeleteButton->SetEnabled( bAnySelected );
m_pCopyButton->SetEnabled( bAnySelected );
}
//-----------------------------------------------------------------------------
// Select a particular node
//-----------------------------------------------------------------------------
void CParticleSystemDefinitionBrowser::SelectParticleSystem( CDmeParticleSystemDefinition *pFind )
{
for ( int i = 0; i < m_pDoc->GetParticleSystemCount(); ++i )
{
if ( m_pDoc->GetParticleSystem(i) == pFind )
{
m_pSystemGrid->SelectId( i, false, false );
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_one" ) || pKeyValues->FindKey( "copy_many" ) )
{
int nCount = m_pSystemGrid->GetSelectedSystemCount();
if ( nCount == 1 )
{
CDmeParticleSystemDefinition *pParticleSystem = GetSelectedParticleSystem( 0 );
CDmeParticleSystemDefinition * pNew = NULL;
{
CAppUndoScopeGuard guard( NOTIFY_SETDIRTYFLAG|NOTIFY_FLAG_PARTICLESYS_ADDED_OR_REMOVED, "Duplicate One Particle System", "Duplicate One Particle System" );
pNew = CastElement<CDmeParticleSystemDefinition>( pParticleSystem->Copy( ) );
pNew->SetName( pText );
m_pDoc->AddNewParticleSystemDefinition( pNew, guard );
}
g_pPetTool->SetCurrentParticleSystem( pNew );
}
else if ( nCount > 1 )
{
CAppUndoScopeGuard guard( NOTIFY_SETDIRTYFLAG|NOTIFY_FLAG_PARTICLESYS_ADDED_OR_REMOVED, "Duplicate Multiple Particle Systems", "Duplicate Multiple Particle Systems" );
CUtlVector<CDmeParticleSystemDefinition*> pNewSystems;
for ( int i = 0; i < nCount; ++i )
{
CDmeParticleSystemDefinition *pParticleSystem = GetSelectedParticleSystem( i );
CDmeParticleSystemDefinition *pNew = NULL;
CUtlString newName = pParticleSystem->GetName();
newName += pText;
pNew = CastElement<CDmeParticleSystemDefinition>( pParticleSystem->Copy( ) );
pNew->SetName( newName.Get() );
pNewSystems.AddToTail(pNew);
}
Assert( pNewSystems.Count() == nCount );
for ( int i = 0; i < nCount; ++i )
{
m_pDoc->AddNewParticleSystemDefinition( pNewSystems[i], guard );
}
g_pPetTool->SetCurrentParticleSystem( NULL );
}
}
}
//-----------------------------------------------------------------------------
// Copy to clipboard
//-----------------------------------------------------------------------------
void CParticleSystemDefinitionBrowser::OnCopy( )
{
int nCount = m_pSystemGrid->GetSelectedSystemCount();
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( PARTICLE_CLIPBOARD_DEFINITION_STR, (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::PasteOperator( CUndoScopeGuard& guard, CDmeParticleFunction *pFunc )
{
int nCount = m_pSystemGrid->GetSelectedSystemCount();
for ( int i = 0; i < nCount; ++i )
{
CDmeParticleSystemDefinition *pParticleSystem = GetSelectedParticleSystem( i );
pParticleSystem->AddCopyOfOperator( pFunc );
}
}
void CParticleSystemDefinitionBrowser::PasteDefinitionBody( CUndoScopeGuard& guard, CDmeParticleSystemDefinition *pDef )
{
int nCount = m_pSystemGrid->GetSelectedSystemCount();
for ( int i = 0; i < nCount; ++i )
{
CDmeParticleSystemDefinition *pParticleSystem = GetSelectedParticleSystem( i );
pParticleSystem->OverrideAttributesFromOtherDefinition( pDef );
}
}
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 )
{
CDmeParticleSystemDefinition *pDef = ReadParticleClassFromKV<CDmeParticleSystemDefinition>( list[i], PARTICLE_CLIPBOARD_DEFINITION_STR );
if ( pDef )
{
ReplaceDef_r( guard, pDef );
bRefreshAll = true;
continue;
}
CDmeParticleFunction *pFunc = ReadParticleClassFromKV<CDmeParticleFunction>( list[i], PARTICLE_CLIPBOARD_FUNCTIONS_STR );
if ( pFunc )
{
PasteOperator( guard, pFunc );
bRefreshAll = true;
continue;
}
pDef = ReadParticleClassFromKV<CDmeParticleSystemDefinition>( list[i], PARTICLE_CLIPBOARD_DEF_BODY_STR );
if ( pDef )
{
PasteDefinitionBody( guard, pDef );
bRefreshAll = true;
continue;
}
}
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" ) )
{
if ( m_pSystemGrid->GetSelectedSystemCount() == 1 )
{
CUtlString newName = m_pSystemGrid->GetSystemName(m_pSystemGrid->GetSelectedSystemId(0));
newName += "_copy";
vgui::InputDialog *pInputDialog = new vgui::InputDialog( g_pPetTool->GetRootPanel(), "Enter Duplicate System Name", "Name:", newName.Get() );
pInputDialog->SetSmallCaption( true );
pInputDialog->SetMultiline( false );
pInputDialog->AddActionSignalTarget( this );
pInputDialog->DoModal( new KeyValues("copy_one") );
}
else if ( m_pSystemGrid->GetSelectedSystemCount() > 1 )
{
vgui::InputDialog *pInputDialog = new vgui::InputDialog( g_pPetTool->GetRootPanel(), "Enter Suffix for New Systems", "Suffix:", "_copy" );
pInputDialog->SetSmallCaption( true );
pInputDialog->SetMultiline( false );
pInputDialog->AddActionSignalTarget( this );
pInputDialog->DoModal( new KeyValues("copy_many") );
}
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( bool bRetainSelection )
{
/////////////////////////
// build a list of previously selected systems
CUtlVector< CUtlString > selectedItems;
if ( bRetainSelection )
{
int nCount = m_pSystemGrid->GetSelectedSystemCount();
for ( int i = 0; i < nCount; ++i )
{
CDmeParticleSystemDefinition *pParticleSystem = GetSelectedParticleSystem( i );
if ( pParticleSystem )
{
selectedItems.AddToTail( pParticleSystem->GetName() );
}
}
}
/////////////////////////
// now go nuts
const CDmrParticleSystemList particleSystemList = m_pDoc->GetParticleSystemDefinitionList();
if ( !particleSystemList.IsValid() )
{
m_pSystemGrid->SetParticleList( CUtlVector<const char *>() );
return;
}
CUtlVector<const char *> systemNames;
CUtlVector<int> selectionIndicies;
/////////////////////////
// populate the new list
for ( int i = 0; i < particleSystemList.Count(); ++i )
{
CDmeParticleSystemDefinition *pParticleSystem = particleSystemList[i];
if ( !pParticleSystem )
continue;
systemNames.AddToTail( pParticleSystem->GetName() );
// see if the system was previously selected
for ( int s = 0; s < selectedItems.Count(); ++s )
{
if( !V_strcmp(pParticleSystem->GetName(), selectedItems[s]) )
{
selectionIndicies.AddToTail(i);
}
}
}
m_pSystemGrid->SetParticleList( systemNames );
/////////////////////////
// reselect any identified systems
if ( bRetainSelection )
{
for ( int i = 0; i < selectionIndicies.Count(); ++i )
{
m_pSystemGrid->SelectId( selectionIndicies[i], true, false );
}
}
}

View File

@@ -0,0 +1,93 @@
//===== Copyright © 1996-2005, 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"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CPetDoc;
class CPetTool;
class CDmeParticleSystemDefinition;
class CUndoScopeGuard;
class CParticleSnapshotGrid;
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 );
// Methods related to updating the listpanel
void UpdateParticleSystemList( bool bRetainSelection = true );
// Select a particular node
void SelectParticleSystem( CDmeParticleSystemDefinition *pParticleSystem );
// paste.
void PasteFromClipboard();
private:
MESSAGE_FUNC( OnCopy, "OnCopy" );
KEYBINDING_FUNC_NODECLARE( edit_copy, KEY_C, vgui::MODIFIER_CONTROL, OnCopy, "#edit_copy_help", 0 );
MESSAGE_FUNC_PARAMS( OnInputCompleted, "InputCompleted", kv );
MESSAGE_FUNC( OnParticleSystemSelectionChanged, "ParticleSystemSelectionChanged" );
void ReplaceDef_r( CUndoScopeGuard& guard, CDmeParticleSystemDefinition *pDef );
void PasteOperator( CUndoScopeGuard& guard, class CDmeParticleFunction *pDef );
void PasteDefinitionBody( CUndoScopeGuard& guard, CDmeParticleSystemDefinition *pDef );
// Gets the selected particle system
CDmeParticleSystemDefinition* GetSelectedParticleSystem( int nIdx );
// Called when the selection changes
void UpdateParticleSystemSelection();
// Deletes selected particle systems
void DeleteParticleSystems();
// Shows the most recent selected object in properties window
void OnProperties();
CPetDoc *m_pDoc;
CParticleSnapshotGrid *m_pSystemGrid;
vgui::Button *m_pCreateButton;
vgui::Button *m_pDeleteButton;
vgui::Button *m_pCopyButton;
};
#endif // PARTICLESYSTEMDEFINITIONBROWSER_H

View File

@@ -0,0 +1,73 @@
//===== Copyright © 1996-2005, 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 );
}
}

View File

@@ -0,0 +1,45 @@
//===== Copyright © 1996-2005, 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

64
tools/pet/pet.vpc Normal file
View File

@@ -0,0 +1,64 @@
//-----------------------------------------------------------------------------
// PET.VPC
//
// Project Script
//-----------------------------------------------------------------------------
$Macro SRCDIR "..\.."
$Macro OUTBINDIR "$SRCDIR\..\game\bin\tools"
$Include "$SRCDIR\vpc_scripts\source_dll_win32_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"
{
$File "$SRCDIR\lib\public\bonesetup.lib"
$File "$SRCDIR\lib\public\datamodel.lib"
$File "$SRCDIR\lib\public\dme_controls.lib"
$File "$SRCDIR\lib\public\dmserializers.lib"
$File "$SRCDIR\lib\public\dmxloader.lib"
$File "$SRCDIR\lib\public\mathlib.lib"
$File "$SRCDIR\lib\public\matsys_controls.lib"
$File "$SRCDIR\lib\public\movieobjects.lib"
$File "$SRCDIR\lib\public\particles.lib"
$File "$SRCDIR\lib\public\tier2.lib"
$File "$SRCDIR\lib\public\tier3.lib"
$File "$SRCDIR\lib\public\toolutils.lib"
$File "$SRCDIR\lib\public\vgui_controls.lib"
}
}

View File

@@ -0,0 +1,13 @@
"vpc_cache"
{
"CacheVersion" "1"
"win32"
{
"CRCFile" "pet.vcxproj.vpc_crc"
"OutputFiles"
{
"0" "pet.vcxproj"
"1" "pet.vcxproj.filters"
}
}
}

616
tools/pet/petdoc.cpp Normal file
View File

@@ -0,0 +1,616 @@
//====== Copyright © 1996-2005, 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/sheeteditorpanel.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;
}
if ( !Q_stricmp( pChoiceListType, "particlefield_rotation" ) )
{
for ( int i = 0; i < MAX_PARTICLE_ATTRIBUTES; ++i )
{
if ( ( ATTRIBUTES_WHICH_ARE_ROTATION & ( 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_activity" ) )
{
for ( int i = 0; i < g_pParticleSystemMgr->Query()->GetActivityCount(); ++i )
{
const char *pName = g_pParticleSystemMgr->Query()->GetActivityNameFromIndex( 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;
const char *pGame = Q_stristr( pFileName, "\\game\\" );
if ( !pGame )
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;
// remove any null functions (eg. if a child has a bad id)
CDmrParticleSystemList defArray( m_hRoot, "particleSystemDefinitions" );
int nSystems = defArray.Count();
for ( int i = 0; i < nSystems; ++i )
{
defArray[i]->RemoveInvalidFunctions();
}
SetDirty( false );
return true;
}
void CPetDoc::SaveToFile( )
{
if ( m_hRoot.Get() && m_pFileName && m_pFileName[0] )
{
CDisableUndoScopeGuard guard;
// make a copy of the definition tree
CDmElement* pRootCopy = m_hRoot->Copy( TD_ALL );
CDmrParticleSystemList defCopyArray( pRootCopy, "particleSystemDefinitions" );
// compact the copied definitions
int nSystems = defCopyArray.Count();
for ( int i = 0; i < nSystems; ++i )
{
defCopyArray[i]->Compact();
}
// save the copy, and kill it
g_pDataModel->SaveToFile( m_pFileName, NULL, "binary", PET_FILE_FORMAT, pRootCopy );
DestroyElement( pRootCopy, TD_ALL );
}
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();
}
int CPetDoc::GetParticleSystemCount( )
{
CDmrElementArray<> array( m_hRoot, "particleSystemDefinitions" );
return array.Count();
}
CDmeParticleSystemDefinition *CPetDoc::GetParticleSystem( int nIndex )
{
CDmrParticleSystemList array( m_hRoot, "particleSystemDefinitions" );
if( array.IsValid() && nIndex >= 0 && nIndex < array.Count() )
{
return array[nIndex];
}
else
{
return NULL;
}
}
void CPetDoc::AddNewParticleSystemDefinition( CDmeParticleSystemDefinition *pNew, CUndoScopeGuard &Guard )
{
CDmrParticleSystemList particleSystemList( GetParticleSystemDefinitionList() );
particleSystemList.AddToTail( pNew );
Guard.Release();
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|NOTIFY_FLAG_PARTICLESYS_ADDED_OR_REMOVED, "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|NOTIFY_FLAG_PARTICLESYS_ADDED_OR_REMOVED, "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;
}
//-----------------------------------------------------------------------------
// Replaces 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 );
}

124
tools/pet/petdoc.h Normal file
View File

@@ -0,0 +1,124 @@
//===== Copyright © 1996-2005, 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();
int GetParticleSystemCount( );
CDmeParticleSystemDefinition *GetParticleSystem( int nIndex );
// 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

1453
tools/pet/pettool.cpp Normal file

File diff suppressed because it is too large Load Diff

223
tools/pet/pettool.h Normal file
View File

@@ -0,0 +1,223 @@
//====== Copyright © 1996-2005, 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 CSheetEditorPanel;
class CDmeParticleSystemDefinition;
enum ParticleFunctionType_t;
namespace vgui
{
class Panel;
}
enum
{
NOTIFY_FLAG_PARTICLESYS_ADDED_OR_REMOVED = (1<<NOTIFY_FLAG_FIRST_APPLICATION_BIT)
};
//-----------------------------------------------------------------------------
// 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( const char *pExitMsg );
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();
void PreOperatorsPaste();
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( OnCopySystems, "OnCopySystems" );
MESSAGE_FUNC( OnCopyFunctions, "OnCopyFunctions" );
MESSAGE_FUNC( OnPaste, "OnPaste" );
MESSAGE_FUNC( OnRequestPaste, "RequestPaste" );
// 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( OnToggleSheetEditor, "OnToggleSheetEditor" );
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_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();
// CSheetEditorPanel *GetSheetEditor();
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;
// Sheet editor
// vgui::DHANDLE< CSheetEditorPanel > m_hSheetEditorPanel;
// 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