예제 #1
0
        private void btnKnowledge_Click(object sender, EventArgs e)
        {
            if (_character.Created)
            {
                List <ListItem> lstDefaultKnowledgeSkills = KnowledgeSkill.DefaultKnowledgeSkills(GlobalOptions.Language).ToList();
                lstDefaultKnowledgeSkills.Sort(CompareListItems.CompareNames);
                frmSelectItem form = new frmSelectItem
                {
                    Description   = LanguageManager.GetString("Label_Options_NewKnowledgeSkill", GlobalOptions.Language),
                    DropdownItems = lstDefaultKnowledgeSkills
                };

                if (form.ShowDialog() == DialogResult.OK)
                {
                    KnowledgeSkill skill = new KnowledgeSkill(ObjCharacter)
                    {
                        WriteableName = form.SelectedItem
                    };

                    ObjCharacter.SkillsSection.KnowledgeSkills.Add(skill);
                }
            }
            else
            {
                ObjCharacter.SkillsSection.KnowledgeSkills.Add(new KnowledgeSkill(ObjCharacter));
            }
        }
        private void btnKnowledge_Click(object sender, EventArgs e)
        {
            if (_objCharacter.Created)
            {
                List <ListItem> lstDefaultKnowledgeSkills = KnowledgeSkill.DefaultKnowledgeSkills().ToList();
                lstDefaultKnowledgeSkills.Sort(CompareListItems.CompareNames);
                using (frmSelectItem form = new frmSelectItem
                {
                    Description = LanguageManager.GetString("Label_Options_NewKnowledgeSkill")
                })
                {
                    form.SetDropdownItemsMode(lstDefaultKnowledgeSkills);

                    if (form.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }
                    KnowledgeSkill skill = new KnowledgeSkill(_objCharacter)
                    {
                        WriteableName = form.SelectedItem
                    };

                    _objCharacter.SkillsSection.KnowledgeSkills.Add(skill);
                }
            }
            else
            {
                _objCharacter.SkillsSection.KnowledgeSkills.Add(new KnowledgeSkill(_objCharacter));
            }
        }
예제 #3
0
        private void btnKnowledge_Click(object sender, EventArgs e)
        {
            if (_character.Created)
            {
                frmSelectItem form = new frmSelectItem
                {
                    Description   = LanguageManager.GetString("Label_Options_NewKnowledgeSkill", GlobalOptions.Language),
                    DropdownItems = KnowledgeSkill.DefaultKnowledgeSkills(GlobalOptions.Language)
                };

                if (form.ShowDialog() == DialogResult.OK)
                {
                    KnowledgeSkill skill = new KnowledgeSkill(ObjCharacter)
                    {
                        WriteableName = form.SelectedItem
                    };
                    skill.LoadDefaultType(skill.Name);


                    ObjCharacter.SkillsSection.KnowledgeSkills.Add(skill);
                }
            }
            else
            {
                ObjCharacter.SkillsSection.KnowledgeSkills.Add(new KnowledgeSkill(ObjCharacter));
            }
        }
예제 #4
0
        private void btnKnowledge_Click(object sender, EventArgs e)
        {
            if (_objCharacter.Created)
            {
                using (frmSelectItem form = new frmSelectItem
                {
                    Description = LanguageManager.GetString("Label_Options_NewKnowledgeSkill")
                })
                {
                    form.SetDropdownItemsMode(KnowledgeSkill.DefaultKnowledgeSkills);

                    if (form.ShowDialog(Program.MainForm) != DialogResult.OK)
                    {
                        return;
                    }
                    KnowledgeSkill skill = new KnowledgeSkill(_objCharacter)
                    {
                        WriteableName = form.SelectedItem
                    };

                    if (_objCharacter.SkillsSection.HasAvailableNativeLanguageSlots && (skill.IsLanguage || string.IsNullOrEmpty(skill.Type)))
                    {
                        DialogResult eDialogResult = Program.MainForm.ShowMessageBox(this,
                                                                                     string.Format(GlobalOptions.CultureInfo, LanguageManager.GetString("Message_NewNativeLanguageSkill"),
                                                                                                   1 + ImprovementManager.ValueOf(_objCharacter, Improvement.ImprovementType.NativeLanguageLimit), skill.WriteableName),
                                                                                     LanguageManager.GetString("Tip_Skill_NativeLanguage"), MessageBoxButtons.YesNoCancel);
                        if (eDialogResult == DialogResult.Cancel)
                        {
                            return;
                        }
                        if (eDialogResult == DialogResult.Yes)
                        {
                            if (!skill.IsLanguage)
                            {
                                skill.Type = "Language";
                            }
                            skill.IsNativeLanguage = true;
                        }
                    }

                    _objCharacter.SkillsSection.KnowledgeSkills.Add(skill);
                }
            }
            else
            {
                _objCharacter.SkillsSection.KnowledgeSkills.Add(new KnowledgeSkill(_objCharacter));
            }
        }
