void SDetailNameArea::BuildObjectNameAreaSelectionLabel( TSharedRef< SHorizontalBox > SelectionLabelBox, const TWeakObjectPtr<UObject> ObjectWeakPtr, const int32 NumSelectedObjects ) 
{
	check( NumSelectedObjects > 1 || ObjectWeakPtr.IsValid() );

	if( NumSelectedObjects == 1 )
	{
		UClass* ObjectClass = ObjectWeakPtr.Get()->GetClass();
		if( ObjectClass != nullptr )
		{
			SelectionLabelBox->AddSlot()
				.AutoWidth()
				.VAlign( VAlign_Center )
				.HAlign( HAlign_Left )
				.Padding( 1.0f, 1.0f, 0.0f, 0.0f )
				[
					FEditorClassUtils::GetDocumentationLinkWidget(ObjectClass)
				];


			if( ObjectClass && ObjectClass->ClassGeneratedBy == nullptr && ObjectClass->GetOutermost() )
			{
				const FString ModuleName = FPackageName::GetShortName(ObjectClass->GetOutermost()->GetFName());

				FModuleStatus PackageModuleStatus;
				if(FModuleManager::Get().QueryModule(*ModuleName, PackageModuleStatus))
				{
					if( PackageModuleStatus.bIsGameModule ) 
					{
						SelectionLabelBox->AddSlot()
						.AutoWidth()
						.VAlign(VAlign_Center)
						.HAlign(HAlign_Left)
						.Padding(6.0f, 1.0f, 0.0f, 0.0f)
						[
							FEditorClassUtils::GetSourceLink(ObjectClass, ObjectWeakPtr)
						];
					}
				}
			}
		
		}
	}
	else
	{
		const FText SelectionText = FText::Format( LOCTEXT("MultipleObjectsSelectedFmt", "{0} objects"), FText::AsNumber(NumSelectedObjects) );
		SelectionLabelBox->AddSlot()
		.VAlign(VAlign_Center)
		.HAlign( HAlign_Left )
		.FillWidth( 1.0f )
		[
			SNew(STextBlock)
			.Text( SelectionText )
		];

	}
}
Ejemplo n.º 2
0
void FBlueprintCompileReinstancer::UpdateBytecodeReferences()
{
	BP_SCOPED_COMPILER_EVENT_STAT(EKismetReinstancerStats_UpdateBytecodeReferences);

	if(ClassToReinstance != NULL)
	{
		TMap<UObject*, UObject*> FieldMappings;
		GenerateFieldMappings(FieldMappings);

		for( auto DependentBP = Dependencies.CreateIterator(); DependentBP; ++DependentBP )
		{
			UClass* BPClass = (*DependentBP)->GeneratedClass;

			// Skip cases where the class is junk, or haven't finished serializing in yet
			if( (BPClass == ClassToReinstance)
				|| (BPClass->GetOutermost() == GetTransientPackage()) 
				|| BPClass->HasAnyClassFlags(CLASS_NewerVersionExists)
				|| (BPClass->ClassGeneratedBy && BPClass->ClassGeneratedBy->HasAnyFlags(RF_NeedLoad|RF_BeingRegenerated)) )
			{
				continue;
			}

			// For each function defined in this blueprint, run through the bytecode, and update any refs from the old properties to the new
			for( TFieldIterator<UFunction> FuncIter(BPClass, EFieldIteratorFlags::ExcludeSuper); FuncIter; ++FuncIter )
			{
				UFunction* CurrentFunction = *FuncIter;
				if( CurrentFunction->Script.Num() > 0 )
				{
					FArchiveReplaceObjectRef<UObject> ReplaceAr(CurrentFunction, FieldMappings, /*bNullPrivateRefs=*/ false, /*bIgnoreOuterRef=*/ true, /*bIgnoreArchetypeRef=*/ true);
				}
			}
		}
	}
}
	static void AddStaticFunctionsForDependencies(FEmitterLocalContext& Context)
	{
		auto SourceClass = Context.GetCurrentlyGeneratedClass();
		auto OriginalClass = Context.Dependencies.FindOriginalClass(SourceClass);
		const FString CppClassName = FEmitHelper::GetCppName(OriginalClass);
		
		// __StaticDependenciesAssets
		Context.AddLine(FString::Printf(TEXT("void %s::__StaticDependenciesAssets(TArray<FBlueprintDependencyData>& AssetsToLoad)"), *CppClassName));
		Context.AddLine(TEXT("{"));
		Context.IncreaseIndent();

		auto CreateAssetToLoadString = [&](const UObject* AssetObj) -> FString
		{
			UClass* AssetType = AssetObj->GetClass();
			if (AssetType->IsChildOf<UUserDefinedEnum>())
			{
				AssetType = UEnum::StaticClass();
			}
			else if (AssetType->IsChildOf<UUserDefinedStruct>())
			{
				AssetType = UScriptStruct::StaticClass();
			}
			else if (AssetType->IsChildOf<UBlueprintGeneratedClass>() && Context.Dependencies.WillClassBeConverted(CastChecked<UBlueprintGeneratedClass>(AssetObj)))
			{
				AssetType = UDynamicClass::StaticClass();
			}

			return FString::Printf(TEXT("AssetsToLoad.Add({FName(TEXT(\"%s\")), FName(TEXT(\"%s\")), FName(TEXT(\"%s\")), FName(TEXT(\"%s\"))});")
				, *AssetObj->GetOutermost()->GetPathName()
				, *AssetObj->GetName()
				, *AssetType->GetOutermost()->GetPathName()
				, *AssetType->GetName());
		};
		for (UObject* LocAsset : Context.Dependencies.Assets)
		{
			Context.AddLine(CreateAssetToLoadString(LocAsset));
		}
		for (UObject* LocAsset : Context.Dependencies.ConvertedClasses)
		{
			if (!Context.Dependencies.Assets.Contains(LocAsset))
			{
				Context.AddLine(CreateAssetToLoadString(LocAsset));
			}
		}

		Context.DecreaseIndent();
		Context.AddLine(TEXT("}"));

		// Register Helper Struct
		const FString RegisterHelperName = FString::Printf(TEXT("FRegisterHelper__%s"), *CppClassName);
		Context.AddLine(FString::Printf(TEXT("struct %s"), *RegisterHelperName));
		Context.AddLine(TEXT("{"));
		Context.IncreaseIndent();

		Context.AddLine(FString::Printf(TEXT("%s()"), *RegisterHelperName));
		Context.AddLine(TEXT("{"));
		Context.IncreaseIndent();

		Context.AddLine(FString::Printf(
			TEXT("FConvertedBlueprintsDependencies::Get().RegisterClass(TEXT(\"%s\"), &%s::__StaticDependenciesAssets);")
			, *OriginalClass->GetOutermost()->GetPathName()
			, *CppClassName));

		Context.DecreaseIndent();
		Context.AddLine(TEXT("}"));

		Context.AddLine(FString::Printf(TEXT("static %s Instance;"), *RegisterHelperName));

		Context.DecreaseIndent();
		Context.AddLine(TEXT("};"));

		Context.AddLine(FString::Printf(TEXT("%s %s::Instance;"), *RegisterHelperName, *RegisterHelperName));
	}
