Пример #1
0
        /// <summary>
        ///     Performs actions based on the character's last loaded AppVersion attribute.
        /// </summary>
        private void LegacyShim()
        {
            //Unstored Cost and LP values prior to 5.190.2 nightlies.
            if (_objCharacter.LastSavedVersion > new Version(5, 190, 0))
            {
                return;
            }
            XPathNavigator objXmlDocument          = _objCharacter.LoadDataXPath("lifestyles.xml");
            XPathNavigator objLifestyleQualityNode = GetNode()?.CreateNavigator()
                                                     ?? objXmlDocument.SelectSingleNode("/chummer/qualities/quality[name = " + Name.CleanXPath() + "]");

            if (objLifestyleQualityNode == null)
            {
                List <ListItem> lstQualities = new List <ListItem>(1);
                foreach (XPathNavigator xmlNode in objXmlDocument.Select("/chummer/qualities/quality"))
                {
                    lstQualities.Add(new ListItem(xmlNode.SelectSingleNode("id")?.Value,
                                                  xmlNode.SelectSingleNode("translate")?.Value ?? xmlNode.SelectSingleNode("name")?.Value));
                }

                using (frmSelectItem frmSelect = new frmSelectItem
                {
                    Description = string.Format(GlobalOptions.CultureInfo, LanguageManager.GetString("String_intCannotFindLifestyleQuality"), _strName)
                })
                {
                    frmSelect.SetGeneralItemsMode(lstQualities);
                    if (frmSelect.ShowDialog(Program.MainForm) == DialogResult.Cancel)
                    {
                        _guiID = Guid.Empty;
                        return;
                    }

                    objLifestyleQualityNode =
                        objXmlDocument.SelectSingleNode("/chummer/qualities/quality[id = " + frmSelect.SelectedItem.CleanXPath() + "]");
                }
            }

            var intTemp = 0;
            var strTemp = string.Empty;

            if (objLifestyleQualityNode.TryGetStringFieldQuickly("cost", ref strTemp))
            {
                CostString = strTemp;
            }
            if (objLifestyleQualityNode.TryGetInt32FieldQuickly("lp", ref intTemp))
            {
                LP = intTemp;
            }
            if (objLifestyleQualityNode.TryGetInt32FieldQuickly("areamaximum", ref intTemp))
            {
                AreaMaximum = intTemp;
            }
            if (objLifestyleQualityNode.TryGetInt32FieldQuickly("comfortsmaximum", ref intTemp))
            {
                ComfortMaximum = intTemp;
            }
            if (objLifestyleQualityNode.TryGetInt32FieldQuickly("securitymaximum", ref intTemp))
            {
                SecurityMaximum = intTemp;
            }
            if (objLifestyleQualityNode.TryGetInt32FieldQuickly("area", ref intTemp))
            {
                Area = intTemp;
            }
            if (objLifestyleQualityNode.TryGetInt32FieldQuickly("comforts", ref intTemp))
            {
                Comfort = intTemp;
            }
            if (objLifestyleQualityNode.TryGetInt32FieldQuickly("security", ref intTemp))
            {
                Security = intTemp;
            }
            if (objLifestyleQualityNode.TryGetInt32FieldQuickly("multiplier", ref intTemp))
            {
                Multiplier = intTemp;
            }
            if (objLifestyleQualityNode.TryGetInt32FieldQuickly("multiplierbaseonly", ref intTemp))
            {
                BaseMultiplier = intTemp;
            }
        }
Пример #2
0
        /// <summary>
        ///     Performs actions based on the character's last loaded AppVersion attribute.
        /// </summary>
        private void LegacyShim()
        {
            //Unstored Cost and LP values prior to 5.190.2 nightlies.
            if (_objCharacter.LastSavedVersion > new Version(5, 190, 0))
            {
                return;
            }
            var objXmlDocument          = XmlManager.Load("lifestyles.xml");
            var objLifestyleQualityNode = GetNode() ??
                                          objXmlDocument.SelectSingleNode(
                "/chummer/qualities/quality[name = \"" + _strName + "\"]");

            if (objLifestyleQualityNode == null)
            {
                List <ListItem> lstQualities = new List <ListItem>(1);
                using (var xmlQualityList = objXmlDocument.SelectNodes("/chummer/qualities/quality"))
                {
                    if (xmlQualityList != null)
                    {
                        foreach (XmlNode xmlNode in xmlQualityList)
                        {
                            lstQualities.Add(new ListItem(xmlNode["id"]?.InnerText,
                                                          xmlNode["translate"]?.InnerText ?? xmlNode["name"]?.InnerText));
                        }
                    }
                }

                using (frmSelectItem frmSelect = new frmSelectItem
                {
                    Description = string.Format(GlobalOptions.CultureInfo, LanguageManager.GetString("String_intCannotFindLifestyleQuality"), _strName)
                })
                {
                    frmSelect.SetGeneralItemsMode(lstQualities);
                    frmSelect.ShowDialog(Program.MainForm);
                    if (frmSelect.DialogResult == DialogResult.Cancel)
                    {
                        return;
                    }

                    objLifestyleQualityNode =
                        objXmlDocument.SelectSingleNode("/chummer/qualities/quality[id = \"" + frmSelect.SelectedItem +
                                                        "\"]");
                }
            }

            var intTemp = 0;
            var strTemp = string.Empty;

            if (objLifestyleQualityNode.TryGetStringFieldQuickly("cost", ref strTemp))
            {
                CostString = strTemp;
            }
            if (objLifestyleQualityNode.TryGetInt32FieldQuickly("lp", ref intTemp))
            {
                LP = intTemp;
            }
            if (objLifestyleQualityNode.TryGetInt32FieldQuickly("areamaximum", ref intTemp))
            {
                AreaMaximum = intTemp;
            }
            if (objLifestyleQualityNode.TryGetInt32FieldQuickly("comfortsmaximum", ref intTemp))
            {
                ComfortMaximum = intTemp;
            }
            if (objLifestyleQualityNode.TryGetInt32FieldQuickly("securitymaximum", ref intTemp))
            {
                SecurityMaximum = intTemp;
            }
            if (objLifestyleQualityNode.TryGetInt32FieldQuickly("area", ref intTemp))
            {
                Area = intTemp;
            }
            if (objLifestyleQualityNode.TryGetInt32FieldQuickly("comforts", ref intTemp))
            {
                Comfort = intTemp;
            }
            if (objLifestyleQualityNode.TryGetInt32FieldQuickly("security", ref intTemp))
            {
                Security = intTemp;
            }
            if (objLifestyleQualityNode.TryGetInt32FieldQuickly("multiplier", ref intTemp))
            {
                Multiplier = intTemp;
            }
            if (objLifestyleQualityNode.TryGetInt32FieldQuickly("multiplierbaseonly", ref intTemp))
            {
                BaseMultiplier = intTemp;
            }
        }