Beispiel #1
0
        private void BuildVehicleList(XPathNodeIterator objXmlVehicleList)
        {
            List <ListItem> lstVehicles = new List <ListItem>();

            foreach (XPathNavigator objXmlVehicle in objXmlVehicleList)
            {
                if (!chkHideOverAvailLimit.Checked || SelectionShared.CheckAvailRestriction(objXmlVehicle, _objCharacter))
                {
                    string strDisplayname = objXmlVehicle.SelectSingleNode("translate")?.Value ?? objXmlVehicle.SelectSingleNode("name")?.Value ?? LanguageManager.GetString("String_Unknown", GlobalOptions.Language);

                    if (!_objCharacter.Options.SearchInCategoryOnly && txtSearch.TextLength != 0)
                    {
                        string strCategory = objXmlVehicle.SelectSingleNode("category")?.Value;
                        if (!string.IsNullOrEmpty(strCategory))
                        {
                            ListItem objFoundItem = _lstCategory.Find(objFind => objFind.Value.ToString() == strCategory);
                            if (!string.IsNullOrEmpty(objFoundItem.Name))
                            {
                                strDisplayname += " [" + objFoundItem.Name + ']';
                            }
                        }
                    }
                    lstVehicles.Add(new ListItem(objXmlVehicle.SelectSingleNode("id")?.Value ?? string.Empty, strDisplayname));
                }
            }
            lstVehicles.Sort(CompareListItems.CompareNames);
            lstVehicle.BeginUpdate();
            lstVehicle.DataSource    = null;
            lstVehicle.ValueMember   = "Value";
            lstVehicle.DisplayMember = "Name";
            lstVehicle.DataSource    = lstVehicles;
            lstVehicle.EndUpdate();
        }
Beispiel #2
0
        /// <summary>
        /// Builds the list of Armors to render in the active tab.
        /// </summary>
        /// <param name="objXmlArmorList">XmlNodeList of Armors to render.</param>
        private void BuildArmorList(XmlNodeList objXmlArmorList)
        {
            switch (tabControl.SelectedIndex)
            {
            case 1:
                DataTable tabArmor = new DataTable("armor");
                tabArmor.Columns.Add("ArmorGuid");
                tabArmor.Columns.Add("ArmorName");
                tabArmor.Columns.Add("Armor");
                tabArmor.Columns["Armor"].DataType = typeof(int);
                tabArmor.Columns.Add("Capacity");
                tabArmor.Columns["Capacity"].DataType = typeof(decimal);
                tabArmor.Columns.Add("Avail");
                tabArmor.Columns["Avail"].DataType = typeof(AvailabilityValue);
                tabArmor.Columns.Add("Special");
                tabArmor.Columns.Add("Source");
                tabArmor.Columns["Source"].DataType = typeof(SourceString);
                tabArmor.Columns.Add("Cost");
                tabArmor.Columns["Cost"].DataType = typeof(NuyenString);

                // Populate the Armor list.
                foreach (XmlNode objXmlArmor in objXmlArmorList)
                {
                    decimal decCostMultiplier = 1 + (nudMarkup.Value / 100.0m);
                    if (_setBlackMarketMaps.Contains(objXmlArmor["category"]?.InnerText))
                    {
                        decCostMultiplier *= 0.9m;
                    }
                    if (!chkHideOverAvailLimit.Checked || SelectionShared.CheckAvailRestriction(objXmlArmor, _objCharacter) &&
                        (chkFreeItem.Checked || !chkShowOnlyAffordItems.Checked ||
                         SelectionShared.CheckNuyenRestriction(objXmlArmor, _objCharacter.Nuyen, decCostMultiplier)))
                    {
                        Armor         objArmor   = new Armor(_objCharacter);
                        List <Weapon> lstWeapons = new List <Weapon>();
                        objArmor.Create(objXmlArmor, 0, lstWeapons, true, true, true);

                        string            strArmorGuid   = objArmor.SourceIDString;
                        string            strArmorName   = objArmor.DisplayName(GlobalOptions.Language);
                        int               intArmor       = objArmor.TotalArmor;
                        decimal           decCapacity    = Convert.ToDecimal(objArmor.CalculatedCapacity, GlobalOptions.CultureInfo);
                        AvailabilityValue objAvail       = objArmor.TotalAvailTuple();
                        StringBuilder     strAccessories = new StringBuilder();
                        foreach (ArmorMod objMod in objArmor.ArmorMods)
                        {
                            strAccessories.AppendLine(objMod.DisplayName(GlobalOptions.Language));
                        }
                        foreach (Gear objGear in objArmor.Gear)
                        {
                            strAccessories.AppendLine(objGear.DisplayName(GlobalOptions.CultureInfo, GlobalOptions.Language));
                        }
                        if (strAccessories.Length > 0)
                        {
                            strAccessories.Length -= Environment.NewLine.Length;
                        }
                        SourceString strSource = new SourceString(objArmor.Source, objArmor.DisplayPage(GlobalOptions.Language), GlobalOptions.Language);
                        NuyenString  strCost   = new NuyenString(objArmor.DisplayCost(out decimal _, false));

                        tabArmor.Rows.Add(strArmorGuid, strArmorName, intArmor, decCapacity, objAvail, strAccessories.ToString(), strSource, strCost);
                    }
                }

                DataSet set = new DataSet("armor");
                set.Tables.Add(tabArmor);

                dgvArmor.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
                dgvArmor.DataSource       = set;
                dgvArmor.DataMember       = "armor";
                break;

            default:
                List <ListItem> lstArmors = new List <ListItem>();
                foreach (XmlNode objXmlArmor in objXmlArmorList)
                {
                    decimal decCostMultiplier = 1 + (nudMarkup.Value / 100.0m);
                    if (_setBlackMarketMaps.Contains(objXmlArmor["category"]?.InnerText))
                    {
                        decCostMultiplier *= 0.9m;
                    }
                    if (!chkHideOverAvailLimit.Checked || SelectionShared.CheckAvailRestriction(objXmlArmor, _objCharacter) &&
                        (chkFreeItem.Checked || !chkShowOnlyAffordItems.Checked ||
                         SelectionShared.CheckNuyenRestriction(objXmlArmor, _objCharacter.Nuyen, decCostMultiplier)))
                    {
                        string strDisplayName = objXmlArmor["translate"]?.InnerText ?? objXmlArmor["name"]?.InnerText;
                        if (!_objCharacter.Options.SearchInCategoryOnly && txtSearch.TextLength != 0)
                        {
                            string strCategory = objXmlArmor["category"]?.InnerText;
                            if (!string.IsNullOrEmpty(strCategory))
                            {
                                ListItem objFoundItem = _lstCategory.Find(objFind => objFind.Value.ToString() == strCategory);
                                if (!string.IsNullOrEmpty(objFoundItem.Name))
                                {
                                    strDisplayName += " [" + objFoundItem.Name + "]";
                                }
                            }
                        }

                        lstArmors.Add(new ListItem(objXmlArmor["id"]?.InnerText, strDisplayName));
                    }
                }
                lstArmors.Sort(CompareListItems.CompareNames);
                _blnLoading = true;
                string strOldSelected = lstArmor.SelectedValue?.ToString();
                lstArmor.BeginUpdate();
                lstArmor.ValueMember   = "Value";
                lstArmor.DisplayMember = "Name";
                lstArmor.DataSource    = lstArmors;
                _blnLoading            = false;
                if (!string.IsNullOrEmpty(strOldSelected))
                {
                    lstArmor.SelectedValue = strOldSelected;
                }
                else
                {
                    lstArmor.SelectedIndex = -1;
                }
                lstArmor.EndUpdate();
                break;
            }
        }
Beispiel #3
0
        private void lstArmor_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (_blnLoading)
            {
                return;
            }

            XmlNode xmlArmor      = null;
            string  strSelectedId = lstArmor.SelectedValue?.ToString();

            if (!string.IsNullOrEmpty(strSelectedId))
            {
                xmlArmor = _objXmlDocument.SelectSingleNode("/chummer/armors/armor[id = \"" + strSelectedId + "\"]");
            }
            if (xmlArmor != null)
            {
                // Create the Armor so we can show its Total Avail (some Armor includes Chemical Seal which adds +6 which wouldn't be factored in properly otherwise).
                Armor         objArmor   = new Armor(_objCharacter);
                List <Weapon> lstWeapons = new List <Weapon>();
                objArmor.Create(xmlArmor, 0, lstWeapons, true, true, true);

                _objSelectedArmor = objArmor;

                string strRating = xmlArmor["rating"]?.InnerText;
                if (!string.IsNullOrEmpty(strRating))
                {
                    nudRating.Maximum = Convert.ToInt32(strRating);
                    if (chkHideOverAvailLimit.Checked)
                    {
                        while (nudRating.Maximum > 1 && !SelectionShared.CheckAvailRestriction(xmlArmor, _objCharacter, decimal.ToInt32(nudRating.Maximum)))
                        {
                            nudRating.Maximum -= 1;
                        }
                    }

                    if (chkShowOnlyAffordItems.Checked && !chkFreeItem.Checked)
                    {
                        decimal decCostMultiplier = 1 + (nudMarkup.Value / 100.0m);
                        if (_setBlackMarketMaps.Contains(xmlArmor.SelectSingleNode("category")?.Value))
                        {
                            decCostMultiplier *= 0.9m;
                        }
                        while (nudRating.Maximum > 1 && !SelectionShared.CheckNuyenRestriction(xmlArmor, _objCharacter.Nuyen, decCostMultiplier, decimal.ToInt32(nudRating.Maximum)))
                        {
                            nudRating.Maximum -= 1;
                        }
                    }
                    lblRatingLabel.Visible   = true;
                    nudRating.Minimum        = 1;
                    nudRating.Value          = 1;
                    nudRating.Enabled        = nudRating.Minimum != nudRating.Maximum;
                    nudRating.Visible        = true;
                    lblRatingNALabel.Visible = false;
                }
                else
                {
                    lblRatingLabel.Visible   = true;
                    lblRatingNALabel.Visible = true;
                    nudRating.Minimum        = 0;
                    nudRating.Maximum        = 0;
                    nudRating.Value          = 0;
                    nudRating.Enabled        = false;
                    nudRating.Visible        = false;
                }

                lblRatingLabel.Text = xmlArmor.SelectSingleNode("ratinglabel") != null
                    ? LanguageManager.GetString("Label_RatingFormat").Replace("{0}",
                                                                              LanguageManager.GetString(xmlArmor.SelectSingleNode("ratinglabel").Value,
                                                                                                        GlobalOptions.Language))
                    : LanguageManager.GetString("Label_Rating");
            }
            else
            {
                _objSelectedArmor        = null;
                lblRatingLabel.Visible   = false;
                lblRatingNALabel.Visible = false;
                nudRating.Visible        = false;
                nudRating.Enabled        = false;
                nudRating.Minimum        = 0;
                nudRating.Value          = 0;
            }

            UpdateArmorInfo();
        }
