Beispiel #1
0
/*Description: Sets the state on a Player Animation*/
void APoseidonCharacter::AnimationBool(FName Animation, bool newState)
{
	if (AnimationBP)
	{
		UBoolProperty* BoolProp = FindField<UBoolProperty>(AnimationBP->GetClass(), Animation);
		if (BoolProp != NULL)
		{
			BoolProp->SetPropertyValue_InContainer(AnimationBP, newState);
		}
	}
}
Beispiel #2
0
void APoseidonCharacter::EndScene()
{
	if (IsEndScene == false)
	{
		PlayerHUD->ChangeCrosshair(EReticleEnum::RE_NO_RETICLE);
		APlayerController* PlayerController = UGameplayStatics::GetPlayerController(GetWorld(), 0);
		UUserWidget* WidgetInstance = CreateWidget<UUserWidget>(PlayerController, WidgetCreditsClass);
		WidgetInstance->AddToViewport();
		FName shouldLoop = FName("ShouldLoop");
		UBoolProperty* BoolProp = FindField<UBoolProperty>(WidgetInstance->GetClass(), shouldLoop);
		if (BoolProp != NULL)
		{
			BoolProp->SetPropertyValue_InContainer(WidgetInstance, false);
		}
		IsEndScene = true;

	}
}
bool FPropertyEditor::SupportsEditConditionToggle( UProperty* InProperty ) 
{
	bool bShowEditConditionToggle = false;

	if (!InProperty->HasMetaData(TEXT("HideEditConditionToggle")))
	{
		bool bNegateValue = false;
		UBoolProperty* ConditionalProperty = PropertyCustomizationHelpers::GetEditConditionProperty( InProperty, bNegateValue );
		if( ConditionalProperty != NULL )
		{
			bShowEditConditionToggle = true;

			if( ConditionalProperty->HasAllPropertyFlags( CPF_Edit ) )
			{
				// Conditionally-dependent property is already exposed for editing, so no need to draw another
				// check box next to this property's label
				bShowEditConditionToggle = false;
			}
		}
	}

	return bShowEditConditionToggle;
}
/** Creates a property named PropertyName of type PropertyType in the Scope or returns NULL if the type is unknown, but does *not* link that property in */
UProperty* FKismetCompilerUtilities::CreatePropertyOnScope(UStruct* Scope, const FName& PropertyName, const FEdGraphPinType& Type, UClass* SelfClass, uint64 PropertyFlags, const UEdGraphSchema_K2* Schema, FCompilerResultsLog& MessageLog)
{
	//@TODO: Check for name conflicts!

	// Properties are non-transactional as they're regenerated on every compile
	const EObjectFlags ObjectFlags = RF_Public;

	UProperty* NewProperty = NULL;
	UObject* PropertyScope = NULL;

	FName ValidatedPropertyName = PropertyName;

	// Check to see if there's already a property on this scope, and throw an internal compiler error if so
	// If this happens, it breaks the property link, which causes stack corruption and hard-to-track errors, so better to fail at this point
	{
		UProperty* ExistingProperty = FindObject<UProperty>(Scope, *PropertyName.ToString(), false);
		if( ExistingProperty )
		{
			MessageLog.Error(*FString::Printf(TEXT("Internal Compiler Error:  Duplicate property %s on scope %s"), *PropertyName.ToString(), (Scope ? *Scope->GetName() : TEXT("None"))));

			// Find a free name, so we can still create the property to make it easier to spot the duplicates, and avoid crashing
			uint32 Counter = 0;
			FString TestNameString;
			do 
			{
				TestNameString = PropertyName.ToString() + FString::Printf(TEXT("_ERROR_DUPLICATE_%d"), Counter++);
			} while (FindObject<UProperty>(Scope, *TestNameString, false) != NULL);

			ValidatedPropertyName = FName(*TestNameString);
		}
	}

	// Handle creating an array property, if necessary
	const bool bIsArrayProperty = Type.bIsArray;
	UArrayProperty* NewArrayProperty = NULL;
	if( bIsArrayProperty )
	{
		NewArrayProperty = NewNamedObject<UArrayProperty>(Scope, ValidatedPropertyName, ObjectFlags);
		PropertyScope = NewArrayProperty;
	}
	else
	{
		PropertyScope = Scope;
	}

	//@TODO: Nasty string if-else tree
	if (Type.PinCategory == Schema->PC_Object)
	{
		UClass* SubType = (Type.PinSubCategory == Schema->PSC_Self) ? SelfClass : Cast<UClass>(Type.PinSubCategoryObject.Get());

		if( SubType == NULL )
		{
			// If this is from a degenerate pin, because the object type has been removed, default this to a UObject subtype so we can make a dummy term for it to allow the compiler to continue
			SubType = UObject::StaticClass();
		}

		if (SubType != NULL)
		{
			if (SubType->HasAnyClassFlags(CLASS_Interface))
			{
				UInterfaceProperty* NewPropertyObj = NewNamedObject<UInterfaceProperty>(PropertyScope, ValidatedPropertyName, ObjectFlags);
				NewPropertyObj->InterfaceClass = SubType;
				NewProperty = NewPropertyObj;
			}
			else
			{
				UObjectPropertyBase* NewPropertyObj = NULL;

				if( Type.bIsWeakPointer )
				{
					NewPropertyObj = NewNamedObject<UWeakObjectProperty>(PropertyScope, ValidatedPropertyName, ObjectFlags);
				}
				else
				{
					NewPropertyObj = NewNamedObject<UObjectProperty>(PropertyScope, ValidatedPropertyName, ObjectFlags);
				}
				NewPropertyObj->PropertyClass = SubType;
				NewProperty = NewPropertyObj;
			}
		}
	}
	else if (Type.PinCategory == Schema->PC_Struct)
	{
		UScriptStruct* SubType = Cast<UScriptStruct>(Type.PinSubCategoryObject.Get());
		if (SubType != NULL)
		{
			FString StructureError;
			if (FStructureEditorUtils::EStructureError::Ok == FStructureEditorUtils::IsStructureValid(SubType, NULL, &StructureError))
			{
				UStructProperty* NewPropertyStruct = NewNamedObject<UStructProperty>(PropertyScope, ValidatedPropertyName, ObjectFlags);
				NewPropertyStruct->Struct = SubType;
				NewProperty = NewPropertyStruct;
			}
			else
			{
				MessageLog.Error(
					*FString::Printf(
						*LOCTEXT("InvalidStructForField_Error", "Invalid property '%s' structure '%s' error: %s").ToString(),
						*PropertyName.ToString(),
						*SubType->GetName(),
						*StructureError
					));
			}
		}
	}
	else if (Type.PinCategory == Schema->PC_Class)
	{
		UClass* SubType = Cast<UClass>(Type.PinSubCategoryObject.Get());
		if (SubType != NULL)
		{
			UClassProperty* NewPropertyClass = NewNamedObject<UClassProperty>(PropertyScope, ValidatedPropertyName, ObjectFlags);
			NewPropertyClass->MetaClass = SubType;
			NewPropertyClass->PropertyClass = UClass::StaticClass();
			NewProperty = NewPropertyClass;
		}
	}
	else if (Type.PinCategory == Schema->PC_Delegate)
	{
		if (UFunction* SignatureFunction = Cast<UFunction>(Type.PinSubCategoryObject.Get()))
		{
			UDelegateProperty* NewPropertyDelegate = NewNamedObject<UDelegateProperty>(PropertyScope, ValidatedPropertyName, ObjectFlags);
			NewPropertyDelegate->SignatureFunction = SignatureFunction;
			NewProperty = NewPropertyDelegate;
		}
	}
	else if (Type.PinCategory == Schema->PC_MCDelegate)
	{
		UFunction* const SignatureFunction = Cast<UFunction>(Type.PinSubCategoryObject.Get());
		UMulticastDelegateProperty* NewPropertyDelegate = NewNamedObject<UMulticastDelegateProperty>(PropertyScope, ValidatedPropertyName, ObjectFlags);
		NewPropertyDelegate->SignatureFunction = SignatureFunction;
		NewProperty = NewPropertyDelegate;
	}
	else if (Type.PinCategory == Schema->PC_Int)
	{
		NewProperty = NewNamedObject<UIntProperty>(PropertyScope, ValidatedPropertyName, ObjectFlags);
	}
	else if (Type.PinCategory == Schema->PC_Float)
	{
		NewProperty = NewNamedObject<UFloatProperty>(PropertyScope, ValidatedPropertyName, ObjectFlags);
	}
	else if (Type.PinCategory == Schema->PC_Boolean)
	{
		UBoolProperty* BoolProperty = NewNamedObject<UBoolProperty>(PropertyScope, ValidatedPropertyName, ObjectFlags);
		BoolProperty->SetBoolSize(sizeof(bool), true);
		NewProperty = BoolProperty;
	}
	else if (Type.PinCategory == Schema->PC_String)
	{
		NewProperty = NewNamedObject<UStrProperty>(PropertyScope, ValidatedPropertyName, ObjectFlags);
	}
	else if (Type.PinCategory == Schema->PC_Text)
	{
		NewProperty = NewNamedObject<UTextProperty>(PropertyScope, ValidatedPropertyName, ObjectFlags);
	}
	else if (Type.PinCategory == Schema->PC_Byte)
	{
		UByteProperty* ByteProp = NewNamedObject<UByteProperty>(PropertyScope, ValidatedPropertyName, ObjectFlags);
		ByteProp->Enum = Cast<UEnum>(Type.PinSubCategoryObject.Get());

		NewProperty = ByteProp;
	}
	else if (Type.PinCategory == Schema->PC_Name)
	{
		NewProperty = NewNamedObject<UNameProperty>(PropertyScope, ValidatedPropertyName, ObjectFlags);
	}
	else
	{
		// Failed to resolve the type-subtype, create a generic property to survive VM bytecode emission
		NewProperty = NewNamedObject<UIntProperty>(PropertyScope, ValidatedPropertyName, ObjectFlags);
	}

	if( bIsArrayProperty )
	{
		// Fix up the array property to have the new type-specific property as its inner, and return the new UArrayProperty
		NewArrayProperty->Inner = NewProperty;
		NewProperty = NewArrayProperty;
	}

	return NewProperty;
}
Beispiel #5
0
void USQLiteDatabase::AssignResultsToObjectProperties(const SQLiteResultValue& ResultValue, UObject* ObjectToPopulate)
{
	auto propertyMap = CollectProperties(ObjectToPopulate);
	for (SQLiteResultField field : ResultValue.Fields)
	{
		if (propertyMap.Contains(field.Name))
		{
			UProperty* targetProperty = propertyMap[field.Name];

			if (field.Type == SQLiteResultValueTypes::Integer)
			{
				UInt64Property* int64prop = NULL;
				UIntProperty* int32prop = NULL;
				UInt16Property* int16prop = NULL;
				UInt8Property* int8prop = NULL;
				UBoolProperty* boolProp = NULL;

				if ((int64prop = Cast<UInt64Property>(targetProperty)) != NULL)
				{
					int64prop->SetPropertyValue_InContainer(ObjectToPopulate, field.IntValue);
					LOGSQLITE(Verbose, *FString::Printf(TEXT("Property '%s' was set to '%d'"), *field.Name, field.IntValue));
				}
				else if ((int32prop = Cast<UIntProperty>(targetProperty)) != NULL)
				{
					int32prop->SetPropertyValue_InContainer(ObjectToPopulate, (int32)field.IntValue);
					LOGSQLITE(Verbose, *FString::Printf(TEXT("Property '%s' was set to '%d'"), *field.Name, field.IntValue));
				}
				else if ((int16prop = Cast<UInt16Property>(targetProperty)) != NULL)
				{
					int16prop->SetPropertyValue_InContainer(ObjectToPopulate, (int16)field.IntValue);
					LOGSQLITE(Verbose, *FString::Printf(TEXT("Property '%s' was set to '%d'"), *field.Name, field.IntValue));
				}
				else if ((int8prop = Cast<UInt8Property>(targetProperty)) != NULL)
				{
					int8prop->SetPropertyValue_InContainer(ObjectToPopulate, (int8)field.IntValue);
					LOGSQLITE(Verbose, *FString::Printf(TEXT("Property '%s' was set to '%d'"), *field.Name, field.IntValue));
				}
				else if ((boolProp = Cast<UBoolProperty>(targetProperty)) != NULL)
				{
					boolProp->SetPropertyValue_InContainer(ObjectToPopulate, field.IntValue > 0);
					LOGSQLITE(Verbose, *FString::Printf(TEXT("Property '%s' was set to '%d'"), *field.Name, field.IntValue));
				}
			}

			else if (field.Type == SQLiteResultValueTypes::Float)
			{
				UDoubleProperty* doubleProp = NULL;
				UFloatProperty* floatProp = NULL;
				if ((doubleProp = Cast<UDoubleProperty>(targetProperty)) != NULL)
				{
					doubleProp->SetPropertyValue_InContainer(ObjectToPopulate, field.DoubleValue);
					LOGSQLITE(Verbose, *FString::Printf(TEXT("Property '%s' was set to '%f'"), *field.Name, field.DoubleValue));
				}
				else if ((floatProp = Cast<UFloatProperty>(targetProperty)) != NULL)
				{
					floatProp->SetPropertyValue_InContainer(ObjectToPopulate, (float)field.DoubleValue);
					LOGSQLITE(Verbose, *FString::Printf(TEXT("Property '%s' was set to '%f'"), *field.Name, field.DoubleValue));
				}
			}

			else if (field.Type == SQLiteResultValueTypes::Text)
			{
				UStrProperty* strProp = NULL;
				if ((strProp = Cast<UStrProperty>(targetProperty)) != NULL)
				{
					strProp->SetPropertyValue_InContainer(ObjectToPopulate, field.StringValue);
					LOGSQLITE(Verbose, *FString::Printf(TEXT("Property '%s' was set to '%s'"), *field.Name, *field.StringValue.Mid(0, 64)));
				}
			}

		}
	}
}