Beispiel #1
0
        /// <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);
                objCharacter.Weapons.Add(objWeapon);
            }
            catch
            {
            }

            frmCreate frmNewCharacter = new frmCreate(objCharacter);

            frmNewCharacter.MdiParent   = this;
            frmNewCharacter.WindowState = FormWindowState.Maximized;
            frmNewCharacter.Show();

            objCharacter.CharacterNameChanged += objCharacter_CharacterNameChanged;
        }
Beispiel #2
0
        /// <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;
            }

			//moving this belove the display select fixes #304, but prevents switch between 
			//techno and magican, arguably a worse bug.
			//needs a "restore state" function, but can't be arsed to implement atm
            //Revert all Special Qualities
            foreach (Quality objQuality in _objCharacter.Qualities)
            {
                switch (objQuality.Name.ToString())
                {
                    case "Magician":
                        _objCharacter.MAGEnabled = false;
                        _objCharacter.MagicianEnabled = false;
                        break;
                    case "Aspected Magician":
                        _objCharacter.MAGEnabled = false;
                        _objCharacter.MagicianEnabled = false;
                        break;
                    case "Adept":
                        _objCharacter.MAGEnabled = false;
                        _objCharacter.AdeptEnabled = false;
                        break;
                    case "Mystic Adept":
                        _objCharacter.MAGEnabled = false;
                        _objCharacter.MagicianEnabled = false;
                        _objCharacter.AdeptEnabled = false;
                        break;
                    case "Technomancer":
                        _objCharacter.RESEnabled = false;
                        _objCharacter.TechnomancerEnabled = false;
                        break;
                    default:
                        break;
                }
            }


            int intEssenceLoss = 0;
            if (!_objOptions.ESSLossReducesMaximumOnly)
                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 = Math.Max(_objCharacter.MAG.Value - _objCharacter.MAG.MetatypeMinimum, 0);
	        int intRES = Math.Max(_objCharacter.RES.Value - _objCharacter.RES.MetatypeMinimum, 0);

            // 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);
            }

            if (_objCharacter.BuildMethod == CharacterBuildMethod.Priority || _objCharacter.BuildMethod == CharacterBuildMethod.SumtoTen)
            {
                frmPriorityMetatype frmSelectMetatype = new frmPriorityMetatype(_objCharacter);
				frmSelectMetatype.Attributes = _objCharacter.AttributesPriority[0].ToString();
				frmSelectMetatype.Skills = _objCharacter.SkillsPriority[0].ToString();
				frmSelectMetatype.Resources = _objCharacter.ResourcesPriority[0].ToString();
				frmSelectMetatype.Special = _objCharacter.SpecialPriority[0].ToString();
				frmSelectMetatype.Metatype = _objCharacter.MetatypePriority[0].ToString();
				frmSelectMetatype.ShowDialog(this);
				if (frmSelectMetatype.DialogResult == DialogResult.Cancel)
                    return;
            }
            else
            {
                frmKarmaMetatype frmSelectMetatype = new frmKarmaMetatype(_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.Implemented)
				{
					objNode.ForeColor = Color.Red;
				}
                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;
            if (_objCharacter.BuildMethod == CharacterBuildMethod.Karma)
            {
                nudKMAG.Maximum = _objCharacter.MAG.TotalMaximum + intEssenceLoss;
                nudKRES.Maximum = _objCharacter.RES.TotalMaximum + intEssenceLoss;
            }
            nudMAG.Maximum = _objCharacter.MAG.TotalMaximum + intEssenceLoss;
            nudRES.Maximum = _objCharacter.RES.TotalMaximum + intEssenceLoss;

            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)
            {
                if (nudMAG.Maximum < 1)
                    nudMAG.Maximum = 1;
                if (nudMAG.Minimum < 1)
                    nudMAG.Minimum = 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.Karma && _objOptions.MetatypeCostsKarma)
                lblKarmaMetatypeBP.Text = (_objCharacter.MetatypeBP * _objOptions.MetatypeCostsKarmaMultiplier).ToString() + " " + LanguageManager.Instance.GetString("String_Karma");
            else
                lblKarmaMetatypeBP.Text = "0 " + LanguageManager.Instance.GetString("String_Karma");
            lblMetatypeBP.Text = "0 " + LanguageManager.Instance.GetString("String_Karma");

            string strToolTip = _objCharacter.Metatype;
            if (_objCharacter.Metavariant != "")
                strToolTip += " (" + _objCharacter.Metavariant + ")";
            strToolTip += " (" + _objCharacter.MetatypeBP.ToString() + ")";
            tipTooltip.SetToolTip(lblKarmaMetatypeBP, strToolTip);

            UpdateCharacterInfo();
        }
