From 3bf9df6b2785fa6d951086978a3e66f49427166a Mon Sep 17 00:00:00 2001 From: FluorescentCIAAfricanAmerican <0934gj3049fk@protonmail.com> Date: Wed, 22 Apr 2020 12:56:21 -0400 Subject: 1 --- tools/toolutils/basepropertiescontainer.cpp | 47 +++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 tools/toolutils/basepropertiescontainer.cpp (limited to 'tools/toolutils/basepropertiescontainer.cpp') diff --git a/tools/toolutils/basepropertiescontainer.cpp b/tools/toolutils/basepropertiescontainer.cpp new file mode 100644 index 0000000..50891a9 --- /dev/null +++ b/tools/toolutils/basepropertiescontainer.cpp @@ -0,0 +1,47 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//============================================================================= + +#include "toolutils/basepropertiescontainer.h" +#include "tier1/KeyValues.h" + +CBasePropertiesContainer::CBasePropertiesContainer( vgui::Panel *parent, IDmNotify *pNotify, CDmeEditorTypeDictionary *pDict /*=NULL*/ ) + : BaseClass( parent, pNotify, NULL, true, pDict ) +{ + SetDropEnabled( true ); +} + +bool CBasePropertiesContainer::IsDroppable( CUtlVector< KeyValues * >& msglist ) +{ + if ( msglist.Count() != 1 ) + return false; + + KeyValues *data = msglist[ 0 ]; + CDmElement *ptr = reinterpret_cast< CDmElement * >( g_pDataModel->GetElement( DmElementHandle_t( data->GetInt( "dmeelement", DMELEMENT_HANDLE_INVALID ) ) ) ); + if ( !ptr ) + return false; + + if ( ptr == GetObject() ) + return false; + + return true; +} + +void CBasePropertiesContainer::OnPanelDropped( CUtlVector< KeyValues * >& msglist ) +{ + if ( msglist.Count() != 1 ) + return; + + KeyValues *data = msglist[ 0 ]; + CDmElement *ptr = reinterpret_cast< CDmElement * >( g_pDataModel->GetElement( DmElementHandle_t( data->GetInt( "dmeelement", DMELEMENT_HANDLE_INVALID ) ) ) ); + if ( !ptr ) + return; + + // Already browsing + if ( ptr == GetObject() ) + return; + + SetObject( ptr ); +} \ No newline at end of file -- cgit v1.2.3