// Backup a file bool BackupFile(const FString& SrcFilename, const FString& DstFilename) { if (IFileManager::Get().Copy(*DstFilename, *SrcFilename) == COPY_OK) { return true; } // log error FMessageLog EditorErrors("EditorErrors"); if(!FPaths::FileExists(SrcFilename)) { FFormatNamedArguments Arguments; Arguments.Add(TEXT("FileName"), FText::FromString(SrcFilename)); EditorErrors.Warning(FText::Format(LOCTEXT("UnsuccessfulBackup_NoExist_Notification", "Unsuccessful backup! {FileName} does not exist!"), Arguments)); } else if(IFileManager::Get().IsReadOnly(*DstFilename)) { FFormatNamedArguments Arguments; Arguments.Add(TEXT("FileName"), FText::FromString(DstFilename)); EditorErrors.Warning(FText::Format(LOCTEXT("UnsuccessfulBackup_ReadOnly_Notification", "Unsuccessful backup! {FileName} is read-only!"), Arguments)); } else { FFormatNamedArguments Arguments; Arguments.Add(TEXT("SourceFileName"), FText::FromString(SrcFilename)); Arguments.Add(TEXT("BackupFileName"), FText::FromString(DstFilename)); // We don't specifically know why it failed, this is a fallback. EditorErrors.Warning(FText::Format(LOCTEXT("UnsuccessfulBackup_Fallback_Notification", "Unsuccessful backup of {SourceFileName} to {BackupFileName}"), Arguments)); } EditorErrors.Notify(LOCTEXT("BackupUnsuccessful_Title", "Backup Unsuccessful!")); return false; }
UClass* FClassData::GetClass() { UClass* RetClass = Class.Get(); if (RetClass == NULL && GeneratedClassPackage.Len()) { GWarn->BeginSlowTask(LOCTEXT("LoadPackage", "Loading Package..."), true); UPackage* Package = LoadPackage(NULL, *GeneratedClassPackage, LOAD_NoRedirects); if (Package) { Package->FullyLoad(); UObject* Object = FindObject<UObject>(Package, *AssetName); GWarn->EndSlowTask(); UBlueprint* BlueprintOb = Cast<UBlueprint>(Object); RetClass = BlueprintOb ? *BlueprintOb->GeneratedClass : Object->GetClass(); Class = RetClass; } else { GWarn->EndSlowTask(); FMessageLog EditorErrors("EditorErrors"); EditorErrors.Error(LOCTEXT("PackageLoadFail", "Package Load Failed")); EditorErrors.Info(FText::FromString(GeneratedClassPackage)); EditorErrors.Notify(LOCTEXT("PackageLoadFail", "Package Load Failed")); } } return RetClass; }
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!")); }
bool FMRUList::VerifyMRUFile(int32 InItem) { check( InItem > -1 && InItem < GetMaxItems() ); const FString filename = Items[InItem]; // If the file doesn't exist, tell the user about it, remove the file from the list if( IFileManager::Get().FileSize( *filename ) == -1 ) { FMessageLog EditorErrors("EditorErrors"); FFormatNamedArguments Arguments; Arguments.Add(TEXT("FileName"), FText::FromString(filename)); EditorErrors.Warning(FText::Format( NSLOCTEXT("MRUList", "Error_FileDoesNotExist", "File does not exist : '{FileName}'. It will be removed from the recent items list."), Arguments ) ); EditorErrors.Notify(NSLOCTEXT("MRUList", "Notification_FileDoesNotExist", "File does not exist! Removed from recent items list!")); RemoveMRUItem( InItem ); WriteToINI(); return false; } // Otherwise, move the file to the top of the list MoveToTop( InItem ); WriteToINI(); return true; }
void FActorDropTarget::OnDrop(FDragDropPayload& DraggedObjects, UWorld& World, const FDragValidationInfo& ValidationInfo, TSharedRef<SWidget> DroppedOnWidget) { AActor* DropActor = Actor.Get(); if (!DropActor) { return; } FActorArray DraggedActors = DraggedObjects.Actors.GetValue(); FMessageLog EditorErrors("EditorErrors"); EditorErrors.NewPage(LOCTEXT("ActorAttachmentsPageLabel", "Actor attachment")); if (ValidationInfo.TooltipType == FActorDragDropGraphEdOp::ToolTip_CompatibleMultipleDetach || ValidationInfo.TooltipType == FActorDragDropGraphEdOp::ToolTip_CompatibleDetach) { const FScopedTransaction Transaction( LOCTEXT("UndoAction_DetachActors", "Detach actors") ); for (const auto& WeakActor : DraggedActors) { if (auto* DragActor = WeakActor.Get()) { DetachActorFromParent(DragActor); } } } else if (ValidationInfo.TooltipType == FActorDragDropGraphEdOp::ToolTip_CompatibleMultipleAttach || ValidationInfo.TooltipType == FActorDragDropGraphEdOp::ToolTip_CompatibleAttach) { // Show socket chooser if we have sockets to select //@TODO: Should create a menu for each component that contains sockets, or have some form of disambiguation within the menu (like a fully qualified path) // Instead, we currently only display the sockets on the root component USceneComponent* Component = DropActor->GetRootComponent(); if ((Component != NULL) && (Component->HasAnySockets())) { // Create the popup FSlateApplication::Get().PushMenu( DroppedOnWidget, SNew(SSocketChooserPopup) .SceneComponent( Component ) .OnSocketChosen_Static(&FActorDropTarget::PerformAttachment, Actor, MoveTemp(DraggedActors) ), FSlateApplication::Get().GetCursorPos(), FPopupTransitionEffect( FPopupTransitionEffect::TypeInPopup ) ); } else { PerformAttachment(NAME_None, Actor, MoveTemp(DraggedActors)); } } // Report errors EditorErrors.Notify(NSLOCTEXT("ActorAttachmentError", "AttachmentsFailed", "Attachments Failed!")); }
void FAssetFixUpRedirectors::ReportFailures(const TArray<FRedirectorRefs>& RedirectorsToFix) const { FMessageLog EditorErrors("EditorErrors"); bool bTitleOutput = false; for ( auto RedirectorIt = RedirectorsToFix.CreateConstIterator(); RedirectorIt; ++RedirectorIt ) { const FRedirectorRefs& RedirectorRefs = *RedirectorIt; if ( !RedirectorRefs.bRedirectorValidForFixup ) { if(!bTitleOutput) { EditorErrors.Info(LOCTEXT("RedirectorFixupFailedMessage", "The following redirectors could not be completely fixed up")); bTitleOutput = true; } FFormatNamedArguments Arguments; Arguments.Add(TEXT("PackageName"), FText::FromName(RedirectorRefs.RedirectorPackageName)); Arguments.Add(TEXT("FailureReason"), FText::FromString(RedirectorRefs.FailureReason.ToString())); EditorErrors.Warning(FText::Format(LOCTEXT("RedirectorFixupFailedReason", "{PackageName} - {FailureReason}"), Arguments )); } } EditorErrors.Open(); }