Beispiel #3
0
        /// <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;
        }
Beispiel #4
0
        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);
                objCharacter.Weapons.Add(objWeapon);
            }
            catch
            {
            }

            frmCreate frmNewCharacter = new frmCreate(objCharacter);

            frmNewCharacter.MdiParent   = this;
            frmNewCharacter.WindowState = FormWindowState.Maximized;
            frmNewCharacter.Show();

            objCharacter.CharacterNameChanged += objCharacter_CharacterNameChanged;
        }
Beispiel #5
0
        /// <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;
		}
Beispiel #6
0
		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;
		}
        private void cmdOK_Click(object sender, EventArgs e)
        {
            if (!(cboCharacterOption.SelectedValue is CharacterOptions objSelectedGameplayOption))
            {
                return;
            }
            CharacterBuildMethod eSelectedBuildMethod = objSelectedGameplayOption.BuildMethod;

            if (_blnForExistingCharacter && !_objCharacter.Created && _objCharacter.Options.BuildMethod == _objCharacter.EffectiveBuildMethod && eSelectedBuildMethod != _eStartingBuildMethod)
            {
                if (Program.MainForm.ShowMessageBox(this,
                                                    string.Format(GlobalOptions.CultureInfo, LanguageManager.GetString("Message_SelectBP_SwitchBuildMethods"),
                                                                  LanguageManager.GetString("String_" + eSelectedBuildMethod), LanguageManager.GetString("String_" + _eStartingBuildMethod)).WordWrap(),
                                                    LanguageManager.GetString("MessageTitle_SelectBP_SwitchBuildMethods"), MessageBoxButtons.YesNo,
                                                    MessageBoxIcon.Warning) != DialogResult.Yes)
                {
                    return;
                }
                string strOldCharacterOptionsKey = _objCharacter.CharacterOptionsKey;
                _objCharacter.CharacterOptionsKey = OptionsManager.LoadedCharacterOptions
                                                    .First(x => x.Value == objSelectedGameplayOption).Key;
                // If the character is loading, make sure we only switch build methods after we've loaded, otherwise we might cause all sorts of nastiness
                if (_objCharacter.IsLoading)
                {
                    _objCharacter.PostLoadMethods.Enqueue(SwitchBuildMethods);
                }
                else if (!SwitchBuildMethods())
                {
                    return;
                }

                bool SwitchBuildMethods()
                {
                    if (eSelectedBuildMethod.UsesPriorityTables())
                    {
                        using (frmPriorityMetatype frmSelectMetatype = new frmPriorityMetatype(_objCharacter))
                        {
                            frmSelectMetatype.ShowDialog(this);
                            if (frmSelectMetatype.DialogResult == DialogResult.Cancel)
                            {
                                _objCharacter.CharacterOptionsKey = strOldCharacterOptionsKey;
                                return(false);
                            }
                        }
                    }
                    else
                    {
                        using (frmKarmaMetatype frmSelectMetatype = new frmKarmaMetatype(_objCharacter))
                        {
                            frmSelectMetatype.ShowDialog(this);
                            if (frmSelectMetatype.DialogResult == DialogResult.Cancel)
                            {
                                _objCharacter.CharacterOptionsKey = strOldCharacterOptionsKey;
                                return(false);
                            }
                        }
                    }

                    if (_eStartingBuildMethod == CharacterBuildMethod.LifeModule)
                    {
                        _objCharacter.Qualities.RemoveAll(x => x.OriginSource == QualitySource.LifeModule);
                    }
                    return(true);
                }
            }
            else
            {
                _objCharacter.CharacterOptionsKey = OptionsManager.LoadedCharacterOptions
                                                    .First(x => x.Value == objSelectedGameplayOption).Key;
            }
            _objCharacter.IgnoreRules = chkIgnoreRules.Checked;
            DialogResult = DialogResult.OK;
        }
