FString FChunkManifestGenerator::CreateCookerFileOrderString(const TMap<FName, FAssetData*>& InAssetData, const TArray<FName>& InMaps) { FString FileOrderString; TArray<FAssetData*> TopLevelNodes; for (auto Asset : InAssetData) { auto PackageName = Asset.Value->PackageName; TArray<FName> Referencers; AssetRegistry.GetReferencers(PackageName, Referencers); bool bIsTopLevel = true; bool bIsMap = InMaps.Contains(PackageName); if (!bIsMap && Referencers.Num() > 0) { for (auto ReferencerName : Referencers) { if (InAssetData.Contains(ReferencerName)) { bIsTopLevel = false; break; } } } if (bIsTopLevel) { if (bIsMap) { TopLevelNodes.Insert(Asset.Value, 0); } else { TopLevelNodes.Insert(Asset.Value, TopLevelNodes.Num()); } } } TArray<FName> FileOrder; TArray<FName> EncounteredNames; for (auto Asset : TopLevelNodes) { AddAssetToFileOrderRecursive(Asset, FileOrder, EncounteredNames, InAssetData, InMaps); } int32 CurrentIndex = 0; for (auto PackageName : FileOrder) { auto Asset = InAssetData[PackageName]; bool bIsMap = InMaps.Contains(Asset->PackageName); auto Filename = FPackageName::LongPackageNameToFilename(Asset->PackageName.ToString(), bIsMap ? FPackageName::GetMapPackageExtension() : FPackageName::GetAssetPackageExtension()); ConvertFilenameToPakFormat(Filename); auto Line = FString::Printf(TEXT("\"%s\" %i\n"), *Filename, CurrentIndex++); FileOrderString.Append(Line); } return FileOrderString; }
void FCompilerResultsLog::InternalLogEvent(const FCompilerEvent& InEvent, int32 InDepth) { const int EventTimeMs = (int)((InEvent.FinishTime - InEvent.StartTime) * 1000); if(EventTimeMs >= EventDisplayThresholdMs) { // Skip display of the top-most event since that time has already been logged if(InDepth > 0) { FString EventString = FString::Printf(TEXT("- %s"), *InEvent.Name); if(InEvent.Counter > 0) { EventString.Append(FString::Printf(TEXT(" (%d)"), InEvent.Counter + 1)); } FFormatNamedArguments Args; Args.Add(TEXT("EventTimeMs"), EventTimeMs); EventString.Append(FText::Format(LOCTEXT("PerformanceSummaryEventTime", " [{EventTimeMs} ms]"), Args).ToString()); FString IndentString = FString::Printf(TEXT("%*s"), (InDepth - 1) << 1, TEXT("")); Note(*FString::Printf(TEXT("%s%s"), *IndentString, *EventString)); } const int32 NumChildEvents = InEvent.ChildEvents.Num(); for(int32 i = 0; i < NumChildEvents; ++i) { InternalLogEvent(InEvent.ChildEvents[i].Get(), InDepth + 1); } } }
FText SLocalizationDashboardTargetRow::GetCulturesText() const { FLocalizationTargetSettings* const TargetSettings = GetTargetSettings(); if (TargetSettings) { TArray<FString> OrderedCultureNames; OrderedCultureNames.Add(TargetSettings->NativeCultureStatistics.CultureName); for (auto& ForeignCultureStatistics : TargetSettings->SupportedCulturesStatistics) { OrderedCultureNames.Add(ForeignCultureStatistics.CultureName); } FString Result; for (FString& CultureName : OrderedCultureNames) { const FCulturePtr Culture = FInternationalization::Get().GetCulture(CultureName); if (Culture.IsValid()) { const FString CultureDisplayName = Culture->GetDisplayName(); if (!Result.IsEmpty()) { Result.Append(TEXT(", ")); } Result.Append(CultureDisplayName); } } return FText::FromString(Result); } return FText::GetEmpty(); }
/** * Create path symbol path. * Reference: https://msdn.microsoft.com/en-us/library/ms681416%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396 */ static FString GetRemoteStorage(const FString& DownstreamStorage) { TArray<FString> RemoteStorage; GConfig->GetArray(CrashReporterSettings, TEXT("RemoteStorage"), RemoteStorage, GEditorPerProjectIni); if (RemoteStorage.Num() > 0) { FString SymbolStorage; for (int StorageIndex = 0; StorageIndex < RemoteStorage.Num(); ++StorageIndex) { if (StorageIndex > 0) { SymbolStorage.AppendChar(';'); } SymbolStorage.Append(TEXT("SRV*")); SymbolStorage.Append(DownstreamStorage); SymbolStorage.AppendChar('*'); SymbolStorage.Append(RemoteStorage[StorageIndex]); } return SymbolStorage; } else { return FString(); } }
void UCompositionGraphCaptureSettings::OnLoadConfig(FMovieSceneCaptureSettings& InSettings) { // Add .{frame} if it doesn't already exist FString OutputFormat = InSettings.OutputFormat; if (!OutputFormat.Contains(TEXT("{frame}"))) { OutputFormat.Append(TEXT(".{frame}")); InSettings.OutputFormat = OutputFormat; } // Add {material} if it doesn't already exist if (!OutputFormat.Contains(TEXT("{material}"))) { int32 FramePosition = OutputFormat.Find(TEXT(".{frame}")); if (FramePosition != INDEX_NONE) { OutputFormat.InsertAt(FramePosition, TEXT("{material}")); } else { OutputFormat.Append(TEXT("{material}")); } InSettings.OutputFormat = OutputFormat; } Super::OnLoadConfig(InSettings); }
FString AProtherer::GetDialogText(FString* text) { FString* retVal = new FString(""); retVal->Append(*this->OrcName); retVal->Append(*text); return *retVal; }
FString UStringUtilities::JoinStringsWithNewlines(TArray<FString> strings) { FString result; for ( auto Itr(strings.CreateIterator()); Itr; Itr++ ) { result.Append(*Itr); if ( Itr + 1 ) { result.Append("\n"); } } return result; }
void AppendToString(const FStringFormatArg& Arg, FString& StringToAppendTo) { switch(Arg.Type) { case FStringFormatArg::Int: StringToAppendTo.Append(LexicalConversion::ToString(Arg.IntValue)); break; case FStringFormatArg::UInt: StringToAppendTo.Append(LexicalConversion::ToString(Arg.UIntValue)); break; case FStringFormatArg::Double: StringToAppendTo.Append(LexicalConversion::ToString(Arg.DoubleValue)); break; case FStringFormatArg::String: StringToAppendTo.AppendChars(*Arg.StringValue, Arg.StringValue.Len()); break; case FStringFormatArg::StringLiteral: StringToAppendTo += Arg.StringLiteralValue; break; } }
HRESULT FMediaPlayerVLC_Ex::AddPlaylistItem(const tchar* pFileName, IMediaOptions* pOptions) { if (!m_pPlaylist) return E_FAIL; USES_CONVERSION; long pos = 0; LPSAFEARRAY pSA = SafeArrayCreateVector(VT_VARIANT, 0, 1); if (pOptions->m_Vout == "") { //If GetWindowsVersion() == WindowsVista => "direct3d" //else "directx"; pOptions->m_Vout = "direct3d"; } FString StrVout; StrVout.Format(":vout=%s;", pOptions->m_Vout); FString Options = StrVout; m_bHasSubs = TRUE; if (pOptions->m_SubPath.GetLength() > 0) { Options.Append(";:sub-file: "); Options.Append(pOptions->m_SubPath); } Options.Append(";:sub-autodetect-file;:sub-autodetect-fuzzy:3;"); if (pOptions->rtOffset > 0) { FString StartTime; StartTime.Format(";:start-time:%d;", pOptions->rtOffset / 1000); Options.Append(StartTime); } _variant_t var(_bstr_t(T2OLE(Options))); SafeArrayPutElement(pSA, &pos, (void FAR *)&var); _variant_t v; v.parray = pSA; v.vt = VT_ARRAY; CComVariant vtName = L"LTV_Video"; BSTR bStrName = SysAllocString(T2OLE(pFileName)); long lId = 0; m_pPlaylist->get_itemCount(&lId); return m_pPlaylist->add(bStrName, vtName, v, &lId); }
void AProtherer::PrintPath(TArray<AWaypoint*> path) { FString* text = new FString("Printing Path with "); text->AppendInt(path.Num()); text->Append(" hops: "); for (int i = 0; i < path.Num(); ++i) { text->Append(path[i]->Name); text->Append(", "); } sayDialog(text); }
FString USQLiteDatabase::ConstructQuery(TArray<FString> Tables, TArray<FString> Fields, FSQLiteQueryFinalizedQuery QueryObject, int32 MaxResults, int32 ResultOffset) { FString fieldString; for (int32 i = 0; i < Fields.Num(); i++) { fieldString.Append(Fields[i] + (i < Fields.Num() - 1 ? "," : "")); } FString tableList = FString::Join(Tables, TEXT(",")); TArray<FString> allQueryParams; allQueryParams.Add(FString::Printf(TEXT("SELECT %s FROM %s"), *fieldString, *tableList)); if (QueryObject.Query.Len() > 0) { allQueryParams.Add(FString::Printf(TEXT("WHERE %s"), *QueryObject.Query)); } if (MaxResults >= 0) { allQueryParams.Add(FString::Printf(TEXT("LIMIT %i"), MaxResults)); } if (ResultOffset > 0) { allQueryParams.Add(FString::Printf(TEXT("OFFSET %i"), ResultOffset)); } FString finalQuery = FString::Join(allQueryParams, TEXT(" ")); return finalQuery; }
void FSlateImageRun::AppendTextTo(FString& AppendToText, const FTextRange& PartialRange) const { check(Range.BeginIndex <= PartialRange.BeginIndex); check(Range.EndIndex >= PartialRange.EndIndex); AppendToText.Append(**Text + PartialRange.BeginIndex, PartialRange.Len()); }
bool FQtCreatorSourceCodeAccessor::OpenSourceFiles(const TArray<FString>& AbsoluteSourcePaths) { for ( const FString& SourcePath : AbsoluteSourcePaths ) { FString Editor = FString(TEXT("/usr/bin/qtcreator")); FString Args = FString(TEXT("-client ")); // Add this to handle spaces in path names. const FString NewSourcePath = FString::Printf(TEXT("\"%s\""), *SourcePath); Args.Append(NewSourcePath); if(!(FLinuxPlatformProcess::CreateProc(*Editor, *Args, true, true, false, nullptr, 0, nullptr, nullptr).IsValid())) { return false; } } return true; }
void UJanusExporterTool::SearchForExport() { // If not prompting individual files, prompt the user to select a target directory. IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get(); void* ParentWindowWindowHandle = NULL; IMainFrameModule& MainFrameModule = FModuleManager::LoadModuleChecked<IMainFrameModule>(TEXT("MainFrame")); const TSharedPtr<SWindow>& MainFrameParentWindow = MainFrameModule.GetParentWindow(); if (MainFrameParentWindow.IsValid() && MainFrameParentWindow->GetNativeWindow().IsValid()) { ParentWindowWindowHandle = MainFrameParentWindow->GetNativeWindow()->GetOSWindowHandle(); } FString FolderName; const FString Title = NSLOCTEXT("UnrealEd", "ChooseADirectory", "Choose A Directory").ToString(); const bool bFolderSelected = DesktopPlatform->OpenDirectoryDialog( ParentWindowWindowHandle, Title, ExportPath, FolderName ); if (bFolderSelected) { ExportPath = FolderName.Append("//"); } }
/* Given the predicted location of the Player and the List of older player locations get the waypoint that probably gives the next path */ AWaypoint* AProtherer::PredictedDestinationFor(AWaypoint* predictedWaypoin) { AWaypoint* ret = NULL; if (!FinalDestination) return predictedWaypoin; // Get all neighbors for the predicted waypoint. TArray<AWaypoint*> list = GetAllNeighbors(predictedWaypoin); float minDist = 999999999999999999.0f; for (int i = 0; i < list.Num(); ++i) { float diff = FVector::Dist(list[i]->GetActorLocation(), FinalDestination->GetActorLocation()); if (diff < minDist) { minDist = diff; ret = list[i]; } } if (ret) { FString* text = new FString("Chosing Waypoint closer to Destination - "); text->Append(ret->Name); this->sayDialog(text); return ret; } return predictedWaypoin; }
bool FBuildDataCompactifier::DeleteNonReferencedManifests(TArray<FString>& AllManifests, const TArray<FString>& ManifestsToKeep, TArray<FString>& DeletedManifests, uint64& BytesDeleted) const { if (ManifestsToKeep.Num() == 0) { return true; // We don't need to delete anything, just return a success response } for (const auto& Manifest : AllManifests) { if (!ManifestsToKeep.Contains(Manifest)) { FString LogMsg = FString::Printf(TEXT("Found deleteable manifest file %s"), *Manifest); FString ManifestPath = CloudDir / Manifest; DeletedManifests.Add(Manifest); BytesDeleted += IFileManager::Get().FileSize(*ManifestPath); if (!bPreview && !bNoPatchDelete) { IFileManager::Get().Delete(*ManifestPath); if (FPlatformFileManager::Get().GetPlatformFile().FileExists(*ManifestPath)) { // Something went wrong ... the file still exists! GLog->Logf(ELogVerbosity::Error, TEXT("Compactify could not delete manifest file %s"), *Manifest); return false; } LogMsg.Append(TEXT(" ... deleted")); } GLog->Logf(*LogMsg); } } AllManifests = ManifestsToKeep; return true; // None of the manifests we need to get rid of still exist, we succeeded }
FText FEditorPropertyPath::GetDisplayText() const { FString DisplayText; for ( int32 SegmentIndex = 0; SegmentIndex < Segments.Num(); SegmentIndex++ ) { const FEditorPropertyPathSegment& Segment = Segments[SegmentIndex]; DisplayText.Append(Segment.GetMemberDisplayText().ToString()); if ( SegmentIndex < ( Segments.Num() - 1 ) ) { DisplayText.Append(TEXT(".")); } } return FText::FromString(DisplayText); }
AWaypoint* AProtherer::GetNextWaypoint() { AWaypoint* predictedLocation = PredictPlayerPosition(); AWaypoint* nextWaypoint; FString* text; if (predictedLocation) { //this->sayDialog(new FString("Found Predicted Location.")); if (CanSeePlayer) { nextWaypoint = NextWaypointTowards(predictedLocation); CanSeePlayer = false; } else { nextWaypoint = NextWaypointTowards(PredictedDestinationFor(predictedLocation)); } if (nextWaypoint) return nextWaypoint; text = new FString("Error Condition: Moving to Predicted Waypoint - "); text->Append(predictedLocation->Name); this->sayDialog(text); return predictedLocation; } this->sayDialog(new FString("Error Condition: Moving to default Location.")); return this->CurrentLocation->WalkNeighbors[0]; }
void FDefaultRichTextMarkupWriter::Write(const TArray<FRichTextLine>& InLines, FString& Output) { for (int32 LineIndex = 0; LineIndex < InLines.Num(); ++LineIndex) { const FRichTextLine& Line = InLines[LineIndex]; // Append \n to the end of the previous line if(LineIndex > 0) { Output.AppendChar('\n'); } for (const FRichTextRun& Run : Line.Runs) { // Our rich-text format takes the form of <Name metakey1="metavalue1" metakey2="metavalue2">The Text</> const bool bHasTag = !Run.Info.Name.IsEmpty(); if (bHasTag) { Output.AppendChar('<'); Output.Append(Run.Info.Name); for(const TPair<FString, FString>& MetaDataEntry : Run.Info.MetaData) { Output.AppendChar(' '); Output.Append(MetaDataEntry.Key); Output.AppendChar('='); Output.AppendChar('"'); Output.Append(MetaDataEntry.Value); Output.AppendChar('"'); } Output.AppendChar('>'); } FString RunText = Run.Text; EscapeText(RunText); Output.Append(RunText); if (bHasTag) { Output.Append(TEXT("</>")); } } } }
bool FCodeLiteSourceCodeAccessor::Launch(const TArray<FString>& InArgs) { if (Location.IsValid()) { FString ArgsString; for (const FString& Arg : InArgs) { ArgsString.Append(Arg); ArgsString.Append(TEXT(" ")); } uint32 ProcessID; FProcHandle hProcess = FPlatformProcess::CreateProc(*Location.URL, *ArgsString, true, false, false, &ProcessID, 0, nullptr, nullptr, nullptr); return hProcess.IsValid(); } return false; }
void FBuildDataCompactifier::DeleteFile(const FString& FilePath) const { FString LogMsg = FString::Printf(TEXT("Deprecated data %s"), *FilePath); if (!bNoPatchDelete && !bPreview) { LogMsg = LogMsg.Append(TEXT(" ... deleted")); IFileManager::Get().Delete(*FilePath); } GLog->Logf(*LogMsg); }
void EndReadWriteRecords() { // Update the list of sessions in storage to match SessionRecords FString SessionListString; if (SessionRecords.Num() > 0) { for (FSessionRecord& Session : SessionRecords) { SessionListString.Append(Session.SessionId); SessionListString.Append(TEXT(",")); } SessionListString.RemoveAt(SessionListString.Len() - 1); } FString ListSectionName = GetStoreSectionString(EditorAnalyticsDefs::SessionRecordListSection); FPlatformMisc::SetStoredValue(EditorAnalyticsDefs::StoreId, ListSectionName, TEXT("SessionList"), SessionListString); // Clear SessionRecords member SessionRecords.Empty(); }
FString GetCallstack()const { FString Ret; const FFunctionContext* Curr = this; while (Curr) { if (Curr->Script) { Ret.Append(*(Curr->Script->GetPathName())); } else { Ret.Append(TEXT("Unknown")); } Ret.Append(TEXT("\n")); Curr = Curr->Parent; } return Ret; }
void SPaperExtractSpritesDialog::CreateExtractedSprites() { FAssetToolsModule& AssetToolsModule = FModuleManager::Get().LoadModuleChecked<FAssetToolsModule>("AssetTools"); FContentBrowserModule& ContentBrowserModule = FModuleManager::LoadModuleChecked<FContentBrowserModule>("ContentBrowser"); TArray<UObject*> ObjectsToSync; // Create the factory used to generate the sprite auto SpriteFactory = NewObject<UPaperSpriteFactory>(); SpriteFactory->InitialTexture = SourceTexture; // Create the sprite FString Name; FString PackageName; FScopedSlowTask Feedback(ExtractedSprites.Num(), NSLOCTEXT("Paper2D", "Paper2D_ExtractSpritesFromTexture", "Extracting Sprites From Texture")); Feedback.MakeDialog(true); for (const FPaperExtractedSprite ExtractedSprite : ExtractedSprites) { Feedback.EnterProgressFrame(1, NSLOCTEXT("Paper2D", "Paper2D_ExtractSpritesFromTexture", "Extracting Sprites From Texture")); SpriteFactory->bUseSourceRegion = true; const FIntRect& ExtractedRect = ExtractedSprite.Rect; SpriteFactory->InitialSourceUV = FVector2D(ExtractedRect.Min.X, ExtractedRect.Min.Y); SpriteFactory->InitialSourceDimension = FVector2D(ExtractedRect.Width(), ExtractedRect.Height()); // Get a unique name for the sprite // Extracted sprite name is a name, we insert a _ as we're appending this to the texture name // Opens up doors to renaming the sprites in the editor, and still ending up with TextureName_UserSpriteName FString Suffix = TEXT("_"); Suffix.Append(ExtractedSprite.Name); AssetToolsModule.Get().CreateUniqueAssetName(SourceTexture->GetOutermost()->GetName(), Suffix, /*out*/ PackageName, /*out*/ Name); const FString PackagePath = FPackageName::GetLongPackagePath(PackageName); if (UObject* NewAsset = AssetToolsModule.Get().CreateAsset(Name, PackagePath, UPaperSprite::StaticClass(), SpriteFactory)) { ObjectsToSync.Add(NewAsset); } if (GWarn->ReceivedUserCancel()) { break; } } if (ObjectsToSync.Num() > 0) { ContentBrowserModule.Get().SyncBrowserToAssets(ObjectsToSync); } }
FName WidgetMaterialTrackUtilities::GetTrackNameFromPropertyNamePath( const TArray<FName>& PropertyNamePath ) { if ( PropertyNamePath.Num() == 0 ) { return FName(); } FString TrackName = PropertyNamePath[0].ToString(); for ( int32 i = 1; i < PropertyNamePath.Num(); i++ ) { TrackName.AppendChar( '.' ); TrackName.Append( PropertyNamePath[i].ToString() ); } return FName( *TrackName ); }
bool FXCodeSourceCodeAccessor::OpenFileAtLine(const FString& FullPath, int32 LineNumber, int32 ColumnNumber) { FString Editor = FString(TEXT("/usr/bin/sensible-editor")); FString Args = FullPath; Args.Append(" +").Append(FString::FromInt(LineNumber)); if(FLinuxPlatformProcess::CreateProc(*Editor, *Args, true, true, false, nullptr, 0, nullptr, nullptr).IsValid()) return true; return false; }
// Finds all .OBJ files in the specified Directory, relative to the Content // path of the game. TArray<FString> URealSenseBlueprintLibrary::GetMeshFiles(FString Directory) { // Ensure that the directory ends with a trailing slash if (Directory.EndsWith("/") == false) { Directory.Append("/"); } // Get the absolute path of the game's Content directory and append the // specified path to it, along with the filename. FString Dir = FPaths::GameContentDir() + Directory + TEXT("*.obj"); IFileManager& FileManager = IFileManager::Get(); TArray<FString> MeshFiles; FileManager.FindFiles(MeshFiles, *Dir, true, false); return MeshFiles; }
bool FQtCreatorSourceCodeAccessor::OpenSolutionAtPath(const FString& InSolutionPath) { FString SolutionPath = InSolutionPath; if (!SolutionPath.EndsWith(TEXT(".pro"))) { SolutionPath += TEXT(".pro"); } if ( FPaths::FileExists( SolutionPath ) ) { FString FilenamePart; FString ExtensionPart; FString ProjectFolder; FPaths::Split(SolutionPath, ProjectFolder, FilenamePart, ExtensionPart); FString Filename = FilenamePart + FString(TEXT(".pro")); FString CodeSolutionFile = FPaths::Combine(*ProjectFolder, *Filename); FString Editor = FString(TEXT("/usr/bin/qtcreator")); FString Args = FString(TEXT("-client ")); // Add this to handle spaces in path names. const FString NewFullPath = FString::Printf(TEXT("\"%s\""), *CodeSolutionFile); Args.Append(NewFullPath); if(FLinuxPlatformProcess::CreateProc(*Editor, *Args, true, true, false, nullptr, 0, nullptr, nullptr).IsValid()) { return true; } } return false; }
AWaypoint* AProtherer::NextWaypointTowards(AWaypoint* destination) { FString* text = NULL; if (CurrentLocation == destination) { return destination; } /* text = new FString("Finding path from "); text->Append(CurrentLocation->Name); text->Append(" to "); text->Append(destination->Name); sayDialog(text); */ // 1. Get the shortest path from CurrentLocation to destination.. TArray<AWaypoint*> emptyList; TArray<AWaypoint*> shortestPath = GetShortestPathBetween(CurrentLocation, destination, emptyList); // If there is a shortest path, return the frst element from it!. if (shortestPath.Num() > 1) { //sayDialog(new FString("Found Shortest Path! Here it is:")); PrintPath(shortestPath); text = new FString("Going to the first node of the shortest path "); text->Append(shortestPath[1]->Name); sayDialog(text); return shortestPath[1]; } // If there is no shortest path from CurrentLocation to Destination (which should not happen!) // then return null. sayDialog(new FString("Error Condition: No Path found!")); return NULL; }
bool FQtCreatorSourceCodeAccessor::OpenFileAtLine(const FString& FullPath, int32 LineNumber, int32 ColumnNumber) { FString Editor = FString(TEXT("/usr/bin/qtcreator")); FString Args = FString(TEXT("-client ")); // Add this to handle spaces in path names. const FString NewFullPath = FString::Printf(TEXT("\"%s:%d\""), *FullPath, LineNumber); Args.Append(NewFullPath); // .Append(TEXT(":")).Append(FString::FromInt(LineNumber)); if (FLinuxPlatformProcess::CreateProc(*Editor, *Args, true, true, false, nullptr, 0, nullptr, nullptr).IsValid()) { return true; } return false; }