Beispiel #1
0
        internal static DisplayType DeterminePropDisplayType(string name, SendTableProp prop, SendTableProp?arrayElemProp)
        {
            SendTableProp elemInfo = prop;

            while (true)
            {
                switch (elemInfo.SendPropType)
                {
                case SendPropType.Int:
                    return(IdentifyTypeForInt(name, elemInfo));

                case SendPropType.Float:
                    return(IdentifyTypeForFloat(name));

                case SendPropType.Vector2:
                    return(IdentifyTypeForVec2(name));

                case SendPropType.Vector3:
                    return(IdentifyTypeForVec3(name));

                case SendPropType.String:
                    return(IdentifyTypeForString(name));

                case SendPropType.Array:
                    elemInfo = arrayElemProp !;
                    continue;

                default:
                    throw new ArgumentOutOfRangeException(nameof(elemInfo.SendPropType));
                }
            }
        }
Beispiel #2
0
        private static DisplayType IdentifyTypeForInt(string name, SendTableProp propInfo)
        {
            if (propInfo.NumBits == 32 && name.ToLower().Contains("color"))
            {
                return(DisplayType.Color);
            }

            // check for flags and special cases first
            if (EntityPropertyEnumManager.DetermineIntSpecialType(propInfo.TableRef.Name, propInfo.Name, out DisplayType disp))
            {
                return(disp);
            }

            string[] split = name.Split('.');

            if (propInfo.NumBits == DemoInfo.NetworkedEHandleBits && split.Any(s => HandleMatcher.IsMatch(s)))
            {
                return(DisplayType.Handle);
            }

            // bool check is kinda dumb, maybe I shouldn't bother tbh
            if (propInfo.NumBits == 1)
            {
                var lowername = name.ToLower();
                if (split.Any(s => BoolMatcher.IsMatch(s)) ||
                    name.Contains("Has") ||
                    name.Contains("Is") ||
                    lowername.Contains("disable") ||
                    lowername.Contains("enable"))
                {
                    return(DisplayType.Bool);
                }
            }

            return(DisplayType.Int);
        }