Beispiel #8
0
        /// <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;
        }
Beispiel #9
0
        /// <summary>
        /// Create a new character and show the Create Form.
        /// </summary>
        private void ShowNewForm(object sender, EventArgs e)
        {
            string strFilePath = Path.Combine(Application.StartupPath, "settings", "default.xml");

            if (!File.Exists(strFilePath))
            {
                if (MessageBox.Show(LanguageManager.GetString("Message_CharacterOptions_OpenOptions", GlobalOptions.Language), LanguageManager.GetString("MessageTitle_CharacterOptions_OpenOptions", GlobalOptions.Language), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    Cursor = Cursors.WaitCursor;
                    frmOptions frmOptions = new frmOptions();
                    frmOptions.ShowDialog();
                    Cursor = Cursors.Default;
                }
            }
            Cursor = Cursors.WaitCursor;
            Character objCharacter = new Character();
            string    settingsPath = Path.Combine(Application.StartupPath, "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();
            Cursor = Cursors.Default;

            if (frmBP.DialogResult == DialogResult.Cancel)
            {
                return;
            }
            if (objCharacter.BuildMethod == CharacterBuildMethod.Karma || objCharacter.BuildMethod == CharacterBuildMethod.LifeModule)
            {
                Cursor = Cursors.WaitCursor;
                frmKarmaMetatype frmSelectMetatype = new frmKarmaMetatype(objCharacter);
                frmSelectMetatype.ShowDialog();
                Cursor = Cursors.Default;

                if (frmSelectMetatype.DialogResult == DialogResult.Cancel)
                {
                    return;
                }
            }
            // Show the Metatype selection window.
            else if (objCharacter.BuildMethod == CharacterBuildMethod.Priority || objCharacter.BuildMethod == CharacterBuildMethod.SumtoTen)
            {
                Cursor = Cursors.WaitCursor;
                frmPriorityMetatype frmSelectMetatype = new frmPriorityMetatype(objCharacter);
                frmSelectMetatype.ShowDialog();
                Cursor = Cursors.Default;

                if (frmSelectMetatype.DialogResult == DialogResult.Cancel)
                {
                    return;
                }
            }
            Cursor = Cursors.WaitCursor;

            // Add the Unarmed Attack Weapon to the character.
            XmlDocument objXmlDocument = XmlManager.Load("weapons.xml");
            XmlNode     objXmlWeapon   = objXmlDocument.SelectSingleNode("/chummer/weapons/weapon[name = \"Unarmed Attack\"]");

            if (objXmlWeapon != null)
            {
                List <Weapon> lstWeapons = new List <Weapon>();
                Weapon        objWeapon  = new Weapon(objCharacter);
                objWeapon.Create(objXmlWeapon, lstWeapons);
                objWeapon.ParentID = Guid.NewGuid().ToString("D"); // Unarmed Attack can never be removed
                objCharacter.Weapons.Add(objWeapon);
                foreach (Weapon objLoopWeapon in lstWeapons)
                {
                    objCharacter.Weapons.Add(objLoopWeapon);
                }
            }

            frmCreate frmNewCharacter = new frmCreate(objCharacter)
            {
                MdiParent   = this,
                WindowState = FormWindowState.Maximized
            };

            frmNewCharacter.Show();

            objCharacter.CharacterNameChanged += objCharacter_CharacterNameChanged;
            Cursor = Cursors.Default;
        }