Beispiel #4
0
        private void BuildWeaponList(XmlNodeList objNodeList)
        {
            if (tabControl.SelectedIndex == 1)
            {
                DataTable tabWeapons = new DataTable("weapons");
                tabWeapons.Columns.Add("WeaponGuid");
                tabWeapons.Columns.Add("WeaponName");
                tabWeapons.Columns.Add("Dice");
                tabWeapons.Columns.Add("Accuracy");
                tabWeapons.Columns.Add("Damage");
                tabWeapons.Columns.Add("AP");
                tabWeapons.Columns.Add("RC");
                tabWeapons.Columns.Add("Ammo");
                tabWeapons.Columns.Add("Mode");
                tabWeapons.Columns.Add("Reach");
                tabWeapons.Columns.Add("Accessories");
                tabWeapons.Columns.Add("Avail");
                tabWeapons.Columns["Avail"].DataType = typeof(AvailabilityValue);
                tabWeapons.Columns.Add("Source");
                tabWeapons.Columns["Source"].DataType = typeof(SourceString);
                tabWeapons.Columns.Add("Cost");
                tabWeapons.Columns["Cost"].DataType = typeof(NuyenString);

                foreach (XmlNode objXmlWeapon in objNodeList)
                {
                    if (objXmlWeapon["cyberware"]?.InnerText == bool.TrueString)
                    {
                        continue;
                    }
                    string strTest = objXmlWeapon["mount"]?.InnerText;
                    if (!string.IsNullOrEmpty(strTest) && !Mounts.Contains(strTest))
                    {
                        continue;
                    }
                    strTest = objXmlWeapon["extramount"]?.InnerText;
                    if (!string.IsNullOrEmpty(strTest) && !Mounts.Contains(strTest))
                    {
                        continue;
                    }
                    if (chkHideOverAvailLimit.Checked && !SelectionShared.CheckAvailRestriction(objXmlWeapon, _objCharacter))
                    {
                        continue;
                    }
                    if (!chkFreeItem.Checked && chkShowOnlyAffordItems.Checked)
                    {
                        decimal decCostMultiplier = 1 + (nudMarkup.Value / 100.0m);
                        if (_setBlackMarketMaps.Contains(objXmlWeapon["category"]?.InnerText))
                        {
                            decCostMultiplier *= 0.9m;
                        }
                        if (!SelectionShared.CheckNuyenRestriction(objXmlWeapon, _objCharacter.Nuyen, decCostMultiplier))
                        {
                            continue;
                        }
                    }

                    Weapon objWeapon = new Weapon(_objCharacter);
                    objWeapon.Create(objXmlWeapon, null, true, false, true);

                    string strID         = objWeapon.SourceID.ToString("D");
                    string strWeaponName = objWeapon.DisplayName(GlobalOptions.Language);
                    string strDice       = objWeapon.GetDicePool(GlobalOptions.CultureInfo, GlobalOptions.Language);
                    string strAccuracy   = objWeapon.DisplayAccuracy(GlobalOptions.CultureInfo, GlobalOptions.Language);
                    string strDamage     = objWeapon.CalculatedDamage(GlobalOptions.CultureInfo, GlobalOptions.Language);
                    string strAP         = objWeapon.TotalAP(GlobalOptions.Language);
                    if (strAP == "-")
                    {
                        strAP = "0";
                    }
                    string        strRC             = objWeapon.TotalRC(GlobalOptions.CultureInfo, GlobalOptions.Language, true);
                    string        strAmmo           = objWeapon.CalculatedAmmo(GlobalOptions.CultureInfo, GlobalOptions.Language);
                    string        strMode           = objWeapon.CalculatedMode(GlobalOptions.Language);
                    string        strReach          = objWeapon.TotalReach.ToString();
                    StringBuilder strbldAccessories = new StringBuilder();
                    foreach (WeaponAccessory objAccessory in objWeapon.WeaponAccessories)
                    {
                        strbldAccessories.AppendLine(objAccessory.DisplayName(GlobalOptions.Language));
                    }
                    if (strbldAccessories.Length > 0)
                    {
                        strbldAccessories.Length -= Environment.NewLine.Length;
                    }
                    AvailabilityValue objAvail  = objWeapon.TotalAvailTuple();
                    SourceString      strSource = new SourceString(objWeapon.Source, objWeapon.DisplayPage(GlobalOptions.Language), GlobalOptions.Language);
                    NuyenString       strCost   = new NuyenString(objWeapon.DisplayCost(out decimal _));

                    tabWeapons.Rows.Add(strID, strWeaponName, strDice, strAccuracy, strDamage, strAP, strRC, strAmmo, strMode, strReach, strbldAccessories.ToString(), objAvail, strSource, strCost);
                }

                DataSet set = new DataSet("weapons");
                set.Tables.Add(tabWeapons);
                string strSelectedCategory = cboCategory.SelectedValue?.ToString();
                if (string.IsNullOrEmpty(strSelectedCategory) || strSelectedCategory == "Show All")
                {
                    //dgvWeapons.Columns[5].Visible = true;
                    dgvWeapons.Columns[6].Visible = true;
                    dgvWeapons.Columns[7].Visible = true;
                    dgvWeapons.Columns[8].Visible = true;
                }
                else if (strSelectedCategory == "Blades" ||
                         strSelectedCategory == "Clubs" ||
                         strSelectedCategory == "Improvised Weapons" ||
                         strSelectedCategory == "Exotic Melee Weapons" ||
                         strSelectedCategory == "Unarmed")
                {
                    //dgvWeapons.Columns[5].Visible = false;
                    dgvWeapons.Columns[6].Visible = false;
                    dgvWeapons.Columns[7].Visible = false;
                    dgvWeapons.Columns[8].Visible = false;
                }
                else
                {
                    //dgvWeapons.Columns[5].Visible = true;
                    dgvWeapons.Columns[6].Visible = true;
                    dgvWeapons.Columns[7].Visible = true;
                    dgvWeapons.Columns[8].Visible = true;
                }
                dgvWeapons.Columns[0].Visible = false;
                dgvWeapons.Columns[12].DefaultCellStyle.Alignment = DataGridViewContentAlignment.TopRight;
                dgvWeapons.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
                dgvWeapons.DataSource       = set;
                dgvWeapons.DataMember       = "weapons";
            }
            else
            {
                List <ListItem> lstWeapons = new List <ListItem>();
                foreach (XmlNode objXmlWeapon in objNodeList)
                {
                    if (objXmlWeapon["cyberware"]?.InnerText == bool.TrueString)
                    {
                        continue;
                    }

                    string strTest = objXmlWeapon["mount"]?.InnerText;
                    if (!string.IsNullOrEmpty(strTest) && !Mounts.Contains(strTest))
                    {
                        continue;
                    }

                    strTest = objXmlWeapon["extramount"]?.InnerText;
                    if (!string.IsNullOrEmpty(strTest) && !Mounts.Contains(strTest))
                    {
                        continue;
                    }

                    if (chkHideOverAvailLimit.Checked && !SelectionShared.CheckAvailRestriction(objXmlWeapon, _objCharacter))
                    {
                        continue;
                    }
                    if (!chkFreeItem.Checked && chkShowOnlyAffordItems.Checked)
                    {
                        decimal decCostMultiplier = 1 + (nudMarkup.Value / 100.0m);
                        if (_setBlackMarketMaps.Contains(objXmlWeapon["category"]?.InnerText))
                        {
                            decCostMultiplier *= 0.9m;
                        }
                        if (!SelectionShared.CheckNuyenRestriction(objXmlWeapon, _objCharacter.Nuyen, decCostMultiplier))
                        {
                            continue;
                        }
                    }
                    lstWeapons.Add(new ListItem(objXmlWeapon["id"]?.InnerText, objXmlWeapon["translate"]?.InnerText ?? objXmlWeapon["name"]?.InnerText));
                }

                lstWeapons.Sort(CompareListItems.CompareNames);
                string strOldSelected = lstWeapon.SelectedValue?.ToString();
                _blnLoading = true;
                lstWeapon.BeginUpdate();
                lstWeapon.ValueMember   = "Value";
                lstWeapon.DisplayMember = "Name";
                lstWeapon.DataSource    = lstWeapons;
                _blnLoading             = false;
                if (!string.IsNullOrEmpty(strOldSelected))
                {
                    lstWeapon.SelectedValue = strOldSelected;
                }
                else
                {
                    lstWeapon.SelectedIndex = -1;
                }
                lstWeapon.EndUpdate();
            }
        }
Beispiel #5
0
        private void BuildVehicleList(XPathNodeIterator objXmlVehicleList)
        {
            List <ListItem> lstVehicles = new List <ListItem>();

            foreach (XPathNavigator objXmlVehicle in objXmlVehicleList)
            {
                if (chkHideOverAvailLimit.Checked && !SelectionShared.CheckAvailRestriction(objXmlVehicle, _objCharacter))
                {
                    continue;
                }
                if (!chkFreeItem.Checked && chkShowOnlyAffordItems.Checked)
                {
                    decimal decCostMultiplier = 1.0m;
                    if (chkUsedVehicle.Checked)
                    {
                        decCostMultiplier -= (nudUsedVehicleDiscount.Value / 100.0m);
                    }
                    decCostMultiplier *= 1 + (nudMarkup.Value / 100.0m);
                    if (_setBlackMarketMaps.Contains(objXmlVehicle.SelectSingleNode("category")?.Value))
                    {
                        decCostMultiplier *= 0.9m;
                    }
                    if (_setDealerConnectionMaps?.Any(set => objXmlVehicle.SelectSingleNode("category")?.Value.StartsWith(set) == true) == true)
                    {
                        decCostMultiplier *= 0.9m;
                    }
                    if (!SelectionShared.CheckNuyenRestriction(objXmlVehicle, _objCharacter.Nuyen, decCostMultiplier))
                    {
                        continue;
                    }
                }

                string strDisplayname = objXmlVehicle.SelectSingleNode("translate")?.Value ?? objXmlVehicle.SelectSingleNode("name")?.Value ?? LanguageManager.GetString("String_Unknown", GlobalOptions.Language);

                if (!_objCharacter.Options.SearchInCategoryOnly && txtSearch.TextLength != 0)
                {
                    string strCategory = objXmlVehicle.SelectSingleNode("category")?.Value;
                    if (!string.IsNullOrEmpty(strCategory))
                    {
                        ListItem objFoundItem = _lstCategory.Find(objFind => objFind.Value.ToString() == strCategory);
                        if (!string.IsNullOrEmpty(objFoundItem.Name))
                        {
                            strDisplayname += " [" + objFoundItem.Name + ']';
                        }
                    }
                }
                lstVehicles.Add(new ListItem(objXmlVehicle.SelectSingleNode("id")?.Value ?? string.Empty, strDisplayname));
            }
            lstVehicles.Sort(CompareListItems.CompareNames);
            string strOldSelected = lstVehicle.SelectedValue?.ToString();

            _blnLoading = true;
            lstVehicle.BeginUpdate();
            lstVehicle.ValueMember   = "Value";
            lstVehicle.DisplayMember = "Name";
            lstVehicle.DataSource    = lstVehicles;
            _blnLoading = false;
            if (string.IsNullOrEmpty(strOldSelected))
            {
                lstVehicle.SelectedIndex = -1;
            }
            else
            {
                lstVehicle.SelectedValue = strOldSelected;
            }
            lstVehicle.EndUpdate();
        }
