本文整理汇总了C#中Chummer.Character.Load方法的典型用法代码示例。如果您正苦于以下问题:C# Character.Load方法的具体用法?C# Character.Load怎么用?C# Character.Load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Chummer.Character
的用法示例。
在下文中一共展示了Character.Load方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: cmdPrint_Click
private void cmdPrint_Click(object sender, EventArgs e)
{
prgProgress.Value = 0;
prgProgress.Maximum = treCharacters.Nodes.Count;
// Write the Character information to a MemoryStream so we don't need to create any files.
MemoryStream objStream = new MemoryStream();
XmlTextWriter objWriter = new XmlTextWriter(objStream, Encoding.UTF8);
// Being the document.
objWriter.WriteStartDocument();
// <characters>
objWriter.WriteStartElement("characters");
// Fire the PrintToStream method for all of the characters in the list.
foreach (TreeNode objNode in treCharacters.Nodes)
{
Character objCharacter = new Character();
objCharacter.FileName = objNode.Tag.ToString();
objCharacter.Load();
objCharacter.PrintToStream(objStream, objWriter);
prgProgress.Value++;
Application.DoEvents();
}
// Finish the document and flush the Writer and Stream.
// </characters>
objWriter.WriteEndElement();
objWriter.WriteEndDocument();
objWriter.Flush();
objStream.Flush();
// Read the stream.
StreamReader objReader = new StreamReader(objStream);
objStream.Position = 0;
XmlDocument objCharacterXML = new XmlDocument();
// Put the stream into an XmlDocument and send it off to the Viewer.
string strXML = objReader.ReadToEnd();
objCharacterXML.LoadXml(strXML);
objWriter.Close();
// Set the ProgressBar back to 0.
prgProgress.Value = 0;
frmViewer frmViewCharacter = new frmViewer();
frmViewCharacter.CharacterXML = objCharacterXML;
frmViewCharacter.SelectedSheet = "Game Master Summary";
frmViewCharacter.ShowDialog();
}
示例2: PetControl_Load
private void PetControl_Load(object sender, EventArgs e)
{
this.Width = cmdDelete.Left + cmdDelete.Width;
lblMetatype.Text = "";
if (_objContact.FileName != string.Empty)
{
// Load the character to get their Metatype.
Character objPet = new Character();
objPet.FileName = _objContact.FileName;
objPet.Load();
lblMetatype.Text = objPet.Metatype;
if (objPet.Metavariant != string.Empty)
lblMetatype.Text += " (" + objPet.Metavariant + ")";
objPet = null;
}
}
示例3: LoadCharacter
/// <summary>
/// Loads the character
/// </summary>
/// <param name="fileName"></param>
private void LoadCharacter(string fileName)
{
if (File.Exists(fileName) && fileName.EndsWith("chum5"))
{
bool blnLoaded = false;
Character objCharacter = new Character();
objCharacter.FileName = fileName;
blnLoaded = objCharacter.Load();
if (!blnLoaded)
{
; // TODO edward setup error page
return; // we obviously cannot init
}
this.nudInit.Value = Int32.Parse(objCharacter.InitiativePasses);
this.txtName.Text = objCharacter.Name;
this.nudInitStart.Value = Int32.Parse(objCharacter.Initiative.Split(' ')[0]);
this._character = objCharacter;
}
}
示例4: LoadCharacter
/// <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);
}
}
示例5: mnuSpecialPossess_Click
private void mnuSpecialPossess_Click(object sender, EventArgs e)
{
// Make sure the Spirit has been saved first.
if (_blnIsDirty)
{
if (MessageBox.Show(LanguageManager.Instance.GetString("Message_PossessionSave"), LanguageManager.Instance.GetString("MessageTitle_Possession"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.No)
return;
}
// Prompt the user to select a save file to possess.
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "Chummer5 Files (*.chum5)|*.chum5|All Files (*.*)|*.*";
if (openFileDialog.ShowDialog(this) == DialogResult.OK)
{
Character objVessel = new Character();
objVessel.FileName = openFileDialog.FileName;
objVessel.Load();
// Make sure the Vessel is in Career Mode.
if (!objVessel.Created)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_VesselInCareerMode"), LanguageManager.Instance.GetString("MessageTitle_Possession"), MessageBoxButtons.OK, MessageBoxIcon.Error);
objVessel = null;
return;
}
// Load the Spirit's save file into a new Merge character.
Character objMerge = new Character();
objMerge.FileName = _objCharacter.FileName;
objMerge.Load();
objMerge.Possessed = true;
objMerge.Alias = objVessel.Alias + " (" + LanguageManager.Instance.GetString("String_Possessed") + ")";
// Give the Critter the Immunity to Normal Weapons Power if they don't already have it.
bool blnHasImmunity = false;
foreach (CritterPower objCritterPower in objMerge.CritterPowers)
{
if (objCritterPower.Name == "Immunity" && objCritterPower.Extra == "Normal Weapons")
{
blnHasImmunity = true;
break;
}
}
if (!blnHasImmunity)
{
XmlDocument objPowerDoc = new XmlDocument();
objPowerDoc = XmlManager.Instance.Load("critterpowers.xml");
XmlNode objPower = objPowerDoc.SelectSingleNode("/chummer/powers/power[name = \"Immunity\"]");
CritterPower objCritterPower = new CritterPower(objMerge);
TreeNode objDummy = new TreeNode();
objCritterPower.Create(objPower, objMerge, objDummy, 0, "Normal Weapons");
objMerge.CritterPowers.Add(objCritterPower);
}
// Add the Vessel's Physical Attributes to the Spirit's Force.
objMerge.BOD.MetatypeMaximum = objVessel.BOD.Value + objMerge.MAG.TotalValue;
objMerge.BOD.Value = objVessel.BOD.Value + objMerge.MAG.TotalValue;
objMerge.AGI.MetatypeMaximum = objVessel.AGI.Value + objMerge.MAG.TotalValue;
objMerge.AGI.Value = objVessel.AGI.Value + objMerge.MAG.TotalValue;
objMerge.REA.MetatypeMaximum = objVessel.REA.Value + objMerge.MAG.TotalValue;
objMerge.REA.Value = objVessel.REA.Value + objMerge.MAG.TotalValue;
objMerge.STR.MetatypeMaximum = objVessel.STR.Value + objMerge.MAG.TotalValue;
objMerge.STR.Value = objVessel.STR.Value + objMerge.MAG.TotalValue;
// Copy any Lifestyles the Vessel has.
foreach (Lifestyle objLifestyle in objVessel.Lifestyles)
objMerge.Lifestyles.Add(objLifestyle);
// Copy any Armor the Vessel has.
foreach (Armor objArmor in objVessel.Armor)
{
objMerge.Armor.Add(objArmor);
CopyArmorImprovements(objVessel, objMerge, objArmor);
}
// Copy any Gear the Vessel has.
foreach (Gear objGear in objVessel.Gear)
{
objMerge.Gear.Add(objGear);
CopyGearImprovements(objVessel, objMerge, objGear);
}
// Copy any Cyberware/Bioware the Vessel has.
foreach (Cyberware objCyberware in objVessel.Cyberware)
{
objMerge.Cyberware.Add(objCyberware);
CopyCyberwareImprovements(objVessel, objMerge, objCyberware);
}
// Copy any Weapons the Vessel has.
foreach (Weapon objWeapon in objVessel.Weapons)
objMerge.Weapons.Add(objWeapon);
// Copy and Vehicles the Vessel has.
foreach (Vehicle objVehicle in objVessel.Vehicles)
objMerge.Vehicles.Add(objVehicle);
// Copy the character info.
objMerge.Sex = objVessel.Sex;
//.........这里部分代码省略.........
示例6: mnuSpecialPossessInanimate_Click
private void mnuSpecialPossessInanimate_Click(object sender, EventArgs e)
{
// Make sure the Spirit has been saved first.
if (_blnIsDirty)
{
if (MessageBox.Show(LanguageManager.Instance.GetString("Message_PossessionSave"), LanguageManager.Instance.GetString("MessageTitle_Possession"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.No)
return;
}
// Prompt the user to select an inanimate Vessel.
XmlDocument objVesselDoc = XmlManager.Instance.Load("vessels.xml");
XmlNodeList objXmlMetatypeList = objVesselDoc.SelectNodes("/chummer/metatypes/metatype");
List<ListItem> lstMetatype = new List<ListItem>();
foreach (XmlNode objXmlMetatype in objXmlMetatypeList)
{
ListItem objItem = new ListItem();
objItem.Value = objXmlMetatype["name"].InnerText;
if (objXmlMetatype["translate"] != null)
objItem.Name = objXmlMetatype["translate"].InnerText;
else
objItem.Name = objXmlMetatype["name"].InnerText;
lstMetatype.Add(objItem);
}
frmSelectItem frmSelectVessel = new frmSelectItem();
frmSelectVessel.GeneralItems = lstMetatype;
frmSelectVessel.ShowDialog(this);
if (frmSelectVessel.DialogResult == DialogResult.Cancel)
return;
// Load the Spirit's save file into a new Merge character.
Character objMerge = new Character();
objMerge.FileName = _objCharacter.FileName;
objMerge.Load();
objMerge.Possessed = true;
objMerge.Alias = frmSelectVessel.SelectedItem + " (" + LanguageManager.Instance.GetString("String_Possessed") + ")";
// Get the Node for the selected Vessel.
XmlNode objSelected = objVesselDoc.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + frmSelectVessel.SelectedItem + "\"]");
// Get the Attribute Modifiers for the Vessel.
int intBOD = Convert.ToInt32(objSelected["bodmin"].InnerText);
int intAGI = Convert.ToInt32(objSelected["agimin"].InnerText);
int intREA = Convert.ToInt32(objSelected["reamin"].InnerText);
int intSTR = Convert.ToInt32(objSelected["strmin"].InnerText);
// Add the Attribute modifiers, making sure that none of them go below 1.
int intSetBOD = objMerge.MAG.TotalValue + intBOD;
int intSetAGI = objMerge.MAG.TotalValue + intAGI;
int intSetREA = objMerge.MAG.TotalValue + intREA;
int intSetSTR = objMerge.MAG.TotalValue + intSTR;
objMerge.BOD.MetatypeMinimum += intBOD;
if (objMerge.BOD.MetatypeMinimum < 1)
objMerge.BOD.MetatypeMinimum = 1;
objMerge.BOD.MetatypeMaximum += intBOD;
if (objMerge.BOD.MetatypeMaximum < 1)
objMerge.BOD.MetatypeMaximum = 1;
objMerge.BOD.Value = intSetBOD;
if (objMerge.BOD.Value < 1)
objMerge.BOD.Value = 1;
objMerge.AGI.MetatypeMinimum += intAGI;
if (objMerge.AGI.MetatypeMinimum < 1)
objMerge.AGI.MetatypeMinimum = 1;
objMerge.AGI.MetatypeMaximum += intAGI;
if (objMerge.AGI.MetatypeMaximum < 1)
objMerge.AGI.MetatypeMaximum = 1;
objMerge.AGI.Value = intSetAGI;
if (objMerge.AGI.Value < 1)
objMerge.AGI.Value = 1;
objMerge.REA.MetatypeMinimum += intREA;
if (objMerge.REA.MetatypeMinimum < 1)
objMerge.REA.MetatypeMinimum = 1;
objMerge.REA.MetatypeMaximum += intREA;
if (objMerge.REA.MetatypeMaximum < 1)
objMerge.REA.MetatypeMaximum = 1;
objMerge.REA.Value = intSetREA;
if (objMerge.REA.Value < 1)
objMerge.REA.Value = 1;
objMerge.STR.MetatypeMinimum += intSTR;
if (objMerge.STR.MetatypeMinimum < 1)
objMerge.STR.MetatypeMinimum = 1;
objMerge.STR.MetatypeMaximum += intSTR;
if (objMerge.STR.MetatypeMaximum < 1)
objMerge.STR.MetatypeMaximum = 1;
objMerge.STR.Value = intSetSTR;
if (objMerge.STR.Value < 1)
objMerge.STR.Value = 1;
// Update the Movement if the Vessel has one.
if (objSelected["movement"] != null)
objMerge.Movement = objSelected["movement"].InnerText;
// Add any additional Critter Powers the Vessel grants.
if (objSelected["powers"] != null)
{
//.........这里部分代码省略.........
示例7: tsAttachCharacter_Click
private void tsAttachCharacter_Click(object sender, EventArgs e)
{
// Prompt the user to select a save file to associate with this Contact.
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "Chummer Files (*.chum5)|*.chum5|All Files (*.*)|*.*";
if (openFileDialog.ShowDialog(this) == DialogResult.OK)
{
_objContact.FileName = openFileDialog.FileName;
tipTooltip.SetToolTip(imgLink, LanguageManager.Instance.GetString("Tip_Contact_OpenFile"));
// Load the character to get their Metatype.
Character objPet = new Character();
objPet.FileName = _objContact.FileName;
objPet.Load();
lblMetatype.Text = objPet.Metatype;
if (objPet.Metavariant != string.Empty)
lblMetatype.Text += " (" + objPet.Metavariant + ")";
objPet = null;
// Set the relative path.
Uri uriApplication = new Uri(@Environment.CurrentDirectory);
Uri uriFile = new Uri(@_objContact.FileName);
Uri uriRelative = uriApplication.MakeRelativeUri(uriFile);
_objContact.RelativeFileName = "../" + uriRelative.ToString();
FileNameChanged(this);
}
}