Esempio n. 1
0
 public override void SetMetaData(Dictionary <FName, string> metadata)
 {
     if (Flags.HasFlag(PropFlags.Instanced))
     {
         metadata[UMeta.GetKeyName(MDProp.EditInline)] = "true";
     }
 }
Esempio n. 2
0
        private static void SetAllMetaData(IntPtr obj, ManagedUnrealReflectionBase field, UMeta.Target target)
        {
            if (!FBuild.WithEditor || !metaDataEnabled || field == null || string.IsNullOrEmpty(field.Path))
            {
                return;
            }

            IntPtr outermost = Native_UObjectBaseUtility.GetOutermost(obj);
            IntPtr metadata  = outermost == IntPtr.Zero ? IntPtr.Zero : Native_UPackage.GetMetaData(outermost);

            if (metadata == IntPtr.Zero)
            {
                return;
            }

            Dictionary <FName, string> values = null;

            if (!metaDataMap.TryGetValue(field.Path.ToLower(), out values))
            {
                values = new Dictionary <FName, string>();
            }

            switch (target)
            {
            // Class / interface
            case UMeta.Target.Class:
            case UMeta.Target.Interface:
                // See GetMetadataKeyword (Engine\Source\Programs\UnrealHeaderTool\Private\BaseParser.cpp)
                // "NotBlueprintable" removes "NotBlueprintable" and adds "IsBlueprintBase=false"
                // "Blueprintable" and adds "IsBlueprintBase=true"
                // "BlueprintInternalUseOnly" adds "BlueprintType"

                if (!values.ContainsKey(UMeta.GetKeyName(MDClass.IsBlueprintBase)))
                {
                    if (values.ContainsKey(UMeta.GetKeyName(MDClass.Blueprintable)))
                    {
                        values[UMeta.GetKeyName(MDClass.IsBlueprintBase)] = "true";
                    }
                    else if (values.ContainsKey(UMeta.GetKeyName(MDClass.NotBlueprintable)))
                    {
                        values[UMeta.GetKeyName(MDClass.IsBlueprintBase)] = "false";
                    }
                }

                MetaDataMergeClassCategories(metadata, obj, values);
                break;
            }
            SetMetaDataBlueprintability(values, target, field as ManagedUnrealTypeInfo);

            using (TArrayUnsafe <FName> keysUnsafe = new TArrayUnsafe <FName>())
                using (TArrayUnsafe <string> valuesUnsafe = new TArrayUnsafe <string>())
                {
                    keysUnsafe.AddRange(values.Keys.ToArray());
                    valuesUnsafe.AddRange(values.Values.ToArray());
                    Native_UMetaData.SetObjectValues(metadata, obj, keysUnsafe.Address, valuesUnsafe.Address);
                }
        }
Esempio n. 3
0
 private static void SetOrClearMetaDataClassCollection(MDClass key, Dictionary <FName, string> values, HashSet <string> collection)
 {
     if (collection.Count > 0)
     {
         values[UMeta.GetKeyName(key)] = string.Join(" ", collection);
     }
     else
     {
         values.Remove(UMeta.GetKeyName(key));
     }
 }
