Example #1
0
 public void Awake()
 {
     tileManager = (TileManager)target;
     resourceManager = tileManager.GetComponent<ResourceManager>();
     improvementManager = tileManager.GetComponent<ImprovementManager>();
     if (tileManager.tiles != null)
     {
         foldoutOpen = new bool[tileManager.tiles.Count];
     }
 }
Example #2
0
        /// Create a Commlink from an XmlNode and return the TreeNodes for it.
        /// <param name="objXmlGear">XmlNode to create the object from.</param>
        /// <param name="objCharacter">Character the Gear is being added to.</param>
        /// <param name="objNode">TreeNode to populate a TreeView.</param>
        /// <param name="intRating">Gear Rating.</param>
        /// <param name="blnAddImprovements">Whether or not Improvements should be added to the character.</param>
        /// <param name="blnCreateChildren">Whether or not child Gear should be created.</param>
        public void Create(XmlNode objXmlGear, Character objCharacter, TreeNode objNode, int intRating, bool blnAddImprovements = true, bool blnCreateChildren = true)
        {
            _strName = objXmlGear["name"].InnerText;
            _strCategory = objXmlGear["category"].InnerText;
            _strAvail = objXmlGear["avail"].InnerText;
            objXmlGear.TryGetField("cost", out _strCost);
            objXmlGear.TryGetField("cost3", out _strCost3, "");
            objXmlGear.TryGetField("cost6", out _strCost6, "");
            objXmlGear.TryGetField("cost10", out _strCost10, "");
            objXmlGear.TryGetField("armorcapacity", out _strArmorCapacity);
            _nodBonus = objXmlGear["bonus"];
            _intMaxRating = Convert.ToInt32(objXmlGear["rating"].InnerText);
            _intRating = intRating;
            _strSource = objXmlGear["source"].InnerText;
            _strPage = objXmlGear["page"].InnerText;
            _intDeviceRating = Convert.ToInt32(objXmlGear["devicerating"].InnerText);

            _intAttack = Convert.ToInt32(objXmlGear["attack"].InnerText);
            _intSleaze= Convert.ToInt32(objXmlGear["sleaze"].InnerText);
            _intDataProcessing = Convert.ToInt32(objXmlGear["dataprocessing"].InnerText);
            _intFirewall = Convert.ToInt32(objXmlGear["firewall"].InnerText);

            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"));
            }

            string strSource = _guiID.ToString();

            objNode.Text = DisplayNameShort;
            objNode.Tag = _guiID.ToString();

            // If the item grants a bonus, pass the information to the Improvement Manager.
            if (objXmlGear["bonus"] != null)
            {
                ImprovementManager objImprovementManager;
                if (blnAddImprovements)
                    objImprovementManager = new ImprovementManager(objCharacter);
                else
                    objImprovementManager = new ImprovementManager(null);

                if (!objImprovementManager.CreateImprovements(Improvement.ImprovementSource.Gear, strSource, objXmlGear["bonus"], false, 1, DisplayNameShort))
                {
                    _guiID = Guid.Empty;
                    return;
                }
                if (objImprovementManager.SelectedValue != "")
                {
                    _strExtra = objImprovementManager.SelectedValue;
                    objNode.Text += " (" + objImprovementManager.SelectedValue + ")";
                }
            }

            // Check to see if there are any child elements.
            if (objXmlGear.InnerXml.Contains("<gears>") && blnCreateChildren)
            {
                // Create Gear using whatever information we're given.
                foreach (XmlNode objXmlChild in objXmlGear.SelectNodes("gears/gear"))
                {
                    Gear objChild = new Gear(_objCharacter);
                    TreeNode objChildNode = new TreeNode();
                    objChild.Name = objXmlChild["name"].InnerText;
                    objChild.Category = objXmlChild["category"].InnerText;
                    objChild.Avail = "0";
                    objChild.Cost = "0";
                    objChild.Source = _strSource;
                    objChild.Page = _strPage;
                    objChild.Parent = this;
                    _objChildren.Add(objChild);

                    objChildNode.Text = objChild.DisplayName;
                    objChildNode.Tag = objChild.InternalId;
                    objNode.Nodes.Add(objChildNode);
                    objNode.Expand();
                }

                XmlDocument objXmlGearDocument = XmlManager.Instance.Load("gear.xml");
                CreateChildren(objXmlGearDocument, objXmlGear, this, objNode, objCharacter, blnCreateChildren);
            }

            // Add the Copy Protection and Registration plugins to the Matrix program. This does not apply if Unwired is not enabled, Hacked is selected, or this is a Suite being added (individual programs will add it to themselves).
            if (blnCreateChildren)
            {
                if ((_strCategory == "Matrix Programs" || _strCategory == "Skillsofts" || _strCategory == "Autosofts" || _strCategory == "Autosofts, Agent" || _strCategory == "Autosofts, Drone") && objCharacter.Options.BookEnabled("UN") && !_strName.StartsWith("Suite:"))
                {
                    XmlDocument objXmlDocument = XmlManager.Instance.Load("gear.xml");

                    if (_objCharacter.Options.AutomaticCopyProtection)
                    {
                        Gear objPlugin1 = new Gear(_objCharacter);
                        TreeNode objPlugin1Node = new TreeNode();
                        objPlugin1.Create(objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"Copy Protection\"]"), objCharacter, objPlugin1Node, _intRating, null, null);
                        if (_intRating == 0)
                            objPlugin1.Rating = 1;
                        objPlugin1.Avail = "0";
                        objPlugin1.Cost = "0";
                        objPlugin1.Cost3 = "0";
                        objPlugin1.Cost6 = "0";
                        objPlugin1.Cost10 = "0";
                        objPlugin1.Capacity = "[0]";
                        objPlugin1.Parent = this;
                        _objChildren.Add(objPlugin1);
                        objNode.Nodes.Add(objPlugin1Node);
                    }

                    if (_objCharacter.Options.AutomaticRegistration)
                    {
                        Gear objPlugin2 = new Gear(_objCharacter);
                        TreeNode objPlugin2Node = new TreeNode();
                        objPlugin2.Create(objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"Registration\"]"), objCharacter, objPlugin2Node, 0, null, null);
                        objPlugin2.Avail = "0";
                        objPlugin2.Cost = "0";
                        objPlugin2.Cost3 = "0";
                        objPlugin2.Cost6 = "0";
                        objPlugin2.Cost10 = "0";
                        objPlugin2.Capacity = "[0]";
                        objPlugin2.Parent = this;
                        _objChildren.Add(objPlugin2);
                        objNode.Nodes.Add(objPlugin2Node);
                        objNode.Expand();
                    }

                    if ((objCharacter.Metatype == "A.I." || objCharacter.MetatypeCategory == "Technocritters" || objCharacter.MetatypeCategory == "Protosapients"))
                    {
                        Gear objPlugin3 = new Gear(_objCharacter);
                        TreeNode objPlugin3Node = new TreeNode();
                        objPlugin3.Create(objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"Ergonomic\"]"), objCharacter, objPlugin3Node, 0, null, null);
                        objPlugin3.Avail = "0";
                        objPlugin3.Cost = "0";
                        objPlugin3.Cost3 = "0";
                        objPlugin3.Cost6 = "0";
                        objPlugin3.Cost10 = "0";
                        objPlugin3.Capacity = "[0]";
                        objPlugin3.Parent = this;
                        _objChildren.Add(objPlugin3);
                        objNode.Nodes.Add(objPlugin3Node);

                        Gear objPlugin4 = new Gear(_objCharacter);
                        TreeNode objPlugin4Node = new TreeNode();
                        objPlugin4.Create(objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"Optimization\" and category = \"Program Options\"]"), objCharacter, objPlugin4Node, _intRating, null, null);
                        if (_intRating == 0)
                            objPlugin4.Rating = 1;
                        objPlugin4.Avail = "0";
                        objPlugin4.Cost = "0";
                        objPlugin4.Cost3 = "0";
                        objPlugin4.Cost6 = "0";
                        objPlugin4.Cost10 = "0";
                        objPlugin4.Capacity = "[0]";
                        objPlugin4.Parent = this;
                        _objChildren.Add(objPlugin4);
                        objNode.Nodes.Add(objPlugin4Node);
                        objNode.Expand();
                    }
                }
            }
        }
