FORCEINLINE bool operator()( const TWeakObjectPtr< UObject >& Lhs, const TWeakObjectPtr< UObject >& Rhs ) const
	{
		const bool LhsObjectValid = Lhs.IsValid();
		if ( !LhsObjectValid )
		{
			return true;
		}

		const bool RhsObjectValid = Rhs.IsValid();
		if ( !RhsObjectValid )
		{
			return false;
		}

		const UStruct* const PropertyTargetType = Property->GetOwnerStruct();
		const UClass* const LhsClass = Lhs->GetClass();

		if ( !LhsClass->IsChildOf( PropertyTargetType ) )
		{
			return true;
		}

		const UClass* const RhsClass = Rhs->GetClass();

		if ( !RhsClass->IsChildOf( PropertyTargetType ) )
		{
			return false;
		}

		typename UPropertyType::TCppType LhsValue = Property->GetPropertyValue_InContainer(Lhs.Get());
		typename UPropertyType::TCppType RhsValue = Property->GetPropertyValue_InContainer(Rhs.Get());

		return ComparePropertyValue( LhsValue, RhsValue );
	}
Example #2
0
bool FLayers::IsActorValidForLayer( const TWeakObjectPtr< AActor >& Actor )
{
	if( !Actor.IsValid() || Actor->GetClass() == nullptr || Actor->GetWorld() == nullptr)
	{
		return false;
	}

	const bool bIsBuilderBrush			= FActorEditorUtils::IsABuilderBrush(Actor.Get());
	const bool bIsHidden				= ( Actor->GetClass()->GetDefaultObject<AActor>()->bHiddenEd == true );
	const bool bIsInEditorWorld			= ( Actor->GetWorld()->WorldType == EWorldType::Editor );
	const bool bIsValid					= !bIsHidden && !bIsBuilderBrush && bIsInEditorWorld;

	return bIsValid;
}
Example #3
0
void FLayers::RemoveActorFromStats( const TWeakObjectPtr< ULayer >& Layer, const TWeakObjectPtr< AActor >& Actor )
{
	if( !Actor.IsValid() )
	{
		return;
	}

	UClass* ActorClass = Actor->GetClass();

	bool bFoundClassStats = false;
	for (int StatsIndex = 0; StatsIndex < Layer->ActorStats.Num() ; StatsIndex++)
	{
		FLayerActorStats& Stats = Layer->ActorStats[ StatsIndex ];

		if( Stats.Type == ActorClass )
		{
			bFoundClassStats = true;
			--Stats.Total;

			if( Stats.Total == 0 )
			{
				Layer->ActorStats.RemoveAt( StatsIndex );
			}
			break;
		}
	}

	if( bFoundClassStats )
	{
		LayersChanged.Broadcast( ELayersAction::Modify, Layer, TEXT( "ActorStats" ) );
	}
}
Example #4
0
void FLayers::AddActorToStats( const TWeakObjectPtr< ULayer >& Layer, const TWeakObjectPtr< AActor >& Actor )
{
	if( !Actor.IsValid() )
	{
		return;
	}

	UClass* ActorClass = Actor->GetClass();

	bool bFoundClassStats = false;
	for( auto StatsIt = Layer->ActorStats.CreateIterator(); StatsIt; ++StatsIt )
	{
		FLayerActorStats& Stats = *StatsIt;

		if( Stats.Type == ActorClass )
		{
			Stats.Total++;
			bFoundClassStats = true;
			break;
		}
	}

	if( !bFoundClassStats )
	{
		FLayerActorStats NewActorStats;
		NewActorStats.Total = 1;
		NewActorStats.Type = ActorClass;

		Layer->ActorStats.Add( NewActorStats );
	}

	LayersChanged.Broadcast( ELayersAction::Modify, Layer, TEXT( "ActorStats" ) );
}
const FSlateBrush* FClassIconFinder::FindIconForActors(const TArray< TWeakObjectPtr<AActor> >& InActors, UClass*& CommonBaseClass)
{
	// Get the common base class of the selected actors
	const FSlateBrush* CommonIcon = nullptr;
	for( int32 ActorIdx = 0; ActorIdx < InActors.Num(); ++ActorIdx )
	{
		TWeakObjectPtr<AActor> Actor = InActors[ActorIdx];
		UClass* ObjClass = Actor->GetClass();

		if (!CommonBaseClass)
		{
			CommonBaseClass = ObjClass;
		}
		while (!ObjClass->IsChildOf(CommonBaseClass))
		{
			CommonBaseClass = CommonBaseClass->GetSuperClass();
		}

		const FSlateBrush* ActorIcon = FindIconForActor(Actor);

		if (!CommonIcon)
		{
			CommonIcon = ActorIcon;
		}
		if (CommonIcon != ActorIcon)
		{
			CommonIcon = FindIconForClass(CommonBaseClass);
		}
	}

	return CommonIcon;
}
	FORCEINLINE bool operator()(const TWeakObjectPtr<AActor>& A) const
	{
		if (A.IsValid())
		{
			bool IsChild = A->GetClass()->IsChildOf(ClassFilter);
			return Negate ? !IsChild : IsChild;
		}
		
		return true; // Default to removal
	}
