コード例 #1
0
 public void UpdateOpponentCards(List <Card> cards, bool reset) => ListViewOpponent.Update(cards, reset);
コード例 #2
0
        private void UpdateCardTooltip()
        {
            //todo: if distance to left or right of overlay < tooltip width -> switch side
            var pos = User32.GetMousePos();
            var relativePlayerDeckPos   = StackPanelPlayer.PointFromScreen(new Point(pos.X, pos.Y));
            var relativeOpponentDeckPos = ListViewOpponent.PointFromScreen(new Point(pos.X, pos.Y));
            var relativeSecretsPos      = StackPanelSecrets.PointFromScreen(new Point(pos.X, pos.Y));
            var visibility = Config.Instance.OverlayCardToolTips ? Visibility.Visible : Visibility.Hidden;

            //player card tooltips
            if (PointInsideControl(relativePlayerDeckPos, ListViewPlayer.ActualWidth, ListViewPlayer.ActualHeight))
            {
                //card size = card list height / ammount of cards
                var cardSize  = ListViewPlayer.ActualHeight / ListViewPlayer.Items.Count;
                var cardIndex = (int)(relativePlayerDeckPos.Y / cardSize);
                if (cardIndex < 0 || cardIndex >= ListViewPlayer.Items.Count)
                {
                    return;
                }

                ToolTipCard.SetValue(DataContextProperty, ListViewPlayer.Items[cardIndex]);

                //offset is affected by scaling
                var topOffset = Canvas.GetTop(StackPanelPlayer) + cardIndex * cardSize * Config.Instance.OverlayPlayerScaling / 100;

                //prevent tooltip from going outside of the overlay
                if (topOffset + ToolTipCard.ActualHeight > Height)
                {
                    topOffset = Height - ToolTipCard.ActualHeight;
                }

                SetTooltipPosition(topOffset, StackPanelPlayer);

                ToolTipCard.Visibility = visibility;
            }
            //opponent card tooltips
            else if (PointInsideControl(relativeOpponentDeckPos, ListViewOpponent.ActualWidth, ListViewOpponent.ActualHeight))
            {
                //card size = card list height / ammount of cards
                var cardSize  = ListViewOpponent.ActualHeight / ListViewOpponent.Items.Count;
                var cardIndex = (int)(relativeOpponentDeckPos.Y / cardSize);
                if (cardIndex < 0 || cardIndex >= ListViewOpponent.Items.Count)
                {
                    return;
                }

                ToolTipCard.SetValue(DataContextProperty, ListViewOpponent.Items[cardIndex]);

                //offset is affected by scaling
                var topOffset = Canvas.GetTop(StackPanelOpponent) + cardIndex * cardSize * Config.Instance.OverlayOpponentScaling / 100;

                //prevent tooltip from going outside of the overlay
                if (topOffset + ToolTipCard.ActualHeight > Height)
                {
                    topOffset = Height - ToolTipCard.ActualHeight;
                }

                SetTooltipPosition(topOffset, StackPanelOpponent);

                ToolTipCard.Visibility = visibility;
            }
            else if (PointInsideControl(relativeSecretsPos, StackPanelSecrets.ActualWidth, StackPanelSecrets.ActualHeight))
            {
                //card size = card list height / ammount of cards
                var cardSize  = StackPanelSecrets.ActualHeight / StackPanelSecrets.Children.Count;
                var cardIndex = (int)(relativeSecretsPos.Y / cardSize);
                if (cardIndex < 0 || cardIndex >= StackPanelSecrets.Children.Count)
                {
                    return;
                }

                ToolTipCard.SetValue(DataContextProperty, StackPanelSecrets.Children[cardIndex].GetValue(DataContextProperty));

                //offset is affected by scaling
                var topOffset = Canvas.GetTop(StackPanelSecrets) + cardIndex * cardSize * Config.Instance.OverlayOpponentScaling / 100;

                //prevent tooltip from going outside of the overlay
                if (topOffset + ToolTipCard.ActualHeight > Height)
                {
                    topOffset = Height - ToolTipCard.ActualHeight;
                }

                SetTooltipPosition(topOffset, StackPanelSecrets);

                ToolTipCard.Visibility = visibility;
            }
            else
            {
                ToolTipCard.Visibility = Visibility.Hidden;
                HideAdditionalToolTips();
            }

            if (ToolTipCard.Visibility == Visibility.Visible)
            {
                var card = ToolTipCard.GetValue(DataContextProperty) as Card;
                if (card != null)
                {
                    if (_lastToolTipCardId != card.Id)
                    {
                        _lastToolTipCardId = card.Id;
                        ShowAdditionalToolTips();
                    }
                }
                else
                {
                    HideAdditionalToolTips();
                }
            }
            else
            {
                HideAdditionalToolTips();
                _lastToolTipCardId = string.Empty;
            }
        }