Example #3
0
        /// Create a Armor Modification from an XmlNode and return the TreeNodes for it.
        /// <param name="objXmlArmorNode">XmlNode to create the object from.</param>
        /// <param name="objNode">TreeNode to populate a TreeView.</param>
        /// <param name="intRating">Rating of the selected ArmorMod.</param>
        /// <param name="objWeapons">List of Weapons that are created by the Armor.</param>
        /// <param name="objWeaponNodes">List of Weapon Nodes that are created by the Armor.</param>
        /// <param name="blnSkipCost">Whether or not creating the Armor should skip the Variable price dialogue (should only be used by frmSelectArmor).</param>
        public void Create(XmlNode objXmlArmorNode, TreeNode objNode, int intRating, List<Weapon> objWeapons, List<TreeNode> objWeaponNodes, bool blnSkipCost = false)
        {
            _strName = objXmlArmorNode["name"].InnerText;
            _strCategory = objXmlArmorNode["category"].InnerText;
            _strArmorCapacity = objXmlArmorNode["armorcapacity"].InnerText;
            _intA = Convert.ToInt32(objXmlArmorNode["armor"].InnerText);
            _intRating = intRating;
            _intMaxRating = Convert.ToInt32(objXmlArmorNode["maxrating"].InnerText);
            _strAvail = objXmlArmorNode["avail"].InnerText;
            _strCost = objXmlArmorNode["cost"].InnerText;
            _strSource = objXmlArmorNode["source"].InnerText;
            _strPage = objXmlArmorNode["page"].InnerText;
            _nodBonus = objXmlArmorNode["bonus"];

            if (GlobalOptions.Instance.Language != "en-us")
            {
                XmlDocument objXmlDocument = XmlManager.Instance.Load("armor.xml");
                XmlNode objArmorNode = objXmlDocument.SelectSingleNode("/chummer/mods/mod[name = \"" + _strName + "\"]");
                if (objArmorNode != null)
                {
                    if (objArmorNode["translate"] != null)
                        _strAltName = objArmorNode["translate"].InnerText;
                    if (objArmorNode["altpage"] != null)
                        _strAltPage = objArmorNode["altpage"].InnerText;
                }

                objArmorNode = objXmlDocument.SelectSingleNode("/chummer/categories/category[. = \"" + _strCategory + "\"]");
                if (objArmorNode != null)
                {
                    if (objArmorNode.Attributes["translate"] != null)
                        _strAltCategory = objArmorNode.Attributes["translate"].InnerText;
                }
            }

            if (objXmlArmorNode["bonus"] != null && !blnSkipCost)
            {
                ImprovementManager objImprovementManager = new ImprovementManager(_objCharacter);
                if (!objImprovementManager.CreateImprovements(Improvement.ImprovementSource.ArmorMod, _guiID.ToString(), objXmlArmorNode["bonus"], false, intRating, DisplayNameShort))
                {
                    _guiID = Guid.Empty;
                    return;
                }
                if (objImprovementManager.SelectedValue != "")
                {
                    _strExtra = objImprovementManager.SelectedValue;
                    objNode.Text += " (" + objImprovementManager.SelectedValue + ")";
                }
            }

            // Add Weapons if applicable.
            if (objXmlArmorNode.InnerXml.Contains("<addweapon>"))
            {
                XmlDocument objXmlWeaponDocument = XmlManager.Instance.Load("weapons.xml");

                // More than one Weapon can be added, so loop through all occurrences.
                foreach (XmlNode objXmlAddWeapon in objXmlArmorNode.SelectNodes("addweapon"))
                {
                    XmlNode objXmlWeapon = objXmlWeaponDocument.SelectSingleNode("/chummer/weapons/weapon[name = \"" + objXmlAddWeapon.InnerText + "\" and starts-with(category, \"Cyberware\")]");

                    TreeNode objGearWeaponNode = new TreeNode();
                    Weapon objGearWeapon = new Weapon(_objCharacter);
                    objGearWeapon.Create(objXmlWeapon, _objCharacter, objGearWeaponNode, null, null);
                    objGearWeaponNode.ForeColor = SystemColors.GrayText;
                    objWeaponNodes.Add(objGearWeaponNode);
                    objWeapons.Add(objGearWeapon);

                    _guiWeaponID = Guid.Parse(objGearWeapon.InternalId);
                }
            }

            objNode.Text = DisplayName;
            objNode.Tag = _guiID.ToString();
        }