Beispiel #6
0
        private async ValueTask <bool> BuildWeaponList(XmlNodeList objNodeList, bool blnForCategories = false)
        {
            SuspendLayout();
            if (tabControl.SelectedIndex == 1 && !blnForCategories)
            {
                DataTable tabWeapons = new DataTable("weapons");
                tabWeapons.Columns.Add("WeaponGuid");
                tabWeapons.Columns.Add("WeaponName");
                tabWeapons.Columns.Add("Dice");
                tabWeapons.Columns.Add("Accuracy");
                tabWeapons.Columns.Add("Damage");
                tabWeapons.Columns.Add("AP");
                tabWeapons.Columns.Add("RC");
                tabWeapons.Columns.Add("Ammo");
                tabWeapons.Columns.Add("Mode");
                tabWeapons.Columns.Add("Reach");
                tabWeapons.Columns.Add("Concealability");
                tabWeapons.Columns.Add("Accessories");
                tabWeapons.Columns.Add("Avail");
                tabWeapons.Columns["Avail"].DataType = typeof(AvailabilityValue);
                tabWeapons.Columns.Add("Source");
                tabWeapons.Columns["Source"].DataType = typeof(SourceString);
                tabWeapons.Columns.Add("Cost");
                tabWeapons.Columns["Cost"].DataType = typeof(NuyenString);

                bool    blnAnyRanged            = false;
                bool    blnAnyMelee             = false;
                XmlNode xmlParentWeaponDataNode = ParentWeapon != null?_objXmlDocument.SelectSingleNode("/chummer/weapons/weapon[id = " + ParentWeapon.SourceIDString.CleanXPath() + ']') : null;

                foreach (XmlNode objXmlWeapon in objNodeList)
                {
                    if (!objXmlWeapon.CreateNavigator().RequirementsMet(_objCharacter, ParentWeapon))
                    {
                        continue;
                    }

                    XmlNode xmlTestNode = objXmlWeapon.SelectSingleNode("forbidden/weapondetails");
                    if (xmlTestNode != null && xmlParentWeaponDataNode.ProcessFilterOperationNode(xmlTestNode, false))
                    {
                        // Assumes topmost parent is an AND node
                        continue;
                    }
                    xmlTestNode = objXmlWeapon.SelectSingleNode("required/weapondetails");
                    if (xmlTestNode != null && !xmlParentWeaponDataNode.ProcessFilterOperationNode(xmlTestNode, false))
                    {
                        // Assumes topmost parent is an AND node
                        continue;
                    }
                    if (objXmlWeapon["cyberware"]?.InnerText == bool.TrueString)
                    {
                        continue;
                    }
                    string strTest = objXmlWeapon["mount"]?.InnerText;
                    if (!string.IsNullOrEmpty(strTest) && !Mounts.Contains(strTest))
                    {
                        continue;
                    }
                    strTest = objXmlWeapon["extramount"]?.InnerText;
                    if (!string.IsNullOrEmpty(strTest) && !Mounts.Contains(strTest))
                    {
                        continue;
                    }
                    if (chkHideOverAvailLimit.Checked && !SelectionShared.CheckAvailRestriction(objXmlWeapon, _objCharacter))
                    {
                        continue;
                    }
                    if (!chkFreeItem.Checked && chkShowOnlyAffordItems.Checked)
                    {
                        decimal decCostMultiplier = 1 + (nudMarkup.Value / 100.0m);
                        if (_setBlackMarketMaps.Contains(objXmlWeapon["category"]?.InnerText))
                        {
                            decCostMultiplier *= 0.9m;
                        }
                        if (!SelectionShared.CheckNuyenRestriction(objXmlWeapon, _objCharacter.Nuyen, decCostMultiplier))
                        {
                            continue;
                        }
                    }

                    using (Weapon objWeapon = new Weapon(_objCharacter))
                    {
                        objWeapon.Create(objXmlWeapon, null, true, false, true);
                        objWeapon.Parent = ParentWeapon;
                        if (objWeapon.RangeType == "Ranged")
                        {
                            blnAnyRanged = true;
                        }
                        else
                        {
                            blnAnyMelee = true;
                        }
                        string strID         = objWeapon.SourceIDString;
                        string strWeaponName = objWeapon.CurrentDisplayName;
                        string strDice       = objWeapon.DicePool.ToString(GlobalSettings.CultureInfo);
                        string strAccuracy   = objWeapon.DisplayAccuracy;
                        string strDamage     = objWeapon.DisplayDamage;
                        string strAP         = objWeapon.DisplayTotalAP;
                        if (strAP == "-")
                        {
                            strAP = "0";
                        }
                        string strRC      = objWeapon.DisplayTotalRC;
                        string strAmmo    = objWeapon.DisplayAmmo;
                        string strMode    = objWeapon.DisplayMode;
                        string strReach   = objWeapon.TotalReach.ToString(GlobalSettings.CultureInfo);
                        string strConceal = objWeapon.DisplayConcealability;
                        using (new FetchSafelyFromPool <StringBuilder>(Utils.StringBuilderPool,
                                                                       out StringBuilder sbdAccessories))
                        {
                            foreach (WeaponAccessory objAccessory in objWeapon.WeaponAccessories)
                            {
                                sbdAccessories.AppendLine(objAccessory.CurrentDisplayName);
                            }

                            if (sbdAccessories.Length > 0)
                            {
                                sbdAccessories.Length -= Environment.NewLine.Length;
                            }
                            AvailabilityValue objAvail  = objWeapon.TotalAvailTuple();
                            SourceString      strSource = await SourceString.GetSourceStringAsync(objWeapon.Source,
                                                                                                  await objWeapon.DisplayPageAsync(GlobalSettings.Language),
                                                                                                  GlobalSettings.Language,
                                                                                                  GlobalSettings.CultureInfo,
                                                                                                  _objCharacter);

                            NuyenString strCost = new NuyenString(objWeapon.DisplayCost(out decimal _));

                            tabWeapons.Rows.Add(strID, strWeaponName, strDice, strAccuracy, strDamage, strAP, strRC,
                                                strAmmo, strMode, strReach, strConceal, sbdAccessories.ToString(),
                                                objAvail,
                                                strSource, strCost);
                        }
                    }
                }

                DataSet set = new DataSet("weapons");
                set.Tables.Add(tabWeapons);
                if (blnAnyRanged)
                {
                    dgvWeapons.Columns[6].Visible = true;
                    dgvWeapons.Columns[7].Visible = true;
                    dgvWeapons.Columns[8].Visible = true;
                }
                else
                {
                    dgvWeapons.Columns[6].Visible = false;
                    dgvWeapons.Columns[7].Visible = false;
                    dgvWeapons.Columns[8].Visible = false;
                }
                dgvWeapons.Columns[9].Visible = blnAnyMelee;
                dgvWeapons.Columns[0].Visible = false;
                dgvWeapons.Columns[13].DefaultCellStyle.Alignment = DataGridViewContentAlignment.TopRight;
                dgvWeapons.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
                dgvWeapons.DataSource       = set;
                dgvWeapons.DataMember       = "weapons";
            }
            else
            {
                using (new FetchSafelyFromPool <List <ListItem> >(Utils.ListItemListPool,
                                                                  out List <ListItem> lstWeapons))
                {
                    int     intOverLimit            = 0;
                    XmlNode xmlParentWeaponDataNode = ParentWeapon != null
                        ? _objXmlDocument.SelectSingleNode("/chummer/weapons/weapon[id = "
                                                           + ParentWeapon.SourceIDString.CleanXPath() + ']')
                        : null;

                    foreach (XmlNode objXmlWeapon in objNodeList)
                    {
                        if (!objXmlWeapon.CreateNavigator().RequirementsMet(_objCharacter, ParentWeapon))
                        {
                            continue;
                        }

                        XmlNode xmlTestNode = objXmlWeapon.SelectSingleNode("forbidden/weapondetails");
                        if (xmlTestNode != null &&
                            xmlParentWeaponDataNode.ProcessFilterOperationNode(xmlTestNode, false))
                        {
                            // Assumes topmost parent is an AND node
                            continue;
                        }

                        xmlTestNode = objXmlWeapon.SelectSingleNode("required/weapondetails");
                        if (xmlTestNode != null &&
                            !xmlParentWeaponDataNode.ProcessFilterOperationNode(xmlTestNode, false))
                        {
                            // Assumes topmost parent is an AND node
                            continue;
                        }

                        if (objXmlWeapon["cyberware"]?.InnerText == bool.TrueString)
                        {
                            continue;
                        }

                        string strMount = objXmlWeapon["mount"]?.InnerText;
                        if (!string.IsNullOrEmpty(strMount) && !Mounts.Contains(strMount))
                        {
                            continue;
                        }

                        string strExtraMount = objXmlWeapon["extramount"]?.InnerText;
                        if (!string.IsNullOrEmpty(strExtraMount) && !Mounts.Contains(strExtraMount))
                        {
                            continue;
                        }

                        if (blnForCategories)
                        {
                            return(true);
                        }
                        if (chkHideOverAvailLimit.Checked &&
                            !SelectionShared.CheckAvailRestriction(objXmlWeapon, _objCharacter))
                        {
                            ++intOverLimit;
                            continue;
                        }

                        if (!chkFreeItem.Checked && chkShowOnlyAffordItems.Checked)
                        {
                            decimal decCostMultiplier = 1 + (nudMarkup.Value / 100.0m);
                            if (_setBlackMarketMaps.Contains(objXmlWeapon["category"]?.InnerText))
                            {
                                decCostMultiplier *= 0.9m;
                            }
                            if (!string.IsNullOrEmpty(ParentWeapon?.DoubledCostModificationSlots) &&
                                (!string.IsNullOrEmpty(strMount) || !string.IsNullOrEmpty(strExtraMount)))
                            {
                                string[] astrParentDoubledCostModificationSlots
                                    = ParentWeapon.DoubledCostModificationSlots.Split(
                                          '/', StringSplitOptions.RemoveEmptyEntries);
                                if (astrParentDoubledCostModificationSlots.Contains(strMount) ||
                                    astrParentDoubledCostModificationSlots.Contains(strExtraMount))
                                {
                                    decCostMultiplier *= 2;
                                }
                            }

                            if (!SelectionShared.CheckNuyenRestriction(
                                    objXmlWeapon, _objCharacter.Nuyen, decCostMultiplier))
                            {
                                ++intOverLimit;
                                continue;
                            }
                        }

                        lstWeapons.Add(new ListItem(objXmlWeapon["id"]?.InnerText,
                                                    objXmlWeapon["translate"]?.InnerText
                                                    ?? objXmlWeapon["name"]?.InnerText));
                    }

                    if (blnForCategories)
                    {
                        return(false);
                    }
                    lstWeapons.Sort(CompareListItems.CompareNames);
                    if (intOverLimit > 0)
                    {
                        // Add after sort so that it's always at the end
                        lstWeapons.Add(new ListItem(string.Empty,
                                                    string.Format(GlobalSettings.CultureInfo,
                                                                  await LanguageManager.GetStringAsync(
                                                                      "String_RestrictedItemsHidden"),
                                                                  intOverLimit)));
                    }

                    string strOldSelected = lstWeapon.SelectedValue?.ToString();
                    _blnLoading = true;
                    await lstWeapon.PopulateWithListItemsAsync(lstWeapons);

                    _blnLoading = false;
                    if (!string.IsNullOrEmpty(strOldSelected))
                    {
                        lstWeapon.SelectedValue = strOldSelected;
                    }
                    else
                    {
                        lstWeapon.SelectedIndex = -1;
                    }
                }
            }
            ResumeLayout();
            return(true);
        }
