Ejemplo n.º 1
0
        private void cmdAddCritterPower_Click(object sender, EventArgs e)
        {
            // Make sure the Critter is allowed to have Optional Powers.
            XmlDocument objXmlDocument = XmlManager.Instance.Load("critters.xml");
            XmlNode objXmlCritter = objXmlDocument.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + _objCharacter.Metatype + "\"]");

            if (objXmlCritter == null)
            {
                objXmlDocument = XmlManager.Instance.Load("metatypes.xml");
                objXmlCritter = objXmlDocument.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + _objCharacter.Metatype + "\"]");
            }

            frmSelectCritterPower frmPickCritterPower = new frmSelectCritterPower(_objCharacter);
            frmPickCritterPower.ShowDialog(this);

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

            objXmlDocument = XmlManager.Instance.Load("critterpowers.xml");
            XmlNode objXmlPower = objXmlDocument.SelectSingleNode("/chummer/powers/power[name = \"" + frmPickCritterPower.SelectedPower + "\"]");
            TreeNode objNode = new TreeNode();
            CritterPower objPower = new CritterPower(_objCharacter);
            objPower.Create(objXmlPower, _objCharacter, objNode, frmPickCritterPower.SelectedRating);
            objPower.PowerPoints = frmPickCritterPower.PowerPoints;
            objNode.ContextMenuStrip = cmsCritterPowers;
            if (objPower.InternalId == Guid.Empty.ToString())
                return;

            _objCharacter.CritterPowers.Add(objPower);

            if (objPower.Category != "Weakness")
            {
                treCritterPowers.Nodes[0].Nodes.Add(objNode);
                treCritterPowers.Nodes[0].Expand();
            }
            else
            {
                treCritterPowers.Nodes[1].Nodes.Add(objNode);
                treCritterPowers.Nodes[1].Expand();
            }

            treCritterPowers.SortCustom();
            UpdateCharacterInfo();

            _blnIsDirty = true;
            UpdateWindowTitle();

            if (frmPickCritterPower.AddAgain)
                cmdAddCritterPower_Click(sender, e);
        }
Ejemplo n.º 2
0
        private void cmdAddCritterPower_Click(object sender, EventArgs e)
        {
            // Make sure the Critter is allowed to have Optional Powers.
            XmlDocument objXmlDocument = XmlManager.Instance.Load("critters.xml");
            XmlNode objXmlCritter = objXmlDocument.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + _objCharacter.Metatype + "\"]");

            if (objXmlCritter == null)
            {
                objXmlDocument = XmlManager.Instance.Load("metatypes.xml");
                objXmlCritter = objXmlDocument.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + _objCharacter.Metatype + "\"]");
            }

            frmSelectCritterPower frmPickCritterPower = new frmSelectCritterPower(_objCharacter);
            frmPickCritterPower.ShowDialog(this);

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

            objXmlDocument = XmlManager.Instance.Load("critterpowers.xml");
            XmlNode objXmlPower = objXmlDocument.SelectSingleNode("/chummer/powers/power[name = \"" + frmPickCritterPower.SelectedPower + "\"]");
            TreeNode objNode = new TreeNode();
            CritterPower objPower = new CritterPower(_objCharacter);
            objPower.Create(objXmlPower, _objCharacter, objNode, frmPickCritterPower.SelectedRating);
            objPower.PowerPoints = frmPickCritterPower.PowerPoints;
            objNode.ContextMenuStrip = cmsCritterPowers;
            if (objPower.InternalId == Guid.Empty.ToString())
                return;

            _objCharacter.CritterPowers.Add(objPower);

            if (objPower.Category != "Weakness")
            {
                treCritterPowers.Nodes[0].Nodes.Add(objNode);
                treCritterPowers.Nodes[0].Expand();
            }
            else
            {
                treCritterPowers.Nodes[1].Nodes.Add(objNode);
                treCritterPowers.Nodes[1].Expand();
            }

            // Determine if the Critter should have access to the Possession menu item.
            bool blnAllowPossession = false;
            foreach (CritterPower objCritterPower in _objCharacter.CritterPowers)
            {
                if (objCritterPower.Name == "Inhabitation" || objCritterPower.Name == "Possession")
                {
                    blnAllowPossession = true;
                    break;
                }
            }
            mnuSpecialPossess.Visible = blnAllowPossession;

            _objFunctions.SortTree(treCritterPowers);
            UpdateCharacterInfo();

            _blnIsDirty = true;
            UpdateWindowTitle();

            if (frmPickCritterPower.AddAgain)
                cmdAddCritterPower_Click(sender, e);
        }