当前位置: 首页>>代码示例>>C++>>正文


C++ FArchive::UseToResolveEnumerators方法代码示例

本文整理汇总了C++中FArchive::UseToResolveEnumerators方法的典型用法代码示例。如果您正苦于以下问题:C++ FArchive::UseToResolveEnumerators方法的具体用法?C++ FArchive::UseToResolveEnumerators怎么用?C++ FArchive::UseToResolveEnumerators使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FArchive的用法示例。


在下文中一共展示了FArchive::UseToResolveEnumerators方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SerializeItem

/*-----------------------------------------------------------------------------
	UByteProperty.
-----------------------------------------------------------------------------*/
void UByteProperty::SerializeItem( FArchive& Ar, void* Value, void const* Defaults ) const
{
	if(Enum && Ar.UseToResolveEnumerators())
	{
		 const int32 ResolvedIndex = Enum->ResolveEnumerator(Ar, *(uint8*)Value);
		 *(uint8*)Value = static_cast<uint8>(ResolvedIndex);
		 return;
	}

	// Serialize enum values by name unless we're not saving or loading OR for backwards compatibility
	const bool bUseBinarySerialization = (Enum == NULL) || (!Ar.IsLoading() && !Ar.IsSaving());
	if( bUseBinarySerialization )
	{
		Super::SerializeItem(Ar, Value, Defaults);
	}
	// Loading
	else if (Ar.IsLoading())
	{
		FName EnumValueName;
		Ar << EnumValueName;
		// Make sure enum is properly populated
		if( Enum->HasAnyFlags(RF_NeedLoad) )
		{
			Ar.Preload(Enum);
		}

		// There's no guarantee EnumValueName is still present in Enum, in which case Value will be set to the enum's max value.
		// On save, it will then be serialized as NAME_None.
		int32 EnumIndex = Enum->FindEnumIndex(EnumValueName);
		if (EnumIndex == INDEX_NONE)
		{
			*(uint8*)Value = Enum->GetMaxEnumValue();
		}
		else
		{
			*(uint8*)Value = Enum->GetValueByIndex(EnumIndex);
		}
	}
	// Saving
	else
	{
		FName EnumValueName;
		uint8 ByteValue = *(uint8*)Value;

		// subtract 1 because the last entry in the enum's Names array
		// is the _MAX entry
		if ( Enum->IsValidEnumValue(ByteValue) )
		{
			EnumValueName = Enum->GetNameByValue(ByteValue);
		}
		else
		{
			EnumValueName = NAME_None;
		}
		Ar << EnumValueName;
	}
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:60,代码来源:PropertyByte.cpp

示例2: ResolveEnumerator

int32 FEnumEditorUtils::ResolveEnumerator(const UEnum* Enum, FArchive& Ar, int32 EnumeratorIndex)
{
	check(Ar.UseToResolveEnumerators());
	const FArchiveEnumeratorResolver* EnumeratorResolver = (FArchiveEnumeratorResolver*)(&Ar);
	if(Enum == EnumeratorResolver->Enum)
	{
		const auto& OldNames = EnumeratorResolver->OldNames;
		if(EnumeratorIndex < OldNames.Num())
		{
			const FName EnumeratorName = OldNames[EnumeratorIndex].Key;
			const int32 NewEnumIndex = Enum->FindEnumIndex(EnumeratorName);
			if(INDEX_NONE != NewEnumIndex)
			{
				return NewEnumIndex;
			}
		}
		return (Enum->NumEnums() - 1);
	}
	return EnumeratorIndex;
}
开发者ID:amyvmiwei,项目名称:UnrealEngine4,代码行数:20,代码来源:EnumEditorUtils.cpp

示例3: ResolveEnumerator

int32 FEnumEditorUtils::ResolveEnumerator(const UEnum* Enum, FArchive& Ar, int32 EnumeratorValue)
{
	check(Ar.UseToResolveEnumerators());
	const FArchiveEnumeratorResolver* EnumeratorResolver = (FArchiveEnumeratorResolver*)(&Ar);
	if(Enum == EnumeratorResolver->Enum)
	{
		for (TPair<FName, uint8> OldName : EnumeratorResolver->OldNames)
		{
			if (OldName.Value == EnumeratorValue)
			{
				const FName EnumeratorName = OldName.Key;
				const int32 NewEnumValue = Enum->GetValueByName(EnumeratorName);
				if(INDEX_NONE != NewEnumValue)
				{
					return NewEnumValue;
				}
			}
		}
		return Enum->GetMaxEnumValue();
	}
	return EnumeratorValue;
}
开发者ID:ErwinT6,项目名称:T6Engine,代码行数:22,代码来源:EnumEditorUtils.cpp


注:本文中的FArchive::UseToResolveEnumerators方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。