Example #4
0
        /// Create a Cyberware from an XmlNode and return the TreeNodes for it.
        /// <param name="objXmlArmorNode">XmlNode to create the object from.</param>
        /// <param name="objNode">TreeNode to populate a TreeView.</param>
        /// <param name="cmsArmorMod">ContextMenuStrip to apply to Armor Mode TreeNodes.</param>
        /// <param name="blnSkipCost">Whether or not creating the Armor should skip the Variable price dialogue (should only be used by frmSelectArmor).</param>
        /// <param name="blnCreateChildren">Whether or not child items should be created.</param>
        public void Create(XmlNode objXmlArmorNode, TreeNode objNode, ContextMenuStrip cmsArmorMod, int intRating, bool blnSkipCost = false, bool blnCreateChildren = true)
        {
            _strName = objXmlArmorNode["name"].InnerText;
            _strCategory = objXmlArmorNode["category"].InnerText;
            _strA = objXmlArmorNode["armor"].InnerText;
            if (objXmlArmorNode["armoroverride"] != null)
                _strO = objXmlArmorNode["armoroverride"].InnerText;
            _intRating = intRating;
            if (objXmlArmorNode["rating"] != null)
                _intMaxRating = Convert.ToInt32(objXmlArmorNode["rating"].InnerText);
            _strArmorCapacity = objXmlArmorNode["armorcapacity"].InnerText;
            _strAvail = objXmlArmorNode["avail"].InnerText;
            _strSource = objXmlArmorNode["source"].InnerText;
            _strPage = objXmlArmorNode["page"].InnerText;
            _nodBonus = objXmlArmorNode["bonus"];

            if (GlobalOptions.Instance.Language != "en-us")
            {
                XmlDocument objXmlDocument = XmlManager.Instance.Load("armor.xml");
                XmlNode objArmorNode = objXmlDocument.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 = objXmlDocument.SelectSingleNode("/chummer/categories/category[. = \"" + _strCategory + "\"]");
                if (objNode != null)
                {
                    if (objArmorNode.Attributes["translate"] != null)
                        _strAltCategory = objArmorNode.Attributes["translate"].InnerText;
                }
            }

            // Check for a Variable Cost.
            if (objXmlArmorNode["cost"].InnerText.StartsWith("Variable"))
            {
                if (blnSkipCost)
                    _strCost = "0";
                else
                {
                    int intMin = 0;
                    int intMax = 0;
                    string strCost = objXmlArmorNode["cost"].InnerText.Replace("Variable(", string.Empty).Replace(")", string.Empty);
                    if (strCost.Contains("-"))
                    {
                        string[] strValues = strCost.Split('-');
                        intMin = Convert.ToInt32(strValues[0]);
                        intMax = Convert.ToInt32(strValues[1]);
                    }
                    else
                        intMin = Convert.ToInt32(strCost.Replace("+", string.Empty));

                    if (intMin != 0 || intMax != 0)
                    {
                        frmSelectNumber frmPickNumber = new frmSelectNumber();
                        if (intMax == 0)
                            intMax = 1000000;
                        frmPickNumber.Minimum = intMin;
                        frmPickNumber.Maximum = intMax;
                        frmPickNumber.Description = LanguageManager.Instance.GetString("String_SelectVariableCost").Replace("{0}", DisplayNameShort);
                        frmPickNumber.AllowCancel = false;
                        frmPickNumber.ShowDialog();
                        _strCost = frmPickNumber.SelectedValue.ToString();
                    }
                }
            }
            else if (objXmlArmorNode["cost"].InnerText.StartsWith("Rating"))
            {
                // If the cost is determined by the Rating, evaluate the expression.
                XmlDocument objXmlDocument = new XmlDocument();
                XPathNavigator nav = objXmlDocument.CreateNavigator();

                string strCost = "";
                string strCostExpression = _strCost;

                strCost = strCostExpression.Replace("Rating", _intRating.ToString());
                XPathExpression xprCost = nav.Compile(strCost);
                _strCost = nav.Evaluate(xprCost).ToString();
            }
            else
            {
                _strCost = objXmlArmorNode["cost"].InnerText;
            }

            if (objXmlArmorNode["bonus"] != null && !blnSkipCost)
            {
                ImprovementManager objImprovementManager = new ImprovementManager(_objCharacter);
                if (!objImprovementManager.CreateImprovements(Improvement.ImprovementSource.Armor, _guiID.ToString(), objXmlArmorNode["bonus"], false, 1, DisplayNameShort))
                {
                    _guiID = Guid.Empty;
                    return;
                }
                if (objImprovementManager.SelectedValue != "")
                {
                    _strExtra = objImprovementManager.SelectedValue;
                    objNode.Text += " (" + objImprovementManager.SelectedValue + ")";
                }
            }

            // Add any Armor Mods that come with the Armor.
            if (objXmlArmorNode["mods"] != null && blnCreateChildren)
            {
                XmlDocument objXmlArmorDocument = XmlManager.Instance.Load("armor.xml");

                foreach (XmlNode objXmlArmorMod in objXmlArmorNode.SelectNodes("mods/name"))
                {
                    intRating = 0;
                    string strForceValue = "";
                    if (objXmlArmorMod.Attributes["rating"] != null)
                        intRating = Convert.ToInt32(objXmlArmorMod.Attributes["rating"].InnerText);
                    if (objXmlArmorMod.Attributes["select"] != null)
                        strForceValue = objXmlArmorMod.Attributes["select"].ToString();

                    XmlNode objXmlMod = objXmlArmorDocument.SelectSingleNode("/chummer/mods/mod[name = \"" + objXmlArmorMod.InnerText + "\"]");
                    if (objXmlMod != null)
                    {
                        ArmorMod objMod = new ArmorMod(_objCharacter);
                        List<Weapon> lstWeapons = new List<Weapon>();
                        List<TreeNode> lstWeaponNodes = new List<TreeNode>();

                        TreeNode objModNode = new TreeNode();

                        objMod.Create(objXmlMod, objModNode, intRating, lstWeapons, lstWeaponNodes, blnSkipCost);
                        objMod.Parent = this;
                        objMod.IncludedInArmor = true;
                        objMod.ArmorCapacity = "[0]";
                        objMod.Cost = "0";
                        objMod.MaximumRating = objMod.Rating;
                        _lstArmorMods.Add(objMod);

                        objModNode.ContextMenuStrip = cmsArmorMod;
                        objNode.Nodes.Add(objModNode);
                        objNode.Expand();
                    }
                    else
                    {
                        ArmorMod objMod = new ArmorMod(_objCharacter);
                        List<Weapon> lstWeapons = new List<Weapon>();
                        List<TreeNode> lstWeaponNodes = new List<TreeNode>();

                        TreeNode objModNode = new TreeNode();

                        objMod.Name = objXmlArmorNode["name"].InnerText;
                        objMod.Category = "Features";
                        objMod.Avail = "0";
                        objMod.Source = _strSource;
                        objMod.Page = _strPage;
                        objMod.Parent = this;
                        objMod.IncludedInArmor = true;
                        objMod.ArmorCapacity = "[0]";
                        objMod.Cost = "0";
                        objMod.Rating = 0;
                        objMod.MaximumRating = objMod.Rating;
                        _lstArmorMods.Add(objMod);

                        objModNode.ContextMenuStrip = cmsArmorMod;
                        objNode.Nodes.Add(objModNode);
                        objNode.Expand();
                    }
                }
            }

            // Add any Gear that comes with the Armor.
            if (objXmlArmorNode["gears"] != null && blnCreateChildren)
            {
                XmlDocument objXmlGearDocument = XmlManager.Instance.Load("gear.xml");
                foreach (XmlNode objXmlArmorGear in objXmlArmorNode.SelectNodes("gears/usegear"))
                {
                    intRating = 0;
                    string strForceValue = "";
                    if (objXmlArmorGear.Attributes["rating"] != null)
                        intRating = Convert.ToInt32(objXmlArmorGear.Attributes["rating"].InnerText);
                    if (objXmlArmorGear.Attributes["select"] != null)
                        strForceValue = objXmlArmorGear.Attributes["select"].InnerText;

                    XmlNode objXmlGear = objXmlGearDocument.SelectSingleNode("/chummer/gears/gear[name = \"" + objXmlArmorGear.InnerText + "\"]");
                    Gear objGear = new Gear(_objCharacter);

                    TreeNode objGearNode = new TreeNode();
                    List<Weapon> lstWeapons = new List<Weapon>();
                    List<TreeNode> lstWeaponNodes = new List<TreeNode>();

                    objGear.Create(objXmlGear, _objCharacter, objGearNode, intRating, lstWeapons, lstWeaponNodes, strForceValue, false, false, !blnSkipCost);
                    objGear.Capacity = "[0]";
                    objGear.ArmorCapacity = "[0]";
                    objGear.Cost = "0";
                    objGear.MaxRating = objGear.Rating;
                    objGear.MinRating = objGear.Rating;
                    objGear.IncludedInParent = true;
                    _lstGear.Add(objGear);

                    objNode.Nodes.Add(objGearNode);
                    objNode.Expand();
                }
            }

            objNode.Text = DisplayName;
            objNode.Tag = _guiID.ToString();
        }
