/** * Called to recompile the out of date blueprint for the current selection set */ void RecompileOutOfDateKismetForSelection() { int32 BlueprintFailures = 0; // Run thru all selected actors, looking for out of date blueprints FSelectionIterator SelectedActorItr( GEditor->GetSelectedActorIterator() ); for ( ; SelectedActorItr; ++SelectedActorItr) { AActor* CurrentActor = Cast<AActor>(*SelectedActorItr); UBlueprint* Blueprint = Cast<UBlueprint>(CurrentActor->GetClass()->ClassGeneratedBy); if ((Blueprint != NULL) && (!Blueprint->IsUpToDate())) { FKismetEditorUtilities::CompileBlueprint(Blueprint); if (Blueprint->Status == BS_Error) { ++BlueprintFailures; } } } if (BlueprintFailures) { UE_LOG(LogViewportBlueprintMenu, Warning, TEXT("%d blueprints failed to be recompiled"), BlueprintFailures); } }
void UK2Node_Timeline::ExpandNode(FKismetCompilerContext& CompilerContext, UEdGraph* SourceGraph) { Super::ExpandNode(CompilerContext, SourceGraph); const UEdGraphSchema_K2* K2Schema = GetDefault<UEdGraphSchema_K2>(); UBlueprint* Blueprint = GetBlueprint(); check(Blueprint); UTimelineTemplate* Timeline = Blueprint->FindTimelineTemplateByVariableName(TimelineName); if(Timeline) { ExpandForPin(GetDirectionPin(), Timeline->GetDirectionPropertyName(), CompilerContext, SourceGraph); for(int32 i=0; i<Timeline->FloatTracks.Num(); i++) { const FName TrackName = Timeline->FloatTracks[i].TrackName; ExpandForPin(FindPin(TrackName.ToString()), Timeline->GetTrackPropertyName(TrackName), CompilerContext, SourceGraph); } for(int32 i=0; i<Timeline->VectorTracks.Num(); i++) { const FName TrackName = Timeline->VectorTracks[i].TrackName; ExpandForPin(FindPin(TrackName.ToString()), Timeline->GetTrackPropertyName(TrackName), CompilerContext, SourceGraph); } for(int32 i=0; i<Timeline->LinearColorTracks.Num(); i++) { const FName TrackName = Timeline->LinearColorTracks[i].TrackName; ExpandForPin(FindPin(TrackName.ToString()), Timeline->GetTrackPropertyName(TrackName), CompilerContext, SourceGraph); } } }
bool UMovieScene::RemoveSpawnable( const FGuid& Guid ) { bool bAnythingRemoved = false; if( ensure( Guid.IsValid() ) ) { for( auto SpawnableIter( Spawnables.CreateIterator() ); SpawnableIter; ++SpawnableIter ) { auto& CurSpawnable = *SpawnableIter; if( CurSpawnable.GetGuid() == Guid ) { Modify(); { UClass* GeneratedClass = CurSpawnable.GetClass(); UBlueprint* Blueprint = GeneratedClass ? Cast<UBlueprint>(GeneratedClass->ClassGeneratedBy) : NULL; check(NULL != Blueprint); // @todo sequencer: Also remove created Blueprint inner object. Is this sufficient? Needs to work with Undo too! Blueprint->ClearFlags( RF_Standalone ); // @todo sequencer: Probably not needed for Blueprint Blueprint->MarkPendingKill(); } RemoveObjectBinding( Guid ); // Found it! Spawnables.RemoveAt( SpawnableIter.GetIndex() ); bAnythingRemoved = true; break; } } } return bAnythingRemoved; }
UGameplayAbility::UGameplayAbility(const class FPostConstructInitializeProperties& PCIP) : Super(PCIP) { CostGameplayEffect = NULL; CooldownGameplayEffect = NULL; { static FName FuncName = FName(TEXT("K2_ShouldAbilityRespondToEvent")); UFunction* ShouldRespondFunction = GetClass()->FindFunctionByName(FuncName); HasBlueprintShouldAbilityRespondToEvent = ShouldRespondFunction && ShouldRespondFunction->GetOuter()->IsA(UBlueprintGeneratedClass::StaticClass()); } { static FName FuncName = FName(TEXT("K2_CanActivateAbility")); UFunction* CanActivateFunction = GetClass()->FindFunctionByName(FuncName); HasBlueprintCanUse = CanActivateFunction && CanActivateFunction->GetOuter()->IsA(UBlueprintGeneratedClass::StaticClass()); } { static FName FuncName = FName(TEXT("K2_ActivateAbility")); UFunction* ActivateFunction = GetClass()->FindFunctionByName(FuncName); HasBlueprintActivate = ActivateFunction && ActivateFunction->GetOuter()->IsA(UBlueprintGeneratedClass::StaticClass()); } #if WITH_EDITOR /** Autoregister abilities with the blueprint debugger in the editor.*/ if (!HasAnyFlags(RF_ClassDefaultObject)) { UBlueprint* BP = Cast<UBlueprint>(GetClass()->ClassGeneratedBy); if (BP && (BP->GetWorldBeingDebugged() == nullptr || BP->GetWorldBeingDebugged() == GetWorld())) { BP->SetObjectBeingDebugged(this); } } #endif }
TSharedRef<SDockTab> FMerge::GenerateMergeWidget(const UBlueprint& Object, TSharedRef<FBlueprintEditor> Editor) { auto ActiveTabPtr = ActiveTab.Pin(); if( ActiveTabPtr.IsValid() ) { // just bring the tab to the foreground: auto CurrentTab = FGlobalTabmanager::Get()->InvokeTab(MergeToolTabId); check( CurrentTab == ActiveTabPtr ); return ActiveTabPtr.ToSharedRef(); } // merge the local asset with the depot, SCC provides us with the last common revision as // a basis for the merge: TSharedPtr<SWidget> Contents; if (!PendingMerge(Object)) { // this should load up the merge-tool, with an asset picker, where they // can pick the asset/revisions to merge against Contents = GenerateMergeTabContents(Editor, nullptr, FRevisionInfo::InvalidRevision(), nullptr, FRevisionInfo::InvalidRevision(), &Object, FOnMergeResolved()); } else { // @todo DO: this will probably need to be async.. pulling down some old versions of assets: const FString& PackageName = Object.GetOutermost()->GetName(); const FString& AssetName = Object.GetName(); FSourceControlStatePtr SourceControlState = FMergeToolUtils::GetSourceControlState(PackageName); if (!SourceControlState.IsValid()) { DisplayErrorMessage( FText::Format( LOCTEXT("MergeFailedNoSourceControl", "Aborted Load of {0} from {1} because the source control state was invalidated") , FText::FromString(AssetName) , FText::FromString(PackageName) ) ); Contents = SNew(SHorizontalBox); } else { ISourceControlState const& SourceControlStateRef = *SourceControlState; FRevisionInfo CurrentRevInfo = FRevisionInfo::InvalidRevision(); const UBlueprint* RemoteBlueprint = Cast< UBlueprint >(LoadHeadRev(PackageName, AssetName, SourceControlStateRef, CurrentRevInfo)); FRevisionInfo BaseRevInfo = FRevisionInfo::InvalidRevision(); const UBlueprint* BaseBlueprint = Cast< UBlueprint >(LoadBaseRev(PackageName, AssetName, SourceControlStateRef, BaseRevInfo)); Contents = GenerateMergeTabContents(Editor, BaseBlueprint, BaseRevInfo, RemoteBlueprint, CurrentRevInfo, &Object, FOnMergeResolved()); } } TSharedRef<SDockTab> Tab = FGlobalTabmanager::Get()->InvokeTab(MergeToolTabId); Tab->SetContent(Contents.ToSharedRef()); ActiveTab = Tab; return Tab; }
FText UK2Node_DynamicCast::GetNodeTitle(ENodeTitleType::Type TitleType) const { if (TargetType == nullptr) { return NSLOCTEXT("K2Node_DynamicCast", "BadCastNode", "Bad cast node"); } else if (CachedNodeTitle.IsOutOfDate()) { // If casting to BP class, use BP name not class name (ie. remove the _C) FString TargetName; UBlueprint* CastToBP = UBlueprint::GetBlueprintFromClass(TargetType); if (CastToBP != NULL) { TargetName = CastToBP->GetName(); } else { TargetName = TargetType->GetName(); } FFormatNamedArguments Args; Args.Add(TEXT("TargetName"), FText::FromString(TargetName)); // FText::Format() is slow, so we cache this to save on performance CachedNodeTitle = FText::Format(NSLOCTEXT("K2Node_DynamicCast", "CastTo", "Cast To {TargetName}"), Args); } return CachedNodeTitle; }
/** * Simulates the user pressing the blueprint's compile button (will load the * blueprint first if it isn't already). * * @param BlueprintAssetPath The asset object path that you wish to compile. * @return False if we failed to load the blueprint, true otherwise */ static bool CompileBlueprint(const FString& BlueprintAssetPath) { UBlueprint* BlueprintObj = Cast<UBlueprint>(StaticLoadObject(UBlueprint::StaticClass(), NULL, *BlueprintAssetPath)); if (!BlueprintObj || !BlueprintObj->ParentClass) { UE_LOG(LogBlueprintAutomationTests, Error, TEXT("Failed to compile invalid blueprint, or blueprint parent no longer exists.")); return false; } UPackage* const BlueprintPackage = Cast<UPackage>(BlueprintObj->GetOutermost()); // compiling the blueprint will inherently dirty the package, but if there // weren't any changes to save before, there shouldn't be after bool const bStartedWithUnsavedChanges = (BlueprintPackage != nullptr) ? BlueprintPackage->IsDirty() : true; bool bIsRegeneratingOnLoad = false; bool bSkipGarbageCollection = true; FBlueprintEditorUtils::RefreshAllNodes(BlueprintObj); FKismetEditorUtilities::CompileBlueprint(BlueprintObj, bIsRegeneratingOnLoad, bSkipGarbageCollection); if (BlueprintPackage != nullptr) { BlueprintPackage->SetDirtyFlag(bStartedWithUnsavedChanges); } return true; }
bool FKismetConnectionDrawingPolicy::CanBuildRoadmap() const { UBlueprint* TargetBP = FBlueprintEditorUtils::FindBlueprintForGraphChecked(GraphObj); UObject* ActiveObject = TargetBP->GetObjectBeingDebugged(); return ActiveObject != NULL; }
//------------------------------------------------------------------------------ static UBlueprint* BlueprintNodeTemplateCacheImpl::MakeCompatibleBlueprint(TSubclassOf<UBlueprint> BlueprintClass, UClass* ParentClass, TSubclassOf<UBlueprintGeneratedClass> GeneratedClassType) { EBlueprintType BlueprintType = BPTYPE_Normal; // @TODO: BPTYPE_LevelScript requires a level outer, which we don't want to have here... can we get away without it? // if (BlueprintClass->IsChildOf<ULevelScriptBlueprint>()) // { // BlueprintType = BPTYPE_LevelScript; // } if (GeneratedClassType == nullptr) { GeneratedClassType = UBlueprintGeneratedClass::StaticClass(); } UPackage* BlueprintOuter = GetTransientPackage(); FString const DesiredName = FString::Printf(TEXT("PROTO_BP_%s"), *BlueprintClass->GetName()); FName const BlueprintName = MakeUniqueObjectName(BlueprintOuter, BlueprintClass, FName(*DesiredName)); BlueprintClass = FBlueprintEditorUtils::FindFirstNativeClass(BlueprintClass); UBlueprint* NewBlueprint = FKismetEditorUtilities::CreateBlueprint(ParentClass, BlueprintOuter, BlueprintName, BlueprintType, BlueprintClass, GeneratedClassType); NewBlueprint->SetFlags(RF_Transient); ++MadeBlueprintCount; float const AproxBlueprintSize = ApproximateMemFootprint(NewBlueprint); // track the average blueprint size, so that we can attempt to predict // whether a blueprint will fail to be cached (when the cache is near full) AverageBlueprintSize = AverageBlueprintSize * ((float)(MadeBlueprintCount-1) / MadeBlueprintCount) + (AproxBlueprintSize / MadeBlueprintCount) + 0.5f; return NewBlueprint; }
bool UK2Node_InputKey::IsCompatibleWithGraph(UEdGraph const* Graph) const { UBlueprint* Blueprint = FBlueprintEditorUtils::FindBlueprintForGraph(Graph); UEdGraphSchema_K2 const* K2Schema = Cast<UEdGraphSchema_K2>(Graph->GetSchema()); bool const bIsConstructionScript = (K2Schema != nullptr) ? K2Schema->IsConstructionScript(Graph) : false; return (Blueprint != nullptr) && Blueprint->SupportsInputEvents() && !bIsConstructionScript && Super::IsCompatibleWithGraph(Graph); }
TSharedRef<SWidget> FEditorClassUtils::GetSourceLinkFormatted(const UClass* Class, const TWeakObjectPtr<UObject> ObjectWeakPtr, const FText& BlueprintFormat, const FText& CodeFormat) { TSharedRef<SWidget> SourceHyperlink = SNew( SSpacer ); UBlueprint* Blueprint = (Class ? Cast<UBlueprint>(Class->ClassGeneratedBy) : nullptr); if (Blueprint) { struct Local { static void OnEditBlueprintClicked( TWeakObjectPtr<UBlueprint> InBlueprint, TWeakObjectPtr<UObject> InAsset ) { if (UBlueprint* BlueprintToEdit = InBlueprint.Get()) { // Set the object being debugged if given an actor reference (if we don't do this before we edit the object the editor wont know we are debugging something) if (UObject* Asset = InAsset.Get()) { check(Asset->GetClass()->ClassGeneratedBy == BlueprintToEdit); BlueprintToEdit->SetObjectBeingDebugged(Asset); } // Open the blueprint GEditor->EditObject( BlueprintToEdit ); } } }; TWeakObjectPtr<UBlueprint> BlueprintPtr = Blueprint; SourceHyperlink = SNew(SHyperlink) .Style(FEditorStyle::Get(), "Common.GotoBlueprintHyperlink") .OnNavigate_Static(&Local::OnEditBlueprintClicked, BlueprintPtr, ObjectWeakPtr) .Text(FText::Format(BlueprintFormat, FText::FromString(Blueprint->GetName()))) .ToolTipText(NSLOCTEXT("SourceHyperlink", "EditBlueprint_ToolTip", "Click to edit the blueprint")); } else if( FSourceCodeNavigation::IsCompilerAvailable() ) { FString ClassHeaderPath; if( FSourceCodeNavigation::FindClassHeaderPath( Class, ClassHeaderPath ) && IFileManager::Get().FileSize( *ClassHeaderPath ) != INDEX_NONE ) { struct Local { static void OnEditCodeClicked( FString InClassHeaderPath ) { FString AbsoluteHeaderPath = IFileManager::Get().ConvertToAbsolutePathForExternalAppForRead(*InClassHeaderPath); FSourceCodeNavigation::OpenSourceFile( AbsoluteHeaderPath ); } }; SourceHyperlink = SNew(SHyperlink) .Style(FEditorStyle::Get(), "Common.GotoNativeCodeHyperlink") .OnNavigate_Static(&Local::OnEditCodeClicked, ClassHeaderPath) .Text(FText::Format(CodeFormat, FText::FromString(FPaths::GetCleanFilename( *ClassHeaderPath ) ) ) ) .ToolTipText(FText::Format(NSLOCTEXT("SourceHyperlink", "GoToCode_ToolTip", "Click to open this source file in {0}"), FSourceCodeNavigation::GetSuggestedSourceCodeIDE())); } } return SourceHyperlink; }
FText UK2Node_AddComponent::GetNodeTitle(ENodeTitleType::Type TitleType) const { FText CachedAssetTitle; FText CachedNodeTitle; UEdGraphPin* TemplateNamePin = GetTemplateNamePin(); if (TemplateNamePin != nullptr) { FString TemplateName = TemplateNamePin->DefaultValue; UBlueprint* Blueprint = GetBlueprint(); if (UActorComponent* SourceTemplate = Blueprint->FindTemplateByName(FName(*TemplateName))) { { FFormatNamedArguments Args; Args.Add(TEXT("ComponentType"), SourceTemplate->GetClass()->GetDisplayNameText()); CachedNodeTitle = FText::Format(LOCTEXT("AddClass", "Add {ComponentType}"), Args); } UChildActorComponent* SubActorComp = Cast<UChildActorComponent>(SourceTemplate); if (const UObject* AssociatedAsset = SourceTemplate->AdditionalStatObject()) { FFormatNamedArguments Args; Args.Add(TEXT("AssetType"), AssociatedAsset->GetClass()->GetDisplayNameText()); Args.Add(TEXT("AssetName"), FText::FromString(AssociatedAsset->GetName())); CachedAssetTitle = FText::Format(LOCTEXT("AddComponentAssetDescription", "{AssetType} {AssetName}"), Args); } else if ((SubActorComp != nullptr) && (SubActorComp->GetChildActorClass() != nullptr)) { FFormatNamedArguments Args; Args.Add(TEXT("ComponentClassName"), SubActorComp->GetChildActorClass()->GetDisplayNameText()); CachedAssetTitle = FText::Format(LOCTEXT("AddChildActorComponent", "Actor Class {ComponentClassName}"), Args); } else { CachedAssetTitle = FText::GetEmpty(); } } } if (!CachedNodeTitle.IsEmpty()) { if (TitleType == ENodeTitleType::FullTitle) { return FText::Format(LOCTEXT("FullAddComponentTitle", "{0}\n{1}"), CachedNodeTitle, CachedAssetTitle); } else if (!CachedAssetTitle.IsEmpty()) { return FText::Format(LOCTEXT("ShortAddComponentTitle", "{0} [{1}]"), CachedNodeTitle, CachedAssetTitle); } else { return CachedNodeTitle; } } return Super::GetNodeTitle(TitleType); }
void UK2Node_Timeline::PrepareForCopying() { UBlueprint* Blueprint = GetBlueprint(); check(Blueprint); //Set the GUID so we can identify which timeline template the copied node should use UTimelineTemplate* Template = Blueprint->FindTimelineTemplateByVariableName(TimelineName); check(Template); TimelineGuid = Template->TimelineGuid; // hold onto the template's Guid so on paste we can match it up on paste }
FReply FKismetVariableDragDropAction::DroppedOnNode(FVector2D ScreenPosition, FVector2D GraphPosition) { UK2Node_Variable* TargetNode = Cast<UK2Node_Variable>(GetHoveredNode()); if (TargetNode && (VariableName != TargetNode->GetVarName())) { const FScopedTransaction Transaction( LOCTEXT("ReplacePinVariable", "Replace Pin Variable") ); UProperty* VariableProperty = GetVariableProperty(); if(CanVariableBeDropped(VariableProperty, *TargetNode->GetGraph())) { const FString OldVarName = TargetNode->GetVarNameString(); const UEdGraphSchema_K2* Schema = Cast<const UEdGraphSchema_K2>(TargetNode->GetSchema()); TArray<class UEdGraphPin*> BadLinks; GetLinksThatWillBreak(TargetNode,VariableProperty,BadLinks); // Change the variable name and context UBlueprint* DropOnBlueprint = FBlueprintEditorUtils::FindBlueprintForGraph(TargetNode->GetGraph()); UEdGraphPin* Pin = TargetNode->FindPin(OldVarName); DropOnBlueprint->Modify(); TargetNode->Modify(); if (Pin != NULL) { Pin->Modify(); } UEdGraphSchema_K2::ConfigureVarNode(TargetNode, VariableName, VariableSource.Get(), DropOnBlueprint); if ((Pin == NULL) || (Pin->LinkedTo.Num() == BadLinks.Num()) || (Schema == NULL)) { TargetNode->GetSchema()->ReconstructNode(*TargetNode); } else { FEdGraphPinType NewPinType; Schema->ConvertPropertyToPinType(VariableProperty,NewPinType); Pin->PinName = VariableName.ToString(); Pin->PinType = NewPinType; //break bad links for(TArray<class UEdGraphPin*>::TIterator OtherPinIt(BadLinks);OtherPinIt;) { Pin->BreakLinkTo(*OtherPinIt); } } return FReply::Handled(); } } return FReply::Unhandled(); }
void FHotReloadClassReinstancer::SetupNewClassReinstancing(UClass* InNewClass, UClass* InOldClass) { // Set base class members to valid values ClassToReinstance = InNewClass; DuplicatedClass = InOldClass; OriginalCDO = InOldClass->GetDefaultObject(); bHasReinstanced = false; bSkipGarbageCollection = false; bNeedsReinstancing = true; NewClass = InNewClass; // Collect the original CDO property values SerializeCDOProperties(InOldClass->GetDefaultObject(), OriginalCDOProperties); // Collect the property values of the new CDO SerializeCDOProperties(InNewClass->GetDefaultObject(), ReconstructedCDOProperties); SaveClassFieldMapping(InOldClass); ObjectsThatShouldUseOldStuff.Add(InOldClass); //CDO of REINST_ class can be used as archetype TArray<UClass*> ChildrenOfClass; GetDerivedClasses(InOldClass, ChildrenOfClass); for (auto ClassIt = ChildrenOfClass.CreateConstIterator(); ClassIt; ++ClassIt) { UClass* ChildClass = *ClassIt; UBlueprint* ChildBP = Cast<UBlueprint>(ChildClass->ClassGeneratedBy); if (ChildBP && !ChildBP->HasAnyFlags(RF_BeingRegenerated)) { // If this is a direct child, change the parent and relink so the property chain is valid for reinstancing if (!ChildBP->HasAnyFlags(RF_NeedLoad)) { if (ChildClass->GetSuperClass() == InOldClass) { ReparentChild(ChildBP); } Children.AddUnique(ChildBP); if (ChildBP->ParentClass == InOldClass) { ChildBP->ParentClass = NewClass; } } else { // If this is a child that caused the load of their parent, relink to the REINST class so that we can still serialize in the CDO, but do not add to later processing ReparentChild(ChildClass); } } } // Finally, remove the old class from Root so that it can get GC'd and mark it as CLASS_NewerVersionExists InOldClass->RemoveFromRoot(); InOldClass->ClassFlags |= CLASS_NewerVersionExists; }
//------------------------------------------------------------------------------ FText SBlueprintLibraryPalette::GetFilterClassName() const { FText FilterDisplayString = LOCTEXT("All", "All"); if (FilterClass != NULL) { UBlueprint* Blueprint = UBlueprint::GetBlueprintFromClass(FilterClass.Get()); FilterDisplayString = FText::FromString((Blueprint != NULL) ? Blueprint->GetName() : FilterClass->GetName()); } return FilterDisplayString; }
void UK2Node::Message_Warn(const FString& Message) { UBlueprint* OwningBP = GetBlueprint(); if( OwningBP ) { OwningBP->Message_Warn(Message); } else { UE_LOG(LogBlueprint, Warning, TEXT("%s"), *Message); } }
/** Util to give better names for BP generated classes */ static FString GetClassDisplayName(const UObject* Object) { const UClass* Class = Cast<UClass>(Object); if (Class != NULL) { UBlueprint* BP = UBlueprint::GetBlueprintFromClass(Class); if(BP != NULL) { return BP->GetName(); } } return (Object) ? Object->GetName() : "None"; }
UActorComponent* UK2Node_AddComponent::GetTemplateFromNode() const { UBlueprint* BlueprintObj = GetBlueprint(); // Find the template name input pin, to get the name from UEdGraphPin* TemplateNamePin = GetTemplateNamePin(); if (TemplateNamePin) { const FString& TemplateName = TemplateNamePin->DefaultValue; return BlueprintObj->FindTemplateByName(FName(*TemplateName)); } return NULL; }
void UK2Node_Timeline::DestroyNode() { UBlueprint* Blueprint = GetBlueprint(); check(Blueprint); UTimelineTemplate* Timeline = Blueprint->FindTimelineTemplateByVariableName(TimelineName); if(Timeline) { FBlueprintEditorUtils::RemoveTimeline(Blueprint, Timeline, true); // Move template object out of the way so that we can potentially create a timeline with the same name either through a paste or a new timeline action Timeline->Rename(NULL, GetTransientPackage(), (Blueprint->bIsRegeneratingOnLoad ? REN_ForceNoResetLoaders : REN_None)); } Super::DestroyNode(); }
void UGatherTextFromAssetsCommandlet::ProcessPackages( const TArray< UPackage* >& PackagesToProcess ) { for( int32 i = 0; i < PackagesToProcess.Num(); ++i ) { UPackage* Package = PackagesToProcess[i]; TArray<UObject*> Objects; GetObjectsWithOuter(Package, Objects); for( int32 j = 0; j < Objects.Num(); ++j ) { UObject* Object = Objects[j]; if ( Object->IsA( UBlueprint::StaticClass() ) ) { UBlueprint* Blueprint = Cast<UBlueprint>( Object ); if( Blueprint->GeneratedClass != NULL ) { ProcessObject( Blueprint->GeneratedClass->GetDefaultObject(), Package ); } else { UE_LOG(LogGatherTextFromAssetsCommandlet, Warning, TEXT("%s - Invalid generated class!"), *Blueprint->GetFullName()); } } else if( Object->IsA( UDialogueWave::StaticClass() ) ) { UDialogueWave* DialogueWave = Cast<UDialogueWave>( Object ); ProcessDialogueWave( DialogueWave ); } ProcessObject( Object, Package ); } } }
void UK2Node_Select::NodeConnectionListChanged() { Super::NodeConnectionListChanged(); if (bReconstructNode) { ReconstructNode(); UBlueprint* Blueprint = GetBlueprint(); if(!Blueprint->bBeingCompiled) { FBlueprintEditorUtils::MarkBlueprintAsModified(Blueprint); Blueprint->BroadcastChanged(); } } }
void UK2Node_AddComponent::DestroyNode() { // See if this node has a template UActorComponent* Template = GetTemplateFromNode(); if (Template != NULL) { // Get the blueprint so we can remove it from it UBlueprint* BlueprintObj = GetBlueprint(); // remove it BlueprintObj->Modify(); BlueprintObj->ComponentTemplates.Remove(Template); } Super::DestroyNode(); }
bool UK2Node_InputAction::IsCompatibleWithGraph(UEdGraph const* Graph) const { // This node expands into event nodes and must be placed in a Ubergraph EGraphType const GraphType = Graph->GetSchema()->GetGraphType(Graph); bool bIsCompatible = (GraphType == EGraphType::GT_Ubergraph); if (bIsCompatible) { UBlueprint* Blueprint = FBlueprintEditorUtils::FindBlueprintForGraph(Graph); UEdGraphSchema_K2 const* K2Schema = Cast<UEdGraphSchema_K2>(Graph->GetSchema()); bool const bIsConstructionScript = (K2Schema != nullptr) ? K2Schema->IsConstructionScript(Graph) : false; bIsCompatible = (Blueprint != nullptr) && Blueprint->SupportsInputEvents() && !bIsConstructionScript && Super::IsCompatibleWithGraph(Graph); } return bIsCompatible; }
FText UK2Node_Timeline::GetNodeTitle(ENodeTitleType::Type TitleType) const { FText Title = FText::FromName(TimelineName); UBlueprint* Blueprint = GetBlueprint(); check(Blueprint != nullptr); UTimelineTemplate* Timeline = Blueprint->FindTimelineTemplateByVariableName(TimelineName); // if a node hasn't been spawned for this node yet, then lets title it // after what it will do (the name would be invalid anyways) if (Timeline == nullptr) { // if this node hasn't spawned a Title = LOCTEXT("NoTimelineTitle", "Add Timeline..."); } return Title; }
FFindHeadersToInclude(FGatherConvertedClassDependencies& InDependencies) : FGatherConvertedClassDependenciesHelperBase(InDependencies) { FindReferences(Dependencies.GetActualStruct()); // special case - literal enum UBlueprintGeneratedClass* BPGC = Cast<UBlueprintGeneratedClass>(Dependencies.GetActualStruct()); UBlueprint* BP = BPGC ? Cast<UBlueprint>(BPGC->ClassGeneratedBy) : nullptr; if (BP) { TArray<UEdGraph*> Graphs; BP->GetAllGraphs(Graphs); for (UEdGraph* Graph : Graphs) { if (Graph) { TArray<UK2Node_EnumLiteral*> LiteralEnumNodes; Graph->GetNodesOfClass<UK2Node_EnumLiteral>(LiteralEnumNodes); for (UK2Node_EnumLiteral* LiteralEnumNode : LiteralEnumNodes) { UEnum* Enum = LiteralEnumNode ? LiteralEnumNode->Enum : nullptr; IncludeTheHeaderInBody(Enum); } } } } // Include classes of native subobjects if (BPGC) { UClass* NativeSuperClass = BPGC->GetSuperClass(); for (; NativeSuperClass && !NativeSuperClass->HasAnyClassFlags(CLASS_Native); NativeSuperClass = NativeSuperClass->GetSuperClass()) {} UObject* NativeCDO = NativeSuperClass ? NativeSuperClass->GetDefaultObject(false) : nullptr; if (NativeCDO) { TArray<UObject*> DefaultSubobjects; NativeCDO->GetDefaultSubobjects(DefaultSubobjects); for (UObject* DefaultSubobject : DefaultSubobjects) { IncludeTheHeaderInBody(DefaultSubobject ? DefaultSubobject->GetClass() : nullptr); } } } }
void FAssetTypeActions_Blueprint::PerformAssetDiff(UObject* OldAsset, UObject* NewAsset, const FRevisionInfo& OldRevision, const FRevisionInfo& NewRevision) const { UBlueprint* OldBlueprint = Cast<UBlueprint>(OldAsset); check(OldBlueprint != NULL); check(OldBlueprint->SkeletonGeneratedClass != NULL); UBlueprint* NewBlueprint = Cast<UBlueprint>(NewAsset); check(NewBlueprint != NULL); check(NewBlueprint->SkeletonGeneratedClass != NULL); // sometimes we're comparing different revisions of one single asset (other // times we're comparing two completely separate assets altogether) bool bIsSingleAsset = (NewBlueprint->GetName() == OldBlueprint->GetName()); FText WindowTitle = LOCTEXT("NamelessBlueprintDiff", "Blueprint Diff"); // if we're diff'ing one asset against itself if (bIsSingleAsset) { // identify the assumed single asset in the window's title WindowTitle = FText::Format(LOCTEXT("Blueprint Diff", "{0} - Blueprint Diff"), FText::FromString(NewBlueprint->GetName())); } const TSharedPtr<SWindow> Window = SNew(SWindow) .Title(WindowTitle) .ClientSize(FVector2D(1000,800)); Window->SetContent(SNew(SBlueprintDiff) .BlueprintOld(OldBlueprint) .BlueprintNew(NewBlueprint) .OldRevision(OldRevision) .NewRevision(NewRevision) .ShowAssetNames(!bIsSingleAsset) .OpenInDefaults(const_cast<FAssetTypeActions_Blueprint*>(this), &FAssetTypeActions_Blueprint::OpenInDefaults) ); // Make this window a child of the modal window if we've been spawned while one is active. TSharedPtr<SWindow> ActiveModal = FSlateApplication::Get().GetActiveModalWindow(); if ( ActiveModal.IsValid() ) { FSlateApplication::Get().AddWindowAsNativeChild( Window.ToSharedRef(), ActiveModal.ToSharedRef() ); } else { FSlateApplication::Get().AddWindow( Window.ToSharedRef() ); } }
bool UK2Node_InputAxisKeyEvent::IsCompatibleWithGraph(const UEdGraph* TargetGraph) const { // By default, to be safe, we don't allow events to be pasted, except under special circumstances (see below) bool bIsCompatible = false; // Find the Blueprint that owns the target graph UBlueprint* Blueprint = FBlueprintEditorUtils::FindBlueprintForGraph(TargetGraph); if (Blueprint != nullptr) { bIsCompatible = FBlueprintEditorUtils::IsActorBased(Blueprint) && Blueprint->SupportsInputEvents(); } UEdGraphSchema_K2 const* K2Schema = Cast<UEdGraphSchema_K2>(TargetGraph->GetSchema()); bool const bIsConstructionScript = (K2Schema != nullptr) ? K2Schema->IsConstructionScript(TargetGraph) : false; bIsCompatible &= !bIsConstructionScript; return bIsCompatible && Super::IsCompatibleWithGraph(TargetGraph); }
FString UK2Node_AddComponent::GetDocumentationExcerptName() const { UEdGraphPin* TemplateNamePin = GetTemplateNamePin(); UBlueprint* Blueprint = GetBlueprint(); if ((TemplateNamePin != NULL) && (Blueprint != NULL)) { FString TemplateName = TemplateNamePin->DefaultValue; UActorComponent* SourceTemplate = Blueprint->FindTemplateByName(FName(*TemplateName)); if (SourceTemplate != NULL) { return SourceTemplate->GetClass()->GetName(); } } return Super::GetDocumentationExcerptName(); }
UObject* UK2Node_Event::GetJumpTargetForDoubleClick() const { if(EventSignatureClass != NULL && EventSignatureClass->ClassGeneratedBy != NULL && EventSignatureClass->ClassGeneratedBy->IsA(UBlueprint::StaticClass())) { UBlueprint* Blueprint = CastChecked<UBlueprint>(EventSignatureClass->ClassGeneratedBy); TArray<UEdGraph*> Graphs; Blueprint->GetAllGraphs(Graphs); for(auto It(Graphs.CreateConstIterator()); It; It++) { if((*It)->GetFName() == EventSignatureName) { return *It; } } } return NULL; }