void FLightmapCustomNodeBuilder::RefreshLightmapItems()
{
	LightmapItems.Empty();

	FWorldContext& Context = GEditor->GetEditorWorldContext();
	UWorld* World = Context.World();
	if ( World )
	{
		TArray<UTexture2D*> LightMapsAndShadowMaps;
		World->GetLightMapsAndShadowMaps(World->GetCurrentLevel(), LightMapsAndShadowMaps);

		for ( auto ObjIt = LightMapsAndShadowMaps.CreateConstIterator(); ObjIt; ++ObjIt )
		{
			UTexture2D* CurrentObject = *ObjIt;
			if (CurrentObject)
			{
				FAssetData AssetData = FAssetData(CurrentObject);
				const uint32 ThumbnailResolution = 64;
				TSharedPtr<FAssetThumbnail> LightMapThumbnail = MakeShareable( new FAssetThumbnail( AssetData, ThumbnailResolution, ThumbnailResolution, ThumbnailPool ) );
				TSharedPtr<FLightmapItem> NewItem = MakeShareable( new FLightmapItem(CurrentObject->GetPathName(), LightMapThumbnail) );
				LightmapItems.Add(NewItem);
			}
		}
	}

	if ( LightmapListView.IsValid() )
	{
		LightmapListView->RequestListRefresh();
	}
}
	void CreateTileSetsFromTextures(TArray<UTexture2D*>& Textures)
	{
		const FString DefaultSuffix = TEXT("_TileSet");

		FAssetToolsModule& AssetToolsModule = FModuleManager::Get().LoadModuleChecked<FAssetToolsModule>("AssetTools");
		FContentBrowserModule& ContentBrowserModule = FModuleManager::LoadModuleChecked<FContentBrowserModule>("ContentBrowser");

		TArray<UObject*> ObjectsToSync;

		for (auto TextureIt = Textures.CreateConstIterator(); TextureIt; ++TextureIt)
		{
			UTexture2D* Texture = *TextureIt;

			// Create the factory used to generate the tile set
			UPaperTileSetFactory* TileSetFactory = NewObject<UPaperTileSetFactory>();
			TileSetFactory->InitialTexture = Texture;

			// Get a unique name for the tile set
			FString Name;
			FString PackageName;
			AssetToolsModule.Get().CreateUniqueAssetName(Texture->GetOutermost()->GetName(), DefaultSuffix, /*out*/ PackageName, /*out*/ Name);
			const FString PackagePath = FPackageName::GetLongPackagePath(PackageName);

			if (UObject* NewAsset = AssetToolsModule.Get().CreateAsset(Name, PackagePath, UPaperTileSet::StaticClass(), TileSetFactory))
			{
				ObjectsToSync.Add(NewAsset);
			}
		}

		if (ObjectsToSync.Num() > 0)
		{
			ContentBrowserModule.Get().SyncBrowserToAssets(ObjectsToSync);
		}
	}
