public frmCareer(Character objCharacter) { _objCharacter = objCharacter; _objOptions = _objCharacter.Options; _objFunctions = new CommonFunctions(_objCharacter); _objFunctions.ContextMenuArmor = cmsArmor; _objFunctions.ContextMenuArmorMod = cmsArmorMod; _objFunctions.ContextMenuCyberware = cmsCyberware; _objFunctions.ContextMenuGear = cmsGear; _objFunctions.ContextMenuVehicle = cmsVehicle; _objFunctions.ContextMenuVehicleMod = cmsVehicle; _objFunctions.ContextMenuWeapon = cmsWeapon; _objFunctions.ContextMenuWeaponAccessory = cmsWeaponAccessoryGear; _objFunctions.ContextMenuWeaponMod = cmsWeaponMod; _objImprovementManager = new ImprovementManager(_objCharacter); _objController = new MainController(_objCharacter); InitializeComponent(); // Add EventHandlers for the MAG and RES enabled events and tab enabled events. _objCharacter.MAGEnabledChanged += objCharacter_MAGEnabledChanged; _objCharacter.RESEnabledChanged += objCharacter_RESEnabledChanged; _objCharacter.AdeptTabEnabledChanged += objCharacter_AdeptTabEnabledChanged; _objCharacter.MagicianTabEnabledChanged += objCharacter_MagicianTabEnabledChanged; _objCharacter.TechnomancerTabEnabledChanged += objCharacter_TechnomancerTabEnabledChanged; _objCharacter.CritterTabEnabledChanged += objCharacter_CritterTabEnabledChanged; _objCharacter.BlackMarketEnabledChanged += objCharacter_BlackMarketChanged; _objCharacter.SensitiveSystemChanged += objCharacter_SensitiveSystemChanged; _objCharacter.UneducatedChanged += objCharacter_UneducatedChanged; _objCharacter.UncouthChanged += objCharacter_UncouthChanged; _objCharacter.InfirmChanged += objCharacter_InfirmChanged; GlobalOptions.Instance.MRUChanged += PopulateMRU; LanguageManager.Instance.Load(this); // Update the text in the Menus so they can be merged with frmMain properly. foreach (ToolStripMenuItem objItem in mnuCreateMenu.Items.OfType<ToolStripMenuItem>()) { if (objItem.Tag != null) { objItem.Text = LanguageManager.Instance.GetString(objItem.Tag.ToString()); } } _lvwKarmaColumnSorter = new ListViewColumnSorter(); _lvwKarmaColumnSorter.SortColumn = 0; _lvwKarmaColumnSorter.Order = SortOrder.Descending; lstKarma.ListViewItemSorter = _lvwKarmaColumnSorter; _lvwNuyenColumnSorter = new ListViewColumnSorter(); _lvwNuyenColumnSorter.SortColumn = 0; _lvwNuyenColumnSorter.Order = SortOrder.Descending; lstNuyen.ListViewItemSorter = _lvwNuyenColumnSorter; SetTooltips(); MoveControls(); }
public frmCreate(Character objCharacter) { _objCharacter = objCharacter; _objOptions = _objCharacter.Options; _objFunctions = new CommonFunctions(_objCharacter); _objImprovementManager = new ImprovementManager(_objCharacter); _objController = new MainController(_objCharacter); InitializeComponent(); // Add EventHandlers for the various events MAG, RES, Qualities, etc. _objCharacter.MAGEnabledChanged += objCharacter_MAGEnabledChanged; _objCharacter.RESEnabledChanged += objCharacter_RESEnabledChanged; _objCharacter.AdeptTabEnabledChanged += objCharacter_AdeptTabEnabledChanged; _objCharacter.MagicianTabEnabledChanged += objCharacter_MagicianTabEnabledChanged; _objCharacter.TechnomancerTabEnabledChanged += objCharacter_TechnomancerTabEnabledChanged; _objCharacter.InitiationTabEnabledChanged += objCharacter_InitiationTabEnabledChanged; _objCharacter.CritterTabEnabledChanged += objCharacter_CritterTabEnabledChanged; _objCharacter.BlackMarketEnabledChanged += objCharacter_BlackMarketDiscountChanged; _objCharacter.SkillsSection.UneducatedChanged += objCharacter_UneducatedChanged; _objCharacter.SkillsSection.UncouthChanged += objCharacter_UncouthChanged; _objCharacter.FriendsInHighPlacesChanged += objCharacter_FriendsInHighPlacesChanged; _objCharacter.SkillsSection.SchoolOfHardKnocksChanged += objCharacter_SchoolOfHardKnocksChanged; _objCharacter.ExConChanged += objCharacter_ExConChanged; _objCharacter.TrustFundChanged += objCharacter_TrustFundChanged; _objCharacter.SkillsSection.TechSchoolChanged += objCharacter_TechSchoolChanged; _objCharacter.RestrictedGearChanged += objCharacter_RestrictedGearChanged; _objCharacter.OverclockerChanged += objCharacter_OverclockerChanged; _objCharacter.MadeManChanged += objCharacter_MadeManChanged; _objCharacter.SkillsSection.LinguistChanged += objCharacter_LinguistChanged; _objCharacter.LightningReflexesChanged += objCharacter_LightningReflexesChanged; _objCharacter.FameChanged += objCharacter_FameChanged; _objCharacter.BornRichChanged += objCharacter_BornRichChanged; _objCharacter.ErasedChanged += objCharacter_ErasedChanged; tabSkillUc.ChildPropertyChanged += SkillPropertyChanged; GlobalOptions.Instance.MRUChanged += PopulateMRU; LanguageManager.Instance.Load(GlobalOptions.Instance.Language, this); // Update the text in the Menus so they can be merged with frmMain properly. foreach (ToolStripMenuItem objItem in mnuCreateMenu.Items.OfType<ToolStripMenuItem>()) { if (objItem.Tag != null) { objItem.Text = LanguageManager.Instance.GetString(objItem.Tag.ToString()); } } SetTooltips(); MoveControls(); }
public frmCareer(Character objCharacter) { _objCharacter = objCharacter; _objOptions = _objCharacter.Options; _objFunctions = new CommonFunctions(_objCharacter); _objImprovementManager = new ImprovementManager(_objCharacter); _objController = new MainController(_objCharacter); InitializeComponent(); // Add EventHandlers for the MAG and RES enabled events and tab enabled events. _objCharacter.MAGEnabledChanged += objCharacter_MAGEnabledChanged; _objCharacter.RESEnabledChanged += objCharacter_RESEnabledChanged; _objCharacter.AdeptTabEnabledChanged += objCharacter_AdeptTabEnabledChanged; _objCharacter.MagicianTabEnabledChanged += objCharacter_MagicianTabEnabledChanged; _objCharacter.TechnomancerTabEnabledChanged += objCharacter_TechnomancerTabEnabledChanged; _objCharacter.CritterTabEnabledChanged += objCharacter_CritterTabEnabledChanged; _objCharacter.SkillsSection.UneducatedChanged += objCharacter_UneducatedChanged; _objCharacter.SkillsSection.UncouthChanged += objCharacter_UncouthChanged; _objCharacter.FameChanged += objCharacter_FameChanged; tabSkillsUc.ChildPropertyChanged += SkillPropertyChanged; GlobalOptions.Instance.MRUChanged += PopulateMRU; LanguageManager.Instance.Load(GlobalOptions.Instance.Language, this); // Update the text in the Menus so they can be merged with frmMain properly. foreach (ToolStripMenuItem objItem in mnuCreateMenu.Items.OfType<ToolStripMenuItem>()) { if (objItem.Tag != null) { objItem.Text = LanguageManager.Instance.GetString(objItem.Tag.ToString()); } } _lvwKarmaColumnSorter = new ListViewColumnSorter(); _lvwKarmaColumnSorter.SortColumn = 0; _lvwKarmaColumnSorter.Order = SortOrder.Descending; lstKarma.ListViewItemSorter = _lvwKarmaColumnSorter; _lvwNuyenColumnSorter = new ListViewColumnSorter(); _lvwNuyenColumnSorter.SortColumn = 0; _lvwNuyenColumnSorter.Order = SortOrder.Descending; lstNuyen.ListViewItemSorter = _lvwNuyenColumnSorter; SetTooltips(); MoveControls(); }
public frmCreate(Character objCharacter) { _objCharacter = objCharacter; _objOptions = _objCharacter.Options; _objFunctions = new CommonFunctions(_objCharacter); _objImprovementManager = new ImprovementManager(_objCharacter); _objController = new MainController(_objCharacter); InitializeComponent(); // Add EventHandlers for the MAG and RES enabled events and tab enabled events. _objCharacter.MAGEnabledChanged += objCharacter_MAGEnabledChanged; _objCharacter.RESEnabledChanged += objCharacter_RESEnabledChanged; _objCharacter.AdeptTabEnabledChanged += objCharacter_AdeptTabEnabledChanged; _objCharacter.MagicianTabEnabledChanged += objCharacter_MagicianTabEnabledChanged; _objCharacter.TechnomancerTabEnabledChanged += objCharacter_TechnomancerTabEnabledChanged; _objCharacter.InitiationTabEnabledChanged += objCharacter_InitiationTabEnabledChanged; _objCharacter.CritterTabEnabledChanged += objCharacter_CritterTabEnabledChanged; _objCharacter.BlackMarketEnabledChanged += objCharacter_BlackMarketChanged; _objCharacter.UneducatedChanged += objCharacter_UneducatedChanged; _objCharacter.UncouthChanged += objCharacter_UncouthChanged; _objCharacter.InfirmChanged += objCharacter_InfirmChanged; GlobalOptions.Instance.MRUChanged += PopulateMRU; LanguageManager.Instance.Load(GlobalOptions.Instance.Language, this); // Update the text in the Menus so they can be merged with frmMain properly. foreach (ToolStripMenuItem objItem in mnuCreateMenu.Items.OfType<ToolStripMenuItem>()) { if (objItem.Tag != null) { objItem.Text = LanguageManager.Instance.GetString(objItem.Tag.ToString()); } } SetTooltips(); MoveControls(); }
public MainController(Character objCharacter) { _objCharacter = objCharacter; _objImprovementManager = new ImprovementManager(_objCharacter); _objFunctions = new CommonFunctions(_objCharacter); }
private void SetToolTips() { const int width = 50; var functions = new CommonFunctions(); tipTooltip.SetToolTip(chkKnucks, functions.WordWrap(LanguageManager.Instance.GetString("Tip_OptionsKnucks"), width)); tipTooltip.SetToolTip(chkIgnoreArt, functions.WordWrap(LanguageManager.Instance.GetString("Tip_OptionsIgnoreArt"), width)); tipTooltip.SetToolTip(chkCyberlegMovement, functions.WordWrap(LanguageManager.Instance.GetString("Tip_OptionsCyberlegMovement"), width)); tipTooltip.SetToolTip(chkDontDoubleQualities, functions.WordWrap(LanguageManager.Instance.GetString("Tip_OptionsDontDoubleQualities"), width)); tipTooltip.SetToolTip(chkUsePointsOnBrokenGroups, functions.WordWrap(LanguageManager.Instance.GetString("Tip_OptionsUsePointsOnBrokenGroups"), width)); tipTooltip.SetToolTip(chkAllowInitiation, functions.WordWrap(LanguageManager.Instance.GetString("Tip_OptionsAllowInitiation"), width)); }
/// <summary> /// Build the list of available weapon accessories. /// </summary> private void BuildAccessoryList() { List <ListItem> lstAccessories = new List <ListItem>(); // Populate the Accessory list. StringBuilder strMount = new StringBuilder("contains(mount, \"Internal\") or contains(mount, \"None\") or mount = \"\""); foreach (string strAllowedMount in _lstAllowedMounts) { if (!string.IsNullOrEmpty(strAllowedMount)) { strMount.Append(" or contains(mount, \"" + strAllowedMount + "\")"); } } strMount.Append(CommonFunctions.GenerateSearchXPath(txtSearch.Text)); XPathNavigator xmlParentWeaponDataNode = _xmlBaseChummerNode.SelectSingleNode("weapons/weapon[id = \"" + _objParentWeapon.SourceIDString + "\"]"); foreach (XPathNavigator objXmlAccessory in _xmlBaseChummerNode.Select("accessories/accessory[(" + strMount + ") and (" + _objCharacter.Options.BookXPath() + ")]")) { string strId = objXmlAccessory.SelectSingleNode("id")?.Value; if (string.IsNullOrEmpty(strId)) { continue; } XPathNavigator xmlExtraMountNode = objXmlAccessory.SelectSingleNode("extramount"); if (xmlExtraMountNode != null) { if (_lstAllowedMounts.Count > 1) { foreach (string strItem in xmlExtraMountNode.Value.Split('/')) { if (!string.IsNullOrEmpty(strItem) && _lstAllowedMounts.All(strAllowedMount => strAllowedMount != strItem)) { goto NextItem; } } } } if (!objXmlAccessory.RequirementsMet(_objCharacter, _objParentWeapon, string.Empty, string.Empty)) { continue; } XPathNavigator xmlTestNode = objXmlAccessory.SelectSingleNode("forbidden/weapondetails"); if (xmlTestNode != null) { // Assumes topmost parent is an AND node if (xmlParentWeaponDataNode.ProcessFilterOperationNode(xmlTestNode, false)) { continue; } } xmlTestNode = objXmlAccessory.SelectSingleNode("required/weapondetails"); if (xmlTestNode != null) { // Assumes topmost parent is an AND node if (!xmlParentWeaponDataNode.ProcessFilterOperationNode(xmlTestNode, false)) { continue; } } decimal decCostMultiplier = 1 + (nudMarkup.Value / 100.0m); if (_blnIsParentWeaponBlackMarketAllowed) { decCostMultiplier *= 0.9m; } if ((!chkHideOverAvailLimit.Checked || SelectionShared.CheckAvailRestriction(objXmlAccessory, _objCharacter) && (chkFreeItem.Checked || !chkShowOnlyAffordItems.Checked || SelectionShared.CheckNuyenRestriction(objXmlAccessory, _objCharacter.Nuyen, decCostMultiplier)))) { lstAccessories.Add(new ListItem(strId, objXmlAccessory.SelectSingleNode("translate")?.Value ?? objXmlAccessory.SelectSingleNode("name")?.Value ?? LanguageManager.GetString("String_Unknown", GlobalOptions.Language))); } NextItem :; } lstAccessories.Sort(CompareListItems.CompareNames); string strOldSelected = lstAccessory.SelectedValue?.ToString(); _blnLoading = true; lstAccessory.BeginUpdate(); lstAccessory.ValueMember = "Value"; lstAccessory.DisplayMember = "Name"; lstAccessory.DataSource = lstAccessories; _blnLoading = false; if (!string.IsNullOrEmpty(strOldSelected)) { lstAccessory.SelectedValue = strOldSelected; } else { lstAccessory.SelectedIndex = -1; } lstAccessory.EndUpdate(); }
private void lblSource_Click(object sender, EventArgs e) { CommonFunctions.OpenPDF(lblSource.Text, _objCharacter); }
private void cboCategory_SelectedIndexChanged(object sender, EventArgs e) { trePowers.Nodes.Clear(); string strCategory = cboCategory.SelectedValue?.ToString(); List <string> lstPowerWhitelist = new List <string>(); // If the Critter is only allowed certain Powers, display only those. XPathNavigator xmlOptionalPowers = _xmlMetatypeDataNode.SelectSingleNode("optionalpowers"); if (xmlOptionalPowers != null) { foreach (XPathNavigator xmlNode in xmlOptionalPowers.Select("power")) { lstPowerWhitelist.Add(xmlNode.Value); } // Determine if the Critter has a physical presence Power (Materialization, Possession, or Inhabitation). bool blnPhysicalPresence = _objCharacter.CritterPowers.Any(x => x.Name == "Materialization" || x.Name == "Possession" || x.Name == "Inhabitation"); // Add any Critter Powers the Critter comes with that have been manually deleted so they can be re-added. foreach (XPathNavigator objXmlCritterPower in _xmlMetatypeDataNode.Select("powers/power")) { bool blnAddPower = true; // Make sure the Critter doesn't already have the Power. foreach (CritterPower objCheckPower in _objCharacter.CritterPowers) { if (objCheckPower.Name == objXmlCritterPower.Value) { blnAddPower = false; break; } if ((objCheckPower.Name == "Materialization" || objCheckPower.Name == "Possession" || objCheckPower.Name == "Inhabitation") && blnPhysicalPresence) { blnAddPower = false; break; } } if (blnAddPower) { lstPowerWhitelist.Add(objXmlCritterPower.Value); // If Manifestation is one of the Powers, also include Inhabitation and Possess if they're not already in the list. if (!blnPhysicalPresence) { if (objXmlCritterPower.Value == "Materialization") { bool blnFoundPossession = false; bool blnFoundInhabitation = false; foreach (string strCheckPower in lstPowerWhitelist) { if (strCheckPower == "Possession") { blnFoundPossession = true; } else if (strCheckPower == "Inhabitation") { blnFoundInhabitation = true; } if (blnFoundInhabitation && blnFoundPossession) { break; } } if (!blnFoundPossession) { lstPowerWhitelist.Add("Possession"); } if (!blnFoundInhabitation) { lstPowerWhitelist.Add("Inhabitation"); } } } } } } string strFilter = "(" + _objCharacter.Options.BookXPath() + ')'; if (!string.IsNullOrEmpty(strCategory) && strCategory != "Show All") { if (strCategory == "Toxic Critter Powers") { strFilter += " and (category = \"" + strCategory + "\" or toxic = \"True\")"; } else { strFilter += " and category = \"" + strCategory + '\"'; } } else { bool blnHasToxic = false; StringBuilder objCategoryFilter = new StringBuilder(); foreach (string strItem in _lstCategory.Select(x => x.Value)) { if (!string.IsNullOrEmpty(strItem)) { objCategoryFilter.Append("category = \"" + strItem + "\" or "); if (strItem == "Toxic Critter Powers") { objCategoryFilter.Append("toxic = \"True\" or "); blnHasToxic = true; } } } if (objCategoryFilter.Length > 0) { strFilter += " and (" + objCategoryFilter.ToString().TrimEndOnce(" or ") + ')'; } if (!blnHasToxic) { strFilter += " and (not(toxic) or toxic != \"True\")"; } } strFilter += CommonFunctions.GenerateSearchXPath(txtSearch.Text); foreach (XPathNavigator objXmlPower in _xmlBaseCritterPowerDataNode.Select("powers/power[" + strFilter + "]")) { string strPowerName = objXmlPower.SelectSingleNode("name")?.Value ?? LanguageManager.GetString("String_Unknown", GlobalOptions.Language); if (!lstPowerWhitelist.Contains(strPowerName) && lstPowerWhitelist.Count != 0) { continue; } if (!objXmlPower.RequirementsMet(_objCharacter, string.Empty, string.Empty)) { continue; } TreeNode objNode = new TreeNode { Tag = objXmlPower.SelectSingleNode("id")?.Value ?? string.Empty, Text = objXmlPower.SelectSingleNode("translate")?.Value ?? strPowerName }; trePowers.Nodes.Add(objNode); } trePowers.Sort(); }
/// <summary> /// Refreshes the list of qualities into the selected TreeNode. If the same number of /// </summary> /// <param name="treQualities">Treeview to insert the qualities into.</param> /// <param name="cmsQuality">ContextMenuStrip to add to each Quality node.</param> /// <param name="blnForce">Forces a refresh of the TreeNode despite a match.</param> protected void RefreshQualities(TreeView treQualities, ContextMenuStrip cmsQuality, bool blnForce = false) { //Count the child nodes in each treenode. int intQualityCount = 0; if (!blnForce) { foreach (TreeNode objTreeNode in treQualities.Nodes) { intQualityCount += objTreeNode.Nodes.Count; } } //If the node count is the same as the quality count, there's no need to do anything. if (blnForce || intQualityCount != _objCharacter.Qualities.Count) { // Multiple instances of the same quality are combined into just one entry with a number next to it (e.g. 6 discrete entries of "Focused Concentration" become "Focused Concentration 6") HashSet <string> strQualitiesToPrint = new HashSet <string>(); foreach (TreeNode objTreeNode in treQualities.Nodes) { objTreeNode.Nodes.Clear(); } foreach (Quality objQuality in _objCharacter.Qualities) { if (!strQualitiesToPrint.Contains(objQuality.QualityId + " " + objQuality.SourceName + " " + objQuality.Extra)) { strQualitiesToPrint.Add(objQuality.QualityId + " " + objQuality.SourceName + " " + objQuality.Extra); } } // Populate the Qualities list. foreach (Quality objQuality in _objCharacter.Qualities) { if (strQualitiesToPrint.Contains(objQuality.QualityId + " " + objQuality.SourceName + " " + objQuality.Extra)) { strQualitiesToPrint.Remove(objQuality.QualityId + " " + objQuality.SourceName + " " + objQuality.Extra); } else { continue; } TreeNode objNode = new TreeNode(); objNode.Text = objQuality.DisplayName; objNode.Tag = objQuality.InternalId; objNode.ContextMenuStrip = cmsQuality; if (!string.IsNullOrEmpty(objQuality.Notes)) { objNode.ForeColor = Color.SaddleBrown; } else if (objQuality.OriginSource == QualitySource.Metatype || objQuality.OriginSource == QualitySource.MetatypeRemovable || objQuality.OriginSource == QualitySource.Improvement) { objNode.ForeColor = SystemColors.GrayText; } objNode.ToolTipText = CommonFunctions.WordWrap(objQuality.Notes, 100); switch (objQuality.Type) { case QualityType.Positive: treQualities.Nodes[0].Nodes.Add(objNode); treQualities.Nodes[0].Expand(); break; case QualityType.Negative: treQualities.Nodes[1].Nodes.Add(objNode); treQualities.Nodes[1].Expand(); break; case QualityType.LifeModule: treQualities.Nodes[2].Nodes.Add(objNode); treQualities.Nodes[2].Expand(); break; } } } }
private void lblSource_Click(object sender, EventArgs e) { CommonFunctions.OpenPdfFromControl(sender, e); }
/// <summary> /// Refresh the information for the selected Vehicle. /// </summary> private void UpdateSelectedVehicle() { if (string.IsNullOrEmpty(lstVehicle.Text)) { return; } decimal decCostModifier = 1.0m; // Retireve the information for the selected Vehicle. XmlNode objXmlVehicle = _objXmlDocument.SelectSingleNode("/chummer/vehicles/vehicle[name = \"" + lstVehicle.SelectedValue + "\"]"); if (objXmlVehicle == null) { return; } if (chkUsedVehicle.Checked) { decCostModifier = 1.0m - (nudUsedVehicleDiscount.Value / 100.0m); } lblVehicleHandling.Text = objXmlVehicle["handling"]?.InnerText; lblVehicleAccel.Text = objXmlVehicle["accel"]?.InnerText; lblVehicleSpeed.Text = objXmlVehicle["speed"]?.InnerText; lblVehiclePilot.Text = objXmlVehicle["pilot"]?.InnerText; lblVehicleBody.Text = objXmlVehicle["body"]?.InnerText; lblVehicleArmor.Text = objXmlVehicle["armor"]?.InnerText; lblVehicleSeats.Text = objXmlVehicle["seats"]?.InnerText; lblVehicleSensor.Text = objXmlVehicle["sensor"]?.InnerText; string strAvail = objXmlVehicle["avail"]?.InnerText ?? string.Empty; if (!string.IsNullOrEmpty(strAvail)) { string strSuffix = string.Empty; if (strAvail.EndsWith('R', 'F')) { strSuffix = strAvail.Substring(strAvail.Length - 1, 1); // Translate the Avail string. if (strSuffix == "R") { strSuffix = LanguageManager.GetString("String_AvailRestricted", GlobalOptions.Language); } else if (strSuffix == "F") { strSuffix = LanguageManager.GetString("String_AvailForbidden", GlobalOptions.Language); } strAvail = strAvail.Substring(0, strAvail.Length - 1); } if (chkUsedVehicle.Checked) { if (int.TryParse(strAvail, out int intTmp)) { strAvail = intTmp + 4.ToString(); } } strAvail += strSuffix; } lblVehicleAvail.Text = strAvail; if (_blackMarketMaps != null) { chkBlackMarketDiscount.Checked = _blackMarketMaps.Contains(objXmlVehicle["category"]?.InnerText); } // Apply the cost multiplier to the Vehicle (will be 1 unless Used Vehicle is selected) if (objXmlVehicle["cost"]?.InnerText.StartsWith("Variable") == true) { lblVehicleCost.Text = objXmlVehicle["cost"].InnerText; lblTest.Text = string.Empty; } else { decimal decCost = 0.0m; if (!chkFreeItem.Checked) { objXmlVehicle.TryGetDecFieldQuickly("cost", ref decCost); // Apply the markup if applicable. decCost *= decCostModifier; decCost *= 1 + (nudMarkup.Value / 100.0m); if (chkBlackMarketDiscount.Checked) { decCost *= 0.9m; } } lblVehicleCost.Text = decCost.ToString(_objCharacter.Options.NuyenFormat, GlobalOptions.CultureInfo) + '¥'; lblTest.Text = _objCharacter.AvailTest(decCost, lblVehicleAvail.Text); } string strBook = CommonFunctions.LanguageBookShort(objXmlVehicle["source"]?.InnerText, GlobalOptions.Language); string strPage = objXmlVehicle["page"]?.InnerText; if (objXmlVehicle["altpage"] != null) { strPage = objXmlVehicle["altpage"].InnerText; } lblSource.Text = strBook + " " + strPage; tipTooltip.SetToolTip(lblSource, CommonFunctions.LanguageBookLong(objXmlVehicle["source"]?.InnerText, GlobalOptions.Language) + " " + LanguageManager.GetString("String_Page", GlobalOptions.Language) + " " + strPage); }
private void frmMain_Load(object sender, EventArgs e) { if (GlobalOptions.Instance.StartupFullscreen) this.WindowState = FormWindowState.Maximized; if (GlobalOptions.Instance.UseLogging) { CommonFunctions objFunctions = new CommonFunctions(); } }
/// Create a Martial Art from an XmlNode. /// <param name="objXmlArtNode">XmlNode to create the object from.</param> public void Create(XmlNode objXmlArtNode) { if (!objXmlArtNode.TryGetField("id", Guid.TryParse, out _guiSourceID)) { Log.Warn(new object[] { "Missing id field for xmlnode", objXmlArtNode }); Utils.BreakIfDebug(); } if (objXmlArtNode.TryGetStringFieldQuickly("name", ref _strName)) { _objCachedMyXmlNode = null; } objXmlArtNode.TryGetStringFieldQuickly("source", ref _strSource); objXmlArtNode.TryGetStringFieldQuickly("page", ref _strPage); objXmlArtNode.TryGetInt32FieldQuickly("cost", ref _intKarmaCost); if (!objXmlArtNode.TryGetStringFieldQuickly("altnotes", ref _strNotes)) { objXmlArtNode.TryGetStringFieldQuickly("notes", ref _strNotes); } _blnIsQuality = objXmlArtNode["isquality"]?.InnerText == bool.TrueString; if (objXmlArtNode["bonus"] != null) { ImprovementManager.CreateImprovements(_objCharacter, Improvement.ImprovementSource.MartialArt, InternalId, objXmlArtNode["bonus"], 1, DisplayNameShort(GlobalOptions.Language)); } if (string.IsNullOrEmpty(Notes)) { string strEnglishNameOnPage = Name; string strNameOnPage = string.Empty; // make sure we have something and not just an empty tag if (objXmlArtNode.TryGetStringFieldQuickly("nameonpage", ref strNameOnPage) && !string.IsNullOrEmpty(strNameOnPage)) { strEnglishNameOnPage = strNameOnPage; } string strQualityNotes = CommonFunctions.GetTextFromPDF(Source + ' ' + Page, strEnglishNameOnPage); if (string.IsNullOrEmpty(strQualityNotes) && GlobalOptions.Language != GlobalOptions.DefaultLanguage) { string strTranslatedNameOnPage = CurrentDisplayName; // don't check again it is not translated if (strTranslatedNameOnPage != _strName) { // if we found <altnameonpage>, and is not empty and not the same as english we must use that instead if (objXmlArtNode.TryGetStringFieldQuickly("altnameonpage", ref strNameOnPage) && !string.IsNullOrEmpty(strNameOnPage) && strNameOnPage != strEnglishNameOnPage) { strTranslatedNameOnPage = strNameOnPage; } Notes = CommonFunctions.GetTextFromPDF(Source + ' ' + DisplayPage(GlobalOptions.Language), strTranslatedNameOnPage); } } else { Notes = strQualityNotes; } } }
private async void lstItems_SelectedIndexChanged(object sender, EventArgs e) { if (_blnSkipRefresh) { return; } try { using (await CursorWait.NewAsync(this, token: _objGenericToken)) { if (await lstItems.DoThreadSafeFuncAsync(x => x.SelectedValue, _objGenericToken) is MasterIndexEntry objEntry) { await Task.WhenAll( lblSourceLabel.DoThreadSafeAsync(x => x.Visible = true, _objGenericToken), lblSourceClickReminder.DoThreadSafeAsync(x => x.Visible = true, _objGenericToken), objEntry.DisplaySource.SetControlAsync(lblSource, _objGenericToken)); (bool blnSuccess, Task <string> tskNotes) = await _dicCachedNotes.TryGetValueAsync(objEntry, _objGenericToken); if (!blnSuccess) { if (!GlobalSettings.Language.Equals(GlobalSettings.DefaultLanguage, StringComparison.OrdinalIgnoreCase) && (objEntry.TranslatedNameOnPage != objEntry.EnglishNameOnPage || objEntry.Source.Page != objEntry.DisplaySource.Page)) { // don't check again it is not translated tskNotes = Task.Run(async() => { string strReturn = await CommonFunctions.GetTextFromPdfAsync( objEntry.Source.ToString(), objEntry.EnglishNameOnPage); if (string.IsNullOrEmpty(strReturn)) { strReturn = await CommonFunctions.GetTextFromPdfAsync( objEntry.DisplaySource.ToString(), objEntry.TranslatedNameOnPage); } return(strReturn); }, _objGenericToken); } else { tskNotes = Task.Run(() => CommonFunctions.GetTextFromPdfAsync( objEntry.Source.ToString(), objEntry.EnglishNameOnPage), _objGenericToken); } await _dicCachedNotes.TryAddAsync(objEntry, tskNotes, _objGenericToken); } string strNotes = await tskNotes; await txtNotes.DoThreadSafeAsync(x => { x.Text = strNotes; x.Visible = true; }, _objGenericToken); } else { await Task.WhenAll( lblSourceLabel.DoThreadSafeAsync(x => x.Visible = false, _objGenericToken), lblSourceClickReminder.DoThreadSafeAsync(x => x.Visible = false, _objGenericToken), SourceString.Blank.SetControlAsync(lblSource, _objGenericToken), txtNotes.DoThreadSafeAsync(x => x.Visible = false, _objGenericToken)); } } } catch (OperationCanceledException) { //swallow this } }
private async void lblSource_Click(object sender, EventArgs e) { await CommonFunctions.OpenPdfFromControl(sender); }
private void tsUndoNuyenExpense_Click(object sender, EventArgs e) { ListViewItem objItem = new ListViewItem(); try { objItem = lstNuyen.SelectedItems[0]; } catch { return; } CommonFunctions objCommon = new CommonFunctions(_objCharacter); ExpenseLogEntry objEntry = new ExpenseLogEntry(); objItem = lstNuyen.SelectedItems[0]; // Find the selected Nuyen Expense. foreach (ExpenseLogEntry objCharacterEntry in _objCharacter.ExpenseEntries) { if (objCharacterEntry.InternalId == objItem.SubItems[3].Text) { objEntry = objCharacterEntry; break; } } if (objEntry.Undo == null) { MessageBox.Show(LanguageManager.Instance.GetString("Message_UndoNoHistory"), LanguageManager.Instance.GetString("MessageTitle_NoUndoHistory"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else if (objEntry.Undo.KarmaType == KarmaExpenseType.ImproveInitiateGrade) { // Get the grade of the item we're undoing and make sure it's the highest grade int intMaxGrade = 0; foreach (InitiationGrade objGrade in _objCharacter.InitiationGrades) { intMaxGrade = Math.Max(intMaxGrade, objGrade.Grade); } foreach (InitiationGrade objGrade in _objCharacter.InitiationGrades) { if (objGrade.InternalId == objEntry.Undo.ObjectId) { if (objGrade.Grade < intMaxGrade) { MessageBox.Show(LanguageManager.Instance.GetString("Message_UndoNotHighestGrade"), LanguageManager.Instance.GetString("MessageTitle_NotHighestGrade"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } break; } } if (MessageBox.Show(LanguageManager.Instance.GetString("Message_UndoExpense"), LanguageManager.Instance.GetString("MessageTitle_UndoExpense"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) return; } else { if (MessageBox.Show(LanguageManager.Instance.GetString("Message_UndoExpense"), LanguageManager.Instance.GetString("MessageTitle_UndoExpense"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) return; } switch (objEntry.Undo.NuyenType) { case NuyenExpenseType.AddCyberware: // Locate the Cyberware that was added. int intOldPenalty = 0; int intNewPenalty = 0; foreach (Cyberware objCyberware in _objCharacter.Cyberware) { if (objCyberware.InternalId == objEntry.Undo.ObjectId) { foreach (Cyberware objChild in objCyberware.Children) { // Remove the Improvements created by child items. _objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.Cyberware, objChild.InternalId); _objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.Bioware, objChild.InternalId); } // Remove the Improvements created by the item. _objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.Cyberware, objCyberware.InternalId); _objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.Bioware, objCyberware.InternalId); // Determine the character's Essence penalty before removing the Cyberware. intOldPenalty = _objCharacter.EssencePenalty; // Remove the Cyberware. _objCharacter.Cyberware.Remove(objCyberware); // Determine the character's Essence penalty after removing the Cyberware. intNewPenalty = _objCharacter.EssencePenalty; // Restore the character's MAG/RES if they have it. //if (!_objCharacter.OverrideSpecialAttributeEssenceLoss && !_objCharacter.OverrideSpecialAttributeEssenceLoss) //{ // if (intOldPenalty != intNewPenalty) // { // if (_objCharacter.MAGEnabled) // _objCharacter.MAG.Value += (intOldPenalty - intNewPenalty); // if (_objCharacter.RESEnabled) // _objCharacter.RES.Value += (intOldPenalty - intNewPenalty); // } //} // Remove the item from the Tree. foreach (TreeNode objNode in treCyberware.Nodes[0].Nodes) { if (objNode.Tag.ToString() == objEntry.Undo.ObjectId) { objNode.Remove(); break; } } foreach (TreeNode objNode in treCyberware.Nodes[1].Nodes) { if (objNode.Tag.ToString() == objEntry.Undo.ObjectId) { objNode.Remove(); break; } } // Remove any Weapon that the Cyberware created. if (objCyberware.WeaponID != Guid.Empty.ToString()) { foreach (Weapon objWeapon in _objCharacter.Weapons) { if (objWeapon.InternalId == objCyberware.WeaponID) { _objCharacter.Weapons.Remove(objWeapon); break; } } // Remove the TreeNode for the Weapon. foreach (TreeNode objWeaponNode in treWeapons.Nodes[0].Nodes) { if (objWeaponNode.Tag.ToString() == objCyberware.WeaponID) { treWeapons.Nodes[0].Nodes.Remove(objWeaponNode); break; } } } break; } else { foreach (Cyberware objChild in objCyberware.Children) { if (objChild.InternalId == objEntry.Undo.ObjectId) { // Remove the Improvements created by the item. _objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.Cyberware, objChild.InternalId); objCyberware.Children.Remove(objChild); // Remove the item from the Tree. foreach (TreeNode objNode in treCyberware.Nodes[0].Nodes) { foreach (TreeNode objChildNode in objNode.Nodes) { if (objChildNode.Tag.ToString() == objEntry.Undo.ObjectId) { objChildNode.Remove(); break; } } } foreach (TreeNode objNode in treCyberware.Nodes[1].Nodes) { foreach (TreeNode objChildNode in objNode.Nodes) { if (objChildNode.Tag.ToString() == objEntry.Undo.ObjectId) { objNode.Remove(); break; } } } break; } // Remove any Weapon that the Cyberware created. if (objChild.WeaponID != Guid.Empty.ToString()) { foreach (Weapon objWeapon in _objCharacter.Weapons) { if (objWeapon.InternalId == objChild.WeaponID) { _objCharacter.Weapons.Remove(objWeapon); break; } } // Remove the TreeNode for the Weapon. foreach (TreeNode objWeaponNode in treWeapons.Nodes[0].Nodes) { if (objWeaponNode.Tag.ToString() == objChild.WeaponID) { treWeapons.Nodes[0].Nodes.Remove(objWeaponNode); break; } } } } } } break; case NuyenExpenseType.AddGear: // Locate the Gear that was added. //If the gear was already deleted manually we will not be able to locate it here Gear objGear = objCommon.FindGear(objEntry.Undo.ObjectId, _objCharacter.Gear); if (objGear == null) break; objGear.Quantity -= objEntry.Undo.Qty; if (objGear.Quantity <= 0) { if (objGear.Parent != null) objGear.Parent.Children.Remove(objGear); else _objCharacter.Gear.Remove(objGear); objCommon.DeleteGear(objGear, treWeapons, _objImprovementManager); TreeNode objNode = objCommon.FindNode(objGear.InternalId, treGear); objNode.Remove(); } else { TreeNode objNode = objCommon.FindNode(objGear.InternalId, treGear); objNode.Text = objGear.DisplayName; } _objController.PopulateFocusList(treFoci); break; case NuyenExpenseType.AddVehicle: // Locate the Vehicle that was added. foreach (Vehicle objVehicle in _objCharacter.Vehicles) { if (objVehicle.InternalId == objEntry.Undo.ObjectId) { // Remove the Vehicle. _objCharacter.Vehicles.Remove(objVehicle); foreach (TreeNode objNode in treVehicles.Nodes[0].Nodes) { if (objNode.Tag.ToString() == objEntry.Undo.ObjectId) { objNode.Remove(); break; } } break; } } break; case NuyenExpenseType.AddVehicleMod: // Locate the Vehicle Mod that was added. foreach (Vehicle objVehicle in _objCharacter.Vehicles) { foreach (VehicleMod objMod in objVehicle.Mods) { if (objMod.InternalId == objEntry.Undo.ObjectId) { // Check for Improved Sensor bonus. if (objMod.Bonus != null) { if (objMod.Bonus["improvesensor"] != null) { ChangeVehicleSensor(objVehicle, false); } } // Remove the Vehicle Mod. objVehicle.Mods.Remove(objMod); // Remove the Vehicle Mod from the tree. foreach (TreeNode objNode in treVehicles.Nodes[0].Nodes) { foreach (TreeNode objChild in objNode.Nodes) { if (objChild.Tag.ToString() == objEntry.Undo.ObjectId) { objChild.Remove(); break; } } } break; } } } break; case NuyenExpenseType.AddVehicleGear: // Locate the Gear that was added. foreach (Vehicle objVehicle in _objCharacter.Vehicles) { foreach (Gear objVehicleGear in objVehicle.Gear) { if (objVehicleGear.InternalId == objEntry.Undo.ObjectId) { // Deduct the Qty from the Gear. objVehicleGear.Quantity -= objEntry.Undo.Qty; foreach (TreeNode objVNode in treVehicles.Nodes[0].Nodes) { foreach (TreeNode objNode in objVNode.Nodes) { if (objNode.Tag.ToString() == objEntry.Undo.ObjectId) { objNode.Text = objVehicleGear.DisplayName; // Remove the Node if its Qty has been reduced to 0. if (objVehicleGear.Quantity <= 0) objNode.Remove(); break; } } } // Remove the Gear if its Qty has been reduced to 0. if (objVehicleGear.Quantity <= 0) { objVehicle.Gear.Remove(objVehicleGear); } break; } else { // Look in child items. foreach (Gear objChild in objVehicleGear.Children) { if (objChild.InternalId == objEntry.Undo.ObjectId) { // Deduct the Qty from the Gear. objChild.Quantity -= objEntry.Undo.Qty; foreach (TreeNode objVNode in treVehicles.Nodes[0].Nodes) { foreach (TreeNode objNode in objVNode.Nodes) { foreach (TreeNode objChildNode in objNode.Nodes) { if (objChildNode.Tag.ToString() == objEntry.Undo.ObjectId) { objChildNode.Text = objChild.DisplayName; // Remove the Node if its Qty has been reduced to 0. if (objChild.Quantity <= 0) { objChildNode.Remove(); } break; } } } } // Remove the Gear if its Qty has been reduce to 0. if (objChild.Quantity <= 0) { objVehicleGear.Children.Remove(objChild); } break; } else { foreach (Gear objSubChild in objChild.Children) { if (objSubChild.InternalId == objEntry.Undo.ObjectId) { // Deduct the Qty from the Gear. objSubChild.Quantity -= objEntry.Undo.Qty; foreach (TreeNode objVNode in treVehicles.Nodes[0].Nodes) { foreach (TreeNode objNode in objVNode.Nodes) { foreach (TreeNode objChildNode in objNode.Nodes) { foreach (TreeNode objSubChildNode in objChildNode.Nodes) { if (objSubChildNode.Tag.ToString() == objEntry.Undo.ObjectId) { objSubChildNode.Text = objSubChild.DisplayName; // Remove the Node if its Qty has been reduced to 0. if (objSubChild.Quantity <= 0) { objSubChildNode.Remove(); } break; } } } } } // Remove the Gear if its Qty has been reduce to 0. if (objSubChild.Quantity <= 0) { objChild.Children.Remove(objSubChild); } break; } } } } } } } break; case NuyenExpenseType.AddVehicleWeapon: // Locate the Weapon that was added. foreach (Vehicle objVehicle in _objCharacter.Vehicles) { foreach (VehicleMod objMod in objVehicle.Mods) { foreach (Weapon objWeapon in objMod.Weapons) { if (objWeapon.InternalId == objEntry.Undo.ObjectId) { // Remove the Weapon. objMod.Weapons.Remove(objWeapon); // Remove the Weapon from the Tree. foreach (TreeNode objVNode in treVehicles.Nodes[0].Nodes) { foreach (TreeNode objNode in objVNode.Nodes) { foreach (TreeNode objChild in objNode.Nodes) { if (objChild.Tag.ToString() == objEntry.Undo.ObjectId) { objChild.Remove(); break; } } } } break; } else { if (objWeapon.UnderbarrelWeapons.Count > 0) { foreach (Weapon objUnderbarrelWeapon in objWeapon.UnderbarrelWeapons) { if (objUnderbarrelWeapon.InternalId == objEntry.Undo.ObjectId) { // Remove the Underbarrel Weapon. objWeapon.UnderbarrelWeapons.Remove(objUnderbarrelWeapon); // Remove the Underbarrel Weapon from the Tree. foreach (TreeNode objVNode in treVehicles.Nodes[0].Nodes) { foreach (TreeNode objNode in objVNode.Nodes) { foreach (TreeNode objChild in objNode.Nodes) { foreach (TreeNode objSubChild in objChild.Nodes) { if (objSubChild.Tag.ToString() == objEntry.Undo.ObjectId) { objSubChild.Remove(); break; } } } } } break; } } } } } } } break; case NuyenExpenseType.AddVehicleWeaponAccessory: // Locate the Weapon Accessory that was added. foreach (Vehicle objVehicle in _objCharacter.Vehicles) { foreach (VehicleMod objMod in objVehicle.Mods) { foreach (Weapon objWeapon in objMod.Weapons) { foreach (WeaponAccessory objAccessory in objWeapon.WeaponAccessories) { if (objAccessory.InternalId == objEntry.Undo.ObjectId) { // Remove the Weapon Accessory. objWeapon.WeaponAccessories.Remove(objAccessory); // Remove the Weapon Accessory from the Tree. foreach (TreeNode objVNode in treVehicles.Nodes[0].Nodes) { foreach (TreeNode objNode in objVNode.Nodes) { foreach (TreeNode objWNode in objNode.Nodes) { foreach (TreeNode objChild in objWNode.Nodes) { if (objChild.Tag.ToString() == objEntry.Undo.ObjectId) { objChild.Remove(); break; } } } } } break; } } if (objWeapon.UnderbarrelWeapons.Count > 0) { foreach (Weapon objUnderbarrelWeapon in objWeapon.UnderbarrelWeapons) { foreach (WeaponAccessory objAccessory in objUnderbarrelWeapon.WeaponAccessories) { if (objAccessory.InternalId == objEntry.Undo.ObjectId) { // Remove the Weapon Accessory. objUnderbarrelWeapon.WeaponAccessories.Remove(objAccessory); // Remove the Weapon Accessory from the Tree. foreach (TreeNode objVNode in treVehicles.Nodes[0].Nodes) { foreach (TreeNode objNode in objVNode.Nodes) { foreach (TreeNode objWNode in objNode.Nodes) { foreach (TreeNode objChild in objWNode.Nodes) { foreach (TreeNode objSubChild in objChild.Nodes) { if (objSubChild.Tag.ToString() == objEntry.Undo.ObjectId) { objSubChild.Remove(); break; } } } } } } break; } } } } } } } break; case NuyenExpenseType.AddVehicleWeaponMod: // Locate the Weapon Mod that was added. foreach (Vehicle objVehicle in _objCharacter.Vehicles) { foreach (VehicleMod objMod in objVehicle.Mods) { foreach (Weapon objWeapon in objMod.Weapons) { foreach (WeaponMod objWMod in objWeapon.WeaponMods) { if (objMod.InternalId == objEntry.Undo.ObjectId) { // Remove the Weapon Mod. objWeapon.WeaponMods.Remove(objWMod); // Remove the Weapon Mod from the Tree. foreach (TreeNode objVNode in treVehicles.Nodes[0].Nodes) { foreach (TreeNode objNode in objVNode.Nodes) { foreach (TreeNode objWNode in objNode.Nodes) { foreach (TreeNode objChild in objWNode.Nodes) { if (objChild.Tag.ToString() == objEntry.Undo.ObjectId) { objChild.Remove(); break; } } } } } break; } } if (objWeapon.UnderbarrelWeapons.Count > 0) { foreach (Weapon objUnderbarrelWeapon in objWeapon.UnderbarrelWeapons) { foreach (WeaponMod objWMod in objUnderbarrelWeapon.WeaponMods) { if (objWMod.InternalId == objEntry.Undo.ObjectId) { // Remove the Weapon Mod. objUnderbarrelWeapon.WeaponMods.Remove(objWMod); // Remove the Weapon Mod from the Tree. foreach (TreeNode objVNode in treVehicles.Nodes[0].Nodes) { foreach (TreeNode objNode in objVNode.Nodes) { foreach (TreeNode objWNode in objNode.Nodes) { foreach (TreeNode objChild in objWNode.Nodes) { foreach (TreeNode objSubChild in objChild.Nodes) { if (objSubChild.Tag.ToString() == objEntry.Undo.ObjectId) { objSubChild.Remove(); break; } } } } } } break; } } } } } } } break; case NuyenExpenseType.AddArmor: // Locate the Armor that was added. Armor objArmor = objCommon.FindArmor(objEntry.Undo.ObjectId, _objCharacter.Armor); if (objArmor != null) { // Remove the Improvements for any child items. foreach (ArmorMod objMod in objArmor.ArmorMods) _objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.ArmorMod, objMod.InternalId); // Remove the Improvements for the Armor. _objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.Armor, objArmor.InternalId); // Remove the Armor from the character. _objCharacter.Armor.Remove(objArmor); // Remove the Armor from the Tree. TreeNode objArmorNode = objCommon.FindNode(objEntry.Undo.ObjectId, treArmor); objArmorNode.Remove(); } break; case NuyenExpenseType.AddArmorMod: // Locate the Armor Mod that was added. foreach (Armor objFoundArmor in _objCharacter.Armor) { foreach (ArmorMod objMod in objFoundArmor.ArmorMods) { if (objMod.InternalId == objEntry.Undo.ObjectId) { // Remove the Improtements for the Armor Mod. _objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.ArmorMod, objMod.InternalId); // Remove the Armor Mod from the Armor. objFoundArmor.ArmorMods.Remove(objMod); // Remove the Cyberweapon created by the Mod if applicable. if (objMod.WeaponID != Guid.Empty.ToString()) { // Remove the Weapon from the TreeView. TreeNode objRemoveNode = new TreeNode(); foreach (TreeNode objWeaponNode in treWeapons.Nodes[0].Nodes) { if (objWeaponNode.Tag.ToString() == objMod.WeaponID) objRemoveNode = objWeaponNode; } treWeapons.Nodes.Remove(objRemoveNode); // Remove the Weapon from the Character. Weapon objRemoveWeapon = new Weapon(_objCharacter); foreach (Weapon objWeapon in _objCharacter.Weapons) { if (objWeapon.InternalId == objMod.WeaponID) objRemoveWeapon = objWeapon; } _objCharacter.Weapons.Remove(objRemoveWeapon); } // Remove the Armor Mod from the Tree. TreeNode objNode = objCommon.FindNode(objMod.InternalId, treArmor.Nodes[0]); objNode.Remove(); break; } } } break; case NuyenExpenseType.AddWeapon: // Locate the Weapon that was added. foreach (Weapon objWeapon in _objCharacter.Weapons) { if (objWeapon.InternalId == objEntry.Undo.ObjectId) { // Remove the Weapn from the character. _objCharacter.Weapons.Remove(objWeapon); // Remove the Weapon from the Tree. foreach (TreeNode objNode in treWeapons.Nodes[0].Nodes) { if (objNode.Tag.ToString() == objEntry.Undo.ObjectId) { objNode.Remove(); break; } } break; } } break; case NuyenExpenseType.AddWeaponAccessory: // Locate the Weapon Accessory that was added. foreach (Weapon objWeapon in _objCharacter.Weapons) { foreach (WeaponAccessory objAccessory in objWeapon.WeaponAccessories) { if (objAccessory.InternalId == objEntry.Undo.ObjectId) { // Remove the Weapon Accessory. objWeapon.WeaponAccessories.Remove(objAccessory); // Remove the Weapon Accessory from the tree. foreach (TreeNode objNode in treWeapons.Nodes[0].Nodes) { foreach (TreeNode objChild in objNode.Nodes) { if (objChild.Tag.ToString() == objEntry.Undo.ObjectId) { objChild.Remove(); break; } } } break; } } } break; case NuyenExpenseType.AddWeaponMod: // Locate the Weapon Mod that was added. foreach (Weapon objWeapon in _objCharacter.Weapons) { foreach (WeaponMod objMod in objWeapon.WeaponMods) { if (objMod.InternalId == objEntry.Undo.ObjectId) { // Remove the Weapon Mod. objWeapon.WeaponMods.Remove(objMod); // Remove the Weapon Mod from the tree. foreach (TreeNode objNode in treWeapons.Nodes[0].Nodes) { foreach (TreeNode objChild in objNode.Nodes) { if (objChild.Tag.ToString() == objEntry.Undo.ObjectId) { objChild.Remove(); break; } } } break; } } } break; case NuyenExpenseType.IncreaseLifestyle: // Locate the Lifestyle that was increased. foreach (Lifestyle objLifestyle in _objCharacter.Lifestyles) { if (objLifestyle.Name == objEntry.Undo.ObjectId) { objLifestyle.Months--; RefreshSelectedLifestyle(); break; } } break; case NuyenExpenseType.AddArmorGear: // Locate the Armor Gear that was added. foreach (Armor objFoundArmor in _objCharacter.Armor) { foreach (Gear objArmorGear in objFoundArmor.Gear) { if (objArmorGear.InternalId == objEntry.Undo.ObjectId) { // Deduct the Qty from the Gear. objArmorGear.Quantity -= objEntry.Undo.Qty; foreach (TreeNode objArmorNode in treArmor.Nodes[0].Nodes) { foreach (TreeNode objNode in objArmorNode.Nodes) { if (objNode.Tag.ToString() == objEntry.Undo.ObjectId) { objNode.Text = objArmorGear.DisplayName; // Remove the Node if its Qty has been reduced to 0. if (objArmorGear.Quantity <= 0) objNode.Remove(); break; } } } // Remove the Gear if its Qty has been reduced to 0. if (objArmorGear.Quantity <= 0) { // Remove any Improvements created by the Gear. _objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.Gear, objArmorGear.InternalId); objFoundArmor.Gear.Remove(objArmorGear); // Remove any Weapons created by the Gear. foreach (Weapon objWeapon in _objCharacter.Weapons) { if (objWeapon.InternalId == objArmorGear.WeaponID) { _objCharacter.Weapons.Remove(objWeapon); foreach (TreeNode objWeaponNode in treWeapons.Nodes[0].Nodes) { if (objWeaponNode.Tag.ToString() == objArmorGear.WeaponID) { objWeaponNode.Remove(); break; } } break; } } } break; } else { // Look in child items. foreach (Gear objChild in objArmorGear.Children) { if (objChild.InternalId == objEntry.Undo.ObjectId) { // Deduct the Qty from the Gear. objChild.Quantity -= objEntry.Undo.Qty; foreach (TreeNode objArmorNode in treArmor.Nodes[0].Nodes) { foreach (TreeNode objNode in objArmorNode.Nodes) { foreach (TreeNode objChildNode in objNode.Nodes) { if (objChildNode.Tag.ToString() == objEntry.Undo.ObjectId) { objChildNode.Text = objChild.DisplayName; // Remove the Node if its Qty has been reduced to 0. if (objChild.Quantity <= 0) { objChildNode.Remove(); // Remove any Weapons created by the Gear. foreach (Weapon objWeapon in _objCharacter.Weapons) { if (objWeapon.InternalId == objChild.WeaponID) { _objCharacter.Weapons.Remove(objWeapon); foreach (TreeNode objWeaponNode in treWeapons.Nodes[0].Nodes) { if (objWeaponNode.Tag.ToString() == objChild.WeaponID) { objWeaponNode.Remove(); break; } } break; } } } break; } } } } // Remove the Gear if its Qty has been reduce to 0. if (objChild.Quantity <= 0) { // Remove any Improvements created by the Gear. _objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.Gear, objChild.InternalId); objArmorGear.Children.Remove(objChild); } break; } else { foreach (Gear objSubChild in objChild.Children) { if (objSubChild.InternalId == objEntry.Undo.ObjectId) { // Deduct the Qty from the Gear. objSubChild.Quantity -= objEntry.Undo.Qty; foreach (TreeNode objArmorNode in treArmor.Nodes[0].Nodes) { foreach (TreeNode objNode in objArmorNode.Nodes) { foreach (TreeNode objChildNode in objNode.Nodes) { foreach (TreeNode objSubChildNode in objChildNode.Nodes) { if (objSubChildNode.Tag.ToString() == objEntry.Undo.ObjectId) { objSubChildNode.Text = objSubChild.DisplayName; // Remove the Node if its Qty has been reduced to 0. if (objSubChild.Quantity <= 0) { objSubChildNode.Remove(); // Remove any Weapons created by the Gear. foreach (Weapon objWeapon in _objCharacter.Weapons) { if (objWeapon.InternalId == objSubChild.WeaponID) { _objCharacter.Weapons.Remove(objWeapon); foreach (TreeNode objWeaponNode in treWeapons.Nodes[0].Nodes) { if (objWeaponNode.Tag.ToString() == objSubChild.WeaponID) { objWeaponNode.Remove(); break; } } break; } } } break; } } } } } // Remove the Gear if its Qty has been reduce to 0. if (objSubChild.Quantity <= 0) { // Remove any Improvements created by the Gear. _objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.Gear, objSubChild.InternalId); objChild.Children.Remove(objSubChild); } break; } } } } } } } break; case NuyenExpenseType.AddVehicleModCyberware: // Locate the Cyberware that was added. foreach (Vehicle objVehicle in _objCharacter.Vehicles) { foreach (VehicleMod objMod in objVehicle.Mods) { foreach (Cyberware objCyberware in objMod.Cyberware) { if (objCyberware.InternalId == objEntry.Undo.ObjectId) { // Remove the Cyberware. objMod.Cyberware.Remove(objCyberware); // Remove the Cyberware from the Tree. foreach (TreeNode objVNode in treVehicles.Nodes[0].Nodes) { foreach (TreeNode objNode in objVNode.Nodes) { foreach (TreeNode objChild in objNode.Nodes) { if (objChild.Tag.ToString() == objEntry.Undo.ObjectId) { objChild.Remove(); break; } } } } break; } } } } break; case NuyenExpenseType.AddCyberwareGear: // Locate the Gear that was added. Cyberware objFoundCyberware = new Cyberware(_objCharacter); Gear objFoundGear = _objFunctions.FindCyberwareGear(objEntry.Undo.ObjectId, _objCharacter.Cyberware, out objFoundCyberware); _objFunctions.DeleteGear(objFoundGear, treWeapons, _objImprovementManager); if (objFoundGear.Parent == null) objFoundCyberware.Gear.Remove(objFoundGear); else objFoundGear.Parent.Children.Remove(objFoundGear); TreeNode objFoundNode = _objFunctions.FindNode(objFoundGear.InternalId, treCyberware); objFoundNode.Remove(); break; case NuyenExpenseType.AddWeaponGear: // Locate the Gear that was added. WeaponAccessory objFoundAccessory = new WeaponAccessory(_objCharacter); Gear objFoundAccGear = _objFunctions.FindWeaponGear(objEntry.Undo.ObjectId, _objCharacter.Weapons, out objFoundAccessory); _objFunctions.DeleteGear(objFoundAccGear, treWeapons, _objImprovementManager); if (objFoundAccGear.Parent == null) objFoundAccessory.Gear.Remove(objFoundAccGear); else objFoundAccGear.Parent.Children.Remove(objFoundAccGear); TreeNode objFoundAccNode = _objFunctions.FindNode(objFoundAccGear.InternalId, treWeapons); objFoundAccNode.Remove(); break; case NuyenExpenseType.ManualAdd: case NuyenExpenseType.ManualSubtract: break; } // Refund the Nuyen amount and remove the Expense Entry. _objCharacter.Nuyen -= objEntry.Amount; _objCharacter.ExpenseEntries.Remove(objEntry); UpdateCharacterInfo(); _blnIsDirty = true; UpdateWindowTitle(); }
/// <summary> /// Create a Critter, put them into Career Mode, link them, and open the newly-created Critter. /// </summary> /// <param name="strCritterName">Name of the Critter's Metatype.</param> /// <param name="intForce">Critter's Force.</param> private async void CreateCritter(string strCritterName, int intForce) { // Code from frmMetatype. XmlDocument objXmlDocument = await _objSpirit.CharacterObject.LoadDataAsync("critters.xml").ConfigureAwait(false); XmlNode objXmlMetatype = objXmlDocument.SelectSingleNode("/chummer/metatypes/metatype[name = " + strCritterName.CleanXPath() + "]"); // If the Critter could not be found, show an error and get out of here. if (objXmlMetatype == null) { Program.MainForm.ShowMessageBox(string.Format(GlobalOptions.CultureInfo, LanguageManager.GetString("Message_UnknownCritterType"), strCritterName), LanguageManager.GetString("MessageTitle_SelectCritterType"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } using (new CursorWait(this)) { // The Critter should use the same settings file as the character. using (Character objCharacter = new Character { CharacterOptionsKey = _objSpirit.CharacterObject.CharacterOptionsKey, // Override the defaults for the setting. IgnoreRules = true, IsCritter = true }) { if (!string.IsNullOrEmpty(txtCritterName.Text)) { objCharacter.Name = txtCritterName.Text; } string strSpace = LanguageManager.GetString("String_Space"); using (SaveFileDialog saveFileDialog = new SaveFileDialog { Filter = LanguageManager.GetString("DialogFilter_Chum5") + '|' + LanguageManager.GetString("DialogFilter_All"), FileName = strCritterName + strSpace + '(' + LanguageManager.GetString(_objSpirit.RatingLabel) + strSpace + _objSpirit.Force.ToString(GlobalOptions.InvariantCultureInfo) + ").chum5" }) { if (saveFileDialog.ShowDialog(this) != DialogResult.OK) { return; } string strFileName = saveFileDialog.FileName; objCharacter.FileName = strFileName; } // Set Metatype information. if (strCritterName == "Ally Spirit") { objCharacter.BOD.AssignLimits( CommonFunctions.ExpressionToInt(objXmlMetatype["bodmin"]?.InnerText, intForce, 0, 0), CommonFunctions.ExpressionToInt(objXmlMetatype["bodmax"]?.InnerText, intForce, 0, 0), CommonFunctions.ExpressionToInt(objXmlMetatype["bodaug"]?.InnerText, intForce, 0, 0)); objCharacter.AGI.AssignLimits( CommonFunctions.ExpressionToInt(objXmlMetatype["agimin"]?.InnerText, intForce, 0, 0), CommonFunctions.ExpressionToInt(objXmlMetatype["agimax"]?.InnerText, intForce, 0, 0), CommonFunctions.ExpressionToInt(objXmlMetatype["agiaug"]?.InnerText, intForce, 0, 0)); objCharacter.REA.AssignLimits( CommonFunctions.ExpressionToInt(objXmlMetatype["reamin"]?.InnerText, intForce, 0, 0), CommonFunctions.ExpressionToInt(objXmlMetatype["reamax"]?.InnerText, intForce, 0, 0), CommonFunctions.ExpressionToInt(objXmlMetatype["reaaug"]?.InnerText, intForce, 0, 0)); objCharacter.STR.AssignLimits( CommonFunctions.ExpressionToInt(objXmlMetatype["strmin"]?.InnerText, intForce, 0, 0), CommonFunctions.ExpressionToInt(objXmlMetatype["strmax"]?.InnerText, intForce, 0, 0), CommonFunctions.ExpressionToInt(objXmlMetatype["straug"]?.InnerText, intForce, 0, 0)); objCharacter.CHA.AssignLimits( CommonFunctions.ExpressionToInt(objXmlMetatype["chamin"]?.InnerText, intForce, 0, 0), CommonFunctions.ExpressionToInt(objXmlMetatype["chamax"]?.InnerText, intForce, 0, 0), CommonFunctions.ExpressionToInt(objXmlMetatype["chaaug"]?.InnerText, intForce, 0, 0)); objCharacter.INT.AssignLimits( CommonFunctions.ExpressionToInt(objXmlMetatype["intmin"]?.InnerText, intForce, 0, 0), CommonFunctions.ExpressionToInt(objXmlMetatype["intmax"]?.InnerText, intForce, 0, 0), CommonFunctions.ExpressionToInt(objXmlMetatype["intaug"]?.InnerText, intForce, 0, 0)); objCharacter.LOG.AssignLimits( CommonFunctions.ExpressionToInt(objXmlMetatype["logmin"]?.InnerText, intForce, 0, 0), CommonFunctions.ExpressionToInt(objXmlMetatype["logmax"]?.InnerText, intForce, 0, 0), CommonFunctions.ExpressionToInt(objXmlMetatype["logaug"]?.InnerText, intForce, 0, 0)); objCharacter.WIL.AssignLimits( CommonFunctions.ExpressionToInt(objXmlMetatype["wilmin"]?.InnerText, intForce, 0, 0), CommonFunctions.ExpressionToInt(objXmlMetatype["wilmax"]?.InnerText, intForce, 0, 0), CommonFunctions.ExpressionToInt(objXmlMetatype["wilaug"]?.InnerText, intForce, 0, 0)); objCharacter.MAG.AssignLimits( CommonFunctions.ExpressionToInt(objXmlMetatype["magmin"]?.InnerText, intForce, 0, 0), CommonFunctions.ExpressionToInt(objXmlMetatype["magmax"]?.InnerText, intForce, 0, 0), CommonFunctions.ExpressionToInt(objXmlMetatype["magaug"]?.InnerText, intForce, 0, 0)); objCharacter.RES.AssignLimits( CommonFunctions.ExpressionToInt(objXmlMetatype["resmin"]?.InnerText, intForce, 0, 0), CommonFunctions.ExpressionToInt(objXmlMetatype["resmax"]?.InnerText, intForce, 0, 0), CommonFunctions.ExpressionToInt(objXmlMetatype["resaug"]?.InnerText, intForce, 0, 0)); objCharacter.EDG.AssignLimits( CommonFunctions.ExpressionToInt(objXmlMetatype["edgmin"]?.InnerText, intForce, 0, 0), CommonFunctions.ExpressionToInt(objXmlMetatype["edgmax"]?.InnerText, intForce, 0, 0), CommonFunctions.ExpressionToInt(objXmlMetatype["edgaug"]?.InnerText, intForce, 0, 0)); objCharacter.ESS.AssignLimits( CommonFunctions.ExpressionToInt(objXmlMetatype["essmin"]?.InnerText, intForce, 0, 0), CommonFunctions.ExpressionToInt(objXmlMetatype["essmax"]?.InnerText, intForce, 0, 0), CommonFunctions.ExpressionToInt(objXmlMetatype["essaug"]?.InnerText, intForce, 0, 0)); } else { int intMinModifier = -3; objCharacter.BOD.AssignLimits( CommonFunctions.ExpressionToInt(objXmlMetatype["bodmin"]?.InnerText, intForce, intMinModifier, 0), CommonFunctions.ExpressionToInt(objXmlMetatype["bodmin"]?.InnerText, intForce, 3, 0), CommonFunctions.ExpressionToInt(objXmlMetatype["bodmin"]?.InnerText, intForce, 3, 0)); objCharacter.AGI.AssignLimits( CommonFunctions.ExpressionToInt(objXmlMetatype["agimin"]?.InnerText, intForce, intMinModifier, 0), CommonFunctions.ExpressionToInt(objXmlMetatype["agimin"]?.InnerText, intForce, 3, 0), CommonFunctions.ExpressionToInt(objXmlMetatype["agimin"]?.InnerText, intForce, 3, 0)); objCharacter.REA.AssignLimits( CommonFunctions.ExpressionToInt(objXmlMetatype["reamin"]?.InnerText, intForce, intMinModifier, 0), CommonFunctions.ExpressionToInt(objXmlMetatype["reamin"]?.InnerText, intForce, 3, 0), CommonFunctions.ExpressionToInt(objXmlMetatype["reamin"]?.InnerText, intForce, 3, 0)); objCharacter.STR.AssignLimits( CommonFunctions.ExpressionToInt(objXmlMetatype["strmin"]?.InnerText, intForce, intMinModifier, 0), CommonFunctions.ExpressionToInt(objXmlMetatype["strmin"]?.InnerText, intForce, 3, 0), CommonFunctions.ExpressionToInt(objXmlMetatype["strmin"]?.InnerText, intForce, 3, 0)); objCharacter.CHA.AssignLimits( CommonFunctions.ExpressionToInt(objXmlMetatype["chamin"]?.InnerText, intForce, intMinModifier, 0), CommonFunctions.ExpressionToInt(objXmlMetatype["chamin"]?.InnerText, intForce, 3, 0), CommonFunctions.ExpressionToInt(objXmlMetatype["chamin"]?.InnerText, intForce, 3, 0)); objCharacter.INT.AssignLimits( CommonFunctions.ExpressionToInt(objXmlMetatype["intmin"]?.InnerText, intForce, intMinModifier, 0), CommonFunctions.ExpressionToInt(objXmlMetatype["intmin"]?.InnerText, intForce, 3, 0), CommonFunctions.ExpressionToInt(objXmlMetatype["intmin"]?.InnerText, intForce, 3, 0)); objCharacter.LOG.AssignLimits( CommonFunctions.ExpressionToInt(objXmlMetatype["logmin"]?.InnerText, intForce, intMinModifier, 0), CommonFunctions.ExpressionToInt(objXmlMetatype["logmin"]?.InnerText, intForce, 3, 0), CommonFunctions.ExpressionToInt(objXmlMetatype["logmin"]?.InnerText, intForce, 3, 0)); objCharacter.WIL.AssignLimits( CommonFunctions.ExpressionToInt(objXmlMetatype["wilmin"]?.InnerText, intForce, intMinModifier, 0), CommonFunctions.ExpressionToInt(objXmlMetatype["wilmin"]?.InnerText, intForce, 3, 0), CommonFunctions.ExpressionToInt(objXmlMetatype["wilmin"]?.InnerText, intForce, 3, 0)); objCharacter.MAG.AssignLimits( CommonFunctions.ExpressionToInt(objXmlMetatype["magmin"]?.InnerText, intForce, intMinModifier, 0), CommonFunctions.ExpressionToInt(objXmlMetatype["magmin"]?.InnerText, intForce, 3, 0), CommonFunctions.ExpressionToInt(objXmlMetatype["magmin"]?.InnerText, intForce, 3, 0)); objCharacter.RES.AssignLimits( CommonFunctions.ExpressionToInt(objXmlMetatype["resmin"]?.InnerText, intForce, intMinModifier, 0), CommonFunctions.ExpressionToInt(objXmlMetatype["resmin"]?.InnerText, intForce, 3, 0), CommonFunctions.ExpressionToInt(objXmlMetatype["resmin"]?.InnerText, intForce, 3, 0)); objCharacter.EDG.AssignLimits( CommonFunctions.ExpressionToInt(objXmlMetatype["edgmin"]?.InnerText, intForce, intMinModifier, 0), CommonFunctions.ExpressionToInt(objXmlMetatype["edgmin"]?.InnerText, intForce, 3, 0), CommonFunctions.ExpressionToInt(objXmlMetatype["edgmin"]?.InnerText, intForce, 3, 0)); objCharacter.ESS.AssignLimits( CommonFunctions.ExpressionToInt(objXmlMetatype["essmin"]?.InnerText, intForce, 0, 0), CommonFunctions.ExpressionToInt(objXmlMetatype["essmax"]?.InnerText, intForce, 0, 0), CommonFunctions.ExpressionToInt(objXmlMetatype["essaug"]?.InnerText, intForce, 0, 0)); } // If we're working with a Critter, set the Attributes to their default values. objCharacter.BOD.MetatypeMinimum = CommonFunctions.ExpressionToInt(objXmlMetatype["bodmin"]?.InnerText, intForce, 0, 0); objCharacter.AGI.MetatypeMinimum = CommonFunctions.ExpressionToInt(objXmlMetatype["agimin"]?.InnerText, intForce, 0, 0); objCharacter.REA.MetatypeMinimum = CommonFunctions.ExpressionToInt(objXmlMetatype["reamin"]?.InnerText, intForce, 0, 0); objCharacter.STR.MetatypeMinimum = CommonFunctions.ExpressionToInt(objXmlMetatype["strmin"]?.InnerText, intForce, 0, 0); objCharacter.CHA.MetatypeMinimum = CommonFunctions.ExpressionToInt(objXmlMetatype["chamin"]?.InnerText, intForce, 0, 0); objCharacter.INT.MetatypeMinimum = CommonFunctions.ExpressionToInt(objXmlMetatype["intmin"]?.InnerText, intForce, 0, 0); objCharacter.LOG.MetatypeMinimum = CommonFunctions.ExpressionToInt(objXmlMetatype["logmin"]?.InnerText, intForce, 0, 0); objCharacter.WIL.MetatypeMinimum = CommonFunctions.ExpressionToInt(objXmlMetatype["wilmin"]?.InnerText, intForce, 0, 0); objCharacter.MAG.MetatypeMinimum = CommonFunctions.ExpressionToInt(objXmlMetatype["magmin"]?.InnerText, intForce, 0, 0); objCharacter.RES.MetatypeMinimum = CommonFunctions.ExpressionToInt(objXmlMetatype["resmin"]?.InnerText, intForce, 0, 0); objCharacter.EDG.MetatypeMinimum = CommonFunctions.ExpressionToInt(objXmlMetatype["edgmin"]?.InnerText, intForce, 0, 0); objCharacter.ESS.MetatypeMinimum = CommonFunctions.ExpressionToInt(objXmlMetatype["essmax"]?.InnerText, intForce, 0, 0); // Sprites can never have Physical Attributes. if (objXmlMetatype["category"].InnerText.EndsWith("Sprite", StringComparison.Ordinal)) { objCharacter.BOD.AssignLimits(0, 0, 0); objCharacter.AGI.AssignLimits(0, 0, 0); objCharacter.REA.AssignLimits(0, 0, 0); objCharacter.STR.AssignLimits(0, 0, 0); } objCharacter.Metatype = strCritterName; objCharacter.MetatypeCategory = objXmlMetatype["category"].InnerText; objCharacter.Metavariant = string.Empty; objCharacter.MetatypeBP = 0; if (objXmlMetatype["movement"] != null) { objCharacter.Movement = objXmlMetatype["movement"].InnerText; } // Load the Qualities file. XmlDocument objXmlQualityDocument = _objSpirit.CharacterObject.LoadData("qualities.xml"); // Determine if the Metatype has any bonuses. if (objXmlMetatype.InnerXml.Contains("bonus")) { ImprovementManager.CreateImprovements(objCharacter, Improvement.ImprovementSource.Metatype, strCritterName, objXmlMetatype.SelectSingleNode("bonus"), 1, strCritterName); } // Create the Qualities that come with the Metatype. foreach (XmlNode objXmlQualityItem in objXmlMetatype.SelectNodes("qualities/*/quality")) { XmlNode objXmlQuality = objXmlQualityDocument.SelectSingleNode("/chummer/qualities/quality[name = " + objXmlQualityItem.InnerText.CleanXPath() + "]"); List <Weapon> lstWeapons = new List <Weapon>(1); Quality objQuality = new Quality(objCharacter); string strForceValue = objXmlQualityItem.Attributes?["select"]?.InnerText ?? string.Empty; QualitySource objSource = objXmlQualityItem.Attributes["removable"]?.InnerText == bool.TrueString ? QualitySource.MetatypeRemovable : QualitySource.Metatype; objQuality.Create(objXmlQuality, objSource, lstWeapons, strForceValue); objCharacter.Qualities.Add(objQuality); // Add any created Weapons to the character. foreach (Weapon objWeapon in lstWeapons) { objCharacter.Weapons.Add(objWeapon); } } // Add any Critter Powers the Metatype/Critter should have. XmlNode objXmlCritter = objXmlDocument.SelectSingleNode("/chummer/metatypes/metatype[name = " + objCharacter.Metatype.CleanXPath() + "]"); objXmlDocument = _objSpirit.CharacterObject.LoadData("critterpowers.xml"); foreach (XmlNode objXmlPower in objXmlCritter.SelectNodes("powers/power")) { XmlNode objXmlCritterPower = objXmlDocument.SelectSingleNode("/chummer/powers/power[name = " + objXmlPower.InnerText.CleanXPath() + "]"); CritterPower objPower = new CritterPower(objCharacter); string strForcedValue = objXmlPower.Attributes?["select"]?.InnerText ?? string.Empty; int intRating = CommonFunctions.ExpressionToInt(objXmlPower.Attributes?["rating"]?.InnerText, intForce, 0, 0); objPower.Create(objXmlCritterPower, intRating, strForcedValue); objCharacter.CritterPowers.Add(objPower); } XmlNode xmlOptionalPowersNode = objXmlCritter["optionalpowers"]; if (xmlOptionalPowersNode != null && intForce >= 3) { XmlDocument objDummyDocument = new XmlDocument { XmlResolver = null }; //For every 3 full points of Force a spirit has, it may gain one Optional Power. for (int i = intForce - 3; i >= 0; i -= 3) { XmlNode bonusNode = objDummyDocument.CreateNode(XmlNodeType.Element, "bonus", null); XmlNode powerNode = objDummyDocument.ImportNode(xmlOptionalPowersNode.CloneNode(true), true); bonusNode.AppendChild(powerNode); objDummyDocument.AppendChild(bonusNode); } foreach (XmlNode bonusNode in objDummyDocument.SelectNodes("/bonus")) { ImprovementManager.CreateImprovements(objCharacter, Improvement.ImprovementSource.Metatype, objCharacter.Metatype, bonusNode, 1, objCharacter.Metatype); } } // Add any Complex Forms the Critter comes with (typically Sprites) XmlDocument objXmlProgramDocument = _objSpirit.CharacterObject.LoadData("complexforms.xml"); foreach (XmlNode objXmlComplexForm in objXmlCritter.SelectNodes("complexforms/complexform")) { string strForceValue = objXmlComplexForm.Attributes?["select"]?.InnerText ?? string.Empty; XmlNode objXmlComplexFormData = objXmlProgramDocument.SelectSingleNode("/chummer/complexforms/complexform[name = " + objXmlComplexForm.InnerText.CleanXPath() + "]"); ComplexForm objComplexForm = new ComplexForm(objCharacter); objComplexForm.Create(objXmlComplexFormData, strForceValue); objCharacter.ComplexForms.Add(objComplexForm); } objCharacter.Alias = strCritterName; objCharacter.Created = true; if (!objCharacter.Save()) { return; } } // Link the newly-created Critter to the Spirit. imgLink.SetToolTip(LanguageManager.GetString(_objSpirit.EntityType == SpiritType.Spirit ? "Tip_Spirit_OpenFile" : "Tip_Sprite_OpenFile")); ContactDetailChanged?.Invoke(this, EventArgs.Empty); Character objOpenCharacter = await Program.MainForm.LoadCharacter(_objSpirit.FileName).ConfigureAwait(false); Program.MainForm.OpenCharacter(objOpenCharacter); } }
private void lblSkillName_Click(object sender, EventArgs e) { string strBook = _objSkill.Source + " " + _objSkill.Page; CommonFunctions objCommon = new CommonFunctions(); objCommon.OpenPDF(strBook); nudSkill.Focus(); }
/// <summary> /// Refresh the information for the selected Vehicle. /// </summary> private void UpdateSelectedVehicle() { if (_blnLoading) { return; } string strSelectedId = lstVehicle.SelectedValue?.ToString(); XPathNavigator objXmlVehicle = null; if (!string.IsNullOrEmpty(strSelectedId)) { // Retireve the information for the selected Vehicle. objXmlVehicle = _xmlBaseVehicleDataNode.SelectSingleNode("vehicles/vehicle[id = \"" + strSelectedId + "\"]"); } if (objXmlVehicle == null) { lblVehicleHandlingLabel.Visible = false; lblVehicleAccelLabel.Visible = false; lblVehicleSpeedLabel.Visible = false; lblVehiclePilotLabel.Visible = false; lblVehicleBodyLabel.Visible = false; lblVehicleArmorLabel.Visible = false; lblVehicleSeatsLabel.Visible = false; lblVehicleSensorLabel.Visible = false; lblVehicleAvailLabel.Visible = false; lblSourceLabel.Visible = false; lblVehicleCostLabel.Visible = false; lblTestLabel.Visible = false; lblVehicleHandling.Text = string.Empty; lblVehicleAccel.Text = string.Empty; lblVehicleSpeed.Text = string.Empty; lblVehiclePilot.Text = string.Empty; lblVehicleBody.Text = string.Empty; lblVehicleArmor.Text = string.Empty; lblVehicleSeats.Text = string.Empty; lblVehicleSensor.Text = string.Empty; lblVehicleAvail.Text = string.Empty; lblSource.Text = string.Empty; lblVehicleCost.Text = string.Empty; lblTest.Text = string.Empty; lblSource.SetToolTip(string.Empty); return; } decimal decCostModifier = 1.0m; if (chkUsedVehicle.Checked) { decCostModifier -= (nudUsedVehicleDiscount.Value / 100.0m); } lblVehicleHandling.Text = objXmlVehicle.SelectSingleNode("handling")?.Value; lblVehicleAccel.Text = objXmlVehicle.SelectSingleNode("accel")?.Value; lblVehicleSpeed.Text = objXmlVehicle.SelectSingleNode("speed")?.Value; lblVehiclePilot.Text = objXmlVehicle.SelectSingleNode("pilot")?.Value; lblVehicleBody.Text = objXmlVehicle.SelectSingleNode("body")?.Value; lblVehicleArmor.Text = objXmlVehicle.SelectSingleNode("armor")?.Value; lblVehicleSeats.Text = objXmlVehicle.SelectSingleNode("seats")?.Value; lblVehicleSensor.Text = objXmlVehicle.SelectSingleNode("sensor")?.Value; lblVehicleHandlingLabel.Visible = !string.IsNullOrEmpty(lblVehicleHandling.Text); lblVehicleAccelLabel.Visible = !string.IsNullOrEmpty(lblVehicleAccel.Text); lblVehicleSpeedLabel.Visible = !string.IsNullOrEmpty(lblVehicleSpeed.Text); lblVehiclePilotLabel.Visible = !string.IsNullOrEmpty(lblVehiclePilot.Text); lblVehicleBodyLabel.Visible = !string.IsNullOrEmpty(lblVehicleBody.Text); lblVehicleArmorLabel.Visible = !string.IsNullOrEmpty(lblVehicleArmor.Text); lblVehicleSeatsLabel.Visible = !string.IsNullOrEmpty(lblVehicleSeats.Text); lblVehicleSensorLabel.Visible = !string.IsNullOrEmpty(lblVehicleSensor.Text); AvailabilityValue objTotalAvail = new AvailabilityValue(0, objXmlVehicle.SelectSingleNode("avail")?.Value, chkUsedVehicle.Checked ? -4 : 0); lblVehicleAvail.Text = objTotalAvail.ToString(); lblVehicleAvailLabel.Visible = !string.IsNullOrEmpty(lblVehicleAvail.Text); chkBlackMarketDiscount.Enabled = _objCharacter.BlackMarketDiscount; if (!chkBlackMarketDiscount.Checked) { chkBlackMarketDiscount.Checked = GlobalOptions.AssumeBlackMarket && _setBlackMarketMaps.Contains(objXmlVehicle.SelectSingleNode("category") ?.Value); } else if (!_setBlackMarketMaps.Contains(objXmlVehicle.SelectSingleNode("category")?.Value)) { //Prevent chkBlackMarketDiscount from being checked if the gear category doesn't match. chkBlackMarketDiscount.Checked = false; } // Apply the cost multiplier to the Vehicle (will be 1 unless Used Vehicle is selected) string strCost = objXmlVehicle.SelectSingleNode("cost")?.Value ?? string.Empty; if (strCost.StartsWith("Variable", StringComparison.Ordinal)) { lblVehicleCost.Text = strCost.TrimStartOnce("Variable(", true).TrimEndOnce(')'); lblVehicleCostLabel.Visible = !string.IsNullOrEmpty(lblVehicleCost.Text); lblTest.Text = string.Empty; lblTestLabel.Visible = false; } else { decimal decCost = 0.0m; if (!chkFreeItem.Checked) { if (decimal.TryParse(strCost, NumberStyles.Any, GlobalOptions.InvariantCultureInfo, out decimal decTmp)) { decCost = decTmp; } // Apply the markup if applicable. decCost *= decCostModifier; decCost *= 1 + (nudMarkup.Value / 100.0m); if (chkBlackMarketDiscount.Checked) { decCost *= 0.9m; } if (_setDealerConnectionMaps != null) { if (_setDealerConnectionMaps.Any(set => objXmlVehicle.SelectSingleNode("category")?.Value.StartsWith(set, StringComparison.Ordinal) == true)) { decCost *= 0.9m; } } } lblVehicleCost.Text = decCost.ToString(_objCharacter.Options.NuyenFormat, GlobalOptions.CultureInfo) + '¥'; lblVehicleCostLabel.Visible = !string.IsNullOrEmpty(lblVehicleCost.Text); lblTest.Text = _objCharacter.AvailTest(decCost, lblVehicleAvail.Text); lblTestLabel.Visible = !string.IsNullOrEmpty(lblTest.Text); } string strSource = objXmlVehicle.SelectSingleNode("source")?.Value ?? LanguageManager.GetString("String_Unknown"); string strPage = objXmlVehicle.SelectSingleNode("altpage")?.Value ?? objXmlVehicle.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); }
/// <summary> /// Build the list of Metamagics. /// </summary> private async ValueTask BuildMetamagicList() { string strFilter = '(' + _objCharacter.Settings.BookXPath() + ')'; // If the character has MAG enabled, filter the list based on Adept/Magician availability. if (_objCharacter.MAGEnabled) { bool blnIsMagician = _objCharacter.MagicianEnabled; if (blnIsMagician != _objCharacter.AdeptEnabled) { if (blnIsMagician) { strFilter += "and magician = " + bool.TrueString.CleanXPath(); } else { strFilter += "and adept = " + bool.TrueString.CleanXPath(); } } } if (_lstMetamagicLimits.Count > 0) { strFilter += " and ("; using (new FetchSafelyFromPool <StringBuilder>(Utils.StringBuilderPool, out StringBuilder sbdFilter)) { foreach (string strMetamagic in _lstMetamagicLimits) { sbdFilter.Append("name = ").Append(strMetamagic.CleanXPath()).Append(" or "); } sbdFilter.Length -= 4; strFilter += sbdFilter.ToString() + ')'; } } string strSearch = await txtSearch.DoThreadSafeFuncAsync(x => x.Text); if (!string.IsNullOrEmpty(strSearch)) { strFilter += " and " + CommonFunctions.GenerateSearchXPath(strSearch); } using (new FetchSafelyFromPool <List <ListItem> >(Utils.ListItemListPool, out List <ListItem> lstMetamagics)) { foreach (XPathNavigator objXmlMetamagic in _objXmlDocument.Select(_strRootXPath + '[' + strFilter + ']')) { string strId = (await objXmlMetamagic.SelectSingleNodeAndCacheExpressionAsync("id"))?.Value; if (string.IsNullOrEmpty(strId)) { continue; } if (!chkLimitList.Checked || objXmlMetamagic.CreateNavigator().RequirementsMet(_objCharacter)) { lstMetamagics.Add(new ListItem(strId, (await objXmlMetamagic.SelectSingleNodeAndCacheExpressionAsync("translate")) ?.Value ?? (await objXmlMetamagic .SelectSingleNodeAndCacheExpressionAsync("name"))?.Value ?? await LanguageManager.GetStringAsync("String_Unknown"))); } } lstMetamagics.Sort(CompareListItems.CompareNames); string strOldSelected = await lstMetamagic.DoThreadSafeFuncAsync(x => x.SelectedValue?.ToString()); _blnLoading = true; await lstMetamagic.PopulateWithListItemsAsync(lstMetamagics); _blnLoading = false; await lstMetamagic.DoThreadSafeAsync(x => { if (!string.IsNullOrEmpty(strOldSelected)) { x.SelectedValue = strOldSelected; } else { x.SelectedIndex = -1; } }); } }
private void UpdateSpellInfo() { string strSelectedSpellId = lstSpells.SelectedValue?.ToString(); if (string.IsNullOrEmpty(strSelectedSpellId)) { lblDescriptors.Text = string.Empty; chkAlchemical.Enabled = false; chkAlchemical.Checked = false; lblType.Text = string.Empty; lblDuration.Text = string.Empty; chkExtended.Checked = false; chkExtended.Enabled = false; lblRange.Text = string.Empty; lblDamage.Text = string.Empty; lblDV.Text = string.Empty; chkFreeBonus.Checked = false; chkFreeBonus.Visible = false; lblSource.Text = string.Empty; tipTooltip.SetToolTip(lblSource, string.Empty); return; } // Display the Spell information. XmlNode objXmlSpell = _objXmlDocument.SelectSingleNode("/chummer/spells/spell[id = \"" + strSelectedSpellId + "\"]"); string[] strDescriptorsIn = objXmlSpell["descriptor"].InnerText.Split(','); StringBuilder objDescriptors = new StringBuilder(); bool blnExtendedFound = false; foreach (string strDescriptor in strDescriptorsIn) { switch (strDescriptor.Trim()) { case "Adept": objDescriptors.Append(LanguageManager.GetString("String_DescAdept", GlobalOptions.Language)); objDescriptors.Append(", "); break; case "Anchored": objDescriptors.Append(LanguageManager.GetString("String_DescAnchored", GlobalOptions.Language)); objDescriptors.Append(", "); break; case "Blood": objDescriptors.Append(LanguageManager.GetString("String_DescBlood", GlobalOptions.Language)); objDescriptors.Append(", "); break; case "Contractual": objDescriptors.Append(LanguageManager.GetString("String_DescContractual", GlobalOptions.Language)); objDescriptors.Append(", "); break; case "Geomancy": objDescriptors.Append(LanguageManager.GetString("String_DescGeomancy", GlobalOptions.Language)); objDescriptors.Append(", "); break; case "Mana": objDescriptors.Append(LanguageManager.GetString("String_DescMana", GlobalOptions.Language)); objDescriptors.Append(", "); break; case "Material Link": objDescriptors.Append(LanguageManager.GetString("String_DescMaterialLink", GlobalOptions.Language)); objDescriptors.Append(", "); break; case "Minion": objDescriptors.Append(LanguageManager.GetString("String_DescMinion", GlobalOptions.Language)); objDescriptors.Append(", "); break; case "Organic Link": objDescriptors.Append(LanguageManager.GetString("String_DescOrganicLink", GlobalOptions.Language)); objDescriptors.Append(", "); break; case "Spell": objDescriptors.Append(LanguageManager.GetString("String_DescSpell", GlobalOptions.Language)); objDescriptors.Append(", "); break; case "Spotter": objDescriptors.Append(LanguageManager.GetString("String_DescSpotter", GlobalOptions.Language)); objDescriptors.Append(", "); break; } } if (objXmlSpell["category"].InnerText == "Rituals") { chkAlchemical.Enabled = false; chkAlchemical.Checked = false; } else { chkAlchemical.Enabled = true; } // If Extended Area was not found and the Extended checkbox is checked, add Extended Area to the list of Descriptors. if (chkExtended.Checked && !blnExtendedFound) { objDescriptors.Append(LanguageManager.GetString("String_DescExtendedArea", GlobalOptions.Language)); objDescriptors.Append(", "); } if (chkAlchemical.Checked && !blnExtendedFound) { objDescriptors.Append(LanguageManager.GetString("String_DescAlchemicalPreparation", GlobalOptions.Language)); objDescriptors.Append(", "); } // Remove the trailing comma. if (objDescriptors.Length > 2) { objDescriptors.Length -= 2; } lblDescriptors.Text = objDescriptors.ToString(); switch (objXmlSpell["type"].InnerText) { case "M": lblType.Text = LanguageManager.GetString("String_SpellTypeMana", GlobalOptions.Language); break; default: lblType.Text = LanguageManager.GetString("String_SpellTypePhysical", GlobalOptions.Language); break; } switch (objXmlSpell["duration"].InnerText) { case "P": lblDuration.Text = LanguageManager.GetString("String_SpellDurationPermanent", GlobalOptions.Language); break; case "S": lblDuration.Text = LanguageManager.GetString("String_SpellDurationSustained", GlobalOptions.Language); break; default: lblDuration.Text = LanguageManager.GetString("String_SpellDurationInstant", GlobalOptions.Language); break; } if (objXmlSpell["category"].InnerText == "Detection") { chkExtended.Enabled = true; } else { chkExtended.Checked = false; chkExtended.Enabled = false; } string strRange = objXmlSpell["range"].InnerText; strRange = strRange.CheapReplace("Self", () => LanguageManager.GetString("String_SpellRangeSelf", GlobalOptions.Language)); strRange = strRange.CheapReplace("LOS", () => LanguageManager.GetString("String_SpellRangeLineOfSight", GlobalOptions.Language)); strRange = strRange.CheapReplace("LOI", () => LanguageManager.GetString("String_SpellRangeLineOfInfluence", GlobalOptions.Language)); strRange = strRange.CheapReplace("T", () => LanguageManager.GetString("String_SpellRangeTouch", GlobalOptions.Language)); strRange = strRange.CheapReplace("(A)", () => "(" + LanguageManager.GetString("String_SpellRangeArea", GlobalOptions.Language) + ")"); strRange = strRange.CheapReplace("MAG", () => LanguageManager.GetString("String_AttributeMAGShort", GlobalOptions.Language)); lblRange.Text = strRange; switch (objXmlSpell["damage"].InnerText) { case "P": lblDamageLabel.Visible = true; lblDamage.Text = LanguageManager.GetString("String_DamagePhysical", GlobalOptions.Language); break; case "S": lblDamageLabel.Visible = true; lblDamage.Text = LanguageManager.GetString("String_DamageStun", GlobalOptions.Language); break; default: lblDamageLabel.Visible = false; lblDamage.Text = string.Empty; break; } string strDV = objXmlSpell["dv"].InnerText.Replace('/', '÷').CheapReplace("F", () => LanguageManager.GetString("String_SpellForce", GlobalOptions.Language)); strDV = strDV.CheapReplace("Overflow damage", () => LanguageManager.GetString("String_SpellOverflowDamage", GlobalOptions.Language)); strDV = strDV.CheapReplace("Damage Value", () => LanguageManager.GetString("String_SpellDamageValue", GlobalOptions.Language)); strDV = strDV.CheapReplace("Toxin DV", () => LanguageManager.GetString("String_SpellToxinDV", GlobalOptions.Language)); strDV = strDV.CheapReplace("Disease DV", () => LanguageManager.GetString("String_SpellDiseaseDV", GlobalOptions.Language)); strDV = strDV.CheapReplace("Radiation Power", () => LanguageManager.GetString("String_SpellRadiationPower", GlobalOptions.Language)); if (chkExtended.Checked) { // Add +2 to the DV value if Extended is selected. int intPos = strDV.IndexOf(')') + 1; string strAfter = strDV.Substring(intPos, strDV.Length - intPos); strDV = strDV.Substring(0, intPos); if (string.IsNullOrEmpty(strAfter)) { strAfter = "+2"; } else { int intValue = Convert.ToInt32(strAfter) + 2; if (intValue == 0) { strAfter = string.Empty; } else if (intValue > 0) { strAfter = "+" + intValue.ToString(); } else { strAfter = intValue.ToString(); } } strDV += strAfter; } if (chkLimited.Checked) { int intPos = 0; if (strDV.Contains('-')) { intPos = strDV.IndexOf('-') + 1; string strAfter = strDV.Substring(intPos, strDV.Length - intPos); strDV = strDV.Substring(0, intPos); int intAfter = Convert.ToInt32(strAfter); intAfter += 2; strDV += intAfter.ToString(); } else if (strDV.Contains('+')) { intPos = strDV.IndexOf('+'); string strAfter = strDV.Substring(intPos, strDV.Length - intPos); strDV = strDV.Substring(0, intPos); int intAfter = Convert.ToInt32(strAfter); intAfter -= 2; if (intAfter > 0) { strDV += "+" + intAfter.ToString(); } else if (intAfter < 0) { strDV += intAfter.ToString(); } } else { strDV += "-2"; } } lblDV.Text = strDV; if (_objCharacter.AdeptEnabled && !_objCharacter.MagicianEnabled && _blnCanTouchOnlySpellBeFree && objXmlSpell["range"].InnerText == "T") { chkFreeBonus.Checked = true; chkFreeBonus.Visible = true; chkFreeBonus.Enabled = false; } else { chkFreeBonus.Checked = false; chkFreeBonus.Visible = _blnCanGenericSpellBeFree || (_blnCanTouchOnlySpellBeFree && objXmlSpell["range"].InnerText == "T"); chkFreeBonus.Enabled = true; } string strBook = CommonFunctions.LanguageBookShort(objXmlSpell["source"].InnerText, GlobalOptions.Language); string strPage = objXmlSpell["page"].InnerText; if (objXmlSpell["altpage"] != null) { strPage = objXmlSpell["altpage"].InnerText; } lblSource.Text = strBook + " " + strPage; tipTooltip.SetToolTip(lblSource, CommonFunctions.LanguageBookLong(objXmlSpell["source"].InnerText, GlobalOptions.Language) + " " + LanguageManager.GetString("String_Page", GlobalOptions.Language) + " " + strPage); }
/// <summary> /// Update the Mod's information based on the Mod selected and current Rating. /// </summary> private void UpdateGearInfo() { if (_blnSkipUpdate) { return; } _blnSkipUpdate = true; if (!string.IsNullOrEmpty(lstMod.Text)) { // Retireve the information for the selected Mod. // Filtering is also done on the Category in case there are non-unique names across categories. XmlNode objXmlMod = _objXmlDocument.SelectSingleNode("/chummer/mods/mod[id = \"" + lstMod.SelectedValue + "\"]"); // Extract the Avil and Cost values from the Gear info since these may contain formulas and/or be based off of the Rating. // This is done using XPathExpression. int intMinRating = 1; if (objXmlMod["minrating"]?.InnerText.Length > 0) { string strMinRating = ReplaceStrings(objXmlMod["minrating"]?.InnerText); intMinRating = Convert.ToInt32(CommonFunctions.EvaluateInvariantXPath(strMinRating)); } // If the rating is "qty", we're looking at Tires instead of actual Rating, so update the fields appropriately. if (objXmlMod["rating"].InnerText == "qty") { nudRating.Enabled = true; nudRating.Maximum = 20; while (nudRating.Maximum > intMinRating && !Backend.SelectionShared.CheckAvailRestriction(objXmlMod, _objCharacter, chkHideOverAvailLimit.Checked, decimal.ToInt32(nudRating.Maximum))) { nudRating.Maximum -= 1; } nudRating.Minimum = intMinRating; lblRatingLabel.Text = LanguageManager.GetString("Label_Qty"); } //Used for the Armor modifications. else if (objXmlMod["rating"].InnerText.ToLower() == "body") { nudRating.Maximum = _objVehicle.Body; while (nudRating.Maximum > intMinRating && !Backend.SelectionShared.CheckAvailRestriction(objXmlMod, _objCharacter, chkHideOverAvailLimit.Checked, decimal.ToInt32(nudRating.Maximum))) { nudRating.Maximum -= 1; } nudRating.Minimum = intMinRating; nudRating.Enabled = true; lblRatingLabel.Text = LanguageManager.GetString("Label_Body"); } //Used for Metahuman Adjustments. else if (objXmlMod["rating"].InnerText.ToLower() == "seats") { nudRating.Maximum = _objVehicle.TotalSeats; while (nudRating.Maximum > intMinRating && !Backend.SelectionShared.CheckAvailRestriction(objXmlMod, _objCharacter, chkHideOverAvailLimit.Checked, decimal.ToInt32(nudRating.Maximum))) { nudRating.Maximum -= 1; } nudRating.Minimum = intMinRating; nudRating.Enabled = true; lblRatingLabel.Text = LanguageManager.GetString("Label_Qty"); } else { if (Convert.ToInt32(objXmlMod["rating"].InnerText) > 0) { nudRating.Maximum = Convert.ToInt32(objXmlMod["rating"].InnerText); while (nudRating.Maximum > intMinRating && !Backend.SelectionShared.CheckAvailRestriction(objXmlMod, _objCharacter, chkHideOverAvailLimit.Checked, decimal.ToInt32(nudRating.Maximum))) { nudRating.Maximum -= 1; } nudRating.Minimum = intMinRating; nudRating.Enabled = true; lblRatingLabel.Text = LanguageManager.GetString("Label_Rating"); } else { nudRating.Minimum = 0; nudRating.Maximum = 0; nudRating.Enabled = false; lblRatingLabel.Text = LanguageManager.GetString("Label_Rating"); } } // Avail. // If avail contains "F" or "R", remove it from the string so we can use the expression. string strAvail = string.Empty; string strAvailExpr = objXmlMod["avail"].InnerText; if (strAvailExpr.StartsWith("FixedValues")) { int intRating = decimal.ToInt32(nudRating.Value - 1); strAvailExpr = strAvailExpr.TrimStart("FixedValues", true).Trim("()".ToCharArray()); string[] strValues = strAvailExpr.Split(','); if (intRating > strValues.Length || intRating < 0) { intRating = strValues.Length - 1; } strAvailExpr = strValues[intRating]; } if (strAvailExpr.EndsWith('F') || strAvailExpr.EndsWith('R')) { strAvail = strAvailExpr.Substring(strAvailExpr.Length - 1, 1); // Translate the Avail string. if (strAvail == "R") { strAvail = LanguageManager.GetString("String_AvailRestricted"); } else if (strAvail == "F") { strAvail = LanguageManager.GetString("String_AvailForbidden"); } // Remove the trailing character if it is "F" or "R". strAvailExpr = strAvailExpr.Substring(0, strAvailExpr.Length - 1); } try { lblAvail.Text = Convert.ToInt32(CommonFunctions.EvaluateInvariantXPath(ReplaceStrings(strAvailExpr))).ToString(); } catch (XPathException) { lblAvail.Text = objXmlMod["avail"].InnerText; } lblAvail.Text = lblAvail.Text + strAvail; // Cost. decimal decItemCost = 0; if (objXmlMod["cost"].InnerText.StartsWith("Variable")) { decimal decMin = 0; decimal decMax = decimal.MaxValue; string strCost = objXmlMod["cost"].InnerText; strCost = strCost.TrimStart("Variable", true).Trim("()".ToCharArray()); if (strCost.Contains('-')) { string[] strValues = strCost.Split('-'); decMin = Convert.ToDecimal(strValues[0], GlobalOptions.InvariantCultureInfo); decMax = Convert.ToDecimal(strValues[1], GlobalOptions.InvariantCultureInfo); } else { decMin = Convert.ToDecimal(strCost.FastEscape('+'), GlobalOptions.InvariantCultureInfo); } 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) + '¥'; } decItemCost = decMin; } else { string strCost = string.Empty; if (chkFreeItem.Checked) { strCost = "0"; } else { strCost = objXmlMod["cost"].InnerText; if (strCost.StartsWith("FixedValues")) { int intRating = decimal.ToInt32(nudRating.Value) - 1; strCost = strCost.TrimStart("FixedValues", true).Trim("()".ToCharArray()); string[] strValues = strCost.Split(','); if (intRating < 0 || intRating > strValues.Length) { intRating = 0; } strCost = strValues[intRating]; } strCost = ReplaceStrings(strCost); } decItemCost = Convert.ToDecimal(CommonFunctions.EvaluateInvariantXPath(strCost), GlobalOptions.InvariantCultureInfo); decItemCost *= _intModMultiplier; // Apply any markup. decItemCost *= 1 + (nudMarkup.Value / 100.0m); if (chkBlackMarketDiscount.Checked) { decItemCost *= 0.9m; } lblCost.Text = decItemCost.ToString(_objCharacter.Options.NuyenFormat, GlobalOptions.CultureInfo) + '¥'; } // Update the Avail Test Label. lblTest.Text = _objCharacter.AvailTest(decItemCost, lblAvail.Text); // Slots. string strSlots = string.Empty; if (objXmlMod["slots"].InnerText.StartsWith("FixedValues")) { string[] strValues = objXmlMod["slots"].InnerText.TrimStart("FixedValues", true).Trim("()".ToCharArray()).Split(','); strSlots = strValues[decimal.ToInt32(nudRating.Value) - 1]; } else { strSlots = objXmlMod["slots"].InnerText; } strSlots = ReplaceStrings(strSlots); lblSlots.Text = CommonFunctions.EvaluateInvariantXPath(strSlots).ToString(); if (objXmlMod["category"].InnerText != null) { if (s_LstCategories.Contains(objXmlMod["category"].InnerText)) { lblVehicleCapacityLabel.Visible = true; lblVehicleCapacity.Visible = true; lblVehicleCapacity.Text = GetRemainingModCapacity(objXmlMod["category"].InnerText, Convert.ToInt32(lblSlots.Text)); tipTooltip.SetToolTip(lblVehicleCapacityLabel, LanguageManager.GetString("Tip_RemainingVehicleModCapacity")); } else { lblVehicleCapacityLabel.Visible = false; lblVehicleCapacity.Visible = false; } lblCategory.Text = objXmlMod["category"].InnerText; if (objXmlMod["category"].InnerText == "Weapon Mod") { lblCategory.Text = LanguageManager.GetString("String_WeaponModification"); } // Translate the Category if possible. else if (GlobalOptions.Language != GlobalOptions.DefaultLanguage) { XmlNode objXmlCategory = _objXmlDocument.SelectSingleNode("/chummer/modcategories/category[. = \"" + objXmlMod["category"].InnerText + "\"]"); if (objXmlCategory?.Attributes["translate"] != null) { lblCategory.Text = objXmlCategory.Attributes["translate"].InnerText; } } } if (objXmlMod["limit"] != null) { // Translate the Limit if possible. if (GlobalOptions.Language != GlobalOptions.DefaultLanguage) { XmlNode objXmlLimit = _objXmlDocument.SelectSingleNode("/chummer/limits/limit[. = \"" + objXmlMod["limit"].InnerText + "\"]"); lblLimit.Text = objXmlLimit.Attributes["translate"] != null ? " (" + objXmlLimit.Attributes["translate"].InnerText + ")" : " (" + objXmlMod["limit"].InnerText + ")"; } else { lblLimit.Text = " (" + objXmlMod["limit"].InnerText + ")"; } } else { lblLimit.Text = string.Empty; } string strBook = _objCharacter.Options.LanguageBookShort(objXmlMod["source"].InnerText); string strPage = objXmlMod["page"].InnerText; if (objXmlMod["altpage"] != null) { strPage = objXmlMod["altpage"].InnerText; } lblSource.Text = strBook + " " + strPage; tipTooltip.SetToolTip(lblSource, _objCharacter.Options.LanguageBookLong(objXmlMod["source"].InnerText) + " " + LanguageManager.GetString("String_Page") + " " + strPage); } _blnSkipUpdate = false; }
/// <summary> /// Build the list of Qualities. /// </summary> private void BuildQualityList() { if (_blnLoading) { return; } string strCategory = cboCategory.SelectedValue?.ToString() ?? string.Empty; StringBuilder sbdFilter = new StringBuilder('(' + _objCharacter.Options.BookXPath() + ')'); if (!string.IsNullOrEmpty(strCategory) && strCategory != "Show All" && (GlobalOptions.SearchInCategoryOnly || txtSearch.TextLength == 0)) { sbdFilter.Append(" and category = " + strCategory.CleanXPath()); } else { StringBuilder objCategoryFilter = new StringBuilder(); foreach (string strItem in _lstCategory.Select(x => x.Value)) { if (!string.IsNullOrEmpty(strItem)) { objCategoryFilter.Append("category = " + strItem.CleanXPath() + " or "); } } if (objCategoryFilter.Length > 0) { objCategoryFilter.Length -= 4; sbdFilter.Append(" and (" + objCategoryFilter + ')'); } } if (chkMetagenic.Checked) { sbdFilter.Append(" and (metagenic = 'True' or required/oneof[contains(., 'Changeling')])"); } else if (chkNotMetagenic.Checked) { sbdFilter.Append(" and not(metagenic = 'True') and not(required/oneof[contains(., 'Changeling')])"); } if (nudValueBP.Value != 0) { if (_objCharacter.Created && !_objCharacter.Options.DontDoubleQualityPurchases && nudValueBP.Value > 0) { sbdFilter.Append(" and ((doublecareer = 'False' and karma = " + nudValueBP.Value.ToString(GlobalOptions.InvariantCultureInfo) + ") or (not(doublecareer = 'False') and karma = " + (nudValueBP.Value / 2).ToString(GlobalOptions.InvariantCultureInfo) + "))"); } else { sbdFilter.Append(" and karma = " + nudValueBP.Value.ToString(GlobalOptions.InvariantCultureInfo)); } } else { if (nudMinimumBP.Value != 0) { if (_objCharacter.Created && !_objCharacter.Options.DontDoubleQualityPurchases) { sbdFilter.Append(" and (((doublecareer = 'False' or karma < 0) and karma >= " + nudMinimumBP.Value.ToString(GlobalOptions.InvariantCultureInfo) + ") or (not(doublecareer = 'False' or karma < 0) and karma >= " + (nudMinimumBP.Value / 2).ToString(GlobalOptions.InvariantCultureInfo) + "))"); } else { sbdFilter.Append(" and karma >= " + nudMinimumBP.Value.ToString(GlobalOptions.InvariantCultureInfo)); } } if (nudMaximumBP.Value != 0) { if (_objCharacter.Created && !_objCharacter.Options.DontDoubleQualityPurchases && nudMaximumBP.Value > 0) { sbdFilter.Append(" and (((doublecareer = 'False' or karma < 0) and karma <= " + nudMaximumBP.Value.ToString(GlobalOptions.InvariantCultureInfo) + ") or (not(doublecareer = 'False' or karma < 0) and karma <= " + (nudMaximumBP.Value / 2).ToString(GlobalOptions.InvariantCultureInfo) + "))"); } else { sbdFilter.Append(" and karma <= " + nudMaximumBP.Value.ToString(GlobalOptions.InvariantCultureInfo)); } } } if (!string.IsNullOrEmpty(txtSearch.Text)) { sbdFilter.Append(" and " + CommonFunctions.GenerateSearchXPath(txtSearch.Text)); } string strCategoryLower = strCategory == "Show All" ? "*" : strCategory.ToLowerInvariant(); List <ListItem> lstQuality = new List <ListItem>(); foreach (XPathNavigator objXmlQuality in _xmlBaseQualityDataNode.Select("qualities/quality[" + sbdFilter + "]")) { string strLoopName = objXmlQuality.SelectSingleNode("name")?.Value; if (string.IsNullOrEmpty(strLoopName)) { continue; } if (_xmlMetatypeQualityRestrictionNode != null && _xmlMetatypeQualityRestrictionNode.SelectSingleNode(strCategoryLower + "/quality[. = " + strLoopName.CleanXPath() + "]") == null) { continue; } if (!chkLimitList.Checked || objXmlQuality.RequirementsMet(_objCharacter, string.Empty, string.Empty, IgnoreQuality)) { lstQuality.Add(new ListItem(objXmlQuality.SelectSingleNode("id")?.Value ?? string.Empty, objXmlQuality.SelectSingleNode("translate")?.Value ?? strLoopName)); } } lstQuality.Sort(CompareListItems.CompareNames); string strOldSelectedQuality = lstQualities.SelectedValue?.ToString(); _blnLoading = true; lstQualities.BeginUpdate(); lstQualities.ValueMember = nameof(ListItem.Value); lstQualities.DisplayMember = nameof(ListItem.Name); lstQualities.DataSource = lstQuality; _blnLoading = false; if (string.IsNullOrEmpty(strOldSelectedQuality)) { lstQualities.SelectedIndex = -1; } else { lstQualities.SelectedValue = strOldSelectedQuality; } lstQualities.EndUpdate(); }
/// <summary> /// Refresh the information for the selected Vehicle. /// </summary> private void UpdateSelectedVehicle() { string strSelectedId = lstVehicle.SelectedValue?.ToString(); XPathNavigator objXmlVehicle = null; if (!string.IsNullOrEmpty(strSelectedId)) { // Retireve the information for the selected Vehicle. objXmlVehicle = _xmlBaseVehicleDataNode.SelectSingleNode("vehicles/vehicle[id = \"" + strSelectedId + "\"]"); } if (objXmlVehicle == null) { lblVehicleHandling.Text = string.Empty; lblVehicleAccel.Text = string.Empty; lblVehicleSpeed.Text = string.Empty; lblVehiclePilot.Text = string.Empty; lblVehicleBody.Text = string.Empty; lblVehicleArmor.Text = string.Empty; lblVehicleSeats.Text = string.Empty; lblVehicleSensor.Text = string.Empty; lblVehicleAvail.Text = string.Empty; lblSource.Text = string.Empty; lblVehicleCost.Text = string.Empty; lblTest.Text = string.Empty; tipTooltip.SetToolTip(lblSource, string.Empty); return; } decimal decCostModifier = 1.0m; if (chkUsedVehicle.Checked) { decCostModifier -= (nudUsedVehicleDiscount.Value / 100.0m); } lblVehicleHandling.Text = objXmlVehicle.SelectSingleNode("handling")?.Value; lblVehicleAccel.Text = objXmlVehicle.SelectSingleNode("accel")?.Value; lblVehicleSpeed.Text = objXmlVehicle.SelectSingleNode("speed")?.Value; lblVehiclePilot.Text = objXmlVehicle.SelectSingleNode("pilot")?.Value; lblVehicleBody.Text = objXmlVehicle.SelectSingleNode("body")?.Value; lblVehicleArmor.Text = objXmlVehicle.SelectSingleNode("armor")?.Value; lblVehicleSeats.Text = objXmlVehicle.SelectSingleNode("seats")?.Value; lblVehicleSensor.Text = objXmlVehicle.SelectSingleNode("sensor")?.Value; string strAvail = objXmlVehicle.SelectSingleNode("avail")?.Value ?? string.Empty; if (!string.IsNullOrEmpty(strAvail)) { string strSuffix = string.Empty; char chrLastChar = strAvail.Length > 0 ? strAvail[strAvail.Length - 1] : ' '; if (chrLastChar == 'F') { strSuffix = LanguageManager.GetString("String_AvailForbidden", GlobalOptions.Language); strAvail = strAvail.Substring(0, strAvail.Length - 1); } else if (chrLastChar == 'R') { strSuffix = LanguageManager.GetString("String_AvailRestricted", GlobalOptions.Language); strAvail = strAvail.Substring(0, strAvail.Length - 1); } if (chkUsedVehicle.Checked) { if (int.TryParse(strAvail, out int intTmp)) { strAvail = intTmp + 4.ToString(); } } strAvail += strSuffix; } lblVehicleAvail.Text = strAvail; chkBlackMarketDiscount.Checked = _setBlackMarketMaps.Contains(objXmlVehicle.SelectSingleNode("category")?.Value); // Apply the cost multiplier to the Vehicle (will be 1 unless Used Vehicle is selected) string strCost = objXmlVehicle.SelectSingleNode("cost")?.Value ?? string.Empty; if (strCost.StartsWith("Variable")) { lblVehicleCost.Text = strCost.TrimStartOnce("Variable(", true).TrimEndOnce(')'); lblTest.Text = string.Empty; } else { decimal decCost = 0.0m; if (!chkFreeItem.Checked) { if (decimal.TryParse(strCost, NumberStyles.Any, GlobalOptions.InvariantCultureInfo, out decimal decTmp)) { decCost = decTmp; } // Apply the markup if applicable. decCost *= decCostModifier; decCost *= 1 + (nudMarkup.Value / 100.0m); if (chkBlackMarketDiscount.Checked) { decCost *= 0.9m; } } lblVehicleCost.Text = decCost.ToString(_objCharacter.Options.NuyenFormat, GlobalOptions.CultureInfo) + '¥'; lblTest.Text = _objCharacter.AvailTest(decCost, lblVehicleAvail.Text); } string strSource = objXmlVehicle.SelectSingleNode("source")?.Value ?? LanguageManager.GetString("String_Unknown", GlobalOptions.Language); string strPage = objXmlVehicle.SelectSingleNode("altpage")?.Value ?? objXmlVehicle.SelectSingleNode("page")?.Value ?? LanguageManager.GetString("String_Unknown", GlobalOptions.Language); lblSource.Text = CommonFunctions.LanguageBookShort(strSource, GlobalOptions.Language) + ' ' + strPage; tipTooltip.SetToolTip(lblSource, CommonFunctions.LanguageBookLong(strSource, GlobalOptions.Language) + ' ' + LanguageManager.GetString("String_Page", GlobalOptions.Language) + ' ' + strPage); }
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 trePowers_AfterSelect(object sender, TreeViewEventArgs e) { lblPowerPoints.Visible = false; lblPowerPointsLabel.Visible = false; string strSelectedPower = trePowers.SelectedNode.Tag?.ToString(); if (!string.IsNullOrEmpty(strSelectedPower)) { XPathNavigator objXmlPower = _xmlBaseCritterPowerDataNode.SelectSingleNode("powers/power[id = \"" + strSelectedPower + "\"]"); if (objXmlPower != null) { lblCritterPowerCategory.Text = objXmlPower.SelectSingleNode("category")?.Value ?? string.Empty; switch (objXmlPower.SelectSingleNode("type")?.Value) { case "M": lblCritterPowerType.Text = LanguageManager.GetString("String_SpellTypeMana", GlobalOptions.Language); break; case "P": lblCritterPowerType.Text = LanguageManager.GetString("String_SpellTypePhysical", GlobalOptions.Language); break; default: lblCritterPowerType.Text = string.Empty; break; } switch (objXmlPower.SelectSingleNode("action")?.Value) { case "Auto": lblCritterPowerAction.Text = LanguageManager.GetString("String_ActionAutomatic", GlobalOptions.Language); break; case "Free": lblCritterPowerAction.Text = LanguageManager.GetString("String_ActionFree", GlobalOptions.Language); break; case "Simple": lblCritterPowerAction.Text = LanguageManager.GetString("String_ActionSimple", GlobalOptions.Language); break; case "Complex": lblCritterPowerAction.Text = LanguageManager.GetString("String_ActionComplex", GlobalOptions.Language); break; case "Special": lblCritterPowerAction.Text = LanguageManager.GetString("String_SpellDurationSpecial", GlobalOptions.Language); break; default: lblCritterPowerAction.Text = string.Empty; break; } string strRange = objXmlPower.SelectSingleNode("range")?.Value ?? string.Empty; if (!string.IsNullOrEmpty(strRange)) { strRange = strRange.CheapReplace("Self", () => LanguageManager.GetString("String_SpellRangeSelf", GlobalOptions.Language)) .CheapReplace("Special", () => LanguageManager.GetString("String_SpellDurationSpecial", GlobalOptions.Language)) .CheapReplace("LOS", () => LanguageManager.GetString("String_SpellRangeLineOfSight", GlobalOptions.Language)) .CheapReplace("LOI", () => LanguageManager.GetString("String_SpellRangeLineOfInfluence", GlobalOptions.Language)) .CheapReplace("T", () => LanguageManager.GetString("String_SpellRangeTouch", GlobalOptions.Language)) .CheapReplace("(A)", () => "(" + LanguageManager.GetString("String_SpellRangeArea", GlobalOptions.Language) + ')') .CheapReplace("MAG", () => LanguageManager.GetString("String_AttributeMAGShort", GlobalOptions.Language)); } lblCritterPowerRange.Text = strRange; string strDuration = objXmlPower.SelectSingleNode("duration")?.Value ?? string.Empty; switch (strDuration) { case "Instant": lblCritterPowerDuration.Text = LanguageManager.GetString("String_SpellDurationInstantLong", GlobalOptions.Language); break; case "Sustained": lblCritterPowerDuration.Text = LanguageManager.GetString("String_SpellDurationSustained", GlobalOptions.Language); break; case "Always": lblCritterPowerDuration.Text = LanguageManager.GetString("String_SpellDurationAlways", GlobalOptions.Language); break; case "Special": lblCritterPowerDuration.Text = LanguageManager.GetString("String_SpellDurationSpecial", GlobalOptions.Language); break; default: lblCritterPowerDuration.Text = strDuration; break; } string strSource = objXmlPower.SelectSingleNode("source")?.Value ?? LanguageManager.GetString("String_Unknown", GlobalOptions.Language); string strPage = objXmlPower.SelectSingleNode("altpage")?.Value ?? objXmlPower.SelectSingleNode("page")?.Value ?? LanguageManager.GetString("String_Unknown", GlobalOptions.Language); string strSpaceCharacter = LanguageManager.GetString("String_Space", GlobalOptions.Language); lblCritterPowerSource.Text = CommonFunctions.LanguageBookShort(strSource, GlobalOptions.Language) + strSpaceCharacter + strPage; lblCritterPowerSource.SetToolTip(CommonFunctions.LanguageBookLong(strSource, GlobalOptions.Language) + strSpaceCharacter + LanguageManager.GetString("String_Page", GlobalOptions.Language) + ' ' + strPage); nudCritterPowerRating.Visible = objXmlPower.SelectSingleNode("rating") != null; lblKarma.Text = objXmlPower.SelectSingleNode("karma")?.Value ?? "0"; // If the character is a Free Spirit, populate the Power Points Cost as well. if (_objCharacter.Metatype == "Free Spirit") { XPathNavigator xmlOptionalPowerCostNode = _xmlMetatypeDataNode.SelectSingleNode("optionalpowers/power[. = \"" + objXmlPower.SelectSingleNode("name")?.Value + "\"]/@cost"); if (xmlOptionalPowerCostNode != null) { lblPowerPoints.Text = xmlOptionalPowerCostNode.Value; lblPowerPoints.Visible = true; lblPowerPointsLabel.Visible = true; } } } } lblCritterPowerTypeLabel.Visible = !string.IsNullOrEmpty(lblCritterPowerType.Text); lblCritterPowerActionLabel.Visible = !string.IsNullOrEmpty(lblCritterPowerAction.Text); lblCritterPowerRangeLabel.Visible = !string.IsNullOrEmpty(lblCritterPowerRange.Text); lblCritterPowerDurationLabel.Visible = !string.IsNullOrEmpty(lblCritterPowerDuration.Text); lblCritterPowerSourceLabel.Visible = !string.IsNullOrEmpty(lblCritterPowerSource.Text); lblKarmaLabel.Visible = !string.IsNullOrEmpty(lblKarma.Text); }
/// <summary> /// Update the information for the selected Armor Mod. /// </summary> private void UpdateSelectedArmor() { // Retireve the information for the selected Accessory. XmlNode objXmlMod = _objXmlDocument.SelectSingleNode("/chummer/mods/mod[name = \"" + lstMod.SelectedValue + "\"]"); // Extract the Avil and Cost values from the Cyberware info since these may contain formulas and/or be based off of the Rating. // This is done using XPathExpression. lblA.Text = objXmlMod["armor"].InnerText; nudRating.Maximum = Convert.ToDecimal(objXmlMod["maxrating"].InnerText, GlobalOptions.InvariantCultureInfo); while (nudRating.Maximum > 1 && !Backend.SelectionShared.CheckAvailRestriction(objXmlMod, _objCharacter, chkHideOverAvailLimit.Checked, decimal.ToInt32(nudRating.Maximum))) { nudRating.Maximum -= 1; } if (nudRating.Maximum <= 1) { nudRating.Enabled = false; } else { nudRating.Enabled = true; if (nudRating.Minimum == 0) { nudRating.Value = 1; nudRating.Minimum = 1; } } string strAvail = string.Empty; string strAvailExpr = string.Empty; strAvailExpr = objXmlMod["avail"].InnerText; if (strAvailExpr.Substring(strAvailExpr.Length - 1, 1) == "F" || strAvailExpr.Substring(strAvailExpr.Length - 1, 1) == "R") { strAvail = strAvailExpr.Substring(strAvailExpr.Length - 1, 1); if (strAvail == "R") { strAvail = LanguageManager.GetString("String_AvailRestricted"); } else if (strAvail == "F") { strAvail = LanguageManager.GetString("String_AvailForbidden"); } // 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.InvariantCultureInfo)))).ToString() + strAvail; } catch (XPathException) { lblAvail.Text = strAvailExpr + strAvail; } // Cost. if (chkFreeItem.Checked) { lblCost.Text = 0.ToString(_objCharacter.Options.NuyenFormat, GlobalOptions.CultureInfo) + '¥'; } else if (objXmlMod["cost"].InnerText.StartsWith("Variable")) { decimal decMin = 0; decimal decMax = decimal.MaxValue; string strCost = objXmlMod["cost"].InnerText.TrimStart("Variable", true).Trim("()".ToCharArray()); if (strCost.Contains('-')) { string[] strValues = strCost.Split('-'); decMin = Convert.ToDecimal(strValues[0], GlobalOptions.InvariantCultureInfo); decMax = Convert.ToDecimal(strValues[1], GlobalOptions.InvariantCultureInfo); } else { decMin = Convert.ToDecimal(strCost.FastEscape('+'), GlobalOptions.InvariantCultureInfo); } 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) + '¥'; } } else { string strCost = objXmlMod["cost"].InnerText.Replace("Rating", nudRating.Value.ToString(GlobalOptions.InvariantCultureInfo)); strCost = strCost.Replace("Armor Cost", _decArmorCost.ToString(GlobalOptions.InvariantCultureInfo)); // Apply any markup. decimal decCost = Convert.ToDecimal(CommonFunctions.EvaluateInvariantXPath(strCost), GlobalOptions.InvariantCultureInfo); decCost *= 1 + (nudMarkup.Value / 100.0m); lblCost.Text = decCost.ToString(_objCharacter.Options.NuyenFormat, GlobalOptions.CultureInfo) + '¥'; lblTest.Text = _objCharacter.AvailTest(decCost, lblAvail.Text); } // Capacity. // XPathExpression cannot evaluate while there are square brackets, so remove them if necessary. string strCapacity = objXmlMod["armorcapacity"].InnerText; // Handle YNT Softweave if (strCapacity.Contains("Capacity")) { lblCapacity.Text = "+50%"; } else { if (strCapacity.StartsWith("FixedValues")) { string[] strValues = strCapacity.TrimStart("FixedValues", true).Trim("()".ToCharArray()).Split(','); strCapacity = strValues[decimal.ToInt32(nudRating.Value) - 1]; } strCapacity = strCapacity.Substring(1, strCapacity.Length - 2); if (_objCapacityStyle == CapacityStyle.Standard) { lblCapacity.Text = "[" + CommonFunctions.EvaluateInvariantXPath(strCapacity.Replace("Rating", nudRating.Value.ToString(GlobalOptions.InvariantCultureInfo))) + "]"; } else if (_objCapacityStyle == CapacityStyle.PerRating) { lblCapacity.Text = "[" + nudRating.Value.ToString(GlobalOptions.InvariantCultureInfo) + "]"; } else if (_objCapacityStyle == CapacityStyle.Zero) { lblCapacity.Text = "[0]"; } } string strBook = _objCharacter.Options.LanguageBookShort(objXmlMod["source"].InnerText); string strPage = objXmlMod["page"].InnerText; if (objXmlMod["altpage"] != null) { strPage = objXmlMod["altpage"].InnerText; } lblSource.Text = strBook + " " + strPage; tipTooltip.SetToolTip(lblSource, _objCharacter.Options.LanguageBookLong(objXmlMod["source"].InnerText) + " " + LanguageManager.GetString("String_Page") + " " + strPage); }
private void OpenSourceFromLabel(object sender, EventArgs e) { CommonFunctions.OpenPDFFromControl(sender, e); }
/// <summary> /// Build the list of Qualities. /// </summary> private async ValueTask BuildQualityList() { if (_blnLoading) { return; } string strCategory = cboCategory.SelectedValue?.ToString() ?? string.Empty; string strFilter = string.Empty; using (new FetchSafelyFromPool <StringBuilder>(Utils.StringBuilderPool, out StringBuilder sbdFilter)) { sbdFilter.Append('(').Append(_objCharacter.Settings.BookXPath()).Append(')'); if (!string.IsNullOrEmpty(strCategory) && strCategory != "Show All" && (GlobalSettings.SearchInCategoryOnly || txtSearch.TextLength == 0)) { sbdFilter.Append(" and category = ").Append(strCategory.CleanXPath()); } else { using (new FetchSafelyFromPool <StringBuilder>(Utils.StringBuilderPool, out StringBuilder sbdCategoryFilter)) { foreach (string strItem in _lstCategory.Select(x => x.Value)) { if (!string.IsNullOrEmpty(strItem)) { sbdCategoryFilter.Append("category = ").Append(strItem.CleanXPath()).Append(" or "); } } if (sbdCategoryFilter.Length > 0) { sbdCategoryFilter.Length -= 4; sbdFilter.Append(" and (").Append(sbdCategoryFilter).Append(')'); } } } if (chkMetagenic.Checked) { sbdFilter.Append(" and (metagenic = 'True' or required/oneof[contains(., 'Changeling')])"); } else if (chkNotMetagenic.Checked) { sbdFilter.Append(" and not(metagenic = 'True') and not(required/oneof[contains(., 'Changeling')])"); } if (nudValueBP.Value != 0) { string strValueBP = nudValueBP.Value.ToString(GlobalSettings.InvariantCultureInfo); if (_objCharacter.Created && !_objCharacter.Settings.DontDoubleQualityPurchases && nudValueBP.Value > 0) { string strValueBPHalved = (nudValueBP.Value / 2).ToString(GlobalSettings.InvariantCultureInfo); sbdFilter.Append(" and ((doublecareer = 'False' and (karma = ").Append(strValueBP) .Append(" or (not(nolevels) and limit != 'False' and (karma mod ").Append(strValueBP) .Append(") = 0 and karma * karma * limit <= karma * ").Append(strValueBP) .Append("))) or (not(doublecareer = 'False') and (karma = ").Append(strValueBPHalved) .Append(" or (not(nolevels) and limit != 'False' and (karma mod ") .Append(strValueBPHalved) .Append(") = 0 and karma * karma * limit <= karma * ").Append(strValueBPHalved) .Append("))))"); } else { sbdFilter.Append(" and (karma = ").Append(strValueBP) .Append(" or (not(nolevels) and limit != 'False' and (karma mod ").Append(strValueBP) .Append(") = 0 and karma * karma * limit <= karma * ").Append(strValueBP).Append("))"); } } else if (nudMinimumBP.Value != 0 || nudMaximumBP.Value != 0) { if (nudMinimumBP.Value < 0 == nudMaximumBP.Value < 0) { sbdFilter.Append(" and (") .Append(GetKarmaRangeString(nudMaximumBP.ValueAsInt, nudMinimumBP.ValueAsInt)) .Append(')'); } else { sbdFilter.Append("and ((").Append(GetKarmaRangeString(nudMaximumBP.ValueAsInt, 0)) .Append(") or (") .Append(GetKarmaRangeString(-1, nudMinimumBP.ValueAsInt)).Append("))"); } string GetKarmaRangeString(int intMax, int intMin) { string strMax = intMax.ToString(GlobalSettings.InvariantCultureInfo); string strMin = intMin.ToString(GlobalSettings.InvariantCultureInfo); string strMostExtremeValue = (intMax > 0 ? intMax : intMin).ToString(GlobalSettings.InvariantCultureInfo); string strValueDiff = (intMax > 0 ? intMax - intMin : intMin - intMax).ToString( GlobalSettings.InvariantCultureInfo); if (_objCharacter.Created && !_objCharacter.Settings.DontDoubleQualityPurchases) { return("((doublecareer = 'False' or karma < 0) and ((karma >= " + strMin + " and karma <= " + strMax + ") or (not(nolevels) and limit != 'False' and karma * karma <= karma * " + strMostExtremeValue + " and (karma * (" + strMostExtremeValue + " mod karma) <= karma * " + strValueDiff + ") and ((karma >= 0 and karma * limit >= " + strMin + ") or (karma < 0 and karma * limit <= " + strMax + "))))) or (not(doublecareer = 'False' or karma < 0) and ((2 * karma >= " + strMin + " and 2 * karma <= " + strMax + ") or (not(nolevels) and limit != 'False' and 2 * karma * karma <= 2 * karma * " + strMostExtremeValue + " and (2 * karma * (" + strMostExtremeValue + " mod (2 * karma)) <= 2 * karma * " + strValueDiff + ") and ((karma >= 0 and 2 * karma * limit >= " + strMin + ") or (karma < 0 and 2 * karma * limit <= " + strMax + ")))))"); } return("(karma >= " + strMin + " and karma <= " + strMax + ") or (not(nolevels) and limit != 'False' and karma * karma <= karma * " + strMostExtremeValue + " and (karma * (" + strMostExtremeValue + " mod karma) <= karma * " + strValueDiff + ") and ((karma >= 0 and karma * limit >= " + strMin + ") or (karma < 0 and karma * limit <= " + strMax + ")))"); } } if (!string.IsNullOrEmpty(txtSearch.Text)) { sbdFilter.Append(" and ").Append(CommonFunctions.GenerateSearchXPath(txtSearch.Text)); } if (sbdFilter.Length > 0) { strFilter = '[' + sbdFilter.ToString() + ']'; } } string strCategoryLower = strCategory == "Show All" ? "*" : strCategory.ToLowerInvariant(); using (new FetchSafelyFromPool <List <ListItem> >(Utils.ListItemListPool, out List <ListItem> lstQuality)) { foreach (XPathNavigator objXmlQuality in _xmlBaseQualityDataNode.Select("qualities/quality" + strFilter)) { string strLoopName = (await objXmlQuality.SelectSingleNodeAndCacheExpressionAsync("name"))?.Value; if (string.IsNullOrEmpty(strLoopName)) { continue; } if (_xmlMetatypeQualityRestrictionNode != null && _xmlMetatypeQualityRestrictionNode.SelectSingleNode( strCategoryLower + "/quality[. = " + strLoopName.CleanXPath() + ']') == null) { continue; } if (!chkLimitList.Checked || objXmlQuality.RequirementsMet(_objCharacter, string.Empty, string.Empty, IgnoreQuality)) { lstQuality.Add(new ListItem( (await objXmlQuality.SelectSingleNodeAndCacheExpressionAsync("id"))?.Value ?? string.Empty, (await objXmlQuality.SelectSingleNodeAndCacheExpressionAsync("translate"))?.Value ?? strLoopName)); } } lstQuality.Sort(CompareListItems.CompareNames); string strOldSelectedQuality = lstQualities.SelectedValue?.ToString(); _blnLoading = true; await lstQualities.PopulateWithListItemsAsync(lstQuality); _blnLoading = false; if (string.IsNullOrEmpty(strOldSelectedQuality)) { lstQualities.SelectedIndex = -1; } else { lstQualities.SelectedValue = strOldSelectedQuality; } } }
/// <summary> /// Save the global settings to the registry. /// </summary> private void SaveRegistrySettings() { // If we're just now enabling logging, flush the log if (!GlobalOptions.Instance.UseLogging && chkUseLogging.Checked) { CommonFunctions objFunctions = new CommonFunctions(); objFunctions.LogFlush(); } // Set Registry values. GlobalOptions.Instance.AutomaticUpdate = chkAutomaticUpdate.Checked; GlobalOptions.Instance.LocalisedUpdatesOnly = chkLocalisedUpdatesOnly.Checked; GlobalOptions.Instance.UseLogging = chkUseLogging.Checked; GlobalOptions.Instance.Language = cboLanguage.SelectedValue.ToString(); GlobalOptions.Instance.StartupFullscreen = chkStartupFullscreen.Checked; GlobalOptions.Instance.SingleDiceRoller = chkSingleDiceRoller.Checked; GlobalOptions.Instance.DefaultCharacterSheet = cboXSLT.SelectedValue.ToString(); GlobalOptions.Instance.DatesIncludeTime = chkDatesIncludeTime.Checked; GlobalOptions.Instance.PrintToFileFirst = chkPrintToFileFirst.Checked; GlobalOptions.Instance.PDFAppPath = txtPDFAppPath.Text; Microsoft.Win32.RegistryKey objRegistry = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("Software\\Chummer5"); objRegistry.SetValue("autoupdate", chkAutomaticUpdate.Checked.ToString()); objRegistry.SetValue("localisedupdatesonly", chkLocalisedUpdatesOnly.Checked.ToString()); objRegistry.SetValue("uselogging", chkUseLogging.Checked.ToString()); objRegistry.SetValue("language", cboLanguage.SelectedValue.ToString()); objRegistry.SetValue("startupfullscreen", chkStartupFullscreen.Checked.ToString()); objRegistry.SetValue("singlediceroller", chkSingleDiceRoller.Checked.ToString()); objRegistry.SetValue("defaultsheet", cboXSLT.SelectedValue.ToString()); objRegistry.SetValue("datesincludetime", chkDatesIncludeTime.Checked.ToString()); objRegistry.SetValue("printtofilefirst", chkPrintToFileFirst.Checked.ToString()); objRegistry.SetValue("pdfapppath", txtPDFAppPath.Text); // Save the SourcebookInfo. Microsoft.Win32.RegistryKey objSourceRegistry = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("Software\\Chummer5\\Sourcebook"); foreach (SourcebookInfo objSource in GlobalOptions.Instance.SourcebookInfo) objSourceRegistry.SetValue(objSource.Code, objSource.Path + "|" + objSource.Offset.ToString()); }
private void lstWeapon_SelectedIndexChanged(object sender, EventArgs e) { if (string.IsNullOrEmpty(lstWeapon.Text)) { return; } // Retireve the information for the selected Weapon. XmlNode objXmlWeapon = _objXmlDocument.SelectSingleNode("/chummer/weapons/weapon[id = \"" + lstWeapon.SelectedValue + "\"]"); if (objXmlWeapon == null) { return; } Weapon objWeapon = new Weapon(_objCharacter); objWeapon.Create(objXmlWeapon, null, true, false); lblWeaponReach.Text = objWeapon.TotalReach.ToString(); lblWeaponDamage.Text = objWeapon.CalculatedDamage(GlobalOptions.CultureInfo, GlobalOptions.Language); lblWeaponAP.Text = objWeapon.TotalAP(GlobalOptions.Language); lblWeaponMode.Text = objWeapon.CalculatedMode(GlobalOptions.Language); lblWeaponRC.Text = objWeapon.TotalRC; lblWeaponAmmo.Text = objWeapon.CalculatedAmmo(GlobalOptions.CultureInfo, GlobalOptions.Language); lblWeaponAccuracy.Text = objWeapon.TotalAccuracy.ToString(); lblWeaponAvail.Text = objWeapon.TotalAvail(GlobalOptions.Language); decimal decItemCost = 0; decimal decCost = 0; if (chkFreeItem.Checked) { lblWeaponCost.Text = 0.ToString(_objCharacter.Options.NuyenFormat, GlobalOptions.CultureInfo) + '¥'; decItemCost = 0; } else { string strCostElement = objXmlWeapon["cost"]?.InnerText ?? string.Empty; if (strCostElement.StartsWith("Variable(")) { decimal decMin; decimal decMax = decimal.MaxValue; string strCost = strCostElement.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) { lblWeaponCost.Text = decMin.ToString(_objCharacter.Options.NuyenFormat, GlobalOptions.CultureInfo) + "¥+"; } else { lblWeaponCost.Text = decMin.ToString(_objCharacter.Options.NuyenFormat, GlobalOptions.CultureInfo) + " - " + decMax.ToString(_objCharacter.Options.NuyenFormat, GlobalOptions.CultureInfo) + '¥'; } decItemCost = decMin; } else { if (decimal.TryParse(strCostElement, NumberStyles.Any, GlobalOptions.InvariantCultureInfo, out decimal decTmp)) { decCost = decTmp; } decCost *= 1 + (nudMarkup.Value / 100.0m); if (chkBlackMarketDiscount.Checked) { decCost *= 0.9m; } lblWeaponCost.Text = decCost.ToString(_objCharacter.Options.NuyenFormat, GlobalOptions.CultureInfo) + '¥'; decItemCost = decCost; } } lblTest.Text = _objCharacter.AvailTest(decItemCost, lblWeaponAvail.Text); string strBook = CommonFunctions.LanguageBookShort(objXmlWeapon["source"]?.InnerText, GlobalOptions.Language); string strPage = objXmlWeapon["page"]?.InnerText; if (objXmlWeapon["altpage"] != null) { strPage = objXmlWeapon["altpage"].InnerText; } lblSource.Text = strBook + " " + strPage; // Build a list of included Accessories and Modifications that come with the weapon. string strAccessories = string.Empty; XmlNodeList objXmlNodeList = objXmlWeapon.SelectNodes("accessories/accessory"); if (objXmlNodeList != null) { foreach (XmlNode objXmlAccessory in objXmlNodeList) { if (objXmlAccessory["name"] != null) { XmlNode objXmlItem = _objXmlDocument.SelectSingleNode("/chummer/accessories/accessory[name = \"" + objXmlAccessory["name"].InnerText + "\"]"); if (objXmlItem?["name"] != null) { strAccessories += objXmlItem["translate"] != null ? objXmlItem["translate"].InnerText + "\n" : objXmlItem["name"].InnerText + "\n"; } } } } if (_blackMarketMaps != null) { chkBlackMarketDiscount.Checked = _blackMarketMaps.Contains(objXmlWeapon["category"]?.InnerText); } lblIncludedAccessories.Text = string.IsNullOrEmpty(strAccessories) ? LanguageManager.GetString("String_None", GlobalOptions.Language) : strAccessories; tipTooltip.SetToolTip(lblSource, CommonFunctions.LanguageBookLong(objXmlWeapon["source"]?.InnerText, GlobalOptions.Language) + " " + LanguageManager.GetString("String_Page", GlobalOptions.Language) + " " + strPage); }
private async void OpenSourceFromLabel(object sender, EventArgs e) { await CommonFunctions.OpenPdfFromControl(sender, e); }
private void lstDrug_SelectedIndexChanged(object sender, EventArgs e) { if (_blnLoading) { return; } _blnLoading = true; XPathNavigator xmlDrug = null; string strSelectedId = lstDrug.SelectedValue?.ToString(); if (!string.IsNullOrEmpty(strSelectedId)) { // Retrieve the information for the selected piece of Drug. xmlDrug = _xmlBaseDrugDataNode.SelectSingleNode(_strNodeXPath + "[id = \"" + strSelectedId + "\"]"); } string strForceGrade; if (xmlDrug != null) { strForceGrade = xmlDrug.SelectSingleNode("forcegrade")?.Value; // If the piece has a Rating value, enable the Rating control, otherwise, disable it and set its value to 0. XPathNavigator xmlRatingNode = xmlDrug.SelectSingleNode("rating"); if (xmlRatingNode != null) { string strMinRating = xmlDrug.SelectSingleNode("minrating")?.Value; int intMinRating = 1; // Not a simple integer, so we need to start mucking around with strings if (!string.IsNullOrEmpty(strMinRating) && !int.TryParse(strMinRating, out intMinRating)) { strMinRating = strMinRating.CheapReplace("MaximumSTR", () => (ParentVehicle != null ? Math.Max(1, ParentVehicle.TotalBody * 2) : _objCharacter.STR.TotalMaximum).ToString()) .CheapReplace("MaximumAGI", () => (ParentVehicle != null ? Math.Max(1, ParentVehicle.Pilot * 2) : _objCharacter.AGI.TotalMaximum).ToString()) .CheapReplace("MinimumSTR", () => (ParentVehicle?.TotalBody ?? 3).ToString()) .CheapReplace("MinimumAGI", () => (ParentVehicle?.Pilot ?? 3).ToString()); object objProcess = CommonFunctions.EvaluateInvariantXPath(strMinRating, out bool blnIsSuccess); intMinRating = blnIsSuccess ? Convert.ToInt32(objProcess) : 1; } nudRating.Minimum = intMinRating; string strMaxRating = xmlRatingNode.Value; int intMaxRating = 0; // Not a simple integer, so we need to start mucking around with strings if (!string.IsNullOrEmpty(strMaxRating) && !int.TryParse(strMaxRating, out intMaxRating)) { strMaxRating = strMaxRating.CheapReplace("MaximumSTR", () => (ParentVehicle != null ? Math.Max(1, ParentVehicle.TotalBody * 2) : _objCharacter.STR.TotalMaximum).ToString()) .CheapReplace("MaximumAGI", () => (ParentVehicle != null ? Math.Max(1, ParentVehicle.Pilot * 2) : _objCharacter.AGI.TotalMaximum).ToString()) .CheapReplace("MinimumSTR", () => (ParentVehicle?.TotalBody ?? 3).ToString()) .CheapReplace("MinimumAGI", () => (ParentVehicle?.Pilot ?? 3).ToString()); object objProcess = CommonFunctions.EvaluateInvariantXPath(strMaxRating, out bool blnIsSuccess); intMaxRating = blnIsSuccess ? Convert.ToInt32(objProcess) : 1; } nudRating.Maximum = intMaxRating; if (chkHideOverAvailLimit.Checked) { int intAvailModifier = strForceGrade == "None" ? 0 : _intAvailModifier; while (nudRating.Maximum > intMinRating && !SelectionShared.CheckAvailRestriction(xmlDrug, _objCharacter, decimal.ToInt32(nudRating.Maximum), intAvailModifier)) { nudRating.Maximum -= 1; } } if (chkShowOnlyAffordItems.Checked && !chkFree.Checked) { decimal decCostMultiplier = 1 + (nudMarkup.Value / 100.0m); if (chkBlackMarketDiscount.Checked) { decCostMultiplier *= 0.9m; } while (nudRating.Maximum > intMinRating && !SelectionShared.CheckNuyenRestriction(xmlDrug, _objCharacter.Nuyen, decCostMultiplier, decimal.ToInt32(nudRating.Maximum))) { nudRating.Maximum -= 1; } } nudRating.Value = nudRating.Minimum; nudRating.Enabled = nudRating.Minimum != nudRating.Maximum; nudRating.Visible = true; lblRatingNALabel.Visible = false; lblRatingLabel.Visible = true; } else { lblRatingLabel.Visible = true; lblRatingNALabel.Visible = true; nudRating.Minimum = 0; nudRating.Value = 0; nudRating.Visible = false; } string strSource = xmlDrug.SelectSingleNode("source")?.Value ?? LanguageManager.GetString("String_Unknown", GlobalOptions.Language); string strPage = xmlDrug.SelectSingleNode("altpage")?.Value ?? xmlDrug.SelectSingleNode("page")?.Value ?? LanguageManager.GetString("String_Unknown", GlobalOptions.Language); string strSpaceCharacter = LanguageManager.GetString("String_Space", GlobalOptions.Language); lblSource.Text = CommonFunctions.LanguageBookShort(strSource, GlobalOptions.Language) + strSpaceCharacter + strPage; lblSource.SetToolTip(CommonFunctions.LanguageBookLong(strSource, GlobalOptions.Language) + strSpaceCharacter + LanguageManager.GetString("String_Page", GlobalOptions.Language) + ' ' + strPage); lblSourceLabel.Visible = !string.IsNullOrEmpty(lblSource.Text); Grade objForcedGrade = null; if (!string.IsNullOrEmpty(strForceGrade)) { // Force the Drug to be a particular Grade. if (cboGrade.Enabled) { cboGrade.Enabled = false; } objForcedGrade = _lstGrades.FirstOrDefault(x => x.Name == strForceGrade); strForceGrade = objForcedGrade?.SourceId.ToString("D"); } else { cboGrade.Enabled = !_blnLockGrade; if (_blnLockGrade) { strForceGrade = _objForcedGrade?.SourceId.ToString("D") ?? cboGrade.SelectedValue?.ToString(); objForcedGrade = _objForcedGrade ?? _lstGrades.FirstOrDefault(x => x.SourceId.ToString("D") == strForceGrade); } } chkBlackMarketDiscount.Enabled = _objCharacter.BlackMarketDiscount; chkBlackMarketDiscount.Checked = GlobalOptions.AssumeBlackMarket && _setBlackMarketMaps.Contains(xmlDrug.SelectSingleNode("category")?.Value); // We may need to rebuild the Grade list since Cultured Bioware is not allowed to select Standard (Second-Hand) as Grade and ForceGrades can change. PopulateGrades(xmlDrug.SelectSingleNode("nosecondhand") != null || (!cboGrade.Enabled && objForcedGrade?.SecondHand != true), false, strForceGrade, chkHideBannedGrades.Checked); /* * string strNotes = xmlDrug.SelectSingleNode("altnotes")?.Value ?? xmlDrug.SelectSingleNode("notes")?.Value; * if (!string.IsNullOrEmpty(strNotes)) * { * lblDrugNotes.Visible = true; * lblDrugNotesLabel.Visible = true; * lblDrugNotes.Text = strNotes; * } * else * { * lblDrugNotes.Visible = false; * lblDrugNotesLabel.Visible = false; * }*/ } else { lblRatingLabel.Visible = false; lblRatingNALabel.Visible = false; nudRating.Minimum = 0; nudRating.Value = 0; nudRating.Visible = false; cboGrade.Enabled = !_blnLockGrade; strForceGrade = string.Empty; Grade objForcedGrade = null; if (_blnLockGrade) { strForceGrade = _objForcedGrade?.SourceId.ToString("D") ?? cboGrade.SelectedValue?.ToString(); objForcedGrade = _objForcedGrade ?? _lstGrades.FirstOrDefault(x => x.SourceId.ToString("D") == strForceGrade); } PopulateGrades(_blnLockGrade && objForcedGrade?.SecondHand != true, false, strForceGrade, chkHideBannedGrades.Checked); chkBlackMarketDiscount.Checked = false; lblSourceLabel.Visible = false; lblSource.Text = string.Empty; lblSource.SetToolTip(string.Empty); } _blnLoading = false; UpdateDrugInfo(); }
private void cmdPDFTest_Click(object sender, EventArgs e) { if (txtPDFLocation.Text == string.Empty) return; SaveRegistrySettings(); CommonFunctions objCommon = new CommonFunctions(null); objCommon.OpenPDF(treSourcebook.SelectedNode.Tag + " 5"); }
private void UpdateGearInfo(bool blnUpdateMountCBOs = true) { 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 strSpace = LanguageManager.GetString("String_Space"); 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 && !xmlAccessory.CheckAvailRestriction(_objCharacter, nudRating.MaximumAsInt)) { 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 && !xmlAccessory.CheckNuyenRestriction(_objCharacter.Nuyen, decCostMultiplier, nudRating.MaximumAsInt)) { 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; } if (blnUpdateMountCBOs) { string strDataMounts = xmlAccessory.SelectSingleNode("mount")?.Value; List <string> strMounts = new List <string>(); if (!string.IsNullOrEmpty(strDataMounts)) { strMounts.AddRange(strDataMounts.SplitNoAlloc('/', StringSplitOptions.RemoveEmptyEntries)); } 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.SplitNoAlloc('/', StringSplitOptions.RemoveEmptyEntries)) { 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. lblAvail.Text = new AvailabilityValue(Convert.ToInt32(nudRating.Value), xmlAccessory.SelectSingleNode("avail")?.Value).ToString(); 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)) .CheapReplace("Weapon Total Cost", () => _objParentWeapon.MultipliableCost(null).ToString(GlobalOptions.InvariantCultureInfo)) .Replace("Rating", nudRating.Value.ToString(GlobalOptions.CultureInfo)); } if (strCost.StartsWith("Variable(", StringComparison.Ordinal)) { 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 = new StringBuilder(decMin.ToString(_objCharacter.Options.NuyenFormat, GlobalOptions.CultureInfo)) .Append(strSpace).Append('-').Append(strSpace) .Append(decMax.ToString(_objCharacter.Options.NuyenFormat, GlobalOptions.CultureInfo)).Append('¥').ToString(); } 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; } decCost *= _objParentWeapon.AccessoryMultiplier; if (!string.IsNullOrEmpty(_objParentWeapon.DoubledCostModificationSlots)) { string[] astrParentDoubledCostModificationSlots = _objParentWeapon.DoubledCostModificationSlots.Split('/', StringSplitOptions.RemoveEmptyEntries); if (astrParentDoubledCostModificationSlots.Contains(cboMount.SelectedItem?.ToString()) || astrParentDoubledCostModificationSlots.Contains(cboExtraMount.SelectedItem?.ToString())) { decCost *= 2; } } 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); } lblRatingLabel.Text = xmlAccessory.SelectSingleNode("ratinglabel") != null ? string.Format(GlobalOptions.CultureInfo, LanguageManager.GetString("Label_RatingFormat"), LanguageManager.GetString(xmlAccessory.SelectSingleNode("ratinglabel").Value)) : LanguageManager.GetString("Label_Rating"); lblCostLabel.Visible = !string.IsNullOrEmpty(lblCost.Text); lblTestLabel.Visible = !string.IsNullOrEmpty(lblTest.Text); if (!chkBlackMarketDiscount.Checked) { chkBlackMarketDiscount.Checked = GlobalOptions.AssumeBlackMarket && _blnIsParentWeaponBlackMarketAllowed; } else if (!_blnIsParentWeaponBlackMarketAllowed) { //Prevent chkBlackMarketDiscount from being checked if the gear category doesn't match. chkBlackMarketDiscount.Checked = false; } chkBlackMarketDiscount.Enabled = _blnIsParentWeaponBlackMarketAllowed; string strSource = xmlAccessory.SelectSingleNode("source")?.Value ?? LanguageManager.GetString("String_Unknown"); string strPage = xmlAccessory.SelectSingleNode("altpage")?.Value ?? xmlAccessory.SelectSingleNode("page")?.Value ?? LanguageManager.GetString("String_Unknown"); SourceString objSourceString = new SourceString(strSource, strPage, GlobalOptions.Language, GlobalOptions.CultureInfo, _objCharacter); objSourceString.SetControl(lblSource); lblSourceLabel.Visible = !string.IsNullOrEmpty(lblSource.Text); }
private void lblPowerName_Click(object sender, EventArgs e) { string strBook = _objPower.Source + " " + _objPower.Page; CommonFunctions objCommon = new CommonFunctions(); objCommon.OpenPDF(strBook); }
/// <summary> /// Build the list of available weapon accessories. /// </summary> private void RefreshList() { List <ListItem> lstAccessories = new List <ListItem>(); // Populate the Accessory list. StringBuilder sbdFilter = new StringBuilder("(" + _objCharacter.Options.BookXPath() + ") and (contains(mount, \"Internal\") or contains(mount, \"None\") or mount = \"\""); foreach (string strAllowedMount in _lstAllowedMounts.Where(strAllowedMount => !string.IsNullOrEmpty(strAllowedMount))) { sbdFilter.Append(" or contains(mount, \"").Append(strAllowedMount).Append("\")"); } sbdFilter.Append(')'); if (!string.IsNullOrEmpty(txtSearch.Text)) { sbdFilter.Append(" and ").Append(CommonFunctions.GenerateSearchXPath(txtSearch.Text)); } int intOverLimit = 0; foreach (XPathNavigator objXmlAccessory in _xmlBaseChummerNode.Select("accessories/accessory[" + sbdFilter.ToString() + "]")) { string strId = objXmlAccessory.SelectSingleNode("id")?.Value; if (string.IsNullOrEmpty(strId)) { continue; } if (!_objParentWeapon.CheckAccessoryRequirements(objXmlAccessory)) { continue; } decimal decCostMultiplier = 1 + (nudMarkup.Value / 100.0m); if (_blnIsParentWeaponBlackMarketAllowed) { decCostMultiplier *= 0.9m; } if ((!chkHideOverAvailLimit.Checked || objXmlAccessory.CheckAvailRestriction(_objCharacter) && (chkFreeItem.Checked || !chkShowOnlyAffordItems.Checked || objXmlAccessory.CheckNuyenRestriction(_objCharacter.Nuyen, decCostMultiplier)))) { lstAccessories.Add(new ListItem(strId, objXmlAccessory.SelectSingleNode("translate")?.Value ?? objXmlAccessory.SelectSingleNode("name")?.Value ?? LanguageManager.GetString("String_Unknown"))); } else { ++intOverLimit; } } lstAccessories.Sort(CompareListItems.CompareNames); if (intOverLimit > 0) { // Add after sort so that it's always at the end lstAccessories.Add(new ListItem(string.Empty, string.Format(GlobalOptions.CultureInfo, LanguageManager.GetString("String_RestrictedItemsHidden"), intOverLimit))); } string strOldSelected = lstAccessory.SelectedValue?.ToString(); _blnLoading = true; lstAccessory.BeginUpdate(); lstAccessory.ValueMember = nameof(ListItem.Value); lstAccessory.DisplayMember = nameof(ListItem.Name); lstAccessory.DataSource = lstAccessories; _blnLoading = false; if (!string.IsNullOrEmpty(strOldSelected)) { lstAccessory.SelectedValue = strOldSelected; } else { lstAccessory.SelectedIndex = -1; } lstAccessory.EndUpdate(); }
private void lblCritterPowerSource_Click(object sender, EventArgs e) { CommonFunctions objCommon = new CommonFunctions(_objCharacter); objCommon.OpenPDF(lblCritterPowerSource.Text); }
/// <summary> /// Calculate the LP value for the selected items. /// </summary> private void CalculateValues(bool blnIncludePercentage = true) { if (_blnSkipRefresh) { return; } decimal decBaseCost = 0; decimal decCost = 0; decimal decMod = 0; // Get the base cost of the lifestyle string strSelectedId = cboLifestyle.SelectedValue?.ToString(); if (strSelectedId != null) { XmlNode objXmlAspect = _objXmlDocument.SelectSingleNode("/chummer/lifestyles/lifestyle[id = \"" + strSelectedId + "\"]"); if (objXmlAspect != null) { decBaseCost += Convert.ToDecimal(objXmlAspect["cost"]?.InnerText, GlobalOptions.InvariantCultureInfo); string strSource = objXmlAspect["source"]?.InnerText; string strPage = objXmlAspect["altpage"]?.InnerText ?? objXmlAspect["page"]?.InnerText; if (!string.IsNullOrEmpty(strSource) && !string.IsNullOrEmpty(strPage)) { 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 { lblSource.Text = LanguageManager.GetString("String_Unknown"); lblSource.SetToolTip(LanguageManager.GetString("String_Unknown")); } lblSourceLabel.Visible = !string.IsNullOrEmpty(lblSource.Text); // Add the flat costs from qualities foreach (TreeNode objNode in treQualities.Nodes) { if (objNode.Checked) { string strCost = _objXmlDocument.SelectSingleNode("/chummer/qualities/quality[id = \"" + objNode.Tag + "\"]/cost")?.InnerText; if (!string.IsNullOrEmpty(strCost)) { object objProcess = CommonFunctions.EvaluateInvariantXPath(strCost, out bool blnIsSuccess); if (blnIsSuccess) { decCost += Convert.ToDecimal(objProcess, GlobalOptions.InvariantCultureInfo); } } } } decimal decBaseMultiplier = 0; if (blnIncludePercentage) { // Add the modifiers from qualities foreach (TreeNode objNode in treQualities.Nodes) { if (!objNode.Checked) { continue; } objXmlAspect = _objXmlDocument.SelectSingleNode("/chummer/qualities/quality[id = \"" + objNode.Tag + "\"]"); if (objXmlAspect == null) { continue; } string strMultiplier = objXmlAspect["multiplier"]?.InnerText; if (!string.IsNullOrEmpty(strMultiplier)) { decMod += Convert.ToDecimal(strMultiplier, GlobalOptions.InvariantCultureInfo) / 100.0m; } strMultiplier = objXmlAspect["multiplierbaseonly"]?.InnerText; if (!string.IsNullOrEmpty(strMultiplier)) { decBaseMultiplier += Convert.ToDecimal(strMultiplier, GlobalOptions.InvariantCultureInfo) / 100.0m; } } // Check for modifiers in the improvements decimal decModifier = Convert.ToDecimal(ImprovementManager.ValueOf(_objCharacter, Improvement.ImprovementType.LifestyleCost), GlobalOptions.InvariantCultureInfo); decMod += decModifier / 100.0m; } decBaseCost += decBaseCost * decBaseMultiplier; if (nudRoommates.Value > 0) { decimal d = nudRoommates.Value * 10; d += 100M; d = Math.Max(d / 100, 0); decBaseCost *= (d); } } } decimal decNuyen = decBaseCost + decBaseCost * decMod + decCost; lblCost.Text = decNuyen.ToString(_objCharacter.Options.NuyenFormat, GlobalOptions.CultureInfo) + '¥'; if (nudPercentage.Value != 100 || (nudRoommates.Value != 0 && !chkPrimaryTenant.Checked)) { decimal decDiscount = decNuyen; decDiscount *= (nudPercentage.Value / 100); if (nudRoommates.Value != 0) { decDiscount /= (nudRoommates.Value); } lblCost.Text += LanguageManager.GetString("String_Space") + '(' + decDiscount.ToString(_objCharacter.Options.NuyenFormat, GlobalOptions.CultureInfo) + "¥)"; } lblCostLabel.Visible = !string.IsNullOrEmpty(lblCost.Text); }
private bool ProcessBonus(Improvement.ImprovementSource objImprovementSource, ref string strSourceName, bool blnConcatSelectedValue, int intRating, string strFriendlyName, XmlNode bonusNode, string strUnique) { Log.Info("Has Child Nodes"); // Add an Attribute. if (bonusNode.LocalName == ("addattribute")) { Log.Info("addattribute"); if (bonusNode["name"].InnerText == "MAG") { _objCharacter.MAGEnabled = true; Log.Info("Calling CreateImprovement for MAG"); CreateImprovement("MAG", objImprovementSource, strSourceName, Improvement.ImprovementType.Attribute, "enableattribute", 0, 0); } else if (bonusNode["name"].InnerText == "RES") { _objCharacter.RESEnabled = true; Log.Info("Calling CreateImprovement for RES"); CreateImprovement("RES", objImprovementSource, strSourceName, Improvement.ImprovementType.Attribute, "enableattribute", 0, 0); } } // Enable a special tab. if (bonusNode.LocalName == ("enabletab")) { Log.Info("enabletab"); foreach (XmlNode objXmlEnable in bonusNode.ChildNodes) { switch (objXmlEnable.InnerText) { case "magician": _objCharacter.MagicianEnabled = true; Log.Info("magician"); CreateImprovement("Magician", objImprovementSource, strSourceName, Improvement.ImprovementType.SpecialTab, "enabletab", 0, 0); break; case "adept": _objCharacter.AdeptEnabled = true; Log.Info("adept"); CreateImprovement("Adept", objImprovementSource, strSourceName, Improvement.ImprovementType.SpecialTab, "enabletab", 0, 0); break; case "technomancer": _objCharacter.TechnomancerEnabled = true; Log.Info("technomancer"); CreateImprovement("Technomancer", objImprovementSource, strSourceName, Improvement.ImprovementType.SpecialTab, "enabletab", 0, 0); break; case "critter": _objCharacter.CritterEnabled = true; Log.Info("critter"); CreateImprovement("Critter", objImprovementSource, strSourceName, Improvement.ImprovementType.SpecialTab, "enabletab", 0, 0); break; case "initiation": _objCharacter.InitiationEnabled = true; Log.Info("initiation"); CreateImprovement("Initiation", objImprovementSource, strSourceName, Improvement.ImprovementType.SpecialTab, "enabletab", 0, 0); break; } } } // Select Restricted (select Restricted items for Fake Licenses). if (bonusNode.LocalName == ("selectrestricted")) { Log.Info("selectrestricted"); frmSelectItem frmPickItem = new frmSelectItem(); frmPickItem.Character = _objCharacter; if (_strForcedValue != string.Empty) frmPickItem.ForceItem = _strForcedValue; frmPickItem.AllowAutoSelect = false; frmPickItem.ShowDialog(); // Make sure the dialogue window was not canceled. if (frmPickItem.DialogResult == DialogResult.Cancel) { Rollback(); _strForcedValue = ""; _strLimitSelection = ""; return false; } _strSelectedValue = frmPickItem.SelectedItem; if (blnConcatSelectedValue) strSourceName += " (" + _strSelectedValue + ")"; Log.Info("_strSelectedValue = " + _strSelectedValue); Log.Info("strSourceName = " + strSourceName); // Create the Improvement. Log.Info("Calling CreateImprovement"); CreateImprovement(frmPickItem.SelectedItem, objImprovementSource, strSourceName, Improvement.ImprovementType.Restricted, strUnique); } if (bonusNode.LocalName == "cyberseeker") { //Check if valid attrib if (new string[] {"BOD", "AGI", "STR", "REA", "LOG", "CHA", "INT", "WIL", "BOX"}.Any(x => x == bonusNode.InnerText)) { CreateImprovement(bonusNode.InnerText, objImprovementSource, strSourceName, Improvement.ImprovementType.Seeker, strUnique,0,0,0,0,0,0); } else { Utils.BreakIfDebug(); } } // Select a Skill. if (bonusNode.LocalName == ("selectskill")) { //TODO this don't work Log.Info("selectskill"); if (_strForcedValue == "+2 to a Combat Skill") _strForcedValue = ""; Log.Info("_strSelectedValue = " + _strSelectedValue); Log.Info("_strForcedValue = " + _strForcedValue); // Display the Select Skill window and record which Skill was selected. frmSelectSkill frmPickSkill = new frmSelectSkill(_objCharacter); if (strFriendlyName != "") frmPickSkill.Description = LanguageManager.Instance.GetString("String_Improvement_SelectSkillNamed") .Replace("{0}", strFriendlyName); else frmPickSkill.Description = LanguageManager.Instance.GetString("String_Improvement_SelectSkill"); Log.Info("selectskill = " + bonusNode.OuterXml.ToString()); if (bonusNode.OuterXml.Contains("skillgroup")) frmPickSkill.OnlySkillGroup = bonusNode.Attributes["skillgroup"].InnerText; else if (bonusNode.OuterXml.Contains("skillcategory")) frmPickSkill.OnlyCategory = bonusNode.Attributes["skillcategory"].InnerText; else if (bonusNode.OuterXml.Contains("excludecategory")) frmPickSkill.ExcludeCategory = bonusNode.Attributes["excludecategory"].InnerText; else if (bonusNode.OuterXml.Contains("limittoskill")) frmPickSkill.LimitToSkill = bonusNode.Attributes["limittoskill"].InnerText; else if (bonusNode.OuterXml.Contains("limittoattribute")) frmPickSkill.LinkedAttribute = bonusNode.Attributes["limittoattribute"].InnerText; if (_strForcedValue != "") { frmPickSkill.OnlySkill = _strForcedValue; frmPickSkill.Opacity = 0; } frmPickSkill.ShowDialog(); // Make sure the dialogue window was not canceled. if (frmPickSkill.DialogResult == DialogResult.Cancel) { Rollback(); _strForcedValue = ""; _strLimitSelection = ""; return false; } bool blnAddToRating = false; if (bonusNode["applytorating"] != null) { if (bonusNode["applytorating"].InnerText == "yes") blnAddToRating = true; } _strSelectedValue = frmPickSkill.SelectedSkill; if (blnConcatSelectedValue) strSourceName += " (" + _strSelectedValue + ")"; Log.Info("_strSelectedValue = " + _strSelectedValue); Log.Info("strSourceName = " + strSourceName); // Find the selected Skill. foreach (Skill objSkill in _objCharacter.SkillsSection.Skills) { if (frmPickSkill.SelectedSkill.Contains("Exotic Melee Weapon") || frmPickSkill.SelectedSkill.Contains("Exotic Ranged Weapon") || frmPickSkill.SelectedSkill.Contains("Pilot Exotic Vehicle")) { if (objSkill.Name + " (" + objSkill.Specialization + ")" == frmPickSkill.SelectedSkill) { // We've found the selected Skill. if (bonusNode.InnerXml.Contains("val")) { Log.Info("Calling CreateImprovement"); CreateImprovement(objSkill.Name + " (" + objSkill.Specialization + ")", objImprovementSource, strSourceName, Improvement.ImprovementType.Skill, strUnique, ValueToInt(bonusNode["val"].InnerText, intRating), 1, 0, 0, 0, 0, "", blnAddToRating); } if (bonusNode.InnerXml.Contains("max")) { Log.Info("Calling CreateImprovement"); CreateImprovement(objSkill.Name + " (" + objSkill.Specialization + ")", objImprovementSource, strSourceName, Improvement.ImprovementType.Skill, strUnique, 0, 1, 0, ValueToInt(bonusNode["max"].InnerText, intRating), 0, 0, "", blnAddToRating); } } } else { if (objSkill.Name == frmPickSkill.SelectedSkill) { // We've found the selected Skill. if (bonusNode.InnerXml.Contains("val")) { Log.Info("Calling CreateImprovement"); CreateImprovement(objSkill.Name, objImprovementSource, strSourceName, Improvement.ImprovementType.Skill, strUnique, ValueToInt(bonusNode["val"].InnerText, intRating), 1, 0, 0, 0, 0, "", blnAddToRating); } if (bonusNode.InnerXml.Contains("max")) { Log.Info("Calling CreateImprovement"); CreateImprovement(objSkill.Name, objImprovementSource, strSourceName, Improvement.ImprovementType.Skill, strUnique, 0, 1, 0, ValueToInt(bonusNode["max"].InnerText, intRating), 0, 0, "", blnAddToRating); } } } } } // Select a Skill Group. if (bonusNode.LocalName == ("selectskillgroup")) { Log.Info("selectskillgroup"); string strExclude = ""; if (bonusNode.Attributes["excludecategory"] != null) strExclude = bonusNode.Attributes["excludecategory"].InnerText; frmSelectSkillGroup frmPickSkillGroup = new frmSelectSkillGroup(); if (strFriendlyName != "") frmPickSkillGroup.Description = LanguageManager.Instance.GetString("String_Improvement_SelectSkillGroupName").Replace("{0}", strFriendlyName); else frmPickSkillGroup.Description = LanguageManager.Instance.GetString("String_Improvement_SelectSkillGroup"); Log.Info("_strForcedValue = " + _strForcedValue); Log.Info("_strLimitSelection = " + _strLimitSelection); if (_strForcedValue != "") { frmPickSkillGroup.OnlyGroup = _strForcedValue; frmPickSkillGroup.Opacity = 0; } if (strExclude != string.Empty) frmPickSkillGroup.ExcludeCategory = strExclude; frmPickSkillGroup.ShowDialog(); // Make sure the dialogue window was not canceled. if (frmPickSkillGroup.DialogResult == DialogResult.Cancel) { Rollback(); _strForcedValue = ""; _strLimitSelection = ""; return false; } bool blnAddToRating = false; if (bonusNode["applytorating"] != null) { if (bonusNode["applytorating"].InnerText == "yes") blnAddToRating = true; } _strSelectedValue = frmPickSkillGroup.SelectedSkillGroup; Log.Info("_strSelectedValue = " + _strSelectedValue); Log.Info("strSourceName = " + strSourceName); if (bonusNode.SelectSingleNode("bonus") != null) { Log.Info("Calling CreateImprovement"); CreateImprovement(_strSelectedValue, objImprovementSource, strSourceName, Improvement.ImprovementType.SkillGroup, strUnique, ValueToInt(bonusNode["bonus"].InnerText, intRating), 1, 0, 0, 0, 0, strExclude, blnAddToRating); } else { Log.Info("Calling CreateImprovement"); CreateImprovement(_strSelectedValue, objImprovementSource, strSourceName, Improvement.ImprovementType.SkillGroup, strUnique, 0, 0, 0, 1, 0, 0, strExclude, blnAddToRating); } } if (bonusNode.LocalName == ("selectattributes")) { foreach (XmlNode objXmlAttribute in bonusNode.SelectNodes("selectattribute")) { Log.Info("selectattribute"); // Display the Select Attribute window and record which Skill was selected. frmSelectAttribute frmPickAttribute = new frmSelectAttribute(); if (strFriendlyName != "") frmPickAttribute.Description = LanguageManager.Instance.GetString("String_Improvement_SelectAttributeNamed").Replace("{0}", strFriendlyName); else frmPickAttribute.Description = LanguageManager.Instance.GetString("String_Improvement_SelectAttribute"); // Add MAG and/or RES to the list of Attributes if they are enabled on the form. if (_objCharacter.MAGEnabled) frmPickAttribute.AddMAG(); if (_objCharacter.RESEnabled) frmPickAttribute.AddRES(); Log.Info("selectattribute = " + bonusNode.OuterXml.ToString()); if (objXmlAttribute.InnerXml.Contains("<attribute>")) { List<string> strValue = new List<string>(); foreach (XmlNode objSubNode in objXmlAttribute.SelectNodes("attribute")) strValue.Add(objSubNode.InnerText); frmPickAttribute.LimitToList(strValue); } if (bonusNode.InnerXml.Contains("<excludeattribute>")) { List<string> strValue = new List<string>(); foreach (XmlNode objSubNode in objXmlAttribute.SelectNodes("excludeattribute")) strValue.Add(objSubNode.InnerText); frmPickAttribute.RemoveFromList(strValue); } // Check to see if there is only one possible selection because of _strLimitSelection. if (_strForcedValue != "") _strLimitSelection = _strForcedValue; Log.Info("_strForcedValue = " + _strForcedValue); Log.Info("_strLimitSelection = " + _strLimitSelection); if (_strLimitSelection != "") { frmPickAttribute.SingleAttribute(_strLimitSelection); frmPickAttribute.Opacity = 0; } frmPickAttribute.ShowDialog(); // Make sure the dialogue window was not canceled. if (frmPickAttribute.DialogResult == DialogResult.Cancel) { Rollback(); _strForcedValue = ""; return false; } _strSelectedValue = frmPickAttribute.SelectedAttribute; if (blnConcatSelectedValue) strSourceName += " (" + _strSelectedValue + ")"; Log.Info("_strSelectedValue = " + _strSelectedValue); Log.Info("strSourceName = " + strSourceName); // Record the improvement. int intMin = 0; int intAug = 0; int intMax = 0; int intAugMax = 0; // Extract the modifiers. if (objXmlAttribute.InnerXml.Contains("min")) intMin = Convert.ToInt32(objXmlAttribute["min"].InnerText); if (objXmlAttribute.InnerXml.Contains("val")) intAug = Convert.ToInt32(objXmlAttribute["val"].InnerText); if (objXmlAttribute.InnerXml.Contains("max")) intMax = Convert.ToInt32(objXmlAttribute["max"].InnerText); if (objXmlAttribute.InnerXml.Contains("aug")) intAugMax = Convert.ToInt32(objXmlAttribute["aug"].InnerText); string strAttribute = frmPickAttribute.SelectedAttribute; if (objXmlAttribute["affectbase"] != null) strAttribute += "Base"; Log.Info("Calling CreateImprovement"); CreateImprovement(strAttribute, objImprovementSource, strSourceName, Improvement.ImprovementType.Attribute, strUnique, 0, 1, intMin, intMax, intAug, intAugMax); } } // Select an CharacterAttribute. if (bonusNode.LocalName == ("selectattribute")) { Log.Info("selectattribute"); // Display the Select Attribute window and record which Skill was selected. frmSelectAttribute frmPickAttribute = new frmSelectAttribute(); if (strFriendlyName != "") frmPickAttribute.Description = LanguageManager.Instance.GetString("String_Improvement_SelectAttributeNamed").Replace("{0}", strFriendlyName); else frmPickAttribute.Description = LanguageManager.Instance.GetString("String_Improvement_SelectAttribute"); // Add MAG and/or RES to the list of Attributes if they are enabled on the form. if (_objCharacter.MAGEnabled) frmPickAttribute.AddMAG(); if (_objCharacter.RESEnabled) frmPickAttribute.AddRES(); Log.Info("selectattribute = " + bonusNode.OuterXml.ToString()); if (bonusNode.InnerXml.Contains("<attribute>")) { List<string> strValue = new List<string>(); foreach (XmlNode objXmlAttribute in bonusNode.SelectNodes("attribute")) strValue.Add(objXmlAttribute.InnerText); frmPickAttribute.LimitToList(strValue); } if (bonusNode.InnerXml.Contains("<excludeattribute>")) { List<string> strValue = new List<string>(); foreach (XmlNode objXmlAttribute in bonusNode.SelectNodes("excludeattribute")) strValue.Add(objXmlAttribute.InnerText); frmPickAttribute.RemoveFromList(strValue); } // Check to see if there is only one possible selection because of _strLimitSelection. if (_strForcedValue != "") _strLimitSelection = _strForcedValue; Log.Info("_strForcedValue = " + _strForcedValue); Log.Info("_strLimitSelection = " + _strLimitSelection); if (_strLimitSelection != "") { frmPickAttribute.SingleAttribute(_strLimitSelection); frmPickAttribute.Opacity = 0; } frmPickAttribute.ShowDialog(); // Make sure the dialogue window was not canceled. if (frmPickAttribute.DialogResult == DialogResult.Cancel) { Rollback(); _strForcedValue = ""; return false; } _strSelectedValue = frmPickAttribute.SelectedAttribute; if (blnConcatSelectedValue) strSourceName += " (" + _strSelectedValue + ")"; Log.Info("_strSelectedValue = " + _strSelectedValue); Log.Info("strSourceName = " + strSourceName); // Record the improvement. int intMin = 0; int intAug = 0; int intMax = 0; int intAugMax = 0; // Extract the modifiers. if (bonusNode.InnerXml.Contains("min")) intMin = ValueToInt(bonusNode["min"].InnerXml, intRating); if (bonusNode.InnerXml.Contains("val")) intAug = ValueToInt(bonusNode["val"].InnerXml, intRating); if (bonusNode.InnerXml.Contains("max")) intMax = ValueToInt(bonusNode["max"].InnerXml, intRating); if (bonusNode.InnerXml.Contains("aug")) intAugMax = ValueToInt(bonusNode["aug"].InnerXml, intRating); string strAttribute = frmPickAttribute.SelectedAttribute; if (bonusNode["affectbase"] != null) strAttribute += "Base"; Log.Info("Calling CreateImprovement"); CreateImprovement(strAttribute, objImprovementSource, strSourceName, Improvement.ImprovementType.Attribute, strUnique, 0, 1, intMin, intMax, intAug, intAugMax); } // Select a Limit. if (bonusNode.LocalName == ("selectlimit")) { Log.Info("selectlimit"); // Display the Select Limit window and record which Limit was selected. frmSelectLimit frmPickLimit = new frmSelectLimit(); if (strFriendlyName != "") frmPickLimit.Description = LanguageManager.Instance.GetString("String_Improvement_SelectLimitNamed") .Replace("{0}", strFriendlyName); else frmPickLimit.Description = LanguageManager.Instance.GetString("String_Improvement_SelectLimit"); Log.Info("selectlimit = " + bonusNode.OuterXml.ToString()); if (bonusNode.InnerXml.Contains("<limit>")) { List<string> strValue = new List<string>(); foreach (XmlNode objXmlAttribute in bonusNode.SelectNodes("limit")) strValue.Add(objXmlAttribute.InnerText); frmPickLimit.LimitToList(strValue); } if (bonusNode.InnerXml.Contains("<excludelimit>")) { List<string> strValue = new List<string>(); foreach (XmlNode objXmlAttribute in bonusNode.SelectNodes("excludelimit")) strValue.Add(objXmlAttribute.InnerText); frmPickLimit.RemoveFromList(strValue); } // Check to see if there is only one possible selection because of _strLimitSelection. if (_strForcedValue != "") _strLimitSelection = _strForcedValue; Log.Info("_strForcedValue = " + _strForcedValue); Log.Info("_strLimitSelection = " + _strLimitSelection); if (_strLimitSelection != "") { frmPickLimit.SingleLimit(_strLimitSelection); frmPickLimit.Opacity = 0; } frmPickLimit.ShowDialog(); // Make sure the dialogue window was not canceled. if (frmPickLimit.DialogResult == DialogResult.Cancel) { Rollback(); _strForcedValue = ""; return false; } _strSelectedValue = frmPickLimit.SelectedLimit; if (blnConcatSelectedValue) strSourceName += " (" + _strSelectedValue + ")"; // Record the improvement. int intMin = 0; int intAug = 0; int intMax = 0; int intAugMax = 0; // Extract the modifiers. if (bonusNode.InnerXml.Contains("min")) intMin = ValueToInt(bonusNode["min"].InnerXml, intRating); if (bonusNode.InnerXml.Contains("val")) intAug = ValueToInt(bonusNode["val"].InnerXml, intRating); if (bonusNode.InnerXml.Contains("max")) intMax = ValueToInt(bonusNode["max"].InnerXml, intRating); if (bonusNode.InnerXml.Contains("aug")) intAugMax = ValueToInt(bonusNode["aug"].InnerXml, intRating); string strLimit = frmPickLimit.SelectedLimit; if (bonusNode["affectbase"] != null) strLimit += "Base"; Log.Info("_strSelectedValue = " + _strSelectedValue); Log.Info("strSourceName = " + strSourceName); LimitModifier objLimitMod = new LimitModifier(_objCharacter); // string strBonus = bonusNode["value"].InnerText; int intBonus = intAug; string strName = strFriendlyName; TreeNode nodTemp = new TreeNode(); Improvement.ImprovementType objType = Improvement.ImprovementType.PhysicalLimit; switch (strLimit) { case "Mental": { objType = Improvement.ImprovementType.MentalLimit; break; } case "Social": { objType = Improvement.ImprovementType.SocialLimit; break; } default: { objType = Improvement.ImprovementType.PhysicalLimit; break; } } Log.Info("Calling CreateImprovement"); CreateImprovement(strLimit, objImprovementSource, strSourceName, objType, strFriendlyName, intBonus, 0, intMin, intMax, intAug, intAugMax); } // Select an CharacterAttribute to use instead of the default on a skill. if (bonusNode.LocalName == ("swapskillattribute")) { Log.Info("swapskillattribute"); // Display the Select Attribute window and record which Skill was selected. frmSelectAttribute frmPickAttribute = new frmSelectAttribute(); if (strFriendlyName != "") frmPickAttribute.Description = LanguageManager.Instance.GetString("String_Improvement_SelectAttributeNamed").Replace("{0}", strFriendlyName); else frmPickAttribute.Description = LanguageManager.Instance.GetString("String_Improvement_SelectAttribute"); List<string> strValue = new List<string>(); strValue.Add("LOG"); strValue.Add("WIL"); strValue.Add("INT"); strValue.Add("CHA"); strValue.Add("EDG"); strValue.Add("MAG"); strValue.Add("RES"); frmPickAttribute.RemoveFromList(strValue); Log.Info("swapskillattribute = " + bonusNode.OuterXml.ToString()); if (bonusNode.InnerXml.Contains("<attribute>")) { List<string> strLimitValue = new List<string>(); foreach (XmlNode objXmlAttribute in bonusNode.SelectNodes("attribute")) strLimitValue.Add(objXmlAttribute.InnerText); frmPickAttribute.LimitToList(strLimitValue); } // Check to see if there is only one possible selection because of _strLimitSelection. if (_strForcedValue != "") _strLimitSelection = _strForcedValue; Log.Info("_strForcedValue = " + _strForcedValue); Log.Info("_strLimitSelection = " + _strLimitSelection); if (_strLimitSelection != "") { frmPickAttribute.SingleAttribute(_strLimitSelection); frmPickAttribute.Opacity = 0; } frmPickAttribute.ShowDialog(); // Make sure the dialogue window was not canceled. if (frmPickAttribute.DialogResult == DialogResult.Cancel) { Rollback(); _strForcedValue = ""; _strLimitSelection = ""; return false; } _strSelectedValue = frmPickAttribute.SelectedAttribute; if (blnConcatSelectedValue) strSourceName += " (" + _strSelectedValue + ")"; Log.Info("_strSelectedValue = " + _strSelectedValue); Log.Info("strSourceName = " + strSourceName); Log.Info("Calling CreateImprovement"); CreateImprovement(frmPickAttribute.SelectedAttribute, objImprovementSource, strSourceName, Improvement.ImprovementType.SwapSkillAttribute, strUnique); } // Select a Spell. if (bonusNode.LocalName == ("selectspell")) { Log.Info("selectspell"); // Display the Select Spell window. frmSelectSpell frmPickSpell = new frmSelectSpell(_objCharacter); if (bonusNode.Attributes["category"] != null) frmPickSpell.LimitCategory = bonusNode.Attributes["category"].InnerText; Log.Info("selectspell = " + bonusNode.OuterXml.ToString()); Log.Info("_strForcedValue = " + _strForcedValue); Log.Info("_strLimitSelection = " + _strLimitSelection); if (_strForcedValue != "") { frmPickSpell.ForceSpellName = _strForcedValue; frmPickSpell.Opacity = 0; } frmPickSpell.ShowDialog(); // Make sure the dialogue window was not canceled. if (frmPickSpell.DialogResult == DialogResult.Cancel) { Rollback(); _strForcedValue = ""; _strLimitSelection = ""; return false; } _strSelectedValue = frmPickSpell.SelectedSpell; if (blnConcatSelectedValue) strSourceName += " (" + _strSelectedValue + ")"; Log.Info("_strSelectedValue = " + _strSelectedValue); Log.Info("strSourceName = " + strSourceName); Log.Info("Calling CreateImprovement"); CreateImprovement(frmPickSpell.SelectedSpell, objImprovementSource, strSourceName, Improvement.ImprovementType.Text, strUnique); } // Select a Contact if (bonusNode.LocalName == ("selectcontact")) { Log.Info("selectcontact"); XmlNode nodSelect = bonusNode; frmSelectItem frmSelect = new frmSelectItem(); String strMode = NodeExists(nodSelect, "type") ? nodSelect["type"].InnerText : "all"; List<Contact> selectedContactsList; if (strMode == "all") { selectedContactsList = new List<Contact>(_objCharacter.Contacts); } else if (strMode == "group" || strMode == "nongroup") { bool blnGroup = strMode == "group"; //Select any contact where IsGroup equals blnGroup //and add to a list selectedContactsList = new List<Contact>(from contact in _objCharacter.Contacts where contact.IsGroup == blnGroup select contact); } else { Rollback(); return false; } if (selectedContactsList.Count == 0) { MessageBox.Show(LanguageManager.Instance.GetString("Message_NoContactFound"), LanguageManager.Instance.GetString("MessageTitle_NoContactFound"), MessageBoxButtons.OK, MessageBoxIcon.Error); Rollback(); return false; } int count = 0; //Black magic LINQ to cast content of list to another type List<ListItem> contacts = new List<ListItem>(from x in selectedContactsList select new ListItem() {Name = x.Name, Value = (count++).ToString()}); String strPrice = NodeExists(nodSelect, "cost") ? nodSelect["cost"].InnerText : ""; frmSelect.GeneralItems = contacts; frmSelect.ShowDialog(); int index = int.Parse(frmSelect.SelectedItem); if (frmSelect.DialogResult != DialogResult.Cancel) { Contact selectedContact = selectedContactsList[index]; if (nodSelect["mademan"] != null) { selectedContact.MadeMan = true; CreateImprovement(selectedContact.GUID, Improvement.ImprovementSource.Quality, strSourceName, Improvement.ImprovementType.ContactMadeMan, selectedContact.GUID); } if (String.IsNullOrWhiteSpace(_strSelectedValue)) { _strSelectedValue = selectedContact.Name; } else { _strSelectedValue += (", " + selectedContact.Name); } } else { Rollback(); return false; } } if (bonusNode.LocalName == "addcontact") { Log.Info("addcontact"); int loyalty, connection; bonusNode.TryGetField("loyalty", out loyalty, 1); bonusNode.TryGetField("connection", out connection, 1); bool group = bonusNode["group"] != null; bool free = bonusNode["free"] != null; Contact contact = new Contact(_objCharacter); contact.Free = free; contact.IsGroup = group; contact.Loyalty = loyalty; contact.Connection = connection; contact.ReadOnly = true; _objCharacter.Contacts.Add(contact); CreateImprovement(contact.GUID, Improvement.ImprovementSource.Quality, strSourceName, Improvement.ImprovementType.AddContact, contact.GUID); } // Affect a Specific CharacterAttribute. if (bonusNode.LocalName == ("specificattribute")) { Log.Info("specificattribute"); if (bonusNode["name"].InnerText != "ESS") { // Display the Select CharacterAttribute window and record which CharacterAttribute was selected. // Record the improvement. int intMin = 0; int intAug = 0; int intMax = 0; int intAugMax = 0; // Extract the modifiers. if (bonusNode.InnerXml.Contains("min")) intMin = ValueToInt(bonusNode["min"].InnerXml, intRating); if (bonusNode.InnerXml.Contains("val")) intAug = ValueToInt(bonusNode["val"].InnerXml, intRating); if (bonusNode.InnerXml.Contains("max")) { if (bonusNode["max"].InnerText.Contains("-natural")) { intMax = Convert.ToInt32(bonusNode["max"].InnerText.Replace("-natural", string.Empty)) - _objCharacter.GetAttribute(bonusNode["name"].InnerText).MetatypeMaximum; } else intMax = ValueToInt(bonusNode["max"].InnerXml, intRating); } if (bonusNode.InnerXml.Contains("aug")) intAugMax = ValueToInt(bonusNode["aug"].InnerXml, intRating); string strUseUnique = strUnique; if (bonusNode["name"].Attributes["precedence"] != null) strUseUnique = "precedence" + bonusNode["name"].Attributes["precedence"].InnerText; string strAttribute = bonusNode["name"].InnerText; if (bonusNode["affectbase"] != null) strAttribute += "Base"; CreateImprovement(strAttribute, objImprovementSource, strSourceName, Improvement.ImprovementType.Attribute, strUseUnique, 0, 1, intMin, intMax, intAug, intAugMax); } else { CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.Essence, "", Convert.ToInt32(bonusNode["val"].InnerText)); } } // Add a paid increase to an attribute if (bonusNode.LocalName == ("attributelevel")) { Log.Info(new object[] {"attributelevel", bonusNode.OuterXml}); String strAttrib; int value; bonusNode.TryGetField("val", out value, 1); if (bonusNode.TryGetField("name", out strAttrib)) { CreateImprovement(strAttrib, objImprovementSource, strSourceName, Improvement.ImprovementType.Attributelevel, "", value); } else { Log.Error(new object[] {"attributelevel", bonusNode.OuterXml}); } } if (bonusNode.LocalName == ("skilllevel")) { Log.Info(new object[] {"skilllevel", bonusNode.OuterXml}); String strSkill; int value; bonusNode.TryGetField("val", out value, 1); if (bonusNode.TryGetField("name", out strSkill)) { CreateImprovement(strSkill, objImprovementSource, strSourceName, Improvement.ImprovementType.SkillLevel, "", value); } else { Log.Error(new object[] {"skilllevel", bonusNode.OuterXml}); } } if (bonusNode.LocalName == "pushtext") { String push = bonusNode.InnerText; if (!String.IsNullOrWhiteSpace(push)) { _objCharacter.Pushtext.Push(push); } } if (bonusNode.LocalName == "knowsoft") { int val = bonusNode["val"] != null ? ValueToInt(bonusNode["val"].InnerText, intRating) : 1; string name; if (!string.IsNullOrWhiteSpace(_strForcedValue)) { name = _strForcedValue; } else if (bonusNode["pick"] != null) { List<ListItem> types; if (bonusNode["group"] != null) { var v = bonusNode.SelectNodes($"./group"); types = KnowledgeSkill.KnowledgeTypes.Where(x => bonusNode.SelectNodes($"group[. = '{x.Value}']").Count > 0).ToList(); } else if (bonusNode["notgroup"] != null) { types = KnowledgeSkill.KnowledgeTypes.Where(x => bonusNode.SelectNodes($"notgroup[. = '{x.Value}']").Count == 0).ToList(); } else { types = KnowledgeSkill.KnowledgeTypes; } frmSelectItem select = new frmSelectItem(); select.DropdownItems = KnowledgeSkill.KnowledgeSkillsWithCategory(types.Select(x => x.Value).ToArray()); select.ShowDialog(); if (select.DialogResult == DialogResult.Cancel) { return false; } name = select.SelectedItem; } else if (bonusNode["name"] != null) { name = bonusNode["name"].InnerText; } else { //TODO some kind of error handling Log.Error(new[] {bonusNode.OuterXml, "Missing pick or name"}); return false; } _strSelectedValue = name; KnowledgeSkill skill = new KnowledgeSkill(_objCharacter, name); bool knowsoft = bonusNode.TryCheckValue("require", "skilljack"); if (knowsoft) { _objCharacter.SkillsSection.KnowsoftSkills.Add(skill); if (_objCharacter.SkillsoftAccess) { _objCharacter.SkillsSection.KnowledgeSkills.Add(skill); } } else { _objCharacter.SkillsSection.KnowledgeSkills.Add(skill); } CreateImprovement(name, objImprovementSource, strSourceName, Improvement.ImprovementType.SkillBase, strUnique, val); CreateImprovement(skill.Id.ToString(), objImprovementSource, strSourceName, Improvement.ImprovementType.SkillKnowledgeForced, strUnique); } if (bonusNode.LocalName == "knowledgeskilllevel") { //Theoretically life modules, right now we just give out free points and let people sort it out themselves. //Going to be fun to do the real way, from a computer science perspective, but i don't feel like using 2 weeks on that now int val = bonusNode["val"] != null ? ValueToInt(bonusNode["val"].InnerText, intRating) : 1; CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.FreeKnowledgeSkills, "", val); } if (bonusNode.LocalName == "knowledgeskillpoints") { CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.FreeKnowledgeSkills, "", ValueToInt(bonusNode.InnerText,Convert.ToInt32(bonusNode.Value))); } if (bonusNode.LocalName == ("skillgrouplevel")) { Log.Info(new object[] {"skillgrouplevel", bonusNode.OuterXml}); String strSkillGroup; int value; if (bonusNode.TryGetField("name", out strSkillGroup) && bonusNode.TryGetField("val", out value)) { CreateImprovement(strSkillGroup, objImprovementSource, strSourceName, Improvement.ImprovementType.SkillGroupLevel, "", value); } else { Log.Error(new object[] {"skillgrouplevel", bonusNode.OuterXml}); } } // Change the maximum number of BP that can be spent on Nuyen. if (bonusNode.LocalName == ("nuyenmaxbp")) { Log.Info("nuyenmaxbp"); Log.Info("nuyenmaxbp = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.NuyenMaxBP, "", ValueToInt(bonusNode.InnerText, intRating)); } // Apply a bonus/penalty to physical limit. if (bonusNode.LocalName == ("physicallimit")) { Log.Info("physicallimit"); Log.Info("physicallimit = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("Physical", objImprovementSource, strSourceName, Improvement.ImprovementType.PhysicalLimit, strFriendlyName, ValueToInt(bonusNode.InnerText, intRating)); } // Apply a bonus/penalty to mental limit. if (bonusNode.LocalName == ("mentallimit")) { Log.Info("mentallimit"); Log.Info("mentallimit = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("Mental", objImprovementSource, strSourceName, Improvement.ImprovementType.MentalLimit, strFriendlyName, ValueToInt(bonusNode.InnerText, intRating)); } // Apply a bonus/penalty to social limit. if (bonusNode.LocalName == ("sociallimit")) { Log.Info("sociallimit"); Log.Info("sociallimit = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("Social", objImprovementSource, strSourceName, Improvement.ImprovementType.SocialLimit, strFriendlyName, ValueToInt(bonusNode.InnerText, intRating)); } // Change the amount of Nuyen the character has at creation time (this can put the character over the amount they're normally allowed). if (bonusNode.LocalName == ("nuyenamt")) { Log.Info("nuyenamt"); Log.Info("nuyenamt = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.Nuyen, strUnique, ValueToInt(bonusNode.InnerText, intRating)); } // Improve Condition Monitors. if (bonusNode.LocalName == ("conditionmonitor")) { Log.Info("conditionmonitor"); Log.Info("conditionmonitor = " + bonusNode.OuterXml.ToString()); // Physical Condition. if (bonusNode.InnerXml.Contains("physical")) { Log.Info("Calling CreateImprovement for Physical"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.PhysicalCM, strUnique, ValueToInt(bonusNode["physical"].InnerText, intRating)); } // Stun Condition. if (bonusNode.InnerXml.Contains("stun")) { Log.Info("Calling CreateImprovement for Stun"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.StunCM, strUnique, ValueToInt(bonusNode["stun"].InnerText, intRating)); } // Condition Monitor Threshold. if (NodeExists(bonusNode, "threshold")) { string strUseUnique = strUnique; if (bonusNode["threshold"].Attributes["precedence"] != null) strUseUnique = "precedence" + bonusNode["threshold"].Attributes["precedence"].InnerText; Log.Info("Calling CreateImprovement for Threshold"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.CMThreshold, strUseUnique, ValueToInt(bonusNode["threshold"].InnerText, intRating)); } // Condition Monitor Threshold Offset. (Additioal boxes appear before the FIRST Condition Monitor penalty) if (NodeExists(bonusNode, "thresholdoffset")) { string strUseUnique = strUnique; if (bonusNode["thresholdoffset"].Attributes["precedence"] != null) strUseUnique = "precedence" + bonusNode["thresholdoffset"].Attributes["precedence"].InnerText; Log.Info("Calling CreateImprovement for Threshold Offset"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.CMThresholdOffset, strUseUnique, ValueToInt(bonusNode["thresholdoffset"].InnerText, intRating)); } // Condition Monitor Overflow. if (bonusNode.InnerXml.Contains("overflow")) { Log.Info("Calling CreateImprovement for Overflow"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.CMOverflow, strUnique, ValueToInt(bonusNode["overflow"].InnerText, intRating)); } } // Improve Living Personal Attributes. if (bonusNode.LocalName == ("livingpersona")) { Log.Info("livingpersona"); Log.Info("livingpersona = " + bonusNode.OuterXml.ToString()); // Response. if (bonusNode.InnerXml.Contains("response")) { Log.Info("Calling CreateImprovement for response"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.LivingPersonaResponse, strUnique, ValueToInt(bonusNode["response"].InnerText, intRating)); } // Signal. if (bonusNode.InnerXml.Contains("signal")) { Log.Info("Calling CreateImprovement for signal"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.LivingPersonaSignal, strUnique, ValueToInt(bonusNode["signal"].InnerText, intRating)); } // Firewall. if (bonusNode.InnerXml.Contains("firewall")) { Log.Info("Calling CreateImprovement for firewall"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.LivingPersonaFirewall, strUnique, ValueToInt(bonusNode["firewall"].InnerText, intRating)); } // System. if (bonusNode.InnerXml.Contains("system")) { Log.Info("Calling CreateImprovement for system"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.LivingPersonaSystem, strUnique, ValueToInt(bonusNode["system"].InnerText, intRating)); } // Biofeedback Filter. if (bonusNode.InnerXml.Contains("biofeedback")) { Log.Info("Calling CreateImprovement for biofeedback"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.LivingPersonaBiofeedback, strUnique, ValueToInt(bonusNode["biofeedback"].InnerText, intRating)); } } // The Improvement adjusts a specific Skill. if (bonusNode.LocalName == ("specificskill")) { Log.Info("specificskill"); Log.Info("specificskill = " + bonusNode.OuterXml.ToString()); bool blnAddToRating = false; if (bonusNode["applytorating"] != null) { if (bonusNode["applytorating"].InnerText == "yes") blnAddToRating = true; } string strUseUnique = strUnique; if (bonusNode.Attributes["precedence"] != null) strUseUnique = "precedence" + bonusNode.Attributes["precedence"].InnerText; // Record the improvement. if (bonusNode["bonus"] != null) { Log.Info("Calling CreateImprovement for bonus"); CreateImprovement(bonusNode["name"].InnerText, objImprovementSource, strSourceName, Improvement.ImprovementType.Skill, strUseUnique, ValueToInt(bonusNode["bonus"].InnerXml, intRating), 1, 0, 0, 0, 0, "", blnAddToRating); } if (bonusNode["max"] != null) { Log.Info("Calling CreateImprovement for max"); CreateImprovement(bonusNode["name"].InnerText, objImprovementSource, strSourceName, Improvement.ImprovementType.Skill, strUseUnique, 0, 1, 0, ValueToInt(bonusNode["max"].InnerText, intRating), 0, 0, "", blnAddToRating); } } if (bonusNode.LocalName == "reflexrecorderoptimization") { CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.ReflexRecorderOptimization, strUnique); } // The Improvement adds a martial art if (bonusNode.LocalName == ("martialart")) { Log.Info("martialart"); Log.Info("martialart = " + bonusNode.OuterXml.ToString()); XmlDocument _objXmlDocument = XmlManager.Instance.Load("martialarts.xml"); XmlNode objXmlArt = _objXmlDocument.SelectSingleNode("/chummer/martialarts/martialart[name = \"" + bonusNode.InnerText + "\"]"); TreeNode objNode = new TreeNode(); MartialArt objMartialArt = new MartialArt(_objCharacter); objMartialArt.Create(objXmlArt, objNode, _objCharacter); objMartialArt.IsQuality = true; _objCharacter.MartialArts.Add(objMartialArt); } // The Improvement adds a limit modifier if (bonusNode.LocalName == ("limitmodifier")) { Log.Info("limitmodifier"); Log.Info("limitmodifier = " + bonusNode.OuterXml.ToString()); LimitModifier objLimitMod = new LimitModifier(_objCharacter); string strLimit = bonusNode["limit"].InnerText; string strBonus = bonusNode["value"].InnerText; if (strBonus == "Rating") { strBonus = intRating.ToString(); } string strCondition = ""; try { strCondition = bonusNode["condition"].InnerText; } catch { } int intBonus = 0; if (strBonus == "Rating") intBonus = intRating; else intBonus = Convert.ToInt32(strBonus); string strName = strFriendlyName; TreeNode nodTemp = new TreeNode(); Log.Info("Calling CreateImprovement"); CreateImprovement(strLimit, objImprovementSource, strSourceName, Improvement.ImprovementType.LimitModifier, strFriendlyName, intBonus, 0, 0, 0, 0, 0, strCondition); } // The Improvement adjusts a Skill Category. if (bonusNode.LocalName == ("skillcategory")) { Log.Info("skillcategory"); Log.Info("skillcategory = " + bonusNode.OuterXml.ToString()); bool blnAddToRating = false; if (bonusNode["applytorating"] != null) { if (bonusNode["applytorating"].InnerText == "yes") blnAddToRating = true; } if (bonusNode.InnerXml.Contains("exclude")) { Log.Info("Calling CreateImprovement - exclude"); CreateImprovement(bonusNode["name"].InnerText, objImprovementSource, strSourceName, Improvement.ImprovementType.SkillCategory, strUnique, ValueToInt(bonusNode["bonus"].InnerXml, intRating), 1, 0, 0, 0, 0, bonusNode["exclude"].InnerText, blnAddToRating); } else { Log.Info("Calling CreateImprovement"); CreateImprovement(bonusNode["name"].InnerText, objImprovementSource, strSourceName, Improvement.ImprovementType.SkillCategory, strUnique, ValueToInt(bonusNode["bonus"].InnerXml, intRating), 1, 0, 0, 0, 0, "", blnAddToRating); } } // The Improvement adjusts a Skill Group. if (bonusNode.LocalName == ("skillgroup")) { Log.Info("skillgroup"); Log.Info("skillgroup = " + bonusNode.OuterXml.ToString()); bool blnAddToRating = false; if (bonusNode["applytorating"] != null) { if (bonusNode["applytorating"].InnerText == "yes") blnAddToRating = true; } if (bonusNode.InnerXml.Contains("exclude")) { Log.Info("Calling CreateImprovement - exclude"); CreateImprovement(bonusNode["name"].InnerText, objImprovementSource, strSourceName, Improvement.ImprovementType.SkillGroup, strUnique, ValueToInt(bonusNode["bonus"].InnerXml, intRating), 1, 0, 0, 0, 0, bonusNode["exclude"].InnerText, blnAddToRating); } else { Log.Info("Calling CreateImprovement"); CreateImprovement(bonusNode["name"].InnerText, objImprovementSource, strSourceName, Improvement.ImprovementType.SkillGroup, strUnique, ValueToInt(bonusNode["bonus"].InnerXml, intRating), 1, 0, 0, 0, 0, "", blnAddToRating); } } // The Improvement adjust Skills with the given CharacterAttribute. if (bonusNode.LocalName == ("skillattribute")) { Log.Info("skillattribute"); Log.Info("skillattribute = " + bonusNode.OuterXml.ToString()); string strUseUnique = strUnique; if (bonusNode["name"].Attributes["precedence"] != null) strUseUnique = "precedence" + bonusNode["name"].Attributes["precedence"].InnerText; bool blnAddToRating = false; if (bonusNode["applytorating"] != null) { if (bonusNode["applytorating"].InnerText == "yes") blnAddToRating = true; } if (bonusNode.InnerXml.Contains("exclude")) { Log.Info("Calling CreateImprovement - exclude"); CreateImprovement(bonusNode["name"].InnerText, objImprovementSource, strSourceName, Improvement.ImprovementType.SkillAttribute, strUseUnique, ValueToInt(bonusNode["bonus"].InnerXml, intRating), 1, 0, 0, 0, 0, bonusNode["exclude"].InnerText, blnAddToRating); } else { Log.Info("Calling CreateImprovement"); CreateImprovement(bonusNode["name"].InnerText, objImprovementSource, strSourceName, Improvement.ImprovementType.SkillAttribute, strUseUnique, ValueToInt(bonusNode["bonus"].InnerXml, intRating), 1, 0, 0, 0, 0, "", blnAddToRating); } } // The Improvement comes from Enhanced Articulation (improves Physical Active Skills linked to a Physical CharacterAttribute). if (bonusNode.LocalName == ("skillarticulation")) { Log.Info("skillarticulation"); Log.Info("skillarticulation = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.EnhancedArticulation, strUnique, ValueToInt(bonusNode["bonus"].InnerText, intRating)); } // Check for Armor modifiers. if (bonusNode.LocalName == ("armor")) { Log.Info("armor"); Log.Info("armor = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); string strUseUnique = strUnique; if (bonusNode.Attributes["precedence"] != null) { strUseUnique = "precedence" + bonusNode.Attributes["precedence"].InnerText; } else if (bonusNode.Attributes["group"] != null) { strUseUnique = "group" + bonusNode.Attributes["group"].InnerText; } CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.Armor, strUseUnique, ValueToInt(bonusNode.InnerText, intRating)); } // Check for Reach modifiers. if (bonusNode.LocalName == ("reach")) { Log.Info("reach"); Log.Info("reach = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.Reach, strUnique, ValueToInt(bonusNode.InnerText, intRating)); } // Check for Unarmed Damage Value modifiers. if (bonusNode.LocalName == ("unarmeddv")) { Log.Info("unarmeddv"); Log.Info("unarmeddv = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.UnarmedDV, strUnique, ValueToInt(bonusNode.InnerText, intRating)); } // Check for Unarmed Damage Value Physical. if (bonusNode.LocalName == ("unarmeddvphysical")) { Log.Info("unarmeddvphysical"); Log.Info("unarmeddvphysical = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.UnarmedDVPhysical, ""); } // Check for Unarmed Armor Penetration. if (bonusNode.LocalName == ("unarmedap")) { Log.Info("unarmedap"); Log.Info("unarmedap = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.UnarmedAP, strUnique, ValueToInt(bonusNode.InnerText, intRating)); } // Check for Initiative modifiers. if (bonusNode.LocalName == ("initiative")) { Log.Info("initiative"); Log.Info("initiative = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.Initiative, strUnique, ValueToInt(bonusNode.InnerText, intRating)); } // Check for Initiative Pass modifiers. Only the highest one ever applies. if (bonusNode.LocalName == ("initiativepass")) { Log.Info("initiativepass"); Log.Info("initiativepass = "******"Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.InitiativePass, "initiativepass", ValueToInt(bonusNode.InnerText, intRating)); } // Check for Initiative Pass modifiers. Only the highest one ever applies. if (bonusNode.LocalName == ("initiativepassadd")) { Log.Info("initiativepassadd"); Log.Info("initiativepassadd = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.InitiativePassAdd, strUnique, ValueToInt(bonusNode.InnerText, intRating)); } // Check for Matrix Initiative modifiers. if (bonusNode.LocalName == ("matrixinitiative")) { Log.Info("matrixinitiative"); Log.Info("matrixinitiative = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.MatrixInitiative, strUnique, ValueToInt(bonusNode.InnerText, intRating)); } // Check for Matrix Initiative Pass modifiers. if (bonusNode.LocalName == ("matrixinitiativepass")) { Log.Info("matrixinitiativepass"); Log.Info("matrixinitiativepass = "******"Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.MatrixInitiativePass, "matrixinitiativepass", ValueToInt(bonusNode.InnerText, intRating)); } // Check for Matrix Initiative Pass modifiers. if (bonusNode.LocalName == ("matrixinitiativepassadd")) { Log.Info("matrixinitiativepassadd"); Log.Info("matrixinitiativepassadd = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.MatrixInitiativePass, strUnique, ValueToInt(bonusNode.InnerText, intRating)); } // Check for Lifestyle cost modifiers. if (bonusNode.LocalName == ("lifestylecost")) { Log.Info("lifestylecost"); Log.Info("lifestylecost = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.LifestyleCost, strUnique, ValueToInt(bonusNode.InnerText, intRating)); } // Check for basic Lifestyle cost modifiers. if (bonusNode.LocalName == ("basiclifestylecost")) { Log.Info("basiclifestylecost"); Log.Info("basiclifestylecost = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.BasicLifestyleCost, strUnique, ValueToInt(bonusNode.InnerText, intRating)); } // Check for Genetech Cost modifiers. if (bonusNode.LocalName == ("genetechcostmultiplier")) { Log.Info("genetechcostmultiplier"); Log.Info("genetechcostmultiplier = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.GenetechCostMultiplier, strUnique, ValueToInt(bonusNode.InnerText, intRating)); } // Check for Genetech: Transgenics Cost modifiers. if (bonusNode.LocalName == ("transgenicsgenetechcost")) { Log.Info("transgenicsgenetechcost"); Log.Info("transgenicsgenetechcost = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.TransgenicsBiowareCost, strUnique, ValueToInt(bonusNode.InnerText, intRating)); } // Check for Basic Bioware Essence Cost modifiers. if (bonusNode.LocalName == ("basicbiowareessmultiplier")) { Log.Info("basicbiowareessmultiplier"); Log.Info("basicbiowareessmultiplier = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.BasicBiowareEssCost, strUnique, ValueToInt(bonusNode.InnerText, intRating)); } // Check for Bioware Essence Cost modifiers. if (bonusNode.LocalName == ("biowareessmultiplier")) { Log.Info("biowareessmultiplier"); Log.Info("biowareessmultiplier = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.BiowareEssCost, strUnique, ValueToInt(bonusNode.InnerText, intRating)); } // Check for Cybeware Essence Cost modifiers. if (bonusNode.LocalName == ("cyberwareessmultiplier")) { Log.Info("cyberwareessmultiplier"); Log.Info("cyberwareessmultiplier = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.CyberwareEssCost, strUnique, ValueToInt(bonusNode.InnerText, intRating)); } // Check for Uneducated modifiers. if (bonusNode.LocalName == ("uneducated")) { Log.Info("uneducated"); Log.Info("uneducated = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.Uneducated, strUnique); _objCharacter.SkillsSection.Uneducated = true; } // Check for College Education modifiers. if (bonusNode.LocalName == ("collegeeducation")) { Log.Info("collegeeducation"); Log.Info("collegeeducation = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.CollegeEducation, strUnique); _objCharacter.SkillsSection.CollegeEducation = true; } // Check for Jack Of All Trades modifiers. if (bonusNode.LocalName == ("jackofalltrades")) { Log.Info("jackofalltrades"); Log.Info("jackofalltrades = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.JackOfAllTrades, strUnique); _objCharacter.SkillsSection.JackOfAllTrades = true; } // Check for Prototype Transhuman modifiers. if (bonusNode.LocalName == ("prototypetranshuman")) { Log.Info("prototypetranshuman"); Log.Info("prototypetranshuman = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.PrototypeTranshuman, strUnique); _objCharacter.PrototypeTranshuman = Convert.ToDecimal(bonusNode.InnerText); } // Check for Uncouth modifiers. if (bonusNode.LocalName == ("uncouth")) { Log.Info("uncouth"); Log.Info("uncouth = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.Uncouth, strUnique); _objCharacter.SkillsSection.Uncouth = true; } // Check for Friends In High Places modifiers. if (bonusNode.LocalName == ("friendsinhighplaces")) { Log.Info("friendsinhighplaces"); Log.Info("friendsinhighplaces = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.FriendsInHighPlaces, strUnique); _objCharacter.FriendsInHighPlaces = true; } // Check for School of Hard Knocks modifiers. if (bonusNode.LocalName == ("schoolofhardknocks")) { Log.Info("schoolofhardknocks"); Log.Info("schoolofhardknocks = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.SchoolOfHardKnocks, strUnique); _objCharacter.SkillsSection.SchoolOfHardKnocks = true; } // Check for ExCon modifiers. if (bonusNode.LocalName == ("excon")) { Log.Info("ExCon"); Log.Info("ExCon = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.ExCon, strUnique); _objCharacter.ExCon = true; } // Check for TrustFund modifiers. if (bonusNode.LocalName == ("trustfund")) { Log.Info("TrustFund"); Log.Info("TrustFund = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.TrustFund, strUnique, ValueToInt(bonusNode.InnerText, intRating)); _objCharacter.TrustFund = ValueToInt(bonusNode.InnerText, intRating); } // Check for Tech School modifiers. if (bonusNode.LocalName == ("techschool")) { Log.Info("techschool"); Log.Info("techschool = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.TechSchool, strUnique); _objCharacter.SkillsSection.TechSchool = true; } // Check for MadeMan modifiers. if (bonusNode.LocalName == ("mademan")) { Log.Info("MadeMan"); Log.Info("MadeMan = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.MadeMan, strUnique); _objCharacter.MadeMan = true; } // Check for Linguist modifiers. if (bonusNode.LocalName == ("linguist")) { Log.Info("Linguist"); Log.Info("Linguist = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.Linguist, strUnique); _objCharacter.SkillsSection.Linguist = true; } // Check for LightningReflexes modifiers. if (bonusNode.LocalName == ("lightningreflexes")) { Log.Info("LightningReflexes"); Log.Info("LightningReflexes = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.LightningReflexes, strUnique); _objCharacter.LightningReflexes = true; } // Check for Fame modifiers. if (bonusNode.LocalName == ("fame")) { Log.Info("Fame"); Log.Info("Fame = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.Fame, strUnique); _objCharacter.Fame = true; } // Check for BornRich modifiers. if (bonusNode.LocalName == ("bornrich")) { Log.Info("BornRich"); Log.Info("BornRich = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.BornRich, strUnique); _objCharacter.BornRich = true; } // Check for Erased modifiers. if (bonusNode.LocalName == ("erased")) { Log.Info("Erased"); Log.Info("Erased = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.Erased, strUnique); _objCharacter.Erased = true; } // Check for Erased modifiers. if (bonusNode.LocalName == ("overclocker")) { Log.Info("OverClocker"); Log.Info("Overclocker = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.Overclocker, strUnique); _objCharacter.Overclocker = true; } // Check for Restricted Gear modifiers. if (bonusNode.LocalName == ("restrictedgear")) { Log.Info("restrictedgear"); Log.Info("restrictedgear = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.RestrictedGear, strUnique); _objCharacter.RestrictedGear = true; } // Check for Adept Linguistics. if (bonusNode.LocalName == ("adeptlinguistics")) { Log.Info("adeptlinguistics"); Log.Info("adeptlinguistics = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.AdeptLinguistics, strUnique, 1); } // Check for Weapon Category DV modifiers. if (bonusNode.LocalName == ("weaponcategorydv")) { //TODO: FIX THIS /* * I feel like talking a little bit about improvementmanager at * this point. It is an intresting class. First of all, it * manages to throw out everything we ever learned about OOP * and create a class based on functional programming. * * That is true, it is a class, based on manipulating a single * list on another class. * * But atleast there is a reference to it somewhere right? * * No, you create one wherever you need it, meaning there are * tens of instances of this class, all operating on the same * list * * After that, it is just plain stupid. * If you have an list of xmlNodes and some might be the same * it checks if a specific node exists (sometimes even by text * comparison on .OuterXml) and then runs specific code for * each. If it is there multiple times either of those 2 things * happen. * * 1. Sad, nothing we can do, guess you have to survive * 2. Lets create a foreach in that specific part of the code * * F**k ImprovementManager, kill it with fire, burn the ashes * and feed what remains to a dragon that eats unholy * abominations */ Log.Info("weaponcategorydv"); Log.Info("weaponcategorydv = " + bonusNode.OuterXml.ToString()); XmlNodeList objXmlCategoryList = bonusNode.SelectNodes("weaponcategorydv"); XmlNode nodWeapon = bonusNode; if (NodeExists(nodWeapon, "selectskill")) { // Display the Select Skill window and record which Skill was selected. frmSelectItem frmPickCategory = new frmSelectItem(); List<ListItem> lstGeneralItems = new List<ListItem>(); ListItem liBlades = new ListItem(); liBlades.Name = "Blades"; liBlades.Value = "Blades"; ListItem liClubs = new ListItem(); liClubs.Name = "Clubs"; liClubs.Value = "Clubs"; ListItem liUnarmed = new ListItem(); liUnarmed.Name = "Unarmed"; liUnarmed.Value = "Unarmed"; ListItem liAstral = new ListItem(); liAstral.Name = "Astral Combat"; liAstral.Value = "Astral Combat"; ListItem liExotic = new ListItem(); liExotic.Name = "Exotic Melee Weapons"; liExotic.Value = "Exotic Melee Weapons"; lstGeneralItems.Add(liAstral); lstGeneralItems.Add(liBlades); lstGeneralItems.Add(liClubs); lstGeneralItems.Add(liExotic); lstGeneralItems.Add(liUnarmed); frmPickCategory.GeneralItems = lstGeneralItems; if (strFriendlyName != "") frmPickCategory.Description = LanguageManager.Instance.GetString("String_Improvement_SelectSkillNamed").Replace("{0}", strFriendlyName); else frmPickCategory.Description = LanguageManager.Instance.GetString("Title_SelectWeaponCategory"); Log.Info("_strForcedValue = " + _strForcedValue); if (_strForcedValue.StartsWith("Adept:") || _strForcedValue.StartsWith("Magician:")) _strForcedValue = ""; if (_strForcedValue != "") { frmPickCategory.Opacity = 0; } frmPickCategory.ShowDialog(); // Make sure the dialogue window was not canceled. if (frmPickCategory.DialogResult == DialogResult.Cancel) { Rollback(); _strForcedValue = ""; _strLimitSelection = ""; return false; } _strSelectedValue = frmPickCategory.SelectedItem; Log.Info("strSelected = " + _strSelectedValue); foreach (Power objPower in _objCharacter.Powers) { if (objPower.InternalId == strSourceName) { objPower.Extra = _strSelectedValue; } } Log.Info("Calling CreateImprovement"); CreateImprovement(_strSelectedValue, objImprovementSource, strSourceName, Improvement.ImprovementType.WeaponCategoryDV, strUnique, ValueToInt(nodWeapon["bonus"].InnerXml, intRating)); } else { // Run through each of the Skill Groups since there may be more than one affected. foreach (XmlNode objXmlCategory in objXmlCategoryList) { Log.Info("Calling CreateImprovement"); CreateImprovement(objXmlCategory["name"].InnerText, objImprovementSource, strSourceName, Improvement.ImprovementType.WeaponCategoryDV, strUnique, ValueToInt(objXmlCategory["bonus"].InnerXml, intRating)); } } } // Check for Mentor Spirit bonuses. if (bonusNode.LocalName == ("selectmentorspirit")) { Log.Info("selectmentorspirit"); Log.Info("selectmentorspirit = " + bonusNode.OuterXml.ToString()); frmSelectMentorSpirit frmPickMentorSpirit = new frmSelectMentorSpirit(_objCharacter); frmPickMentorSpirit.ShowDialog(); // Make sure the dialogue window was not canceled. if (frmPickMentorSpirit.DialogResult == DialogResult.Cancel) { Rollback(); _strForcedValue = ""; _strLimitSelection = ""; return false; } _strSelectedValue = frmPickMentorSpirit.SelectedMentor; string strHoldValue = _strSelectedValue; if (blnConcatSelectedValue) strSourceName += " (" + _strSelectedValue + ")"; Log.Info("_strSelectedValue = " + _strSelectedValue); Log.Info("strSourceName = " + strSourceName); if (frmPickMentorSpirit.BonusNode != null) { if (!CreateImprovements(objImprovementSource, strSourceName, frmPickMentorSpirit.BonusNode, blnConcatSelectedValue, intRating, strFriendlyName)) { Rollback(); _strForcedValue = ""; _strLimitSelection = ""; return false; } } if (frmPickMentorSpirit.Choice1BonusNode != null) { Log.Info("frmPickMentorSpirit.Choice1BonusNode = " + frmPickMentorSpirit.Choice1BonusNode.OuterXml.ToString()); string strForce = _strForcedValue; if (!frmPickMentorSpirit.Choice1.StartsWith("Adept:") && !frmPickMentorSpirit.Choice1.StartsWith("Magician:")) _strForcedValue = frmPickMentorSpirit.Choice1; else _strForcedValue = ""; Log.Info("Calling CreateImprovement"); bool blnSuccess = CreateImprovements(objImprovementSource, strSourceName, frmPickMentorSpirit.Choice1BonusNode, blnConcatSelectedValue, intRating, strFriendlyName); if (!blnSuccess) { Rollback(); _strForcedValue = ""; _strLimitSelection = ""; return false; } _strForcedValue = strForce; _objCharacter.Improvements.Last().Notes = frmPickMentorSpirit.Choice1; } if (frmPickMentorSpirit.Choice2BonusNode != null) { Log.Info("frmPickMentorSpirit.Choice2BonusNode = " + frmPickMentorSpirit.Choice2BonusNode.OuterXml.ToString()); string strForce = _strForcedValue; if (!frmPickMentorSpirit.Choice2.StartsWith("Adept:") && !frmPickMentorSpirit.Choice2.StartsWith("Magician:")) _strForcedValue = frmPickMentorSpirit.Choice2; else _strForcedValue = ""; Log.Info("Calling CreateImprovement"); bool blnSuccess = CreateImprovements(objImprovementSource, strSourceName, frmPickMentorSpirit.Choice2BonusNode, blnConcatSelectedValue, intRating, strFriendlyName); if (!blnSuccess) { Rollback(); _strForcedValue = ""; _strLimitSelection = ""; return false; } _strForcedValue = strForce; _objCharacter.Improvements.Last().Notes = frmPickMentorSpirit.Choice2; } _strSelectedValue = strHoldValue; Log.Info("_strSelectedValue = " + _strSelectedValue); Log.Info("_strForcedValue = " + _strForcedValue); } // Check for Paragon bonuses. if (bonusNode.LocalName == ("selectparagon")) { Log.Info("selectparagon"); Log.Info("selectparagon = " + bonusNode.OuterXml.ToString()); frmSelectMentorSpirit frmPickMentorSpirit = new frmSelectMentorSpirit(_objCharacter); frmPickMentorSpirit.XmlFile = "paragons.xml"; frmPickMentorSpirit.ShowDialog(); // Make sure the dialogue window was not canceled. if (frmPickMentorSpirit.DialogResult == DialogResult.Cancel) { Rollback(); _strForcedValue = ""; _strLimitSelection = ""; return false; } _strSelectedValue = frmPickMentorSpirit.SelectedMentor; string strHoldValue = _strSelectedValue; if (blnConcatSelectedValue) strSourceName += " (" + _strSelectedValue + ")"; if (frmPickMentorSpirit.BonusNode != null) { bool blnSuccess = CreateImprovements(objImprovementSource, strSourceName, frmPickMentorSpirit.BonusNode, blnConcatSelectedValue, intRating, strFriendlyName); if (!blnSuccess) { Rollback(); _strForcedValue = ""; _strLimitSelection = ""; return false; } } if (frmPickMentorSpirit.Choice1BonusNode != null) { string strForce = _strForcedValue; _strForcedValue = frmPickMentorSpirit.Choice1; bool blnSuccess = CreateImprovements(objImprovementSource, strSourceName, frmPickMentorSpirit.Choice1BonusNode, blnConcatSelectedValue, intRating, strFriendlyName); if (!blnSuccess) { Rollback(); _strForcedValue = ""; _strLimitSelection = ""; return false; } _strForcedValue = strForce; _objCharacter.Improvements.Last().Notes = frmPickMentorSpirit.Choice1; } if (frmPickMentorSpirit.Choice2BonusNode != null) { string strForce = _strForcedValue; _strForcedValue = frmPickMentorSpirit.Choice2; bool blnSuccess = CreateImprovements(objImprovementSource, strSourceName, frmPickMentorSpirit.Choice2BonusNode, blnConcatSelectedValue, intRating, strFriendlyName); if (!blnSuccess) { Rollback(); _strForcedValue = ""; _strLimitSelection = ""; return false; } _strForcedValue = strForce; _objCharacter.Improvements.Last().Notes = frmPickMentorSpirit.Choice2; } _strSelectedValue = strHoldValue; } // Check for Smartlink bonus. if (bonusNode.LocalName == ("smartlink")) { Log.Info("smartlink"); Log.Info("smartlink = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.Smartlink, "smartlink"); } // Check for Adapsin bonus. if (bonusNode.LocalName == ("adapsin")) { Log.Info("adapsin"); Log.Info("adapsin = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.Adapsin, "adapsin"); } // Check for SoftWeave bonus. if (bonusNode.LocalName == ("softweave")) { Log.Info("softweave"); Log.Info("softweave = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.SoftWeave, "softweave"); } // Check for Sensitive System. if (bonusNode.LocalName == ("sensitivesystem")) { Log.Info("sensitivesystem"); Log.Info("sensitivesystem = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.SensitiveSystem, "sensitivesystem"); } // Check for Movement Percent. if (bonusNode.LocalName == ("movementpercent")) { Log.Info("movementpercent"); Log.Info("movementpercent = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.MovementPercent, "", ValueToInt(bonusNode.InnerText, intRating)); } // Check for Swim Percent. if (bonusNode.LocalName == ("swimpercent")) { Log.Info("swimpercent"); Log.Info("swimpercent = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.SwimPercent, "", ValueToInt(bonusNode.InnerText, intRating)); } // Check for Fly Percent. if (bonusNode.LocalName == ("flypercent")) { Log.Info("flypercent"); Log.Info("flypercent = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.FlyPercent, "", ValueToInt(bonusNode.InnerText, intRating)); } // Check for Fly Speed. if (bonusNode.LocalName == ("flyspeed")) { Log.Info("flyspeed"); Log.Info("flyspeed = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.FlySpeed, "", ValueToInt(bonusNode.InnerText, intRating)); } // Check for free Positive Qualities. if (bonusNode.LocalName == ("freepositivequalities")) { Log.Info("freepositivequalities"); Log.Info("freepositivequalities = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.FreePositiveQualities, "", ValueToInt(bonusNode.InnerText, intRating)); } // Check for free Negative Qualities. if (bonusNode.LocalName == ("freenegativequalities")) { Log.Info("freenegativequalities"); Log.Info("freenegativequalities = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.FreeNegativeQualities, "", ValueToInt(bonusNode.InnerText, intRating)); } // Check for Select Side. if (bonusNode.LocalName == ("selectside")) { Log.Info("selectside"); Log.Info("selectside = " + bonusNode.OuterXml.ToString()); frmSelectSide frmPickSide = new frmSelectSide(); frmPickSide.Description = LanguageManager.Instance.GetString("Label_SelectSide").Replace("{0}", strFriendlyName); if (_strForcedValue != "") frmPickSide.ForceValue(_strForcedValue); else frmPickSide.ShowDialog(); // Make sure the dialogue window was not canceled. if (frmPickSide.DialogResult == DialogResult.Cancel) { Rollback(); _strForcedValue = ""; _strLimitSelection = ""; return false; } _strSelectedValue = frmPickSide.SelectedSide; Log.Info("_strSelectedValue = " + _strSelectedValue); } // Check for Free Spirit Power Points. if (bonusNode.LocalName == ("freespiritpowerpoints")) { Log.Info("freespiritpowerpoints"); Log.Info("freespiritpowerpoints = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.FreeSpiritPowerPoints, "", ValueToInt(bonusNode.InnerText, intRating)); } // Check for Adept Power Points. if (bonusNode.LocalName == ("adeptpowerpoints")) { Log.Info("adeptpowerpoints"); Log.Info("adeptpowerpoints = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.AdeptPowerPoints, "", ValueToInt(bonusNode.InnerText, intRating)); } // Check for Adept Powers if (bonusNode.LocalName == ("specificpower")) { //TODO: Probably broken Log.Info("specificpower"); Log.Info("specificpower = " + bonusNode.OuterXml.ToString()); // If the character isn't an adept or mystic adept, skip the rest of this. if (_objCharacter.AdeptEnabled) { string strSelection = ""; _strForcedValue = ""; Log.Info("objXmlSpecificPower = " + bonusNode.OuterXml.ToString()); string strPowerName = bonusNode["name"].InnerText; int intLevels = 0; if (bonusNode["val"] != null) intLevels = Convert.ToInt32(bonusNode["val"].InnerText); bool blnFree = false; if (bonusNode["free"] != null) blnFree = (bonusNode["free"].InnerText == "yes"); string strPowerNameLimit = strPowerName; if (bonusNode["selectlimit"] != null) { Log.Info("selectlimit = " + bonusNode["selectlimit"].OuterXml.ToString()); _strForcedValue = ""; // Display the Select Limit window and record which Limit was selected. frmSelectLimit frmPickLimit = new frmSelectLimit(); if (strFriendlyName != "") frmPickLimit.Description = LanguageManager.Instance.GetString("String_Improvement_SelectLimitNamed") .Replace("{0}", strFriendlyName); else frmPickLimit.Description = LanguageManager.Instance.GetString("String_Improvement_SelectLimit"); if (bonusNode["selectlimit"].InnerXml.Contains("<limit>")) { List<string> strValue = new List<string>(); foreach (XmlNode objXmlAttribute in bonusNode["selectlimit"].SelectNodes("limit")) strValue.Add(objXmlAttribute.InnerText); frmPickLimit.LimitToList(strValue); } if (bonusNode["selectlimit"].InnerXml.Contains("<excludelimit>")) { List<string> strValue = new List<string>(); foreach (XmlNode objXmlAttribute in bonusNode["selectlimit"].SelectNodes("excludelimit")) strValue.Add(objXmlAttribute.InnerText); frmPickLimit.RemoveFromList(strValue); } // Check to see if there is only one possible selection because of _strLimitSelection. if (_strForcedValue != "") _strLimitSelection = _strForcedValue; Log.Info("_strForcedValue = " + _strForcedValue); Log.Info("_strLimitSelection = " + _strLimitSelection); if (_strLimitSelection != "") { frmPickLimit.SingleLimit(_strLimitSelection); frmPickLimit.Opacity = 0; } frmPickLimit.ShowDialog(); // Make sure the dialogue window was not canceled. if (frmPickLimit.DialogResult == DialogResult.Cancel) { Rollback(); _strForcedValue = ""; _strLimitSelection = ""; return false; } _strSelectedValue = frmPickLimit.SelectedLimit; strSelection = _strSelectedValue; _strForcedValue = _strSelectedValue; Log.Info("_strForcedValue = " + _strForcedValue); Log.Info("_strLimitSelection = " + _strLimitSelection); } if (bonusNode["selectskill"] != null) { Log.Info("selectskill = " + bonusNode["selectskill"].OuterXml.ToString()); XmlNode nodSkill = bonusNode; // Display the Select Skill window and record which Skill was selected. frmSelectSkill frmPickSkill = new frmSelectSkill(_objCharacter); if (strFriendlyName != "") frmPickSkill.Description = LanguageManager.Instance.GetString("String_Improvement_SelectSkillNamed") .Replace("{0}", strFriendlyName); else frmPickSkill.Description = LanguageManager.Instance.GetString("String_Improvement_SelectSkill"); if (nodSkill.SelectSingleNode("selectskill").OuterXml.Contains("skillgroup")) frmPickSkill.OnlySkillGroup = nodSkill.SelectSingleNode("selectskill").Attributes["skillgroup"].InnerText; else if (nodSkill.SelectSingleNode("selectskill").OuterXml.Contains("skillcategory")) frmPickSkill.OnlyCategory = nodSkill.SelectSingleNode("selectskill").Attributes["skillcategory"].InnerText; else if (nodSkill.SelectSingleNode("selectskill").OuterXml.Contains("excludecategory")) frmPickSkill.ExcludeCategory = nodSkill.SelectSingleNode("selectskill").Attributes["excludecategory"].InnerText; else if (nodSkill.SelectSingleNode("selectskill").OuterXml.Contains("limittoskill")) frmPickSkill.LimitToSkill = nodSkill.SelectSingleNode("selectskill").Attributes["limittoskill"].InnerText; if (_strForcedValue.StartsWith("Adept:") || _strForcedValue.StartsWith("Magician:")) _strForcedValue = ""; Log.Info("_strForcedValue = " + _strForcedValue); Log.Info("_strLimitSelection = " + _strLimitSelection); if (_strForcedValue != "") { frmPickSkill.OnlySkill = _strForcedValue; frmPickSkill.Opacity = 0; } frmPickSkill.ShowDialog(); // Make sure the dialogue window was not canceled. if (frmPickSkill.DialogResult == DialogResult.Cancel) { Rollback(); _strForcedValue = ""; _strLimitSelection = ""; return false; } _strSelectedValue = frmPickSkill.SelectedSkill; _strForcedValue = _strSelectedValue; strSelection = _strSelectedValue; Log.Info("_strForcedValue = " + _strForcedValue); Log.Info("_strSelectedValue = " + _strSelectedValue); Log.Info("strSelection = " + strSelection); } if (bonusNode["selecttext"] != null) { Log.Info("selecttext = " + bonusNode["selecttext"].OuterXml.ToString()); frmSelectText frmPickText = new frmSelectText(); if (_objCharacter.Pushtext.Count > 0) { strSelection = _objCharacter.Pushtext.Pop(); } else { frmPickText.Description = LanguageManager.Instance.GetString("String_Improvement_SelectText") .Replace("{0}", strFriendlyName); Log.Info("_strForcedValue = " + _strForcedValue); Log.Info("_strLimitSelection = " + _strLimitSelection); if (_strLimitSelection != "") { frmPickText.SelectedValue = _strLimitSelection; frmPickText.Opacity = 0; } frmPickText.ShowDialog(); // Make sure the dialogue window was not canceled. if (frmPickText.DialogResult == DialogResult.Cancel) { Rollback(); _strForcedValue = ""; _strLimitSelection = ""; return false; } strSelection = frmPickText.SelectedValue; _strLimitSelection = strSelection; } Log.Info("_strLimitSelection = " + _strLimitSelection); Log.Info("strSelection = " + strSelection); } if (bonusNode["specificattribute"] != null) { Log.Info("specificattribute = " + bonusNode["specificattribute"].OuterXml.ToString()); strSelection = bonusNode["specificattribute"]["name"].InnerText.ToString(); Log.Info( "strSelection = " + strSelection); } if (bonusNode["selectattribute"] != null) { Log.Info("selectattribute = " + bonusNode["selectattribute"].OuterXml.ToString()); XmlNode nodSkill = bonusNode; if (_strForcedValue.StartsWith("Adept")) _strForcedValue = ""; // Display the Select CharacterAttribute window and record which CharacterAttribute was selected. frmSelectAttribute frmPickAttribute = new frmSelectAttribute(); if (strFriendlyName != "") frmPickAttribute.Description = LanguageManager.Instance.GetString("String_Improvement_SelectAttributeNamed").Replace("{0}", strFriendlyName); else frmPickAttribute.Description = LanguageManager.Instance.GetString("String_Improvement_SelectAttribute"); // Add MAG and/or RES to the list of Attributes if they are enabled on the form. if (_objCharacter.MAGEnabled) frmPickAttribute.AddMAG(); if (_objCharacter.RESEnabled) frmPickAttribute.AddRES(); if (nodSkill["selectattribute"].InnerXml.Contains("<attribute>")) { List<string> strValue = new List<string>(); foreach (XmlNode objXmlAttribute in nodSkill["selectattribute"].SelectNodes("attribute")) strValue.Add(objXmlAttribute.InnerText); frmPickAttribute.LimitToList(strValue); } if (nodSkill["selectattribute"].InnerXml.Contains("<excludeattribute>")) { List<string> strValue = new List<string>(); foreach (XmlNode objXmlAttribute in nodSkill["selectattribute"].SelectNodes("excludeattribute")) strValue.Add(objXmlAttribute.InnerText); frmPickAttribute.RemoveFromList(strValue); } // Check to see if there is only one possible selection because of _strLimitSelection. if (_strForcedValue != "") _strLimitSelection = _strForcedValue; Log.Info("_strForcedValue = " + _strForcedValue); Log.Info("_strLimitSelection = " + _strLimitSelection); if (_strLimitSelection != "") { frmPickAttribute.SingleAttribute(_strLimitSelection); frmPickAttribute.Opacity = 0; } frmPickAttribute.ShowDialog(); // Make sure the dialogue window was not canceled. if (frmPickAttribute.DialogResult == DialogResult.Cancel) { Rollback(); _strForcedValue = ""; _strLimitSelection = ""; return false; } _strSelectedValue = frmPickAttribute.SelectedAttribute; if (blnConcatSelectedValue) strSourceName += " (" + _strSelectedValue + ")"; strSelection = _strSelectedValue; _strForcedValue = _strSelectedValue; Log.Info("_strSelectedValue = " + _strSelectedValue); Log.Info("strSourceName = " + strSourceName); Log.Info("_strForcedValue = " + _strForcedValue); } // Check if the character already has this power Log.Info("strSelection = " + strSelection); bool blnHasPower = false; Power objPower = new Power(_objCharacter); foreach (Power power in _objCharacter.Powers) { if (power.Name == strPowerNameLimit) { if (power.Extra != "" && power.Extra == strSelection) { blnHasPower = true; objPower = power; } else if (power.Extra == "") { blnHasPower = true; objPower = power; } } } Log.Info("blnHasPower = " + blnHasPower); if (blnHasPower) { // If yes, mark it free or give it free levels if (blnFree) { objPower.Free = true; } else { objPower.FreeLevels += intLevels; if (objPower.Rating < objPower.FreeLevels) objPower.Rating = objPower.FreeLevels; } } else { Log.Info("Adding Power " + strPowerName); // If no, add the power and mark it free or give it free levels objPower = new Power(_objCharacter); _objCharacter.Powers.Add(objPower); // Get the Power information XmlDocument objXmlDocument = new XmlDocument(); objXmlDocument = XmlManager.Instance.Load("powers.xml"); XmlNode objXmlPower = objXmlDocument.SelectSingleNode("/chummer/powers/power[name = \"" + strPowerName + "\"]"); Log.Info("objXmlPower = " + objXmlPower.OuterXml.ToString()); bool blnLevels = false; if (objXmlPower["levels"] != null) blnLevels = (objXmlPower["levels"].InnerText == "yes"); objPower.LevelsEnabled = blnLevels; objPower.Name = strPowerNameLimit; objPower.PointsPerLevel = Convert.ToDecimal(objXmlPower["points"].InnerText, GlobalOptions.Instance.CultureInfo); objPower.Source = objXmlPower["source"].InnerText; objPower.Page = objXmlPower["page"].InnerText; if (strSelection != string.Empty) objPower.Extra = strSelection; if (objXmlPower["doublecost"] != null) objPower.DoubleCost = false; if (blnFree) { objPower.Free = true; } else { objPower.FreeLevels += intLevels; if (objPower.Rating < intLevels) objPower.Rating = objPower.FreeLevels; } if (objXmlPower.InnerXml.Contains("bonus")) { objPower.Bonus = objXmlPower["bonus"]; Log.Info("Calling CreateImprovements"); if ( !CreateImprovements(Improvement.ImprovementSource.Power, objPower.InternalId, objPower.Bonus, false, Convert.ToInt32(objPower.Rating), objPower.DisplayNameShort)) { _objCharacter.Powers.Remove(objPower); } } } _strSelectedValue = ""; _strForcedValue = ""; strSelection = ""; } Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.AdeptPower, ""); } // Select a Power. if (bonusNode.LocalName == ("selectpowers")) { XmlNodeList objXmlPowerList = bonusNode.SelectNodes("selectpower"); foreach (XmlNode objNode in objXmlPowerList) { Log.Info("selectpower"); Log.Info("_strSelectedValue = " + _strSelectedValue); Log.Info("_strForcedValue = " + _strForcedValue); //Gerry: These unfortunately did not work in any case of multiple bonuses // Switched the setting of powerpoints and levels to ADDING them // Remove resetting powerpoints. bool blnExistingPower = false; foreach (Power objExistingPower in _objCharacter.Powers) { if (objExistingPower.Name.StartsWith("Improved Reflexes")) { if (objExistingPower.Name.EndsWith("1")) { if (objExistingPower.Name.EndsWith("1")) { if (intRating >= 6) objExistingPower.FreePoints += 1.5M; //else // objExistingPower.FreePoints = 0; } else if (objExistingPower.Name.EndsWith("2")) { if (intRating >= 10) objExistingPower.FreePoints += 2.5M; else if (intRating >= 4) objExistingPower.FreePoints += 1.0M; //else // objExistingPower.FreePoints = 0; } else { if (intRating >= 14) objExistingPower.FreePoints += 3.5M; else if (intRating >= 8) objExistingPower.FreePoints += 2.0M; else if (intRating >= 4) objExistingPower.FreePoints += 1.0M; //else // objExistingPower.FreePoints = 0; } } else { // we have to adjust the number of free levels. decimal decLevels = Convert.ToDecimal(intRating)/4; decLevels = Math.Floor(decLevels/objExistingPower.PointsPerLevel); objExistingPower.FreeLevels += Convert.ToInt32(decLevels); if (objExistingPower.Rating < intRating) objExistingPower.Rating = objExistingPower.FreeLevels; break; } } else { // we have to adjust the number of free levels. decimal decLevels = Convert.ToDecimal(intRating)/4; decLevels = Math.Floor(decLevels/objExistingPower.PointsPerLevel); objExistingPower.FreeLevels = Convert.ToInt32(decLevels); if (objExistingPower.Rating < intRating) objExistingPower.Rating = objExistingPower.FreeLevels; break; } //} } if (!blnExistingPower) { // Display the Select Skill window and record which Skill was selected. frmSelectPower frmPickPower = new frmSelectPower(_objCharacter); Log.Info("selectpower = " + objNode.OuterXml.ToString()); if (objNode.OuterXml.Contains("limittopowers")) frmPickPower.LimitToPowers = objNode.Attributes["limittopowers"].InnerText; frmPickPower.ShowDialog(); // Make sure the dialogue window was not canceled. if (frmPickPower.DialogResult == DialogResult.Cancel) { Rollback(); _strForcedValue = ""; _strLimitSelection = ""; return false; } _strSelectedValue = frmPickPower.SelectedPower; if (blnConcatSelectedValue) strSourceName += " (" + _strSelectedValue + ")"; XmlDocument objXmlDocument = XmlManager.Instance.Load("powers.xml"); XmlNode objXmlPower = objXmlDocument.SelectSingleNode("/chummer/powers/power[name = \"" + _strSelectedValue + "\"]"); string strSelection = ""; Log.Info("_strSelectedValue = " + _strSelectedValue); Log.Info("strSourceName = " + strSourceName); XmlNode objBonus = objXmlPower["bonus"]; string strPowerNameLimit = _strSelectedValue; if (objBonus != null) { if (objBonus["selectlimit"] != null) { Log.Info("selectlimit = " + objBonus["selectlimit"].OuterXml.ToString()); _strForcedValue = ""; // Display the Select Limit window and record which Limit was selected. frmSelectLimit frmPickLimit = new frmSelectLimit(); if (strFriendlyName != "") frmPickLimit.Description = LanguageManager.Instance.GetString("String_Improvement_SelectLimitNamed") .Replace("{0}", strFriendlyName); else frmPickLimit.Description = LanguageManager.Instance.GetString("String_Improvement_SelectLimit"); if (objBonus["selectlimit"].InnerXml.Contains("<limit>")) { List<string> strValue = new List<string>(); foreach (XmlNode objXmlAttribute in objBonus["selectlimit"].SelectNodes("limit")) strValue.Add(objXmlAttribute.InnerText); frmPickLimit.LimitToList(strValue); } if (objBonus["selectlimit"].InnerXml.Contains("<excludelimit>")) { List<string> strValue = new List<string>(); foreach (XmlNode objXmlAttribute in objBonus["selectlimit"].SelectNodes("excludelimit")) strValue.Add(objXmlAttribute.InnerText); frmPickLimit.RemoveFromList(strValue); } // Check to see if there is only one possible selection because of _strLimitSelection. if (_strForcedValue != "") _strLimitSelection = _strForcedValue; Log.Info("_strForcedValue = " + _strForcedValue); Log.Info("_strLimitSelection = " + _strLimitSelection); if (_strLimitSelection != "") { frmPickLimit.SingleLimit(_strLimitSelection); frmPickLimit.Opacity = 0; } frmPickLimit.ShowDialog(); // Make sure the dialogue window was not canceled. if (frmPickLimit.DialogResult == DialogResult.Cancel) { Rollback(); _strForcedValue = ""; _strLimitSelection = ""; return false; } _strSelectedValue = frmPickLimit.SelectedLimit; strSelection = _strSelectedValue; _strForcedValue = _strSelectedValue; Log.Info("_strForcedValue = " + _strForcedValue); Log.Info("_strLimitSelection = " + _strLimitSelection); } if (objBonus["selectskill"] != null) { Log.Info("selectskill = " + objBonus["selectskill"].OuterXml.ToString()); XmlNode nodSkill = objBonus; // Display the Select Skill window and record which Skill was selected. frmSelectSkill frmPickSkill = new frmSelectSkill(_objCharacter); if (strFriendlyName != "") frmPickSkill.Description = LanguageManager.Instance.GetString("String_Improvement_SelectSkillNamed") .Replace("{0}", strFriendlyName); else frmPickSkill.Description = LanguageManager.Instance.GetString("String_Improvement_SelectSkill"); if (nodSkill.SelectSingleNode("selectskill").OuterXml.Contains("skillgroup")) frmPickSkill.OnlySkillGroup = nodSkill.SelectSingleNode("selectskill").Attributes["skillgroup"].InnerText; else if (nodSkill.SelectSingleNode("selectskill").OuterXml.Contains("skillcategory")) frmPickSkill.OnlyCategory = nodSkill.SelectSingleNode("selectskill").Attributes["skillcategory"].InnerText; else if (nodSkill.SelectSingleNode("selectskill").OuterXml.Contains("excludecategory")) frmPickSkill.ExcludeCategory = nodSkill.SelectSingleNode("selectskill").Attributes["excludecategory"].InnerText; else if (nodSkill.SelectSingleNode("selectskill").OuterXml.Contains("limittoskill")) frmPickSkill.LimitToSkill = nodSkill.SelectSingleNode("selectskill").Attributes["limittoskill"].InnerText; if (_strForcedValue.StartsWith("Adept:") || _strForcedValue.StartsWith("Magician:")) _strForcedValue = ""; Log.Info("_strForcedValue = " + _strForcedValue); Log.Info("_strLimitSelection = " + _strLimitSelection); if (_strForcedValue != "") { frmPickSkill.OnlySkill = _strForcedValue; frmPickSkill.Opacity = 0; } frmPickSkill.ShowDialog(); // Make sure the dialogue window was not canceled. if (frmPickSkill.DialogResult == DialogResult.Cancel) { Rollback(); _strForcedValue = ""; _strLimitSelection = ""; return false; } _strSelectedValue = frmPickSkill.SelectedSkill; _strForcedValue = _strSelectedValue; strSelection = _strSelectedValue; Log.Info("_strForcedValue = " + _strForcedValue); Log.Info("_strSelectedValue = " + _strSelectedValue); Log.Info("strSelection = " + strSelection); } if (objBonus["selecttext"] != null) { Log.Info("selecttext = " + objBonus["selecttext"].OuterXml.ToString()); frmSelectText frmPickText = new frmSelectText(); frmPickText.Description = LanguageManager.Instance.GetString("String_Improvement_SelectText") .Replace("{0}", strFriendlyName); Log.Info("_strForcedValue = " + _strForcedValue); Log.Info("_strLimitSelection = " + _strLimitSelection); if (_strLimitSelection != "") { frmPickText.SelectedValue = _strLimitSelection; frmPickText.Opacity = 0; } frmPickText.ShowDialog(); // Make sure the dialogue window was not canceled. if (frmPickText.DialogResult == DialogResult.Cancel) { Rollback(); _strForcedValue = ""; _strLimitSelection = ""; return false; } strSelection = frmPickText.SelectedValue; _strLimitSelection = strSelection; Log.Info("_strLimitSelection = " + _strLimitSelection); Log.Info("strSelection = " + strSelection); } if (objBonus["specificattribute"] != null) { Log.Info("specificattribute = " + objBonus["specificattribute"].OuterXml.ToString()); strSelection = objBonus["specificattribute"]["name"].InnerText.ToString(); Log.Info("strSelection = " + strSelection); } if (objBonus["selectattribute"] != null) { Log.Info("selectattribute = " + objBonus["selectattribute"].OuterXml.ToString()); XmlNode nodSkill = objBonus; if (_strForcedValue.StartsWith("Adept")) _strForcedValue = ""; // Display the Select CharacterAttribute window and record which CharacterAttribute was selected. frmSelectAttribute frmPickAttribute = new frmSelectAttribute(); if (strFriendlyName != "") frmPickAttribute.Description = LanguageManager.Instance.GetString("String_Improvement_SelectAttributeNamed").Replace("{0}", strFriendlyName); else frmPickAttribute.Description = LanguageManager.Instance.GetString("String_Improvement_SelectAttribute"); // Add MAG and/or RES to the list of Attributes if they are enabled on the form. if (_objCharacter.MAGEnabled) frmPickAttribute.AddMAG(); if (_objCharacter.RESEnabled) frmPickAttribute.AddRES(); if (nodSkill["selectattribute"].InnerXml.Contains("<attribute>")) { List<string> strValue = new List<string>(); foreach (XmlNode objXmlAttribute in nodSkill["selectattribute"].SelectNodes("attribute")) strValue.Add(objXmlAttribute.InnerText); frmPickAttribute.LimitToList(strValue); } if (nodSkill["selectattribute"].InnerXml.Contains("<excludeattribute>")) { List<string> strValue = new List<string>(); foreach (XmlNode objXmlAttribute in nodSkill["selectattribute"].SelectNodes("excludeattribute")) strValue.Add(objXmlAttribute.InnerText); frmPickAttribute.RemoveFromList(strValue); } // Check to see if there is only one possible selection because of _strLimitSelection. if (_strForcedValue != "") _strLimitSelection = _strForcedValue; Log.Info("_strForcedValue = " + _strForcedValue); Log.Info("_strLimitSelection = " + _strLimitSelection); if (_strLimitSelection != "") { frmPickAttribute.SingleAttribute(_strLimitSelection); frmPickAttribute.Opacity = 0; } frmPickAttribute.ShowDialog(); // Make sure the dialogue window was not canceled. if (frmPickAttribute.DialogResult == DialogResult.Cancel) { Rollback(); _strForcedValue = ""; _strLimitSelection = ""; return false; } _strSelectedValue = frmPickAttribute.SelectedAttribute; if (blnConcatSelectedValue) strSourceName += " (" + _strSelectedValue + ")"; strSelection = _strSelectedValue; _strForcedValue = _strSelectedValue; Log.Info("_strSelectedValue = " + _strSelectedValue); Log.Info("strSourceName = " + strSourceName); Log.Info("_strForcedValue = " + _strForcedValue); } } // If no, add the power and mark it free or give it free levels Power objPower = new Power(_objCharacter); bool blnHasPower = false; foreach (Power power in _objCharacter.Powers) { if (power.Name == objXmlPower["name"].InnerText) { if (power.Extra != "" && power.Extra == strSelection) { blnHasPower = true; objPower = power; } else if (power.Extra == "") { blnHasPower = true; objPower = power; } } } Log.Info("blnHasPower = " + blnHasPower); if (blnHasPower) { // If yes, mark it free or give it free levels if (objXmlPower["levels"].InnerText == "no") { if (objPower.Name.StartsWith("Improved Reflexes")) { if (objPower.Name.EndsWith("1")) { if (intRating >= 6) objPower.FreePoints = 1.5M; else objPower.FreePoints = 0; } else if (objPower.Name.EndsWith("2")) { if (intRating >= 10) objPower.FreePoints = 2.5M; else if (intRating >= 4) objPower.FreePoints = 1.0M; else objPower.FreePoints = 0; } else { if (intRating >= 14) objPower.FreePoints = 3.5M; else if (intRating >= 8) objPower.FreePoints = 2.0M; else if (intRating >= 4) objPower.FreePoints = 1.0M; else objPower.FreePoints = 0; } } else { objPower.Free = true; } } else { decimal decLevels = Convert.ToDecimal(intRating)/4; decLevels = Math.Floor(decLevels/objPower.PointsPerLevel); objPower.FreeLevels += Convert.ToInt32(decLevels); objPower.Rating += Convert.ToInt32(decLevels); } objPower.BonusSource = strSourceName; } else { Log.Info("Adding Power " + _strSelectedValue); // Get the Power information _objCharacter.Powers.Add(objPower); Log.Info("objXmlPower = " + objXmlPower.OuterXml.ToString()); bool blnLevels = false; if (objXmlPower["levels"] != null) blnLevels = (objXmlPower["levels"].InnerText == "yes"); objPower.LevelsEnabled = blnLevels; objPower.Name = objXmlPower["name"].InnerText; objPower.PointsPerLevel = Convert.ToDecimal(objXmlPower["points"].InnerText, GlobalOptions.Instance.CultureInfo); objPower.Source = objXmlPower["source"].InnerText; objPower.Page = objXmlPower["page"].InnerText; objPower.BonusSource = strSourceName; if (strSelection != string.Empty) objPower.Extra = strSelection; if (objXmlPower["doublecost"] != null) objPower.DoubleCost = false; if (objXmlPower["levels"].InnerText == "no") { if (objPower.Name.StartsWith("Improved Reflexes")) { if (objPower.Name.EndsWith("1")) { if (intRating >= 6) objPower.FreePoints = 1.5M; else objPower.FreePoints = 0; } else if (objPower.Name.EndsWith("2")) { if (intRating >= 10) objPower.FreePoints = 2.5M; else if (intRating >= 4) objPower.FreePoints = 1.0M; else objPower.FreePoints = 0; } else { if (intRating >= 14) objPower.FreePoints = 3.5M; else if (intRating >= 8) objPower.FreePoints = 2.0M; else if (intRating >= 4) objPower.FreePoints = 1.0M; else objPower.FreePoints = 0; } } else { objPower.Free = true; } } else { decimal decLevels = Convert.ToDecimal(intRating)/4; decLevels = Math.Floor(decLevels/objPower.PointsPerLevel); objPower.FreeLevels += Convert.ToInt32(decLevels); if (objPower.Rating < intRating) objPower.Rating = objPower.FreeLevels; } if (objXmlPower.InnerXml.Contains("bonus")) { objPower.Bonus = objXmlPower["bonus"]; Log.Info("Calling CreateImprovements"); if ( !CreateImprovements(Improvement.ImprovementSource.Power, objPower.InternalId, objPower.Bonus, false, Convert.ToInt32(objPower.Rating), objPower.DisplayNameShort)) { _objCharacter.Powers.Remove(objPower); } } } } } } // Check for Armor Encumbrance Penalty. if (bonusNode.LocalName == ("armorencumbrancepenalty")) { Log.Info("armorencumbrancepenalty"); Log.Info("armorencumbrancepenalty = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.ArmorEncumbrancePenalty, "", ValueToInt(bonusNode.InnerText, intRating)); } // Check for Initiation. if (bonusNode.LocalName == ("initiation")) { Log.Info("initiation"); Log.Info("initiation = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.Initiation, "", ValueToInt(bonusNode.InnerText, intRating)); _objCharacter.InitiateGrade += ValueToInt(bonusNode.InnerText, intRating); } // Check for Submersion. if (bonusNode.LocalName == ("submersion")) { Log.Info("submersion"); Log.Info("submersion = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.Submersion, "", ValueToInt(bonusNode.InnerText, intRating)); _objCharacter.SubmersionGrade += ValueToInt(bonusNode.InnerText, intRating); } // Check for Skillwires. if (bonusNode.LocalName == ("skillwire")) { Log.Info("skillwire"); Log.Info("skillwire = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.Skillwire, "", ValueToInt(bonusNode.InnerText, intRating)); } // Check for Hardwires. if (bonusNode.LocalName == ("hardwires")) { Log.Info("hardwire"); Log.Info("hardwire = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); Cyberware objCyberware = new Cyberware(_objCharacter); CommonFunctions _objFunctions = new CommonFunctions(); objCyberware = _objFunctions.FindCyberware(strSourceName, _objCharacter.Cyberware); if (objCyberware == null) { Log.Info("_strSelectedValue = " + _strSelectedValue); Log.Info("_strForcedValue = " + _strForcedValue); // Display the Select Skill window and record which Skill was selected. frmSelectSkill frmPickSkill = new frmSelectSkill(_objCharacter); if (strFriendlyName != "") frmPickSkill.Description = LanguageManager.Instance.GetString("String_Improvement_SelectSkillNamed") .Replace("{0}", strFriendlyName); else frmPickSkill.Description = LanguageManager.Instance.GetString("String_Improvement_SelectSkill"); Log.Info("selectskill = " + bonusNode.OuterXml.ToString()); if (bonusNode.OuterXml.Contains("skillgroup")) frmPickSkill.OnlySkillGroup = bonusNode.Attributes["skillgroup"].InnerText; else if (bonusNode.OuterXml.Contains("skillcategory")) frmPickSkill.OnlyCategory = bonusNode.Attributes["skillcategory"].InnerText; else if (bonusNode.OuterXml.Contains("excludecategory")) frmPickSkill.ExcludeCategory = bonusNode.Attributes["excludecategory"].InnerText; else if (bonusNode.OuterXml.Contains("limittoskill")) frmPickSkill.LimitToSkill = bonusNode.Attributes["limittoskill"].InnerText; else if (bonusNode.OuterXml.Contains("limittoattribute")) frmPickSkill.LinkedAttribute = bonusNode.Attributes["limittoattribute"].InnerText; if (_strForcedValue != "") { frmPickSkill.OnlySkill = _strForcedValue; frmPickSkill.Opacity = 0; } frmPickSkill.ShowDialog(); // Make sure the dialogue window was not canceled. if (frmPickSkill.DialogResult == DialogResult.Cancel) { Rollback(); _strForcedValue = ""; _strLimitSelection = ""; return false; } _strSelectedValue = frmPickSkill.SelectedSkill; } else { _strSelectedValue = objCyberware.Location; } if (blnConcatSelectedValue) strSourceName += " (" + _strSelectedValue + ")"; Log.Info("_strSelectedValue = " + _strSelectedValue); Log.Info("strSourceName = " + strSourceName); CreateImprovement(_strSelectedValue, objImprovementSource, strSourceName, Improvement.ImprovementType.Hardwire, _strSelectedValue, ValueToInt(bonusNode.InnerText, intRating)); } // Check for Damage Resistance. if (bonusNode.LocalName == ("damageresistance")) { Log.Info("damageresistance"); Log.Info("damageresistance = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.DamageResistance,"", ValueToInt(bonusNode.InnerText, intRating)); } // Check for Restricted Item Count. if (bonusNode.LocalName == ("restricteditemcount")) { Log.Info("restricteditemcount"); Log.Info("restricteditemcount = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.RestrictedItemCount, "", ValueToInt(bonusNode.InnerText, intRating)); } // Check for Judge Intentions. if (bonusNode.LocalName == ("judgeintentions")) { Log.Info("judgeintentions"); Log.Info("judgeintentions = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.JudgeIntentions, "", ValueToInt(bonusNode.InnerText, intRating)); } // Check for Composure. if (bonusNode.LocalName == ("composure")) { Log.Info("composure"); Log.Info("composure = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.Composure, "", ValueToInt(bonusNode.InnerText, intRating)); } // Check for Lift and Carry. if (bonusNode.LocalName == ("liftandcarry")) { Log.Info("liftandcarry"); Log.Info("liftandcarry = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.LiftAndCarry, "", ValueToInt(bonusNode.InnerText, intRating)); } // Check for Memory. if (bonusNode.LocalName == ("memory")) { Log.Info("memory"); Log.Info("memory = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.Memory, "", ValueToInt(bonusNode.InnerText, intRating)); } // Check for Concealability. if (bonusNode.LocalName == ("concealability")) { Log.Info("concealability"); Log.Info("concealability = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.Concealability, "", ValueToInt(bonusNode.InnerText, intRating)); } // Check for Drain Resistance. if (bonusNode.LocalName == ("drainresist")) { Log.Info("drainresist"); Log.Info("drainresist = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.DrainResistance, "", ValueToInt(bonusNode.InnerText, intRating)); } // Check for Fading Resistance. if (bonusNode.LocalName == ("fadingresist")) { Log.Info("fadingresist"); Log.Info("fadingresist = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.FadingResistance, "", ValueToInt(bonusNode.InnerText, intRating)); } // Check for Notoriety. if (bonusNode.LocalName == ("notoriety")) { Log.Info("notoriety"); Log.Info("notoriety = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.Notoriety, "", ValueToInt(bonusNode.InnerText, intRating)); } // Check for Complex Form Limit. if (bonusNode.LocalName == ("complexformlimit")) { Log.Info("complexformlimit"); Log.Info("complexformlimit = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.ComplexFormLimit, "", ValueToInt(bonusNode.InnerText, intRating)); } // Check for Spell Limit. if (bonusNode.LocalName == ("spelllimit")) { Log.Info("spelllimit"); Log.Info("spelllimit = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.SpellLimit, "", ValueToInt(bonusNode.InnerText, intRating)); } // Check for Spell Category bonuses. if (bonusNode.LocalName == ("spellcategory")) { Log.Info("spellcategory"); Log.Info("spellcategory = " + bonusNode.OuterXml.ToString()); string strUseUnique = strUnique; if (bonusNode["name"].Attributes["precedence"] != null) strUseUnique = "precedence" + bonusNode["name"].Attributes["precedence"].InnerText; Log.Info("Calling CreateImprovement"); CreateImprovement(bonusNode["name"].InnerText, objImprovementSource, strSourceName, Improvement.ImprovementType.SpellCategory, strUseUnique, ValueToInt(bonusNode["val"].InnerText, intRating)); } // Check for Throwing Range bonuses. if (bonusNode.LocalName == ("throwrange")) { Log.Info("throwrange"); Log.Info("throwrange = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.ThrowRange, strUnique, ValueToInt(bonusNode.InnerText, intRating)); } // Check for Throwing STR bonuses. if (bonusNode.LocalName == ("throwstr")) { Log.Info("throwstr"); Log.Info("throwstr = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.ThrowSTR, strUnique, ValueToInt(bonusNode.InnerText, intRating)); } // Check for Skillsoft access. if (bonusNode.LocalName == ("skillsoftaccess")) { Log.Info("skillsoftaccess"); Log.Info("skillsoftaccess = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.SkillsoftAccess, ""); _objCharacter.SkillsSection.KnowledgeSkills.AddRange(_objCharacter.SkillsSection.KnowsoftSkills); } // Check for Quickening Metamagic. if (bonusNode.LocalName == ("quickeningmetamagic")) { Log.Info("quickeningmetamagic"); Log.Info("quickeningmetamagic = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.QuickeningMetamagic, ""); } // Check for ignore Stun CM Penalty. if (bonusNode.LocalName == ("ignorecmpenaltystun")) { Log.Info("ignorecmpenaltystun"); Log.Info("ignorecmpenaltystun = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.IgnoreCMPenaltyStun, ""); } // Check for ignore Physical CM Penalty. if (bonusNode.LocalName == ("ignorecmpenaltyphysical")) { Log.Info("ignorecmpenaltyphysical"); Log.Info("ignorecmpenaltyphysical = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.IgnoreCMPenaltyPhysical, ""); } // Check for a Cyborg Essence which will permanently set the character's ESS to 0.1. if (bonusNode.LocalName == ("cyborgessence")) { Log.Info("cyborgessence"); Log.Info("cyborgessence = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.CyborgEssence, ""); } // Check for Maximum Essence which will permanently modify the character's Maximum Essence value. if (bonusNode.LocalName == ("essencemax")) { Log.Info("essencemax"); Log.Info("essencemax = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.EssenceMax, "", ValueToInt(bonusNode.InnerText, intRating)); } // Check for Select Sprite. if (bonusNode.LocalName == ("selectsprite")) { Log.Info("selectsprite"); Log.Info("selectsprite = " + bonusNode.OuterXml.ToString()); XmlDocument objXmlDocument = XmlManager.Instance.Load("critters.xml"); XmlNodeList objXmlNodeList = objXmlDocument.SelectNodes("/chummer/metatypes/metatype[contains(category, \"Sprites\")]"); List<ListItem> lstCritters = new List<ListItem>(); foreach (XmlNode objXmlNode in objXmlNodeList) { ListItem objItem = new ListItem(); if (objXmlNode["translate"] != null) objItem.Name = objXmlNode["translate"].InnerText; else objItem.Name = objXmlNode["name"].InnerText; objItem.Value = objItem.Name; lstCritters.Add(objItem); } frmSelectItem frmPickItem = new frmSelectItem(); frmPickItem.GeneralItems = lstCritters; frmPickItem.ShowDialog(); if (frmPickItem.DialogResult == DialogResult.Cancel) { Rollback(); _strForcedValue = ""; _strLimitSelection = ""; return false; } _strSelectedValue = frmPickItem.SelectedItem; Log.Info("Calling CreateImprovement"); CreateImprovement(frmPickItem.SelectedItem, objImprovementSource, strSourceName, Improvement.ImprovementType.AddSprite, ""); } // Check for Black Market Discount. if (bonusNode.LocalName == ("blackmarketdiscount")) { Log.Info("blackmarketdiscount"); Log.Info("blackmarketdiscount = " + bonusNode.OuterXml.ToString()); Log.Info("Calling CreateImprovement"); CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.BlackMarketDiscount, strUnique); _objCharacter.BlackMarketDiscount = true; } // Select Armor (Mostly used for Custom Fit (Stack)). if (bonusNode.LocalName == ("selectarmor")) { Log.Info("selectarmor"); Log.Info("selectarmor = " + bonusNode.OuterXml.ToString()); string strSelectedValue = ""; if (_strForcedValue != "") _strLimitSelection = _strForcedValue; // Display the Select Item window and record the value that was entered. List<ListItem> lstArmors = new List<ListItem>(); foreach (Armor objArmor in _objCharacter.Armor) { foreach (ArmorMod objMod in objArmor.ArmorMods) { if (objMod.Name.StartsWith("Custom Fit")) { ListItem objItem = new ListItem(); objItem.Value = objArmor.Name; objItem.Name = objArmor.DisplayName; lstArmors.Add(objItem); } } } if (lstArmors.Count > 0) { frmSelectItem frmPickItem = new frmSelectItem(); frmPickItem.Description = LanguageManager.Instance.GetString("String_Improvement_SelectText").Replace("{0}", strFriendlyName); frmPickItem.GeneralItems = lstArmors; Log.Info( "_strLimitSelection = " + _strLimitSelection); Log.Info( "_strForcedValue = " + _strForcedValue); if (_strLimitSelection != "") { frmPickItem.ForceItem = _strLimitSelection; frmPickItem.Opacity = 0; } frmPickItem.ShowDialog(); // Make sure the dialogue window was not canceled. if (frmPickItem.DialogResult == DialogResult.Cancel) { Rollback(); _strForcedValue = ""; _strLimitSelection = ""; return false; } _strSelectedValue = frmPickItem.SelectedItem; if (blnConcatSelectedValue) strSourceName += " (" + _strSelectedValue + ")"; strSelectedValue = frmPickItem.SelectedItem; Log.Info( "_strSelectedValue = " + _strSelectedValue); Log.Info( "strSelectedValue = " + strSelectedValue); } } // Select Weapon (custom entry for things like Spare Clip). if (bonusNode.LocalName == ("selectweapon")) { Log.Info("selectweapon"); Log.Info("selectweapon = " + bonusNode.OuterXml.ToString()); string strSelectedValue = ""; if (_strForcedValue != "") _strLimitSelection = _strForcedValue; if (_objCharacter == null) { // If the character is null (this is a Vehicle), the user must enter their own string. // Display the Select Item window and record the value that was entered. frmSelectText frmPickText = new frmSelectText(); frmPickText.Description = LanguageManager.Instance.GetString("String_Improvement_SelectText") .Replace("{0}", strFriendlyName); Log.Info("_strLimitSelection = " + _strLimitSelection); Log.Info("_strForcedValue = " + _strForcedValue); if (_strLimitSelection != "") { frmPickText.SelectedValue = _strLimitSelection; frmPickText.Opacity = 0; } frmPickText.ShowDialog(); // Make sure the dialogue window was not canceled. if (frmPickText.DialogResult == DialogResult.Cancel) { Rollback(); _strForcedValue = ""; _strLimitSelection = ""; return false; } _strSelectedValue = frmPickText.SelectedValue; if (blnConcatSelectedValue) strSourceName += " (" + _strSelectedValue + ")"; strSelectedValue = frmPickText.SelectedValue; Log.Info("_strSelectedValue = " + _strSelectedValue); Log.Info("strSelectedValue = " + strSelectedValue); } else { List<ListItem> lstWeapons = new List<ListItem>(); foreach (Weapon objWeapon in _objCharacter.Weapons) { ListItem objItem = new ListItem(); objItem.Value = objWeapon.Name; objItem.Name = objWeapon.DisplayName; lstWeapons.Add(objItem); } frmSelectItem frmPickItem = new frmSelectItem(); frmPickItem.Description = LanguageManager.Instance.GetString("String_Improvement_SelectText") .Replace("{0}", strFriendlyName); frmPickItem.GeneralItems = lstWeapons; Log.Info("_strLimitSelection = " + _strLimitSelection); Log.Info("_strForcedValue = " + _strForcedValue); if (_strLimitSelection != "") { frmPickItem.ForceItem = _strLimitSelection; frmPickItem.Opacity = 0; } frmPickItem.ShowDialog(); // Make sure the dialogue window was not canceled. if (frmPickItem.DialogResult == DialogResult.Cancel) { Rollback(); _strForcedValue = ""; _strLimitSelection = ""; return false; } _strSelectedValue = frmPickItem.SelectedItem; if (blnConcatSelectedValue) strSourceName += " (" + _strSelectedValue + ")"; strSelectedValue = frmPickItem.SelectedItem; Log.Info("_strSelectedValue = " + _strSelectedValue); Log.Info("strSelectedValue = " + strSelectedValue); } // Create the Improvement. Log.Info("Calling CreateImprovement"); CreateImprovement(strSelectedValue, objImprovementSource, strSourceName, Improvement.ImprovementType.Text, strUnique); } // Select an Optional Power. if (bonusNode.LocalName == ("optionalpowers")) { XmlNodeList objXmlPowerList = bonusNode.SelectNodes("optionalpower"); //Log.Info("selectoptionalpower"); // Display the Select Attribute window and record which Skill was selected. frmSelectOptionalPower frmPickPower = new frmSelectOptionalPower(); frmPickPower.Description = LanguageManager.Instance.GetString("String_Improvement_SelectOptionalPower"); string strForcedValue = ""; List<KeyValuePair<string, string>> lstValue = new List<KeyValuePair<string,string>>(); foreach (XmlNode objXmlOptionalPower in objXmlPowerList) { string strQuality = objXmlOptionalPower.InnerText; if (objXmlOptionalPower.Attributes["select"] != null) { strForcedValue = objXmlOptionalPower.Attributes["select"].InnerText; } lstValue.Add(new KeyValuePair<string, string>(strQuality,strForcedValue)); } frmPickPower.LimitToList(lstValue); // Check to see if there is only one possible selection because of _strLimitSelection. if (_strForcedValue != "") _strLimitSelection = _strForcedValue; Log.Info( "_strForcedValue = " + _strForcedValue); Log.Info( "_strLimitSelection = " + _strLimitSelection); if (_strLimitSelection != "") { frmPickPower.SinglePower(_strLimitSelection); frmPickPower.Opacity = 0; } frmPickPower.ShowDialog(); // Make sure the dialogue window was not canceled. if (frmPickPower.DialogResult == DialogResult.Cancel) { Rollback(); _strForcedValue = ""; _strLimitSelection = ""; return false; } _strSelectedValue = frmPickPower.SelectedPower; // Record the improvement. XmlDocument objXmlDocument = XmlManager.Instance.Load("critterpowers.xml"); XmlNode objXmlPowerNode = objXmlDocument.SelectSingleNode("/chummer/powers/power[name = \"" + _strSelectedValue + "\"]"); TreeNode objPowerNode = new TreeNode(); CritterPower objPower = new CritterPower(_objCharacter); objPower.Create(objXmlPowerNode, _objCharacter, objPowerNode, 0, strForcedValue); _objCharacter.CritterPowers.Add(objPower); } if (bonusNode.LocalName == "publicawareness") { CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.PublicAwareness, strUnique, ValueToInt(bonusNode.InnerText,1)); } if (bonusNode.LocalName == "dealerconnection") { Log.Info("dealerconnection"); frmSelectItem frmPickItem = new frmSelectItem(); List<ListItem> lstItems = new List<ListItem>(); XmlNodeList objXmlList = bonusNode.SelectNodes("category"); foreach (XmlNode objNode in objXmlList) { ListItem objItem = new ListItem(); objItem.Value = objNode.InnerText; objItem.Name = objNode.InnerText; lstItems.Add(objItem); } frmPickItem.GeneralItems = lstItems; frmPickItem.AllowAutoSelect = false; frmPickItem.ShowDialog(); // Make sure the dialogue window was not canceled. if (frmPickItem.DialogResult == DialogResult.Cancel) { Rollback(); _strForcedValue = ""; _strLimitSelection = ""; return false; } _strSelectedValue = frmPickItem.SelectedItem; if (blnConcatSelectedValue) strSourceName += " (" + _strSelectedValue + ")"; Log.Info("_strSelectedValue = " + _strSelectedValue); Log.Info("strSourceName = " + strSourceName); // Create the Improvement. Log.Info("Calling CreateImprovement"); CreateImprovement(frmPickItem.SelectedItem, objImprovementSource, strSourceName, Improvement.ImprovementType.DealerConnection, strUnique); } if (bonusNode.LocalName == "unlockskills") { List<string> options = bonusNode.InnerText.Split(',').Select(x => x.Trim()).ToList(); string final; if (options.Count == 0) { Utils.BreakIfDebug(); return false; } else if (options.Count == 1) { final = options[0]; } else { frmSelectItem frmSelect = new frmSelectItem { AllowAutoSelect = true, GeneralItems = options.Select(x => new ListItem(x, x)).ToList() }; if (_objCharacter.Pushtext.Count > 0) { frmSelect.ForceItem = _objCharacter.Pushtext.Pop(); } if (frmSelect.ShowDialog() == DialogResult.Cancel) { return false; } final = frmSelect.SelectedItem; } SkillsSection.FilterOptions skills; if (Enum.TryParse(final, out skills)) { _objCharacter.SkillsSection.AddSkills(skills); CreateImprovement(skills.ToString(), Improvement.ImprovementSource.Quality, strSourceName, Improvement.ImprovementType.SpecialSkills, strUnique); } else { Utils.BreakIfDebug(); Log.Info(new[] {"Failed to parse", "specialskills", bonusNode.OuterXml}); } } //nothing went wrong, so return true return true; }
private void frmSelectLifestyle_Load(object sender, EventArgs e) { string strSelectedId = string.Empty; // Populate the Lifestyle ComboBoxes. List <ListItem> lstLifestyle = new List <ListItem>(); using (XmlNodeList xmlLifestyleList = _objXmlDocument.SelectNodes("/chummer/lifestyles/lifestyle[" + _objCharacter.Options.BookXPath() + "]")) if (xmlLifestyleList?.Count > 0) { foreach (XmlNode objXmlLifestyle in xmlLifestyleList) { string strLifeStyleId = objXmlLifestyle["id"]?.InnerText; if (!string.IsNullOrEmpty(strLifeStyleId) && !strLifeStyleId.IsEmptyGuid()) { string strName = objXmlLifestyle["name"]?.InnerText ?? LanguageManager.GetString("String_Unknown"); if (strName == _objSourceLifestyle?.BaseLifestyle) { strSelectedId = strLifeStyleId; } lstLifestyle.Add(new ListItem(strLifeStyleId, objXmlLifestyle["translate"]?.InnerText ?? strName)); } } } cboLifestyle.BeginUpdate(); cboLifestyle.ValueMember = "Value"; cboLifestyle.DisplayMember = "Name"; cboLifestyle.DataSource = lstLifestyle; if (!string.IsNullOrEmpty(strSelectedId)) { cboLifestyle.SelectedValue = strSelectedId; } if (cboLifestyle.SelectedIndex == -1) { cboLifestyle.SelectedIndex = 0; } cboLifestyle.EndUpdate(); string strSpace = LanguageManager.GetString("String_Space"); // Fill the Options list. using (XmlNodeList xmlLifestyleOptionsList = _objXmlDocument.SelectNodes("/chummer/qualities/quality[(source = \"" + "SR5" + "\" or category = \"" + "Contracts" + "\") and (" + _objCharacter.Options.BookXPath() + ")]")) if (xmlLifestyleOptionsList?.Count > 0) { foreach (XmlNode objXmlOption in xmlLifestyleOptionsList) { string strOptionName = objXmlOption["name"]?.InnerText; if (string.IsNullOrEmpty(strOptionName)) { continue; } TreeNode nodOption = new TreeNode(); XmlNode nodMultiplier = objXmlOption["multiplier"]; string strBaseString = string.Empty; if (nodMultiplier == null) { nodMultiplier = objXmlOption["multiplierbaseonly"]; strBaseString = strSpace + LanguageManager.GetString("Label_Base"); } nodOption.Tag = objXmlOption["id"]?.InnerText; if (nodMultiplier != null && int.TryParse(nodMultiplier.InnerText, out int intCost)) { nodOption.Text = (objXmlOption["translate"]?.InnerText ?? strOptionName) + strSpace + (intCost > 0 ? "[+" : "[") + intCost.ToString(GlobalOptions.CultureInfo) + strBaseString + "%]"; } else { string strCost = objXmlOption["cost"]?.InnerText; object objProcess = CommonFunctions.EvaluateInvariantXPath(strCost, out bool blnIsSuccess); decimal decCost = blnIsSuccess ? Convert.ToDecimal((double)objProcess) : 0; nodOption.Text = (objXmlOption["translate"]?.InnerText ?? strOptionName) + strSpace + '[' + decCost.ToString(_objCharacter.Options.NuyenFormat, GlobalOptions.CultureInfo) + "¥]"; } treQualities.Nodes.Add(nodOption); } } SortTree(treQualities); if (_objSourceLifestyle != null) { txtLifestyleName.Text = _objSourceLifestyle.Name; nudRoommates.Value = _objSourceLifestyle.Roommates; nudPercentage.Value = _objSourceLifestyle.Percentage; foreach (LifestyleQuality objQuality in _objSourceLifestyle.LifestyleQualities) { TreeNode objNode = treQualities.FindNode(objQuality.SourceIDString); if (objNode != null) { objNode.Checked = true; } } chkPrimaryTenant.Checked = _objSourceLifestyle.PrimaryTenant; } _blnSkipRefresh = false; CalculateValues(); }
private void lblVehicleSource_Click(object sender, EventArgs e) { CommonFunctions objCommon = new CommonFunctions(_objCharacter); _objFunctions.OpenPDF(lblVehicleSource.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) { // Get the information for the selected Mentor. lblAdvantage.Text = objXmlMentor.SelectSingleNode("altadvantage")?.Value ?? objXmlMentor.SelectSingleNode("advantage")?.Value ?? LanguageManager.GetString("String_Unknown", GlobalOptions.Language); lblDisadvantage.Text = objXmlMentor.SelectSingleNode("altdisadvantage")?.Value ?? objXmlMentor.SelectSingleNode("disadvantage")?.Value ?? LanguageManager.GetString("String_Unknown", GlobalOptions.Language); 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:")) && (_objCharacter.MagicianEnabled || !strName.StartsWith("Magician:"))) { 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)); } } } lblChoice1.Visible = true; cboChoice1.Visible = true; cboChoice1.ValueMember = "Value"; cboChoice1.DisplayMember = "Name"; cboChoice1.DataSource = lstChoice1; lblChoice1.Top = lblAdvantage.Top + lblAdvantage.Height + 6; cboChoice1.Top = lblChoice1.Top + lblChoice1.Height + 3; lblChoice2.Top = cboChoice1.Top + cboChoice1.Height + 6; cboChoice2.Top = lblChoice2.Top + lblChoice2.Height + 3; if (lstChoice2.Count > 0) { lblChoice2.Visible = true; cboChoice2.Visible = true; cboChoice2.ValueMember = "Value"; cboChoice2.DisplayMember = "Name"; cboChoice2.DataSource = lstChoice2; chkMentorMask.Top = cboChoice2.Top + cboChoice2.Height + 6; } else { lblChoice2.Visible = false; cboChoice2.Visible = false; chkMentorMask.Top = cboChoice1.Top + cboChoice1.Height + 6; } lblDisadvantageLabel.Top = Math.Max(chkMentorMask.Top + chkMentorMask.Height + 6, 133); lblDisadvantage.Top = Math.Max(chkMentorMask.Top + chkMentorMask.Height + 6, 133); } else { lblChoice1.Visible = false; cboChoice1.Visible = false; lblChoice2.Visible = false; cboChoice2.Visible = false; } cboChoice1.EndUpdate(); cboChoice2.EndUpdate(); string strSource = objXmlMentor.SelectSingleNode("source")?.Value ?? LanguageManager.GetString("String_Unknown", GlobalOptions.Language); string strPage = objXmlMentor.SelectSingleNode("altpage")?.Value ?? objXmlMentor.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); cmdOK.Enabled = true; } else { lblAdvantage.Text = string.Empty; lblDisadvantage.Text = string.Empty; lblChoice1.Visible = false; lblChoice2.Visible = false; cboChoice1.BeginUpdate(); cboChoice1.Visible = false; cboChoice1.DataSource = null; cboChoice1.EndUpdate(); cboChoice2.BeginUpdate(); cboChoice2.Visible = false; cboChoice2.DataSource = null; cboChoice2.EndUpdate(); lblSource.Text = string.Empty; lblSource.SetToolTip(string.Empty); cmdOK.Enabled = false; } }