/// <summary> /// Print the object's XML to the XmlWriter. /// </summary> /// <param name="objWriter">XmlTextWriter to write with.</param> /// <param name="objCulture">Culture in which to print.</param> /// <param name="strLanguageToPrint">Language in which to print</param> public void Print(XmlTextWriter objWriter, CultureInfo objCulture, string strLanguageToPrint) { if (objWriter == null) { return; } objWriter.WriteStartElement("metamagic"); objWriter.WriteElementString("guid", InternalId); objWriter.WriteElementString("sourceid", SourceIDString); objWriter.WriteElementString("name", DisplayNameShort(strLanguageToPrint)); objWriter.WriteElementString("fullname", DisplayName(strLanguageToPrint)); objWriter.WriteElementString("name_english", Name); objWriter.WriteElementString("source", CommonFunctions.LanguageBookShort(Source, strLanguageToPrint)); objWriter.WriteElementString("page", DisplayPage(strLanguageToPrint)); objWriter.WriteElementString("grade", Grade.ToString(objCulture)); objWriter.WriteElementString("improvementsource", _eImprovementSource.ToString()); if (_objCharacter.Options.PrintNotes) { objWriter.WriteElementString("notes", Notes); } objWriter.WriteEndElement(); }
/// <summary> /// Print the object's XML to the XmlWriter. /// </summary> /// <param name="objWriter">XmlTextWriter to write with.</param> /// <param name="objCulture">Culture in which to print.</param> /// <param name="strLanguageToPrint">Language in which to print</param> public void Print(XmlTextWriter objWriter, CultureInfo objCulture, string strLanguageToPrint) { objWriter.WriteStartElement("martialart"); objWriter.WriteElementString("name", DisplayNameShort(strLanguageToPrint)); objWriter.WriteElementString("fullname", DisplayName(strLanguageToPrint)); objWriter.WriteElementString("name_english", Name); objWriter.WriteElementString("source", CommonFunctions.LanguageBookShort(Source, strLanguageToPrint)); objWriter.WriteElementString("page", DisplayPage(strLanguageToPrint)); objWriter.WriteElementString("rating", Rating.ToString(objCulture)); objWriter.WriteElementString("cost", Cost.ToString(objCulture)); objWriter.WriteStartElement("martialarttechniques"); foreach (MartialArtTechnique objAdvantage in Techniques) { objAdvantage.Print(objWriter, strLanguageToPrint); } objWriter.WriteEndElement(); if (_objCharacter.Options.PrintNotes) { objWriter.WriteElementString("notes", Notes); } objWriter.WriteEndElement(); }
private void lstPrograms_SelectedIndexChanged(object sender, EventArgs e) { string strSelectedComplexFormId = lstPrograms.SelectedValue?.ToString(); if (string.IsNullOrEmpty(strSelectedComplexFormId)) { lblDuration.Text = string.Empty; lblSource.Text = string.Empty; lblFV.Text = string.Empty; tipTooltip.SetToolTip(lblSource, string.Empty); return; } // Display the Program information. XmlNode objXmlProgram = _objXmlDocument.SelectSingleNode("/chummer/complexforms/complexform[id = \"" + strSelectedComplexFormId + "\"]"); if (objXmlProgram != null) { string strDuration = objXmlProgram["duration"].InnerText; string strTarget = objXmlProgram["target"].InnerText; string strFV = objXmlProgram["fv"].InnerText; lblDuration.Text = strDuration; lblTarget.Text = strTarget; lblFV.Text = strFV; string strBook = CommonFunctions.LanguageBookShort(objXmlProgram["source"].InnerText, GlobalOptions.Language); string strPage = objXmlProgram["page"].InnerText; if (objXmlProgram["altpage"] != null) { strPage = objXmlProgram["altpage"].InnerText; } lblSource.Text = strBook + " " + strPage; tipTooltip.SetToolTip(lblSource, CommonFunctions.LanguageBookLong(objXmlProgram["source"].InnerText, GlobalOptions.Language) + " " + LanguageManager.GetString("String_Page", GlobalOptions.Language) + " " + strPage); } }
/// <summary> /// Print the object's XML to the XmlWriter. /// </summary> /// <param name="objWriter">XmlTextWriter to write with.</param> /// <param name="strLanguageToPrint">Language in which to print</param> public void Print(XmlTextWriter objWriter, string strLanguageToPrint) { if (objWriter == null) { return; } objWriter.WriteStartElement("mentorspirit"); objWriter.WriteElementString("name", DisplayNameShort(strLanguageToPrint)); objWriter.WriteElementString("mentortype", _eMentorType.ToString()); objWriter.WriteElementString("name_english", Name); objWriter.WriteElementString("advantage", Advantage); objWriter.WriteElementString("disadvantage", Disadvantage); objWriter.WriteElementString("extra", LanguageManager.TranslateExtra(Extra, strLanguageToPrint)); objWriter.WriteElementString("source", CommonFunctions.LanguageBookShort(Source, strLanguageToPrint)); objWriter.WriteElementString("page", DisplayPage(strLanguageToPrint)); objWriter.WriteElementString("mentormask", MentorMask.ToString(GlobalOptions.InvariantCultureInfo)); if (_objCharacter.Options.PrintNotes) { objWriter.WriteElementString("notes", _strNotes); } objWriter.WriteEndElement(); }
public SourceString(string strSourceString, string strLanguage = "", CultureInfo objCultureInfo = null) { Language = !string.IsNullOrEmpty(strLanguage) ? strLanguage : GlobalOptions.Language; CultureInfo = objCultureInfo ?? GlobalOptions.CultureInfo; string strCode = strSourceString ?? string.Empty; int intWhitespaceIndex = strCode.IndexOf(' '); if (intWhitespaceIndex != -1) { strCode = strCode.Substring(0, intWhitespaceIndex); if (intWhitespaceIndex + 1 < strCode.Length) { int.TryParse(strCode.Substring(intWhitespaceIndex + 1), NumberStyles.Integer, GlobalOptions.InvariantCultureInfo, out _intPage); } } Code = CommonFunctions.LanguageBookShort(strCode, Language); _intHashCode = new { Language, CultureInfo, Code, Page }.GetHashCode(); _strCachedSpace = LanguageManager.GetString("String_Space", strLanguage); LanguageBookTooltip = CommonFunctions.LanguageBookLong(strCode, Language) + _strCachedSpace + LanguageManager.GetString("String_Page", strLanguage) + _strCachedSpace + _intPage.ToString(CultureInfo); }
/// <summary> /// Print the object's XML to the XmlWriter. /// </summary> /// <param name="objWriter">XmlTextWriter to write with.</param> /// <param name="objCulture">Culture in which to print numbers.</param> /// <param name="strLanguageToPrint">Language in which to print.</param> public void Print(XmlTextWriter objWriter, CultureInfo objCulture, string strLanguageToPrint) { if (objWriter == null) { return; } objWriter.WriteStartElement("spell"); if (Limited) { objWriter.WriteElementString("name", DisplayNameShort(strLanguageToPrint) + LanguageManager.GetString("String_Space", strLanguageToPrint) + '(' + LanguageManager.GetString("String_SpellLimited", strLanguageToPrint) + ')'); } else if (Alchemical) { objWriter.WriteElementString("name", DisplayNameShort(strLanguageToPrint) + LanguageManager.GetString("String_Space", strLanguageToPrint) + '(' + LanguageManager.GetString("String_SpellAlchemical", strLanguageToPrint) + ')'); } else { objWriter.WriteElementString("name", DisplayNameShort(strLanguageToPrint)); } objWriter.WriteElementString("name_english", Name); objWriter.WriteElementString("descriptors", DisplayDescriptors(strLanguageToPrint)); objWriter.WriteElementString("category", DisplayCategory(strLanguageToPrint)); objWriter.WriteElementString("category_english", Category); objWriter.WriteElementString("type", DisplayType(strLanguageToPrint)); objWriter.WriteElementString("range", DisplayRange(strLanguageToPrint)); objWriter.WriteElementString("damage", DisplayDamage(strLanguageToPrint)); objWriter.WriteElementString("duration", DisplayDuration(strLanguageToPrint)); objWriter.WriteElementString("dv", DisplayDV(strLanguageToPrint)); objWriter.WriteElementString("alchemy", Alchemical.ToString(GlobalOptions.InvariantCultureInfo)); objWriter.WriteElementString("dicepool", DicePool.ToString(objCulture)); objWriter.WriteElementString("source", CommonFunctions.LanguageBookShort(Source, strLanguageToPrint)); objWriter.WriteElementString("page", DisplayPage(strLanguageToPrint)); objWriter.WriteElementString("extra", LanguageManager.TranslateExtra(Extra, strLanguageToPrint)); if (_objCharacter.Options.PrintNotes) { objWriter.WriteElementString("notes", Notes); } objWriter.WriteEndElement(); }
/// <summary> /// Print the object's XML to the XmlWriter. /// </summary> /// <param name="objWriter">XmlTextWriter to write with.</param> /// <param name="strLanguageToPrint">Language in which to print</param> public void Print(XmlTextWriter objWriter, string strLanguageToPrint) { if (objWriter == null) { return; } objWriter.WriteStartElement("complexform"); objWriter.WriteElementString("guid", InternalId); objWriter.WriteElementString("sourceid", SourceIDString); objWriter.WriteElementString("name", DisplayNameShort(strLanguageToPrint)); objWriter.WriteElementString("fullname", DisplayName(strLanguageToPrint)); objWriter.WriteElementString("name_english", Name); objWriter.WriteElementString("duration", DisplayDuration(strLanguageToPrint)); objWriter.WriteElementString("fv", DisplayFV(strLanguageToPrint)); objWriter.WriteElementString("target", DisplayTarget(strLanguageToPrint)); objWriter.WriteElementString("source", CommonFunctions.LanguageBookShort(Source, strLanguageToPrint)); objWriter.WriteElementString("page", DisplayPage(strLanguageToPrint)); if (_objCharacter.Options.PrintNotes) { objWriter.WriteElementString("notes", Notes); } objWriter.WriteEndElement(); }
/// <summary> /// Update the Program's information based on the Program selected. /// </summary> private void UpdateProgramInfo(XmlNode objXmlProgram) { if (!string.IsNullOrEmpty(lstAIPrograms.Text)) { string strRequiresProgram = LanguageManager.GetString("String_None", GlobalOptions.Language); if (objXmlProgram["require"] != null) { strRequiresProgram = objXmlProgram["require"].InnerText; } lblRequiresProgram.Text = strRequiresProgram; string strBook = CommonFunctions.LanguageBookShort(objXmlProgram["source"].InnerText, GlobalOptions.Language); string strPage = objXmlProgram["page"].InnerText; if (objXmlProgram["altpage"] != null) { strPage = objXmlProgram["altpage"].InnerText; } lblSource.Text = strBook + " " + strPage; tipTooltip.SetToolTip(lblSource, CommonFunctions.LanguageBookLong(objXmlProgram["source"].InnerText, GlobalOptions.Language) + " " + LanguageManager.GetString("String_Page", GlobalOptions.Language) + " " + strPage); } }
/// <summary> /// Print the object's XML to the XmlWriter. /// </summary> /// <param name="objWriter">XmlTextWriter to write with.</param> /// <param name="intRating">Pre-calculated rating of the quality for printing.</param> /// <param name="objCulture">Culture in which to print.</param> /// <param name="strLanguageToPrint">Language in which to print</param> public void Print(XmlTextWriter objWriter, int intRating, CultureInfo objCulture, string strLanguageToPrint) { if (AllowPrint) { string strSpaceCharacter = LanguageManager.GetString("String_Space", strLanguageToPrint); string strRatingString = string.Empty; if (intRating > 1) { strRatingString = strSpaceCharacter + intRating.ToString(objCulture); } string strSourceName = string.Empty; if (!string.IsNullOrWhiteSpace(SourceName)) { strSourceName = strSpaceCharacter + '(' + GetSourceName(strLanguageToPrint) + ')'; } objWriter.WriteStartElement("quality"); objWriter.WriteElementString("name", DisplayNameShort(strLanguageToPrint)); objWriter.WriteElementString("name_english", Name + strRatingString); objWriter.WriteElementString("extra", LanguageManager.TranslateExtra(Extra, strLanguageToPrint) + strRatingString + strSourceName); objWriter.WriteElementString("bp", BP.ToString(objCulture)); string strQualityType = Type.ToString(); if (strLanguageToPrint != GlobalOptions.DefaultLanguage) { strQualityType = XmlManager.Load("qualities.xml", strLanguageToPrint).SelectSingleNode("/chummer/categories/category[. = \"" + strQualityType + "\"]/@translate")?.InnerText ?? strQualityType; } objWriter.WriteElementString("qualitytype", strQualityType); objWriter.WriteElementString("qualitytype_english", Type.ToString()); objWriter.WriteElementString("qualitysource", OriginSource.ToString()); objWriter.WriteElementString("source", CommonFunctions.LanguageBookShort(Source, strLanguageToPrint)); objWriter.WriteElementString("page", DisplayPage(strLanguageToPrint)); if (_objCharacter.Options.PrintNotes) { objWriter.WriteElementString("notes", Notes); } objWriter.WriteEndElement(); } }
/// <summary> /// Print the object's XML to the XmlWriter. /// </summary> /// <param name="objWriter">XmlTextWriter to write with.</param> /// <param name="strLanguageToPrint">Language in which to print</param> public void Print(XmlTextWriter objWriter, string strLanguageToPrint) { if (objWriter == null) { return; } objWriter.WriteStartElement("mentorspirit"); objWriter.WriteElementString("guid", InternalId); objWriter.WriteElementString("sourceid", SourceIDString); objWriter.WriteElementString("name", DisplayNameShort(strLanguageToPrint)); objWriter.WriteElementString("mentortype", _eMentorType.ToString()); objWriter.WriteElementString("name_english", Name); objWriter.WriteElementString("advantage", Advantage); objWriter.WriteElementString("disadvantage", Disadvantage); objWriter.WriteElementString("extra", LanguageManager.TranslateExtra(Extra, strLanguageToPrint)); objWriter.WriteElementString("source", CommonFunctions.LanguageBookShort(Source, strLanguageToPrint)); objWriter.WriteElementString("page", DisplayPage(strLanguageToPrint)); objWriter.WriteElementString("mentormask", MentorMask.ToString(GlobalOptions.InvariantCultureInfo)); if (_objCharacter.Options.PrintNotes) { objWriter.WriteElementString("notes", System.Text.RegularExpressions.Regex.Replace(_strNotes, @"[\u0000-\u0008\u000B\u000C\u000E-\u001F]", "")); } objWriter.WriteEndElement(); }
private void treQualities_AfterSelect(object sender, TreeViewEventArgs e) { string strQualityId = treQualities.SelectedNode?.Tag.ToString(); if (string.IsNullOrEmpty(strQualityId)) { XmlNode objXmlQuality = _objXmlDocument.SelectSingleNode("/chummer/qualities/quality[id = \"" + strQualityId + "\"]"); if (objXmlQuality == null) { lblSource.Text = string.Empty; tipTooltip.SetToolTip(lblSource, string.Empty); return; } string strBook = CommonFunctions.LanguageBookShort(objXmlQuality["altsource"]?.InnerText ?? objXmlQuality["source"].InnerText, GlobalOptions.Language); string strPage = CommonFunctions.LanguageBookShort(objXmlQuality["altpage"]?.InnerText ?? objXmlQuality["page"].InnerText, GlobalOptions.Language); lblSource.Text = $"{strBook} {strPage}"; tipTooltip.SetToolTip(lblSource, CommonFunctions.LanguageBookLong(strBook, GlobalOptions.Language) + " " + LanguageManager.GetString("String_Page", GlobalOptions.Language) + " " + strPage); } else { lblSource.Text = string.Empty; tipTooltip.SetToolTip(lblSource, string.Empty); } }
private void lstComplexForms_SelectedIndexChanged(object sender, EventArgs e) { string strSelectedComplexFormId = lstComplexForms.SelectedValue?.ToString(); if (_blnLoading || string.IsNullOrEmpty(strSelectedComplexFormId)) { lblDuration.Text = string.Empty; lblSource.Text = string.Empty; lblFV.Text = string.Empty; lblSource.SetToolTip(string.Empty); return; } // Display the Complex Form information. XPathNavigator xmlComplexForm = _xmlBaseComplexFormsNode.SelectSingleNode("complexform[id = \"" + strSelectedComplexFormId + "\"]"); if (xmlComplexForm != null) { switch (xmlComplexForm.SelectSingleNode("duration")?.Value) { case "P": lblDuration.Text = LanguageManager.GetString("String_SpellDurationPermanent"); break; case "S": lblDuration.Text = LanguageManager.GetString("String_SpellDurationSustained"); break; case "Special": lblDuration.Text = LanguageManager.GetString("String_SpellDurationSpecial"); break; default: lblDuration.Text = LanguageManager.GetString("String_SpellDurationInstant"); break; } switch (xmlComplexForm.SelectSingleNode("target")?.Value) { case "Persona": lblTarget.Text = LanguageManager.GetString("String_ComplexFormTargetPersona"); break; case "Device": lblTarget.Text = LanguageManager.GetString("String_ComplexFormTargetDevice"); break; case "File": lblTarget.Text = LanguageManager.GetString("String_ComplexFormTargetFile"); break; case "Self": lblTarget.Text = LanguageManager.GetString("String_SpellRangeSelf"); break; case "Sprite": lblTarget.Text = LanguageManager.GetString("String_ComplexFormTargetSprite"); break; case "Host": lblTarget.Text = LanguageManager.GetString("String_ComplexFormTargetHost"); break; case "IC": lblTarget.Text = LanguageManager.GetString("String_ComplexFormTargetIC"); break; default: lblTarget.Text = LanguageManager.GetString("String_None"); break; } string strFV = xmlComplexForm.SelectSingleNode("fv")?.Value.Replace('/', '÷') ?? string.Empty; if (GlobalOptions.Language != GlobalOptions.DefaultLanguage) { strFV = strFV.CheapReplace("L", () => LanguageManager.GetString("String_ComplexFormLevel")) .CheapReplace("Overflow damage", () => LanguageManager.GetString("String_SpellOverflowDamage")) .CheapReplace("Damage Value", () => LanguageManager.GetString("String_SpellDamageValue")) .CheapReplace("Toxin DV", () => LanguageManager.GetString("String_SpellToxinDV")) .CheapReplace("Disease DV", () => LanguageManager.GetString("String_SpellDiseaseDV")) .CheapReplace("Radiation Power", () => LanguageManager.GetString("String_SpellRadiationPower")); } lblFV.Text = strFV; string strSource = xmlComplexForm.SelectSingleNode("source")?.Value ?? LanguageManager.GetString("String_Unknown"); string strPage = xmlComplexForm.SelectSingleNode("altpage")?.Value ?? xmlComplexForm.SelectSingleNode("page")?.Value ?? LanguageManager.GetString("String_Unknown"); string strSpace = LanguageManager.GetString("String_Space"); lblSource.Text = CommonFunctions.LanguageBookShort(strSource) + strSpace + strPage; lblSource.SetToolTip(CommonFunctions.LanguageBookLong(strSource) + strSpace + LanguageManager.GetString("String_Page") + strSpace + strPage); } else { lblDuration.Text = string.Empty; lblSource.Text = string.Empty; lblFV.Text = string.Empty; lblSource.SetToolTip(string.Empty); } lblDurationLabel.Visible = !string.IsNullOrEmpty(lblDuration.Text); lblSourceLabel.Visible = !string.IsNullOrEmpty(lblSource.Text); lblFVLabel.Visible = !string.IsNullOrEmpty(lblFV.Text); lblSourceLabel.Visible = !string.IsNullOrEmpty(lblSource.Text); }
private void lstMentor_SelectedIndexChanged(object sender, EventArgs e) { if (_blnSkipRefresh) { return; } XPathNavigator objXmlMentor = null; string strSelectedId = lstMentor.SelectedValue?.ToString(); if (!string.IsNullOrEmpty(strSelectedId)) { objXmlMentor = _xmlBaseMentorSpiritDataNode.SelectSingleNode("mentors/mentor[id = \"" + lstMentor.SelectedValue + "\"]"); } if (objXmlMentor != null) { cboChoice1.BeginUpdate(); cboChoice2.BeginUpdate(); cboChoice1.DataSource = null; cboChoice2.DataSource = null; // If the Mentor offers a choice of bonuses, build the list and let the user select one. XPathNavigator xmlChoices = objXmlMentor.SelectSingleNode("choices"); if (xmlChoices != null) { List <ListItem> lstChoice1 = new List <ListItem>(); List <ListItem> lstChoice2 = new List <ListItem>(); foreach (XPathNavigator objChoice in xmlChoices.Select("choice")) { string strName = objChoice.SelectSingleNode("name")?.Value ?? string.Empty; if ((_objCharacter.AdeptEnabled || !strName.StartsWith("Adept:", StringComparison.Ordinal)) && (_objCharacter.MagicianEnabled || !strName.StartsWith("Magician:", StringComparison.Ordinal))) { if (objChoice.SelectSingleNode("@set")?.Value == "2") { lstChoice2.Add(new ListItem(strName, objChoice.SelectSingleNode("translate")?.Value ?? strName)); } else { lstChoice1.Add(new ListItem(strName, objChoice.SelectSingleNode("translate")?.Value ?? strName)); } } } cboChoice1.Visible = true; cboChoice1.ValueMember = "Value"; cboChoice1.DisplayMember = "Name"; cboChoice1.DataSource = lstChoice1; if (lstChoice2.Count > 0) { cboChoice2.Visible = true; cboChoice2.ValueMember = "Value"; cboChoice2.DisplayMember = "Name"; cboChoice2.DataSource = lstChoice2; } else { cboChoice2.Visible = false; } cboChoice1.Visible = lstChoice1.Count > 0; cboChoice1.Enabled = lstChoice1.Count > 1; cboChoice2.Enabled = lstChoice2.Count > 1; } else { cboChoice1.Visible = false; cboChoice2.Visible = false; } cboChoice1.EndUpdate(); cboChoice2.EndUpdate(); lblChoice1.Visible = cboChoice1.Visible; lblChoice2.Visible = cboChoice2.Visible; // Get the information for the selected Mentor. lblAdvantage.Text = objXmlMentor.SelectSingleNode("altadvantage")?.Value ?? objXmlMentor.SelectSingleNode("advantage")?.Value ?? LanguageManager.GetString("String_Unknown"); lblAdvantageLabel.Visible = !string.IsNullOrEmpty(lblAdvantage.Text); lblDisadvantage.Text = objXmlMentor.SelectSingleNode("altdisadvantage")?.Value ?? objXmlMentor.SelectSingleNode("disadvantage")?.Value ?? LanguageManager.GetString("String_Unknown"); lblDisadvantageLabel.Visible = !string.IsNullOrEmpty(lblDisadvantage.Text); string strSource = objXmlMentor.SelectSingleNode("source")?.Value ?? LanguageManager.GetString("String_Unknown"); string strPage = objXmlMentor.SelectSingleNode("altpage")?.Value ?? objXmlMentor.SelectSingleNode("page")?.Value ?? LanguageManager.GetString("String_Unknown"); string strSpace = LanguageManager.GetString("String_Space"); lblSource.Text = CommonFunctions.LanguageBookShort(strSource) + strSpace + strPage; lblSource.SetToolTip(CommonFunctions.LanguageBookLong(strSource) + strSpace + LanguageManager.GetString("String_Page") + strSpace + strPage); lblSourceLabel.Visible = !string.IsNullOrEmpty(lblSource.Text); cmdOK.Enabled = true; } else { lblAdvantageLabel.Visible = false; lblAdvantage.Text = string.Empty; lblDisadvantageLabel.Visible = false; lblDisadvantage.Text = string.Empty; lblChoice1.Visible = false; lblChoice2.Visible = false; cboChoice1.Visible = false; cboChoice2.Visible = false; lblSourceLabel.Visible = false; lblSource.Text = string.Empty; lblSource.SetToolTip(string.Empty); cmdOK.Enabled = false; } }
private void UpdateGearInfo() { // Retrieve the information for the selected Accessory. XmlNode objXmlAccessory = _objXmlDocument.SelectSingleNode("/chummer/accessories/accessory[name = \"" + lstAccessory.SelectedValue + "\"]"); if (objXmlAccessory == null) { return; } if (objXmlAccessory.InnerXml.Contains("<rc>")) { lblRC.Visible = true; lblRCLabel.Visible = true; lblRC.Text = objXmlAccessory["rc"]?.InnerText; } else { lblRC.Visible = false; lblRCLabel.Visible = false; } if (int.TryParse(objXmlAccessory["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 && !Backend.SelectionShared.CheckAvailRestriction(objXmlAccessory, _objCharacter, decimal.ToInt32(nudRating.Maximum))) { nudRating.Maximum -= 1; } } } else { nudRating.Enabled = false; nudRating.Visible = false; lblRatingLabel.Visible = false; } List <string> strMounts = new List <string>(); foreach (string strItem in objXmlAccessory["mount"]?.InnerText?.Split('/')) { strMounts.Add(strItem); } strMounts.Add("None"); List <string> strAllowed = new List <string>(); foreach (string strItem in _strAllowedMounts.Split('/')) { strAllowed.Add(strItem); } strAllowed.Add("None"); cboMount.Items.Clear(); foreach (string strCurrentMount in strMounts) { if (!string.IsNullOrEmpty(strCurrentMount)) { foreach (string strAllowedMount in strAllowed) { if (strCurrentMount == strAllowedMount) { cboMount.Items.Add(strCurrentMount); } } } } if (cboMount.Items.Count <= 1) { cboMount.Enabled = false; } else { cboMount.Enabled = true; } cboMount.SelectedIndex = 0; List <string> strExtraMounts = new List <string>(); if (objXmlAccessory.InnerXml.Contains("<extramount>")) { foreach (string strItem in objXmlAccessory["extramount"]?.InnerText?.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); } } } } if (cboExtraMount.Items.Count <= 1) { cboExtraMount.Enabled = false; } else { cboExtraMount.Enabled = true; } 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 strAvail = string.Empty; string strAvailExpr = objXmlAccessory["avail"]?.InnerText; if (!string.IsNullOrWhiteSpace(strAvailExpr)) { lblAvail.Text = strAvailExpr; if (strAvailExpr.EndsWith('F', 'R')) { strAvail = strAvailExpr.Substring(strAvailExpr.Length - 1, 1); if (strAvail == "R") { strAvail = LanguageManager.GetString("String_AvailRestricted", GlobalOptions.Language); } else if (strAvail == "F") { strAvail = LanguageManager.GetString("String_AvailForbidden", GlobalOptions.Language); } // Remove the trailing character if it is "F" or "R". strAvailExpr = strAvailExpr.Substring(0, strAvailExpr.Length - 1); } try { lblAvail.Text = Convert.ToInt32(CommonFunctions.EvaluateInvariantXPath(strAvailExpr.Replace("Rating", nudRating.Value.ToString(GlobalOptions.CultureInfo)))).ToString() + strAvail; } catch (XPathException) { lblAvail.Text = strAvailExpr + strAvail; } } else { lblAvail.Text = string.Empty; } if (!chkFreeItem.Checked) { string strCost = "0"; if (objXmlAccessory.TryGetStringFieldQuickly("cost", ref strCost)) { strCost = strCost.Replace("Weapon Cost", _decWeaponCost.ToString(GlobalOptions.InvariantCultureInfo)) .Replace("Rating", nudRating.Value.ToString(GlobalOptions.CultureInfo)); } if (strCost.StartsWith("Variable(")) { decimal decMin = 0; 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.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 strBookCode = objXmlAccessory["source"]?.InnerText; string strBook = CommonFunctions.LanguageBookShort(strBookCode, GlobalOptions.Language); string strPage = objXmlAccessory["altpage"]?.InnerText ?? objXmlAccessory["page"]?.InnerText; lblSource.Text = strBook + ' ' + strPage; tipTooltip.SetToolTip(lblSource, CommonFunctions.LanguageBookLong(strBookCode, GlobalOptions.Language) + ' ' + LanguageManager.GetString("String_Page", GlobalOptions.Language) + ' ' + strPage); }
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); }