Example #3
0
void USkeleton::CollectAnimationNotifies()
{
	// need to verify if these pose is used by anybody else
	FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>(TEXT("AssetRegistry"));

	// @Todo : remove it when we know the asset registry is updated
	// meanwhile if you remove this, this will miss the links
	//AnimationNotifies.Empty();
	TArray<FAssetData> AssetList;
	AssetRegistryModule.Get().GetAssetsByClass(UAnimSequenceBase::StaticClass()->GetFName(), AssetList, true);
#if WITH_EDITOR
	// do not clear AnimationNotifies. We can't remove old ones yet. 
	FString CurrentSkeletonName = FAssetData(this).GetExportTextName();
	for (auto Iter = AssetList.CreateConstIterator(); Iter; ++Iter)
	{
		const FAssetData& Asset = *Iter;
		const FString* SkeletonValue = Asset.TagsAndValues.Find(TEXT("Skeleton"));
		if (SkeletonValue && *SkeletonValue == CurrentSkeletonName)
		{
			if (const FString* Value = Asset.TagsAndValues.Find(USkeleton::AnimNotifyTag))
			{
				TArray<FString> NotifyList;
				Value->ParseIntoArray(&NotifyList, &AnimNotifyTagDelimiter, true);
				for (auto NotifyIter = NotifyList.CreateConstIterator(); NotifyIter; ++NotifyIter)
				{
					FString NotifyName = *NotifyIter;
					AddNewAnimationNotify(FName(*NotifyName));
				}
			}
		}
	}
#endif
}
Example #4
0
bool FLayers::AddActorsToLayers( const TArray< TWeakObjectPtr< AActor > >& Actors, const TArray< FName >& LayerNames )
{
	bool bChangesOccurred = false;

	if ( LayerNames.Num() > 0 ) 
	{
		Editor->GetSelectedActors()->BeginBatchSelectOperation();

		for( auto ActorIt = Actors.CreateConstIterator(); ActorIt; ++ActorIt )
		{
			const TWeakObjectPtr< AActor > Actor = *ActorIt;

			if ( !IsActorValidForLayer( Actor ) )
			{
				continue;
			}

			bool bActorWasModified = false;
			for( auto LayerNameIt = LayerNames.CreateConstIterator(); LayerNameIt; ++LayerNameIt )
			{
				const FName& LayerName = *LayerNameIt;

				if( !Actor->Layers.Contains( LayerName ) )
				{
					if( !bActorWasModified )
					{
						Actor->Modify();
						bActorWasModified = true;
					}

					TWeakObjectPtr< ULayer > Layer = EnsureLayerExists( LayerName );
					Actor->Layers.Add( LayerName );

					Layer->Modify();
					AddActorToStats( Layer, Actor);
				}
			} //END Iteration over Layers

			if( bActorWasModified )
			{
				// update per-view visibility info
				UpdateActorAllViewsVisibility(Actor);

				// update general actor visibility
				bool bActorModified = false;
				bool bActorSelectionChanged = false;
				const bool bActorNotifySelectionChange = true;
				const bool bActorRedrawViewports = false;
				UpdateActorVisibility( Actor, bActorSelectionChanged, bActorModified, bActorNotifySelectionChange, bActorRedrawViewports );

				bChangesOccurred = true;
			}
		} //END Iteration over Actors

		Editor->GetSelectedActors()->EndBatchSelectOperation();
	}

	return bChangesOccurred;
}
Example #5
0
void UK2Node_MacroInstance::ReallocatePinsDuringReconstruction(TArray<UEdGraphPin*>& OldPins)
{
	Super::ReallocatePinsDuringReconstruction(OldPins);

	const UEdGraphSchema_K2* const Schema = GetDefault<UEdGraphSchema_K2>();

	// determine if all wildcard pins are unlinked.
	// if they are, we should revert them all back to wildcard status
	bool bAllWildcardsAreUnlinked = true;
	for (auto PinIt = Pins.CreateConstIterator(); PinIt; PinIt++)
	{
		// for each of the wildcard pins...
		UEdGraphPin* const Pin = *PinIt;
		if ( Pin->PinType.PinCategory == Schema->PC_Wildcard )
		{
			// find it in the old pins array (where it might not be a wildcard)
			// and see if it's unlinked
			for (auto OldPinIt = OldPins.CreateConstIterator(); OldPinIt; OldPinIt++)
			{
				UEdGraphPin const* const OldPin = *OldPinIt;
				if (OldPin->PinName == Pin->PinName)
				{
					if (OldPin->LinkedTo.Num() > 0)
					{
						bAllWildcardsAreUnlinked = false;
						break;
					}
				}
			}
		}
	}

	if (bAllWildcardsAreUnlinked == false)
	{
		// Copy pin types from old pins for wildcard pins
		for (auto PinIt = Pins.CreateConstIterator(); PinIt; PinIt++)
		{
			UEdGraphPin* const Pin = *PinIt;
			if ( Pin->PinType.PinCategory == Schema->PC_Wildcard )
			{
				// find it in the old pins and copy the type
				for (auto OldPinIt = OldPins.CreateConstIterator(); OldPinIt; OldPinIt++)
				{
					UEdGraphPin const* const OldPin = *OldPinIt;
					if (OldPin->PinName == Pin->PinName)
					{
						Pin->PinType = OldPin->PinType;
					}
				}
			}
		}
	}
	else
	{
		// no type
		ResolvedWildcardType.ResetToDefaults();
	}
}
Example #6
0
bool FLayers::RemoveActorsFromLayers( const TArray< TWeakObjectPtr< AActor > >& Actors, const TArray< FName >& LayerNames, const bool bUpdateStats )
{
	Editor->GetSelectedActors()->BeginBatchSelectOperation();

	bool bChangesOccurred = false;
	for( auto ActorIt = Actors.CreateConstIterator(); ActorIt; ++ActorIt )
	{
		const TWeakObjectPtr< AActor > Actor = *ActorIt;

		if ( !IsActorValidForLayer( Actor ) )
		{
			continue;
		}

		bool ActorWasModified = false;
		for( auto LayerNameIt = LayerNames.CreateConstIterator(); LayerNameIt; ++LayerNameIt )
		{
			const FName& LayerName = *LayerNameIt;
			if( Actor->Layers.Contains( LayerName ) )
			{
				if( !ActorWasModified )
				{
					Actor->Modify();
					ActorWasModified = true;
				}

				Actor->Layers.Remove( LayerName );

				TWeakObjectPtr< ULayer > Layer;
				if( bUpdateStats && TryGetLayer( LayerName, Layer ))
				{
					Layer->Modify();
					RemoveActorFromStats( Layer, Actor);
				}
			}
		} //END Iteration over Layers

		if( ActorWasModified )
		{
			// update per-view visibility info
			UpdateActorAllViewsVisibility(Actor);

			// update general actor visibility
			bool bActorModified = false;
			bool bActorSelectionChanged = false;
			const bool bActorNotifySelectionChange = true;
			const bool bActorRedrawViewports = false;
			UpdateActorVisibility( Actor, bActorSelectionChanged, bActorModified, bActorNotifySelectionChange, bActorRedrawViewports );

			bChangesOccurred = true;
		}
	} //END Iteration over Actors

	Editor->GetSelectedActors()->EndBatchSelectOperation();

	return bChangesOccurred;
}
void FPathContextMenu::ExecuteSCCOpenForAdd()
{
	ISourceControlProvider& SourceControlProvider = ISourceControlModule::Get().GetProvider();

	// Get a list of package names in the selected paths
	TArray<FString> PackageNames;
	GetPackageNamesInSelectedPaths(PackageNames);

	TArray<FString> PackagesToAdd;
	TArray<UPackage*> PackagesToSave;
	for ( auto PackageIt = PackageNames.CreateConstIterator(); PackageIt; ++PackageIt )
	{
		FSourceControlStatePtr SourceControlState = SourceControlProvider.GetState(SourceControlHelpers::PackageFilename(*PackageIt), EStateCacheUsage::Use);
		if ( SourceControlState.IsValid() && !SourceControlState->IsSourceControlled() )
		{
			PackagesToAdd.Add(*PackageIt);

			// Make sure the file actually exists on disk before adding it
			FString Filename;
			if ( !FPackageName::DoesPackageExist(*PackageIt, NULL, &Filename) )
			{
				UPackage* Package = FindPackage(NULL, **PackageIt);
				if ( Package )
				{
					PackagesToSave.Add(Package);
				}
			}
		}
	}

	if ( PackagesToAdd.Num() > 0 )
	{
		// If any of the packages are new, save them now
		if ( PackagesToSave.Num() > 0 )
		{
			const bool bCheckDirty = false;
			const bool bPromptToSave = false;
			TArray<UPackage*> FailedPackages;
			const FEditorFileUtils::EPromptReturnCode Return = FEditorFileUtils::PromptForCheckoutAndSave(PackagesToSave, bCheckDirty, bPromptToSave, &FailedPackages);
			if(FailedPackages.Num() > 0)
			{
				// don't try and add files that failed to save - remove them from the list
				for(auto FailedPackageIt = FailedPackages.CreateConstIterator(); FailedPackageIt; FailedPackageIt++)
				{
					PackagesToAdd.Remove((*FailedPackageIt)->GetName());
				}
			}
		}

		if ( PackagesToAdd.Num() > 0 )
		{
			SourceControlProvider.Execute(ISourceControlOperation::Create<FMarkForAdd>(), SourceControlHelpers::PackageFilenames(PackagesToAdd));
		}
	}
}
bool FAssetFixUpRedirectors::CheckOutReferencingPackages(TArray<FRedirectorRefs>& RedirectorsToFix, TArray<UPackage*>& InOutReferencingPackagesToSave) const
{
	// Prompt to check out all successfully loaded packages
	bool bUserAcceptedCheckout = true;

	if ( InOutReferencingPackagesToSave.Num() > 0 )
	{
		if ( ISourceControlModule::Get().IsEnabled() )
		{
			TArray<UPackage*> PackagesCheckedOutOrMadeWritable;
			TArray<UPackage*> PackagesNotNeedingCheckout;
			bUserAcceptedCheckout = FEditorFileUtils::PromptToCheckoutPackages( false, InOutReferencingPackagesToSave, &PackagesCheckedOutOrMadeWritable, &PackagesNotNeedingCheckout );
			if ( bUserAcceptedCheckout )
			{
				TArray<UPackage*> PackagesThatCouldNotBeCheckedOut = InOutReferencingPackagesToSave;

				for ( auto PackageIt = PackagesCheckedOutOrMadeWritable.CreateConstIterator(); PackageIt; ++PackageIt )
				{
					PackagesThatCouldNotBeCheckedOut.Remove(*PackageIt);
				}

				for ( auto PackageIt = PackagesNotNeedingCheckout.CreateConstIterator(); PackageIt; ++PackageIt )
				{
					PackagesThatCouldNotBeCheckedOut.Remove(*PackageIt);
				}

				for ( auto PackageIt = PackagesThatCouldNotBeCheckedOut.CreateConstIterator(); PackageIt; ++PackageIt )
				{
					const FName NonCheckedOutPackageName = (*PackageIt)->GetFName();

					for ( auto RedirectorRefsIt = RedirectorsToFix.CreateIterator(); RedirectorRefsIt; ++RedirectorRefsIt )
					{
						FRedirectorRefs& RedirectorRefs = *RedirectorRefsIt;
						if ( RedirectorRefs.ReferencingPackageNames.Contains(NonCheckedOutPackageName) )
						{
							// We did not check out at least one of the packages we needed to. This redirector can not be fixed up.
							RedirectorRefs.FailureReason = FText::Format(LOCTEXT("RedirectorFixupFailed_NotCheckedOut", "Referencing package {0} was not checked out"), FText::FromName(NonCheckedOutPackageName));
							RedirectorRefs.bRedirectorValidForFixup = false;
						}
					}

					InOutReferencingPackagesToSave.Remove(*PackageIt);
				}
			}
		}
	}

	return bUserAcceptedCheckout;
}
	virtual void SnapPointToGrid(FVector& Point, const FVector& GridBase) override
	{
		for (auto PolicyIt = PolicyList.CreateConstIterator(); PolicyIt; ++PolicyIt)
		{
			(*PolicyIt)->SnapPointToGrid(Point, GridBase);
		}
	}