Beispiel #7
0
        private void lstDrug_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (_blnLoading)
            {
                return;
            }
            _blnLoading = true;
            XPathNavigator xmlDrug       = null;
            string         strSelectedId = lstDrug.SelectedValue?.ToString();

            if (!string.IsNullOrEmpty(strSelectedId))
            {
                // Retrieve the information for the selected piece of Drug.
                xmlDrug = _xmlBaseDrugDataNode.SelectSingleNode(_strNodeXPath + "[id = \"" + strSelectedId + "\"]");
            }
            string strForceGrade;

            if (xmlDrug != null)
            {
                strForceGrade = xmlDrug.SelectSingleNode("forcegrade")?.Value;
                // If the piece has a Rating value, enable the Rating control, otherwise, disable it and set its value to 0.
                XPathNavigator xmlRatingNode = xmlDrug.SelectSingleNode("rating");
                if (xmlRatingNode != null)
                {
                    string strMinRating = xmlDrug.SelectSingleNode("minrating")?.Value;
                    int    intMinRating = 1;
                    // Not a simple integer, so we need to start mucking around with strings
                    if (!string.IsNullOrEmpty(strMinRating) && !int.TryParse(strMinRating, out intMinRating))
                    {
                        strMinRating = strMinRating.CheapReplace("MaximumSTR", () => (ParentVehicle != null ? Math.Max(1, ParentVehicle.TotalBody * 2) : _objCharacter.STR.TotalMaximum).ToString())
                                       .CheapReplace("MaximumAGI", () => (ParentVehicle != null ? Math.Max(1, ParentVehicle.Pilot * 2) : _objCharacter.AGI.TotalMaximum).ToString())
                                       .CheapReplace("MinimumSTR", () => (ParentVehicle?.TotalBody ?? 3).ToString())
                                       .CheapReplace("MinimumAGI", () => (ParentVehicle?.Pilot ?? 3).ToString());

                        object objProcess = CommonFunctions.EvaluateInvariantXPath(strMinRating, out bool blnIsSuccess);
                        intMinRating = blnIsSuccess ? Convert.ToInt32(objProcess) : 1;
                    }
                    nudRating.Minimum = intMinRating;

                    string strMaxRating = xmlRatingNode.Value;
                    int    intMaxRating = 0;
                    // Not a simple integer, so we need to start mucking around with strings
                    if (!string.IsNullOrEmpty(strMaxRating) && !int.TryParse(strMaxRating, out intMaxRating))
                    {
                        strMaxRating = strMaxRating.CheapReplace("MaximumSTR", () => (ParentVehicle != null ? Math.Max(1, ParentVehicle.TotalBody * 2) : _objCharacter.STR.TotalMaximum).ToString())
                                       .CheapReplace("MaximumAGI", () => (ParentVehicle != null ? Math.Max(1, ParentVehicle.Pilot * 2) : _objCharacter.AGI.TotalMaximum).ToString())
                                       .CheapReplace("MinimumSTR", () => (ParentVehicle?.TotalBody ?? 3).ToString())
                                       .CheapReplace("MinimumAGI", () => (ParentVehicle?.Pilot ?? 3).ToString());

                        object objProcess = CommonFunctions.EvaluateInvariantXPath(strMaxRating, out bool blnIsSuccess);
                        intMaxRating = blnIsSuccess ? Convert.ToInt32(objProcess) : 1;
                    }
                    nudRating.Maximum = intMaxRating;
                    if (chkHideOverAvailLimit.Checked)
                    {
                        int intAvailModifier = strForceGrade == "None" ? 0 : _intAvailModifier;
                        while (nudRating.Maximum > intMinRating && !SelectionShared.CheckAvailRestriction(xmlDrug, _objCharacter, decimal.ToInt32(nudRating.Maximum), intAvailModifier))
                        {
                            nudRating.Maximum -= 1;
                        }
                    }

                    if (chkShowOnlyAffordItems.Checked && !chkFree.Checked)
                    {
                        decimal decCostMultiplier = 1 + (nudMarkup.Value / 100.0m);
                        if (chkBlackMarketDiscount.Checked)
                        {
                            decCostMultiplier *= 0.9m;
                        }
                        while (nudRating.Maximum > intMinRating && !SelectionShared.CheckNuyenRestriction(xmlDrug, _objCharacter.Nuyen, decCostMultiplier, decimal.ToInt32(nudRating.Maximum)))
                        {
                            nudRating.Maximum -= 1;
                        }
                    }
                    nudRating.Value          = nudRating.Minimum;
                    nudRating.Enabled        = nudRating.Minimum != nudRating.Maximum;
                    nudRating.Visible        = true;
                    lblRatingNALabel.Visible = false;
                    lblRatingLabel.Visible   = true;
                }
                else
                {
                    lblRatingLabel.Visible   = true;
                    lblRatingNALabel.Visible = true;
                    nudRating.Minimum        = 0;
                    nudRating.Value          = 0;
                    nudRating.Visible        = false;
                }

                string strSource         = xmlDrug.SelectSingleNode("source")?.Value ?? LanguageManager.GetString("String_Unknown", GlobalOptions.Language);
                string strPage           = xmlDrug.SelectSingleNode("altpage")?.Value ?? xmlDrug.SelectSingleNode("page")?.Value ?? LanguageManager.GetString("String_Unknown", GlobalOptions.Language);
                string strSpaceCharacter = LanguageManager.GetString("String_Space", GlobalOptions.Language);
                lblSource.Text = CommonFunctions.LanguageBookShort(strSource, GlobalOptions.Language) + strSpaceCharacter + strPage;
                lblSource.SetToolTip(CommonFunctions.LanguageBookLong(strSource, GlobalOptions.Language) + strSpaceCharacter + LanguageManager.GetString("String_Page", GlobalOptions.Language) + ' ' + strPage);
                lblSourceLabel.Visible = !string.IsNullOrEmpty(lblSource.Text);

                Grade objForcedGrade = null;
                if (!string.IsNullOrEmpty(strForceGrade))
                {
                    // Force the Drug to be a particular Grade.
                    if (cboGrade.Enabled)
                    {
                        cboGrade.Enabled = false;
                    }
                    objForcedGrade = _lstGrades.FirstOrDefault(x => x.Name == strForceGrade);
                    strForceGrade  = objForcedGrade?.SourceId.ToString("D");
                }
                else
                {
                    cboGrade.Enabled = !_blnLockGrade;
                    if (_blnLockGrade)
                    {
                        strForceGrade  = _objForcedGrade?.SourceId.ToString("D") ?? cboGrade.SelectedValue?.ToString();
                        objForcedGrade = _objForcedGrade ?? _lstGrades.FirstOrDefault(x => x.SourceId.ToString("D") == strForceGrade);
                    }
                }

                chkBlackMarketDiscount.Enabled = _objCharacter.BlackMarketDiscount;

                if (!chkBlackMarketDiscount.Checked)
                {
                    chkBlackMarketDiscount.Checked = GlobalOptions.AssumeBlackMarket &&
                                                     _setBlackMarketMaps.Contains(xmlDrug.SelectSingleNode("category")
                                                                                  ?.Value);
                }
                else if (!_setBlackMarketMaps.Contains(xmlDrug.SelectSingleNode("category")?.Value))
                {
                    //Prevent chkBlackMarketDiscount from being checked if the gear category doesn't match.
                    chkBlackMarketDiscount.Checked = false;
                }

                // We may need to rebuild the Grade list since Cultured Bioware is not allowed to select Standard (Second-Hand) as Grade and ForceGrades can change.
                PopulateGrades(xmlDrug.SelectSingleNode("nosecondhand") != null || (!cboGrade.Enabled && objForcedGrade?.SecondHand != true), false, strForceGrade, chkHideBannedGrades.Checked);

                /*
                 * string strNotes = xmlDrug.SelectSingleNode("altnotes")?.Value ?? xmlDrug.SelectSingleNode("notes")?.Value;
                 * if (!string.IsNullOrEmpty(strNotes))
                 * {
                 *  lblDrugNotes.Visible = true;
                 *  lblDrugNotesLabel.Visible = true;
                 *  lblDrugNotes.Text = strNotes;
                 * }
                 * else
                 * {
                 *  lblDrugNotes.Visible = false;
                 *  lblDrugNotesLabel.Visible = false;
                 * }*/
            }
            else
            {
                lblRatingLabel.Visible   = false;
                lblRatingNALabel.Visible = false;
                nudRating.Minimum        = 0;
                nudRating.Value          = 0;
                nudRating.Visible        = false;
                cboGrade.Enabled         = !_blnLockGrade;
                strForceGrade            = string.Empty;
                Grade objForcedGrade = null;
                if (_blnLockGrade)
                {
                    strForceGrade  = _objForcedGrade?.SourceId.ToString("D") ?? cboGrade.SelectedValue?.ToString();
                    objForcedGrade = _objForcedGrade ?? _lstGrades.FirstOrDefault(x => x.SourceId.ToString("D") == strForceGrade);
                }
                PopulateGrades(_blnLockGrade && objForcedGrade?.SecondHand != true, false, strForceGrade, chkHideBannedGrades.Checked);
                chkBlackMarketDiscount.Checked = false;
                lblSourceLabel.Visible         = false;
                lblSource.Text = string.Empty;
                lblSource.SetToolTip(string.Empty);
            }
            _blnLoading = false;
            UpdateDrugInfo();
        }
Beispiel #8
0
        private void UpdateGearInfo()
        {
            if (_blnLoading)
            {
                return;
            }

            XPathNavigator xmlAccessory  = null;
            string         strSelectedId = lstAccessory.SelectedValue?.ToString();

            // Retrieve the information for the selected Accessory.
            if (!string.IsNullOrEmpty(strSelectedId))
            {
                xmlAccessory = _xmlBaseChummerNode.SelectSingleNode("accessories/accessory[id = \"" + strSelectedId + "\"]");
            }
            if (xmlAccessory == null)
            {
                lblRC.Visible            = false;
                lblRCLabel.Visible       = false;
                nudRating.Enabled        = false;
                nudRating.Visible        = false;
                lblRatingLabel.Visible   = false;
                lblRatingNALabel.Visible = false;
                lblMountLabel.Visible    = false;
                cboMount.Visible         = false;
                cboMount.Items.Clear();
                lblExtraMountLabel.Visible = false;
                cboExtraMount.Visible      = false;
                cboExtraMount.Items.Clear();
                lblAvailLabel.Visible  = false;
                lblAvail.Text          = string.Empty;
                lblCostLabel.Visible   = false;
                lblCost.Text           = string.Empty;
                lblTestLabel.Visible   = false;
                lblTest.Text           = string.Empty;
                lblSourceLabel.Visible = false;
                lblSource.Text         = string.Empty;
                lblSource.SetToolTip(string.Empty);
                return;
            }

            string strRC = xmlAccessory.SelectSingleNode("rc")?.Value;

            if (!string.IsNullOrEmpty(strRC))
            {
                lblRC.Visible      = true;
                lblRCLabel.Visible = true;
                lblRC.Text         = strRC;
            }
            else
            {
                lblRC.Visible      = false;
                lblRCLabel.Visible = false;
            }
            if (int.TryParse(xmlAccessory.SelectSingleNode("rating")?.Value, out int intMaxRating) && intMaxRating > 0)
            {
                nudRating.Maximum = intMaxRating;
                if (chkHideOverAvailLimit.Checked)
                {
                    while (nudRating.Maximum > nudRating.Minimum && !SelectionShared.CheckAvailRestriction(xmlAccessory, _objCharacter, decimal.ToInt32(nudRating.Maximum)))
                    {
                        nudRating.Maximum -= 1;
                    }
                }
                if (chkShowOnlyAffordItems.Checked && !chkFreeItem.Checked)
                {
                    decimal decCostMultiplier = 1 + (nudMarkup.Value / 100.0m);
                    if (_setBlackMarketMaps.Contains(xmlAccessory.SelectSingleNode("category")?.Value))
                    {
                        decCostMultiplier *= 0.9m;
                    }
                    while (nudRating.Maximum > nudRating.Minimum && !SelectionShared.CheckNuyenRestriction(xmlAccessory, _objCharacter.Nuyen, decCostMultiplier, decimal.ToInt32(nudRating.Maximum)))
                    {
                        nudRating.Maximum -= 1;
                    }
                }
                nudRating.Enabled        = nudRating.Maximum != nudRating.Minimum;
                nudRating.Visible        = true;
                lblRatingLabel.Visible   = true;
                lblRatingNALabel.Visible = false;
            }
            else
            {
                lblRatingNALabel.Visible = true;
                nudRating.Enabled        = false;
                nudRating.Visible        = false;
                lblRatingLabel.Visible   = true;
            }

            string[]      astrDataMounts = xmlAccessory.SelectSingleNode("mount")?.Value.Split('/');
            List <string> strMounts      = new List <string>();

            if (astrDataMounts != null)
            {
                strMounts.AddRange(astrDataMounts);
            }
            strMounts.Add("None");

            List <string> strAllowed = new List <string>(_lstAllowedMounts)
            {
                "None"
            };

            cboMount.Visible = true;
            cboMount.Items.Clear();
            foreach (string strCurrentMount in strMounts)
            {
                if (!string.IsNullOrEmpty(strCurrentMount))
                {
                    foreach (string strAllowedMount in strAllowed)
                    {
                        if (strCurrentMount == strAllowedMount)
                        {
                            cboMount.Items.Add(strCurrentMount);
                        }
                    }
                }
            }
            cboMount.Enabled       = cboMount.Items.Count > 1;
            cboMount.SelectedIndex = 0;
            lblMountLabel.Visible  = true;

            List <string> strExtraMounts = new List <string>();
            string        strExtraMount  = xmlAccessory.SelectSingleNode("extramount")?.Value;

            if (!string.IsNullOrEmpty(strExtraMount))
            {
                foreach (string strItem in strExtraMount.Split('/'))
                {
                    strExtraMounts.Add(strItem);
                }
            }
            strExtraMounts.Add("None");

            cboExtraMount.Items.Clear();
            foreach (string strCurrentMount in strExtraMounts)
            {
                if (!string.IsNullOrEmpty(strCurrentMount))
                {
                    foreach (string strAllowedMount in strAllowed)
                    {
                        if (strCurrentMount == strAllowedMount)
                        {
                            cboExtraMount.Items.Add(strCurrentMount);
                        }
                    }
                }
            }
            cboExtraMount.Enabled       = cboExtraMount.Items.Count > 1;
            cboExtraMount.SelectedIndex = 0;
            if (cboMount.SelectedItem.ToString() != "None" && cboExtraMount.SelectedItem.ToString() != "None" &&
                cboMount.SelectedItem.ToString() == cboExtraMount.SelectedItem.ToString())
            {
                cboExtraMount.SelectedIndex += 1;
            }
            cboExtraMount.Visible      = cboExtraMount.Enabled && cboExtraMount.SelectedItem.ToString() != "None";
            lblExtraMountLabel.Visible = cboExtraMount.Visible;
            // Avail.
            // If avail contains "F" or "R", remove it from the string so we can use the expression.
            string strSuffix = string.Empty;
            string strAvail  = xmlAccessory.SelectSingleNode("avail")?.Value;

            if (!string.IsNullOrWhiteSpace(strAvail))
            {
                char chrLastAvailChar = strAvail[strAvail.Length - 1];
                if (chrLastAvailChar == 'F')
                {
                    strSuffix = LanguageManager.GetString("String_AvailForbidden", GlobalOptions.Language);
                    strAvail  = strAvail.Substring(0, strAvail.Length - 1);
                }
                else if (chrLastAvailChar == 'R')
                {
                    strSuffix = LanguageManager.GetString("String_AvailRestricted", GlobalOptions.Language);
                    strAvail  = strAvail.Substring(0, strAvail.Length - 1);
                }

                object objProcess = CommonFunctions.EvaluateInvariantXPath(strAvail.Replace("Rating", nudRating.Value.ToString(GlobalOptions.CultureInfo)), out bool blnIsSuccess);
                lblAvail.Text = blnIsSuccess ? Convert.ToInt32(objProcess).ToString() : strAvail + strSuffix;
            }
            else
            {
                lblAvail.Text = "0";
            }
            lblAvailLabel.Visible = !string.IsNullOrEmpty(lblAvail.Text);

            if (!chkFreeItem.Checked)
            {
                string strCost = "0";
                if (xmlAccessory.TryGetStringFieldQuickly("cost", ref strCost))
                {
                    strCost = strCost.CheapReplace("Weapon Cost", () => _objParentWeapon.OwnCost.ToString(GlobalOptions.InvariantCultureInfo))
                              .Replace("Rating", nudRating.Value.ToString(GlobalOptions.CultureInfo));
                }
                if (strCost.StartsWith("Variable("))
                {
                    decimal decMin;
                    decimal decMax = decimal.MaxValue;
                    strCost = strCost.TrimStartOnce("Variable(", true).TrimEndOnce(')');
                    if (strCost.Contains('-'))
                    {
                        string[] strValues = strCost.Split('-');
                        decimal.TryParse(strValues[0], NumberStyles.Any, GlobalOptions.InvariantCultureInfo, out decMin);
                        decimal.TryParse(strValues[1], NumberStyles.Any, GlobalOptions.InvariantCultureInfo, out decMax);
                    }
                    else
                    {
                        decimal.TryParse(strCost.FastEscape('+'), NumberStyles.Any, GlobalOptions.InvariantCultureInfo, out decMin);
                    }

                    if (decMax == decimal.MaxValue)
                    {
                        lblCost.Text = decMin.ToString(_objCharacter.Options.NuyenFormat, GlobalOptions.CultureInfo) + "¥+";
                    }
                    else
                    {
                        lblCost.Text = decMin.ToString(_objCharacter.Options.NuyenFormat, GlobalOptions.CultureInfo) + " - " + decMax.ToString(_objCharacter.Options.NuyenFormat, GlobalOptions.CultureInfo) + '¥';
                    }

                    lblTest.Text = _objCharacter.AvailTest(decMax, lblAvail.Text);
                }
                else
                {
                    object  objProcess = CommonFunctions.EvaluateInvariantXPath(strCost, out bool blnIsSuccess);
                    decimal decCost    = blnIsSuccess ? Convert.ToDecimal(objProcess, GlobalOptions.InvariantCultureInfo) : 0;

                    // Apply any markup.
                    decCost *= 1 + (nudMarkup.Value / 100.0m);

                    if (chkBlackMarketDiscount.Checked)
                    {
                        decCost *= 0.9m;
                    }

                    lblCost.Text = decCost.ToString(_objCharacter.Options.NuyenFormat, GlobalOptions.CultureInfo) + '¥';
                    lblTest.Text = _objCharacter.AvailTest(decCost, lblAvail.Text);
                }
            }
            else
            {
                lblCost.Text = (0.0m).ToString(_objCharacter.Options.NuyenFormat, GlobalOptions.CultureInfo) + '¥';
                lblTest.Text = _objCharacter.AvailTest(0, lblAvail.Text);
            }
            lblCostLabel.Visible           = !string.IsNullOrEmpty(lblCost.Text);
            lblTestLabel.Visible           = !string.IsNullOrEmpty(lblTest.Text);
            chkBlackMarketDiscount.Checked = _blnIsParentWeaponBlackMarketAllowed;
            string strSource         = xmlAccessory.SelectSingleNode("source")?.Value ?? LanguageManager.GetString("String_Unknown", GlobalOptions.Language);
            string strPage           = xmlAccessory.SelectSingleNode("altpage")?.Value ?? xmlAccessory.SelectSingleNode("page")?.Value ?? LanguageManager.GetString("String_Unknown", GlobalOptions.Language);
            string strSpaceCharacter = LanguageManager.GetString("String_Space", GlobalOptions.Language);

            lblSource.Text = CommonFunctions.LanguageBookShort(strSource, GlobalOptions.Language) + strSpaceCharacter + strPage;
            lblSource.SetToolTip(CommonFunctions.LanguageBookLong(strSource, GlobalOptions.Language) + strSpaceCharacter + LanguageManager.GetString("String_Page", GlobalOptions.Language) + strSpaceCharacter + strPage);
            lblSourceLabel.Visible = !string.IsNullOrEmpty(lblSource.Text);
        }