コード例 #3
0
        private async Task UpdateCardTooltip()
        {
            var pos = User32.GetMousePos();
            var relativePlayerDeckPos   = ListViewPlayer.PointFromScreen(new Point(pos.X, pos.Y));
            var relativeOpponentDeckPos = ListViewOpponent.PointFromScreen(new Point(pos.X, pos.Y));
            var relativeSecretsPos      = StackPanelSecrets.PointFromScreen(new Point(pos.X, pos.Y));
            var relativeCardMark        = _cardMarks.Select(x => new { Label = x, Pos = x.PointFromScreen(new Point(pos.X, pos.Y)) });
            var visibility = (Config.Instance.OverlayCardToolTips && !Config.Instance.OverlaySecretToolTipsOnly)
                                                                 ? Visible : Hidden;

            var cardMark =
                relativeCardMark.FirstOrDefault(
                    x =>
                    x.Label.IsVisible && PointInsideControl(x.Pos, x.Label.ActualWidth, x.Label.ActualHeight, new Thickness(3, 1, 7, 1)));

            if (!Config.Instance.HideOpponentCardMarks && cardMark != null)
            {
                var index = _cardMarks.IndexOf(cardMark.Label);
                var card  = Database.GetCardFromId(_game.Opponent.Hand[index].CardId);
                if (card != null)
                {
                    ToolTipCard.SetValue(DataContextProperty, card);
                    var topOffset  = Canvas.GetTop(_cardMarks[index]) + _cardMarks[index].ActualHeight;
                    var leftOffset = Canvas.GetLeft(_cardMarks[index]) + _cardMarks[index].ActualWidth * index;
                    Canvas.SetTop(ToolTipCard, topOffset);
                    Canvas.SetLeft(ToolTipCard, leftOffset);
                    ToolTipCard.Visibility = Config.Instance.OverlayCardMarkToolTips ? Visible : Hidden;
                }
            }
            //player card tooltips
            else if (ListViewPlayer.Visibility == Visible && StackPanelPlayer.Visibility == Visible &&
                     PointInsideControl(relativePlayerDeckPos, ListViewPlayer.ActualWidth, ListViewPlayer.ActualHeight))
            {
                //card size = card list height / ammount of cards
                var cardSize  = ListViewPlayer.ActualHeight / ListViewPlayer.Items.Count;
                var cardIndex = (int)(relativePlayerDeckPos.Y / cardSize);
                if (cardIndex < 0 || cardIndex >= ListViewPlayer.Items.Count)
                {
                    return;
                }

                ToolTipCard.SetValue(DataContextProperty, ListViewPlayer.Items[cardIndex]);

                //offset is affected by scaling
                var topOffset = Canvas.GetTop(StackPanelPlayer) + GetListViewOffset(StackPanelPlayer)
                                + cardIndex * cardSize * Config.Instance.OverlayPlayerScaling / 100;

                //prevent tooltip from going outside of the overlay
                if (topOffset + ToolTipCard.ActualHeight > Height)
                {
                    topOffset = Height - ToolTipCard.ActualHeight;
                }

                SetTooltipPosition(topOffset, StackPanelPlayer);

                ToolTipCard.Visibility = visibility;
            }
            //opponent card tooltips
            else if (ListViewOpponent.Visibility == Visible && StackPanelOpponent.Visibility == Visible &&
                     PointInsideControl(relativeOpponentDeckPos, ListViewOpponent.ActualWidth, ListViewOpponent.ActualHeight))
            {
                //card size = card list height / ammount of cards
                var cardSize  = ListViewOpponent.ActualHeight / ListViewOpponent.Items.Count;
                var cardIndex = (int)(relativeOpponentDeckPos.Y / cardSize);
                if (cardIndex < 0 || cardIndex >= ListViewOpponent.Items.Count)
                {
                    return;
                }

                ToolTipCard.SetValue(DataContextProperty, ListViewOpponent.Items[cardIndex]);

                //offset is affected by scaling
                var topOffset = Canvas.GetTop(StackPanelOpponent) + GetListViewOffset(StackPanelOpponent)
                                + cardIndex * cardSize * Config.Instance.OverlayOpponentScaling / 100;

                //prevent tooltip from going outside of the overlay
                if (topOffset + ToolTipCard.ActualHeight > Height)
                {
                    topOffset = Height - ToolTipCard.ActualHeight;
                }

                SetTooltipPosition(topOffset, StackPanelOpponent);

                ToolTipCard.Visibility = visibility;
            }
            else if (StackPanelSecrets.Visibility == Visible &&
                     PointInsideControl(relativeSecretsPos, StackPanelSecrets.ActualWidth, StackPanelSecrets.ActualHeight))
            {
                //card size = card list height / ammount of cards
                var cardSize  = StackPanelSecrets.ActualHeight / StackPanelSecrets.Children.Count;
                var cardIndex = (int)(relativeSecretsPos.Y / cardSize);
                if (cardIndex < 0 || cardIndex >= StackPanelSecrets.Children.Count)
                {
                    return;
                }

                ToolTipCard.SetValue(DataContextProperty, StackPanelSecrets.Children[cardIndex].GetValue(DataContextProperty));

                //offset is affected by scaling
                var topOffset = Canvas.GetTop(StackPanelSecrets) + cardIndex * cardSize * Config.Instance.OverlayOpponentScaling / 100;

                //prevent tooltip from going outside of the overlay
                if (topOffset + ToolTipCard.ActualHeight > Height)
                {
                    topOffset = Height - ToolTipCard.ActualHeight;
                }

                SetTooltipPosition(topOffset, StackPanelSecrets);

                ToolTipCard.Visibility = Config.Instance.OverlaySecretToolTipsOnly ? Visible : visibility;
            }
            else
            {
                ToolTipCard.Visibility = Hidden;
                HideAdditionalToolTips();
            }

            if (ToolTipCard.Visibility == Visible)
            {
                var card = ToolTipCard.GetValue(DataContextProperty) as Card;
                if (card != null)
                {
                    if (_lastToolTipCardId != card.Id)
                    {
                        _lastToolTipCardId = card.Id;
                        ShowAdditionalToolTips();
                    }
                }
                else
                {
                    HideAdditionalToolTips();
                }
            }
            else
            {
                HideAdditionalToolTips();
                _lastToolTipCardId = string.Empty;
            }


            if (!Config.Instance.ForceMouseHook)
            {
                if (Config.Instance.ExtraFeatures)
                {
                    var relativePos = PointFromScreen(new Point(pos.X, pos.Y));
                    if ((StackPanelSecrets.IsVisible &&
                         (PointInsideControl(StackPanelSecrets.PointFromScreen(new Point(pos.X, pos.Y)), StackPanelSecrets.ActualWidth,
                                             StackPanelSecrets.ActualHeight, new Thickness(20))) || relativePos.X < 170 && relativePos.Y > Height - 120))
                    {
                        if (_mouseInput == null)
                        {
                            HookMouse();
                        }
                    }
                    else if (_mouseInput != null && !((_isFriendsListOpen.HasValue && _isFriendsListOpen.Value) || await Helper.FriendsListOpen()))
                    {
                        UnHookMouse();
                    }
                }
                else if (_mouseInput != null)
                {
                    UnHookMouse();
                }
            }

            if (!Config.Instance.AlwaysShowGoldProgress)
            {
                if (_game.IsInMenu &&
                    PointInsideControl(RectGoldDisplay.PointFromScreen(new Point(pos.X, pos.Y)), RectGoldDisplay.ActualWidth,
                                       RectGoldDisplay.ActualHeight))
                {
                    UpdateGoldProgress();
                    GoldProgressGrid.Visibility = Visible;
                }
                else
                {
                    GoldProgressGrid.Visibility = Hidden;
                }
            }
        }