Beispiel #1
0
 private void chkAutoBackstory_CheckedChanged(object sender, EventArgs e)
 {
     _objCharacter.Options.AutomaticBackstory = chkAutoBackstory.Checked;
     if (chkAutoBackstory.Checked)
     {
         if (_objStoryBuilder == null) _objStoryBuilder = new StoryBuilder(_objCharacter);
         txtBackground.Text = _objStoryBuilder.GetStory();
     }
 }
Beispiel #2
0
		private void btnCreateBackstory_Click(object sender, EventArgs e)
		{
			if (_objStoryBuilder == null) _objStoryBuilder = new StoryBuilder(_objCharacter);
			txtBackground.Text = _objStoryBuilder.GetStory();
		}
Beispiel #3
0
        private void cmdLifeModule_Click(object sender, EventArgs e)
        {
            XmlDocument xdoc = XmlManager.Instance.Load("lifemodules.xml");

            XmlNodeList xnodes = xdoc.SelectNodes("chummer/stages/stage");
            //from 1 to second highest life module order possible (ye hardcoding is bad, but extra stage is a niche case)
            int i;
            for (i = 1; i < 5; i++)
            {
                XmlNode node = xdoc.SelectSingleNode("chummer/stages/stage[@order = \"" + i + "\"]");
                if (node == null)
                {
                    i--;
                    break;
                }
                Quality q = _objCharacter.Qualities.Find(x => (
                    x.Type == QualityType.LifeModule &&
                    x.Stage == node.InnerText
                ));
                if (q == null)
                {
                    break;
                }
            }
            //i--; //Counter last increment
            frmSelectLifeModule selectLifeModule = new frmSelectLifeModule(_objCharacter, i);
            selectLifeModule.ShowDialog(this);

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

            XmlNode objXmlLifeModule = selectLifeModule.SelectedNode;

            TreeNode objNode = new TreeNode();
            List<Weapon> objWeapons = new List<Weapon>();
            List<TreeNode> objWeaponNodes = new List<TreeNode>();
            Quality objLifeModule = new Quality(_objCharacter);

            objLifeModule.Create(objXmlLifeModule, _objCharacter, QualitySource.LifeModule, objNode, objWeapons, objWeaponNodes);
            objNode.ContextMenuStrip = cmsQuality; //Think this is responsible for the "add notes" menu. Think
            if (objLifeModule.InternalId == Guid.Empty.ToString())
                return;

            //Is there any reason not to add it?
            if (true)
            {
                treQualities.Nodes[2].Nodes.Add(objNode);
                treQualities.Nodes[2].Expand();

                _objCharacter.Qualities.Add(objLifeModule);

                foreach (Weapon objWeapon in objWeapons)
                    _objCharacter.Weapons.Add(objWeapon);

                foreach (TreeNode objWeaponNode in  objWeaponNodes)
                {
                    objWeaponNode.ContextMenuStrip = cmsWeapon;
                    treWeapons.Nodes[0].Nodes.Add(objWeaponNode);
                    treWeapons.Nodes[0].Expand();
                }

                if (objXmlLifeModule.SelectNodes("addqualities/addquality").Count > 0)
                {
                    XmlDocument objQualityDocument = XmlManager.Instance.Load("qualities.xml");

                    foreach (XmlNode objXmlAddQuality in objXmlLifeModule.SelectNodes("addqualities/addquality"))
                    {
                        XmlNode objXmlSelectedQuality =
                            objQualityDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" +
                                                            objXmlAddQuality.InnerText + "\"]");
                        Quality objSubQuality = AddQuality(objXmlAddQuality, objXmlSelectedQuality, objWeapons,
                            objWeaponNodes);
                        if (objSubQuality != null)
                        {
                            _objCharacter.Qualities.Add(objSubQuality);
                        }
                    }
                }

                if (chkAutoBackstory.Checked)
                {
                    if(_objStoryBuilder == null) _objStoryBuilder = new StoryBuilder(_objCharacter);
                    txtBackground.Text = _objStoryBuilder.GetStory();
                }
            }
            else
            {
                //If not add, fallback (Dead code as we don't check for exceeding karma
                //Until validation
                _objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.Quality, objLifeModule.InternalId);
            }

            //Stupid hardcoding but no sane way
            //To do group skills (not that anything else is sane)

            foreach (Control control in panSkillGroups.Controls)
            {
                SkillGroupControl sgc = (SkillGroupControl) control;
                if (sgc != null)
                {
                    sgc.BaseRating = _objImprovementManager.ValueOf(Improvement.ImprovementType.SkillGroupLevel, false,
                        sgc.SkillGroupObject.Name);
            }
            }

            _objFunctions.SortTree(treQualities);
            UpdateCharacterInfo();
            RefreshContacts();
            _blnIsDirty = true;
            UpdateWindowTitle();
            RefreshKnowledgeSkills();

            if(selectLifeModule.AddAgain)
                cmdLifeModule_Click(sender, e);
        }