Beispiel #9
0
        /// <summary>
        /// Build the list of available weapon accessories.
        /// </summary>
        private void BuildAccessoryList()
        {
            List <ListItem> lstAccessories = new List <ListItem>();

            // Populate the Accessory list.
            StringBuilder strMount = new StringBuilder("contains(mount, \"Internal\") or contains(mount, \"None\") or mount = \"\"");

            foreach (string strAllowedMount in _lstAllowedMounts)
            {
                if (!string.IsNullOrEmpty(strAllowedMount))
                {
                    strMount.Append(" or contains(mount, \"" + strAllowedMount + "\")");
                }
            }
            strMount.Append(CommonFunctions.GenerateSearchXPath(txtSearch.Text));
            XPathNavigator xmlParentWeaponDataNode = _xmlBaseChummerNode.SelectSingleNode("weapons/weapon[id = \"" + _objParentWeapon.SourceIDString + "\"]");

            foreach (XPathNavigator objXmlAccessory in _xmlBaseChummerNode.Select("accessories/accessory[(" + strMount + ") and (" + _objCharacter.Options.BookXPath() + ")]"))
            {
                string strId = objXmlAccessory.SelectSingleNode("id")?.Value;
                if (string.IsNullOrEmpty(strId))
                {
                    continue;
                }

                XPathNavigator xmlExtraMountNode = objXmlAccessory.SelectSingleNode("extramount");
                if (xmlExtraMountNode != null)
                {
                    if (_lstAllowedMounts.Count > 1)
                    {
                        foreach (string strItem in xmlExtraMountNode.Value.Split('/'))
                        {
                            if (!string.IsNullOrEmpty(strItem) && _lstAllowedMounts.All(strAllowedMount => strAllowedMount != strItem))
                            {
                                goto NextItem;
                            }
                        }
                    }
                }

                if (!objXmlAccessory.RequirementsMet(_objCharacter, _objParentWeapon, string.Empty, string.Empty))
                {
                    continue;
                }

                XPathNavigator xmlTestNode = objXmlAccessory.SelectSingleNode("forbidden/weapondetails");
                if (xmlTestNode != null)
                {
                    // Assumes topmost parent is an AND node
                    if (xmlParentWeaponDataNode.ProcessFilterOperationNode(xmlTestNode, false))
                    {
                        continue;
                    }
                }
                xmlTestNode = objXmlAccessory.SelectSingleNode("required/weapondetails");
                if (xmlTestNode != null)
                {
                    // Assumes topmost parent is an AND node
                    if (!xmlParentWeaponDataNode.ProcessFilterOperationNode(xmlTestNode, false))
                    {
                        continue;
                    }
                }

                decimal decCostMultiplier = 1 + (nudMarkup.Value / 100.0m);
                if (_blnIsParentWeaponBlackMarketAllowed)
                {
                    decCostMultiplier *= 0.9m;
                }
                if ((!chkHideOverAvailLimit.Checked || SelectionShared.CheckAvailRestriction(objXmlAccessory, _objCharacter) &&
                     (chkFreeItem.Checked || !chkShowOnlyAffordItems.Checked ||
                      SelectionShared.CheckNuyenRestriction(objXmlAccessory, _objCharacter.Nuyen, decCostMultiplier))))
                {
                    lstAccessories.Add(new ListItem(strId, objXmlAccessory.SelectSingleNode("translate")?.Value ?? objXmlAccessory.SelectSingleNode("name")?.Value ?? LanguageManager.GetString("String_Unknown", GlobalOptions.Language)));
                }
                NextItem :;
            }

            lstAccessories.Sort(CompareListItems.CompareNames);
            string strOldSelected = lstAccessory.SelectedValue?.ToString();

            _blnLoading = true;
            lstAccessory.BeginUpdate();
            lstAccessory.ValueMember   = "Value";
            lstAccessory.DisplayMember = "Name";
            lstAccessory.DataSource    = lstAccessories;
            _blnLoading = false;
            if (!string.IsNullOrEmpty(strOldSelected))
            {
                lstAccessory.SelectedValue = strOldSelected;
            }
            else
            {
                lstAccessory.SelectedIndex = -1;
            }
            lstAccessory.EndUpdate();
        }
Beispiel #10
0
        private void lstArmor_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (_blnLoading)
            {
                return;
            }

            XmlNode xmlArmor      = null;
            string  strSelectedId = lstArmor.SelectedValue?.ToString();

            if (!string.IsNullOrEmpty(strSelectedId))
            {
                xmlArmor = _objXmlDocument.SelectSingleNode("/chummer/armors/armor[id = \"" + strSelectedId + "\"]");
            }
            if (xmlArmor != null)
            {
                // Create the Armor so we can show its Total Avail (some Armor includes Chemical Seal which adds +6 which wouldn't be factored in properly otherwise).
                Armor         objArmor   = new Armor(_objCharacter);
                List <Weapon> lstWeapons = new List <Weapon>();
                objArmor.Create(xmlArmor, 0, lstWeapons, true, true, true);

                _objSelectedArmor = objArmor;

                string strRating = xmlArmor["rating"]?.InnerText;
                if (!string.IsNullOrEmpty(strRating))
                {
                    nudRating.Maximum = Convert.ToInt32(strRating);
                    if (chkHideOverAvailLimit.Checked)
                    {
                        while (nudRating.Maximum > 1 && !SelectionShared.CheckAvailRestriction(xmlArmor, _objCharacter, decimal.ToInt32(nudRating.Maximum)))
                        {
                            nudRating.Maximum -= 1;
                        }
                    }
                    lblRatingLabel.Visible = true;
                    nudRating.Visible      = true;
                    nudRating.Enabled      = true;
                    nudRating.Minimum      = 1;
                    nudRating.Value        = 1;
                }
                else
                {
                    lblRatingLabel.Visible = false;
                    nudRating.Visible      = false;
                    nudRating.Enabled      = false;
                    nudRating.Minimum      = 0;
                    nudRating.Value        = 0;
                }
            }
            else
            {
                _objSelectedArmor      = null;
                lblRatingLabel.Visible = false;
                nudRating.Visible      = false;
                nudRating.Enabled      = false;
                nudRating.Minimum      = 0;
                nudRating.Value        = 0;
            }

            UpdateArmorInfo();
        }