Esempio n. 4
0
        private static void SetMetaDataBlueprintability(Dictionary <FName, string> values, UMeta.Target target,
                                                        ManagedUnrealTypeInfo typeInfo)
        {
            ManagedUnrealVisibility.Type defaultTypeVisibility = ManagedUnrealVisibility.Type.None;
            switch (target)
            {
            case UMeta.Target.Class:
                defaultTypeVisibility = ManagedUnrealVisibility.Class;
                break;

            case UMeta.Target.Interface:
                defaultTypeVisibility = ManagedUnrealVisibility.Interface;
                break;

            case UMeta.Target.Struct:
                defaultTypeVisibility = ManagedUnrealVisibility.Struct;
                break;

            case UMeta.Target.Enum:
                defaultTypeVisibility = ManagedUnrealVisibility.Enum;
                break;

            default:
                return;
            }
            if (defaultTypeVisibility == ManagedUnrealVisibility.Type.None)
            {
                return;
            }

            // Use whatever state is in typeInfo if default state is enabled. It should have been resolved
            // properly for our managed type (if the state was defined on a native type the default state config
            // should have overridden it)

            if (defaultTypeVisibility.HasFlag(ManagedUnrealVisibility.Type.BlueprintType))
            {
                if (typeInfo.AdditionalFlags.HasFlag(ManagedUnrealTypeInfoFlags.BlueprintTypeHierarchical))
                {
                    values[UMeta.GetKeyName(MDClass.BlueprintType)] = "true";
                    values.Remove(UMeta.GetKeyName(MDClass.NotBlueprintType));
                }
                else
                {
                    values[UMeta.GetKeyName(MDClass.NotBlueprintType)] = "true";
                    values.Remove(UMeta.GetKeyName(MDClass.BlueprintType));
                }
            }

            if (defaultTypeVisibility.HasFlag(ManagedUnrealVisibility.Type.Blueprintable))
            {
                if (typeInfo.AdditionalFlags.HasFlag(ManagedUnrealTypeInfoFlags.BlueprintableHierarchical))
                {
                    values[UMeta.GetKeyName(MDClass.Blueprintable)]   = "true";
                    values[UMeta.GetKeyName(MDClass.IsBlueprintBase)] = "true";
                    values.Remove(UMeta.GetKeyName(MDClass.NotBlueprintable));
                }
                else
                {
                    values[UMeta.GetKeyName(MDClass.NotBlueprintType)] = "true";
                    values[UMeta.GetKeyName(MDClass.IsBlueprintBase)]  = "false";
                    values.Remove(UMeta.GetKeyName(MDClass.Blueprintable));
                }
            }
        }
