Ejemplo n.º 1
0
        public WatchVariableControlPrecursor(XElement element)
        {
            /// Watchvariable params
            string typeName    = (element.Attribute(XName.Get("type"))?.Value);
            string specialType = element.Attribute(XName.Get("specialType"))?.Value;
            BaseAddressTypeEnum baseAddressType = WatchVariableUtilities.GetBaseAddressType(element.Attribute(XName.Get("base")).Value);
            uint?offsetUS      = ParsingUtilities.ParseHexNullable(element.Attribute(XName.Get("offsetUS"))?.Value);
            uint?offsetJP      = ParsingUtilities.ParseHexNullable(element.Attribute(XName.Get("offsetJP"))?.Value);
            uint?offsetSH      = ParsingUtilities.ParseHexNullable(element.Attribute(XName.Get("offsetSH"))?.Value);
            uint?offsetEU      = ParsingUtilities.ParseHexNullable(element.Attribute(XName.Get("offsetEU"))?.Value);
            uint?offsetDefault = ParsingUtilities.ParseHexNullable(element.Attribute(XName.Get("offset"))?.Value);
            uint?mask          = element.Attribute(XName.Get("mask")) != null ?
                                 (uint?)ParsingUtilities.ParseHex(element.Attribute(XName.Get("mask")).Value) : null;
            int?shift = element.Attribute(XName.Get("shift")) != null?
                        int.Parse(element.Attribute(XName.Get("shift")).Value) : (int?)null;

            bool handleMapping = (element.Attribute(XName.Get("handleMapping")) != null) ?
                                 bool.Parse(element.Attribute(XName.Get("handleMapping")).Value) : true;
            string name = element.Value;

            WatchVar =
                new WatchVariable(
                    name,
                    typeName,
                    specialType,
                    baseAddressType,
                    offsetUS,
                    offsetJP,
                    offsetSH,
                    offsetEU,
                    offsetDefault,
                    mask,
                    shift,
                    handleMapping);

            Name            = name;
            Subclass        = WatchVariableUtilities.GetSubclass(element.Attribute(XName.Get("subclass"))?.Value);
            GroupList       = WatchVariableUtilities.ParseVariableGroupList(element.Attribute(XName.Get("groupList"))?.Value);
            BackgroundColor = (element.Attribute(XName.Get("color")) != null) ?
                              ColorUtilities.GetColorFromString(element.Attribute(XName.Get("color")).Value) : (Color?)null;
            string displayTypeName = (element.Attribute(XName.Get("display"))?.Value);

            DisplayType   = displayTypeName != null ? TypeUtilities.StringToType[displayTypeName] : null;
            RoundingLimit = (element.Attribute(XName.Get("round")) != null) ?
                            ParsingUtilities.ParseInt(element.Attribute(XName.Get("round")).Value) : (int?)null;
            UseHex = (element.Attribute(XName.Get("useHex")) != null) ?
                     bool.Parse(element.Attribute(XName.Get("useHex")).Value) : (bool?)null;
            InvertBool = element.Attribute(XName.Get("invertBool")) != null?
                         bool.Parse(element.Attribute(XName.Get("invertBool")).Value) : (bool?)null;

            IsYaw = (element.Attribute(XName.Get("yaw")) != null) ?
                    bool.Parse(element.Attribute(XName.Get("yaw")).Value) : (bool?)null;
            Coordinate = element.Attribute(XName.Get("coord")) != null?
                         WatchVariableUtilities.GetCoordinate(element.Attribute(XName.Get("coord")).Value) : (Coordinate?)null;

            FixedAddresses = element.Attribute(XName.Get("fixed")) != null?
                             ParsingUtilities.ParseHexList(element.Attribute(XName.Get("fixed")).Value) : null;

            VerifyState();
        }