Beispiel #11
0
        private void BuildWeaponList(XmlNodeList objNodeList)
        {
            SuspendLayout();
            if (tabControl.SelectedIndex == 1)
            {
                DataTable tabWeapons = new DataTable("weapons");
                tabWeapons.Columns.Add("WeaponGuid");
                tabWeapons.Columns.Add("WeaponName");
                tabWeapons.Columns.Add("Dice");
                tabWeapons.Columns.Add("Accuracy");
                tabWeapons.Columns.Add("Damage");
                tabWeapons.Columns.Add("AP");
                tabWeapons.Columns.Add("RC");
                tabWeapons.Columns.Add("Ammo");
                tabWeapons.Columns.Add("Mode");
                tabWeapons.Columns.Add("Reach");
                tabWeapons.Columns.Add("Accessories");
                tabWeapons.Columns.Add("Avail");
                tabWeapons.Columns["Avail"].DataType = typeof(AvailabilityValue);
                tabWeapons.Columns.Add("Source");
                tabWeapons.Columns["Source"].DataType = typeof(SourceString);
                tabWeapons.Columns.Add("Cost");
                tabWeapons.Columns["Cost"].DataType = typeof(NuyenString);

                XmlNode xmlParentWeaponDataNode = _objXmlDocument.SelectSingleNode("/chummer/weapons/weapon[id = \"" + ParentWeapon?.SourceIDString + "\"]");
                foreach (XmlNode objXmlWeapon in objNodeList)
                {
                    if (!objXmlWeapon.CreateNavigator().RequirementsMet(_objCharacter, ParentWeapon))
                    {
                        continue;
                    }

                    XmlNode xmlTestNode = objXmlWeapon.SelectSingleNode("forbidden/weapondetails");
                    if (xmlTestNode != null)
                    {
                        // Assumes topmost parent is an AND node
                        if (xmlParentWeaponDataNode.ProcessFilterOperationNode(xmlTestNode, false))
                        {
                            continue;
                        }
                    }
                    xmlTestNode = objXmlWeapon.SelectSingleNode("required/weapondetails");
                    if (xmlTestNode != null)
                    {
                        // Assumes topmost parent is an AND node
                        if (!xmlParentWeaponDataNode.ProcessFilterOperationNode(xmlTestNode, false))
                        {
                            continue;
                        }
                    }
                    if (objXmlWeapon["cyberware"]?.InnerText == bool.TrueString)
                    {
                        continue;
                    }
                    string strTest = objXmlWeapon["mount"]?.InnerText;
                    if (!string.IsNullOrEmpty(strTest) && !Mounts.Contains(strTest))
                    {
                        continue;
                    }
                    strTest = objXmlWeapon["extramount"]?.InnerText;
                    if (!string.IsNullOrEmpty(strTest) && !Mounts.Contains(strTest))
                    {
                        continue;
                    }
                    if (chkHideOverAvailLimit.Checked && !SelectionShared.CheckAvailRestriction(objXmlWeapon, _objCharacter))
                    {
                        continue;
                    }
                    if (!chkFreeItem.Checked && chkShowOnlyAffordItems.Checked)
                    {
                        decimal decCostMultiplier = 1 + (nudMarkup.Value / 100.0m);
                        if (_setBlackMarketMaps.Contains(objXmlWeapon["category"]?.InnerText))
                        {
                            decCostMultiplier *= 0.9m;
                        }
                        if (!SelectionShared.CheckNuyenRestriction(objXmlWeapon, _objCharacter.Nuyen, decCostMultiplier))
                        {
                            continue;
                        }
                    }

                    Weapon objWeapon = new Weapon(_objCharacter);
                    objWeapon.Create(objXmlWeapon, null, true, false, true);
                    objWeapon.Parent = ParentWeapon;

                    string strID         = objWeapon.SourceIDString;
                    string strWeaponName = objWeapon.CurrentDisplayName;
                    string strDice       = objWeapon.DicePool.ToString(GlobalOptions.CultureInfo);
                    string strAccuracy   = objWeapon.DisplayAccuracy;
                    string strDamage     = objWeapon.DisplayDamage;
                    string strAP         = objWeapon.DisplayTotalAP;
                    if (strAP == "-")
                    {
                        strAP = "0";
                    }
                    string        strRC          = objWeapon.DisplayTotalRC;
                    string        strAmmo        = objWeapon.DisplayAmmo;
                    string        strMode        = objWeapon.DisplayMode;
                    string        strReach       = objWeapon.TotalReach.ToString(GlobalOptions.CultureInfo);
                    StringBuilder sbdAccessories = new StringBuilder();
                    foreach (WeaponAccessory objAccessory in objWeapon.WeaponAccessories)
                    {
                        sbdAccessories.AppendLine(objAccessory.CurrentDisplayName);
                    }
                    if (sbdAccessories.Length > 0)
                    {
                        sbdAccessories.Length -= Environment.NewLine.Length;
                    }
                    AvailabilityValue objAvail  = objWeapon.TotalAvailTuple();
                    SourceString      strSource = new SourceString(objWeapon.Source, objWeapon.DisplayPage(GlobalOptions.Language), GlobalOptions.Language, GlobalOptions.CultureInfo);
                    NuyenString       strCost   = new NuyenString(objWeapon.DisplayCost(out decimal _));

                    tabWeapons.Rows.Add(strID, strWeaponName, strDice, strAccuracy, strDamage, strAP, strRC, strAmmo, strMode, strReach, sbdAccessories.ToString(), objAvail, strSource, strCost);
                }

                DataSet set = new DataSet("weapons");
                set.Tables.Add(tabWeapons);
                string strSelectedCategory = cboCategory.SelectedValue?.ToString();
                if (string.IsNullOrEmpty(strSelectedCategory) ||
                    strSelectedCategory == "Show All" ||
                    !(strSelectedCategory == "Blades" ||
                      strSelectedCategory == "Clubs" ||
                      strSelectedCategory == "Improvised Weapons" ||
                      strSelectedCategory == "Exotic Melee Weapons" ||
                      strSelectedCategory == "Unarmed"))
                {
                    //dgvWeapons.Columns[5].Visible = true;
                    dgvWeapons.Columns[6].Visible = true;
                    dgvWeapons.Columns[7].Visible = true;
                    dgvWeapons.Columns[8].Visible = true;
                }
                else
                {
                    //dgvWeapons.Columns[5].Visible = false;
                    dgvWeapons.Columns[6].Visible = false;
                    dgvWeapons.Columns[7].Visible = false;
                    dgvWeapons.Columns[8].Visible = false;
                }
                dgvWeapons.Columns[0].Visible = false;
                dgvWeapons.Columns[12].DefaultCellStyle.Alignment = DataGridViewContentAlignment.TopRight;
                dgvWeapons.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
                dgvWeapons.DataSource       = set;
                dgvWeapons.DataMember       = "weapons";
            }
            else
            {
                int             intOverLimit            = 0;
                List <ListItem> lstWeapons              = new List <ListItem>();
                XmlNode         xmlParentWeaponDataNode = _objXmlDocument.SelectSingleNode("/chummer/weapons/weapon[id = \"" + ParentWeapon?.SourceIDString + "\"]");
                foreach (XmlNode objXmlWeapon in objNodeList)
                {
                    if (!objXmlWeapon.CreateNavigator().RequirementsMet(_objCharacter, ParentWeapon))
                    {
                        continue;
                    }

                    XmlNode xmlTestNode = objXmlWeapon.SelectSingleNode("forbidden/weapondetails");
                    if (xmlTestNode != null)
                    {
                        // Assumes topmost parent is an AND node
                        if (xmlParentWeaponDataNode.ProcessFilterOperationNode(xmlTestNode, false))
                        {
                            continue;
                        }
                    }
                    xmlTestNode = objXmlWeapon.SelectSingleNode("required/weapondetails");
                    if (xmlTestNode != null)
                    {
                        // Assumes topmost parent is an AND node
                        if (!xmlParentWeaponDataNode.ProcessFilterOperationNode(xmlTestNode, false))
                        {
                            continue;
                        }
                    }
                    if (objXmlWeapon["cyberware"]?.InnerText == bool.TrueString)
                    {
                        continue;
                    }

                    string strMount = objXmlWeapon["mount"]?.InnerText;
                    if (!string.IsNullOrEmpty(strMount) && !Mounts.Contains(strMount))
                    {
                        continue;
                    }

                    string strExtraMount = objXmlWeapon["extramount"]?.InnerText;
                    if (!string.IsNullOrEmpty(strExtraMount) && !Mounts.Contains(strExtraMount))
                    {
                        continue;
                    }

                    if (chkHideOverAvailLimit.Checked && !SelectionShared.CheckAvailRestriction(objXmlWeapon, _objCharacter))
                    {
                        ++intOverLimit;
                        continue;
                    }
                    if (!chkFreeItem.Checked && chkShowOnlyAffordItems.Checked)
                    {
                        decimal decCostMultiplier = 1 + (nudMarkup.Value / 100.0m);
                        if (_setBlackMarketMaps.Contains(objXmlWeapon["category"]?.InnerText))
                        {
                            decCostMultiplier *= 0.9m;
                        }
                        if (!string.IsNullOrEmpty(ParentWeapon?.DoubledCostModificationSlots) &&
                            (!string.IsNullOrEmpty(strMount) || !string.IsNullOrEmpty(strExtraMount)))
                        {
                            string[] astrParentDoubledCostModificationSlots = ParentWeapon.DoubledCostModificationSlots.Split('/', StringSplitOptions.RemoveEmptyEntries);
                            if (astrParentDoubledCostModificationSlots.Contains(strMount) || astrParentDoubledCostModificationSlots.Contains(strExtraMount))
                            {
                                decCostMultiplier *= 2;
                            }
                        }
                        if (!SelectionShared.CheckNuyenRestriction(objXmlWeapon, _objCharacter.Nuyen, decCostMultiplier))
                        {
                            ++intOverLimit;
                            continue;
                        }
                    }
                    lstWeapons.Add(new ListItem(objXmlWeapon["id"]?.InnerText, objXmlWeapon["translate"]?.InnerText ?? objXmlWeapon["name"]?.InnerText));
                }

                lstWeapons.Sort(CompareListItems.CompareNames);
                if (intOverLimit > 0)
                {
                    // Add after sort so that it's always at the end
                    lstWeapons.Add(new ListItem(string.Empty,
                                                string.Format(GlobalOptions.CultureInfo, LanguageManager.GetString("String_RestrictedItemsHidden"),
                                                              intOverLimit)));
                }
                string strOldSelected = lstWeapon.SelectedValue?.ToString();
                _blnLoading = true;
                lstWeapon.BeginUpdate();
                lstWeapon.ValueMember   = nameof(ListItem.Value);
                lstWeapon.DisplayMember = nameof(ListItem.Name);
                lstWeapon.DataSource    = lstWeapons;
                _blnLoading             = false;
                if (!string.IsNullOrEmpty(strOldSelected))
                {
                    lstWeapon.SelectedValue = strOldSelected;
                }
                else
                {
                    lstWeapon.SelectedIndex = -1;
                }
                lstWeapon.EndUpdate();
            }
            ResumeLayout();
        }
        /// <summary>
        /// Build the list of available weapon accessories.
        /// </summary>
        private void BuildAccessoryList()
        {
            List <ListItem> lstAccessories = new List <ListItem>();

            // Populate the Accessory list.
            StringBuilder strMount = new StringBuilder("contains(mount, \"Internal\") or contains(mount, \"None\") or mount = \"\"");

            foreach (string strAllowedMount in _lstAllowedMounts)
            {
                if (!string.IsNullOrEmpty(strAllowedMount))
                {
                    strMount.Append(" or contains(mount, \"" + strAllowedMount + "\")");
                }
            }
            XPathNavigator xmlParentWeaponDataNode = _xmlBaseChummerNode.SelectSingleNode("weapons/weapon[id = \"" + _objParentWeapon.SourceID.ToString("D") + "\"]");

            foreach (XPathNavigator objXmlAccessory in _xmlBaseChummerNode.Select("accessories/accessory[(" + strMount + ") and (" + _objCharacter.Options.BookXPath() + ")]"))
            {
                string strId = objXmlAccessory.SelectSingleNode("id")?.Value;
                if (string.IsNullOrEmpty(strId))
                {
                    continue;
                }

                XPathNavigator xmlExtraMountNode = objXmlAccessory.SelectSingleNode("extramount");
                if (xmlExtraMountNode != null)
                {
                    if (_lstAllowedMounts.Count > 1)
                    {
                        foreach (string strItem in xmlExtraMountNode.Value.Split('/'))
                        {
                            if (!string.IsNullOrEmpty(strItem) && _lstAllowedMounts.All(strAllowedMount => strAllowedMount != strItem))
                            {
                                goto NextItem;
                            }
                        }
                    }
                }

                XPathNavigator xmlTestNode = objXmlAccessory.SelectSingleNode("forbidden/weapondetails");
                if (xmlTestNode != null)
                {
                    // Assumes topmost parent is an AND node
                    if (xmlParentWeaponDataNode.ProcessFilterOperationNode(xmlTestNode, false))
                    {
                        continue;
                    }
                }
                xmlTestNode = objXmlAccessory.SelectSingleNode("required/weapondetails");
                if (xmlTestNode != null)
                {
                    // Assumes topmost parent is an AND node
                    if (!xmlParentWeaponDataNode.ProcessFilterOperationNode(xmlTestNode, false))
                    {
                        continue;
                    }
                }

                xmlTestNode = objXmlAccessory.SelectSingleNode("forbidden/oneof");
                XPathNodeIterator objXmlForbiddenList = xmlTestNode?.Select("accessory");
                if (objXmlForbiddenList?.Count > 0)
                {
                    //Add to set for O(N log M) runtime instead of O(N * M)

                    HashSet <string> objForbiddenAccessory = new HashSet <string>();
                    foreach (XPathNavigator node in objXmlForbiddenList)
                    {
                        objForbiddenAccessory.Add(node.Value);
                    }

                    if (_objParentWeapon.WeaponAccessories.Any(objAccessory =>
                                                               objForbiddenAccessory.Contains(objAccessory.Name)))
                    {
                        continue;
                    }
                }

                xmlTestNode = objXmlAccessory.SelectSingleNode("required/oneof");
                if (xmlTestNode != null)
                {
                    XPathNodeIterator objXmlRequiredList = xmlTestNode.Select("accessory");
                    if (objXmlRequiredList.Count > 0)
                    {
                        //Add to set for O(N log M) runtime instead of O(N * M)

                        HashSet <string> objRequiredAccessory = new HashSet <string>();
                        foreach (XPathNavigator node in objXmlRequiredList)
                        {
                            objRequiredAccessory.Add(node.Value);
                        }

                        if (!_objParentWeapon.WeaponAccessories.Any(objAccessory =>
                                                                    objRequiredAccessory.Contains(objAccessory.Name)))
                        {
                            continue;
                        }
                    }
                    else
                    {
                        continue;
                    }
                }

                if (!chkHideOverAvailLimit.Checked || SelectionShared.CheckAvailRestriction(objXmlAccessory, _objCharacter))
                {
                    lstAccessories.Add(new ListItem(strId, objXmlAccessory.SelectSingleNode("translate")?.Value ?? objXmlAccessory.SelectSingleNode("name")?.Value ?? LanguageManager.GetString("String_Unknown", GlobalOptions.Language)));
                }
                NextItem :;
            }

            lstAccessories.Sort(CompareListItems.CompareNames);
            string strOldSelected = lstAccessory.SelectedValue?.ToString();

            _blnLoading = true;
            lstAccessory.BeginUpdate();
            lstAccessory.ValueMember   = "Value";
            lstAccessory.DisplayMember = "Name";
            lstAccessory.DataSource    = lstAccessories;
            _blnLoading = false;
            if (!string.IsNullOrEmpty(strOldSelected))
            {
                lstAccessory.SelectedValue = strOldSelected;
            }
            else
            {
                lstAccessory.SelectedIndex = -1;
            }
            lstAccessory.EndUpdate();
        }