Esempio n. 5
0
        private static void MetaDataMergeClassCategories(IntPtr metadata, IntPtr obj, Dictionary <FName, string> values)
        {
            // Copying the logic in FClassDeclarationMetaData::MergeClassCategories
            // Engine\Source\Programs\UnrealHeaderTool\Private\ClassDeclarationMetaData.cpp
            // ShowFunctions HideFunctions
            // HideCategories ShowCategories ShowSubCatgories
            // AutoExpandCategories AutoCollapseCategories

            // - How is ShowFunctions / HideFunctions used? Hiding a function doesn't seem to hide it from being
            //   visible in the actions list in Blueprint. If it isn't super important we could skip it.
            // - ShowCategories / HideCategories is important

            // Maybe cache these lists and clear them for each type
            HashSet <string> showCategories             = new HashSet <string>();
            HashSet <string> hideCategories             = new HashSet <string>();
            HashSet <string> showSubCategories          = new HashSet <string>();
            HashSet <string> showFunctions              = new HashSet <string>();
            HashSet <string> hideFunctions              = new HashSet <string>();
            HashSet <string> autoExpandCategories       = new HashSet <string>();
            HashSet <string> autoCollapseCategories     = new HashSet <string>();
            HashSet <string> dontAutoCollapseCategories = new HashSet <string>();
            HashSet <string> classGroupNames            = new HashSet <string>();

            GetMetaDataItems(UMeta.GetKeyName(MDClass.ShowCategories), values, showCategories);
            GetMetaDataItems(UMeta.GetKeyName(MDClass.HideCategories), values, hideCategories);
            GetMetaDataItems(UMeta.GetKeyName(MDClass.ShowFunctions), values, showFunctions);
            GetMetaDataItems(UMeta.GetKeyName(MDClass.HideFunctions), values, hideFunctions);
            GetMetaDataItems(UMeta.GetKeyName(MDClass.AutoExpandCategories), values, autoExpandCategories);
            GetMetaDataItems(UMeta.GetKeyName(MDClass.AutoCollapseCategories), values, autoCollapseCategories);
            GetMetaDataItems(UMeta.GetKeyName(MDClass.DontAutoCollapseCategories), values, dontAutoCollapseCategories);
            GetMetaDataItems(UMeta.GetKeyName(MDClass.ClassGroupNames), values, classGroupNames);

            IntPtr           parentClass                  = Native_UClass.GetSuperClass(obj);
            HashSet <string> parentHideCategories         = new HashSet <string>();
            HashSet <string> parentShowSubCatgories       = new HashSet <string>();
            HashSet <string> parentHideFunctions          = new HashSet <string>();
            HashSet <string> parentAutoExpandCategories   = new HashSet <string>();
            HashSet <string> parentAutoCollapseCategories = new HashSet <string>();

            GetParentMetaDataItems(metadata, parentClass, UMeta.GetKeyName(MDClass.HideCategories), parentHideCategories);
            GetParentMetaDataItems(metadata, parentClass, UMeta.GetKeyName(MDClass.ShowCategories), parentShowSubCatgories);
            GetParentMetaDataItems(metadata, parentClass, UMeta.GetKeyName(MDClass.HideFunctions), parentHideFunctions);
            GetParentMetaDataItems(metadata, parentClass, UMeta.GetKeyName(MDClass.AutoExpandCategories), parentAutoExpandCategories);
            GetParentMetaDataItems(metadata, parentClass, UMeta.GetKeyName(MDClass.AutoCollapseCategories), parentAutoCollapseCategories);

            // Add parent categories. We store the opposite of HideCategories and HideFunctions in a separate array anyway.
            MetaDataMergeCollection(hideCategories, parentHideCategories);
            MetaDataMergeCollection(showSubCategories, parentShowSubCatgories);
            MetaDataMergeCollection(hideFunctions, parentHideFunctions);

            MetaDataMergeShowCategories(showCategories, hideCategories, showSubCategories);

            // Merge ShowFunctions and HideFunctions
            foreach (string value in showFunctions)
            {
                hideFunctions.Remove(value);
            }
            //showFunctions.Clear();

            // Merge DontAutoCollapseCategories and AutoCollapseCategories
            foreach (string value in dontAutoCollapseCategories)
            {
                autoCollapseCategories.Remove(value);
            }
            //dontAutoCollapseCategories.Clear();

            // The original function then merges ShowFunctions / HideFunctions again? (ShowFunctions will now be empty)

            // Merge AutoExpandCategories and AutoCollapseCategories (we still want to keep AutoExpandCategories though!)
            foreach (string value in autoExpandCategories)
            {
                autoCollapseCategories.Remove(value);
                parentAutoCollapseCategories.Remove(value);
            }

            // Do the same as above but the other way around
            foreach (string value in autoCollapseCategories)
            {
                autoExpandCategories.Remove(value);
                parentAutoExpandCategories.Remove(value);
            }

            // Once AutoExpandCategories and AutoCollapseCategories for THIS class have been parsed, add the parent inherited categories
            MetaDataMergeCollection(autoCollapseCategories, parentAutoCollapseCategories);
            MetaDataMergeCollection(autoExpandCategories, parentAutoExpandCategories);

            SetOrClearMetaDataClassCollection(MDClass.ClassGroupNames, values, classGroupNames);
            SetOrClearMetaDataClassCollection(MDClass.AutoCollapseCategories, values, autoCollapseCategories);
            SetOrClearMetaDataClassCollection(MDClass.HideCategories, values, hideCategories);
            SetOrClearMetaDataClassCollection(MDClass.ShowCategories, values, showSubCategories);
            SetOrClearMetaDataClassCollection(MDClass.HideFunctions, values, hideFunctions);
            SetOrClearMetaDataClassCollection(MDClass.AutoExpandCategories, values, autoExpandCategories);
        }
Esempio n. 6
0
 public override void SetMetaData(Dictionary <FName, string> metadata)
 {
     metadata[UMeta.GetKeyName(MDProp.ExposeOnSpawn)] = "true";
 }
 public override void SetMetaData(Dictionary <FName, string> metadata)
 {
     // HeaderParser.cpp just adds an empty string for tagged functions so this should be fine
     metadata[UMeta.GetKeyName(MDFunc.BlueprintSetter)] = FunctionName;
 }