void FTextFormatData::GetFormatArgumentNames_NoLock(TArray<FString>& OutArgumentNames) { ConditionalCompile_NoLock(); if (CompiledExpressionType != FTextFormat::EExpressionType::Complex) { return; } for (const FExpressionToken& Token : LexedExpression) { if (const auto* ArgumentToken = Token.Node.Cast<TextFormatTokens::FArgumentTokenSpecifier>()) { // Add the entry to the array if it doesn't already exist // We can't just use AddUnique since we need the names to be case-sensitive const bool bIsInArray = OutArgumentNames.ContainsByPredicate([&](const FString& InEntry) -> bool { return ArgumentToken->ArgumentNameLen == InEntry.Len() && FCString::Strnicmp(ArgumentToken->ArgumentNameStartPos, *InEntry, ArgumentToken->ArgumentNameLen) == 0; }); if (!bIsInArray) { OutArgumentNames.Add(FString(ArgumentToken->ArgumentNameLen, ArgumentToken->ArgumentNameStartPos)); } } else if (const auto* ArgumentModifierToken = Token.Node.Cast<TextFormatTokens::FArgumentModifierTokenSpecifier>()) { ArgumentModifierToken->TextFormatArgumentModifier->GetFormatArgumentNames(OutArgumentNames); } } }
void FPathContextMenu::ExecuteSCCSync() const { ISourceControlProvider& SourceControlProvider = ISourceControlModule::Get().GetProvider(); TArray<FString> RootPaths; FPackageName::QueryRootContentPaths( RootPaths ); // find valid paths on disk TArray<FString> PathsOnDisk; for(const auto& SelectedPath : SelectedPaths) { // note: we make sure to terminate our path here so root directories map correctly. const FString CompletePath = SelectedPath / ""; const bool bMatchesRoot = RootPaths.ContainsByPredicate([&](const FString& RootPath){ return CompletePath.StartsWith(RootPath); }); if(bMatchesRoot) { FString PathOnDisk = FPackageName::LongPackageNameToFilename(CompletePath); PathsOnDisk.Add(PathOnDisk); } } if ( PathsOnDisk.Num() > 0 ) { // attempt to unload all assets under this path TArray<FString> PackageNames; GetPackageNamesInSelectedPaths(PackageNames); // Form a list of loaded packages to prompt for save TArray<UPackage*> LoadedPackages; for( const auto& PackageName : PackageNames ) { UPackage* Package = FindPackage(nullptr, *PackageName); if ( Package != nullptr ) { LoadedPackages.Add(Package); } } FText ErrorMessage; PackageTools::UnloadPackages(LoadedPackages, ErrorMessage); if(!ErrorMessage.IsEmpty()) { FMessageDialog::Open( EAppMsgType::Ok, ErrorMessage ); } else { SourceControlProvider.Execute(ISourceControlOperation::Create<FSync>(), PathsOnDisk); } } else { UE_LOG(LogContentBrowser, Warning, TEXT("Couldn't find any valid paths to sync.")) } }
void FFeaturePackContentSource::TryAddFeaturePackCategory(FString CategoryTitle, TArray< TSharedPtr<FSearchEntry> >& OutSuggestions) { if (OutSuggestions.ContainsByPredicate([&CategoryTitle](TSharedPtr<FSearchEntry>& InElement) { return ((InElement->Title == CategoryTitle) && (InElement->bCategory == true)); }) == false) { TSharedPtr<FSearchEntry> FeaturePackCat = MakeShareable(new FSearchEntry()); FeaturePackCat->bCategory = true; FeaturePackCat->Title = CategoryTitle; OutSuggestions.Add(FeaturePackCat); } }
void UCarlaSettingsDelegate::SetAllRoads(UWorld* world, const float max_draw_distance, const TArray<FStaticMaterial> &road_pieces_materials) const { if(!world||!IsValid(world)||world->IsPendingKill()) return; AsyncTask(ENamedThreads::GameThread, [=](){ if(!world||!IsValid(world)||world->IsPendingKill()) return; TArray<AActor*> actors; UGameplayStatics::GetAllActorsWithTag(world, UCarlaSettings::CARLA_ROAD_TAG,actors); for(int32 i=0; i<actors.Num(); i++) { AActor* actor = actors[i]; if(!IsValid(actor) || actor->IsPendingKill()) continue; TArray<UActorComponent*> components = actor->GetComponentsByClass(UStaticMeshComponent::StaticClass()); for(int32 j=0; j<components.Num(); j++) { UStaticMeshComponent* staticmeshcomponent = Cast<UStaticMeshComponent>(components[j]); if(staticmeshcomponent) { staticmeshcomponent->bAllowCullDistanceVolume = (max_draw_distance>0); staticmeshcomponent->bUseAsOccluder = false; staticmeshcomponent->LDMaxDrawDistance = max_draw_distance; staticmeshcomponent->CastShadow = (max_draw_distance==0); if(road_pieces_materials.Num()>0) { TArray<FName> meshslotsnames = staticmeshcomponent->GetMaterialSlotNames(); for(int32 k=0; k<meshslotsnames.Num(); k++) { const FName &slotname = meshslotsnames[k]; road_pieces_materials.ContainsByPredicate( [staticmeshcomponent,slotname](const FStaticMaterial& material) { if(material.MaterialSlotName.IsEqual(slotname)) { staticmeshcomponent->SetMaterial( staticmeshcomponent->GetMaterialIndex(slotname), material.MaterialInterface ); return true; } else return false; }); } } } } } }); //,DELAY_TIME_TO_SET_ALL_ROADS, false); }
bool FMovieSceneCinematicShotTrackInstance::ShouldEvaluateIfOverlapping(const TArray<UMovieSceneSection*>& TraversedSections, UMovieSceneSection* Section) const { // Check with this shot's exclusive upper bound for when shots are adjacent to each other but on different rows. TRange<float> ThisSectionWithExclusiveUpper = TRange<float>(Section->GetRange().GetLowerBoundValue(), Section->GetRange().GetUpperBoundValue()); // Only evaluate the top most row on overlapping cinematic shot sections. Disregard overlap priority. const bool bShouldRemove = TraversedSections.ContainsByPredicate([=](UMovieSceneSection* OtherSection){ if (Section->GetRowIndex() > OtherSection->GetRowIndex() && ThisSectionWithExclusiveUpper.Overlaps(OtherSection->GetRange())) { return true; } return false; }); return bShouldRemove; }
bool ACoverActor::IsCloseToPlayer(FName SocketName) { //Perform a raycast in order to determine if the player is //near the given socket TArray<FHitResult> HitResults; const FVector StartLocation = SM->GetSocketLocation(SocketName); const FVector EndLocation = UGameplayStatics::GetPlayerCharacter(GetWorld(), 0)->GetActorLocation(); FCollisionShape Shape; Shape.ShapeType = ECollisionShape::Line; GetWorld()->SweepMultiByChannel(HitResults, StartLocation, EndLocation, FQuat(), ECC_WorldDynamic, Shape); //If our raycast contains the character inside its hit result //the character can take cover in the side that this socket represents return HitResults.ContainsByPredicate([&](FHitResult hitResult) { AActor* HitActor = hitResult.GetActor(); return HitActor && HitActor->IsA<ACoverSystemCharacter>(); }); }
void FAssetFixUpRedirectors::DeleteRedirectors(TArray<FRedirectorRefs>& RedirectorsToFix, const TArray<UPackage*>& FailedToSave) const { TArray<UObject*> ObjectsToDelete; for ( auto RedirectorIt = RedirectorsToFix.CreateIterator(); RedirectorIt; ++RedirectorIt ) { FRedirectorRefs& RedirectorRefs = *RedirectorIt; if ( RedirectorRefs.bRedirectorValidForFixup ) { bool bAllReferencersFixedUp = true; for (const auto& ReferencingPackageName : RedirectorRefs.ReferencingPackageNames) { if (FailedToSave.ContainsByPredicate([&](UPackage* Package) { return Package->GetFName() == ReferencingPackageName; })) { bAllReferencersFixedUp = false; break; } } if (!bAllReferencersFixedUp) { continue; } // Add all redirectors found in this package to the redirectors to delete list. // All redirectors in this package should be fixed up. UPackage* RedirectorPackage = RedirectorRefs.Redirector->GetOutermost(); TArray<UObject*> AssetsInRedirectorPackage; GetObjectsWithOuter(RedirectorPackage, AssetsInRedirectorPackage, /*bIncludeNestedObjects=*/false); UMetaData* PackageMetaData = NULL; bool bContainsAtLeastOneOtherAsset = false; for ( auto ObjIt = AssetsInRedirectorPackage.CreateConstIterator(); ObjIt; ++ObjIt ) { if ( UObjectRedirector* Redirector = Cast<UObjectRedirector>(*ObjIt) ) { Redirector->RemoveFromRoot(); ObjectsToDelete.Add(Redirector); } else if ( UMetaData* MetaData = Cast<UMetaData>(*ObjIt) ) { PackageMetaData = MetaData; } else { bContainsAtLeastOneOtherAsset = true; } } if ( !bContainsAtLeastOneOtherAsset ) { RedirectorPackage->RemoveFromRoot(); // @todo we shouldnt be worrying about metadata objects here, ObjectTools::CleanUpAfterSuccessfulDelete should if ( PackageMetaData ) { PackageMetaData->RemoveFromRoot(); ObjectsToDelete.Add(PackageMetaData); } } // This redirector will be deleted, NULL the reference here RedirectorRefs.Redirector = NULL; } } if ( ObjectsToDelete.Num() > 0 ) { ObjectTools::DeleteObjects(ObjectsToDelete, false); } }
bool LocalizationCommandletTasks::ReportLoadedAudioAssets(const TArray<ULocalizationTarget*>& Targets, const TOptional<FString>& CultureName) { TSet<FString> LoadedDialogueWaveAssets; TSet<FString> LoadedSoundWaveAssets; for (const ULocalizationTarget* Target : Targets) { const FString RootAssetPath = Target->IsMemberOfEngineTargetSet() ? TEXT("/Engine") : TEXT("/Game"); TArray<FString> CulturesToTest; { if (CultureName.IsSet()) { CulturesToTest.Add(CultureName.GetValue()); } else { CulturesToTest.Reserve(Target->Settings.SupportedCulturesStatistics.Num()); for (const FCultureStatistics& CultureData : Target->Settings.SupportedCulturesStatistics) { CulturesToTest.Add(CultureData.CultureName); } } } TArray<FString> DialogueWavePathsToTest; TArray<FString> SoundWavePathsToTest; { const FString NativeCulture = Target->Settings.SupportedCulturesStatistics.IsValidIndex(Target->Settings.NativeCultureIndex) ? Target->Settings.SupportedCulturesStatistics[Target->Settings.NativeCultureIndex].CultureName : FString(); const bool bImportNativeAsSource = Target->Settings.ImportDialogueSettings.bImportNativeAsSource && !NativeCulture.IsEmpty(); if (bImportNativeAsSource) { DialogueWavePathsToTest.Add(RootAssetPath); SoundWavePathsToTest.Add(RootAssetPath / Target->Settings.ImportDialogueSettings.ImportedDialogueFolder); } for (const FString& Culture : CulturesToTest) { if (bImportNativeAsSource && Culture == NativeCulture) { continue; } DialogueWavePathsToTest.Add(RootAssetPath / TEXT("L10N") / Culture); SoundWavePathsToTest.Add(RootAssetPath / TEXT("L10N") / Culture / Target->Settings.ImportDialogueSettings.ImportedDialogueFolder); } } ForEachObjectOfClass(UDialogueWave::StaticClass(), [&](UObject* InObject) { const FString ObjectPath = InObject->GetPathName(); auto FindAssetPathPredicate = [&](const FString& InAssetPath) -> bool { return ObjectPath.StartsWith(InAssetPath, ESearchCase::IgnoreCase); }; if (DialogueWavePathsToTest.ContainsByPredicate(FindAssetPathPredicate)) { LoadedDialogueWaveAssets.Add(ObjectPath); } }); ForEachObjectOfClass(USoundWave::StaticClass(), [&](UObject* InObject) { const FString ObjectPath = InObject->GetPathName(); auto FindAssetPathPredicate = [&](const FString& InAssetPath) -> bool { return ObjectPath.StartsWith(InAssetPath, ESearchCase::IgnoreCase); }; if (SoundWavePathsToTest.ContainsByPredicate(FindAssetPathPredicate)) { LoadedSoundWaveAssets.Add(ObjectPath); } }); } if (LoadedDialogueWaveAssets.Num() > 0 || LoadedSoundWaveAssets.Num() > 0) { FTextBuilder MsgBuilder; MsgBuilder.AppendLine(LOCTEXT("Warning_LoadedAudioAssetsMsg", "The following audio assets have been loaded by the editor and may cause the dialogue import to fail as their files will be read-only.")); MsgBuilder.AppendLine(FText::GetEmpty()); MsgBuilder.AppendLine(LOCTEXT("Warning_LoadedAudioAssetsMsg_Continue", "Do you want to continue?")); if (LoadedDialogueWaveAssets.Num() > 0) { MsgBuilder.AppendLine(FText::GetEmpty()); MsgBuilder.AppendLine(LOCTEXT("Warning_LoadedAudioAssetsMsg_DialogueWaves", "Dialogue Waves:")); MsgBuilder.Indent(); for (const FString& LoadedDialogueWaveAsset : LoadedDialogueWaveAssets) { MsgBuilder.AppendLine(LoadedDialogueWaveAsset); } MsgBuilder.Unindent(); } if (LoadedSoundWaveAssets.Num() > 0) { MsgBuilder.AppendLine(FText::GetEmpty()); MsgBuilder.AppendLine(LOCTEXT("Warning_LoadedAudioAssetsMsg_SoundWaves", "Sound Waves:")); MsgBuilder.Indent(); for (const FString& LoadedSoundWaveAsset : LoadedSoundWaveAssets) { MsgBuilder.AppendLine(LoadedSoundWaveAsset); } MsgBuilder.Unindent(); } const FText MsgTitle = LOCTEXT("Warning_LoadedAudioAssetsTitle", "Warning - Loaded Audio Assets"); return FMessageDialog::Open(EAppMsgType::YesNo, MsgBuilder.ToText(), &MsgTitle) == EAppReturnType::Yes; } return true; }