TSharedRef< SWidget > SDetailNameArea::BuildObjectNameArea( const TArray< TWeakObjectPtr<UObject> >& SelectedObjects )
{
	// Get the common base class of the selected objects
	UClass* BaseClass = NULL;
	for( int32 ObjectIndex = 0; ObjectIndex < SelectedObjects.Num(); ++ObjectIndex )
	{
		TWeakObjectPtr<UObject> ObjectWeakPtr = SelectedObjects[ObjectIndex];
		if( ObjectWeakPtr.IsValid() )
		{
			UClass* ObjClass = ObjectWeakPtr->GetClass();

			if (!BaseClass)
			{
				BaseClass = ObjClass;
			}

			while (!ObjClass->IsChildOf(BaseClass))
			{
				BaseClass = BaseClass->GetSuperClass();
			}
		}
	}

	TSharedRef< SHorizontalBox > ObjectNameArea = SNew( SHorizontalBox );

	if (BaseClass)
	{
		// Get selection icon based on actor(s) classes and add before the selection label
		const FSlateBrush* ActorIcon = FClassIconFinder::FindIconForClass(BaseClass);

		ObjectNameArea->AddSlot()
		.AutoWidth()
		.HAlign(HAlign_Left)
		.VAlign(VAlign_Center)
		.Padding(0,0,6,0)
		[
			SNew(SImage)
			.Image(ActorIcon)
			.ToolTip(FEditorClassUtils::GetTooltip(BaseClass))
		];
	}


	// Add the selected object(s) type name, along with buttons for either opening C++ code or editing blueprints
	const int32 NumSelectedSurfaces = AssetSelectionUtils::GetNumSelectedSurfaces( GWorld );
	if( SelectedObjects.Num() > 0 )
	{
		if ( bShowActorLabel )
		{
			FEditorWidgetsModule& EdWidgetsModule = FModuleManager::LoadModuleChecked<FEditorWidgetsModule>(TEXT("EditorWidgets"));
			TSharedRef<IObjectNameEditableTextBox> ObjectNameBox = EdWidgetsModule.CreateObjectNameEditableTextBox(SelectedObjects);

			ObjectNameArea->AddSlot()
				.AutoWidth()
				.Padding(0, 0, 3, 0)
				[
					SNew(SBox)
					.WidthOverride(200.0f)
					.VAlign(VAlign_Center)
					[
						ObjectNameBox
					]
				];
		}

		const TWeakObjectPtr< UObject > ObjectWeakPtr = SelectedObjects.Num() == 1 ? SelectedObjects[0] : NULL;
		BuildObjectNameAreaSelectionLabel( ObjectNameArea, ObjectWeakPtr, SelectedObjects.Num() );

		if( bShowLockButton )
		{
			ObjectNameArea->AddSlot()
				.HAlign(HAlign_Right)
				.FillWidth(1.0f)
				[
					SNew( SButton )
					.ButtonStyle( FEditorStyle::Get(), "NoBorder" )
					.OnClicked(	OnLockButtonClicked )
					.ToolTipText( LOCTEXT("LockSelectionButton_ToolTip", "Locks the current selection into the Details panel") )
					[
						SNew( SImage )
						.Image( this, &SDetailNameArea::OnGetLockButtonImageResource )
					]
				];
		}
	}
	else
	{
		if ( SelectionTip.Get() && NumSelectedSurfaces == 0 )
		{
			ObjectNameArea->AddSlot()
			.FillWidth( 1.0f )
			.HAlign( HAlign_Center )
			.Padding( 2.0f, 24.0f, 2.0f, 2.0f )
			[
				SNew( STextBlock )
				.Text( LOCTEXT("NoObjectsSelected", "Select an object to view details.") )
			];
		}
		else
		{
			// Fill the empty space
			ObjectNameArea->AddSlot();
		}
	}
	
	return ObjectNameArea;
}