public static int GetEffectiveLevelItem(string[] ItemParts, int Quality, int LevelIndex)
        {
            if (LevelIndex != 0)
            {
                return(LevelIndex - 2);
            }

            string Manufacturer = ItemParts[6].After("gd_manufacturers.Manufacturers.");
            //            string Manufacturer = GetPartAttribute(WeaponParts[6], "Manufacturer").TrimEnd();
            string LevelIndexText = GetPartAttribute(ItemParts[0], Manufacturer + Quality);

            return(Parse.AsInt(LevelIndexText, 2) - 2);
        }
        //public class InventoryComparer : Comparer<InventoryEntry>
        //{
        //    public int[] comparisons;

        //    public InventoryComparer(int[] comparisonarray)
        //    {
        //        comparisons = comparisonarray;
        //    }

        //    public override int Compare(InventoryEntry x, InventoryEntry y)
        //    {
        //        int result = 0;
        //        foreach (int comparison in comparisons)
        //        {
        //            switch (comparison)
        //            {
        //                case 0: result = string.Compare(x.Name, y.Name); break;
        //                case 1:
        //                    if (x.Rarity > y.Rarity)
        //                        result = -1;
        //                    else if (x.Rarity < y.Rarity)
        //                        result = 1;
        //                    else
        //                        result = 0;
        //                    break;
        //                case 2: result = string.Compare(x.Category, y.Category); break;
        //                case 3: result = string.Compare(x.NameParts[3], y.NameParts[3]); break;
        //                case 4: result = string.Compare(x.NameParts[2], y.NameParts[2]); break;
        //                case 5: result = string.Compare(x.NameParts[1], y.NameParts[1]); break;
        //                case 6: result = string.Compare(x.NameParts[0], y.NameParts[0]); break;
        //                case 7:
        //                    if (x.Level > y.Level)
        //                        result = -1;
        //                    else if (x.Level < y.Level)
        //                        result = 1;
        //                    else
        //                        result = 0;
        //                    break;
        //                case 8:
        //                    int xkeyval = int.Parse(x.Key);
        //                    int ykeyval = int.Parse(y.Key);
        //                    if (xkeyval > ykeyval)
        //                        result = -1;
        //                    else if (xkeyval < ykeyval)
        //                        result = 1;
        //                    else
        //                        result = 0;
        //                    break;
        //            }
        //            if (result != 0)
        //                return result;
        //        }
        //        return result;
        //    }
        //}
        //InventoryComparer CategoryNameComparison = new InventoryComparer(new int[] { 2, 0, 8 });
        //InventoryComparer CategoryRarityLevelComparison = new InventoryComparer(new int[] { 2, 1, 7, 8 });
        //InventoryComparer CategoryTitlePrefixModelComparison = new InventoryComparer(new int[] { 2, 3, 4, 5, 8 });
        //InventoryComparer CategoryLevelNameComparison = new InventoryComparer(new int[] { 2, 7, 0, 8 });
        //InventoryComparer NameComparison = new InventoryComparer(new int[] { 0, 8 });
        //InventoryComparer RarityLevelComparison = new InventoryComparer(new int[] { 1, 7, 8 });
        //InventoryComparer TitlePrefixModelComparison = new InventoryComparer(new int[] { 2, 3, 4, 5, 8 });
        //InventoryComparer LevelNameComparison = new InventoryComparer(new int[] { 7, 0, 8 });

        //public class InventoryComparisonIterator
        //{
        //    public int ComparerIndex;
        //    public InventoryComparer[] Comparers;
        //    public InventoryComparisonIterator(InventoryComparer[] comparers)
        //    {
        //        Comparers = comparers;
        //    }
        //    public void NextComparer()
        //    {
        //        ComparerIndex++;
        //        if (ComparerIndex >= Comparers.Length)
        //            ComparerIndex = 0;
        //    }
        //    public void PreviousComparer()
        //    {
        //        ComparerIndex++;
        //        if (ComparerIndex >= Comparers.Length)
        //            ComparerIndex = 0;
        //    }
        //    public InventoryComparer CurrentComparer()
        //    {
        //        return Comparers[ComparerIndex];
        //    }
        //}

        public static int GetEffectiveLevelWeapon(string[] WeaponParts, int Quality, int LevelIndex)
        {
            if (LevelIndex != 0)
            {
                return(LevelIndex - 2);
            }

            //            string Manufacturer = GetPartAttribute(WeaponParts[1], "Manufacturer").TrimEnd();
            // There may be a case below where the manufacturer is invalid or blank
            string Manufacturer   = WeaponParts[1].After("gd_manufacturers.Manufacturers.");
            string LevelIndexText = GetPartAttribute(WeaponParts[0], Manufacturer + Quality);

            return(Parse.AsInt(LevelIndexText, 2) - 2);
        }
        static public void Load()
        {
            string filename = db.XmlPath + "options.xml";

            if (!System.IO.File.Exists(filename))
            {
                return;
            }
            using (XmlTextReader gs = new XmlTextReader(filename))
            {
                gs.XmlResolver = null;
                while (gs.Read())
                {
                    if (gs.NodeType == XmlNodeType.Element)
                    {
                        switch (gs.Name)
                        {
                        case "InputMode":
                            string InputModeText = gs.ReadElementContentAsString();
                            if (InputModeText == "Advanced")
                            {
                                InputMode = InputMode.Advanced;
                            }
                            else if (InputModeText == "Standard")
                            {
                                InputMode = InputMode.Standard;
                            }
                            break;

                        case "UseHexInAdvancedMode": XmlReadBool(gs, ref UseHexInAdvancedMode); break;

                        case "PartSelectorTracking": XmlReadBool(gs, ref PartSelectorTracking); break;

                        case "ShowManufacturer": XmlReadBool(gs, ref ShowManufacturer); break;

                        case "ShowRarity": XmlReadBool(gs, ref ShowRarity); break;

                        case "ShowLevel": XmlReadBool(gs, ref ShowLevel); break;

                        case "UseColor": XmlReadBool(gs, ref UseColor); break;

                        case "autoSaveItems": XmlReadBool(gs, ref autoSaveItems); break;

                        case "backupSaves": XmlReadBool(gs, ref backupSaves); break;

                        case "lastLockerFile": db.OpenedLockerFilename(gs.ReadElementContentAsString()); break;

                        case "customCharacters": XmlReadDict(gs, ref customCharacters); break;

                        case "MaxCash": XmlReadInt(gs, ref MaxCash); break;

                        case "MaxLevel": XmlReadInt(gs, ref MaxLevel); break;

                        case "MaxExperience": XmlReadInt(gs, ref MaxExperience); break;

                        case "MaxInventorySlots": XmlReadInt(gs, ref MaxBackpackSlots); break;

                        case "MaxBankSlots": XmlReadInt(gs, ref MaxBankSlots); break;

                        case "MaxSkillPoints": XmlReadInt(gs, ref MaxSkillPoints); break;

                        case "RarityColor0":
                        case "RarityColor1":
                        case "RarityColor2":
                        case "RarityColor3":
                        case "RarityColor4":
                        case "RarityColor5":
                        case "RarityColor6":
                        case "RarityColor7":
                        case "RarityColor8":
                        case "RarityColor9":
                        case "RarityColor10":
                        case "RarityColor11":
                            try
                            {
                                int    index = Parse.AsInt(gs.Name.After("RarityColor"));
                                uint   colorval;
                                string text = gs.ReadElementContentAsString();
                                if (uint.TryParse(text, System.Globalization.NumberStyles.HexNumber, System.Globalization.CultureInfo.InvariantCulture, out colorval))
                                {
                                    GlobalSettings.RarityColor[index] = Color.FromArgb((int)colorval);
                                }
                            }
                            catch { }
                            break;
                        }
                    }
                }
            }
        }
        public static int GetPartRarity(string part)
        {
            string ComponentText = GetPartAttribute(part, "Rarity");

            return(Parse.AsInt(ComponentText, null));
        }
        // 5 references - Fetch the PartNumberAddend attribute of a part
        public static int GetPartNumber(string part)
        {
            string ComponentText = GetPartAttribute(part, "PartNumberAddend");

            return(Parse.AsInt(ComponentText, null));
        }
        // 0 references - Compose the full name of an item from its parts (list vesion)
        // OBSOLETE - Nothing uses this.  It couid be removed.
        public static string GetItemNameFast(List <string> parts)
        {
            // This version uses the higher performance GetName function to fetch
            // part names from the NameLookup dictionary.
            string Name   = GetName(parts[8]);
            string Prefix = GetName(parts[7]);

            if ((Name == "") && (Prefix == ""))
            {
                Name = GetName(parts[1]);
                if (Name == "")
                {
                    return("Unknown Item");
                }
                return(Name);
            }

            string MfgText;

            if (GlobalSettings.ShowManufacturer)
            {
                MfgText = GetName(parts[6]); // Mfg Name
                if (MfgText == "")
                {
                    MfgText = GetPartAttribute(parts[1], "NoManufacturerName");
                }
            }
            else
            {
                MfgText = "";
            }

            string BodyText     = GetName(parts[5]);    // Right text
            string MaterialText = GetName(parts[2]);    // Material text

            int Model = Parse.AsInt(GetName(parts[3])); // ModelNumber text

            Model += Parse.AsInt(GetName(parts[4]));    //
            //            if ((GetPartRarity(parts[3]) == 0) || (GetPartRarity(parts[4]) == 0))
            //                Model = Model / 10;
            if ((GetPartRarity(parts[3]) != 0) && (GetPartRarity(parts[4]) != 0))
            {
                Model = Model * 10;
            }
            string ModelText = (Model != 0 ? Model.ToString() : "");

            string ModelName = BodyText + ModelText + MaterialText;

            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            if (MfgText != "")
            {
                sb.Append(MfgText);
                sb.Append(' ');
            }

            if (ModelName != "")
            {
                sb.Append(ModelName);
                sb.Append(' ');
            }

            if (Prefix != "")
            {
                sb.Append(Prefix);
                sb.Append(' ');
            }

            sb.Append(Name);

            return(sb.ToString());
        }
        // 1 references - Compose the full name of a item from its parts (list version)
        // OBSOLETE - Nothing uses this.  It couid be removed.
        public static string GetWeaponNameFast(List <string> parts)
        {
            // This version uses the higher performance GetName function to fetch
            // part names from the NameLookup dictionary.
            string Name   = GetName(parts[13]);
            string Prefix = GetName(parts[12]);

            string MfgText;

            if (GlobalSettings.ShowManufacturer)
            {
                MfgText = GetName(parts[1]); // Mfg Name
                if (MfgText == "")
                {
                    MfgText = "Generic";
                }
            }
            else
            {
                MfgText = "";
            }

            string BodyText     = GetName(parts[3]);       // Body text
            string MaterialText = GetName(parts[11]);      // Material text

            int Model = Parse.AsInt(GetName(parts[8]), 0); // Number from stock

            Model += Parse.AsInt(GetName(parts[5]), 0);    // Number from mag
            //            if ((GetPartRarity(parts[8]) == 0) || (GetPartRarity(parts[5]) == 0))
            //                Model = Model / 10;
            if ((GetPartRarity(parts[8]) != 0) && (GetPartRarity(parts[5]) != 0))
            {
                Model = Model * 10;
            }
            string ModelText = (Model != 0 ? Model.ToString() : "");

            string ModelName = BodyText + ModelText + MaterialText;

            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            if (MfgText != "")
            {
                sb.Append(MfgText);
                sb.Append(' ');
            }

            if (ModelName != "")
            {
                sb.Append(ModelName);
                sb.Append(' ');
            }

            if (Prefix != "")
            {
                sb.Append(Prefix);
                sb.Append(' ');
            }

            sb.Append(Name);

            return(sb.ToString());
        }