/// <summary> /// Load a Character and open the correct window. /// </summary> /// <param name="strFileName">File to load.</param> /// <param name="blnIncludeInMRU">Whether or not the file should appear in the MRU list.</param> /// <param name="strNewName">New name for the character.</param> /// <param name="blnClearFileName">Whether or not the name of the save file should be cleared.</param> public void LoadCharacter(string strFileName, bool blnIncludeInMRU = true, string strNewName = "", bool blnClearFileName = false) { if (File.Exists(strFileName) && strFileName.EndsWith("chum5")) { Timekeeper.Start("loading"); bool blnLoaded = false; Character objCharacter = new Character(); objCharacter.FileName = strFileName; Timekeeper.Start("load_file"); blnLoaded = objCharacter.Load(); Timekeeper.Finish("load_file"); Timekeeper.Start("load_free"); if (!blnLoaded) return; // If a new name is given, set the character's name to match (used in cloning). if (strNewName != "") objCharacter.Name = strNewName; // Clear the File Name field so that this does not accidentally overwrite the original save file (used in cloning). if (blnClearFileName) objCharacter.FileName = ""; // Show the character form. if (!objCharacter.Created) { frmCreate frmCharacter = new frmCreate(objCharacter); frmCharacter.MdiParent = this; frmCharacter.WindowState = FormWindowState.Maximized; frmCharacter.Loading = true; frmCharacter.Show(); } else { frmCareer frmCharacter = new frmCareer(objCharacter); frmCharacter.MdiParent = this; frmCharacter.WindowState = FormWindowState.Maximized; frmCharacter.Loading = true; frmCharacter.DiceRollerOpened += objCareer_DiceRollerOpened; frmCharacter.DiceRollerOpenedInt += objCareer_DiceRollerOpenedInt; frmCharacter.Show(); } if (blnIncludeInMRU) GlobalOptions.Instance.AddToMRUList(strFileName); objCharacter.CharacterNameChanged += objCharacter_CharacterNameChanged; objCharacter_CharacterNameChanged(objCharacter); } else { MessageBox.Show(LanguageManager.Instance.GetString("Message_FileNotFound").Replace("{0}", strFileName), LanguageManager.Instance.GetString("MessageTitle_FileNotFound"), MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void mnuNewCritter_Click(object sender, EventArgs e) { Character objCharacter = new Character(); string settingsPath = Path.Combine(Environment.CurrentDirectory, "settings"); string[] settingsFiles = Directory.GetFiles(settingsPath, "*.xml"); if (settingsFiles.Length > 1) { frmSelectSetting frmPickSetting = new frmSelectSetting(); frmPickSetting.ShowDialog(this); if (frmPickSetting.DialogResult == DialogResult.Cancel) return; objCharacter.SettingsFile = frmPickSetting.SettingsFile; } else { string strSettingsFile = settingsFiles[0]; objCharacter.SettingsFile = Path.GetFileName(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 { frmKarmaMetatype frmSelectMetatype = new frmKarmaMetatype(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) { string strFilePath = Path.Combine(Environment.CurrentDirectory, "settings", "default.xml"); if (!File.Exists(strFilePath)) { if (MessageBox.Show(LanguageManager.Instance.GetString("Message_CharacterOptions_OpenOptions"), LanguageManager.Instance.GetString("MessageTitle_CharacterOptions_OpenOptions"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { frmOptions frmOptions = new frmOptions(); frmOptions.ShowDialog(); } } Character objCharacter = new Character(); string settingsPath = Path.Combine(Environment.CurrentDirectory, "settings"); string[] settingsFiles = Directory.GetFiles(settingsPath, "*.xml"); if (settingsFiles.Length > 1) { frmSelectSetting frmPickSetting = new frmSelectSetting(); frmPickSetting.ShowDialog(this); if (frmPickSetting.DialogResult == DialogResult.Cancel) return; objCharacter.SettingsFile = frmPickSetting.SettingsFile; } else { string strSettingsFile = settingsFiles[0]; objCharacter.SettingsFile = Path.GetFileName(strSettingsFile); } // Show the BP selection window. frmSelectBuildMethod frmBP = new frmSelectBuildMethod(objCharacter); frmBP.ShowDialog(); if (frmBP.DialogResult == DialogResult.Cancel) return; if (objCharacter.BuildMethod == CharacterBuildMethod.Karma || objCharacter.BuildMethod == CharacterBuildMethod.LifeModule) { frmKarmaMetatype frmSelectMetatype = new frmKarmaMetatype(objCharacter); frmSelectMetatype.ShowDialog(); if (frmSelectMetatype.DialogResult == DialogResult.Cancel) { return; } } // Show the Metatype selection window. else if (objCharacter.BuildMethod == CharacterBuildMethod.Priority || objCharacter.BuildMethod == CharacterBuildMethod.SumtoTen) { frmPriorityMetatype frmSelectMetatype = new frmPriorityMetatype(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> /// 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(Environment.CurrentDirectory, "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(Environment.CurrentDirectory, "settings"), "*.xml")[0]; strSettingsFile = strSettingsFile.Replace(Path.Combine(Environment.CurrentDirectory, "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; if (objCharacter.BuildMethod == CharacterBuildMethod.Karma || objCharacter.BuildMethod == CharacterBuildMethod.LifeModule) { frmKarmaMetatype frmSelectMetatype = new frmKarmaMetatype(objCharacter); frmSelectMetatype.ShowDialog(); if (frmSelectMetatype.DialogResult == DialogResult.Cancel) { return; } } // Show the Metatype selection window. else if (objCharacter.BuildMethod == CharacterBuildMethod.Priority) { frmPriorityMetatype frmSelectMetatype = new frmPriorityMetatype(objCharacter); frmSelectMetatype.ShowDialog(); if (frmSelectMetatype.DialogResult == DialogResult.Cancel) { return; } } else if (objCharacter.BuildMethod == CharacterBuildMethod.SumtoTen) { frmSumtoTenMetatype frmSumtoTenMetatype = new frmSumtoTenMetatype(objCharacter); frmSumtoTenMetatype.ShowDialog(); if (frmSumtoTenMetatype.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; }