void FAssetTypeActions_StaticMesh::ExecuteCreateDestructibleMesh(TArray<TWeakObjectPtr<UStaticMesh>> Objects)
{
	TArray< UObject* > Assets;
	for (auto ObjIt = Objects.CreateConstIterator(); ObjIt; ++ObjIt)
	{
		auto Object = (*ObjIt).Get();
		if ( Object )
		{
			FText ErrorMsg;
			FDestructibleMeshEditorModule& DestructibleMeshEditorModule = FModuleManager::LoadModuleChecked<FDestructibleMeshEditorModule>( "DestructibleMeshEditor" );
			UDestructibleMesh* DestructibleMesh = DestructibleMeshEditorModule.CreateDestructibleMeshFromStaticMesh(Object->GetOuter(), Object, NAME_None, Object->GetFlags(), ErrorMsg);
			if ( DestructibleMesh )
			{
				FAssetEditorManager::Get().OpenEditorForAsset(DestructibleMesh);
				Assets.Add(DestructibleMesh);
			}
			else if ( !ErrorMsg.IsEmpty() )
			{
				FNotificationInfo ErrorNotification( ErrorMsg );
				FSlateNotificationManager::Get().AddNotification(ErrorNotification);
			}
		}
	}
	if ( Assets.Num() > 0 )
	{
		FAssetTools::Get().SyncBrowserToAssets(Assets);
	}
}
bool FPerforceSourceControlLabel::GetFileRevisions( const TArray<FString>& InFiles, TArray< TSharedRef<ISourceControlRevision, ESPMode::ThreadSafe> >& OutRevisions ) const
{
	bool bCommandOK = false;

	FPerforceSourceControlModule& PerforceSourceControl = FModuleManager::LoadModuleChecked<FPerforceSourceControlModule>("PerforceSourceControl");
	FScopedPerforceConnection ScopedConnection(EConcurrency::Synchronous, PerforceSourceControl.AccessSettings().GetConnectionInfo());
	if(ScopedConnection.IsValid())
	{
		FPerforceConnection& Connection = ScopedConnection.GetConnection();
		FP4RecordSet Records;
		TArray<FString> Parameters;
		TArray<FText> ErrorMessages;
		for(auto Iter(InFiles.CreateConstIterator()); Iter; Iter++)
		{
			Parameters.Add(*Iter + TEXT("@") + Name);
		}
		bool bConnectionDropped = false;
		bCommandOK = Connection.RunCommand(TEXT("files"), Parameters, Records, ErrorMessages, FOnIsCancelled(), bConnectionDropped);
		if(bCommandOK)
		{
			ParseFilesResults(Records, OutRevisions, Connection.ClientRoot);
		}
		else
		{
			// output errors if any
			for (int32 ErrorIndex = 0; ErrorIndex < ErrorMessages.Num(); ++ErrorIndex)
			{
				FMessageLog("SourceControl").Error(ErrorMessages[ErrorIndex]);
			}
		}
	}

	return bCommandOK;
}
Example #12
0
void SBlutilityShelf::ToggleFavoriteStatusOnSelection(TArray<FAssetData> AssetList, bool bIsNewFavorite)
{
	if (AssetList.Num() > 0)
	{
		// Get the list to add/remove
		TArray<FName> AllPaths;
		for (auto AssetIt = AssetList.CreateConstIterator(); AssetIt; ++AssetIt)
		{
			const FAssetData& AssetData = *AssetIt;
			AllPaths.Add(AssetData.ObjectPath);
		}

		// Determine the current status
		bool bAreAnySelected;
		bool bAreAllSelected;
		GetFavoriteStatus(AssetList, /*out*/ bAreAnySelected, /*out*/ bAreAllSelected);

		FCollectionManagerModule& CollectionManagerModule = FCollectionManagerModule::GetModule();
		if (bAreAllSelected)
		{
			// Remove them
			CollectionManagerModule.Get().RemoveFromCollection(BlutilityModule::BlutilityShelfCollectionName, ECollectionShareType::CST_Local, AllPaths);
		}
		else
		{
			// Add them
			CollectionManagerModule.Get().AddToCollection(BlutilityModule::BlutilityShelfCollectionName, ECollectionShareType::CST_Local, AllPaths);
		}
	}
}
void FAssetTypeActions_EditorUtilityBlueprint::OpenAssetEditor(const TArray<UObject*>& InObjects, TSharedPtr<class IToolkitHost> EditWithinLevelEditor)
{
	EToolkitMode::Type Mode = EditWithinLevelEditor.IsValid() ? EToolkitMode::WorldCentric : EToolkitMode::Standalone;

	for (auto ObjIt = InObjects.CreateConstIterator(); ObjIt; ++ObjIt)
	{
		if (UEditorUtilityBlueprint* Blueprint = Cast<UEditorUtilityBlueprint>(*ObjIt))
		{
			if (Blueprint->GeneratedClass->IsChildOf(UGlobalEditorUtilityBase::StaticClass()))
			{
				const UGlobalEditorUtilityBase* CDO = Blueprint->GeneratedClass->GetDefaultObject<UGlobalEditorUtilityBase>();
				if (CDO->bAutoRunDefaultAction)
				{
					// This is an instant-run blueprint, just execute it
					UGlobalEditorUtilityBase* Instance = NewObject<UGlobalEditorUtilityBase>(GetTransientPackage(), Blueprint->GeneratedClass);
					Instance->ExecuteDefaultAction();
				}
				else
				{
					// This one needs settings or has multiple actions to execute, so invoke the blutility dialog
					TSharedRef<FGlobalBlutilityDialog> NewBlutilityDialog(new FGlobalBlutilityDialog());
					NewBlutilityDialog->InitBlutilityDialog(Mode, EditWithinLevelEditor, Blueprint);
				}
			}
			else
			{
				// Edit actor blutilities
				FBlueprintEditorModule& BlueprintEditorModule = FModuleManager::LoadModuleChecked<FBlueprintEditorModule>( "Kismet" );
				TSharedRef<IBlueprintEditor> NewBlueprintEditor = BlueprintEditorModule.CreateBlueprintEditor(Mode, EditWithinLevelEditor, Blueprint, false);
			}
		}
	}
}
/**
* Generates a list of assets from the ENGINE and the GAME by a specific type.
* This is to be used by the GetTest() function.
*/
void FEditorAutomationTestUtilities::CollectTestsByClass(UClass * Class, TArray<FString>& OutBeautifiedNames, TArray <FString>& OutTestCommands)
{
	FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>(TEXT("AssetRegistry"));
	TArray<FAssetData> ObjectList;
	AssetRegistryModule.Get().GetAssetsByClass(Class->GetFName(), ObjectList);

	for (TObjectIterator<UClass> AllClassesIt; AllClassesIt; ++AllClassesIt)
	{
		UClass* ClassList = *AllClassesIt;
		FName ClassName = ClassList->GetFName();
	}

	for (auto ObjIter = ObjectList.CreateConstIterator(); ObjIter; ++ObjIter)
	{
		const FAssetData& Asset = *ObjIter;
		FString Filename = Asset.ObjectPath.ToString();
		//convert to full paths
		Filename = FPackageName::LongPackageNameToFilename(Filename);
		if (FAutomationTestFramework::GetInstance().ShouldTestContent(Filename))
		{
			FString BeautifiedFilename = Asset.AssetName.ToString();
			OutBeautifiedNames.Add(BeautifiedFilename);
			OutTestCommands.Add(Asset.ObjectPath.ToString());
		}
	}
}
	virtual void DrawSnappingHelpers(const FSceneView* View, FPrimitiveDrawInterface* PDI)
	{
		for (auto PolicyIt = PolicyList.CreateConstIterator(); PolicyIt; ++PolicyIt)
		{
			(*PolicyIt)->DrawSnappingHelpers(View, PDI);
		}
	}
