Beispiel #1
0
        private void tsVehicleAddUnderbarrelWeapon_Click(object sender, EventArgs e)
        {
            // Attempt to locate the selected VehicleWeapon.
            bool blnWeaponFound = false;
            Vehicle objFoundVehicle = new Vehicle(_objCharacter);
            Weapon objSelectedWeapon = _objFunctions.FindVehicleWeapon(treVehicles.SelectedNode.Tag.ToString(), _objCharacter.Vehicles, out objFoundVehicle);
            if (objSelectedWeapon != null)
                blnWeaponFound = true;

            if (!blnWeaponFound)
            {
                MessageBox.Show(LanguageManager.Instance.GetString("Message_VehicleWeaponUnderbarrel"), LanguageManager.Instance.GetString("MessageTitle_VehicleWeaponUnderbarrel"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            frmSelectWeapon frmPickWeapon = new frmSelectWeapon(_objCharacter);
            frmPickWeapon.ShowDialog(this);

            // Make sure the dialogue window was not canceled.
            if (frmPickWeapon.DialogResult == DialogResult.Cancel)
                return;

            // Open the Weapons XML file and locate the selected piece.
            XmlDocument objXmlDocument = XmlManager.Instance.Load("weapons.xml");

            XmlNode objXmlWeapon = objXmlDocument.SelectSingleNode("/chummer/weapons/weapon[name = \"" + frmPickWeapon.SelectedWeapon + "\"]");

            TreeNode objNode = new TreeNode();
            Weapon objWeapon = new Weapon(_objCharacter);
            objWeapon.Create(objXmlWeapon, _objCharacter, objNode, cmsVehicleWeapon, cmsVehicleWeaponAccessory, cmsVehicleWeaponMod);
            objWeapon.VehicleMounted = true;
            objWeapon.IsUnderbarrelWeapon = true;
            objSelectedWeapon.UnderbarrelWeapons.Add(objWeapon);

            objNode.ContextMenuStrip = cmsVehicleWeapon;
            treVehicles.SelectedNode.Nodes.Add(objNode);
            treVehicles.SelectedNode.Expand();
            //treWeapons.SelectedNode = objNode;

            UpdateCharacterInfo();
        }
Beispiel #2
0
        private void tsWeaponAddUnderbarrel_Click(object sender, EventArgs e)
        {
            // Make sure a parent item is selected, then open the Select Accessory window.
            try
            {
                if (treWeapons.SelectedNode.Level == 0)
                {
                    MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectWeaponUnderbarrel"), LanguageManager.Instance.GetString("MessageTitle_SelectWeapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }
            catch
            {
                MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectWeaponUnderbarrel"), LanguageManager.Instance.GetString("MessageTitle_SelectWeapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

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

            // Get the information for the currently selected Weapon.
            foreach (Weapon objCharacterWeapon in _objCharacter.Weapons)
            {
                if (treWeapons.SelectedNode.Tag.ToString() == objCharacterWeapon.InternalId)
                {
                    if (objCharacterWeapon.InternalId == treWeapons.SelectedNode.Tag.ToString())
                    {
                        if (objCharacterWeapon.Cyberware)
                        {
                            MessageBox.Show(LanguageManager.Instance.GetString("Message_CyberwareUnderbarrel"), LanguageManager.Instance.GetString("MessageTitle_WeaponUnderbarrel"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                    }
                }
            }

            // Locate the Weapon that is selected in the tree.
            Weapon objSelectedWeapon = _objFunctions.FindWeapon(treWeapons.SelectedNode.Tag.ToString(), _objCharacter.Weapons);
            if (objSelectedWeapon == null)
                return;

            frmSelectWeapon frmPickWeapon = new frmSelectWeapon(_objCharacter);
            frmPickWeapon.ShowDialog(this);

            // Make sure the dialogue window was not canceled.
            if (frmPickWeapon.DialogResult == DialogResult.Cancel)
                return;

            // Open the Weapons XML file and locate the selected piece.
            XmlDocument objXmlDocument = XmlManager.Instance.Load("weapons.xml");

            XmlNode objXmlWeapon = objXmlDocument.SelectSingleNode("/chummer/weapons/weapon[name = \"" + frmPickWeapon.SelectedWeapon + "\"]");

            TreeNode objNode = new TreeNode();
            Weapon objWeapon = new Weapon(_objCharacter);
            objWeapon.Create(objXmlWeapon, _objCharacter, objNode, cmsWeapon, cmsWeaponAccessory, cmsWeaponMod);
            objWeapon.IsUnderbarrelWeapon = true;
            objSelectedWeapon.UnderbarrelWeapons.Add(objWeapon);

            objNode.ContextMenuStrip = cmsWeapon;
            treWeapons.SelectedNode.Nodes.Add(objNode);
            treWeapons.SelectedNode.Expand();
            //treWeapons.SelectedNode = objNode;

            UpdateCharacterInfo();
            RefreshSelectedWeapon();
        }
Beispiel #3
0
        private void tsVehicleAddWeaponWeapon_Click(object sender, EventArgs e)
        {
            VehicleMod objMod = new VehicleMod(_objCharacter);

            // Make sure that a Weapon Mount has been selected.
            try
            {
                // Attempt to locate the selected VehicleMod.
                Vehicle objFoundVehicle = new Vehicle(_objCharacter);
                objMod = _objFunctions.FindVehicleMod(treVehicles.SelectedNode.Tag.ToString(), _objCharacter.Vehicles, out objFoundVehicle);

                if (!objMod.Name.StartsWith("Weapon Mount") && !objMod.Name.StartsWith("Heavy Weapon Mount") && !objMod.Name.StartsWith("Mechanical Arm"))
                {
                    MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotAddWeapon"), LanguageManager.Instance.GetString("MessageTitle_CannotAddWeapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }
            catch
            {
                MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotAddWeapon"), LanguageManager.Instance.GetString("MessageTitle_CannotAddWeapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            frmSelectWeapon frmPickWeapon = new frmSelectWeapon(_objCharacter);
            frmPickWeapon.ShowDialog();

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

            // Open the Weapons XML file and locate the selected piece.
            XmlDocument objXmlDocument = XmlManager.Instance.Load("weapons.xml");

            XmlNode objXmlWeapon = objXmlDocument.SelectSingleNode("/chummer/weapons/weapon[name = \"" + frmPickWeapon.SelectedWeapon + "\"]");

            TreeNode objNode = new TreeNode();
            Weapon objWeapon = new Weapon(_objCharacter);
            objWeapon.Create(objXmlWeapon, _objCharacter, objNode, cmsVehicleWeapon, cmsVehicleWeaponAccessory, cmsVehicleWeaponMod);
            objWeapon.VehicleMounted = true;

            objMod.Weapons.Add(objWeapon);

            objNode.ContextMenuStrip = cmsVehicleWeapon;
            treVehicles.SelectedNode.Nodes.Add(objNode);
            treVehicles.SelectedNode.Expand();

            if (frmPickWeapon.AddAgain)
                tsVehicleAddWeaponWeapon_Click(sender, e);

            UpdateCharacterInfo();
        }
Beispiel #4
0
        private void cmdAddWeapon_Click(object sender, EventArgs e)
        {
            frmSelectWeapon frmPickWeapon = new frmSelectWeapon(_objCharacter);
            frmPickWeapon.ShowDialog(this);

            // Make sure the dialogue window was not canceled.
            if (frmPickWeapon.DialogResult == DialogResult.Cancel)
                return;

            // Open the Weapons XML file and locate the selected piece.
            XmlDocument objXmlDocument = XmlManager.Instance.Load("weapons.xml");

            XmlNode objXmlWeapon = objXmlDocument.SelectSingleNode("/chummer/weapons/weapon[name = \"" + frmPickWeapon.SelectedWeapon + "\"]");

            TreeNode objNode = new TreeNode();
            Weapon objWeapon = new Weapon(_objCharacter);
            objWeapon.Create(objXmlWeapon, _objCharacter, objNode, cmsWeapon, cmsWeaponAccessory, cmsWeaponMod);
            _objCharacter.Weapons.Add(objWeapon);

            objNode.ContextMenuStrip = cmsWeapon;
            treWeapons.Nodes[0].Nodes.Add(objNode);
            treWeapons.Nodes[0].Expand();
            treWeapons.SelectedNode = objNode;

            UpdateCharacterInfo();

            _blnIsDirty = true;
            UpdateWindowTitle();

            if (frmPickWeapon.AddAgain)
                cmdAddWeapon_Click(sender, e);
        }
Beispiel #5
0
        private void cmdAddWeapon_Click(object sender, EventArgs e)
        {
            frmSelectWeapon frmPickWeapon = new frmSelectWeapon(_objCharacter, true);
            frmPickWeapon.ShowDialog(this);

            // Make sure the dialogue window was not canceled.
            if (frmPickWeapon.DialogResult == DialogResult.Cancel)
                return;

            // Open the Weapons XML file and locate the selected piece.
            XmlDocument objXmlDocument = XmlManager.Instance.Load("weapons.xml");

            XmlNode objXmlWeapon = objXmlDocument.SelectSingleNode("/chummer/weapons/weapon[name = \"" + frmPickWeapon.SelectedWeapon + "\"]");

            TreeNode objNode = new TreeNode();
            Weapon objWeapon = new Weapon(_objCharacter);
            objWeapon.Create(objXmlWeapon, _objCharacter, objNode, cmsWeapon, cmsWeaponAccessory, cmsWeaponMod);

            int intCost = objWeapon.TotalCost;
            // Apply a markup if applicable.
            if (frmPickWeapon.Markup != 0)
            {
                double dblCost = Convert.ToDouble(intCost, GlobalOptions.Instance.CultureInfo);
                dblCost *= 1 + (Convert.ToDouble(frmPickWeapon.Markup, GlobalOptions.Instance.CultureInfo) / 100.0);
                intCost = Convert.ToInt32(dblCost);
            }

            // Multiply the cost if applicable.
            if (objWeapon.TotalAvail.EndsWith(LanguageManager.Instance.GetString("String_AvailRestricted")) && _objOptions.MultiplyRestrictedCost)
                intCost *= _objOptions.RestrictedCostMultiplier;
            if (objWeapon.TotalAvail.EndsWith(LanguageManager.Instance.GetString("String_AvailForbidden")) && _objOptions.MultiplyForbiddenCost)
                intCost *= _objOptions.ForbiddenCostMultiplier;

            // Check the item's Cost and make sure the character can afford it.
            if (!frmPickWeapon.FreeCost)
            {
                if (intCost > _objCharacter.Nuyen)
                {
                    MessageBox.Show(LanguageManager.Instance.GetString("Message_NotEnoughNuyen"), LanguageManager.Instance.GetString("MessageTitle_NotEnoughNuyen"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    if (frmPickWeapon.AddAgain)
                        cmdAddWeapon_Click(sender, e);

                    return;
                }
                else
                {
                    // Create the Expense Log Entry.
                    ExpenseLogEntry objExpense = new ExpenseLogEntry();
                    objExpense.Create(intCost * -1, LanguageManager.Instance.GetString("String_ExpensePurchaseWeapon") + " " + objWeapon.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
                    _objCharacter.ExpenseEntries.Add(objExpense);
                    _objCharacter.Nuyen -= intCost;

                    ExpenseUndo objUndo = new ExpenseUndo();
                    objUndo.CreateNuyen(NuyenExpenseType.AddWeapon, objWeapon.InternalId);
                    objExpense.Undo = objUndo;
                }
            }

            _objCharacter.Weapons.Add(objWeapon);

            objNode.ContextMenuStrip = cmsWeapon;
            treWeapons.Nodes[0].Nodes.Add(objNode);
            treWeapons.Nodes[0].Expand();
            treWeapons.SelectedNode = objNode;

            UpdateCharacterInfo();

            _blnIsDirty = true;
            UpdateWindowTitle();

            if (frmPickWeapon.AddAgain)
                cmdAddWeapon_Click(sender, e);
        }
Beispiel #6
0
        private void tsWeaponAddUnderbarrel_Click(object sender, EventArgs e)
        {
            // Make sure a parent item is selected, then open the Select Accessory window.
            try
            {
                if (treWeapons.SelectedNode.Level == 0)
                {
                    MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectWeaponAccessory"), LanguageManager.Instance.GetString("MessageTitle_SelectWeapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }
            catch
            {
                MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectWeaponAccessory"), LanguageManager.Instance.GetString("MessageTitle_SelectWeapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

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

            // Get the information for the currently selected Weapon.
            foreach (Weapon objCharacterWeapon in _objCharacter.Weapons)
            {
                if (treWeapons.SelectedNode.Tag.ToString() == objCharacterWeapon.InternalId)
                {
                    if (objCharacterWeapon.InternalId == treWeapons.SelectedNode.Tag.ToString())
                    {
                        if (objCharacterWeapon.Category.StartsWith("Cyberware"))
                        {
                            MessageBox.Show(LanguageManager.Instance.GetString("Message_CyberwareUnderbarrel"), LanguageManager.Instance.GetString("MessageTitle_WeaponUnderbarrel"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                    }
                }
            }

            // Locate the Weapon that is selected in the tree.
            Weapon objSelectedWeapon = (Weapon)_objFunctions.FindEquipment(treWeapons.SelectedNode.Tag.ToString(), _objCharacter.Weapons, typeof(Weapon));
            if (objSelectedWeapon == null)
                return;

            frmSelectWeapon frmPickWeapon = new frmSelectWeapon(_objCharacter, true);
            frmPickWeapon.ShowDialog(this);

            // Make sure the dialogue window was not canceled.
            if (frmPickWeapon.DialogResult == DialogResult.Cancel)
                return;

            // Open the Weapons XML file and locate the selected piece.
            XmlDocument objXmlDocument = XmlManager.Instance.Load("weapons.xml");

            XmlNode objXmlWeapon = objXmlDocument.SelectSingleNode("/chummer/weapons/weapon[id = \"" + frmPickWeapon.SelectedWeapon + "\"]");

            TreeNode objNode = new TreeNode();
            Weapon objWeapon = new Weapon(_objCharacter);
            objWeapon.Create(objXmlWeapon, _objCharacter, objNode, cmsWeapon, cmsWeaponAccessory, cmsWeapon);
            objWeapon.IsUnderbarrelWeapon = true;

            int intCost = objWeapon.TotalCost;
            // Apply a markup if applicable.
            if (frmPickWeapon.Markup != 0)
            {
                double dblCost = Convert.ToDouble(intCost, GlobalOptions.Instance.CultureInfo);
                dblCost *= 1 + (Convert.ToDouble(frmPickWeapon.Markup, GlobalOptions.Instance.CultureInfo) / 100.0);
                intCost = Convert.ToInt32(dblCost);
            }

            // Check the item's Cost and make sure the character can afford it.
            if (!frmPickWeapon.FreeCost)
            {
                if (intCost > _objCharacter.Nuyen)
                {
                    MessageBox.Show(LanguageManager.Instance.GetString("Message_NotEnoughNuyen"), LanguageManager.Instance.GetString("MessageTitle_NotEnoughNuyen"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    if (frmPickWeapon.AddAgain)
                        cmdAddWeapon_Click(sender, e);

                    return;
                }
                else
                {
                    // Create the Expense Log Entry.
                    ExpenseLogEntry objExpense = new ExpenseLogEntry();
                    objExpense.Create(intCost * -1, LanguageManager.Instance.GetString("String_ExpensePurchaseWeapon") + " " + objWeapon.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
                    _objCharacter.ExpenseEntries.Add(objExpense);
                    _objCharacter.Nuyen -= intCost;

                    ExpenseUndo objUndo = new ExpenseUndo();
                    objUndo.CreateNuyen(NuyenExpenseType.AddWeapon, objWeapon.InternalId);
                    objExpense.Undo = objUndo;
                }
            }

            objSelectedWeapon.Weapons.Add(objWeapon);

            objNode.ContextMenuStrip = cmsWeapon;
            treWeapons.SelectedNode.Nodes.Add(objNode);
            treWeapons.SelectedNode.Expand();
            treWeapons.SelectedNode = objNode;//

            UpdateCharacterInfo();
            RefreshSelectedWeapon();

            _blnIsDirty = true;
            UpdateWindowTitle();
        }
Beispiel #7
0
        private void tsVehicleAddWeaponWeapon_Click(object sender, EventArgs e)
        {
            VehicleMod objMod = new VehicleMod(_objCharacter);

            // Make sure that a Weapon Mount has been selected.
            try
            {
                // Attempt to locate the selected VehicleMod.
                objMod = (VehicleMod)_objFunctions.FindEquipment(treVehicles.SelectedNode.Tag.ToString(), _objCharacter.Vehicles, typeof(VehicleMod));

                if (!objMod.WeaponMount)
                {
                    MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotAddWeapon"), LanguageManager.Instance.GetString("MessageTitle_CannotAddWeapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }
            catch
            {
                MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotAddWeapon"), LanguageManager.Instance.GetString("MessageTitle_CannotAddWeapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            frmSelectWeapon frmPickWeapon = new frmSelectWeapon(_objCharacter, true);
            frmPickWeapon.ShowDialog();

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

            // Open the Weapons XML file and locate the selected piece.
            XmlDocument objXmlDocument = XmlManager.Instance.Load("weapons.xml");

            XmlNode objXmlWeapon = objXmlDocument.SelectSingleNode("/chummer/weapons/weapon[id = \"" + frmPickWeapon.SelectedWeapon + "\"]");

            TreeNode objNode = new TreeNode();
            Weapon objWeapon = new Weapon(_objCharacter);
            objWeapon.Create(objXmlWeapon, _objCharacter, objNode, cmsVehicleWeapon, cmsVehicleWeaponAccessory, cmsVehicleWeaponMod);
            objWeapon.VehicleMounted = true;

            int intCost = objWeapon.TotalCost;
            // Apply a markup if applicable.
            if (frmPickWeapon.Markup != 0)
            {
                double dblCost = Convert.ToDouble(intCost, GlobalOptions.Instance.CultureInfo);
                dblCost *= 1 + (Convert.ToDouble(frmPickWeapon.Markup, GlobalOptions.Instance.CultureInfo) / 100.0);
                intCost = Convert.ToInt32(dblCost);
            }

            if (!frmPickWeapon.FreeCost)
            {
                // Check the item's Cost and make sure the character can afford it.
                if (intCost > _objCharacter.Nuyen)
                {
                    MessageBox.Show(LanguageManager.Instance.GetString("Message_NotEnoughNuyen"), LanguageManager.Instance.GetString("MessageTitle_NotEnoughNuyen"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    if (frmPickWeapon.AddAgain)
                        tsVehicleAddWeaponWeapon_Click(sender, e);

                    return;
                }
                else
                {
                    // Create the Expense Log Entry.
                    ExpenseLogEntry objExpense = new ExpenseLogEntry();
                    objExpense.Create(intCost * -1, LanguageManager.Instance.GetString("String_ExpensePurchaseVehicleWeapon") + " " + objWeapon.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
                    _objCharacter.ExpenseEntries.Add(objExpense);
                    _objCharacter.Nuyen -= intCost;

                    ExpenseUndo objUndo = new ExpenseUndo();
                    objUndo.CreateNuyen(NuyenExpenseType.AddVehicleWeapon, objWeapon.InternalId);
                    objExpense.Undo = objUndo;
                }
            }

            objMod.Weapons.Add(objWeapon);

            objNode.ContextMenuStrip = cmsVehicleWeapon;
            treVehicles.SelectedNode.Nodes.Add(objNode);
            treVehicles.SelectedNode.Expand();

            if (frmPickWeapon.AddAgain)
                tsVehicleAddWeaponWeapon_Click(sender, e);

            UpdateCharacterInfo();

            _blnIsDirty = true;
            UpdateWindowTitle();
        }