Beispiel #13
0
        /// <summary>
        /// Builds the list of Armors to render in the active tab.
        /// </summary>
        /// <param name="objXmlArmorList">XmlNodeList of Armors to render.</param>
        private void BuildArmorList(XmlNodeList objXmlArmorList)
        {
            switch (tabControl.SelectedIndex)
            {
            case 1:
                DataTable tabArmor = new DataTable("armor");
                tabArmor.Columns.Add("ArmorGuid");
                tabArmor.Columns.Add("ArmorName");
                tabArmor.Columns.Add("Armor");
                tabArmor.Columns["Armor"].DataType = typeof(int);
                tabArmor.Columns.Add("Capacity");
                tabArmor.Columns["Capacity"].DataType = typeof(decimal);
                tabArmor.Columns.Add("Avail");
                tabArmor.Columns["Avail"].DataType = typeof(AvailabilityValue);
                tabArmor.Columns.Add("Special");
                tabArmor.Columns.Add("Source");
                tabArmor.Columns["Source"].DataType = typeof(SourceString);
                tabArmor.Columns.Add("Cost");
                tabArmor.Columns["Cost"].DataType = typeof(NuyenString);

                // Populate the Armor list.
                foreach (XmlNode objXmlArmor in objXmlArmorList)
                {
                    decimal decCostMultiplier = 1 + (nudMarkup.Value / 100.0m);
                    if (_setBlackMarketMaps.Contains(objXmlArmor["category"]?.InnerText))
                    {
                        decCostMultiplier *= 0.9m;
                    }
                    if (!chkHideOverAvailLimit.Checked ||
                        SelectionShared.CheckAvailRestriction(objXmlArmor, _objCharacter) && (chkFreeItem.Checked ||
                                                                                              !chkShowOnlyAffordItems.Checked ||
                                                                                              SelectionShared.CheckNuyenRestriction(
                                                                                                  objXmlArmor, _objCharacter.Nuyen, decCostMultiplier)))
                    {
                        using (Armor objArmor = new Armor(_objCharacter))
                        {
                            List <Weapon> lstWeapons = new List <Weapon>(1);
                            objArmor.Create(objXmlArmor, 0, lstWeapons, true, true, true);

                            string  strArmorGuid = objArmor.SourceIDString;
                            string  strArmorName = objArmor.CurrentDisplayName;
                            int     intArmor     = objArmor.TotalArmor;
                            decimal decCapacity
                                = Convert.ToDecimal(objArmor.CalculatedCapacity(GlobalSettings.InvariantCultureInfo), GlobalSettings.InvariantCultureInfo);
                            AvailabilityValue objAvail = objArmor.TotalAvailTuple();
                            using (new FetchSafelyFromPool <StringBuilder>(Utils.StringBuilderPool,
                                                                           out StringBuilder sbdAccessories))
                            {
                                foreach (ArmorMod objMod in objArmor.ArmorMods)
                                {
                                    sbdAccessories.AppendLine(objMod.CurrentDisplayName);
                                }

                                foreach (Gear objGear in objArmor.GearChildren)
                                {
                                    sbdAccessories.AppendLine(objGear.CurrentDisplayName);
                                }

                                if (sbdAccessories.Length > 0)
                                {
                                    sbdAccessories.Length -= Environment.NewLine.Length;
                                }
                                SourceString strSource = new SourceString(
                                    objArmor.Source, objArmor.DisplayPage(GlobalSettings.Language),
                                    GlobalSettings.Language, GlobalSettings.CultureInfo, _objCharacter);
                                NuyenString strCost = new NuyenString(objArmor.DisplayCost(out decimal _, false));

                                tabArmor.Rows.Add(strArmorGuid, strArmorName, intArmor, decCapacity, objAvail,
                                                  sbdAccessories.ToString(), strSource, strCost);
                            }
                        }
                    }
                }

                DataSet set = new DataSet("armor");
                set.Tables.Add(tabArmor);

                dgvArmor.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
                dgvArmor.DataSource       = set;
                dgvArmor.DataMember       = "armor";
                break;

            default:
                using (new FetchSafelyFromPool <List <ListItem> >(Utils.ListItemListPool,
                                                                  out List <ListItem> lstArmors))
                {
                    int    intOverLimit = 0;
                    string strSpace     = LanguageManager.GetString("String_Space");
                    foreach (XmlNode objXmlArmor in objXmlArmorList)
                    {
                        decimal decCostMultiplier = 1 + (nudMarkup.Value / 100.0m);
                        if (_setBlackMarketMaps.Contains(objXmlArmor["category"]?.InnerText))
                        {
                            decCostMultiplier *= 0.9m;
                        }
                        if ((!chkHideOverAvailLimit.Checked ||
                             (chkHideOverAvailLimit.Checked &&
                              SelectionShared.CheckAvailRestriction(objXmlArmor, _objCharacter))) &&
                            (chkFreeItem.Checked ||
                             !chkShowOnlyAffordItems.Checked ||
                             (chkShowOnlyAffordItems.Checked &&
                              SelectionShared.CheckNuyenRestriction(
                                  objXmlArmor, _objCharacter.Nuyen, decCostMultiplier))))
                        {
                            string strDisplayName = objXmlArmor["translate"]?.InnerText
                                                    ?? objXmlArmor["name"]?.InnerText;
                            if (!GlobalSettings.SearchInCategoryOnly && txtSearch.TextLength != 0)
                            {
                                string strCategory = objXmlArmor["category"]?.InnerText;
                                if (!string.IsNullOrEmpty(strCategory))
                                {
                                    ListItem objFoundItem
                                        = _lstCategory.Find(objFind => objFind.Value.ToString() == strCategory);
                                    if (!string.IsNullOrEmpty(objFoundItem.Name))
                                    {
                                        strDisplayName += strSpace + '[' + objFoundItem.Name + ']';
                                    }
                                }
                            }

                            lstArmors.Add(new ListItem(objXmlArmor["id"]?.InnerText, strDisplayName));
                        }
                        else
                        {
                            ++intOverLimit;
                        }
                    }

                    lstArmors.Sort(CompareListItems.CompareNames);
                    if (intOverLimit > 0)
                    {
                        // Add after sort so that it's always at the end
                        lstArmors.Add(new ListItem(string.Empty,
                                                   string.Format(GlobalSettings.CultureInfo,
                                                                 LanguageManager.GetString(
                                                                     "String_RestrictedItemsHidden"),
                                                                 intOverLimit)));
                    }

                    _blnLoading = true;
                    string strOldSelected = lstArmor.SelectedValue?.ToString();
                    lstArmor.BeginUpdate();
                    lstArmor.PopulateWithListItems(lstArmors);
                    _blnLoading = false;
                    if (!string.IsNullOrEmpty(strOldSelected))
                    {
                        lstArmor.SelectedValue = strOldSelected;
                    }
                    else
                    {
                        lstArmor.SelectedIndex = -1;
                    }
                    lstArmor.EndUpdate();
                    break;
                }
            }
        }
