Exemplo n.º 1
0
        /// <summary>
        /// Load the VehicleMod from the XmlNode.
        /// </summary>
        /// <param name="objNode">XmlNode to load.</param>
        /// <param name="objVehicle">Vehicle that the mod is attached to.</param>
        /// <param name="blnCopy">Indicates whether a new item will be created as a copy of this one.</param>
        public void Load(XmlNode objNode, Vehicle objVehicle, bool blnCopy = false)
        {
            if (blnCopy)
            {
                _guiID = Guid.NewGuid();
            }
            else
            {
                objNode.TryGetField("guid", Guid.TryParse, out _guiID);
            }
            objNode.TryGetStringFieldQuickly("name", ref _strName);
            objNode.TryGetStringFieldQuickly("category", ref _strCategory);
            objNode.TryGetStringFieldQuickly("limit", ref _strLimit);
            objNode.TryGetInt32FieldQuickly("slots", ref _intSlots);
            objNode.TryGetStringFieldQuickly("weaponmountcategories", ref _strWeaponMountCategories);
            objNode.TryGetStringFieldQuickly("page", ref _strPage);
            objNode.TryGetStringFieldQuickly("avail", ref _strAvail);
            objNode.TryGetStringFieldQuickly("cost", ref _strCost);
            objNode.TryGetDecFieldQuickly("markup", ref _decMarkup);
            objNode.TryGetStringFieldQuickly("source", ref _strSource);
            objNode.TryGetBoolFieldQuickly("included", ref _blnIncludeInVehicle);
            objNode.TryGetBoolFieldQuickly("installed", ref _blnInstalled);
            if (objNode["weapons"] != null)
            {
                foreach (XmlNode n in objNode.SelectNodes("weapons/weapon"))
                {
                    Weapon w = new Weapon(_character);
                    w.Load(n, blnCopy);
                    _weapons.Add(w);
                }
            }
            if (objNode["weaponmountoptions"] != null)
            {
                foreach (XmlNode n in objNode.SelectNodes("weaponmountoptions/weaponmountoption"))
                {
                    WeaponMountOption w = new WeaponMountOption(_character);
                    w.Load(n, _vehicle);
                    WeaponMountOptions.Add(w);
                }
            }
            objNode.TryGetStringFieldQuickly("notes", ref _strNotes);
            objNode.TryGetBoolFieldQuickly("discountedcost", ref _blnDiscountCost);
            objNode.TryGetStringFieldQuickly("extra", ref _strExtra);

            if (GlobalOptions.Language != GlobalOptions.DefaultLanguage)
            {
                XmlNode objModNode = MyXmlNode;
                if (objModNode != null)
                {
                    objModNode.TryGetStringFieldQuickly("translate", ref _strAltName);
                    objModNode.TryGetStringFieldQuickly("altpage", ref _strAltPage);
                }

                XmlDocument objXmlDocument = XmlManager.Load("vehicles.xml");
                objModNode      = objXmlDocument.SelectSingleNode("/chummer/categories/category[. = \"" + _strCategory + "\"]");
                _strAltCategory = objModNode?.Attributes?["translate"]?.InnerText;
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Load the VehicleMod from the XmlNode.
 /// </summary>
 /// <param name="objNode">XmlNode to load.</param>
 /// <param name="objVehicle">Vehicle that the mod is attached to.</param>
 /// <param name="blnCopy">Indicates whether a new item will be created as a copy of this one.</param>
 public void Load(XmlNode objNode, Vehicle objVehicle, bool blnCopy = false)
 {
     if (blnCopy)
     {
         _guiID = Guid.NewGuid();
     }
     else
     {
         objNode.TryGetField("guid", Guid.TryParse, out _guiID);
     }
     objNode.TryGetStringFieldQuickly("name", ref _strName);
     if (!objNode.TryGetStringFieldQuickly("sourceid", ref _strSourceId))
     {
         _strSourceId = XmlManager.Load("vehicles.xml")?.SelectSingleNode("/chummer/weaponmounts/weaponmount[name = \"" + _strName + "\"]")?["id"]?.InnerText ?? Guid.NewGuid().ToString();
     }
     objNode.TryGetStringFieldQuickly("category", ref _strCategory);
     objNode.TryGetStringFieldQuickly("limit", ref _strLimit);
     objNode.TryGetInt32FieldQuickly("slots", ref _intSlots);
     objNode.TryGetStringFieldQuickly("weaponmountcategories", ref _strWeaponMountCategories);
     objNode.TryGetStringFieldQuickly("page", ref _strPage);
     objNode.TryGetStringFieldQuickly("avail", ref _strAvail);
     objNode.TryGetStringFieldQuickly("cost", ref _strCost);
     objNode.TryGetDecFieldQuickly("markup", ref _decMarkup);
     objNode.TryGetStringFieldQuickly("source", ref _strSource);
     objNode.TryGetBoolFieldQuickly("included", ref _blnIncludeInVehicle);
     objNode.TryGetBoolFieldQuickly("installed", ref _blnInstalled);
     if (objNode["weapons"] != null)
     {
         foreach (XmlNode n in objNode.SelectNodes("weapons/weapon"))
         {
             Weapon w = new Weapon(_character);
             w.Load(n, blnCopy);
             _weapons.Add(w);
         }
     }
     if (objNode["weaponmountoptions"] != null)
     {
         foreach (XmlNode n in objNode.SelectNodes("weaponmountoptions/weaponmountoption"))
         {
             WeaponMountOption w = new WeaponMountOption(_character);
             w.Load(n, _vehicle);
             WeaponMountOptions.Add(w);
         }
     }
     objNode.TryGetStringFieldQuickly("notes", ref _strNotes);
     objNode.TryGetBoolFieldQuickly("discountedcost", ref _blnDiscountCost);
     objNode.TryGetStringFieldQuickly("extra", ref _strExtra);
 }
Exemplo n.º 3
0
        /// <summary>
        /// Load the VehicleMod from the XmlNode.
        /// </summary>
        /// <param name="objNode">XmlNode to load.</param>
        /// <param name="objVehicle">Vehicle that the mod is attached to.</param>
        /// <param name="blnCopy">Indicates whether a new item will be created as a copy of this one.</param>
        public void Load(XmlNode objNode, Vehicle objVehicle, bool blnCopy = false)
        {
            if (blnCopy)
            {
                _guiID = Guid.NewGuid();
            }
            else
            {
                objNode.TryGetField("guid", Guid.TryParse, out _guiID);
            }
            objNode.TryGetStringFieldQuickly("name", ref _strName);
            if (!objNode.TryGetStringFieldQuickly("sourceid", ref _strSourceId))
            {
                _strSourceId = XmlManager.Load("vehicles.xml").SelectSingleNode("/chummer/weaponmounts/weaponmount[name = \"" + _strName + "\"]/id")?.InnerText ?? Guid.NewGuid().ToString("D");
            }
            objNode.TryGetStringFieldQuickly("category", ref _strCategory);
            objNode.TryGetStringFieldQuickly("limit", ref _strLimit);
            objNode.TryGetInt32FieldQuickly("slots", ref _intSlots);
            objNode.TryGetStringFieldQuickly("weaponmountcategories", ref _strWeaponMountCategories);
            objNode.TryGetStringFieldQuickly("page", ref _strPage);
            objNode.TryGetStringFieldQuickly("avail", ref _strAvail);
            objNode.TryGetStringFieldQuickly("cost", ref _strCost);
            objNode.TryGetDecFieldQuickly("markup", ref _decMarkup);
            objNode.TryGetStringFieldQuickly("source", ref _strSource);
            objNode.TryGetBoolFieldQuickly("included", ref _blnIncludeInVehicle);
            objNode.TryGetBoolFieldQuickly("installed", ref _blnInstalled);

            XmlNode xmlChildrenNode = objNode["weapons"];

            if (xmlChildrenNode != null)
            {
                using (XmlNodeList xmlWeaponList = xmlChildrenNode.SelectNodes("weapon"))
                    if (xmlWeaponList != null)
                    {
                        foreach (XmlNode xmlWeaponNode in xmlWeaponList)
                        {
                            Weapon objWeapon = new Weapon(_objCharacter)
                            {
                                ParentVehicle = Parent,
                                ParentMount   = this
                            };
                            objWeapon.Load(xmlWeaponNode, blnCopy);
                            _lstWeapons.Add(objWeapon);
                        }
                    }
            }
            xmlChildrenNode = objNode["weaponmountoptions"];
            if (xmlChildrenNode != null)
            {
                using (XmlNodeList xmlWeaponMountOptionList = xmlChildrenNode.SelectNodes("weaponmountoption"))
                    if (xmlWeaponMountOptionList != null)
                    {
                        foreach (XmlNode xmlWeaponMountOptionNode in xmlWeaponMountOptionList)
                        {
                            WeaponMountOption objWeaponMountOption = new WeaponMountOption(_objCharacter);
                            objWeaponMountOption.Load(xmlWeaponMountOptionNode);
                            WeaponMountOptions.Add(objWeaponMountOption);
                        }
                    }
            }
            xmlChildrenNode = objNode["mods"];
            if (xmlChildrenNode != null)
            {
                using (XmlNodeList xmlModList = xmlChildrenNode.SelectNodes("mod"))
                    if (xmlModList != null)
                    {
                        foreach (XmlNode xmlModNode in xmlModList)
                        {
                            VehicleMod objMod = new VehicleMod(_objCharacter)
                            {
                                Parent            = Parent,
                                WeaponMountParent = this
                            };
                            objMod.Load(xmlModNode);
                            _lstMods.Add(objMod);
                        }
                    }
            }
            objNode.TryGetStringFieldQuickly("notes", ref _strNotes);
            objNode.TryGetBoolFieldQuickly("discountedcost", ref _blnDiscountCost);
            objNode.TryGetStringFieldQuickly("extra", ref _strExtra);
        }