Beispiel #1
0
        /// <summary>
        /// Callback for highlighting a new item.
        /// Updates the text box on the main form.
        /// </summary>
        /// <param name="sender">sender object</param>
        /// <param name="e">SackPanelEventArgs data</param>
        private void NewItemHighlightedCallback(object sender, SackPanelEventArgs e)
        {
            Item           item      = e.Item;
            SackCollection sack      = e.Sack;
            SackPanel      sackPanel = (SackPanel)sender;

            if (item == null)
            {
                // Only do something if this sack is the "owner" of the current item highlighted.
                if (sack == this.lastSackHighlighted)
                {
                    this.itemText.Text = string.Empty;

                    // hide the tooltip
                    ItemTooltip.HideTooltip();
                }
            }
            else
            {
                var itt = ItemTooltip.ShowTooltip(this.ServiceProvider, item, sackPanel);

                this.itemText.ForeColor = itt.Data.Item.GetColor(itt.Data.BaseItemInfoDescription);
                this.itemText.Text      = itt.Data.FullNameBagTooltipClean;
            }

            this.lastSackHighlighted      = sack;
            this.lastSackPanelHighlighted = sackPanel;
        }
Beispiel #2
0
        /// <summary>
        /// Callback for highlighting a new item.
        /// Updates the text box on the main form.
        /// </summary>
        /// <param name="sender">sender object</param>
        /// <param name="e">SackPanelEventArgs data</param>
        private void NewItemHighlightedCallback(object sender, SackPanelEventArgs e)
        {
            Item           item      = e.Item;
            SackCollection sack      = e.Sack;
            SackPanel      sackPanel = (SackPanel)sender;

            if (item == null)
            {
                // Only do something if this sack is the "owner" of the current item highlighted.
                if (sack == this.lastSackHighlighted)
                {
                    this.itemText.Text = string.Empty;

                    // hide the tooltip
                    this.tooltipText = null;
                    this.tooltip.ChangeText(this.tooltipText);
                }
            }
            else
            {
                var result = ItemHtmlHelper.NewItemHighlightedTooltip(item);
                this.itemText.ForeColor = result.ForeColor;
                this.itemText.Text      = result.FriendlyName;
                this.tooltipText        = result.TooltipText;
                this.tooltip.ChangeText(this.tooltipText);
            }

            this.lastSackHighlighted      = sack;
            this.lastSackPanelHighlighted = sackPanel;
        }
Beispiel #3
0
        /// <summary>
        /// Callback for highlighting a new item.
        /// Updates the text box on the main form.
        /// </summary>
        /// <param name="sender">sender object</param>
        /// <param name="e">SackPanelEventArgs data</param>
        private void NewItemHighlightedCallback(object sender, SackPanelEventArgs e)
        {
            Item           item      = e.Item;
            SackCollection sack      = e.Sack;
            SackPanel      sackPanel = (SackPanel)sender;

            if (item == null)
            {
                // Only do something if this sack is the "owner" of the current item highlighted.
                if (sack == this.lastSackHighlighted)
                {
                    this.itemText.Text = string.Empty;

                    // hide the tooltip
                    this.tooltipText = null;
                    this.tooltip.ChangeText(this.tooltipText);
                }
            }
            else
            {
                string text  = ItemProvider.ToFriendlyName(item);
                Color  color = ItemGfxHelper.GetColorTag(item, text);
                text = Item.ClipColorTag(text);
                this.itemText.ForeColor = color;
                this.itemText.Text      = text;

                string attributes = ItemHtmlHelper.GetAttributes(item, true);                 // true means hide uninteresting attributes
                string setitems   = ItemHtmlHelper.GetItemSetString(item);
                string reqs       = ItemHtmlHelper.GetRequirements(item);

                // combine the 2
                if (reqs.Length < 1)
                {
                    this.tooltipText = attributes;
                }
                else if (setitems.Length < 1)
                {
                    string reqTitle = HtmlHelper.MakeSafeForHtml("?Requirements?");
                    reqTitle = string.Format(CultureInfo.InvariantCulture, "<font size=+2 color={0}>{1}</font><br>", HtmlHelper.HtmlColor(ItemGfxHelper.GetColor(ItemStyle.Potion)), reqTitle);
                    string separator = string.Format(CultureInfo.InvariantCulture, "<hr color={0}><br>", HtmlHelper.HtmlColor(ItemGfxHelper.GetColor(ItemStyle.Broken)));
                    this.tooltipText = string.Concat(attributes, separator, reqs);
                }
                else
                {
                    string reqTitle = HtmlHelper.MakeSafeForHtml("?Requirements?");
                    reqTitle = string.Format(CultureInfo.InvariantCulture, "<font size=+2 color={0}>{1}</font><br>", HtmlHelper.HtmlColor(ItemGfxHelper.GetColor(ItemStyle.Potion)), reqTitle);
                    string separator1 = string.Format(CultureInfo.InvariantCulture, "<hr color={0}>", HtmlHelper.HtmlColor(ItemGfxHelper.GetColor(ItemStyle.Broken)));
                    string separator2 = string.Format(CultureInfo.InvariantCulture, "<hr color={0}><br>", HtmlHelper.HtmlColor(ItemGfxHelper.GetColor(ItemStyle.Broken)));
                    this.tooltipText = string.Concat(attributes, separator1, setitems, separator2, reqs);
                }

                // show tooltip
                this.tooltipText = string.Concat(HtmlHelper.TooltipBodyTag(Database.DB.Scale), this.tooltipText);
                this.tooltip.ChangeText(this.tooltipText);
            }

            this.lastSackHighlighted      = sack;
            this.lastSackPanelHighlighted = sackPanel;
        }
