Example #1
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(GlobalOptions.ApplicationPath(), "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(GlobalOptions.ApplicationPath(), "settings"), "*.xml")[0];
                strSettingsFile = strSettingsFile.Replace(Path.Combine(GlobalOptions.ApplicationPath(), "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.Priority)
            {
                // Show the Metatype selection window.
                frmMetatype frmSelectMetatype = new frmMetatype(objCharacter);
                frmSelectMetatype.ShowDialog();

                if (frmSelectMetatype.DialogResult == DialogResult.Cancel)
                    return;
            }
            else
            {
                //Show the Priority selection window.
                frmPriority frmSelectPriority = new frmPriority(objCharacter);
                frmSelectPriority.ShowDialog();

                if (frmSelectPriority.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[id = \"" + Constants.UnarmedAttack + "\"]");
                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;
        }
Example #2
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(GlobalOptions.ApplicationPath(), "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(GlobalOptions.ApplicationPath(), "settings"), "*.xml")[0];
                strSettingsFile           = strSettingsFile.Replace(Path.Combine(GlobalOptions.ApplicationPath(), "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.Priority)
            {
                // Show the Metatype selection window.
                frmMetatype frmSelectMetatype = new frmMetatype(objCharacter);
                frmSelectMetatype.ShowDialog();

                if (frmSelectMetatype.DialogResult == DialogResult.Cancel)
                {
                    return;
                }
            }
            else
            {
                //Show the Priority selection window.
                frmPriority frmSelectPriority = new frmPriority(objCharacter);
                frmSelectPriority.ShowDialog();

                if (frmSelectPriority.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[id = \"" + Constants.UnarmedAttack + "\"]");
                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;
        }