void FPrimaryAssetIdCustomization::CustomizeHeader(TSharedRef<class IPropertyHandle> InStructPropertyHandle, class FDetailWidgetRow& HeaderRow, IPropertyTypeCustomizationUtils& StructCustomizationUtils)
{
	if (!UAssetManager::IsValid())
	{
		HeaderRow
		.NameContent()
		[
			InStructPropertyHandle->CreatePropertyNameWidget()
		]
		.ValueContent()
		.MinDesiredWidth(250.0f)
		.MaxDesiredWidth(0.0f)
		[
			SNew(STextBlock)
			.Text(LOCTEXT("NoAssetManager", "Enable Asset Manager to edit Primary Asset Ids"))
		];

		return;
	}

	StructPropertyHandle = InStructPropertyHandle;

	const FString& TypeFilterString = StructPropertyHandle->GetMetaData("AllowedTypes");
	if( !TypeFilterString.IsEmpty() )
	{
		TArray<FString> CustomTypeFilterNames;
		TypeFilterString.ParseIntoArray(CustomTypeFilterNames, TEXT(","), true);

		for(auto It = CustomTypeFilterNames.CreateConstIterator(); It; ++It)
		{
			const FString& TypeName = *It;

			AllowedTypes.Add(*TypeName);
		}
	}

	FOnShouldFilterAsset AssetFilter = FOnShouldFilterAsset::CreateStatic(&IAssetManagerEditorModule::OnShouldFilterPrimaryAsset, AllowedTypes);

	// Can the field be cleared
	const bool bAllowClear = !(StructPropertyHandle->GetMetaDataProperty()->PropertyFlags & CPF_NoClear);

	HeaderRow
	.NameContent()
	[
		InStructPropertyHandle->CreatePropertyNameWidget()
	]
	.ValueContent()
	.MinDesiredWidth(250.0f)
	.MaxDesiredWidth(0.0f)
	[
		// Add an object entry box.  Even though this isn't an object entry, we will simulate one
		SNew( SObjectPropertyEntryBox )
		.ObjectPath(this, &FPrimaryAssetIdCustomization::OnGetObjectPath)
		.PropertyHandle(InStructPropertyHandle)
		.ThumbnailPool(StructCustomizationUtils.GetThumbnailPool())
		.OnShouldFilterAsset(AssetFilter)
		.OnObjectChanged(this, &FPrimaryAssetIdCustomization::OnSetObject)
		.AllowClear(bAllowClear)
	];
}
bool FSubversionSourceControlRevision::GetAnnotated( TArray<FAnnotationLine>& OutLines ) const
{
	SubversionSourceControlUtils::CheckFilename(Filename);

	FSubversionSourceControlModule& SubversionSourceControl = FModuleManager::LoadModuleChecked<FSubversionSourceControlModule>( "SubversionSourceControl" );
	FSubversionSourceControlProvider& Provider = SubversionSourceControl.GetProvider();

	TArray<FString> Results;
	TArray<FString> Parameters;
	TArray<FString> ErrorMessages;

	// Make temp filename to export to
	FString RevString = (RevisionNumber < 0) ? TEXT("HEAD") : FString::Printf(TEXT("%d"), RevisionNumber);
	Parameters.Add(FString(TEXT("--revision ")) + RevString);
	Parameters.Add(TEXT("--use-merge-history"));

	TArray<FString> Files;
	Files.Add(Filename);

	if(SubversionSourceControlUtils::RunCommand(TEXT("blame"), Files, Parameters, Results, ErrorMessages, Provider.GetUserName()))
	{
		ParseBlameResults(Results, OutLines);
		return true;
	}
	else
	{
		for(auto Iter(ErrorMessages.CreateConstIterator()); Iter; Iter++)
		{
			FMessageLog("SourceControl").Error(FText::FromString(*Iter));
		}
	}

	return false;
}
void FAssetTypeActions_Blueprint::ExecuteEditDefaults(TArray<TWeakObjectPtr<UBlueprint>> Objects)
{
	TArray< UBlueprint* > Blueprints;

	FMessageLog EditorErrors("EditorErrors");
	EditorErrors.NewPage(LOCTEXT("ExecuteEditDefaultsNewLogPage", "Loading Blueprints"));

	for (auto ObjIt = Objects.CreateConstIterator(); ObjIt; ++ObjIt)
	{
		auto Object = (*ObjIt).Get();
		if ( Object )
		{
			// If the blueprint is valid, allow it to be added to the list, otherwise log the error.
			if (Object && Object->SkeletonGeneratedClass && Object->GeneratedClass )
			{
				Blueprints.Add(Object);
			}
			else
			{
				FFormatNamedArguments Arguments;
				Arguments.Add(TEXT("ObjectName"), FText::FromString(Object->GetName()));
				EditorErrors.Error(FText::Format(LOCTEXT("LoadBlueprint_FailedLog", "{ObjectName} could not be loaded because it derives from an invalid class.  Check to make sure the parent class for this blueprint hasn't been removed!"), Arguments ) );
			}
		}
	}

	if ( Blueprints.Num() > 0 )
	{
		FBlueprintEditorModule& BlueprintEditorModule = FModuleManager::LoadModuleChecked<FBlueprintEditorModule>( "Kismet" );
		TSharedRef< IBlueprintEditor > NewBlueprintEditor = BlueprintEditorModule.CreateBlueprintEditor(  EToolkitMode::Standalone, TSharedPtr<IToolkitHost>(), Blueprints );
	}

	// Report errors
	EditorErrors.Notify(LOCTEXT("OpenDefaults_Failed", "Opening Blueprint Defaults Failed!"));
}
void UGameplayTagsManager::LoadGameplayTagTables(TArray<FString>& TagTableNames)
{
	if (GameplayTagTables.Num() == 0 && TagTableNames.Num() > 0)
	{
		for (auto It(TagTableNames.CreateConstIterator()); It; ++It)
		{
			const FString& FileName = *It;
			UDataTable* TagTable = LoadObject<UDataTable>(NULL, *FileName, NULL, LOAD_None, NULL);

			// Handle case where the module is dynamically-loaded within a LoadPackage stack, which would otherwise
			// result in the tag table not having its RowStruct serialized in time. Without the RowStruct, the tags manager
			// will not be initialized correctly.
			if (TagTable && IsLoading())
			{
				FLinkerLoad* TagLinker = TagTable->GetLinker();
				if (TagLinker)
				{
					TagTable->GetLinker()->Preload(TagTable);
				}
			}
			GameplayTagTables.Add(TagTable);
		}
	}

#if WITH_EDITOR
	// Hook into notifications for object re-imports so that the gameplay tag tree can be reconstructed if the table changes
	if (GIsEditor && GameplayTagTables.Num() > 0 && !RegisteredObjectReimport)
	{
		RegisteredObjectReimport = true;
		FEditorDelegates::OnAssetPostImport.AddUObject(this, &UGameplayTagsManager::OnObjectReimported);
	}
#endif
}
Example #20
0
bool FAssetFixUpRedirectors::UpdatePackageStatus(const TArray<FRedirectorRefs>& RedirectorsToFix) const
{
	ISourceControlProvider& SourceControlProvider = ISourceControlModule::Get().GetProvider();
	if ( ISourceControlModule::Get().IsEnabled() )
	{
		// Update the source control server availability to make sure we can do the rename operation
		SourceControlProvider.Login();
		if ( !SourceControlProvider.IsAvailable() )
		{
			// We have failed to update source control even though it is enabled. This is critical and we can not continue
			FMessageDialog::Open( EAppMsgType::Ok, NSLOCTEXT("UnrealEd", "SourceControl_ServerUnresponsive", "Source Control is unresponsive. Please check your connection and try again.") );
			return false;
		}

		TArray<UPackage*> PackagesToAddToSCCUpdate;

		for ( auto RedirectorRefsIt = RedirectorsToFix.CreateConstIterator(); RedirectorRefsIt; ++RedirectorRefsIt )
		{
			const FRedirectorRefs& RedirectorRefs = *RedirectorRefsIt;
			PackagesToAddToSCCUpdate.Add(RedirectorRefs.Redirector->GetOutermost());
		}

		SourceControlProvider.Execute(ISourceControlOperation::Create<FUpdateStatus>(), PackagesToAddToSCCUpdate);
	}

	return true;
}
Example #21
0
void SBlutilityShelf::GetFavoriteStatus(const TArray<FAssetData>& AssetList, /*out*/ bool& bAreAnySelected, /*out*/ bool& bAreAllSelected)
{
	TArray<FName> AssetPaths;
	FCollectionManagerModule& CollectionManagerModule = FCollectionManagerModule::GetModule();
	CollectionManagerModule.Get().GetAssetsInCollection(BlutilityModule::BlutilityShelfCollectionName, ECollectionShareType::CST_Local, /*out*/ AssetPaths);

	bAreAnySelected = false;
	bAreAllSelected = false;

	if (AssetList.Num() > 0)
	{
		bAreAllSelected = true;
		for (auto AssetIt = AssetList.CreateConstIterator(); AssetIt; ++AssetIt)
		{
			const FAssetData& AssetData = *AssetIt;
			if (AssetPaths.Contains(AssetData.ObjectPath))
			{
				bAreAnySelected = true;
			}
			else
			{
				bAreAllSelected = false;
			}
		}
	}
}
	virtual void SnapRotatorToGrid(FRotator& Rotation) override
	{
		for (auto PolicyIt = PolicyList.CreateConstIterator(); PolicyIt; ++PolicyIt)
		{
			(*PolicyIt)->SnapRotatorToGrid(Rotation);
		}
	}
	virtual void ClearSnappingHelpers(bool bClearImmediately) override
	{
		for (auto PolicyIt = PolicyList.CreateConstIterator(); PolicyIt; ++PolicyIt)
		{
			(*PolicyIt)->ClearSnappingHelpers(bClearImmediately);
		}
	}
