Пример #1
0
        /// <summary>
        /// Handler for when the mouse leaves the BagButton
        /// </summary>
        /// <param name="sender">sender object</param>
        /// <param name="e">EventArgs data</param>
        private void MouseLeaveCallback(object sender, EventArgs e)
        {
            this.IsOver = false;
            Refresh();

            // Clear out the tooltip if it is being displayed.
            BagButtonTooltip.HideTooltip();
        }
Пример #2
0
        /// <summary>
        /// Callback for when the mouse enters the BagButton
        /// </summary>
        /// <param name="sender">sender object</param>
        /// <param name="e">EventArgs data</param>
        private void MouseEnterCallback(object sender, EventArgs e)
        {
            string tooltip = null;

            if (this.getToolTip != null)
            {
                tooltip = this.getToolTip(this);
                BagButtonTooltip.ShowTooltip(Program.MainFormInstance, this);
            }

            this.IsOver = true;
            Refresh();
        }
Пример #3
0
        /// <summary>
        /// Marks the item as placed removing it from the original container.
        /// </summary>
        /// <param name="slot">slot if an equipment placement.</param>
        public void MarkPlaced()
        {
            int slot = -1;

            // modified items do not have a source sack.
            // so no one needs to be notified of the placement.
            if (!this.IsModifiedItem)
            {
                // Check to see if the dragged item is from one of the equipped slots.
                if (this.sack.SackType == SackType.Equipment)
                {
                    slot = EquipmentPanel.FindEquipmentSlot(this.sack, this.item);
                }

                if (slot != -1)
                {
                    // Remove the item out of the equipment slot
                    this.sack.RemoveAtItem(slot);

                    // Put a dummy item in it's place
                    Item newItem = this.item.MakeEmptyItem();
                    newItem.PositionX = SackCollection.GetEquipmentLocationOffset(slot).X;
                    newItem.PositionY = SackCollection.GetEquipmentLocationOffset(slot).Y;
                    this.sack.InsertItem(slot, newItem);
                }
                else
                {
                    // Remove the item from the old sack
                    this.sack.RemoveItem(this.item);
                }

                BagButtonTooltip.InvalidateCache(this.Sack, this.Original?.Sack);
            }

            // finally clear things out
            this.item             = null;
            this.sack             = null;
            this.sackPanel        = null;
            this.original         = null;
            this.AutoMove         = AutoMoveLocation.NotSet;
            this.IsBeingCancelled = false;
        }
Пример #4
0
        /// <summary>
        /// Handler for clicking on the context menu
        /// </summary>
        /// <param name="sender">semder object</param>
        /// <param name="e">ToolStripItemClickedEventArgs data</param>
        private void ContextMenuItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            string selectedItem = e.ClickedItem.Text;

            if (selectedItem == Resources.PlayerPanelMenuEmpty)
            {
                if (Config.Settings.Default.SuppressWarnings || MessageBox.Show(
                        Resources.PlayerPanelEmptyMsg,
                        Resources.PlayerPanelEmpty,
                        MessageBoxButtons.YesNo,
                        MessageBoxIcon.Question,
                        MessageBoxDefaultButton.Button1,
                        PlayerPanel.RightToLeftOptions) == DialogResult.Yes)
                {
                    this.BagSackPanel.Sack.EmptySack();
                    this.BagSackPanel.Refresh();
                    BagButtonTooltip.InvalidateCache(this.BagSackPanel.Sack);
                }
            }
        }
Пример #5
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);
                    }
                }
            }
        }