예제 #5
0
        private void btnKnowledge_Click(object sender, EventArgs e)
        {
            if (_character.Created)
            {
                frmSelectItem form = new frmSelectItem();
                form.Description   = LanguageManager.Instance.GetString("Label_Options_NewKnowledgeSkill");
                form.DropdownItems = KnowledgeSkill.DefaultKnowledgeSkillCatagories;

                if (form.ShowDialog() == DialogResult.OK)
                {
                    KnowledgeSkill skill = new KnowledgeSkill(ObjCharacter);
                    skill.WriteableName = form.SelectedItem;


                    ObjCharacter.SkillsSection.KnowledgeSkills.Add(skill);
                }
            }
            else
            {
                ObjCharacter.SkillsSection.KnowledgeSkills.Add(new KnowledgeSkill(ObjCharacter));
            }
        }
예제 #6
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"))
            {
                XmlDocument objXmlDocument          = XmlManager.Load("lifestyles.xml");
                XmlNode     objLifestyleQualityNode = GetNode() ??
                                                      objXmlDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + _strName + "\"]");
                if (objLifestyleQualityNode == null)
                {
                    List <ListItem> lstQualities = new List <ListItem>();
                    using (XmlNodeList 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));
                            }
                        }
                    frmSelectItem frmSelect = new frmSelectItem
                    {
                        GeneralItems = lstQualities,
                        Description  = LanguageManager.GetString("String_CannotFindLifestyleQuality", GlobalOptions.Language).Replace("{0}", _strName)
                    };
                    frmSelect.ShowDialog();
                    if (frmSelect.DialogResult == DialogResult.Cancel)
                    {
                        return;
                    }

                    objLifestyleQualityNode = objXmlDocument.SelectSingleNode("/chummer/qualities/quality[id = \"" + frmSelect.SelectedItem + "\"]");
                }
                int    intTemp = 0;
                string 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;
                }
            }
        }
예제 #7
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 <= Version.Parse("5.190.0"))
            {
                XmlDocument objXmlDocument          = XmlManager.Load("lifestyles.xml");
                XmlNode     objLifestyleQualityNode = objXmlDocument.SelectSingleNode("/chummer/qualities/quality[id = \"" + _guiID + "\"]") ??
                                                      objXmlDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + _strName + "\"]");
                if (objLifestyleQualityNode == null)
                {
                    var lstQualities = new List <ListItem>();
                    lstQualities.AddRange(
                        from XmlNode objNode in
                        objXmlDocument.SelectNodes("/chummer/qualities/quality")
                        select new ListItem
                    {
                        Value = objNode["name"].InnerText,
                        Name  = objNode["translate"]?.InnerText ?? objNode["name"].InnerText
                    });
                    var frmSelect = new frmSelectItem
                    {
                        GeneralItems = lstQualities,
                        Description  =
                            LanguageManager.GetString("String_CannotFindLifestyleQuality").Replace("{0}", _strName)
                    };
                    frmSelect.ShowDialog();
                    if (frmSelect.DialogResult == DialogResult.Cancel)
                    {
                        return;
                    }

                    objLifestyleQualityNode = objXmlDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + frmSelect.SelectedItem + "\"]");
                }
                int    intTemp = 0;
                string strTemp = string.Empty;
                if (objLifestyleQualityNode.TryGetStringFieldQuickly("cost", ref strTemp))
                {
                    CostString = strTemp;
                }
                if (objLifestyleQualityNode.TryGetInt32FieldQuickly("lp", ref intTemp))
                {
                    LP = intTemp;
                }
                if (objLifestyleQualityNode.TryGetInt32FieldQuickly("area", ref intTemp))
                {
                    AreaCost = intTemp;
                }
                if (objLifestyleQualityNode.TryGetInt32FieldQuickly("comforts", ref intTemp))
                {
                    ComfortCost = intTemp;
                }
                if (objLifestyleQualityNode.TryGetInt32FieldQuickly("security", ref intTemp))
                {
                    SecurityCost = intTemp;
                }
                if (objLifestyleQualityNode.TryGetInt32FieldQuickly("areaminimum", ref intTemp))
                {
                    AreaMinimum = intTemp;
                }
                if (objLifestyleQualityNode.TryGetInt32FieldQuickly("comfortsminimum", ref intTemp))
                {
                    ComfortMinimum = intTemp;
                }
                if (objLifestyleQualityNode.TryGetInt32FieldQuickly("securityminimum", ref intTemp))
                {
                    SecurityMinimum = intTemp;
                }
                if (objLifestyleQualityNode.TryGetInt32FieldQuickly("multiplier", ref intTemp))
                {
                    Multiplier = intTemp;
                }
                if (objLifestyleQualityNode.TryGetInt32FieldQuickly("multiplierbaseonly", ref intTemp))
                {
                    BaseMultiplier = intTemp;
                }
            }
        }
