Example #1
0
        /// <summary>
        /// Handler for clicking on Copy Bag from the context menu
        /// </summary>
        /// <param name="sender">sender object</param>
        /// <param name="e">EventArgs data</param>
        private void CopyBagClicked(object sender, EventArgs e)
        {
            ToolStripMenuItem item = (ToolStripMenuItem)sender;

            if (item != null)
            {
                int destinationIndex = VaultPanel.GetDestinationSackIndex(item.Name);

                if (destinationIndex > this.Player.NumberOfSacks)
                {
                    return;
                }

                if (!this.Player.GetSack(destinationIndex + this.BagPanelOffset).IsEmpty)
                {
                    if (Settings.Default.SuppressWarnings || MessageBox.Show(
                            Resources.PlayerOverwriteSackMsg,
                            Resources.PlayerOverwriteSack,
                            MessageBoxButtons.YesNo,
                            MessageBoxIcon.Question,
                            MessageBoxDefaultButton.Button1,
                            VaultPanel.RightToLeftOptions) != DialogResult.Yes)
                    {
                        return;
                    }
                }

                if (this.Player.CopySack(this.CurrentBag, destinationIndex))
                {
                    if (this.CurrentBag != destinationIndex)
                    {
                        // turn off the current bag and turn on the new bag
                        this.BagButtons[this.CurrentBag].IsOn  = false;
                        this.BagButtons[destinationIndex].IsOn = true;
                        this.CurrentBag               = destinationIndex;
                        this.BagSackPanel.Sack        = this.Player.GetSack(this.CurrentBag + this.BagPanelOffset);
                        this.BagSackPanel.CurrentSack = this.CurrentBag;
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        /// Handler for clicking move bag from the context menu
        /// </summary>
        /// <param name="sender">sender object</param>
        /// <param name="e">EventArgs data</param>
        private void MoveBagClicked(object sender, EventArgs e)
        {
            ToolStripMenuItem item = (ToolStripMenuItem)sender;

            if (item != null)
            {
                int destinationIndex = VaultPanel.GetDestinationSackIndex(item.Name);
                if (this.Player.MoveSack(this.CurrentBag, destinationIndex))
                {
                    if (this.CurrentBag != destinationIndex)
                    {
                        // turn off the current bag and turn on the new bag
                        this.BagButtons[this.CurrentBag].IsOn  = false;
                        this.BagButtons[destinationIndex].IsOn = true;
                        this.CurrentBag               = destinationIndex;
                        this.BagSackPanel.Sack        = this.Player.GetSack(this.CurrentBag + this.BagPanelOffset);
                        this.BagSackPanel.CurrentSack = this.CurrentBag;
                    }
                }
            }
        }
Example #3
0
        /// <summary>
        /// Used for sending items between sacks or panels.
        /// </summary>
        /// <param name="sender">sender object</param>
        /// <param name="e">SackPanelEventArgs data</param>
        private void AutoMoveItemCallback(object sender, SackPanelEventArgs e)
        {
            SackPanel sackPanel = (SackPanel)sender;

            // Make sure we have to move something.
            if (this.DragInfo.IsAutoMoveActive)
            {
                SackCollection oldSack = null;
                VaultPanel     destinationPlayerPanel = null;
                int            sackNumber             = 0;

                SackPanel destinationSackPanel = null;
                if (this.DragInfo.AutoMove < AutoMoveLocation.Vault)
                {
                    // This is a sack to sack move on the same panel.
                    destinationSackPanel = sackPanel;
                    switch (sackPanel.SackType)
                    {
                    case SackType.Vault:
                        if (sackPanel.IsSecondaryVault)
                        {
                            destinationPlayerPanel = this.secondaryVaultPanel;
                        }
                        else
                        {
                            destinationPlayerPanel = this.vaultPanel;
                        }
                        break;

                    default:
                        destinationPlayerPanel = this.playerPanel;
                        break;
                    }

                    sackNumber = (int)this.DragInfo.AutoMove;
                }
                else if (this.DragInfo.AutoMove == AutoMoveLocation.Vault)
                {
                    // Vault
                    destinationPlayerPanel = this.vaultPanel;
                    destinationSackPanel   = destinationPlayerPanel.SackPanel;
                    sackNumber             = destinationPlayerPanel.CurrentBag;
                }
                else if (this.DragInfo.AutoMove == AutoMoveLocation.Player)
                {
                    // Player
                    destinationPlayerPanel = this.playerPanel;
                    destinationSackPanel   = ((PlayerPanel)destinationPlayerPanel).SackPanel;

                    // Main Player panel
                    sackNumber = 0;
                }
                else if (this.DragInfo.AutoMove == AutoMoveLocation.SecondaryVault)
                {
                    // Secondary Vault
                    destinationPlayerPanel = this.secondaryVaultPanel;
                    destinationSackPanel   = destinationPlayerPanel.SackPanel;
                    sackNumber             = destinationPlayerPanel.CurrentBag;
                }

                // Special Case for moving to stash.
                if (this.DragInfo.AutoMove == AutoMoveLocation.Stash)
                {
                    // Check if we are moving to the player's stash
                    if (this.stashPanel.CurrentBag == 2 && this.stashPanel.Player == null)
                    {
                        // We have nowhere to send the item so cancel the move.
                        this.DragInfo.Cancel();
                        return;
                    }

                    // Check for the equipment panel
                    if (this.stashPanel.CurrentBag == 0)
                    {
                        // Equipment Panel is active so switch to the transfer stash.
                        this.stashPanel.CurrentBag = 1;
                    }

                    // Check the transfer stash
                    if (this.stashPanel.TransferStash == null && this.stashPanel.CurrentBag == 1)
                    {
                        // We have nowhere to send the item so cancel the move.
                        this.DragInfo.Cancel();
                        return;
                    }

                    // Check the relic vault stash
                    if (this.stashPanel.RelicVaultStash == null && this.stashPanel.CurrentBag == 3)
                    {
                        // We have nowhere to send the item so cancel the move.
                        this.DragInfo.Cancel();
                        return;
                    }

                    // See if we have an open space to put the item.
                    Point location = this.stashPanel.SackPanel.FindOpenCells(this.DragInfo.Item.Width, this.DragInfo.Item.Height);

                    // We have no space in the sack so we cancel.
                    if (location.X == -1)
                    {
                        this.DragInfo.Cancel();
                    }
                    else
                    {
                        Item dragItem = this.DragInfo.Item;

                        if (!this.stashPanel.SackPanel.IsItemValidForPlacement(dragItem))
                        {
                            this.DragInfo.Cancel();
                            return;
                        }

                        // Use the same method as if we used to mouse to pickup and place the item.
                        this.DragInfo.MarkPlaced();
                        dragItem.PositionX = location.X;
                        dragItem.PositionY = location.Y;
                        this.stashPanel.SackPanel.Sack.AddItem(dragItem);
                        this.lastSackPanelHighlighted.Invalidate();
                        this.stashPanel.Refresh();
                        BagButtonTooltip.InvalidateCache(this.stashPanel.SackPanel.Sack);
                    }
                }
                else
                {
                    // The stash is not involved.
                    if (destinationPlayerPanel == null || destinationPlayerPanel.Player == null)
                    {
                        // We have nowhere to send the item so cancel the move.
                        this.DragInfo.Cancel();
                        return;
                    }

                    // Save the current sack.
                    oldSack = destinationSackPanel.Sack;

                    // Find the destination sack.
                    destinationSackPanel.Sack = destinationPlayerPanel.Player.GetSack(sackNumber);

                    // See if we have an open space to put the item.
                    Point location = destinationSackPanel.FindOpenCells(this.DragInfo.Item.Width, this.DragInfo.Item.Height);

                    // CurrentBag only returns the values for the bag panels and is zero based.  Main sack is not included.
                    int destination = destinationPlayerPanel.CurrentBag;

                    // We need to accout for the player panel offsets.
                    if (sackPanel.SackType == SackType.Sack)
                    {
                        destination++;
                    }
                    else if (sackPanel.SackType == SackType.Player)
                    {
                        destination = 0;
                    }

                    // We either have no space or are sending the item to the same sack so we cancel.
                    if (location.X == -1 || (int)this.DragInfo.AutoMove == destination)
                    {
                        destinationSackPanel.Sack = oldSack;
                        this.DragInfo.Cancel();
                    }
                    else
                    {
                        Item dragItem = this.DragInfo.Item;

                        // Use the same method as if we used to mouse to pickup and place the item.
                        this.DragInfo.MarkPlaced();
                        dragItem.PositionX = location.X;
                        dragItem.PositionY = location.Y;
                        destinationSackPanel.Sack.AddItem(dragItem);

                        // Set it back to the original sack so the display does not change.
                        var destsack = destinationSackPanel.Sack;
                        destinationSackPanel.Sack = oldSack;
                        sackPanel.Invalidate();
                        destinationPlayerPanel.Refresh();
                        BagButtonTooltip.InvalidateCache(destsack, oldSack);
                    }
                }
            }
        }