/// <summary> /// Create a new character and show the Create Form. /// </summary> private void ShowNewForm(object sender, EventArgs e) { Character objCharacter = new Character(); if (Directory.GetFiles(Path.Combine(Application.StartupPath, "settings"), "*.xml").Count() > 1) { frmSelectSetting frmPickSetting = new frmSelectSetting(); frmPickSetting.ShowDialog(this); if (frmPickSetting.DialogResult == DialogResult.Cancel) { return; } objCharacter.SettingsFile = frmPickSetting.SettingsFile; } else { string strSettingsFile = Directory.GetFiles(Path.Combine(Application.StartupPath, "settings"), "*.xml")[0]; strSettingsFile = strSettingsFile.Replace(Path.Combine(Application.StartupPath, "settings"), string.Empty); strSettingsFile = strSettingsFile.Replace(Path.DirectorySeparatorChar, ' ').Trim(); objCharacter.SettingsFile = strSettingsFile; } // Show the BP selection window. frmSelectBP frmBP = new frmSelectBP(objCharacter); frmBP.ShowDialog(); if (frmBP.DialogResult == DialogResult.Cancel) { return; } // Show the Metatype selection window. if (objCharacter.BuildMethod == CharacterBuildMethod.Priority) { frmPriorityMetatype frmSelectMetatype = new frmPriorityMetatype(objCharacter); frmSelectMetatype.ShowDialog(); if (frmSelectMetatype.DialogResult == DialogResult.Cancel) { return; } } else { frmMetatype frmSelectMetatype = new frmMetatype(objCharacter); frmSelectMetatype.ShowDialog(); if (frmSelectMetatype.DialogResult == DialogResult.Cancel) { return; } } // Add the Unarmed Attack Weapon to the character. try { XmlDocument objXmlDocument = XmlManager.Instance.Load("weapons.xml"); XmlNode objXmlWeapon = objXmlDocument.SelectSingleNode("/chummer/weapons/weapon[name = \"Unarmed Attack\"]"); TreeNode objDummy = new TreeNode(); Weapon objWeapon = new Weapon(objCharacter); objWeapon.Create(objXmlWeapon, objCharacter, objDummy, null, null, null); objCharacter.Weapons.Add(objWeapon); } catch { } frmCreate frmNewCharacter = new frmCreate(objCharacter); frmNewCharacter.MdiParent = this; frmNewCharacter.WindowState = FormWindowState.Maximized; frmNewCharacter.Show(); objCharacter.CharacterNameChanged += objCharacter_CharacterNameChanged; }
private void mnuNewCritter_Click(object sender, EventArgs e) { Character objCharacter = new Character(); if (Directory.GetFiles(Path.Combine(Application.StartupPath, "settings"), "*.xml").Count() > 1) { frmSelectSetting frmPickSetting = new frmSelectSetting(); frmPickSetting.ShowDialog(this); if (frmPickSetting.DialogResult == DialogResult.Cancel) { return; } objCharacter.SettingsFile = frmPickSetting.SettingsFile; } else { string strSettingsFile = Directory.GetFiles(Path.Combine(Application.StartupPath, "settings"), "*.xml")[0]; strSettingsFile = strSettingsFile.Replace(Path.Combine(Application.StartupPath, "settings"), string.Empty); strSettingsFile = strSettingsFile.Replace(Path.DirectorySeparatorChar, ' ').Trim(); objCharacter.SettingsFile = strSettingsFile; } // Override the defaults for the setting. objCharacter.IgnoreRules = true; objCharacter.IsCritter = true; objCharacter.BuildMethod = CharacterBuildMethod.Karma; objCharacter.BuildPoints = 0; // Make sure that Running Wild is one of the allowed source books since most of the Critter Powers come from this book. bool blnRunningWild = false; blnRunningWild = (objCharacter.Options.Books.Contains("RW")); if (!blnRunningWild) { MessageBox.Show(LanguageManager.Instance.GetString("Message_Main_RunningWild"), LanguageManager.Instance.GetString("MessageTitle_Main_RunningWild"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } // Show the Metatype selection window. if (objCharacter.BuildMethod == CharacterBuildMethod.Priority) { frmPriorityMetatype frmSelectMetatype = new frmPriorityMetatype(objCharacter); frmSelectMetatype.XmlFile = "critters.xml"; frmSelectMetatype.ShowDialog(); if (frmSelectMetatype.DialogResult == DialogResult.Cancel) { return; } } else { frmMetatype frmSelectMetatype = new frmMetatype(objCharacter); frmSelectMetatype.XmlFile = "critters.xml"; frmSelectMetatype.ShowDialog(); if (frmSelectMetatype.DialogResult == DialogResult.Cancel) { return; } } // Add the Unarmed Attack Weapon to the character. try { XmlDocument objXmlDocument = XmlManager.Instance.Load("weapons.xml"); XmlNode objXmlWeapon = objXmlDocument.SelectSingleNode("/chummer/weapons/weapon[name = \"Unarmed Attack\"]"); TreeNode objDummy = new TreeNode(); Weapon objWeapon = new Weapon(objCharacter); objWeapon.Create(objXmlWeapon, objCharacter, objDummy, null, null, null); objCharacter.Weapons.Add(objWeapon); } catch { } frmCreate frmNewCharacter = new frmCreate(objCharacter); frmNewCharacter.MdiParent = this; frmNewCharacter.WindowState = FormWindowState.Maximized; frmNewCharacter.Show(); objCharacter.CharacterNameChanged += objCharacter_CharacterNameChanged; }
/// <summary> /// Create a new character and show the Create Form. /// </summary> private void ShowNewForm(object sender, EventArgs e) { Character objCharacter = new Character(); if (Directory.GetFiles(Path.Combine(Application.StartupPath, "settings"), "*.xml").Count() > 1) { frmSelectSetting frmPickSetting = new frmSelectSetting(); frmPickSetting.ShowDialog(this); if (frmPickSetting.DialogResult == DialogResult.Cancel) return; objCharacter.SettingsFile = frmPickSetting.SettingsFile; } else { string strSettingsFile = Directory.GetFiles(Path.Combine(Application.StartupPath, "settings"), "*.xml")[0]; strSettingsFile = strSettingsFile.Replace(Path.Combine(Application.StartupPath, "settings"), string.Empty); strSettingsFile = strSettingsFile.Replace(Path.DirectorySeparatorChar, ' ').Trim(); objCharacter.SettingsFile = strSettingsFile; } // Show the BP selection window. frmSelectBP frmBP = new frmSelectBP(objCharacter); frmBP.ShowDialog(); if (frmBP.DialogResult == DialogResult.Cancel) return; // Show the Metatype selection window. frmMetatype frmSelectMetatype = new frmMetatype(objCharacter); frmSelectMetatype.ShowDialog(); if (frmSelectMetatype.DialogResult == DialogResult.Cancel) return; // Add the Unarmed Attack Weapon to the character. try { XmlDocument objXmlDocument = XmlManager.Instance.Load("weapons.xml"); XmlNode objXmlWeapon = objXmlDocument.SelectSingleNode("/chummer/weapons/weapon[name = \"Unarmed Attack\"]"); TreeNode objDummy = new TreeNode(); Weapon objWeapon = new Weapon(objCharacter); objWeapon.Create(objXmlWeapon, objCharacter, objDummy, null, null, null); objCharacter.Weapons.Add(objWeapon); } catch { } frmCreate frmNewCharacter = new frmCreate(objCharacter); frmNewCharacter.MdiParent = this; frmNewCharacter.WindowState = FormWindowState.Maximized; frmNewCharacter.Show(); objCharacter.CharacterNameChanged += objCharacter_CharacterNameChanged; }
/// <summary> /// Change the character's Metatype. /// </summary> public void ChangeMetatype() { // Determine if the character has any chosen Qualities that depend on their current Metatype. If so, don't let the change happen. XmlDocument objXmlDocument = XmlManager.Instance.Load("qualities.xml"); string strQualities = ""; foreach (Quality objQuality in _objCharacter.Qualities) { if (objQuality.OriginSource != QualitySource.Metatype && objQuality.OriginSource != QualitySource.MetatypeRemovable) { XmlNode objXmlQuality = objXmlDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + objQuality.Name + "\"]"); if (objXmlQuality.SelectNodes("required/oneof/metatype[. = \"" + _objCharacter.Metatype + "\"]").Count > 0 || objXmlQuality.SelectNodes("required/oneof/metavariant[. = \"" + _objCharacter.Metavariant + "\"]").Count > 0) strQualities += "\n\t" + objQuality.DisplayNameShort; if (objXmlQuality.SelectNodes("required/allof/metatype[. = \"" + _objCharacter.Metatype + "\"]").Count > 0 || objXmlQuality.SelectNodes("required/allof/metavariant[. = \"" + _objCharacter.Metavariant + "\"]").Count > 0) strQualities += "\n\t" + objQuality.DisplayNameShort; } } if (strQualities != "") { MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotChangeMetatype") + strQualities, LanguageManager.Instance.GetString("MessageTitle_CannotChangeMetatype"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } int intEssenceLoss = 0; intEssenceLoss = _objCharacter.EssencePenalty; // Determine the number of points that have been put into Attributes. int intBOD = _objCharacter.BOD.Value - _objCharacter.BOD.MetatypeMinimum; int intAGI = _objCharacter.AGI.Value - _objCharacter.AGI.MetatypeMinimum; int intREA = _objCharacter.REA.Value - _objCharacter.REA.MetatypeMinimum; int intSTR = _objCharacter.STR.Value - _objCharacter.STR.MetatypeMinimum; int intCHA = _objCharacter.CHA.Value - _objCharacter.CHA.MetatypeMinimum; int intINT = _objCharacter.INT.Value - _objCharacter.INT.MetatypeMinimum; int intLOG = _objCharacter.LOG.Value - _objCharacter.LOG.MetatypeMinimum; int intWIL = _objCharacter.WIL.Value - _objCharacter.WIL.MetatypeMinimum; int intEDG = _objCharacter.EDG.Value - _objCharacter.EDG.MetatypeMinimum; int intMAG = _objCharacter.MAG.Value - _objCharacter.MAG.MetatypeMinimum; int intRES = _objCharacter.RES.Value - _objCharacter.RES.MetatypeMinimum; // Build a list of the current Metatype's Improvements to remove if the Metatype changes. List<Improvement> lstImprovement = new List<Improvement>(); foreach (Improvement objImprovement in _objCharacter.Improvements) { if (objImprovement.ImproveSource == Improvement.ImprovementSource.Metatype || objImprovement.ImproveSource == Improvement.ImprovementSource.Metavariant) lstImprovement.Add(objImprovement); } // Build a list of the current Metatype's Qualities to remove if the Metatype changes. List<Quality> lstRemoveQuality = new List<Quality>(); foreach (Quality objQuality in _objCharacter.Qualities) { if (objQuality.OriginSource == QualitySource.Metatype || objQuality.OriginSource == QualitySource.MetatypeRemovable) lstRemoveQuality.Add(objQuality); } frmMetatype frmSelectMetatype = new frmMetatype(_objCharacter); frmSelectMetatype.ShowDialog(this); if (frmSelectMetatype.DialogResult == DialogResult.Cancel) return; // Remove any Improvements the character received from their Metatype. foreach (Improvement objImprovement in lstImprovement) { _objImprovementManager.RemoveImprovements(objImprovement.ImproveSource, objImprovement.SourceName); _objCharacter.Improvements.Remove(objImprovement); } // Remove any Qualities the character received from their Metatype, then remove the Quality. foreach (Quality objQuality in lstRemoveQuality) { _objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.Quality, objQuality.InternalId); _objCharacter.Qualities.Remove(objQuality); } // Populate the Qualities list. treQualities.Nodes[0].Nodes.Clear(); treQualities.Nodes[1].Nodes.Clear(); foreach (Quality objQuality in _objCharacter.Qualities) { TreeNode objNode = new TreeNode(); objNode.Text = objQuality.DisplayName; objNode.Tag = objQuality.InternalId; if (objQuality.OriginSource == QualitySource.Metatype || objQuality.OriginSource == QualitySource.MetatypeRemovable) objNode.ForeColor = SystemColors.GrayText; if (objQuality.Type == QualityType.Positive) { treQualities.Nodes[0].Nodes.Add(objNode); treQualities.Nodes[0].Expand(); } else { treQualities.Nodes[1].Nodes.Add(objNode); treQualities.Nodes[1].Expand(); } } _blnSkipUpdate = true; nudBOD.Maximum = _objCharacter.BOD.TotalMaximum; nudAGI.Maximum = _objCharacter.AGI.TotalMaximum; nudREA.Maximum = _objCharacter.REA.TotalMaximum; nudSTR.Maximum = _objCharacter.STR.TotalMaximum; nudCHA.Maximum = _objCharacter.CHA.TotalMaximum; nudINT.Maximum = _objCharacter.INT.TotalMaximum; nudLOG.Maximum = _objCharacter.LOG.TotalMaximum; nudWIL.Maximum = _objCharacter.WIL.TotalMaximum; nudEDG.Maximum = _objCharacter.EDG.TotalMaximum; nudMAG.Maximum = _objCharacter.MAG.TotalMaximum; nudRES.Maximum = _objCharacter.RES.TotalMaximum; nudBOD.Minimum = _objCharacter.BOD.MetatypeMinimum; nudAGI.Minimum = _objCharacter.AGI.MetatypeMinimum; nudREA.Minimum = _objCharacter.REA.MetatypeMinimum; nudSTR.Minimum = _objCharacter.STR.MetatypeMinimum; nudCHA.Minimum = _objCharacter.CHA.MetatypeMinimum; nudINT.Minimum = _objCharacter.INT.MetatypeMinimum; nudLOG.Minimum = _objCharacter.LOG.MetatypeMinimum; nudWIL.Minimum = _objCharacter.WIL.MetatypeMinimum; nudEDG.Minimum = _objCharacter.EDG.MetatypeMinimum; nudMAG.Minimum = _objCharacter.MAG.MetatypeMinimum; nudRES.Minimum = _objCharacter.RES.MetatypeMinimum; _objCharacter.BOD.Value = _objCharacter.BOD.MetatypeMinimum + intBOD; _objCharacter.AGI.Value = _objCharacter.AGI.MetatypeMinimum + intAGI; _objCharacter.REA.Value = _objCharacter.REA.MetatypeMinimum + intREA; _objCharacter.STR.Value = _objCharacter.STR.MetatypeMinimum + intSTR; _objCharacter.CHA.Value = _objCharacter.CHA.MetatypeMinimum + intCHA; _objCharacter.INT.Value = _objCharacter.INT.MetatypeMinimum + intINT; _objCharacter.LOG.Value = _objCharacter.LOG.MetatypeMinimum + intLOG; _objCharacter.WIL.Value = _objCharacter.WIL.MetatypeMinimum + intWIL; _objCharacter.EDG.Value = _objCharacter.EDG.MetatypeMinimum + intEDG; _objCharacter.MAG.Value = _objCharacter.MAG.MetatypeMinimum + intMAG; _objCharacter.RES.Value = _objCharacter.RES.MetatypeMinimum + intRES; nudBOD.Value = _objCharacter.BOD.Value; nudAGI.Value = _objCharacter.AGI.Value; nudREA.Value = _objCharacter.REA.Value; nudSTR.Value = _objCharacter.STR.Value; nudCHA.Value = _objCharacter.CHA.Value; nudINT.Value = _objCharacter.INT.Value; nudLOG.Value = _objCharacter.LOG.Value; nudWIL.Value = _objCharacter.WIL.Value; nudEDG.Value = _objCharacter.EDG.Value; if (_objCharacter.MAG.Value < 1) nudMAG.Value = 1; else nudMAG.Value = _objCharacter.MAG.Value; if (_objCharacter.RES.Value < 1) nudRES.Value = 1; else nudRES.Value = _objCharacter.RES.Value; _blnSkipUpdate = false; XmlDocument objMetatypeDoc = new XmlDocument(); XmlNode objMetatypeNode; string strMetatype = ""; string strBook = ""; string strPage = ""; objMetatypeDoc = XmlManager.Instance.Load("metatypes.xml"); { objMetatypeNode = objMetatypeDoc.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + _objCharacter.Metatype + "\"]"); if (objMetatypeNode == null) objMetatypeDoc = XmlManager.Instance.Load("critters.xml"); objMetatypeNode = objMetatypeDoc.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + _objCharacter.Metatype + "\"]"); if (objMetatypeNode["translate"] != null) strMetatype = objMetatypeNode["translate"].InnerText; else strMetatype = _objCharacter.Metatype; strBook = _objOptions.LanguageBookShort(objMetatypeNode["source"].InnerText); if (objMetatypeNode["altpage"] != null) strPage = objMetatypeNode["altpage"].InnerText; else strPage = objMetatypeNode["page"].InnerText; if (_objCharacter.Metavariant != "") { objMetatypeNode = objMetatypeNode.SelectSingleNode("metavariants/metavariant[name = \"" + _objCharacter.Metavariant + "\"]"); if (objMetatypeNode["translate"] != null) strMetatype += " (" + objMetatypeNode["translate"].InnerText + ")"; else strMetatype += " (" + _objCharacter.Metavariant + ")"; strBook = _objOptions.LanguageBookShort(objMetatypeNode["source"].InnerText); if (objMetatypeNode["altpage"] != null) strPage = objMetatypeNode["altpage"].InnerText; else strPage = objMetatypeNode["page"].InnerText; } } lblMetatype.Text = strMetatype; lblMetatypeSource.Text = strBook + " " + strPage; tipTooltip.SetToolTip(lblMetatypeSource, _objOptions.LanguageBookLong(objMetatypeNode["source"].InnerText) + " " + LanguageManager.Instance.GetString("String_Page") + " " + strPage); // If we're working with Karma, the Metatype doesn't cost anything. if (_objCharacter.BuildMethod == CharacterBuildMethod.BP) lblMetatypeBP.Text = _objCharacter.MetatypeBP.ToString() + " " + LanguageManager.Instance.GetString("String_BP"); else if (_objCharacter.BuildMethod == CharacterBuildMethod.Karma && _objOptions.MetatypeCostsKarma) lblMetatypeBP.Text = (_objCharacter.MetatypeBP * _objOptions.MetatypeCostsKarmaMultiplier).ToString() + " " + LanguageManager.Instance.GetString("String_Karma"); else lblMetatypeBP.Text = "0 " + LanguageManager.Instance.GetString("String_Karma"); string strToolTip = _objCharacter.Metatype; if (_objCharacter.Metavariant != "") strToolTip += " (" + _objCharacter.Metavariant + ")"; strToolTip += " (" + _objCharacter.MetatypeBP.ToString() + ")"; tipTooltip.SetToolTip(lblMetatypeBP, strToolTip); UpdateCharacterInfo(); }
private void mnuNewCritter_Click(object sender, EventArgs e) { Character objCharacter = new Character(); if (Directory.GetFiles(Path.Combine(Application.StartupPath, "settings"), "*.xml").Count() > 1) { frmSelectSetting frmPickSetting = new frmSelectSetting(); frmPickSetting.ShowDialog(this); if (frmPickSetting.DialogResult == DialogResult.Cancel) return; objCharacter.SettingsFile = frmPickSetting.SettingsFile; } else { string strSettingsFile = Directory.GetFiles(Path.Combine(Application.StartupPath, "settings"), "*.xml")[0]; strSettingsFile = strSettingsFile.Replace(Path.Combine(Application.StartupPath, "settings"), string.Empty); strSettingsFile = strSettingsFile.Replace(Path.DirectorySeparatorChar, ' ').Trim(); objCharacter.SettingsFile = strSettingsFile; } // Override the defaults for the setting. objCharacter.IgnoreRules = true; objCharacter.IsCritter = true; objCharacter.BuildMethod = CharacterBuildMethod.BP; objCharacter.BuildPoints = 0; // Make sure that Running Wild is one of the allowed source books since most of the Critter Powers come from this book. bool blnRunningWild = false; blnRunningWild = (objCharacter.Options.Books.Contains("RW")); if (!blnRunningWild) { MessageBox.Show(LanguageManager.Instance.GetString("Message_Main_RunningWild"), LanguageManager.Instance.GetString("MessageTitle_Main_RunningWild"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } // Show the Metatype selection window. frmMetatype frmSelectMetatype = new frmMetatype(objCharacter); frmSelectMetatype.XmlFile = "critters.xml"; frmSelectMetatype.ShowDialog(); if (frmSelectMetatype.DialogResult == DialogResult.Cancel) return; // Add the Unarmed Attack Weapon to the character. try { XmlDocument objXmlDocument = XmlManager.Instance.Load("weapons.xml"); XmlNode objXmlWeapon = objXmlDocument.SelectSingleNode("/chummer/weapons/weapon[name = \"Unarmed Attack\"]"); TreeNode objDummy = new TreeNode(); Weapon objWeapon = new Weapon(objCharacter); objWeapon.Create(objXmlWeapon, objCharacter, objDummy, null, null, null); objCharacter.Weapons.Add(objWeapon); } catch { } frmCreate frmNewCharacter = new frmCreate(objCharacter); frmNewCharacter.MdiParent = this; frmNewCharacter.WindowState = FormWindowState.Maximized; frmNewCharacter.Show(); objCharacter.CharacterNameChanged += objCharacter_CharacterNameChanged; }