Ejemplo n.º 1
0
        private void DataGridHitFreqClick(object sender, RoutedEventArgs e)
        {
            if (dataGrid.SelectedItems.Count == 1)
            {
                var chart   = new HitFreqChart();
                var results = DamageStatsManager.GetHitFreqValues(dataGrid.SelectedItems.Cast <PlayerStats>().First(), CurrentStats);

                var main          = Application.Current.MainWindow as MainWindow;
                var hitFreqWindow = Helpers.OpenNewTab(main.dockSite, "freqChart", "Hit Frequency", chart, 400, 300);

                chart.Update(results);
                hitFreqWindow.CanFloat = true;
                hitFreqWindow.CanClose = true;
            }
        }
Ejemplo n.º 2
0
        private void UpdateTimerTick(object sender, EventArgs e)
        {
            lock (StatsLock)
            {
                try
                {
                    Topmost = true; // possible workaround

                    // people wanted shorter delays for damage updates but I don't want the indicator to change constantly
                    // so this limits it to 1/2 the current time value
                    ProcessDirection = !ProcessDirection;

                    Stats = DamageStatsManager.ComputeOverlayStats(CurrentDamageSelectionMode, CurrentMaxRows, SelectedClass);

                    if (Stats == null)
                    {
                        windowBrush.Opacity = 0.0;
                        ButtonPopup.IsOpen  = false;
                        SetVisible(false);
                        Height   = 0;
                        PrevList = null;
                        UpdateTimer.Stop();
                        DataManager.Instance.ResetOverlayFights();
                    }
                    else if (Active)
                    {
                        TitleBlock.Text       = Stats.TargetTitle;
                        TitleDamageBlock.Text = string.Format(CultureInfo.CurrentCulture, "{0} [{1}s @{2}]",
                                                              StatsUtil.FormatTotals(Stats.RaidStats.Total), Stats.RaidStats.TotalSeconds, StatsUtil.FormatTotals(Stats.RaidStats.DPS));

                        long total        = 0;
                        int  goodRowCount = 0;
                        long me           = 0;
                        var  topList      = new Dictionary <int, long>();
                        for (int i = 0; i < CurrentMaxRows; i++)
                        {
                            if (Stats.StatsList.Count > i)
                            {
                                if (ProcessDirection)
                                {
                                    DamageRateList[i].Opacity = 0.0;
                                }

                                if (i == 0)
                                {
                                    total = Stats.StatsList[i].Total;
                                    RectangleList[i].Width = Width;
                                }
                                else
                                {
                                    RectangleList[i].Visibility = Visibility.Hidden; // maybe it calculates width better
                                    RectangleList[i].Width      = Convert.ToDouble(Stats.StatsList[i].Total) / total * Width;
                                }

                                string playerName = ConfigUtil.PlayerName;
                                var    isMe       = !string.IsNullOrEmpty(playerName) && Stats.StatsList[i].Name.StartsWith(playerName, StringComparison.OrdinalIgnoreCase) &&
                                                    (playerName.Length >= Stats.StatsList[i].Name.Length || Stats.StatsList[i].Name[playerName.Length] == ' ');

                                string updateText;
                                if (IsHideOverlayOtherPlayersEnabled && !isMe)
                                {
                                    updateText             = string.Format(CultureInfo.CurrentCulture, "{0}. Hidden Player", Stats.StatsList[i].Rank);
                                    NameIconList[i].Source = PlayerManager.UNK_ICON;
                                }
                                else
                                {
                                    updateText             = string.Format(CultureInfo.CurrentCulture, "{0}. {1}", Stats.StatsList[i].Rank, Stats.StatsList[i].Name);
                                    NameIconList[i].Source = PlayerManager.Instance.GetPlayerIcon(Stats.StatsList[i].OrigName);
                                }

                                if (IsShowOverlayCritRateEnabled)
                                {
                                    List <string> critMods = new List <string>();

                                    if (isMe && PlayerManager.Instance.IsDoTClass(Stats.StatsList[i].ClassName) && DataManager.Instance.MyDoTCritRateMod is uint doTCritRate && doTCritRate > 0)
                                    {
                                        critMods.Add(string.Format(CultureInfo.CurrentCulture, "DoT CR +{0}", doTCritRate));
                                    }

                                    if (isMe && DataManager.Instance.MyNukeCritRateMod is uint nukeCritRate && nukeCritRate > 0)
                                    {
                                        critMods.Add(string.Format(CultureInfo.CurrentCulture, "Nuke CR +{0}", nukeCritRate));
                                    }

                                    if (critMods.Count > 0)
                                    {
                                        updateText = string.Format(CultureInfo.CurrentCulture, "{0} [{1}]", updateText, string.Join(", ", critMods));
                                    }
                                }

                                NameBlockList[i].Text = updateText;

                                if (i <= 4 && !isMe && Stats.StatsList[i].Total > 0)
                                {
                                    topList[i] = Stats.StatsList[i].Total;
                                }
                                else if (isMe)
                                {
                                    me = Stats.StatsList[i].Total;
                                }

                                var damage = StatsUtil.FormatTotals(Stats.StatsList[i].Total) + " [" + Stats.StatsList[i].TotalSeconds.ToString(CultureInfo.CurrentCulture)
                                             + "s @" + StatsUtil.FormatTotals(Stats.StatsList[i].DPS) + "]";
                                DamageBlockList[i].Text = damage;
                                goodRowCount++;
                            }
                        }

                        if (ProcessDirection)
                        {
                            if (me > 0 && topList.Count > 0)
                            {
                                var updatedList = new Dictionary <int, double>();
                                foreach (int i in topList.Keys)
                                {
                                    if (i != me)
                                    {
                                        var diff = topList[i] / (double)me;
                                        updatedList[i] = diff;
                                        if (PrevList != null && PrevList.ContainsKey(i))
                                        {
                                            if (PrevList[i] > diff)
                                            {
                                                DamageRateList[i].Icon       = FontAwesomeIcon.LongArrowDown;
                                                DamageRateList[i].Foreground = OverlayUtil.DOWNBRUSH;
                                                DamageRateList[i].Opacity    = OverlayUtil.DATA_OPACITY;
                                            }
                                            else if (PrevList[i] < diff)
                                            {
                                                DamageRateList[i].Icon       = FontAwesomeIcon.LongArrowUp;
                                                DamageRateList[i].Foreground = OverlayUtil.UPBRUSH;
                                                DamageRateList[i].Opacity    = OverlayUtil.DATA_OPACITY;
                                            }
                                        }
                                    }
                                }

                                PrevList = updatedList;
                            }
                            else
                            {
                                PrevList = null;
                            }
                        }

                        var requested = (goodRowCount + 1) * CalculatedRowHeight;
                        if (ActualHeight != requested)
                        {
                            Height = requested;
                        }

                        if (overlayCanvas.Visibility != Visibility.Visible)
                        {
                            overlayCanvas.Visibility    = Visibility.Hidden;
                            TitleRectangle.Visibility   = Visibility.Hidden;
                            TitlePanel.Visibility       = Visibility.Hidden;
                            TitleDamagePanel.Visibility = Visibility.Hidden;
                            TitleRectangle.Height       = CalculatedRowHeight;
                            TitleDamagePanel.Height     = CalculatedRowHeight;
                            TitlePanel.Height           = CalculatedRowHeight;
                            overlayCanvas.Visibility    = Visibility.Visible;
                            TitleRectangle.Visibility   = Visibility.Visible;
                            TitlePanel.Visibility       = Visibility.Visible;
                            TitleDamagePanel.Visibility = Visibility.Visible;
                            windowBrush.Opacity         = OverlayUtil.OPACITY;
                            ButtonPopup.IsOpen          = true;
                        }

                        for (int i = 0; i < CurrentMaxRows; i++)
                        {
                            SetRowVisible(i < goodRowCount, i);
                        }
                    }
                }
                catch (Exception ex)
                {
                    LOG.Error("Overlay Error", ex);
                }
            }
        }