void FAssetTypeActions_DataTable::ExecuteExportAsJSON(TArray< TWeakObjectPtr<UObject> > Objects)
{
	IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get();

	const void* ParentWindowWindowHandle = FSlateApplication::Get().FindBestParentWindowHandleForDialogs(nullptr);

	for (auto ObjIt = Objects.CreateConstIterator(); ObjIt; ++ObjIt)
	{
		auto DataTable = Cast<UDataTable>((*ObjIt).Get());
		if (DataTable)
		{
			const FText Title = FText::Format(LOCTEXT("DataTable_ExportJSONDialogTitle", "Export '{0}' as JSON..."), FText::FromString(*DataTable->GetName()));
			const FString CurrentFilename = DataTable->AssetImportData->GetFirstFilename();
			const FString FileTypes = TEXT("Data Table JSON (*.json)|*.json");

			TArray<FString> OutFilenames;
			DesktopPlatform->SaveFileDialog(
				ParentWindowWindowHandle,
				Title.ToString(),
				(CurrentFilename.IsEmpty()) ? TEXT("") : FPaths::GetPath(CurrentFilename),
				(CurrentFilename.IsEmpty()) ? TEXT("") : FPaths::GetBaseFilename(CurrentFilename) + TEXT(".json"),
				FileTypes,
				EFileDialogFlags::None,
				OutFilenames
				);

			if (OutFilenames.Num() > 0)
			{
				FFileHelper::SaveStringToFile(DataTable->GetTableAsJSON(EDataTableExportFlags::UsePrettyPropertyNames | EDataTableExportFlags::UsePrettyEnumNames | EDataTableExportFlags::UseJsonObjectsForStructs), *OutFilenames[0]);
			}
		}
	}
}
Example #25
0
TSharedRef<SWidget> FCameraDetails::OnGetComboContent() const
{
	// Fill the combo menu with presets of common screen resolutions
	FMenuBuilder MenuBuilder(true, NULL);

	TArray<FText> Items;
	Items.Add(LOCTEXT("PresetRatio640x480", "640x480 (4:3, 1.33) SDTV"));
	Items.Add(LOCTEXT("PresetRatio852x480", "852x480 (16:9, 1.78) SDTV Widescreen"));
	Items.Add(LOCTEXT("PresetRatio1280x720", "1280x720 (16:9, 1.78) HDTV 720"));
	Items.Add(LOCTEXT("PresetRatio1920x1080", "1920x1080 (16:9, 1.78) HDTV 1080"));
	Items.Add(LOCTEXT("PresetRatio960x544", "960x544 (16:9, 1.76) PS Vita"));
	Items.Add(LOCTEXT("PresetRatio1024x640", "1024x640 (1.6)"));
	Items.Add(LOCTEXT("PresetRatio1024x76", "1024x768 (4:3, 1.33)"));
	Items.Add(LOCTEXT("PresetRatio1366x768", "1366x768 (16:9, 1.78)"));
	Items.Add(LOCTEXT("PresetRatio2048x1536", "2048x1536 (4:3, 1.33) iPad 3"));
	Items.Add(LOCTEXT("PresetRatio4096x2304", "4096x2304 (16:9, 1.78) 4K"));

	for (auto ItemIter = Items.CreateConstIterator(); ItemIter; ++ItemIter)
	{
		FText ItemText = *ItemIter;
		FUIAction ItemAction( FExecuteAction::CreateSP( this, &FCameraDetails::CommitAspectRatioText, ItemText ) );
		MenuBuilder.AddMenuEntry(ItemText, TAttribute<FText>(), FSlateIcon(), ItemAction);
	}

	return MenuBuilder.MakeWidget();
}
void UK2Node_CallArrayFunction::GetArrayPins(TArray< FArrayPropertyPinCombo >& OutArrayPinInfo ) const
{
	OutArrayPinInfo.Empty();

	UFunction* TargetFunction = GetTargetFunction();
	check(TargetFunction);
	FString ArrayPointerMetaData = TargetFunction->GetMetaData(FBlueprintMetadata::MD_ArrayParam);
	TArray<FString> ArrayPinComboNames;
	ArrayPointerMetaData.ParseIntoArray(ArrayPinComboNames, TEXT(","), true);

	for(auto Iter = ArrayPinComboNames.CreateConstIterator(); Iter; ++Iter)
	{
		TArray<FString> ArrayPinNames;
		Iter->ParseIntoArray(ArrayPinNames, TEXT("|"), true);

		FArrayPropertyPinCombo ArrayInfo;
		ArrayInfo.ArrayPin = FindPin(ArrayPinNames[0]);
		if(ArrayPinNames.Num() > 1)
		{
			ArrayInfo.ArrayPropPin = FindPin(ArrayPinNames[1]);
		}

		if(ArrayInfo.ArrayPin)
		{
			OutArrayPinInfo.Add(ArrayInfo);
		}
	}
}
/**
* Generates a list of assets from the GAME by a specific type.
*/
void FEditorAutomationTestUtilities::CollectGameContentByClass(const UClass * Class, bool bRecursiveClass, TArray<FString>& OutAssetList)
{
	//Setting the Asset Registry
	FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>(TEXT("AssetRegistry"));

	//Variable setups
	TArray<FAssetData> ObjectList;
	FARFilter AssetFilter;

	//Generating the list of assets.
	//This list is being filtered by the game folder and class type.  The results are placed into the ObjectList variable.
	AssetFilter.ClassNames.Add(Class->GetFName());
	AssetFilter.PackagePaths.Add("/Game");
	AssetFilter.bRecursiveClasses = bRecursiveClass;
	AssetFilter.bRecursivePaths = true;
	AssetRegistryModule.Get().GetAssets(AssetFilter, ObjectList);

	//Loop through the list of assets, make their path full and a string, then add them to the test.
	for (auto ObjIter = ObjectList.CreateConstIterator(); ObjIter; ++ObjIter)
	{
		const FAssetData& Asset = *ObjIter;
		FString Filename = Asset.ObjectPath.ToString();
		//convert to full paths
		Filename = FPackageName::LongPackageNameToFilename(Filename);
		if (FAutomationTestFramework::GetInstance().ShouldTestContent(Filename))
		{
			OutAssetList.Add(Asset.ObjectPath.ToString());
		}
	}
}
Example #28
0
void UK2Node_Select::PostReconstructNode()
{
	bReconstructNode = false;

	const UEdGraphSchema_K2* Schema = Cast<UEdGraphSchema_K2>(GetSchema());

	UEdGraphPin* ReturnPin = GetReturnValuePin();
	PinConnectionListChanged(ReturnPin);
	const bool bFillTypeFromReturn = Schema && ReturnPin && (ReturnPin->PinType.PinCategory != Schema->PC_Wildcard);

	TArray<UEdGraphPin*> OptionPins;
	GetOptionPins(OptionPins);
	for (auto It = OptionPins.CreateConstIterator(); It; It++)
	{
		UEdGraphPin* Pin = *It;
		const bool bTypeShouldBeFilled = Schema && Pin && (Pin->PinType.PinCategory == Schema->PC_Wildcard);
		if (bTypeShouldBeFilled && bFillTypeFromReturn)
		{
			Pin->Modify();
			Pin->PinType = ReturnPin->PinType;
			UEdGraphSchema_K2::ValidateExistingConnections(Pin);
		}

		PinConnectionListChanged(*It);
	}

	//After ReconstructNode we must be sure, that no additional reconstruction is required
	bReconstructNode = false;
}
void UK2Node_CallArrayFunction::AllocateDefaultPins()
{
	Super::AllocateDefaultPins();

	const UEdGraphSchema_K2* Schema = GetDefault<UEdGraphSchema_K2>();

	UEdGraphPin* TargetArrayPin = GetTargetArrayPin();
	check(TargetArrayPin);
	TargetArrayPin->PinType.bIsArray = true;
	TargetArrayPin->PinType.bIsReference = true;
	TargetArrayPin->PinType.PinCategory = Schema->PC_Wildcard;
	TargetArrayPin->PinType.PinSubCategory = TEXT("");
	TargetArrayPin->PinType.PinSubCategoryObject = NULL;

	TArray< FArrayPropertyPinCombo > ArrayPins;
	GetArrayPins(ArrayPins);
	for(auto Iter = ArrayPins.CreateConstIterator(); Iter; ++Iter)
	{
		if(Iter->ArrayPropPin)
		{
			Iter->ArrayPropPin->bHidden = true;
			Iter->ArrayPropPin->bNotConnectable = true;
			Iter->ArrayPropPin->bDefaultValueIsReadOnly = true;
		}
	}

	PropagateArrayTypeInfo(TargetArrayPin);
}
Example #30
0
bool UK2Node_Select::CanChangePinType(UEdGraphPin* Pin) const
{
	// If this is the index pin, only allow type switching if nothing is linked to the pin
	if (Pin == GetIndexPin())
	{
		if (Pin->LinkedTo.Num() > 0)
		{
			return false;
		}
	}
	// Else it's one of the wildcard pins that share their type, so make sure none of them have a link
	else
	{
		if (GetReturnValuePin()->LinkedTo.Num() > 0)
		{
			return false;
		}
		else
		{
			TArray<UEdGraphPin*> OptionPins;
			GetOptionPins(OptionPins);
			for (auto It = OptionPins.CreateConstIterator(); It; It++)
			{
				UEdGraphPin* OptionPin = (*It);
				if (OptionPin && OptionPin->LinkedTo.Num() > 0)
				{
					return false;
				}
			}
		}
	}
	return true;
}