Ejemplo n.º 4
0
void UAssetClassProperty::Serialize( FArchive& Ar )
{
	Super::Serialize( Ar );
	Ar << MetaClass;

	if( !(MetaClass||HasAnyFlags(RF_ClassDefaultObject)) )
	{
		// If we failed to load the MetaClass and we're not a CDO, that means we relied on a class that has been removed or doesn't exist.
		// The most likely cause for this is either an incomplete recompile, or if content was migrated between games that had native class dependencies
		// that do not exist in this game.  We allow blueprint classes to continue, because compile on load will error out, and stub the class that was using it
		UClass* TestClass = dynamic_cast<UClass*>(GetOwnerStruct());
		if( TestClass && TestClass->HasAllClassFlags(CLASS_Native) && !TestClass->HasAllClassFlags(CLASS_NewerVersionExists) && (TestClass->GetOutermost() != GetTransientPackage()) )
		{
			checkf(false, TEXT("Class property tried to serialize a missing class.  Did you remove a native class and not fully recompile?"));
		}
	}
}
//------------------------------------------------------------------------------
bool FBlueprintNodeSpawnerUtils::IsStaleFieldAction(UBlueprintNodeSpawner const* BlueprintAction)
{
	bool bHasStaleAssociatedField= false;

	const UField* AssociatedField = GetAssociatedField(BlueprintAction);
	if (AssociatedField != nullptr)
	{
		UClass* ClassOwner = AssociatedField->GetOwnerClass();
		if (ClassOwner != nullptr)
		{
			// check to see if this field belongs to a TRASH or REINST class,
			// maybe to a class that was thrown out because of a hot-reload?
			bHasStaleAssociatedField = ClassOwner->HasAnyClassFlags(CLASS_NewerVersionExists) || (ClassOwner->GetOutermost() == GetTransientPackage());
		}
	}

	return bHasStaleAssociatedField;
}
Ejemplo n.º 6
0
/** Manipulates the data referenced by this UProperty */
void UInterfaceProperty::Serialize( FArchive& Ar )
{
	Super::Serialize( Ar );

	Ar << InterfaceClass;

#if USE_CIRCULAR_DEPENDENCY_LOAD_DEFERRING
	if (Ar.IsLoading() || Ar.IsObjectReferenceCollector())
	{
		if (ULinkerPlaceholderClass* PlaceholderClass = Cast<ULinkerPlaceholderClass>(InterfaceClass))
		{
			PlaceholderClass->AddReferencingProperty(this);
		}
	}
#endif // USE_CIRCULAR_DEPENDENCY_LOAD_DEFERRING

	if ( !InterfaceClass && !HasAnyFlags(RF_ClassDefaultObject) )
 	{
		// If we failed to load the InterfaceClass and we're not a CDO, that means we relied on a class that has been removed or doesn't exist.
		// The most likely cause for this is either an incomplete recompile, or if content was migrated between games that had native class dependencies
		// that do not exist in this game.  We allow blueprint classes to continue, because compile-on-load will error out, and stub the class that was using it
		UClass* TestClass = dynamic_cast<UClass*>(GetOwnerStruct());
		if( TestClass && TestClass->HasAllClassFlags(CLASS_Native) && !TestClass->HasAllClassFlags(CLASS_NewerVersionExists) && (TestClass->GetOutermost() != GetTransientPackage()) )
		{
			checkf(false, TEXT("Interface property tried to serialize a missing interface.  Did you remove a native class and not fully recompile?"));
		}
 	}
}