Exemplo n.º 1
0
        private void SaveChangesLocker_Click(object sender, EventArgs e)
        {
            if (LockerTree.SelectedNode == null)
            {
                return;
            }

            if (LockerTree.SelectedNode.Children.Count > 0)
            {
                return;
            }

            InventoryEntry entry = LockerTree.SelectedNode.GetEntry();

            int partcount = entry.GetPartCount();

            for (int Progress = 0; Progress < partcount; Progress++)
            {
                entry.Parts[Progress] = (string)PartsLocker.Items[Progress];
            }

            entry.UsesBigLevel = InventoryEntry.ItemgradePartUsesBigLevel((string)PartsLocker.Items[0]);

            entry.Quantity     = (int)RemAmmoLocker.Value;
            entry.QualityIndex = QualityLocker.Value;
            entry.EquippedSlot = 0;
            entry.LevelIndex   = LevelIndexLocker.Value;
            entry.IsJunk       = (int)JunkLocker.Value;
            entry.IsLocked     = (int)LockedLocker.Value;

            if (entry.Type == InventoryType.Weapon)
            {
                entry.RecalculateDataWeapon();
                entry.BuildName();
            }
            else if (entry.Type == InventoryType.Item)
            {
                entry.RecalculateDataItem();
                entry.BuildName();
            }
            else
            {
                System.Diagnostics.Debug.Assert(true, "Invalid item type in locker");
                entry.Name = "Invalid ItemType (" + entry.Type + ")";
            }

            // When the item changes, it may not belong in the same location in
            // in the sorted tree because the name, level, or other sort key
            // has changed.  Remove the node then place it back into the tree to
            // make sure it is relocated to the proper location, then select the
            // node and make sure it is visible so the user is focused on the new
            // location after the changes.
            LockerTL.RemoveFromTreeView(LockerTree.SelectedNode, false);
            LockerTL.AddToTreeView(entry);
            LockerTL.AdjustSelectionAfterAdd();
            LockerTree.EnsureVisible(LockerTree.SelectedNode);

            LockerPartsGroup.Text = entry.Name;
            LockerTree.Focus();
        }
Exemplo n.º 2
0
        private void saveGear(bool resetUI)
        {
            if (GearTree.SelectedNode == null)
            {
                return;
            }

            // Do nothing if it is a category not an item.
            if (GearTree.SelectedNode.Children.Count > 0)
            {
                return;
            }

            InventoryEntry gear = GearTree.SelectedNode.GetEntry();

            for (int Progress = 0; Progress < PartsGear.Items.Count; Progress++)
            {
                gear.Parts[Progress] = (string)PartsGear.Items[Progress];
            }

            gear.UsesBigLevel = InventoryEntry.ItemgradePartUsesBigLevel((string)PartsGear.Items[0]);
            gear.Quantity     = (int)QuantityGear.Value;
            gear.QualityIndex = QualityGear.Value;
            gear.EquippedSlot = EquippedSlotGear.SelectedIndex;
            gear.LevelIndex   = LevelIndexGear.Value;

            // Recalculate the gear stats
            if (GearTree.SelectedNode.GetEntry().Type == InventoryType.Weapon)
            {
                gear.RecalculateDataWeapon();
            }
            else if (GearTree.SelectedNode.GetEntry().Type == InventoryType.Item)
            {
                gear.RecalculateDataItem();
            }

            gear.BuildName();

            // When the item changes, it may not belong in the same location in
            // in the sorted tree because the name, level, or other sort key
            // has changed.  Remove the node then place it back into the tree to
            // make sure it is relocated to the proper location, then select the
            // node and make sure it is visible so the user is focused on the new
            // location after the changes.
            if (resetUI)
            {
                GearTL.RemoveFromTreeView(GearTree.SelectedNode, false);
                GearTL.AddToTreeView(gear);
                GearTL.AdjustSelectionAfterAdd();
                GearTree.EnsureVisible(GearTree.SelectedNode);
            }
            // Set the parts group page header to display the new name
            GearPartsGroup.Text = gear.Name;
        }