예제 #8
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;
            }
        }
예제 #9
0
        /// <summary>
        /// Load the CharacterAttribute from the XmlNode.
        /// </summary>
        /// <param name="objNode">XmlNode to load.</param>
        /// <param name="blnCopy"></param>
        public void Load(XmlNode objNode, bool blnCopy = false)
        {
            //Can't out property and no backing field
            if (objNode.TryGetField("sourceid", Guid.TryParse, out Guid source))
            {
                SourceID = source;
            }

            if (blnCopy)
            {
                _guiID         = Guid.NewGuid();
                _intIncrements = 0;
            }
            else
            {
                objNode.TryGetInt32FieldQuickly("months", ref _intIncrements);
                objNode.TryGetField("guid", Guid.TryParse, out _guiID);
            }

            objNode.TryGetStringFieldQuickly("name", ref _strName);
            objNode.TryGetDecFieldQuickly("cost", ref _decCost);
            objNode.TryGetInt32FieldQuickly("dice", ref _intDice);
            objNode.TryGetDecFieldQuickly("multiplier", ref _decMultiplier);

            objNode.TryGetInt32FieldQuickly("area", ref _intArea);
            objNode.TryGetInt32FieldQuickly("comforts", ref _intComforts);
            objNode.TryGetInt32FieldQuickly("security", ref _intSecurity);
            objNode.TryGetInt32FieldQuickly("basearea", ref _intBaseArea);
            objNode.TryGetInt32FieldQuickly("basecomforts", ref _intBaseComforts);
            objNode.TryGetInt32FieldQuickly("basesecurity", ref _intBaseSecurity);
            objNode.TryGetDecFieldQuickly("costforarea", ref _decCostForArea);
            objNode.TryGetDecFieldQuickly("costforcomforts", ref _decCostForComforts);
            objNode.TryGetDecFieldQuickly("costforsecurity", ref _decCostForSecurity);
            objNode.TryGetInt32FieldQuickly("roommates", ref _intRoommates);
            objNode.TryGetDecFieldQuickly("percentage", ref _decPercentage);
            objNode.TryGetStringFieldQuickly("baselifestyle", ref _strBaseLifestyle);
            objNode.TryGetInt32FieldQuickly("sortorder", ref _intSortOrder);
            if (XmlManager.Load("lifestyles.xml").SelectSingleNode($"/chummer/lifestyles/lifestyle[name =\"{_strBaseLifestyle}\"]") == null && XmlManager.Load("lifestyles.xml").SelectSingleNode($"/chummer/lifestyles/lifestyle[name =\"{_strName}\"]") != null)
            {
                string baselifestyle = _strName;
                _strName          = _strBaseLifestyle;
                _strBaseLifestyle = baselifestyle;
            }
            if (string.IsNullOrWhiteSpace(_strBaseLifestyle))
            {
                objNode.TryGetStringFieldQuickly("lifestylename", ref _strBaseLifestyle);
                if (string.IsNullOrWhiteSpace(_strBaseLifestyle))
                {
                    List <ListItem> lstQualities = new List <ListItem>();
                    using (XmlNodeList xmlLifestyleList = XmlManager.Load("lifestyles.xml").SelectNodes("/chummer/lifestyles/lifestyle"))
                        if (xmlLifestyleList != null)
                        {
                            foreach (XmlNode xmlLifestyle in xmlLifestyleList)
                            {
                                string strName = xmlLifestyle["name"]?.InnerText ?? LanguageManager.GetString("String_Error", GlobalOptions.Language);
                                lstQualities.Add(new ListItem(strName, xmlLifestyle["translate"]?.InnerText ?? strName));
                            }
                        }
                    frmSelectItem frmSelect = new frmSelectItem
                    {
                        GeneralItems = lstQualities,
                        Description  = string.Format(LanguageManager.GetString("String_CannotFindLifestyle", GlobalOptions.Language), _strName)
                    };
                    frmSelect.ShowDialog();
                    if (frmSelect.DialogResult == DialogResult.Cancel)
                    {
                        return;
                    }
                    _strBaseLifestyle = frmSelect.SelectedItem;
                }
            }
            if (_strBaseLifestyle == "Middle")
            {
                _strBaseLifestyle = "Medium";
            }
            if (!objNode.TryGetBoolFieldQuickly("allowbonuslp", ref _blnAllowBonusLP))
            {
                GetNode()?.TryGetBoolFieldQuickly("allowbonuslp", ref _blnAllowBonusLP);
            }
            if (!objNode.TryGetInt32FieldQuickly("bonuslp", ref _intBonusLP) && _strBaseLifestyle == "Traveler")
            {
                _intBonusLP = 1 + GlobalOptions.RandomGenerator.NextD6ModuloBiasRemoved();
            }
            objNode.TryGetStringFieldQuickly("source", ref _strSource);
            objNode.TryGetBoolFieldQuickly("trustfund", ref _blnTrustFund);
            if (objNode["primarytenant"] == null)
            {
                _blnIsPrimaryTenant = _intRoommates == 0;
            }
            else
            {
                objNode.TryGetBoolFieldQuickly("primarytenant", ref _blnIsPrimaryTenant);
            }
            objNode.TryGetStringFieldQuickly("page", ref _strPage);

            // Lifestyle Qualities
            using (XmlNodeList xmlQualityList = objNode.SelectNodes("lifestylequalities/lifestylequality"))
                if (xmlQualityList != null)
                {
                    foreach (XmlNode xmlQuality in xmlQualityList)
                    {
                        LifestyleQuality objQuality = new LifestyleQuality(_objCharacter);
                        objQuality.Load(xmlQuality, this);
                        _lstLifestyleQualities.Add(objQuality);
                    }
                }

            // Free Grids provided by the Lifestyle
            using (XmlNodeList xmlQualityList = objNode.SelectNodes("freegrids/lifestylequality"))
                if (xmlQualityList != null)
                {
                    foreach (XmlNode xmlQuality in xmlQualityList)
                    {
                        LifestyleQuality objQuality = new LifestyleQuality(_objCharacter);
                        objQuality.Load(xmlQuality, this);
                        _lstFreeGrids.Add(objQuality);
                    }
                }

            objNode.TryGetStringFieldQuickly("notes", ref _strNotes);

            string strTemp = string.Empty;

            if (objNode.TryGetStringFieldQuickly("type", ref strTemp))
            {
                _eType = ConvertToLifestyleType(strTemp);
            }
            if (objNode.TryGetStringFieldQuickly("increment", ref strTemp))
            {
                _eIncrement = ConvertToLifestyleIncrement(strTemp);
            }
            else if (_eType == LifestyleType.Safehouse)
            {
                _eIncrement = LifestyleIncrement.Week;
            }
            else
            {
                XmlNode xmlLifestyleNode = GetNode();
                if (xmlLifestyleNode != null && xmlLifestyleNode.TryGetStringFieldQuickly("increment", ref strTemp))
                {
                    _eIncrement = ConvertToLifestyleIncrement(strTemp);
                }
            }
            LegacyShim(objNode);
        }