Beispiel #4
0
 /// <summary>
 /// Used to clear the selection when a bag button is clicked.
 /// </summary>
 /// <param name="sender">sender object</param>
 /// <param name="e">SackPanelEventArgs data</param>
 private void ClearAllItemsSelectedCallback(object sender, SackPanelEventArgs e)
 {
     this.playerPanel.SackPanel.ClearSelectedItems();
     this.playerPanel.BagSackPanel.ClearSelectedItems();
     this.vaultPanel.SackPanel.ClearSelectedItems();
     this.secondaryVaultPanel.SackPanel.ClearSelectedItems();
     this.stashPanel.SackPanel.ClearSelectedItems();
 }
Beispiel #5
0
        /// <summary>
        /// Used to clear out selections on other panels if the user tries to select across multiple panels.
        /// </summary>
        /// <param name="sender">sender object</param>
        /// <param name="e">SackPanelEventArgs data</param>
        private void ItemSelectedCallback(object sender, SackPanelEventArgs e)
        {
            SackPanel sackPanel = (SackPanel)sender;

            if (this.playerPanel.SackPanel == sackPanel)
            {
                this.playerPanel.BagSackPanel.ClearSelectedItems();
                this.vaultPanel.SackPanel.ClearSelectedItems();
                this.secondaryVaultPanel.SackPanel.ClearSelectedItems();
                this.stashPanel.SackPanel.ClearSelectedItems();
            }
            else if (this.playerPanel.BagSackPanel == sackPanel)
            {
                this.playerPanel.SackPanel.ClearSelectedItems();
                this.vaultPanel.SackPanel.ClearSelectedItems();
                this.secondaryVaultPanel.SackPanel.ClearSelectedItems();
                this.stashPanel.SackPanel.ClearSelectedItems();
            }
            else if (this.vaultPanel.SackPanel == sackPanel)
            {
                this.playerPanel.SackPanel.ClearSelectedItems();
                this.playerPanel.BagSackPanel.ClearSelectedItems();
                this.secondaryVaultPanel.SackPanel.ClearSelectedItems();
                this.stashPanel.SackPanel.ClearSelectedItems();
            }
            else if (this.secondaryVaultPanel.SackPanel == sackPanel)
            {
                this.playerPanel.SackPanel.ClearSelectedItems();
                this.playerPanel.BagSackPanel.ClearSelectedItems();
                this.vaultPanel.SackPanel.ClearSelectedItems();
                this.stashPanel.SackPanel.ClearSelectedItems();
            }
            else if (this.stashPanel.SackPanel == sackPanel)
            {
                this.playerPanel.SackPanel.ClearSelectedItems();
                this.playerPanel.BagSackPanel.ClearSelectedItems();
                this.vaultPanel.SackPanel.ClearSelectedItems();
                this.secondaryVaultPanel.SackPanel.ClearSelectedItems();
            }
        }
Beispiel #6
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);
                    }
                }
            }
        }
Beispiel #7
0
 /// <summary>
 /// Callback for activating the search text box.
 /// Used when a hot key is pressed.
 /// </summary>
 /// <param name="sender">sender object</param>
 /// <param name="e">SackPanelEventArgs data</param>
 private void ActivateSearchCallback(object sender, SackPanelEventArgs e)
 => this.OpenSearchDialog();
Beispiel #8
0
 /// <summary>
 /// Clear all selected items Callback
 /// </summary>
 /// <param name="sender">sender object</param>
 /// <param name="e">SackPanelEventArgs data</param>
 protected void ClearAllItemsSelectedCallback(object sender, SackPanelEventArgs e)
 {
     this.OnClearAllItemsSelected(sender, e);
 }
Beispiel #9
0
 /// <summary>
 /// Item Selected Callback
 /// </summary>
 /// <param name="sender">sender object</param>
 /// <param name="e">SackPanelEventArgs data</param>
 protected void ItemSelectedCallback(object sender, SackPanelEventArgs e)
 {
     this.OnItemSelected(sender, e);
 }
Beispiel #10
0
 /// <summary>
 /// Activate Search Callback
 /// </summary>
 /// <param name="sender">sender object</param>
 /// <param name="e">SackPanelEventArgs data</param>
 protected void ActivateSearchCallback(object sender, SackPanelEventArgs e)
 {
     this.OnActivateSearch(sender, e);
 }
Beispiel #11
0
 /// <summary>
 /// Automove Item Callback
 /// </summary>
 /// <param name="sender">sender object</param>
 /// <param name="e">SackPanelEventArgs data</param>
 protected void AutoMoveItemCallback(object sender, SackPanelEventArgs e)
 {
     this.OnAutoMoveItem(sender, e);
 }
Beispiel #12
0
 /// <summary>
 /// New Item Highlighted Callback
 /// </summary>
 /// <param name="sender">sender object</param>
 /// <param name="e">SackPanelEventArgs data</param>
 protected void NewItemHighlightedCallback(object sender, SackPanelEventArgs e)
 {
     this.OnNewItemHighlighted(sender, e);
 }