Example #5
0
        /// Create a Gear from an XmlNode and return the TreeNodes for it.
        /// <param name="objXmlGear">XmlNode to create the object from.</param>
        /// <param name="objCharacter">Character the Gear is being added to.</param>
        /// <param name="objNode">TreeNode to populate a TreeView.</param>
        /// <param name="intRating">Selected Rating for the Gear.</param>
        /// <param name="objWeapons">List of Weapons that should be added to the character.</param>
        /// <param name="objWeaponNodes">List of TreeNodes to represent the added Weapons</param>
        /// <param name="strForceValue">Value to forcefully select for any ImprovementManager prompts.</param>
        /// <param name="blnHacked">Whether or not a Matrix Program has been hacked (removing the Copy Protection and Registration plugins).</param>
        /// <param name="blnInherent">Whether or not a Program is Inherent to an A.I.</param>
        /// <param name="blnAddImprovements">Whether or not Improvements should be added to the character.</param>
        /// <param name="blnCreateChildren">Whether or not child Gear should be created.</param>
        /// <param name="blnAerodynamic">Whether or not Weapons should be created as Aerodynamic.</param>
        public void Create(XmlNode objXmlGear, Character objCharacter, TreeNode objNode, int intRating, List<Weapon> objWeapons, List<TreeNode> objWeaponNodes, string strForceValue = "", bool blnHacked = false, bool blnInherent = false, bool blnAddImprovements = true, bool blnCreateChildren = true, bool blnAerodynamic = false)
        {
            _strName = objXmlGear["name"].InnerText;
            _strCategory = objXmlGear["category"].InnerText;
            _strAvail = objXmlGear["avail"].InnerText;
            try
            {
                _strAvail3 = objXmlGear["avail3"].InnerText;
            }
            catch
            {
            }
            try
            {
                _strAvail6 = objXmlGear["avail6"].InnerText;
            }
            catch
            {
            }
            try
            {
                _strAvail10 = objXmlGear["avail10"].InnerText;
            }
            catch
            {
            }
            try
            {
                _strCapacity = objXmlGear["capacity"].InnerText;
            }
            catch
            {
            }
            try
            {
                _strArmorCapacity = objXmlGear["armorcapacity"].InnerText;
            }
            catch
            {
            }
            try
            {
                _intCostFor = Convert.ToInt32(objXmlGear["costfor"].InnerText);
                _intQty = Convert.ToInt32(objXmlGear["costfor"].InnerText);
            }
            catch
            {
            }
            try
            {
                _strCost = objXmlGear["cost"].InnerText;
            }
            catch
            {
            }
            try
            {
                _strCost3 = objXmlGear["cost3"].InnerText;
            }
            catch
            {
            }
            try
            {
                _strCost6 = objXmlGear["cost6"].InnerText;
            }
            catch
            {
            }
            try
            {
                _strCost10 = objXmlGear["cost10"].InnerText;
            }
            catch
            {
            }
            _nodBonus = objXmlGear["bonus"];
            _intMaxRating = Convert.ToInt32(objXmlGear["rating"].InnerText);
            try
            {
                _intMinRating = Convert.ToInt32(objXmlGear["minrating"].InnerText);
            }
            catch
            {
            }
            _intRating = intRating;
            _strSource = objXmlGear["source"].InnerText;
            _strPage = objXmlGear["page"].InnerText;

            try
            {
                _intChildCostMultiplier = Convert.ToInt32(objXmlGear["childcostmultiplier"].InnerText);
            }
            catch
            {
            }
            try
            {
                _intChildAvailModifier = Convert.ToInt32(objXmlGear["childavailmodifier"].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"));
            }

            // Check for a Custom name
            if (objXmlGear["name"].InnerText == "Custom Item")
            {
                frmSelectText frmPickText = new frmSelectText();
                frmPickText.Description = LanguageManager.Instance.GetString("String_CustomItem_SelectText");
                frmPickText.ShowDialog();

                // Make sure the dialogue window was not canceled.
                if (frmPickText.DialogResult != DialogResult.Cancel)
                {
                    _strName = frmPickText.SelectedValue;
                }
            }

            // Check for a Variable Cost.
            if (objXmlGear["cost"] != null)
            {
                if (objXmlGear["cost"].InnerText.StartsWith("Variable"))
                {
                    int intMin = 0;
                    int intMax = 0;
                    string strCost = objXmlGear["cost"].InnerText.Replace("Variable(", string.Empty).Replace(")", string.Empty);
                    if (strCost.Contains("-"))
                    {
                        string[] strValues = strCost.Split('-');
                        intMin = Convert.ToInt32(strValues[0]);
                        intMax = Convert.ToInt32(strValues[1]);
                    }
                    else
                        intMin = Convert.ToInt32(strCost.Replace("+", string.Empty));

                    if (intMin != 0 || intMax != 0)
                    {
                        frmSelectNumber frmPickNumber = new frmSelectNumber();
                        if (intMax == 0)
                            intMax = 1000000;
                        frmPickNumber.Minimum = intMin;
                        frmPickNumber.Maximum = intMax;
                        frmPickNumber.Description = LanguageManager.Instance.GetString("String_SelectVariableCost").Replace("{0}", DisplayNameShort);
                        frmPickNumber.AllowCancel = false;
                        frmPickNumber.ShowDialog();
                        _strCost = frmPickNumber.SelectedValue.ToString();
                    }
                }
            }

            string strSource = _guiID.ToString();

            objNode.Text = _strName;
            objNode.Tag = _guiID.ToString();

            // If the Gear is Ammunition, ask the user to select a Weapon Category for it to be limited to.
            if (_strCategory == "Ammunition" && (_strName.StartsWith("Ammo:") || _strName.StartsWith("Arrow:") || _strName.StartsWith("Bolt:")))
            {
                frmSelectWeaponCategory frmPickWeaponCategory = new frmSelectWeaponCategory();
                frmPickWeaponCategory.Description = LanguageManager.Instance.GetString("String_SelectWeaponCategoryAmmo");
                if (strForceValue != "")
                    frmPickWeaponCategory.OnlyCategory = strForceValue;

                //should really go in a data file
                if (_strName.StartsWith("Ammo:"))
                {
                    if (_strName.StartsWith("Ammo: Assault Cannon") || _strName.StartsWith("Ammo: Gauss"))
                    {
                        frmPickWeaponCategory.WeaponType = "cannon";
                    }
                    else if (_strName.StartsWith("Ammo: Taser Dart"))
                    {
                        frmPickWeaponCategory.WeaponType = "taser";
                    }
                    else if(_strName.StartsWith("Ammo: Fuel Canister"))
                    {
                        frmPickWeaponCategory.WeaponType = "flame";
                    }
                    else if (_strName.StartsWith("Ammo: Injection Dart") || _strName.StartsWith("Ammo: Peak-Discharge"))
                    {
                        frmPickWeaponCategory.WeaponType = "exotic";
                    }
                    else
                    {
                        frmPickWeaponCategory.WeaponType = "gun";
                    }
                }
                else if (_strName.StartsWith("Arrow:"))
                {
                    frmPickWeaponCategory.WeaponType = "bow";
                }
                else if (_strName.StartsWith("Bolt:"))
                {
                    frmPickWeaponCategory.WeaponType = "crossbow";
                }
                frmPickWeaponCategory.ShowDialog();

                _strExtra = frmPickWeaponCategory.SelectedCategory;
                objNode.Text += " (" + _strExtra + ")";
            }

            // Add Gear Weapons if applicable.
            if (objXmlGear.InnerXml.Contains("<addweapon>"))
            {
                XmlDocument objXmlWeaponDocument = XmlManager.Instance.Load("weapons.xml");

                // More than one Weapon can be added, so loop through all occurrences.
                foreach (XmlNode objXmlAddWeapon in objXmlGear.SelectNodes("addweapon"))
                {
                    XmlNode objXmlWeapon = objXmlWeaponDocument.SelectSingleNode("/chummer/weapons/weapon[name = \"" + objXmlAddWeapon.InnerText + "\"]");

                    TreeNode objGearWeaponNode = new TreeNode();
                    Weapon objGearWeapon = new Weapon(objCharacter);
                    objGearWeapon.Create(objXmlWeapon, objCharacter, objGearWeaponNode, null, null);
                    objGearWeaponNode.ForeColor = SystemColors.GrayText;
                    if (blnAerodynamic)
                    {
                        objGearWeapon.Name += " (" + LanguageManager.Instance.GetString("Checkbox_Aerodynamic") + ")";
                        objGearWeapon.SetRange("Aerodynamic Grenades");
                        objGearWeaponNode.Text = objGearWeapon.DisplayName;
                        _strName += " (" + LanguageManager.Instance.GetString("Checkbox_Aerodynamic") + ")";
                        objNode.Text = DisplayName;
                    }

                    objWeaponNodes.Add(objGearWeaponNode);
                    objWeapons.Add(objGearWeapon);

                    _guiWeaponID = Guid.Parse(objGearWeapon.InternalId);
                }
            }

            // If the item grants a bonus, pass the information to the Improvement Manager.
            if (objXmlGear.InnerXml.Contains("<bonus>"))
            {
                // Do not apply the Improvements if this is a Focus, unless we're speicifically creating a Weapon Focus. This is to avoid creating the Foci's Improvements twice (once when it's first added
                // to the character which is incorrect, and once when the Focus is actually Bonded).
                bool blnApply = !((_strCategory == "Foci" || _strCategory == "Metamagic Foci") && !objXmlGear["bonus"].InnerXml.Contains("selecttext"));

                if (blnApply)
                {
                    ImprovementManager objImprovementManager;
                    if (blnAddImprovements)
                        objImprovementManager = new ImprovementManager(objCharacter);
                    else
                        objImprovementManager = new ImprovementManager(null);

                    objImprovementManager.ForcedValue = strForceValue;
                    if (!objImprovementManager.CreateImprovements(Improvement.ImprovementSource.Gear, strSource, objXmlGear["bonus"], false, intRating, DisplayNameShort))
                    {
                        _guiID = Guid.Empty;
                        return;
                    }
                    if (objImprovementManager.SelectedValue != "")
                    {
                        _strExtra = objImprovementManager.SelectedValue;
                        objNode.Text += " (" + objImprovementManager.SelectedValue + ")";
                    }
                }
            }

            // Check to see if there are any child elements.
            if (objXmlGear.InnerXml.Contains("<gears>") && blnCreateChildren)
            {
                // Create Gear using whatever information we're given.
                foreach (XmlNode objXmlChild in objXmlGear.SelectNodes("gears/gear"))
                {
                    Gear objChild = new Gear(_objCharacter);
                    TreeNode objChildNode = new TreeNode();
                    objChild.Name = objXmlChild["name"].InnerText;
                    objChild.Category = objXmlChild["category"].InnerText;
                    objChild.Avail = "0";
                    objChild.Cost = "0";
                    objChild.Source = _strSource;
                    objChild.Page = _strPage;
                    objChild.Parent = this;
                    objChild.IncludedInParent = true;
                    _objChildren.Add(objChild);

                    objChildNode.Text = objChild.DisplayName;
                    objChildNode.Tag = objChild.InternalId;
                    objNode.Nodes.Add(objChildNode);
                    objNode.Expand();
                }

                XmlDocument objXmlGearDocument = XmlManager.Instance.Load("gear.xml");
                CreateChildren(objXmlGearDocument, objXmlGear, this, objNode, objCharacter, blnHacked);
            }

            // Add the Copy Protection and Registration plugins to the Matrix program. This does not apply if Unwired is not enabled, Hacked is selected, or this is a Suite being added (individual programs will add it to themselves).
            if (blnCreateChildren)
            {
                if ((_strCategory == "Matrix Programs" || _strCategory == "Skillsofts" || _strCategory == "Autosofts" || _strCategory == "Autosofts, Agent" || _strCategory == "Autosofts, Drone") && objCharacter.Options.BookEnabled("UN") && !blnHacked && !_strName.StartsWith("Suite:"))
                {
                    XmlDocument objXmlDocument = XmlManager.Instance.Load("gear.xml");

                    if (_objCharacter.Options.AutomaticCopyProtection && !blnInherent)
                    {
                        Gear objPlugin1 = new Gear(_objCharacter);
                        TreeNode objPlugin1Node = new TreeNode();
                        objPlugin1.Create(objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"Copy Protection\"]"), objCharacter, objPlugin1Node, _intRating, null, null);
                        if (_intRating == 0)
                            objPlugin1.Rating = 1;
                        objPlugin1.Avail = "0";
                        objPlugin1.Cost = "0";
                        objPlugin1.Cost3 = "0";
                        objPlugin1.Cost6 = "0";
                        objPlugin1.Cost10 = "0";
                        objPlugin1.Capacity = "[0]";
                        objPlugin1.Parent = this;
                        _objChildren.Add(objPlugin1);
                        objNode.Nodes.Add(objPlugin1Node);
                    }

                    if (_objCharacter.Options.AutomaticRegistration && !blnInherent)
                    {
                        Gear objPlugin2 = new Gear(_objCharacter);
                        TreeNode objPlugin2Node = new TreeNode();
                        objPlugin2.Create(objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"Registration\"]"), objCharacter, objPlugin2Node, 0, null, null);
                        objPlugin2.Avail = "0";
                        objPlugin2.Cost = "0";
                        objPlugin2.Cost3 = "0";
                        objPlugin2.Cost6 = "0";
                        objPlugin2.Cost10 = "0";
                        objPlugin2.Capacity = "[0]";
                        objPlugin2.Parent = this;
                        _objChildren.Add(objPlugin2);
                        objNode.Nodes.Add(objPlugin2Node);
                        objNode.Expand();
                    }

                    if ((objCharacter.Metatype == "A.I." || objCharacter.MetatypeCategory == "Technocritters" || objCharacter.MetatypeCategory == "Protosapients") && blnInherent)
                    {
                        Gear objPlugin3 = new Gear(_objCharacter);
                        TreeNode objPlugin3Node = new TreeNode();
                        objPlugin3.Create(objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"Ergonomic\"]"), objCharacter, objPlugin3Node, 0, null, null);
                        objPlugin3.Avail = "0";
                        objPlugin3.Cost = "0";
                        objPlugin3.Cost3 = "0";
                        objPlugin3.Cost6 = "0";
                        objPlugin3.Cost10 = "0";
                        objPlugin3.Capacity = "[0]";
                        objPlugin3.Parent = this;
                        _objChildren.Add(objPlugin3);
                        objNode.Nodes.Add(objPlugin3Node);

                        Gear objPlugin4 = new Gear(_objCharacter);
                        TreeNode objPlugin4Node = new TreeNode();
                        objPlugin4.Create(objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"Optimization\" and category = \"Program Options\"]"), objCharacter, objPlugin4Node, _intRating, null, null);
                        if (_intRating == 0)
                            objPlugin4.Rating = 1;
                        objPlugin4.Avail = "0";
                        objPlugin4.Cost = "0";
                        objPlugin4.Cost3 = "0";
                        objPlugin4.Cost6 = "0";
                        objPlugin4.Cost10 = "0";
                        objPlugin4.Capacity = "[0]";
                        objPlugin4.Parent = this;
                        _objChildren.Add(objPlugin4);
                        objNode.Nodes.Add(objPlugin4Node);
                        objNode.Expand();
                    }
                }
            }

            // If the item grants a Weapon bonus (Ammunition), just fill the WeaponBonus XmlNode.
            if (objXmlGear.InnerXml.Contains("<weaponbonus>"))
                _nodWeaponBonus = objXmlGear["weaponbonus"];
            objNode.Text = DisplayName;
        }