/// <summary> /// Load the CharacterAttribute from the XmlNode. /// </summary> /// <param name="objNode">XmlNode to load.</param> /// <param name="blnCopy">Whether or not we are copying an existing node.</param> public void Load(XmlNode objNode, bool blnCopy = false) { if (blnCopy) { _guiID = Guid.NewGuid(); } else { _guiID = Guid.Parse(objNode["guid"].InnerText); } objNode.TryGetStringFieldQuickly("name", ref _strName); objNode.TryGetStringFieldQuickly("category", ref _strCategory); objNode.TryGetInt32FieldQuickly("armor", ref _intA); objNode.TryGetStringFieldQuickly("armorcapacity", ref _strArmorCapacity); objNode.TryGetStringFieldQuickly("gearcapacity", ref _strGearCapacity); objNode.TryGetInt32FieldQuickly("maxrating", ref _intMaxRating); objNode.TryGetInt32FieldQuickly("rating", ref _intRating); objNode.TryGetStringFieldQuickly("avail", ref _strAvail); objNode.TryGetStringFieldQuickly("cost", ref _strCost); _nodBonus = objNode["bonus"]; _nodWirelessBonus = objNode["wirelessbonus"]; objNode.TryGetStringFieldQuickly("source", ref _strSource); objNode.TryGetStringFieldQuickly("page", ref _strPage); objNode.TryGetBoolFieldQuickly("included", ref _blnIncludedInArmor); objNode.TryGetBoolFieldQuickly("equipped", ref _blnEquipped); if (!objNode.TryGetBoolFieldQuickly("wirelesson", ref _blnWirelessOn)) { _blnWirelessOn = _nodWirelessBonus != null; } objNode.TryGetStringFieldQuickly("extra", ref _strExtra); if (objNode["weaponguid"] != null) { _guiWeaponID = Guid.Parse(objNode["weaponguid"].InnerText); } objNode.TryGetStringFieldQuickly("notes", ref _strNotes); objNode.TryGetBoolFieldQuickly("discountedcost", ref _blnDiscountCost); if (objNode.InnerXml.Contains("gears")) { XmlNodeList nodGears = objNode.SelectNodes("gears/gear"); foreach (XmlNode nodGear in nodGears) { if (nodGear["iscommlink"]?.InnerText == System.Boolean.TrueString || (nodGear["category"].InnerText == "Commlinks" || nodGear["category"].InnerText == "Commlink Accessories" || nodGear["category"].InnerText == "Cyberdecks" || nodGear["category"].InnerText == "Rigger Command Consoles")) { Gear objCommlink = new Commlink(_objCharacter); objCommlink.Load(nodGear, blnCopy); _lstGear.Add(objCommlink); } else { Gear objGear = new Gear(_objCharacter); objGear.Load(nodGear, blnCopy); _lstGear.Add(objGear); } } } if (GlobalOptions.Language != GlobalOptions.DefaultLanguage) { XmlNode objArmorNode = MyXmlNode; if (objArmorNode != null) { objArmorNode.TryGetStringFieldQuickly("translate", ref _strAltName); objArmorNode.TryGetStringFieldQuickly("altpage", ref _strAltPage); } XmlDocument objXmlDocument = XmlManager.Load("armor.xml"); objArmorNode = objXmlDocument.SelectSingleNode("/chummer/categories/category[. = \"" + _strCategory + "\"]"); _strAltCategory = objArmorNode?.Attributes?["translate"]?.InnerText; } }
/// <summary> /// Load the CharacterAttribute from the XmlNode. /// </summary> /// <param name="objNode">XmlNode to load.</param> /// <param name="blnCopy">Whether another node is being copied.</param> public void Load(XmlNode objNode, bool blnCopy = false) { if (blnCopy) { _guiID = Guid.NewGuid(); } else { _guiID = Guid.Parse(objNode["guid"].InnerText); } objNode.TryGetStringFieldQuickly("name", ref _strName); objNode.TryGetStringFieldQuickly("mount", ref _strMount); objNode.TryGetStringFieldQuickly("extramount", ref _strExtraMount); objNode.TryGetStringFieldQuickly("rc", ref _strRC); objNode.TryGetInt32FieldQuickly("rating", ref _intRating); objNode.TryGetInt32FieldQuickly("rcgroup", ref _intRCGroup); objNode.TryGetInt32FieldQuickly("accuracy", ref _intAccuracy); objNode.TryGetInt32FieldQuickly("rating", ref _intRating); objNode.TryGetStringFieldQuickly("conceal", ref _strConceal); objNode.TryGetBoolFieldQuickly("rcdeployable", ref _blnDeployable); objNode.TryGetStringFieldQuickly("avail", ref _strAvail); objNode.TryGetStringFieldQuickly("cost", ref _strCost); objNode.TryGetBoolFieldQuickly("included", ref _blnIncludedInWeapon); objNode.TryGetBoolFieldQuickly("installed", ref _blnInstalled); _nodAllowGear = objNode["allowgear"]; objNode.TryGetStringFieldQuickly("source", ref _strSource); objNode.TryGetStringFieldQuickly("page", ref _strPage); objNode.TryGetStringFieldQuickly("dicepool", ref _strDicePool); objNode.TryGetInt32FieldQuickly("ammoslots", ref _intAmmoSlots); if (objNode.InnerXml.Contains("<gears>")) { XmlNodeList nodChildren = objNode.SelectNodes("gears/gear"); foreach (XmlNode nodChild in nodChildren) { switch (nodChild["category"].InnerText) { case "Commlinks": case "Commlink Accessories": case "Cyberdecks": case "Rigger Command Consoles": Commlink objCommlink = new Commlink(_objCharacter); objCommlink.Load(nodChild, blnCopy); _lstGear.Add(objCommlink); break; default: Gear objGear = new Gear(_objCharacter); objGear.Load(nodChild, blnCopy); _lstGear.Add(objGear); break; } } } objNode.TryGetStringFieldQuickly("notes", ref _strNotes); objNode.TryGetBoolFieldQuickly("discountedcost", ref _blnDiscountCost); if (GlobalOptions.Instance.Language != "en-us") { XmlDocument objXmlDocument = XmlManager.Instance.Load("weapons.xml"); XmlNode objAccessoryNode = objXmlDocument.SelectSingleNode("/chummer/accessories/accessory[name = \"" + _strName + "\"]"); if (objAccessoryNode != null) { objAccessoryNode.TryGetStringFieldQuickly("translate", ref _strAltName); objAccessoryNode.TryGetStringFieldQuickly("altpage", ref _strAltPage); } } objNode.TryGetStringFieldQuickly("damage", ref _strDamage); objNode.TryGetStringFieldQuickly("damagetype", ref _strDamageType); objNode.TryGetStringFieldQuickly("damagereplace", ref _strDamageReplace); objNode.TryGetStringFieldQuickly("firemode", ref _strFireMode); objNode.TryGetStringFieldQuickly("firemodereplace", ref _strFireModeReplace); objNode.TryGetStringFieldQuickly("ap", ref _strAP); objNode.TryGetStringFieldQuickly("apreplace", ref _strAPReplace); objNode.TryGetInt32FieldQuickly("accessorycostmultiplier", ref _intAccessoryCostMultiplier); objNode.TryGetStringFieldQuickly("addmode", ref _strAddMode); objNode.TryGetInt32FieldQuickly("fullburst", ref _intFullBurst); objNode.TryGetInt32FieldQuickly("suppressive", ref _intSuppressive); objNode.TryGetInt32FieldQuickly("rangebonus", ref _intRangeBonus); objNode.TryGetStringFieldQuickly("extra", ref _strExtra); objNode.TryGetInt32FieldQuickly("ammobonus", ref _intAmmoBonus); }
/// <summary> /// Load the Vehicle from the XmlNode. /// </summary> /// <param name="objNode">XmlNode to load.</param> public void Load(XmlNode objNode, bool blnCopy = false) { _guiID = Guid.Parse(objNode["guid"].InnerText); _strName = objNode["name"].InnerText; _strCategory = objNode["category"].InnerText; //Some vehicles have different Offroad Handling speeds. If so, we want to split this up for use with mods and such later. if (objNode["handling"].InnerText.Contains('/')) { _intHandling = Convert.ToInt32(objNode["handling"].InnerText.Split('/')[0]); _intOffroadHandling = Convert.ToInt32(objNode["handling"].InnerText.Split('/')[1]); } else { _intHandling = Convert.ToInt32(objNode["handling"].InnerText); if (objNode.InnerXml.Contains("offroadhandling")) { _intOffroadHandling = Convert.ToInt32(objNode["offroadhandling"].InnerText); } } _intAccel = Convert.ToInt32(objNode["accel"].InnerText); objNode.TryGetField("seats", out _intSeats); _intSpeed = Convert.ToInt32(objNode["speed"].InnerText); _intPilot = Convert.ToInt32(objNode["pilot"].InnerText); _intBody = Convert.ToInt32(objNode["body"].InnerText); _intArmor = Convert.ToInt32(objNode["armor"].InnerText); _intSensor = Convert.ToInt32(objNode["sensor"].InnerText); objNode.TryGetField("devicerating", out _intDeviceRating); _strAvail = objNode["avail"].InnerText; _strCost = objNode["cost"].InnerText; objNode.TryGetField("addslots", out _intAddSlots); objNode.TryGetField("modslots", out _intModSlots); _strSource = objNode["source"].InnerText; objNode.TryGetField("page", out _strPage); objNode.TryGetField("matrixcmfilled", out _intMatrixCMFilled); objNode.TryGetField("physicalcmfilled", out _intPhysicalCMFilled); objNode.TryGetField("vehiclename", out _strVehicleName); objNode.TryGetField("homenode", out _blnHomeNode); if (GlobalOptions.Instance.Language != "en-us") { XmlDocument objXmlDocument = XmlManager.Instance.Load("vehicles.xml"); XmlNode objVehicleNode = objXmlDocument.SelectSingleNode("/chummer/vehicles/vehicle[name = \"" + _strName + "\"]"); if (objVehicleNode != null) { if (objVehicleNode["translate"] != null) _strAltName = objVehicleNode["translate"].InnerText; if (objVehicleNode["altpage"] != null) _strAltPage = objVehicleNode["altpage"].InnerText; } objVehicleNode = objXmlDocument.SelectSingleNode("/chummer/categories/category[. = \"" + _strCategory + "\"]"); if (objVehicleNode != null) { if (objVehicleNode.Attributes["translate"] != null) _strAltCategory = objVehicleNode.Attributes["translate"].InnerText; } } if (objNode.InnerXml.Contains("<mods>")) { XmlNodeList nodChildren = objNode.SelectNodes("mods/mod"); foreach (XmlNode nodChild in nodChildren) { VehicleMod objMod = new VehicleMod(_objCharacter); objMod.Load(nodChild, blnCopy); _lstVehicleMods.Add(objMod); } } if (objNode.InnerXml.Contains("<gears>")) { XmlNodeList nodChildren = objNode.SelectNodes("gears/gear"); foreach (XmlNode nodChild in nodChildren) { switch (nodChild["category"].InnerText) { case "Commlinks": case "Commlink Accessories": case "Cyberdecks": case "Rigger Command Consoles": Commlink objCommlink = new Commlink(_objCharacter); objCommlink.Load(nodChild, blnCopy); _lstGear.Add(objCommlink); break; default: Gear objGear = new Gear(_objCharacter); objGear.Load(nodChild, blnCopy); _lstGear.Add(objGear); break; } } } if (objNode.InnerXml.Contains("<weapons>")) { XmlNodeList nodChildren = objNode.SelectNodes("weapons/weapon"); foreach (XmlNode nodChild in nodChildren) { Weapon objWeapon = new Weapon(_objCharacter); objWeapon.Load(nodChild, blnCopy); objWeapon.VehicleMounted = true; if (objWeapon.UnderbarrelWeapons.Count > 0) { foreach (Weapon objUnderbarrel in objWeapon.UnderbarrelWeapons) objUnderbarrel.VehicleMounted = true; } _lstWeapons.Add(objWeapon); } } objNode.TryGetField("notes", out _strNotes); objNode.TryGetField("dealerconnection", out _blnDealerConnectionDiscount); if (objNode["locations"] != null) { // Locations. foreach (XmlNode objXmlLocation in objNode.SelectNodes("locations/location")) { _lstLocations.Add(objXmlLocation.InnerText); } } if (blnCopy) { _guiID = Guid.NewGuid(); _blnHomeNode = false; } }
/// <summary> /// Load the Gear from the XmlNode. /// </summary> /// <param name="objNode">XmlNode to load.</param> public new void Load(XmlNode objNode, bool blnCopy = false) { _guiID = Guid.Parse(objNode["guid"].InnerText); _strName = objNode["name"].InnerText; _strCategory = objNode["category"].InnerText; objNode.TryGetField("armorcapacity", out _strArmorCapacity).ToString(); _intMaxRating = Convert.ToInt32(objNode["maxrating"].InnerText); _intRating = Convert.ToInt32(objNode["rating"].InnerText); _intQty = Convert.ToInt32(objNode["qty"].InnerText); _strAvail = objNode["avail"].InnerText; _strCost = objNode["cost"].InnerText; _strExtra = objNode["extra"].InnerText; objNode.TryGetField("overclocked", out _strOverclocked); objNode.TryGetField("bonded", out _blnBonded); objNode.TryGetField("equipped", out _blnEquipped); objNode.TryGetField("homenode", out _blnHomeNode); _nodBonus = objNode["bonus"]; _strSource = objNode["source"].InnerText; objNode.TryGetField("page", out _strPage); _intDeviceRating = Convert.ToInt32(objNode["devicerating"].InnerText); objNode.TryGetField("attack", out _intAttack); objNode.TryGetField("sleaze", out _intSleaze); objNode.TryGetField("dataprocessing", out _intDataProcessing); objNode.TryGetField("firewall", out _intFirewall); objNode.TryGetField("gearname", out _strGearName); if (objNode.InnerXml.Contains("<gear>")) { XmlNodeList nodChildren = objNode.SelectNodes("children/gear"); foreach (XmlNode nodChild in nodChildren) { switch (nodChild["category"].InnerText) { case "Commlinks": case "Commlink Accessories": case "Cyberdecks": case "Rigger Command Consoles": Commlink objCommlink = new Commlink(_objCharacter); objCommlink.Load(nodChild, blnCopy); objCommlink.Parent = this; _objChildren.Add(objCommlink); break; default: Gear objGear = new Gear(_objCharacter); objGear.Load(nodChild, blnCopy); objGear.Parent = this; _objChildren.Add(objGear); break; } } } objNode.TryGetField("location", out _strLocation); objNode.TryGetField("notes", out _strNotes); objNode.TryGetField("discountedcost", out _blnDiscountCost); objNode.TryGetField("active", out _blnActiveCommlink); if (GlobalOptions.Instance.Language != "en-us") { XmlDocument objXmlDocument = XmlManager.Instance.Load("gear.xml"); XmlNode objGearNode = objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"" + _strName + "\"]"); if (objGearNode != null) { if (objGearNode["translate"] != null) _strAltName = objGearNode["translate"].InnerText; if (objGearNode["altpage"] != null) _strAltPage = objGearNode["altpage"].InnerText; } if (_strAltName.StartsWith("Stacked Focus")) _strAltName = _strAltName.Replace("Stacked Focus", LanguageManager.Instance.GetString("String_StackedFocus")); objGearNode = objXmlDocument.SelectSingleNode("/chummer/categories/category[. = \"" + _strCategory + "\"]"); if (objGearNode != null) { if (objGearNode.Attributes["translate"] != null) _strAltCategory = objGearNode.Attributes["translate"].InnerText; } if (_strAltCategory.StartsWith("Stacked Focus")) _strAltCategory = _strAltCategory.Replace("Stacked Focus", LanguageManager.Instance.GetString("String_StackedFocus")); } if (blnCopy) { _guiID = Guid.NewGuid(); _strLocation = string.Empty; _blnHomeNode = false; } }
/// <summary> /// Load the Gear from the XmlNode. /// </summary> /// <param name="objNode">XmlNode to load.</param> public new void Load(XmlNode objNode, bool blnCopy = false) { _guiID = Guid.Parse(objNode["guid"].InnerText); _strName = objNode["name"].InnerText; _strCategory = objNode["category"].InnerText; objNode.TryGetField("armorcapacity", out _strArmorCapacity).ToString(); _intMaxRating = Convert.ToInt32(objNode["maxrating"].InnerText); _intRating = Convert.ToInt32(objNode["rating"].InnerText); _intQty = Convert.ToInt32(objNode["qty"].InnerText); _strAvail = objNode["avail"].InnerText; _strCost = objNode["cost"].InnerText; _strExtra = objNode["extra"].InnerText; objNode.TryGetField("overclocked", out _strOverclocked); objNode.TryGetField("bonded", out _blnBonded); objNode.TryGetField("equipped", out _blnEquipped); objNode.TryGetField("homenode", out _blnHomeNode); _nodBonus = objNode["bonus"]; _strSource = objNode["source"].InnerText; objNode.TryGetField("page", out _strPage); _intDeviceRating = Convert.ToInt32(objNode["devicerating"].InnerText); objNode.TryGetField("attack", out _intAttack); objNode.TryGetField("sleaze", out _intSleaze); objNode.TryGetField("dataprocessing", out _intDataProcessing); objNode.TryGetField("firewall", out _intFirewall); objNode.TryGetField("gearname", out _strGearName); if (objNode.InnerXml.Contains("<gear>")) { XmlNodeList nodChildren = objNode.SelectNodes("children/gear"); foreach (XmlNode nodChild in nodChildren) { switch (nodChild["category"].InnerText) { case "Commlinks": case "Commlink Accessories": case "Cyberdecks": case "Rigger Command Consoles": Commlink objCommlink = new Commlink(_objCharacter); objCommlink.Load(nodChild, blnCopy); objCommlink.Parent = this; _objChildren.Add(objCommlink); break; default: Gear objGear = new Gear(_objCharacter); objGear.Load(nodChild, blnCopy); objGear.Parent = this; _objChildren.Add(objGear); break; } } } objNode.TryGetField("location", out _strLocation); objNode.TryGetField("notes", out _strNotes); objNode.TryGetField("discountedcost", out _blnDiscountCost); objNode.TryGetField("active", out _blnActiveCommlink); if (GlobalOptions.Instance.Language != "en-us") { XmlDocument objXmlDocument = XmlManager.Instance.Load("gear.xml"); XmlNode objGearNode = objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"" + _strName + "\"]"); if (objGearNode != null) { if (objGearNode["translate"] != null) { _strAltName = objGearNode["translate"].InnerText; } if (objGearNode["altpage"] != null) { _strAltPage = objGearNode["altpage"].InnerText; } } if (_strAltName.StartsWith("Stacked Focus")) { _strAltName = _strAltName.Replace("Stacked Focus", LanguageManager.Instance.GetString("String_StackedFocus")); } objGearNode = objXmlDocument.SelectSingleNode("/chummer/categories/category[. = \"" + _strCategory + "\"]"); if (objGearNode != null) { if (objGearNode.Attributes["translate"] != null) { _strAltCategory = objGearNode.Attributes["translate"].InnerText; } } if (_strAltCategory.StartsWith("Stacked Focus")) { _strAltCategory = _strAltCategory.Replace("Stacked Focus", LanguageManager.Instance.GetString("String_StackedFocus")); } } if (blnCopy) { _guiID = Guid.NewGuid(); _strLocation = string.Empty; _blnHomeNode = false; } }
/// <summary> /// Load the CharacterAttribute from the XmlNode. /// </summary> /// <param name="objNode">XmlNode to load.</param> /// <param name="blnCopy">Whether another node is being copied.</param> public void Load(XmlNode objNode, bool blnCopy = false) { _guiID = Guid.Parse(objNode["guid"].InnerText); _strName = objNode["name"].InnerText; _strMount = objNode["mount"].InnerText; objNode.TryGetField("extramount", out _strExtraMount, ""); _strRC = objNode["rc"].InnerText; objNode.TryGetField("rating", out _intRating, 0); objNode.TryGetField("rcgroup", out _intRCGroup, 0); objNode.TryGetField("accuracy", out _intAccuracy, 0); objNode.TryGetField("rating", out _intRating, 0); objNode.TryGetField("rating", out _intRating, 0); objNode.TryGetField("conceal", out _strConceal, "0"); objNode.TryGetField("rcdeployable", out _blnDeployable); _strAvail = objNode["avail"].InnerText; _strCost = objNode["cost"].InnerText; _blnIncludedInWeapon = Convert.ToBoolean(objNode["included"].InnerText); objNode.TryGetField("installed", out _blnInstalled, true); try { _nodAllowGear = objNode["allowgear"]; } catch { } _strSource = objNode["source"].InnerText; objNode.TryGetField("page", out _strPage, "0"); objNode.TryGetField("dicepool", out _strDicePool, "0"); if (objNode.InnerXml.Contains("ammoslots")) { objNode.TryGetField("ammoslots", out _intAmmoSlots, 0); //TODO: Might work if 0 -> 1 } if (objNode.InnerXml.Contains("<gears>")) { XmlNodeList nodChildren = objNode.SelectNodes("gears/gear"); foreach (XmlNode nodChild in nodChildren) { switch (nodChild["category"].InnerText) { case "Commlinks": case "Commlink Accessories": case "Cyberdecks": case "Rigger Command Consoles": Commlink objCommlink = new Commlink(_objCharacter); objCommlink.Load(nodChild, blnCopy); _lstGear.Add(objCommlink); break; default: Gear objGear = new Gear(_objCharacter); objGear.Load(nodChild, blnCopy); _lstGear.Add(objGear); break; } } } objNode.TryGetField("notes", out _strNotes, ""); objNode.TryGetField("discountedcost", out _blnDiscountCost, false); if (GlobalOptions.Instance.Language != "en-us") { XmlDocument objXmlDocument = XmlManager.Instance.Load("weapons.xml"); XmlNode objAccessoryNode = objXmlDocument.SelectSingleNode("/chummer/accessories/accessory[name = \"" + _strName + "\"]"); if (objAccessoryNode != null) { if (objAccessoryNode["translate"] != null) { _strAltName = objAccessoryNode["translate"].InnerText; } if (objAccessoryNode["altpage"] != null) { _strAltPage = objAccessoryNode["altpage"].InnerText; } } } if (objNode["damage"] != null) { _strDamage = objNode["damage"].InnerText; } if (objNode["damagetype"] != null) { _strDamageType = objNode["damagetype"].InnerText; } if (objNode["damagereplace"] != null) { _strDamageReplace = objNode["damagereplace"].InnerText; } if (objNode["firemode"] != null) { _strFireMode = objNode["firemode"].InnerText; } if (objNode["firemodereplace"] != null) { _strFireModeReplace = objNode["firemodereplace"].InnerText; } if (objNode["ap"] != null) { _strAP = objNode["ap"].InnerText; } if (objNode["apreplace"] != null) { _strAPReplace = objNode["apreplace"].InnerText; } objNode.TryGetField("accessorycostmultiplier", out _intAccessoryCostMultiplier); objNode.TryGetField("addmode", out _strAddMode); objNode.TryGetField("fullburst", out _intFullBurst, 0); objNode.TryGetField("suppressive", out _intSuppressive, 0); objNode.TryGetField("rangebonus", out _intRangeBonus, 0); objNode.TryGetField("extra", out _strExtra, ""); objNode.TryGetField("ammobonus", out _intAmmoBonus, 0); if (blnCopy) { _guiID = Guid.NewGuid(); } }
/// <summary> /// Load the CharacterAttribute from the XmlNode. /// </summary> /// <param name="objNode">XmlNode to load.</param> /// <param name="blnCopy">Whether another node is being copied.</param> public void Load(XmlNode objNode, bool blnCopy = false) { _guiID = Guid.Parse(objNode["guid"].InnerText); _strName = objNode["name"].InnerText; _strMount = objNode["mount"].InnerText; _strRC = objNode["rc"].InnerText; objNode.TryGetField("rating", out _intRating,0); objNode.TryGetField("rcgroup", out _intRCGroup, 0); objNode.TryGetField("accuracy", out _intAccuracy, 0); objNode.TryGetField("rating", out _intRating, 0); objNode.TryGetField("rating", out _intRating, 0); objNode.TryGetField("conceal", out _strConceal, "0"); objNode.TryGetField("rcdeployable", out _blnDeployable); _strAvail = objNode["avail"].InnerText; _strCost = objNode["cost"].InnerText; _blnIncludedInWeapon = Convert.ToBoolean(objNode["included"].InnerText); objNode.TryGetField("installed", out _blnInstalled, true); try { _nodAllowGear = objNode["allowgear"]; } catch { } _strSource = objNode["source"].InnerText; objNode.TryGetField("page", out _strPage, "0"); objNode.TryGetField("dicepool", out _strDicePool, "0"); if (objNode.InnerXml.Contains("ammoslots")) { objNode.TryGetField("ammoslots", out _intAmmoSlots, 0); //TODO: Might work if 0 -> 1 } if (objNode.InnerXml.Contains("<gears>")) { XmlNodeList nodChildren = objNode.SelectNodes("gears/gear"); foreach (XmlNode nodChild in nodChildren) { switch (nodChild["category"].InnerText) { case "Commlinks": case "Commlink Accessories": case "Cyberdecks": case "Rigger Command Consoles": Commlink objCommlink = new Commlink(_objCharacter); objCommlink.Load(nodChild, blnCopy); _lstGear.Add(objCommlink); break; default: Gear objGear = new Gear(_objCharacter); objGear.Load(nodChild, blnCopy); _lstGear.Add(objGear); break; } } } objNode.TryGetField("notes", out _strNotes, ""); objNode.TryGetField("discountedcost", out _blnDiscountCost, false); if (GlobalOptions.Instance.Language != "en-us") { XmlDocument objXmlDocument = XmlManager.Instance.Load("weapons.xml"); XmlNode objAccessoryNode = objXmlDocument.SelectSingleNode("/chummer/accessories/accessory[name = \"" + _strName + "\"]"); if (objAccessoryNode != null) { if (objAccessoryNode["translate"] != null) _strAltName = objAccessoryNode["translate"].InnerText; if (objAccessoryNode["altpage"] != null) _strAltPage = objAccessoryNode["altpage"].InnerText; } } if (objNode["damage"] != null) { _strDamage = objNode["damage"].InnerText; } if (objNode["damagetype"] != null) { _strDamageType = objNode["damagetype"].InnerText; } if (objNode["damagereplace"] != null) { _strDamageReplace = objNode["damagereplace"].InnerText; } if (objNode["firemode"] != null) { _strFireMode = objNode["firemode"].InnerText; } if (objNode["firemodereplace"] != null) { _strFireModeReplace = objNode["firemodereplace"].InnerText; } if (objNode["ap"] != null) { _strAP = objNode["ap"].InnerText; } if (objNode["apreplace"] != null) { _strAPReplace = objNode["apreplace"].InnerText; } objNode.TryGetField("accessorycostmultiplier", out _intAccessoryCostMultiplier); objNode.TryGetField("addmode", out _strAddMode); objNode.TryGetField("fullburst", out _intFullBurst,0); objNode.TryGetField("suppressive", out _intSuppressive,0); objNode.TryGetField("rangebonus", out _intRangeBonus,0); objNode.TryGetField("extra", out _strExtra,""); objNode.TryGetField("ammobonus", out _intAmmoBonus,0); if (blnCopy) { _guiID = Guid.NewGuid(); } }
/// <summary> /// Enable/Disable the Paste Menu and ToolStrip items as appropriate. /// </summary> private void RefreshPasteStatus() { bool blnPasteEnabled = false; bool blnCopyEnabled = false; if (tabCharacterTabs.SelectedTab == tabStreetGear) { // Lifestyle Tab. if (tabStreetGearTabs.SelectedTab == tabLifestyle) { if (GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.Lifestyle) blnPasteEnabled = true; try { foreach (Lifestyle objLifestyle in _objCharacter.Lifestyles) { if (objLifestyle.InternalId == treLifestyles.SelectedNode.Tag.ToString()) { blnCopyEnabled = true; break; } } } catch { } } // Armor Tab. if (tabStreetGearTabs.SelectedTab == tabArmor) { if (GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.Armor) blnPasteEnabled = true; if (GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.Gear || GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.Commlink || GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.OperatingSystem) { // Gear can only be pasted into Armor, not Armor Mods. try { foreach (Armor objArmor in _objCharacter.Armor) { if (objArmor.InternalId == treArmor.SelectedNode.Tag.ToString()) { blnPasteEnabled = true; break; } } } catch { } } try { foreach (Armor objArmor in _objCharacter.Armor) { if (objArmor.InternalId == treArmor.SelectedNode.Tag.ToString()) { blnCopyEnabled = true; break; } } } catch { } try { Armor objArmor = new Armor(_objCharacter); Gear objGear = _objFunctions.FindArmorGear(treArmor.SelectedNode.Tag.ToString(), _objCharacter.Armor, out objArmor); if (objGear != null) blnCopyEnabled = true; } catch { } } // Weapons Tab. if (tabStreetGearTabs.SelectedTab == tabWeapons) { if (GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.Weapon) blnPasteEnabled = true; if (GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.Gear || GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.Commlink || GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.OperatingSystem) { // Check if the copied Gear can be pasted into the selected Weapon Accessory. Gear objGear = new Gear(_objCharacter); XmlNode objXmlNode = GlobalOptions.Instance.Clipboard.SelectSingleNode("/character/gear"); if (objXmlNode != null) { switch (objXmlNode["category"].InnerText) { case "Commlinks": case "Cyberdecks": case "Rigger Command Consoles": Commlink objCommlink = new Commlink(_objCharacter); objCommlink.Load(objXmlNode, true); objGear = objCommlink; break; default: Gear objNewGear = new Gear(_objCharacter); objNewGear.Load(objXmlNode, true); objGear = objNewGear; break; } objGear.Parent = null; // Make sure that a Weapon Accessory is selected and that it allows Gear of the item's Category. WeaponAccessory objAccessory = new WeaponAccessory(_objCharacter); try { foreach (Weapon objCharacterWeapon in _objCharacter.Weapons) { foreach (WeaponAccessory objWeaponAccessory in objCharacterWeapon.WeaponAccessories) { if (objWeaponAccessory.InternalId == treWeapons.SelectedNode.Tag.ToString()) { objAccessory = objWeaponAccessory; break; } } } if (objAccessory.AllowGear != null) { foreach (XmlNode objAllowed in objAccessory.AllowGear.SelectNodes("gearcategory")) { if (objAllowed.InnerText == objGear.Category) { blnPasteEnabled = true; break; } } } } catch { } } } try { foreach (Weapon objWeapon in _objCharacter.Weapons) { if (objWeapon.InternalId == treWeapons.SelectedNode.Tag.ToString()) { blnCopyEnabled = true; break; } } } catch { } try { WeaponAccessory objAccessory = new WeaponAccessory(_objCharacter); Gear objGear = _objFunctions.FindWeaponGear(treWeapons.SelectedNode.Tag.ToString(), _objCharacter.Weapons, out objAccessory); if (objGear != null) blnCopyEnabled = true; } catch { } } // Gear Tab. if (tabStreetGearTabs.SelectedTab == tabGear) { if (GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.Gear || GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.Commlink || GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.OperatingSystem) blnPasteEnabled = true; try { Gear objGear = _objFunctions.FindGear(treGear.SelectedNode.Tag.ToString(), _objCharacter.Gear); if (objGear != null) blnCopyEnabled = true; } catch { } } } // Vehicles Tab. if (tabCharacterTabs.SelectedTab == tabVehicles) { if (GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.Vehicle) blnPasteEnabled = true; if (GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.Gear || GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.Commlink || GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.OperatingSystem) { // Gear can only be pasted into Vehicles and Vehicle Gear. try { foreach (Vehicle objVehicle in _objCharacter.Vehicles) { if (objVehicle.InternalId == treVehicles.SelectedNode.Tag.ToString()) { blnPasteEnabled = true; break; } } } catch { } try { Vehicle objVehicle = new Vehicle(_objCharacter); Gear objGear = _objFunctions.FindVehicleGear(treVehicles.SelectedNode.Tag.ToString(), _objCharacter.Vehicles, out objVehicle); if (objGear != null) blnPasteEnabled = true; } catch { } } if (GlobalOptions.Instance.ClipboardContentType == ClipboardContentType.Weapon) { // Weapons can only be pasted into Vehicle Mods that allow them (Weapon Mounts and Mechanical Arms). try { VehicleMod objMod = new VehicleMod(_objCharacter); foreach (Vehicle objVehicle in _objCharacter.Vehicles) { foreach (VehicleMod objVehicleMod in objVehicle.Mods) { if (objVehicleMod.InternalId == treVehicles.SelectedNode.Tag.ToString()) { if (objVehicleMod.Name.Contains("Weapon Mount") || objVehicleMod.Name.StartsWith("Mechanical Arm") || objMod.WeaponMountCategories != "") { blnPasteEnabled = true; break; } } } } } catch { } } try { foreach (Vehicle objVehicle in _objCharacter.Vehicles) { if (objVehicle.InternalId == treVehicles.SelectedNode.Tag.ToString()) { blnCopyEnabled = true; break; } } } catch { } try { Vehicle objVehicle = new Vehicle(_objCharacter); Gear objGear = _objFunctions.FindVehicleGear(treVehicles.SelectedNode.Tag.ToString(), _objCharacter.Vehicles, out objVehicle); if (objGear != null) blnCopyEnabled = true; } catch { } try { foreach (Vehicle objVehicle in _objCharacter.Vehicles) { foreach (VehicleMod objMod in objVehicle.Mods) { foreach (Weapon objWeapon in objMod.Weapons) { if (objWeapon.InternalId == treVehicles.SelectedNode.Tag.ToString()) { blnCopyEnabled = true; break; } } } } } catch { } } mnuEditPaste.Enabled = blnPasteEnabled; tsbPaste.Enabled = blnPasteEnabled; mnuEditCopy.Enabled = blnCopyEnabled; tsbCopy.Enabled = blnCopyEnabled; }
private void mnuEditPaste_Click(object sender, EventArgs e) { if (tabCharacterTabs.SelectedTab == tabStreetGear) { // Lifestyle Tab. if (tabStreetGearTabs.SelectedTab == tabLifestyle) { // Paste Lifestyle. Lifestyle objLifestyle = new Lifestyle(_objCharacter); XmlNode objXmlNode = GlobalOptions.Instance.Clipboard.SelectSingleNode("/character/lifestyle"); if (objXmlNode != null) { objLifestyle.Load(objXmlNode, true); // Reset the number of months back to 1 since 0 isn't valid in Create Mode. objLifestyle.Months = 1; _objCharacter.Lifestyles.Add(objLifestyle); TreeNode objLifestyleNode = new TreeNode(); objLifestyleNode.Text = objLifestyle.DisplayName; objLifestyleNode.Tag = objLifestyle.InternalId; if (objLifestyle.StyleType.ToString() != "Standard") objLifestyleNode.ContextMenuStrip = cmsAdvancedLifestyle; else objLifestyleNode.ContextMenuStrip = cmsLifestyleNotes; if (objLifestyle.Notes != string.Empty) objLifestyleNode.ForeColor = Color.SaddleBrown; objLifestyleNode.ToolTipText = CommonFunctions.WordWrap(objLifestyle.Notes, 100); treLifestyles.Nodes[0].Nodes.Add(objLifestyleNode); UpdateCharacterInfo(); _blnIsDirty = true; UpdateWindowTitle(); return; } } // Armor Tab. if (tabStreetGearTabs.SelectedTab == tabArmor) { // Paste Armor. Armor objArmor = new Armor(_objCharacter); XmlNode objXmlNode = GlobalOptions.Instance.Clipboard.SelectSingleNode("/character/armor"); if (objXmlNode != null) { objArmor.Load(objXmlNode, true); _objCharacter.Armor.Add(objArmor); _objFunctions.CreateArmorTreeNode(objArmor, treArmor, cmsArmor, cmsArmorMod, cmsArmorGear); UpdateCharacterInfo(); _blnIsDirty = true; UpdateWindowTitle(); return; } // Paste Gear. Gear objGear = new Gear(_objCharacter); objXmlNode = GlobalOptions.Instance.Clipboard.SelectSingleNode("/character/gear"); if (objXmlNode != null) { switch (objXmlNode["category"].InnerText) { case "Commlinks": case "Cyberdecks": case "Rigger Command Consoles": Commlink objCommlink = new Commlink(_objCharacter); objCommlink.Load(objXmlNode, true); objGear = objCommlink; break; default: Gear objNewGear = new Gear(_objCharacter); objNewGear.Load(objXmlNode, true); objGear = objNewGear; break; } foreach (Armor objCharacterArmor in _objCharacter.Armor) { if (objCharacterArmor.InternalId == treArmor.SelectedNode.Tag.ToString()) { objCharacterArmor.Gear.Add(objGear); TreeNode objNode = new TreeNode(); objNode.Text = objGear.DisplayName; objNode.Tag = objGear.InternalId; objNode.ContextMenuStrip = cmsArmorGear; _objFunctions.BuildGearTree(objGear, objNode, cmsArmorGear); treArmor.SelectedNode.Nodes.Add(objNode); treArmor.SelectedNode.Expand(); } } // Add any Weapons that come with the Gear. objXmlNode = GlobalOptions.Instance.Clipboard.SelectSingleNode("/character/weapon"); if (objXmlNode != null) { Weapon objWeapon = new Weapon(_objCharacter); objWeapon.Load(objXmlNode, true); _objCharacter.Weapons.Add(objWeapon); objGear.WeaponID = objWeapon.InternalId; _objFunctions.CreateWeaponTreeNode(objWeapon, treWeapons.Nodes[0], cmsWeapon, cmsWeaponAccessory, cmsWeaponAccessoryGear); } UpdateCharacterInfo(); _blnIsDirty = true; UpdateWindowTitle(); return; } } // Weapons Tab. if (tabStreetGearTabs.SelectedTab == tabWeapons) { // Paste Gear into a Weapon Accessory. Gear objGear = new Gear(_objCharacter); XmlNode objXmlNode = GlobalOptions.Instance.Clipboard.SelectSingleNode("/character/gear"); if (objXmlNode != null) { switch (objXmlNode["category"].InnerText) { case "Commlinks": case "Cyberdecks": case "Rigger Command Consoles": Commlink objCommlink = new Commlink(_objCharacter); objCommlink.Load(objXmlNode, true); objGear = objCommlink; break; default: Gear objNewGear = new Gear(_objCharacter); objNewGear.Load(objXmlNode, true); objGear = objNewGear; break; } objGear.Parent = null; // Make sure that a Weapon Accessory is selected and that it allows Gear of the item's Category. WeaponAccessory objAccessory = _objFunctions.FindWeaponAccessory(treWeapons.SelectedNode.Tag.ToString(), _objCharacter.Weapons); bool blnAllowPaste = false; if (objAccessory.AllowGear != null) { foreach (XmlNode objAllowed in objAccessory.AllowGear.SelectNodes("gearcategory")) { if (objAllowed.InnerText == objGear.Category) { blnAllowPaste = true; break; } } } if (blnAllowPaste) { objAccessory.Gear.Add(objGear); TreeNode objNode = new TreeNode(); objNode.Text = objGear.DisplayName; objNode.Tag = objGear.InternalId; objNode.ContextMenuStrip = cmsWeaponAccessoryGear; _objFunctions.BuildGearTree(objGear, objNode, cmsWeaponAccessoryGear); treWeapons.SelectedNode.Nodes.Add(objNode); treWeapons.SelectedNode.Expand(); // Add any Weapons that come with the Gear. objXmlNode = GlobalOptions.Instance.Clipboard.SelectSingleNode("/character/weapon"); if (objXmlNode != null) { Weapon objGearWeapon = new Weapon(_objCharacter); objGearWeapon.Load(objXmlNode, true); _objCharacter.Weapons.Add(objGearWeapon); objGear.WeaponID = objGearWeapon.InternalId; _objFunctions.CreateWeaponTreeNode(objGearWeapon, treWeapons.Nodes[0], cmsWeapon, cmsWeaponAccessory, cmsWeaponAccessoryGear); } UpdateCharacterInfo(); _blnIsDirty = true; UpdateWindowTitle(); return; } } // Paste Weapon. Weapon objWeapon = new Weapon(_objCharacter); objXmlNode = GlobalOptions.Instance.Clipboard.SelectSingleNode("/character/weapon"); if (objXmlNode != null) { objWeapon.Load(objXmlNode, true); objWeapon.VehicleMounted = false; _objCharacter.Weapons.Add(objWeapon); _objFunctions.CreateWeaponTreeNode(objWeapon, treWeapons.Nodes[0], cmsWeapon, cmsWeaponAccessory, cmsWeaponAccessoryGear); UpdateCharacterInfo(); _blnIsDirty = true; UpdateWindowTitle(); return; } } // Gear Tab. if (tabStreetGearTabs.SelectedTab == tabGear) { // Paste Gear. Gear objGear = new Gear(_objCharacter); XmlNode objXmlNode = GlobalOptions.Instance.Clipboard.SelectSingleNode("/character/gear"); if (objXmlNode != null) { switch (objXmlNode["category"].InnerText) { case "Commlinks": case "Cyberdecks": case "Rigger Command Consoles": Commlink objCommlink = new Commlink(_objCharacter); objCommlink.Load(objXmlNode, true); _objCharacter.Gear.Add(objCommlink); objGear = objCommlink; break; default: Gear objNewGear = new Gear(_objCharacter); objNewGear.Load(objXmlNode, true); _objCharacter.Gear.Add(objNewGear); objGear = objNewGear; break; } objGear.Parent = null; TreeNode objNode = new TreeNode(); objNode.Text = objGear.DisplayName; objNode.Tag = objGear.InternalId; if (objGear.Notes != string.Empty) objNode.ForeColor = Color.SaddleBrown; objNode.ToolTipText = CommonFunctions.WordWrap(objGear.Notes, 100); _objFunctions.BuildGearTree(objGear, objNode, cmsGear); objNode.ContextMenuStrip = cmsGear; TreeNode objParent = new TreeNode(); if (objGear.Location == "") objParent = treGear.Nodes[0]; else { foreach (TreeNode objFind in treGear.Nodes) { if (objFind.Text == objGear.Location) { objParent = objFind; break; } } } objParent.Nodes.Add(objNode); objParent.Expand(); // Add any Weapons that come with the Gear. objXmlNode = GlobalOptions.Instance.Clipboard.SelectSingleNode("/character/weapon"); if (objXmlNode != null) { Weapon objWeapon = new Weapon(_objCharacter); objWeapon.Load(objXmlNode, true); _objCharacter.Weapons.Add(objWeapon); objGear.WeaponID = objWeapon.InternalId; _objFunctions.CreateWeaponTreeNode(objWeapon, treWeapons.Nodes[0], cmsWeapon, cmsWeaponAccessory, cmsWeaponAccessoryGear); } UpdateCharacterInfo(); _blnIsDirty = true; UpdateWindowTitle(); return; } } } // Vehicles Tab. if (tabCharacterTabs.SelectedTab == tabVehicles) { // Paste Vehicle. Vehicle objVehicle = new Vehicle(_objCharacter); XmlNode objXmlNode = GlobalOptions.Instance.Clipboard.SelectSingleNode("/character/vehicle"); if (objXmlNode != null) { objVehicle.Load(objXmlNode, true); _objCharacter.Vehicles.Add(objVehicle); _objFunctions.CreateVehicleTreeNode(objVehicle, treVehicles, cmsVehicle, cmsVehicleLocation, cmsVehicleWeapon, cmsVehicleWeaponAccessory, cmsVehicleWeaponAccessoryGear, cmsVehicleGear); UpdateCharacterInfo(); _blnIsDirty = true; UpdateWindowTitle(); return; } // Paste Gear. Gear objGear = new Gear(_objCharacter); objXmlNode = GlobalOptions.Instance.Clipboard.SelectSingleNode("/character/gear"); if (objXmlNode != null) { switch (objXmlNode["category"].InnerText) { case "Commlinks": case "Cyberdecks": case "Rigger Command Consoles": Commlink objCommlink = new Commlink(_objCharacter); objCommlink.Load(objXmlNode, true); objGear = objCommlink; break; default: Gear objNewGear = new Gear(_objCharacter); objNewGear.Load(objXmlNode, true); objGear = objNewGear; break; } // Paste the Gear into a Vehicle. foreach (Vehicle objCharacterVehicle in _objCharacter.Vehicles) { if (objCharacterVehicle.InternalId == treVehicles.SelectedNode.Tag.ToString()) { objCharacterVehicle.Gear.Add(objGear); TreeNode objNode = new TreeNode(); objNode.Text = objGear.DisplayName; objNode.Tag = objGear.InternalId; objNode.ContextMenuStrip = cmsVehicleGear; objVehicle = objCharacterVehicle; _objFunctions.BuildGearTree(objGear, objNode, cmsVehicleGear); treVehicles.SelectedNode.Nodes.Add(objNode); treVehicles.SelectedNode.Expand(); } } // Paste the Gear into a Vehicle's Gear. Vehicle objTempVehicle = objVehicle; Gear objVehicleGear = _objFunctions.FindVehicleGear(treVehicles.SelectedNode.Tag.ToString(), _objCharacter.Vehicles, out objVehicle); if (objVehicle == null) objVehicle = objTempVehicle; if (objVehicleGear != null) { objVehicleGear.Children.Add(objGear); objGear.Parent = objVehicleGear; TreeNode objNode = new TreeNode(); objNode.Text = objGear.DisplayName; objNode.Tag = objGear.InternalId; objNode.ContextMenuStrip = cmsVehicleGear; _objFunctions.BuildGearTree(objGear, objNode, cmsVehicleGear); treVehicles.SelectedNode.Nodes.Add(objNode); treVehicles.SelectedNode.Expand(); } UpdateCharacterInfo(); _blnIsDirty = true; UpdateWindowTitle(); return; } // Paste Weapon. Weapon objWeapon = new Weapon(_objCharacter); objXmlNode = GlobalOptions.Instance.Clipboard.SelectSingleNode("/character/weapon"); if (objXmlNode != null) { objWeapon.Load(objXmlNode, true); objWeapon.VehicleMounted = true; try { // Weapons can only be added to Vehicle Mods that support them (Weapon Mounts and Mechanical Arms). VehicleMod objMod = new VehicleMod(_objCharacter); foreach (Vehicle objCharacterVehicle in _objCharacter.Vehicles) { foreach (VehicleMod objVehicleMod in objCharacterVehicle.Mods) { if (objVehicleMod.InternalId == treVehicles.SelectedNode.Tag.ToString()) { if (objVehicleMod.Name.StartsWith("Weapon Mount") || objVehicleMod.Name.StartsWith("Heavy Weapon Mount") || objVehicleMod.Name.StartsWith("Mechanical Arm") || objVehicleMod.WeaponMountCategories != "") { objVehicleMod.Weapons.Add(objWeapon); _objFunctions.CreateWeaponTreeNode(objWeapon, treVehicles.SelectedNode, cmsVehicleWeapon, cmsVehicleWeaponAccessory, null); UpdateCharacterInfo(); _blnIsDirty = true; UpdateWindowTitle(); return; } } } } } catch { } } } }
/// <summary> /// Load the CharacterAttribute from the XmlNode. /// </summary> /// <param name="objNode">XmlNode to load.</param> public void Load(XmlNode objNode, bool blnCopy = false) { _guiID = Guid.Parse(objNode["guid"].InnerText); _strName = objNode["name"].InnerText; _strCategory = objNode["category"].InnerText; _strA = objNode["armor"].InnerText; _strAvail = objNode["avail"].InnerText; _strCost = objNode["cost"].InnerText; _strSource = objNode["source"].InnerText; objNode.TryGetField("armoroverride", out _strO); objNode.TryGetField("armorcapacity", out _strArmorCapacity); objNode.TryGetField("rating", out _intRating); objNode.TryGetField("maxrating", out _intMaxRating); objNode.TryGetField("page", out _strPage); objNode.TryGetField("armorname", out _strArmorName); objNode.TryGetField("equipped", out _blnEquipped); objNode.TryGetField("extra", out _strExtra); objNode.TryGetField("damage", out _intDamage); objNode.TryGetField("location", out _strLocation); objNode.TryGetField("notes", out _strNotes); objNode.TryGetField("discountedcost", out _blnDiscountCost); try { _nodBonus = objNode["bonus"]; } catch { } if (objNode.InnerXml.Contains("armormods")) { XmlNodeList nodMods = objNode.SelectNodes("armormods/armormod"); foreach (XmlNode nodMod in nodMods) { ArmorMod objMod = new ArmorMod(_objCharacter); objMod.Load(nodMod, blnCopy); objMod.Parent = this; _lstArmorMods.Add(objMod); } } if (objNode.InnerXml.Contains("gears")) { XmlNodeList nodGears = objNode.SelectNodes("gears/gear"); foreach (XmlNode nodGear in nodGears) { switch (nodGear["category"].InnerText) { case "Commlinks": case "Commlink Accessories": case "Cyberdecks": case "Rigger Command Consoles": Commlink objCommlink = new Commlink(_objCharacter); objCommlink.Load(nodGear, blnCopy); _lstGear.Add(objCommlink); break; default: Gear objGear = new Gear(_objCharacter); objGear.Load(nodGear, blnCopy); _lstGear.Add(objGear); break; } } } if (GlobalOptions.Instance.Language != "en-us") { XmlDocument objXmlArmorDocument = XmlManager.Instance.Load("armor.xml"); XmlNode objArmorNode = objXmlArmorDocument.SelectSingleNode("/chummer/armors/armor[name = \"" + _strName + "\"]"); if (objArmorNode != null) { if (objArmorNode["translate"] != null) _strAltName = objArmorNode["translate"].InnerText; if (objArmorNode["altpage"] != null) _strAltPage = objArmorNode["altpage"].InnerText; } objArmorNode = objXmlArmorDocument.SelectSingleNode("/chummer/categories/category[. = \"" + _strCategory + "\"]"); if (objArmorNode != null) { if (objArmorNode.Attributes["translate"] != null) _strAltCategory = objArmorNode.Attributes["translate"].InnerText; } } if (blnCopy) { _guiID = Guid.NewGuid(); _strLocation = string.Empty; } }
/// <summary> /// Load the Gear from the XmlNode. /// </summary> /// <param name="objNode">XmlNode to load.</param> public void Load(XmlNode objNode, bool blnCopy = false) { _guiID = Guid.Parse(objNode["guid"].InnerText); _strName = objNode["name"].InnerText; _strCategory = objNode["category"].InnerText; objNode.TryGetField("matrixcmfilled", out _intMatrixCMFilled); objNode.TryGetField("capacity", out _strCapacity); objNode.TryGetField("armorcapacity", out _strArmorCapacity); objNode.TryGetField("minrating", out _intMinRating); _intMaxRating = Convert.ToInt32(objNode["maxrating"].InnerText); _intRating = Convert.ToInt32(objNode["rating"].InnerText); _intQty = Convert.ToInt32(objNode["qty"].InnerText); _strAvail = objNode["avail"].InnerText; try { _strAvail3 = objNode["avail3"].InnerText; } catch { } try { _strAvail6 = objNode["avail6"].InnerText; } catch { } try { _strAvail10 = objNode["avail10"].InnerText; } catch { } try { _intCostFor = Convert.ToInt32(objNode["costfor"].InnerText); } catch { } _strCost = objNode["cost"].InnerText; try { _strCost3 = objNode["cost3"].InnerText; } catch { } try { _strCost6 = objNode["cost6"].InnerText; } catch { } try { _strCost10 = objNode["cost10"].InnerText; } catch { } if (objNode["extra"].InnerText == "Hold-Outs") objNode["extra"].InnerText = "Holdouts"; _strExtra = objNode["extra"].InnerText; try { _blnBonded = Convert.ToBoolean(objNode["bonded"].InnerText); } catch { } try { _blnEquipped = Convert.ToBoolean(objNode["equipped"].InnerText); } catch { } try { _blnHomeNode = Convert.ToBoolean(objNode["homenode"].InnerText); } catch { } _nodBonus = objNode["bonus"]; try { _nodWeaponBonus = objNode["weaponbonus"]; } catch { } _strSource = objNode["source"].InnerText; try { _strPage = objNode["page"].InnerText; } catch { } try { _intDeviceRating = Convert.ToInt32(objNode["devicerating"].InnerText); } catch { } try { _guiWeaponID = Guid.Parse(objNode["weaponguid"].InnerText); } catch { } try { _intChildCostMultiplier = Convert.ToInt32(objNode["childcostmultiplier"].InnerText); } catch { } try { _intChildAvailModifier = Convert.ToInt32(objNode["childavailmodifier"].InnerText); } catch { } try { _strGearName = objNode["gearname"].InnerText; } catch { } try { _blnIncludedInParent = Convert.ToBoolean(objNode["includedinparent"].InnerText); } catch { } if (objNode.InnerXml.Contains("<gear>")) { XmlNodeList nodChildren = objNode.SelectNodes("children/gear"); foreach (XmlNode nodChild in nodChildren) { switch (nodChild["category"].InnerText) { case "Commlinks": case "Commlink Accessories": case "Cyberdecks": case "Rigger Command Consoles": Commlink objCommlink = new Commlink(_objCharacter); objCommlink.Load(nodChild, blnCopy); objCommlink.Parent = this; _objChildren.Add(objCommlink); break; default: Gear objGear = new Gear(_objCharacter); objGear.Load(nodChild, blnCopy); objGear.Parent = this; _objChildren.Add(objGear); break; } } } try { _strLocation = objNode["location"].InnerText; } catch { } try { _strNotes = objNode["notes"].InnerText; } catch { } try { _blnDiscountCost = Convert.ToBoolean(objNode["discountedcost"].InnerText); } catch { } if (GlobalOptions.Instance.Language != "en-us") { XmlDocument objXmlDocument = XmlManager.Instance.Load("gear.xml"); XmlNode objGearNode = objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"" + _strName + "\"]"); if (objGearNode != null) { if (objGearNode["translate"] != null) _strAltName = objGearNode["translate"].InnerText; if (objGearNode["altpage"] != null) _strAltPage = objGearNode["altpage"].InnerText; } if (_strAltName.StartsWith("Stacked Focus")) _strAltName = _strAltName.Replace("Stacked Focus", LanguageManager.Instance.GetString("String_StackedFocus")); objGearNode = objXmlDocument.SelectSingleNode("/chummer/categories/category[. = \"" + _strCategory + "\"]"); if (objGearNode != null) { if (objGearNode.Attributes["translate"] != null) _strAltCategory = objGearNode.Attributes["translate"].InnerText; } if (_strAltCategory.StartsWith("Stacked Focus")) _strAltCategory = _strAltCategory.Replace("Stacked Focus", LanguageManager.Instance.GetString("String_StackedFocus")); } if (blnCopy) { _guiID = Guid.NewGuid(); _strLocation = string.Empty; _blnHomeNode = false; } }