Beispiel #1
0
        private void tsAddComplexFormOption_Click(object sender, EventArgs e)
        {
            try
            {
                if (treComplexForms.SelectedNode.Level == 0)
                {
                    MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectComplexForm"), LanguageManager.Instance.GetString("MessageTitle_SelectComplexForm"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }
            catch
            {
                MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectComplexForm"), LanguageManager.Instance.GetString("MessageTitle_SelectComplexForm"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (treComplexForms.SelectedNode.Level > 1)
                treComplexForms.SelectedNode = treComplexForms.SelectedNode.Parent;

            // Locate the Program that is selected in the tree.
            TechProgram objProgram = _objFunctions.FindTechProgram(treComplexForms.SelectedNode.Tag.ToString(), _objCharacter.TechPrograms);

            if (objProgram.CalculatedCapacity == 0)
            {
                MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotAddComplexFormOption"), LanguageManager.Instance.GetString("MessageTitle_CannotAddComplexFormOption"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            else
            {
                if (objProgram.Options.Count >= objProgram.CalculatedCapacity && !_objCharacter.IgnoreRules)
                {
                    MessageBox.Show(LanguageManager.Instance.GetString("Message_ConntAddComplexFormOptionLimit").Replace("{0}", objProgram.CalculatedCapacity.ToString()), LanguageManager.Instance.GetString("MessageTitle_CannotAddComplexFormOption"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }

            frmSelectProgramOption frmPickProgramOption = new frmSelectProgramOption(_objCharacter);
            frmPickProgramOption.ProgramName = objProgram.Name;
            frmPickProgramOption.ProgramCategory = objProgram.Category;
            frmPickProgramOption.ProgramTags = objProgram.Tags;
            frmPickProgramOption.ShowDialog(this);

            if (frmPickProgramOption.DialogResult == DialogResult.Cancel)
                return;

            XmlDocument objXmlDocument = XmlManager.Instance.Load("programs.xml");

            XmlNode objXmlOption = objXmlDocument.SelectSingleNode("/chummer/options/option[name = \"" + frmPickProgramOption.SelectedOption + "\"]");

            TreeNode objNode = new TreeNode();
            TechProgramOption objOption = new TechProgramOption(_objCharacter);
            objOption.Create(objXmlOption, _objCharacter, objNode);
            objNode.ContextMenuStrip = cmsComplexFormPlugin;
            if (objOption.InternalId == Guid.Empty.ToString())
                return;

            objProgram.Options.Add(objOption);

            treComplexForms.SelectedNode.Nodes.Add(objNode);
            treComplexForms.SelectedNode.Expand();

            UpdateCharacterInfo();
        }
Beispiel #2
0
        private void tsAddComplexFormOption_Click(object sender, EventArgs e)
        {
            try
            {
                if (treComplexForms.SelectedNode.Level == 0)
                {
                    MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectComplexForm"), LanguageManager.Instance.GetString("MessageTitle_SelectComplexForm"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }
            catch
            {
                MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectComplexForm"), LanguageManager.Instance.GetString("MessageTitle_SelectComplexForm"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (treComplexForms.SelectedNode.Level > 1)
                treComplexForms.SelectedNode = treComplexForms.SelectedNode.Parent;

            // Locate the Program that is selected in the tree.
            TechProgram objProgram = _objFunctions.FindTechProgram(treComplexForms.SelectedNode.Tag.ToString(), _objCharacter.TechPrograms);

            if (objProgram.CalculatedCapacity == 0)
            {
                MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotAddComplexFormOption"), LanguageManager.Instance.GetString("MessageTitle_CannotAddComplexFormOption"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            else
            {
                if (objProgram.Options.Count >= objProgram.CalculatedCapacity && !_objCharacter.IgnoreRules)
                {
                    MessageBox.Show(LanguageManager.Instance.GetString("Message_ConntAddComplexFormOptionLimit").Replace("{0}", objProgram.CalculatedCapacity.ToString()), LanguageManager.Instance.GetString("MessageTitle_CannotAddComplexFormOption"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }

            frmSelectProgramOption frmPickProgramOption = new frmSelectProgramOption(_objCharacter);
            frmPickProgramOption.ProgramName = objProgram.Name;
            frmPickProgramOption.ProgramCategory = objProgram.Category;
            frmPickProgramOption.ProgramTags = objProgram.Tags;
            frmPickProgramOption.ShowDialog(this);

            if (frmPickProgramOption.DialogResult == DialogResult.Cancel)
                return;

            // Make sure the character has enough Karma to improve the Attribute.
            int intKarmaCost = _objOptions.KarmaComplexFormOption;
            // Skillsofts Options only cost KarmaComplexFormSkillsoft Karma.
            if (objProgram.Category == "Skillsofts")
                intKarmaCost = _objOptions.KarmaComplexFormSkillsoft;
            if (intKarmaCost > _objCharacter.Karma)
            {
                MessageBox.Show(LanguageManager.Instance.GetString("Message_NotEnoughKarma"), LanguageManager.Instance.GetString("MessageTitle_NotEnoughKarma"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (!ConfirmKarmaExpense(LanguageManager.Instance.GetString("Message_ConfirmKarmaExpenseComplexFormOption").Replace("{0}", intKarmaCost.ToString())))
                return;

            XmlDocument objXmlDocument = XmlManager.Instance.Load("programs.xml");

            XmlNode objXmlOption = objXmlDocument.SelectSingleNode("/chummer/options/option[name = \"" + frmPickProgramOption.SelectedOption + "\"]");

            TreeNode objNode = new TreeNode();
            TechProgramOption objOption = new TechProgramOption(_objCharacter);
            objOption.Create(objXmlOption, _objCharacter, objNode);
            objNode.ContextMenuStrip = cmsComplexFormPlugin;
            if (objOption.InternalId == Guid.Empty.ToString())
                return;

            // Create the Karma expense.
            ExpenseLogEntry objExpense = new ExpenseLogEntry();
            objExpense.Create(intKarmaCost * -1, LanguageManager.Instance.GetString("String_ExpenseAddComplexFormOption") + " " + frmPickProgramOption.SelectedOption, ExpenseType.Karma, DateTime.Now);
            _objCharacter.ExpenseEntries.Add(objExpense);
            _objCharacter.Karma -= intKarmaCost;

            ExpenseUndo objUndo = new ExpenseUndo();
            objUndo.CreateKarma(KarmaExpenseType.AddComplexFormOption, objOption.InternalId);
            objExpense.Undo = objUndo;

            objProgram.Options.Add(objOption);

            treComplexForms.SelectedNode.Nodes.Add(objNode);
            treComplexForms.SelectedNode.Expand();

            UpdateCharacterInfo();

            _blnIsDirty = true;
            UpdateWindowTitle();
        }