Beispiel #14
0
        private void lstArmor_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (_blnLoading)
            {
                return;
            }

            XmlNode xmlArmor      = null;
            string  strSelectedId = lstArmor.SelectedValue?.ToString();

            if (!string.IsNullOrEmpty(strSelectedId))
            {
                xmlArmor = _objXmlDocument.SelectSingleNode("/chummer/armors/armor[id = " + strSelectedId.CleanXPath() + ']');
            }
            if (xmlArmor != null)
            {
                // Create the Armor so we can show its Total Avail (some Armor includes Chemical Seal which adds +6 which wouldn't be factored in properly otherwise).
                Armor         objArmor   = new Armor(_objCharacter);
                List <Weapon> lstWeapons = new List <Weapon>(1);
                objArmor.Create(xmlArmor, 0, lstWeapons, true, true, true);

                _objSelectedArmor?.Dispose();
                _objSelectedArmor = objArmor;

                int intRating = 0;
                if (xmlArmor.TryGetInt32FieldQuickly("rating", ref intRating))
                {
                    nudRating.Maximum = intRating;
                    if (chkHideOverAvailLimit.Checked)
                    {
                        while (nudRating.Maximum > 1 && !SelectionShared.CheckAvailRestriction(xmlArmor, _objCharacter, nudRating.MaximumAsInt))
                        {
                            --nudRating.Maximum;
                        }
                    }

                    if (chkShowOnlyAffordItems.Checked && !chkFreeItem.Checked)
                    {
                        decimal decCostMultiplier = 1 + (nudMarkup.Value / 100.0m);
                        if (_setBlackMarketMaps.Contains(xmlArmor.SelectSingleNode("category")?.Value))
                        {
                            decCostMultiplier *= 0.9m;
                        }
                        while (nudRating.Maximum > 1 && !SelectionShared.CheckNuyenRestriction(xmlArmor, _objCharacter.Nuyen, decCostMultiplier, nudRating.MaximumAsInt))
                        {
                            --nudRating.Maximum;
                        }
                    }
                    lblRatingLabel.Visible   = true;
                    nudRating.Minimum        = 1;
                    nudRating.Value          = 1;
                    nudRating.Enabled        = nudRating.Minimum != nudRating.Maximum;
                    nudRating.Visible        = true;
                    lblRatingNALabel.Visible = false;
                }
                else
                {
                    lblRatingLabel.Visible   = true;
                    lblRatingNALabel.Visible = true;
                    nudRating.Minimum        = 0;
                    nudRating.Maximum        = 0;
                    nudRating.Value          = 0;
                    nudRating.Enabled        = false;
                    nudRating.Visible        = false;
                }

                string strRatingLabel = xmlArmor.SelectSingleNode("ratinglabel")?.Value;
                lblRatingLabel.Text = !string.IsNullOrEmpty(strRatingLabel)
                    ? string.Format(GlobalSettings.CultureInfo, LanguageManager.GetString("Label_RatingFormat"),
                                    LanguageManager.GetString(strRatingLabel))
                    : LanguageManager.GetString("Label_Rating");
            }
            else
            {
                _objSelectedArmor?.Dispose();
                _objSelectedArmor        = null;
                lblRatingLabel.Visible   = false;
                lblRatingNALabel.Visible = false;
                nudRating.Visible        = false;
                nudRating.Enabled        = false;
                nudRating.Minimum        = 0;
                nudRating.Value          = 0;
            }

            UpdateArmorInfo();
        }
        /// <summary>
        /// Build the list of available weapon accessories.
        /// </summary>
        private void BuildAccessoryList()
        {
            List <ListItem> lstAccessories = new List <ListItem>();

            // Populate the Accessory list.
            StringBuilder strMount = new StringBuilder("contains(mount, \"Internal\") or contains(mount, \"None\") or mount = \"\"");

            foreach (string strAllowedMount in _lstAllowedMounts)
            {
                if (!string.IsNullOrEmpty(strAllowedMount))
                {
                    strMount.Append(" or contains(mount, \"" + strAllowedMount + "\")");
                }
            }
            XmlNode xmlParentWeaponDataNode = _objParentWeapon.GetNode();

            using (XmlNodeList objXmlAccessoryList = _objXmlDocument.SelectNodes("/chummer/accessories/accessory[(" + strMount + ") and (" + _objCharacter.Options.BookXPath() + ")]"))
                if (objXmlAccessoryList != null)
                {
                    foreach (XmlNode objXmlAccessory in objXmlAccessoryList)
                    {
                        XmlNode xmlExtraMountNode = objXmlAccessory["extramount"];
                        if (xmlExtraMountNode != null)
                        {
                            if (_lstAllowedMounts.Count > 1)
                            {
                                foreach (string strItem in (xmlExtraMountNode.InnerText.Split('/')).Where(strItem => !string.IsNullOrEmpty(strItem)))
                                {
                                    if (_lstAllowedMounts.All(strAllowedMount => strAllowedMount != strItem))
                                    {
                                        goto NextItem;
                                    }
                                }
                            }
                        }

                        XmlNode xmlTestNode = objXmlAccessory.SelectSingleNode("forbidden/weapondetails");
                        if (xmlTestNode != null)
                        {
                            // Assumes topmost parent is an AND node
                            if (xmlParentWeaponDataNode.ProcessFilterOperationNode(xmlTestNode, false))
                            {
                                continue;
                            }
                        }
                        xmlTestNode = objXmlAccessory.SelectSingleNode("required/weapondetails");
                        if (xmlTestNode != null)
                        {
                            // Assumes topmost parent is an AND node
                            if (!xmlParentWeaponDataNode.ProcessFilterOperationNode(xmlTestNode, false))
                            {
                                continue;
                            }
                        }

                        xmlTestNode = objXmlAccessory.SelectSingleNode("forbidden/oneof");
                        if (xmlTestNode != null)
                        {
                            using (XmlNodeList objXmlForbiddenList = xmlTestNode.SelectNodes("accessory"))
                            {
                                if (objXmlForbiddenList != null)
                                {
                                    //Add to set for O(N log M) runtime instead of O(N * M)

                                    HashSet <string> objForbiddenAccessory = new HashSet <string>();
                                    foreach (XmlNode node in objXmlForbiddenList)
                                    {
                                        objForbiddenAccessory.Add(node.InnerText);
                                    }

                                    if (_objParentWeapon.WeaponAccessories.Any(objAccessory =>
                                                                               objForbiddenAccessory.Contains(objAccessory.Name)))
                                    {
                                        continue;
                                    }
                                }
                            }
                        }

                        xmlTestNode = objXmlAccessory.SelectSingleNode("required/oneof");
                        if (xmlTestNode != null)
                        {
                            using (XmlNodeList objXmlRequiredList = xmlTestNode.SelectNodes("accessory"))
                            {
                                if (objXmlRequiredList != null)
                                {
                                    //Add to set for O(N log M) runtime instead of O(N * M)

                                    HashSet <string> objRequiredAccessory = new HashSet <string>();
                                    foreach (XmlNode node in objXmlRequiredList)
                                    {
                                        objRequiredAccessory.Add(node.InnerText);
                                    }

                                    if (!_objParentWeapon.WeaponAccessories.Any(objAccessory =>
                                                                                objRequiredAccessory.Contains(objAccessory.Name)))
                                    {
                                        continue;
                                    }
                                }
                                else
                                {
                                    continue;
                                }
                            }
                        }

                        if (!chkHideOverAvailLimit.Checked || SelectionShared.CheckAvailRestriction(objXmlAccessory, _objCharacter))
                        {
                            lstAccessories.Add(new ListItem(objXmlAccessory["id"]?.InnerText, objXmlAccessory["translate"]?.InnerText ?? objXmlAccessory["name"]?.InnerText ?? string.Empty));
                        }
                        NextItem :;
                    }
                }

            lstAccessories.Sort(CompareListItems.CompareNames);
            string strOldSelected = lstAccessory.SelectedValue?.ToString();

            _blnLoading = true;
            lstAccessory.BeginUpdate();
            lstAccessory.ValueMember   = "Value";
            lstAccessory.DisplayMember = "Name";
            lstAccessory.DataSource    = lstAccessories;
            _blnLoading = false;
            if (!string.IsNullOrEmpty(strOldSelected))
            {
                lstAccessory.SelectedValue = strOldSelected;
            }
            else
            {
                lstAccessory.SelectedIndex = -1;
            }
            lstAccessory.EndUpdate();
        }
        private void UpdateGearInfo()
        {
            if (_blnLoading)
            {
                return;
            }

            XmlNode xmlAccessory  = null;
            string  strSelectedId = lstAccessory.SelectedValue?.ToString();

            // Retrieve the information for the selected Accessory.
            if (!string.IsNullOrEmpty(strSelectedId))
            {
                xmlAccessory = _objXmlDocument.SelectSingleNode("/chummer/accessories/accessory[id = \"" + strSelectedId + "\"]");
            }
            if (xmlAccessory == null)
            {
                lblRC.Visible          = false;
                lblRCLabel.Visible     = false;
                nudRating.Enabled      = false;
                nudRating.Visible      = false;
                lblRatingLabel.Visible = false;
                cboMount.Visible       = false;
                cboMount.Items.Clear();
                cboExtraMount.Visible = false;
                cboExtraMount.Items.Clear();
                lblAvail.Text  = string.Empty;
                lblCost.Text   = string.Empty;
                lblTest.Text   = string.Empty;
                lblSource.Text = string.Empty;
                tipTooltip.SetToolTip(lblSource, string.Empty);
                return;
            }

            string strRC = xmlAccessory["rc"]?.InnerText;

            if (!string.IsNullOrEmpty(strRC))
            {
                lblRC.Visible      = true;
                lblRCLabel.Visible = true;
                lblRC.Text         = strRC;
            }
            else
            {
                lblRC.Visible      = false;
                lblRCLabel.Visible = false;
            }
            if (int.TryParse(xmlAccessory["rating"]?.InnerText, out int intMaxRating) && intMaxRating > 0)
            {
                nudRating.Enabled      = true;
                nudRating.Visible      = true;
                lblRatingLabel.Visible = true;
                nudRating.Maximum      = intMaxRating;
                if (chkHideOverAvailLimit.Checked)
                {
                    while (nudRating.Maximum > nudRating.Minimum && !SelectionShared.CheckAvailRestriction(xmlAccessory, _objCharacter, decimal.ToInt32(nudRating.Maximum)))
                    {
                        nudRating.Maximum -= 1;
                    }
                }
            }
            else
            {
                nudRating.Enabled      = false;
                nudRating.Visible      = false;
                lblRatingLabel.Visible = false;
            }

            string[]      astrDataMounts = xmlAccessory["mount"]?.InnerText.Split('/');
            List <string> strMounts      = new List <string>();

            if (astrDataMounts != null)
            {
                strMounts.AddRange(astrDataMounts);
            }
            strMounts.Add("None");

            List <string> strAllowed = new List <string>(_lstAllowedMounts)
            {
                "None"
            };

            cboMount.Visible = true;
            cboMount.Items.Clear();
            foreach (string strCurrentMount in strMounts)
            {
                if (!string.IsNullOrEmpty(strCurrentMount))
                {
                    foreach (string strAllowedMount in strAllowed)
                    {
                        if (strCurrentMount == strAllowedMount)
                        {
                            cboMount.Items.Add(strCurrentMount);
                        }
                    }
                }
            }
            cboMount.Enabled       = cboMount.Items.Count > 1;
            cboMount.SelectedIndex = 0;

            List <string> strExtraMounts = new List <string>();
            string        strExtraMount  = xmlAccessory["extramount"]?.InnerText;

            if (!string.IsNullOrEmpty(strExtraMount))
            {
                foreach (string strItem in strExtraMount.Split('/'))
                {
                    strExtraMounts.Add(strItem);
                }
            }
            strExtraMounts.Add("None");

            cboExtraMount.Visible = true;
            cboExtraMount.Items.Clear();
            foreach (string strCurrentMount in strExtraMounts)
            {
                if (!string.IsNullOrEmpty(strCurrentMount))
                {
                    foreach (string strAllowedMount in strAllowed)
                    {
                        if (strCurrentMount == strAllowedMount)
                        {
                            cboExtraMount.Items.Add(strCurrentMount);
                        }
                    }
                }
            }
            cboExtraMount.Enabled       = cboExtraMount.Items.Count > 1;
            cboExtraMount.SelectedIndex = 0;
            if (cboMount.SelectedItem.ToString() != "None" && cboExtraMount.SelectedItem.ToString() != "None" &&
                cboMount.SelectedItem.ToString() == cboExtraMount.SelectedItem.ToString())
            {
                cboExtraMount.SelectedIndex += 1;
            }
            // Avail.
            // If avail contains "F" or "R", remove it from the string so we can use the expression.
            string strSuffix = string.Empty;
            string strAvail  = xmlAccessory["avail"]?.InnerText;

            if (!string.IsNullOrWhiteSpace(strAvail))
            {
                char chrLastAvailChar = strAvail[strAvail.Length - 1];
                if (chrLastAvailChar == 'F')
                {
                    strSuffix = LanguageManager.GetString("String_AvailForbidden", GlobalOptions.Language);
                    strAvail  = strAvail.Substring(0, strAvail.Length - 1);
                }
                else if (chrLastAvailChar == 'R')
                {
                    strSuffix = LanguageManager.GetString("String_AvailRestricted", GlobalOptions.Language);
                    strAvail  = strAvail.Substring(0, strAvail.Length - 1);
                }
                try
                {
                    lblAvail.Text = Convert.ToInt32(CommonFunctions.EvaluateInvariantXPath(strAvail.Replace("Rating", nudRating.Value.ToString(GlobalOptions.CultureInfo)))).ToString() + strSuffix;
                }
                catch (XPathException)
                {
                    lblAvail.Text = strAvail + strSuffix;
                }
            }
            else
            {
                lblAvail.Text = string.Empty;
            }
            if (!chkFreeItem.Checked)
            {
                string strCost = "0";
                if (xmlAccessory.TryGetStringFieldQuickly("cost", ref strCost))
                {
                    strCost = strCost.CheapReplace("Weapon Cost", () => _objParentWeapon.OwnCost.ToString(GlobalOptions.InvariantCultureInfo))
                              .Replace("Rating", nudRating.Value.ToString(GlobalOptions.CultureInfo));
                }
                if (strCost.StartsWith("Variable("))
                {
                    decimal decMin;
                    decimal decMax = decimal.MaxValue;
                    strCost = strCost.TrimStart("Variable(", true).TrimEnd(')');
                    if (strCost.Contains('-'))
                    {
                        string[] strValues = strCost.Split('-');
                        decimal.TryParse(strValues[0], NumberStyles.Any, GlobalOptions.InvariantCultureInfo, out decMin);
                        decimal.TryParse(strValues[1], NumberStyles.Any, GlobalOptions.InvariantCultureInfo, out decMax);
                    }
                    else
                    {
                        decimal.TryParse(strCost.FastEscape('+'), NumberStyles.Any, GlobalOptions.InvariantCultureInfo, out decMin);
                    }

                    if (decMax == decimal.MaxValue)
                    {
                        lblCost.Text = decMin.ToString(_objCharacter.Options.NuyenFormat, GlobalOptions.CultureInfo) + "¥+";
                    }
                    else
                    {
                        lblCost.Text = decMin.ToString(_objCharacter.Options.NuyenFormat, GlobalOptions.CultureInfo) + " - " + decMax.ToString(_objCharacter.Options.NuyenFormat, GlobalOptions.CultureInfo) + '¥';
                    }

                    lblTest.Text = _objCharacter.AvailTest(decMax, lblAvail.Text);
                }
                else
                {
                    decimal decCost = 0.0m;
                    try
                    {
                        decCost = Convert.ToDecimal(CommonFunctions.EvaluateInvariantXPath(strCost), GlobalOptions.InvariantCultureInfo);
                    }
                    catch (XPathException)
                    {
                    }

                    // Apply any markup.
                    decCost *= 1 + (nudMarkup.Value / 100.0m);

                    lblCost.Text = decCost.ToString(_objCharacter.Options.NuyenFormat, GlobalOptions.CultureInfo) + '¥';
                    lblTest.Text = _objCharacter.AvailTest(decCost, lblAvail.Text);
                }
            }
            else
            {
                lblCost.Text = (0.0m).ToString(_objCharacter.Options.NuyenFormat, GlobalOptions.CultureInfo) + '¥';
                lblTest.Text = _objCharacter.AvailTest(0, lblAvail.Text);
            }

            /*TODO: Accessories don't use a category mapping, so this doesn't work.
             * if (_blackMarketMaps != null)
             *  chkBlackMarketDiscount.Checked =
             *      _blackMarketMaps.Contains(objXmlAccessory["category"]?.InnerText);
             */
            string strSource = xmlAccessory["source"].InnerText;
            string strPage   = xmlAccessory["altpage"]?.InnerText ?? xmlAccessory["page"].InnerText;

            lblSource.Text = CommonFunctions.LanguageBookShort(strSource, GlobalOptions.Language) + ' ' + strPage;

            tipTooltip.SetToolTip(lblSource, CommonFunctions.LanguageBookLong(strSource, GlobalOptions.Language) + ' ' + LanguageManager.GetString("String_Page", GlobalOptions.Language) + ' ' + strPage);
        }