Ejemplo n.º 1
0
        private void AddCyberwareSuite(Improvement.ImprovementSource objSource)
        {
            frmSelectCyberwareSuite frmPickCyberwareSuite = new frmSelectCyberwareSuite(objSource, _objCharacter);
            frmPickCyberwareSuite.ShowDialog(this);

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

            string strType = "";
            int intParentNode = 0;
            if (objSource == Improvement.ImprovementSource.Cyberware)
            {
                strType = "cyberware";
                intParentNode = 0;
            }
            else
            {
                strType = "bioware";
                intParentNode = 1;
            }
            XmlDocument objXmlDocument = XmlManager.Instance.Load(strType + ".xml");

            XmlNode objXmlSuite = objXmlDocument.SelectSingleNode("/chummer/suites/suite[name = \"" + frmPickCyberwareSuite.SelectedSuite + "\"]");
            Cyberware objTemp = new Cyberware(_objCharacter);
            Grade objGrade = new Grade();
            objGrade = objTemp.ConvertToCyberwareGrade(objXmlSuite["grade"].InnerText, objSource);

            // Run through each of the items in the Suite and add them to the character.
            foreach (XmlNode objXmlItem in objXmlSuite.SelectNodes(strType + "s/" + strType))
            {
                XmlNode objXmlCyberware = objXmlDocument.SelectSingleNode("/chummer/" + strType + "s/" + strType + "[name = \"" + objXmlItem["name"].InnerText + "\"]");
                TreeNode objNode = new TreeNode();
                int intRating = 0;

                if (objXmlItem["rating"] != null)
                    intRating = Convert.ToInt32(objXmlItem["rating"].InnerText);

                objNode = CreateSuiteCyberware(objXmlItem, objXmlCyberware, objGrade, intRating, true, objSource, strType, null);

                objNode.Expand();
                treCyberware.Nodes[intParentNode].Nodes.Add(objNode);
                treCyberware.Nodes[intParentNode].Expand();
            }

            _blnIsDirty = true;
            UpdateWindowTitle();
            UpdateCharacterInfo();
        }
Ejemplo n.º 2
0
        private void AddCyberwareSuite(Improvement.ImprovementSource objSource)
        {
            frmSelectCyberwareSuite frmPickCyberwareSuite = new frmSelectCyberwareSuite(objSource, _objCharacter);
            frmPickCyberwareSuite.ShowDialog(this);

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

            int intCost = frmPickCyberwareSuite.TotalCost;
            if (intCost > _objCharacter.Nuyen)
            {
                MessageBox.Show(LanguageManager.Instance.GetString("Message_NotEnoughNuyen"), LanguageManager.Instance.GetString("MessageTitle_NotEnoughNuyen"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            else
            {
                // Create the Expense Log Entry.
                ExpenseLogEntry objExpense = new ExpenseLogEntry();
                objExpense.Create(intCost * -1, LanguageManager.Instance.GetString("String_ExpensePurchaseCyberwareSuite") + " " + frmPickCyberwareSuite.SelectedSuite, ExpenseType.Nuyen, DateTime.Now);
                _objCharacter.ExpenseEntries.Add(objExpense);
                _objCharacter.Nuyen -= intCost;
            }

            string strType = "";
            int intParentNode = 0;
            if (objSource == Improvement.ImprovementSource.Cyberware)
            {
                strType = "cyberware";
                intParentNode = 0;
            }
            else
            {
                strType = "bioware";
                intParentNode = 1;
            }
            XmlDocument objXmlDocument = XmlManager.Instance.Load(strType + ".xml");

            XmlNode objXmlSuite = objXmlDocument.SelectSingleNode("/chummer/suites/suite[name = \"" + frmPickCyberwareSuite.SelectedSuite + "\"]");
            Cyberware objTemp = new Cyberware(_objCharacter);
            Grade objGrade = new Grade();
            objGrade = objTemp.ConvertToCyberwareGrade(objXmlSuite["grade"].InnerText, objSource);

            // Run through each of the items in the Suite and add them to the character.
            foreach (XmlNode objXmlItem in objXmlSuite.SelectNodes(strType + "s/" + strType))
            {
                XmlNode objXmlCyberware = objXmlDocument.SelectSingleNode("/chummer/" + strType + "s/" + strType + "[name = \"" + objXmlItem["name"].InnerText + "\"]");
                TreeNode objNode = new TreeNode();
                int intRating = 0;

                if (objXmlItem["rating"] != null)
                    intRating = Convert.ToInt32(objXmlItem["rating"].InnerText);

                objNode = CreateSuiteCyberware(objXmlItem, objXmlCyberware, objGrade, intRating, true, objSource, strType, null);

                objNode.Expand();
                treCyberware.Nodes[intParentNode].Nodes.Add(objNode);
                treCyberware.Nodes[intParentNode].Expand();
            }

            _blnIsDirty = true;
            UpdateWindowTitle();
            UpdateCharacterInfo();
        }