예제 #10
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;
            }
        }
예제 #11
0
        private void btnKnowledge_Click(object sender, EventArgs e)
        {
            if (_character.Created)
            {
                frmSelectItem form = new frmSelectItem();
                form.Description = LanguageManager.Instance.GetString("Label_Options_NewKnowledgeSkill");
                form.DropdownItems = KnowledgeSkill.DefaultKnowledgeSkillCatagories;

                if (form.ShowDialog() == DialogResult.OK)
                {
                    KnowledgeSkill skill = new KnowledgeSkill(ObjCharacter);
                    skill.WriteableName = form.SelectedItem;
                    skill.Karma = 1;
                    _character.Karma -= _character.Options.KarmaNewKnowledgeSkill;

                    ObjCharacter.SkillsSection.KnowledgeSkills.Add(skill);
                }
            }
            else
            {
                ObjCharacter.SkillsSection.KnowledgeSkills.Add(new KnowledgeSkill(ObjCharacter));
            }
        }
예제 #12
0
        /// <summary>
        /// Load the CharacterAttribute from the XmlNode.
        /// </summary>
        /// <param name="objNode">XmlNode to load.</param>
        /// <param name="blnCopy"></param>
        public void Load(XmlNode objNode, bool blnCopy = false)
        {
            //Can't out property and no backing field
            if (objNode.TryGetField("sourceid", Guid.TryParse, out Guid source))
            {
                SourceID = source;
            }

            if (blnCopy)
            {
                _guiID     = Guid.NewGuid();
                _intMonths = 0;
            }
            else
            {
                objNode.TryGetInt32FieldQuickly("months", ref _intMonths);
                objNode.TryGetField("guid", Guid.TryParse, out _guiID);
            }

            objNode.TryGetStringFieldQuickly("name", ref _strName);
            objNode.TryGetDecFieldQuickly("cost", ref _decCost);
            objNode.TryGetInt32FieldQuickly("dice", ref _intDice);
            objNode.TryGetDecFieldQuickly("multiplier", ref _decMultiplier);

            objNode.TryGetInt32FieldQuickly("area", ref _intArea);
            objNode.TryGetInt32FieldQuickly("comforts", ref _intComforts);
            objNode.TryGetInt32FieldQuickly("security", ref _intSecurity);
            objNode.TryGetInt32FieldQuickly("basearea", ref _intBaseArea);
            objNode.TryGetInt32FieldQuickly("basecomforts", ref _intBaseComforts);
            objNode.TryGetInt32FieldQuickly("basesecurity", ref _intBaseSecurity);
            objNode.TryGetInt32FieldQuickly("costforarea", ref _costForArea);
            objNode.TryGetInt32FieldQuickly("costforcomforts", ref _costForComforts);
            objNode.TryGetInt32FieldQuickly("costforsecurity", ref _costForSecurity);
            objNode.TryGetInt32FieldQuickly("roommates", ref _intRoommates);
            objNode.TryGetDecFieldQuickly("percentage", ref _decPercentage);
            objNode.TryGetBoolFieldQuickly("purchased", ref _blnPurchased);
            objNode.TryGetStringFieldQuickly("baselifestyle", ref _strBaseLifestyle);
            if (string.IsNullOrWhiteSpace(_strBaseLifestyle))
            {
                objNode.TryGetStringFieldQuickly("lifestylename", ref _strBaseLifestyle);
                if (string.IsNullOrWhiteSpace(_strBaseLifestyle))
                {
                    XmlDocument objXmlDocument = XmlManager.Load("lifestyles.xml");
                    var         lstQualities   = new List <ListItem>();
                    foreach (XmlNode n in objXmlDocument.SelectNodes("/chummer/lifestyles/lifestyle"))
                    {
                        string strName = n["name"].InnerText;
                        lstQualities.Add(new ListItem(strName, n["translate"]?.InnerText ?? strName));
                    }
                    var frmSelect = new frmSelectItem
                    {
                        GeneralItems = lstQualities,
                        Description  = LanguageManager.GetString("String_CannotFindLifestyle", GlobalOptions.Language).Replace("{0}", _strName)
                    };
                    frmSelect.ShowDialog();
                    if (frmSelect.DialogResult == DialogResult.Cancel)
                    {
                        return;
                    }
                    _strBaseLifestyle = frmSelect.SelectedItem;
                }
            }
            if (_strBaseLifestyle == "Middle")
            {
                _strBaseLifestyle = "Medium";
            }
            objNode.TryGetStringFieldQuickly("source", ref _strSource);
            objNode.TryGetBoolFieldQuickly("trustfund", ref _blnTrustFund);
            if (objNode["primarytenant"] == null)
            {
                _primaryTenant = _intRoommates == 0;
            }
            else
            {
                objNode.TryGetBoolFieldQuickly("primarytenant", ref _primaryTenant);
            }
            objNode.TryGetStringFieldQuickly("page", ref _strPage);

            // Lifestyle Qualities
            var objXmlNodeList = objNode.SelectNodes("lifestylequalities/lifestylequality");

            if (objXmlNodeList != null)
            {
                foreach (XmlNode objXmlQuality in objXmlNodeList)
                {
                    var objQuality = new LifestyleQuality(_objCharacter);
                    objQuality.Load(objXmlQuality, this);
                    _lstLifestyleQualities.Add(objQuality);
                }
            }

            // Free Grids provided by the Lifestyle
            objXmlNodeList = objNode.SelectNodes("freegrids/lifestylequality");
            if (objXmlNodeList != null)
            {
                foreach (XmlNode objXmlQuality in objXmlNodeList)
                {
                    var objQuality = new LifestyleQuality(_objCharacter);
                    objQuality.Load(objXmlQuality, this);
                    FreeGrids.Add(objQuality);
                }
            }

            objNode.TryGetStringFieldQuickly("notes", ref _strNotes);

            var strtemp = string.Empty;

            if (objNode.TryGetStringFieldQuickly("type", ref strtemp))
            {
                _objType = ConverToLifestyleType(strtemp);
            }
            LegacyShim(objNode);
        }